<commit_before>(function (exports, requirejs, define, window, XMLHttpRequest) {
    /** ECMA SCRIPT COMPLIANT**/
    if (!String.prototype.trim) {
        String.prototype.trim = function () {
            return this.replace(/^\s+|\s+$/g, '');
        };
    }

    var underscore,
        Bus,
        Stage,
        document = window.document; // TODO: create workaround for node

    /***
     * marks a function to be executed asycn
     * @return {*}
     */
    Function.prototype.async = function () {
        this._async = true;
        return this;
    };

    var xamlApplication = /^(xaml!)?(.+?)(\.xml)?$/;

    var Rewrite = function (from, to) {
            this.$from = from;
            this.$to = to;
        },
        defaultNamespaceMap = {
            "http://www.w3.org/1999/xhtml": "js.html",
            "http://www.w3.org/2000/svg": "js.svg"
        },
        defaultRewriteMap = [
            new Rewrite(/^js\/html\/(a)$/, "js/html/a"),
            new Rewrite(/^js\/html\/(input)$/, "js/html/Input"),
            new Rewrite(/^js\/html\/(select)$/, "js/html/Select"),
            new Rewrite(/^js\/html\/(textarea)$/, "js/html/TextArea"),
            new Rewrite(/^js\/html\/(option)$/, "js/html/Option"),
            new Rewrite(/^js\/html\/(.+)$/, "js/html/HtmlElement"),

            new Rewrite(/^js\/svg\/svg$/, "js/svg/Svg"),
            new Rewrite(/^js\/svg\/(.+)$/, "js/svg/SvgElement")
        ];

    if (typeof JSON !== "undefined") {
        define("JSON", function () {
            return JSON;
        });
    } else {
        requirejs.config({
            paths: {
                JSON: "js/lib/json2"
            },
            shim: {
                JSON: {
                    exports: "JSON"
                }
            }
        });
    }

    requirejs.config({
        paths: {
            json: "js/plugins/json"
        }
    });

    var rAppid = {

        createApplicationContext: function (mainClass, config, callback) {

            config = config || {};

            var internalCreateApplicationContext = function (config) {

                config.xamlClasses = config.xamlClasses || [];
                config.namespaceMap = config.namespaceMap || defaultNamespaceMap;
                config.rewriteMap = config.rewriteMap || defaultRewriteMap;

                var requirejsContext = requirejs.config(config),
                    applicationContext = new ApplicationContext(requirejsContext, config);

                define("applicationContext", function () {
                    return applicationContext;
                });

                if (typeof JSON !== "undefined") {
                    define("JSON", function () {
                        return JSON;
                    });
                }

                requirejsContext(["inherit", "underscore", "js/core/Bus", "js/core/Stage"], function (inherit, _, b, s) {
                    // we have to load inherit.js in order that inheritance is working
                    underscore = _;
                    Bus = b;
                    Stage = s;

                    if (inherit && _) {

                        if (mainClass) {
                            //TODO: have a look at xamlClasses
                            var parts = xamlApplication.exec(mainClass);
                            if (parts) {
                                // mainClass is xaml
                                mainClass = "xaml!" + parts[2];
                            } else {
                                // mainClass is javascript factory
                                mainClass = mainClass.replace(/\./g, "/");
                            }

                            requirejsContext([mainClass], function (applicationFactory) {
                                applicationContext.$applicationFactory = applicationFactory;
                                callback(null, applicationContext);
                            }, function (err) {
                                callback(err);
                            });
                        } else {
                            callback(null, applicationContext);
                        }

                    } else {
                        callback("inherit or underscore missing");
                    }
                });

            };

            if (Object.prototype.toString.call(config) == '[object String]') {
                requirejs(["json!" + config], function (config) {
                    internalCreateApplicationContext(config);
                });
            } else {
                internalCreateApplicationContext(config);
            }

        },

        /***
         *
         * @param {js.core.Application} mainClass the application main class to load and start
         * @param {Element} [target=document.body] the target where the application is rendered
         * @param {Object} [parameter] an object defining the parameters passed to the Application.start method
         * @param {String|Object} [config=config.json] filename of the config file to load or configuration object
         * @param {Function} [callback] callback function in the form function (err, systemManager, application)
         */
        bootStrap: function (mainClass, target, parameter, config, callback) {

            parameter = parameter || {};

            if (typeof window !== 'undefined' && window.location && !parameter.initialHash) {
                var param = window.location.search.replace(/^\?/, '').split('&');
                for (var i = 0; i < param.length; i++) {
                    var result = /^([^=]+)=(.*)$/.exec(param[i]);
                    if (result && result[1] === 'fragment') {

                        var redirectUrl = location.protocol + '//' + location.host + location.pathname;
                        param.splice(i, 1);

                        if (param.length) {
                            redirectUrl += '?' + param.join('&');
                        }

                        redirectUrl += '#' + result[2];
                        window.location = redirectUrl;

                        return;
                    }
                }
            }

            if (!target && document && document.body) {
                // render default into document.body
                target = document.body;
            }

            config = config || "config.json";

            callback = callback || function () {
            };

            if (!document) {
                callback("Document missing");
                return;
            }

            if (!target) {
                callback("Target missing");
                return;
            }

            // flow.js is not available here, so do it in a dirty way
            rAppid.createApplicationContext(mainClass, config, function (err, applicationContext) {
                if (err) {
                    callback(err);
                } else {
                    applicationContext.createApplicationInstance(window, function (err, stage, application) {
                        if (err) {
                            callback(err);
                        } else {

                            // start the application
                            application.start(parameter, function (err) {
                                if (err) {
                                    callback(err);
                                } else {
                                    // render stage to target
                                    stage.render(target);

                                    callback(null, stage, application);
                                }
                            })
                        }
                    })
                }
            });

        },

        rewriteMapEntry: Rewrite,

        createQueryString: function (parameter) {
            var ret = [];

            for (var key in parameter) {
                if (parameter.hasOwnProperty(key)) {
                    ret.push(encodeURIComponent(key) + "=" + encodeURIComponent(parameter[key]));
                }
            }

            return ret.join("&");
        },

        ajax: function (url, options, callback) {

            var s = {
                url: url
            };

            underscore.extend(s, rAppid.ajaxSettings, options);

            if (s.data && !underscore.isString(s.data)) {
                throw "data must be a string";
            }

            s.hasContent = !/^(?:GET|HEAD)$/.test(s.type);

            if (s.queryParameter && underscore.keys(s.queryParameter).length > 0) {
                // append query parameter to url
                s.url += /\?/.test(s.url) ? "&" : "?" + this.createQueryString(s.queryParameter);
            }

            // create new xhr
            var xhr = s.xhr();
            xhr.open(s.type, s.url, s.async);

            if (s.hasContent && s.contentType !== false) {
                xhr.setRequestHeader("Content-Type", s.contentType);
                if(typeof window === "undefined"){
                    // On NodeJs the XMLHttprequest does not set Content-Length
                    // In the browser it's not allowed to set the Content-length
                    xhr.setRequestHeader("Content-Length", s.data ? s.data.length.toString() : "0");
                }
            }

            try {
                for (var header in s.headers) {
                    if (s.headers.hasOwnProperty(header)) {
                        xhr.setRequestHeader(header, s.headers[header]);
                    }
                }
            } catch(e) {
            } // FF3

            xhr.send(s.data);

            var xhrCallback = function (_, isAbort) {

                var wrappedXhr;

                if (xhrCallback && (isAbort || xhr.readyState === 4)) {
                    xhrCallback = undefined;

                    if (isAbort) {
                        // Abort it manually if needed
                        if (xhr.readyState !== 4) {
                            xhr.abort();
                        }
                    } else {
                        wrappedXhr = new rAppidXhr(xhr);
                    }

                    if (callback) {
                        callback(isAbort, wrappedXhr)
                    }
                }
            };

            if (!s.async || xhr.readyState === 4) {
                xhrCallback();
            } else {
                xhr.onreadystatechange = xhrCallback
            }

            return xhr;
        }
    };

    var rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg; // IE leaves an \r character at EOL

    var rAppidXhr = function (xhr) {
        this.xhr = xhr;
        this.status = xhr.status;
        this.$nativeResponseHeaders = xhr.getAllResponseHeaders();
        this.responses = {};

        var xml = xhr.responseXML;

        // Construct response list
        if (xml && xml.documentElement) {
            this.responses.xml = xml;
        }
        this.responses.text = xhr.responseText;

        try {
            this.statusText = xhr.statusText;
        } catch(e) {
            this.statusText = "";
        }
    };

    rAppidXhr.prototype.getResponseHeader = function (key) {
        var match;
        if (!this.$responseHeaders) {
            this.$responseHeaders = {};
            while (( match = rheaders.exec(this.$nativeResponseHeaders) )) {
                this.$responseHeaders[match[1].toLowerCase()] = match[2];
            }
        }
        return this.$responseHeaders[key.toLowerCase()];
    };

    rAppid.ajaxSettings = {
        type: "GET",
        contentType: "application/x-www-form-urlencoded",
        async: true,
        xhr: function () {
            return new XMLHttpRequest();
        },
        headers: {
        },
        data: null
    };

    var ApplicationContext = function (requirejsContext, config) {
        this.$requirejsContext = requirejsContext;
        this.$config = config;
    };

    ApplicationContext.prototype.createApplicationInstance = function (window, callback) {

        var document;

        // create instance
        var applicationFactory = this.$applicationFactory;

        if (window.document) {
            document = window.document;
        } else {
            document = window;
            window = null;
        }

        // TODO: add node support for window
        var stage = new Stage(this.$requirejsContext, this, document, window);

        this.$requirejsContext(["js/core/Application", "js/core/HeadManager", "js/core/History", "js/core/Injection"], function (Application, HeadManager, History, Injection) {
            stage.$headManager = new HeadManager(document);
            stage.$bus = new Bus();
            stage.$history = new History();
            var injection = stage.$injection = new Injection(null, null, stage);

            injection.addInstance(stage.$bus);
            injection.addInstance(stage.$history);
            injection.addInstance(stage.$headManager);

            var application = new applicationFactory(null, false, stage, null, null);

            if (application instanceof Application) {

                stage.$application = application;
                stage._initialize("auto");

                application._initialize("auto");

                // return rAppid instance
                if (callback) {
                    callback(null, stage, application);
                }

            } else {
                var errMessage = "mainClass isn't an instance of js.core.Application";
                if (callback) {
                    callback(errMessage);
                } else {
                    throw(errMessage);
                }
            }
        });

    };

    ApplicationContext.prototype.getFqClassName = function (namespace, className, useRewriteMap) {
        if (useRewriteMap == undefined || useRewriteMap == null) {
            useRewriteMap = true;
        }

        if (namespace && className) {
            namespace = (this.$config.namespaceMap[namespace] || namespace).replace(/\./g, '/');
            var fqClassName = [namespace, className].join("/");
        } else {
            fqClassName = (namespace || className).replace(/\./g, '/');
        }

        if (underscore.indexOf(this.$config.xamlClasses, fqClassName) !== -1) {
            fqClassName = 'xaml!' + fqClassName;
        }

        if (useRewriteMap) {
            for (var i = 0; i < this.$config.rewriteMap.length; i++) {
                var entry = this.$config.rewriteMap[i];
                if (entry instanceof rAppid.rewriteMapEntry) {
                    if (entry.$from.test(fqClassName)) {
                        return fqClassName.replace(entry.$from, entry.$to);
                    }
                }
            }
        }

        return fqClassName;
    };

    ApplicationContext.prototype.createInstance = function (fqClassName, args, className) {
        args = args || [];

        var classDefinition;

        if (fqClassName instanceof Function) {
            classDefinition = fqClassName;
            fqClassName = classDefinition.prototype.constructor.name;
        } else {
            fqClassName = fqClassName.replace(/\./g, "/");
            classDefinition = this.$requirejsContext(fqClassName);
        }

        className = className || fqClassName;

        function construct(constructor, args) {
            function F() {
                return constructor.apply(this, args);
            }

            F.prototype = constructor.prototype;
            return new F();
        }

        var ret;
        try {
            ret = construct(classDefinition, args);
            ret.className = className;
        } catch(e) {
            console.warn(["Cannot create instance of '" + fqClassName + "'", e, args]);
        }

        return ret;
    };

    ApplicationContext.prototype.ajax = function (url, options, callback) {

        if (!(/^http.*$/.test(url)) && this.$config.applicationUrl) {
            url = this.$config.applicationUrl + '/' + url;
        }

        rAppid.ajax(url, options, callback);
    };

    rAppid.defaultNamespaceMap = defaultNamespaceMap;
    rAppid.defaultRewriteMap = defaultRewriteMap;
    rAppid.ApplicationContext = ApplicationContext;
    rAppid.Rewrite = Rewrite;

    exports.rAppid = rAppid;

}(typeof exports !== "undefined" ? exports : window,
    typeof requirejs !== "undefined" ? requirejs : require('requirejs'),
    typeof requirejs !== "undefined" ? define : require('requirejs').define,
    typeof window !== "undefined" ? window : exports,
    typeof window !== "undefined" ? window.XMLHttpRequest : require('xmlhttprequest').XMLHttpRequest));
<commit_msg>moved bus requiring into Stage<commit_after>(function (exports, requirejs, define, window, XMLHttpRequest) {
    /** ECMA SCRIPT COMPLIANT**/
    if (!String.prototype.trim) {
        String.prototype.trim = function () {
            return this.replace(/^\s+|\s+$/g, '');
        };
    }

    var underscore,
        Stage,
        document = window.document; // TODO: create workaround for node

    /***
     * marks a function to be executed asycn
     * @return {*}
     */
    Function.prototype.async = function () {
        this._async = true;
        return this;
    };

    var xamlApplication = /^(xaml!)?(.+?)(\.xml)?$/;

    var Rewrite = function (from, to) {
            this.$from = from;
            this.$to = to;
        },
        defaultNamespaceMap = {
            "http://www.w3.org/1999/xhtml": "js.html",
            "http://www.w3.org/2000/svg": "js.svg"
        },
        defaultRewriteMap = [
            new Rewrite(/^js\/html\/(a)$/, "js/html/a"),
            new Rewrite(/^js\/html\/(input)$/, "js/html/Input"),
            new Rewrite(/^js\/html\/(select)$/, "js/html/Select"),
            new Rewrite(/^js\/html\/(textarea)$/, "js/html/TextArea"),
            new Rewrite(/^js\/html\/(option)$/, "js/html/Option"),
            new Rewrite(/^js\/html\/(.+)$/, "js/html/HtmlElement"),

            new Rewrite(/^js\/svg\/svg$/, "js/svg/Svg"),
            new Rewrite(/^js\/svg\/(.+)$/, "js/svg/SvgElement")
        ];

    if (typeof JSON !== "undefined") {
        define("JSON", function () {
            return JSON;
        });
    } else {
        requirejs.config({
            paths: {
                JSON: "js/lib/json2"
            },
            shim: {
                JSON: {
                    exports: "JSON"
                }
            }
        });
    }

    requirejs.config({
        paths: {
            json: "js/plugins/json"
        }
    });

    var rAppid = {

        createApplicationContext: function (mainClass, config, callback) {

            config = config || {};

            var internalCreateApplicationContext = function (config) {

                config.xamlClasses = config.xamlClasses || [];
                config.namespaceMap = config.namespaceMap || defaultNamespaceMap;
                config.rewriteMap = config.rewriteMap || defaultRewriteMap;

                var requirejsContext = requirejs.config(config),
                    applicationContext = new ApplicationContext(requirejsContext, config);

                define("applicationContext", function () {
                    return applicationContext;
                });

                if (typeof JSON !== "undefined") {
                    define("JSON", function () {
                        return JSON;
                    });
                }

                requirejsContext(["inherit", "underscore", "js/core/Stage"], function (inherit, _, s) {
                    // we have to load inherit.js in order that inheritance is working
                    underscore = _;
                    Stage = s;

                    if (inherit && _) {

                        if (mainClass) {
                            //TODO: have a look at xamlClasses
                            var parts = xamlApplication.exec(mainClass);
                            if (parts) {
                                // mainClass is xaml
                                mainClass = "xaml!" + parts[2];
                            } else {
                                // mainClass is javascript factory
                                mainClass = mainClass.replace(/\./g, "/");
                            }

                            requirejsContext([mainClass], function (applicationFactory) {
                                applicationContext.$applicationFactory = applicationFactory;
                                callback(null, applicationContext);
                            }, function (err) {
                                callback(err);
                            });
                        } else {
                            callback(null, applicationContext);
                        }

                    } else {
                        callback("inherit or underscore missing");
                    }
                });

            };

            if (Object.prototype.toString.call(config) == '[object String]') {
                requirejs(["json!" + config], function (config) {
                    internalCreateApplicationContext(config);
                });
            } else {
                internalCreateApplicationContext(config);
            }

        },

        /***
         *
         * @param {js.core.Application} mainClass the application main class to load and start
         * @param {Element} [target=document.body] the target where the application is rendered
         * @param {Object} [parameter] an object defining the parameters passed to the Application.start method
         * @param {String|Object} [config=config.json] filename of the config file to load or configuration object
         * @param {Function} [callback] callback function in the form function (err, systemManager, application)
         */
        bootStrap: function (mainClass, target, parameter, config, callback) {

            parameter = parameter || {};

            if (typeof window !== 'undefined' && window.location && !parameter.initialHash) {
                var param = window.location.search.replace(/^\?/, '').split('&');
                for (var i = 0; i < param.length; i++) {
                    var result = /^([^=]+)=(.*)$/.exec(param[i]);
                    if (result && result[1] === 'fragment') {

                        var redirectUrl = location.protocol + '//' + location.host + location.pathname;
                        param.splice(i, 1);

                        if (param.length) {
                            redirectUrl += '?' + param.join('&');
                        }

                        redirectUrl += '#' + result[2];
                        window.location = redirectUrl;

                        return;
                    }
                }
            }

            if (!target && document && document.body) {
                // render default into document.body
                target = document.body;
            }

            config = config || "config.json";

            callback = callback || function () {
            };

            if (!document) {
                callback("Document missing");
                return;
            }

            if (!target) {
                callback("Target missing");
                return;
            }

            // flow.js is not available here, so do it in a dirty way
            rAppid.createApplicationContext(mainClass, config, function (err, applicationContext) {
                if (err) {
                    callback(err);
                } else {
                    applicationContext.createApplicationInstance(window, function (err, stage, application) {
                        if (err) {
                            callback(err);
                        } else {

                            // start the application
                            application.start(parameter, function (err) {
                                if (err) {
                                    callback(err);
                                } else {
                                    // render stage to target
                                    stage.render(target);

                                    callback(null, stage, application);
                                }
                            })
                        }
                    })
                }
            });

        },

        rewriteMapEntry: Rewrite,

        createQueryString: function (parameter) {
            var ret = [];

            for (var key in parameter) {
                if (parameter.hasOwnProperty(key)) {
                    ret.push(encodeURIComponent(key) + "=" + encodeURIComponent(parameter[key]));
                }
            }

            return ret.join("&");
        },

        ajax: function (url, options, callback) {

            var s = {
                url: url
            };

            underscore.extend(s, rAppid.ajaxSettings, options);

            if (s.data && !underscore.isString(s.data)) {
                throw "data must be a string";
            }

            s.hasContent = !/^(?:GET|HEAD)$/.test(s.type);

            if (s.queryParameter && underscore.keys(s.queryParameter).length > 0) {
                // append query parameter to url
                s.url += /\?/.test(s.url) ? "&" : "?" + this.createQueryString(s.queryParameter);
            }

            // create new xhr
            var xhr = s.xhr();
            xhr.open(s.type, s.url, s.async);

            if (s.hasContent && s.contentType !== false) {
                xhr.setRequestHeader("Content-Type", s.contentType);
                if(typeof window === "undefined"){
                    // On NodeJs the XMLHttprequest does not set Content-Length
                    // In the browser it's not allowed to set the Content-length
                    xhr.setRequestHeader("Content-Length", s.data ? s.data.length.toString() : "0");
                }
            }

            try {
                for (var header in s.headers) {
                    if (s.headers.hasOwnProperty(header)) {
                        xhr.setRequestHeader(header, s.headers[header]);
                    }
                }
            } catch(e) {
            } // FF3

            xhr.send(s.data);

            var xhrCallback = function (_, isAbort) {

                var wrappedXhr;

                if (xhrCallback && (isAbort || xhr.readyState === 4)) {
                    xhrCallback = undefined;

                    if (isAbort) {
                        // Abort it manually if needed
                        if (xhr.readyState !== 4) {
                            xhr.abort();
                        }
                    } else {
                        wrappedXhr = new rAppidXhr(xhr);
                    }

                    if (callback) {
                        callback(isAbort, wrappedXhr)
                    }
                }
            };

            if (!s.async || xhr.readyState === 4) {
                xhrCallback();
            } else {
                xhr.onreadystatechange = xhrCallback
            }

            return xhr;
        }
    };

    var rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg; // IE leaves an \r character at EOL

    var rAppidXhr = function (xhr) {
        this.xhr = xhr;
        this.status = xhr.status;
        this.$nativeResponseHeaders = xhr.getAllResponseHeaders();
        this.responses = {};

        var xml = xhr.responseXML;

        // Construct response list
        if (xml && xml.documentElement) {
            this.responses.xml = xml;
        }
        this.responses.text = xhr.responseText;

        try {
            this.statusText = xhr.statusText;
        } catch(e) {
            this.statusText = "";
        }
    };

    rAppidXhr.prototype.getResponseHeader = function (key) {
        var match;
        if (!this.$responseHeaders) {
            this.$responseHeaders = {};
            while (( match = rheaders.exec(this.$nativeResponseHeaders) )) {
                this.$responseHeaders[match[1].toLowerCase()] = match[2];
            }
        }
        return this.$responseHeaders[key.toLowerCase()];
    };

    rAppid.ajaxSettings = {
        type: "GET",
        contentType: "application/x-www-form-urlencoded",
        async: true,
        xhr: function () {
            return new XMLHttpRequest();
        },
        headers: {
        },
        data: null
    };

    var ApplicationContext = function (requirejsContext, config) {
        this.$requirejsContext = requirejsContext;
        this.$config = config;
    };

    ApplicationContext.prototype.createApplicationInstance = function (window, callback) {

        var document;

        // create instance
        var applicationFactory = this.$applicationFactory;

        if (window.document) {
            document = window.document;
        } else {
            document = window;
            window = null;
        }

        // TODO: add node support for window
        var stage = new Stage(this.$requirejsContext, this, document, window);

        this.$requirejsContext(["js/core/Application", "js/core/HeadManager", "js/core/History", "js/core/Injection"], function (Application, HeadManager, History, Injection) {
            stage.$headManager = new HeadManager(document);
            stage.$history = new History();
            var injection = stage.$injection = new Injection(null, null, stage);

            injection.addInstance(stage.$bus);
            injection.addInstance(stage.$history);
            injection.addInstance(stage.$headManager);

            var application = new applicationFactory(null, false, stage, null, null);

            if (application instanceof Application) {

                stage.$application = application;
                stage._initialize("auto");

                application._initialize("auto");

                // return rAppid instance
                if (callback) {
                    callback(null, stage, application);
                }

            } else {
                var errMessage = "mainClass isn't an instance of js.core.Application";
                if (callback) {
                    callback(errMessage);
                } else {
                    throw(errMessage);
                }
            }
        });

    };

    ApplicationContext.prototype.getFqClassName = function (namespace, className, useRewriteMap) {
        if (useRewriteMap == undefined || useRewriteMap == null) {
            useRewriteMap = true;
        }

        if (namespace && className) {
            namespace = (this.$config.namespaceMap[namespace] || namespace).replace(/\./g, '/');
            var fqClassName = [namespace, className].join("/");
        } else {
            fqClassName = (namespace || className).replace(/\./g, '/');
        }

        if (underscore.indexOf(this.$config.xamlClasses, fqClassName) !== -1) {
            fqClassName = 'xaml!' + fqClassName;
        }

        if (useRewriteMap) {
            for (var i = 0; i < this.$config.rewriteMap.length; i++) {
                var entry = this.$config.rewriteMap[i];
                if (entry instanceof rAppid.rewriteMapEntry) {
                    if (entry.$from.test(fqClassName)) {
                        return fqClassName.replace(entry.$from, entry.$to);
                    }
                }
            }
        }

        return fqClassName;
    };

    ApplicationContext.prototype.createInstance = function (fqClassName, args, className) {
        args = args || [];

        var classDefinition;

        if (fqClassName instanceof Function) {
            classDefinition = fqClassName;
            fqClassName = classDefinition.prototype.constructor.name;
        } else {
            fqClassName = fqClassName.replace(/\./g, "/");
            classDefinition = this.$requirejsContext(fqClassName);
        }

        className = className || fqClassName;

        function construct(constructor, args) {
            function F() {
                return constructor.apply(this, args);
            }

            F.prototype = constructor.prototype;
            return new F();
        }

        var ret;
        try {
            ret = construct(classDefinition, args);
            ret.className = className;
        } catch(e) {
            console.warn(["Cannot create instance of '" + fqClassName + "'", e, args]);
        }

        return ret;
    };

    ApplicationContext.prototype.ajax = function (url, options, callback) {

        if (!(/^http.*$/.test(url)) && this.$config.applicationUrl) {
            url = this.$config.applicationUrl + '/' + url;
        }

        rAppid.ajax(url, options, callback);
    };

    rAppid.defaultNamespaceMap = defaultNamespaceMap;
    rAppid.defaultRewriteMap = defaultRewriteMap;
    rAppid.ApplicationContext = ApplicationContext;
    rAppid.Rewrite = Rewrite;

    exports.rAppid = rAppid;

}(typeof exports !== "undefined" ? exports : window,
    typeof requirejs !== "undefined" ? requirejs : require('requirejs'),
    typeof requirejs !== "undefined" ? define : require('requirejs').define,
    typeof window !== "undefined" ? window : exports,
    typeof window !== "undefined" ? window.XMLHttpRequest : require('xmlhttprequest').XMLHttpRequest));
<|endoftext|>


<commit_before>var fs = require('fs');

module.exports = {
  'default': function (test) {
    // Load in the images
    // TODO: If this were BDD, we should be loading this into a canvas and doing a threshold comparison there (i.e. are the images 90% similar)
    var expectedCanvasImage = fs.readFileSync(__dirname + '/expected_files/canvas.png', 'binary');
    var expectedGmImage = fs.readFileSync(__dirname + '/expected_files/gm.png', 'binary');
    var actualImage = fs.readFileSync(__dirname + '/scratch/sprite.png', 'binary');
    var matchesImage = expectedCanvasImage === actualImage || expectedGmImage === actualImage;

    // Assert they are equal
    test.ok(matchesImage, 'Actual image does not match expected image');

    // Load in the sprite positions
    // TODO: If this were BDD, we would be asserting the same variables exist -- which means loading this into either Stylus or a meta-language
    var expectedCoords = fs.readFileSync(__dirname + '/expected_files/sprite_positions.styl', 'utf8');
    var actualCoords = fs.readFileSync(__dirname + '/scratch/sprite_positions.styl', 'utf8');

    // Make sure the outputs match
    test.strictEqual(actualCoords, expectedCoords, 'Generated output doesn\'t match expected output.');

    // Callback since we are done testing
    test.done();
  },
  'jpg,json': function (test) {
    // Load in the images
    // TODO: If this were BDD, we should be loading this into a canvas and doing a threshold comparison there (i.e. are the images 90% similar)
    var actualImage = fs.readFileSync(__dirname + '/scratch/sprite.jpg', 'binary');

    // Assert they are equal
    // TODO: Perform more accurate assertion
    test.ok(actualImage, 'Actual image does not match expected image');

    // Load in the sprite positions
    // TODO: If this were BDD, we would be asserting the same variables exist -- which means loading this into either Stylus or a meta-language
    var expectedCoords = fs.readFileSync(__dirname + '/expected_files/sprite_positions.json', 'utf8');
    var actualCoords = fs.readFileSync(__dirname + '/scratch/sprite_positions.json', 'utf8');

    // Make sure the outputs match
    test.deepEqual(JSON.parse(actualCoords), JSON.parse(expectedCoords), 'Generated output doesn\'t match expected output.');

    // Callback since we are done testing
    test.done();
  },
  overrides: function (test) {
    // Load in the images
    // TODO: If this were BDD, we should be loading this into a canvas and doing a threshold comparison there (i.e. are the images 90% similar)
    var actualImage = fs.readFileSync(__dirname + '/scratch/sprite.overrides.png', 'binary');

    // Assert they are equal
    // TODO: Perform more accurate assertion
    test.ok(actualImage, 'Actual image does not match expected image');

    // Load in the sprite positions
    // TODO: If this were BDD, we would be asserting the same variables exist -- which means loading this into either Stylus or a meta-language
    var expectedCoords = fs.readFileSync(__dirname + '/expected_files/sprite_positions.overrides.styl', 'utf8');
    var actualCoords = fs.readFileSync(__dirname + '/scratch/sprite_positions.overrides.styl', 'utf8');

    // Make sure the outputs match
    test.deepEqual(JSON.parse(actualCoords), JSON.parse(expectedCoords), 'Generated output doesn\'t match expected output.');

    // Callback since we are done testing
    test.done();
  },
  nested: function (test) {
    // Load in the coordinates and extract the path to the sprite file
    var coords = fs.readFileSync(__dirname + '/scratch/3/4/sprite_positions.styl', 'utf8');

    // Assert the path is the relative one we expect
    test.notEqual(coords.indexOf('../../nested/1/2/spritesheet.png'), -1);

    // Finish the test
    test.done();
  },
  // DEV: This is for testing an edge case -- don't let this strawman you in maintenance.
  empty: function (test) {
    // Setup
    test.expect(2);
    var img = fs.readFileSync(__dirname + '/scratch/empty/sprite.png', 'binary');
    var coords = fs.readFileSync(__dirname + '/scratch/empty/sprite_positions.json', 'utf8');

    // Assert that an empty file and JSON blob are created
    test.strictEqual(img, '');
    test.strictEqual(coords, '{}');

    // Callback
    test.done();
  },
  // DEV: This is testing an edge case. CSS options are not critical for module functionality.
  cssOpts: function (test) {
    // Setup
    var expectedCoords = fs.readFileSync(__dirname + '/expected_files/css_opts/sprite_positions.css', 'utf8');
    var actualCoords = fs.readFileSync(__dirname + '/scratch/css_opts/sprite_positions.css', 'utf8');

    // Make sure the outputs match
    test.strictEqual(actualCoords, expectedCoords, 'Generated output doesn\'t match expected output.');

    // Callback
    test.done();
  },
  // DEV: This is testing an edge case. A custom template is not critical for module functionality.
  cssFunctionTemplate: function (test) {
    // Setup
    var expectedCoords = fs.readFileSync(__dirname + '/expected_files/sprite_positions_custom_function_template.styl', 'utf8');
    var actualCoords = fs.readFileSync(__dirname + '/scratch/sprite_positions_custom_function_template.styl', 'utf8');

    // Make sure the outputs match
    test.strictEqual(actualCoords, expectedCoords, 'Generated output doesn\'t match expected output.');

    // Callback
    test.done();
  },
  // DEV: This is testing an edge case. A custom template is not critical for module functionality.
  cssMustacheTemplate: function (test) {
    // Setup
    var expectedCoords = fs.readFileSync(__dirname + '/expected_files/sprite_positions_custom_mustache_template.styl', 'utf8');
    var actualCoords = fs.readFileSync(__dirname + '/scratch/sprite_positions_custom_mustache_template.styl', 'utf8');

    // Make sure the outputs match
    test.strictEqual(actualCoords, expectedCoords, 'Generated output doesn\'t match expected output.');

    // Callback
    test.done();
  },
  // DEV: This is testing an edge case. A custom template is not critical for module functionality.
  cssVarMap: function (test) {
    // Setup
    var expectedCoords = fs.readFileSync(__dirname + '/expected_files/css_var_map/sprite_positions.styl', 'utf8');
    var actualCoords = fs.readFileSync(__dirname + '/scratch/css_var_map/sprite_positions.styl', 'utf8');

    // Make sure the outputs match
    test.strictEqual(actualCoords, expectedCoords, 'Generated output doesn\'t match expected output.');

    // Callback
    test.done();
  }
};
<commit_msg>Fixing up line lengths<commit_after>var fs = require('fs');
var expectedDir = __dirname + '/expected_files/';
var actualDir = __dirname + '/scratch/';

module.exports = {
  'default': function (test) {
    // Load in the images
    // TODO: If this were BDD, we should be loading this into a canvas and doing a threshold comparison there
    //   (i.e. are the images 90% similar)
    var expectedCanvasImage = fs.readFileSync(expectedDir + 'canvas.png', 'binary');
    var expectedGmImage = fs.readFileSync(expectedDir + 'gm.png', 'binary');
    var actualImage = fs.readFileSync(actualDir + 'sprite.png', 'binary');
    var matchesImage = expectedCanvasImage === actualImage || expectedGmImage === actualImage;

    // Assert they are equal
    test.ok(matchesImage, 'Actual image does not match expected image');

    // Load in the sprite positions
    // TODO: If this were BDD, we would be asserting the same variables exist -- which means loading this into either
    //   Stylus or a meta-language
    var expectedCoords = fs.readFileSync(expectedDir + 'sprite_positions.styl', 'utf8');
    var actualCoords = fs.readFileSync(actualDir + 'sprite_positions.styl', 'utf8');

    // Make sure the outputs match
    test.strictEqual(actualCoords, expectedCoords, 'Generated output doesn\'t match expected output.');

    // Callback since we are done testing
    test.done();
  },
  'jpg,json': function (test) {
    // Load in the images
    // TODO: If this were BDD, we should be loading this into a canvas and doing a threshold comparison there
    //   (i.e. are the images 90% similar)
    var actualImage = fs.readFileSync(actualDir + 'sprite.jpg', 'binary');

    // Assert they are equal
    // TODO: Perform more accurate assertion
    test.ok(actualImage, 'Actual image does not match expected image');

    // Load in the sprite positions
    // TODO: If this were BDD, we would be asserting the same variables exist -- which means loading this into either
    //   Stylus or a meta-language
    var expectedCoords = fs.readFileSync(expectedDir + 'sprite_positions.json', 'utf8');
    var actualCoords = fs.readFileSync(actualDir + 'sprite_positions.json', 'utf8');

    // Make sure the outputs match
    test.deepEqual(JSON.parse(actualCoords), JSON.parse(expectedCoords),
      'Generated output doesn\'t match expected output.');

    // Callback since we are done testing
    test.done();
  },
  overrides: function (test) {
    // Load in the images
    // TODO: If this were BDD, we should be loading this into a canvas and doing a threshold comparison there
    //   (i.e. are the images 90% similar)
    var actualImage = fs.readFileSync(actualDir + 'sprite.overrides.png', 'binary');

    // Assert they are equal
    // TODO: Perform more accurate assertion
    test.ok(actualImage, 'Actual image does not match expected image');

    // Load in the sprite positions
    // TODO: If this were BDD, we would be asserting the same variables exist -- which means loading this into either
    //   Stylus or a meta-language
    var expectedCoords = fs.readFileSync(expectedDir + 'sprite_positions.overrides.styl', 'utf8');
    var actualCoords = fs.readFileSync(actualDir + 'sprite_positions.overrides.styl', 'utf8');

    // Make sure the outputs match
    test.deepEqual(JSON.parse(actualCoords), JSON.parse(expectedCoords),
      'Generated output doesn\'t match expected output.');

    // Callback since we are done testing
    test.done();
  },
  nested: function (test) {
    // Load in the coordinates and extract the path to the sprite file
    var coords = fs.readFileSync(actualDir + '3/4/sprite_positions.styl', 'utf8');

    // Assert the path is the relative one we expect
    test.notEqual(coords.indexOf('../../nested/1/2/spritesheet.png'), -1);

    // Finish the test
    test.done();
  },
  // DEV: This is for testing an edge case -- don't let this strawman you in maintenance.
  empty: function (test) {
    // Setup
    test.expect(2);
    var img = fs.readFileSync(actualDir + 'empty/sprite.png', 'binary');
    var coords = fs.readFileSync(actualDir + 'empty/sprite_positions.json', 'utf8');

    // Assert that an empty file and JSON blob are created
    test.strictEqual(img, '');
    test.strictEqual(coords, '{}');

    // Callback
    test.done();
  },
  // DEV: This is testing an edge case. CSS options are not critical for module functionality.
  cssOpts: function (test) {
    // Setup
    var expectedCoords = fs.readFileSync(expectedDir + 'css_opts/sprite_positions.css', 'utf8');
    var actualCoords = fs.readFileSync(actualDir + 'css_opts/sprite_positions.css', 'utf8');

    // Make sure the outputs match
    test.strictEqual(actualCoords, expectedCoords, 'Generated output doesn\'t match expected output.');

    // Callback
    test.done();
  },
  // DEV: This is testing an edge case. A custom template is not critical for module functionality.
  cssFunctionTemplate: function (test) {
    // Setup
    var expectedCoords = fs.readFileSync(expectedDir + 'sprite_positions_custom_function_template.styl', 'utf8');
    var actualCoords = fs.readFileSync(actualDir + 'sprite_positions_custom_function_template.styl', 'utf8');

    // Make sure the outputs match
    test.strictEqual(actualCoords, expectedCoords, 'Generated output doesn\'t match expected output.');

    // Callback
    test.done();
  },
  // DEV: This is testing an edge case. A custom template is not critical for module functionality.
  cssMustacheTemplate: function (test) {
    // Setup
    var expectedCoords = fs.readFileSync(expectedDir + 'sprite_positions_custom_mustache_template.styl', 'utf8');
    var actualCoords = fs.readFileSync(actualDir + 'sprite_positions_custom_mustache_template.styl', 'utf8');

    // Make sure the outputs match
    test.strictEqual(actualCoords, expectedCoords, 'Generated output doesn\'t match expected output.');

    // Callback
    test.done();
  },
  // DEV: This is testing an edge case. A custom template is not critical for module functionality.
  cssVarMap: function (test) {
    // Setup
    var expectedCoords = fs.readFileSync(expectedDir + 'css_var_map/sprite_positions.styl', 'utf8');
    var actualCoords = fs.readFileSync(actualDir + 'css_var_map/sprite_positions.styl', 'utf8');

    // Make sure the outputs match
    test.strictEqual(actualCoords, expectedCoords, 'Generated output doesn\'t match expected output.');

    // Callback
    test.done();
  }
};
<|endoftext|>


<commit_before>import {concat, flatten, map, pipe} from "ramda";

import {SITES_COLLECTION_NAME} from "./config";
import {getCollection} from "./services/mongodb";

function getSensorsIds (sensor) {
    return pipe(
        map(getSensorsIds),
        flatten,
        concat([sensor.id])
    )(sensor.children || []);
}

export default async function handleUpsert (event, actionDelete) {
    const site = {
        ...event.data.element
    };
    const id = event.data.id;
    const sensorsIds = pipe(
        map(getSensorsIds),
        flatten
    )(site.sensors || []);

    const update = actionDelete ?
        {$set: {isDeleted: true}} :
        {...site, sensorsIds, isDeleted: actionDelete};

    const sitesCollection = await getCollection(SITES_COLLECTION_NAME);
    await sitesCollection.update(
        {_id: id},
        update,
        {upsert: true}
    );
    return null;
}
<commit_msg>Fixed unit tests failing on travis<commit_after>import {concat, flatten, map, pipe} from "ramda";

import {SITES_COLLECTION_NAME} from "./config";
import {getCollection} from "./services/mongodb";

function getSensorsIds (sensor) {
    return pipe(
        map(getSensorsIds),
        flatten,
        concat([sensor.id])
    )(sensor.children || []);
}

export default async function handleUpsert (event, actionDelete) {
    const site = {
        ...event.data.element
    };
    const id = event.data.id;
    const sensorsIds = pipe(
        map(getSensorsIds),
        flatten
    )(site.sensors || []);

    const update = actionDelete ?
        {$set: {isDeleted: true}} :
        {...site, sensorsIds, isDeleted: actionDelete, _id: id};

    const sitesCollection = await getCollection(SITES_COLLECTION_NAME);
    await sitesCollection.update(
        {_id: id},
        update,
        {upsert: true}
    );
    return null;
}
<|endoftext|>


<commit_before>function MulterImpl(config){
   var defaultDest = './uploads/';

   this.init = function(){
      var multer  = require('multer');
      var uploadDir = !config.uplodaDir ? defaultDest : config.uplodaDir;

      var options = {
          dest: uploadDir,
          rename: function (fieldname, filename) {
                              return filename+Date.now();
          },
          onFileUploadStart: function (file) {
                              console.log(file.originalname + ' is starting ...');
          },
          onFileUploadComplete: function (file) {
                               console.log(file.fieldname + ' uploaded to  ' + file.path);
          }
      };

      return multer(options);
   }
}

module.exports = MulterImpl;<commit_msg>Code Style for Multer<commit_after>function MulterImpl(config) {
    var defaultDest = './uploads/';

    this.init = function () {
        var multer = require('multer');
        var uploadDir = !config.uplodaDir ? defaultDest : config.uplodaDir;

        var options = {
            dest: uploadDir,
            rename: function (fieldname, filename) {
                return filename + Date.now();
            },
            onFileUploadStart: function (file) {
                console.log(file.originalname + ' is starting ...');
            },
            onFileUploadComplete: function (file) {
                console.log(file.fieldname + ' uploaded to  ' + file.path);
            }
        };

        return multer(options);
    }
}

module.exports = MulterImpl;<|endoftext|>


<commit_before>import React from 'react';
import PropTypes from 'prop-types';
import { StatusBar, StyleSheet, View } from 'react-native';
import isEmpty from 'lodash.isempty';
import DummyNavButton from './DummyNavButton';
import NavButton from './NavButton';
import Title from './Title';
import ViewPropTypes from '../config/ViewPropTypes';

function generateChild(value, type) {
  if (React.isValidElement(value)) {
    return <View key={type}>{value}</View>;
  } else if (typeof value === 'object' && !isEmpty(value)) {
    return type === 'center' ? (
      <Title {...value} key={type} />
    ) : (
      <NavButton {...value} key={type} />
    );
  }
  return type === 'center' ? null : <DummyNavButton key={type} />;
}

function populateChildren(propChildren) {
  const childrenArray = [];

  const leftComponent = generateChild(propChildren.leftComponent, 'left');
  const centerComponent = generateChild(propChildren.centerComponent, 'center');
  const rightComponent = generateChild(propChildren.rightComponent, 'right');

  childrenArray.push(leftComponent, centerComponent, rightComponent);

  return childrenArray;
}

const Header = props => {
  const {
    children,
    statusBarProps,
    leftComponent,
    centerComponent,
    rightComponent,
    backgroundColor,
    outerContainerStyles,
    innerContainerStyles,
    ...attributes
  } = props;

  let propChildren = [];

  if (leftComponent || centerComponent || rightComponent) {
    propChildren = populateChildren({
      leftComponent,
      centerComponent,
      rightComponent,
    });
  }

  return (
    <View
      {...attributes}
      style={[
        styles.outerContainer,
        backgroundColor && { backgroundColor },
        outerContainerStyles,
      ]}
    >
      <StatusBar {...statusBarProps} />
      <View style={[styles.innerContainer, innerContainerStyles]}>
        {propChildren.length > 0 ? propChildren : children}
      </View>
    </View>
  );
};

Header.propTypes = {
  leftComponent: PropTypes.object,
  centerComponent: PropTypes.object,
  rightComponent: PropTypes.object,
  backgroundColor: PropTypes.string,
  outerContainerStyles: ViewPropTypes.style,
  innerContainerStyles: ViewPropTypes.style,
  children: PropTypes.oneOf([
    PropTypes.element,
    PropTypes.arrayOf(PropTypes.element),
  ]),
  statusBarProps: PropTypes.object,
};

const styles = StyleSheet.create({
  innerContainer: {
    flex: 1,
    flexDirection: 'row',
    justifyContent: 'space-between',
    alignItems: 'flex-end',
  },
  outerContainer: {
    backgroundColor: '#476DC5',
    borderBottomColor: '#f2f2f2',
    borderBottomWidth: 1,
    padding: 15,
    height: 70,
  },
});

export default Header;
<commit_msg>Fix children proptypes in Header<commit_after>import React from 'react';
import PropTypes from 'prop-types';
import { StatusBar, StyleSheet, View } from 'react-native';
import isEmpty from 'lodash.isempty';
import DummyNavButton from './DummyNavButton';
import NavButton from './NavButton';
import Title from './Title';
import ViewPropTypes from '../config/ViewPropTypes';

function generateChild(value, type) {
  if (React.isValidElement(value)) {
    return <View key={type}>{value}</View>;
  } else if (typeof value === 'object' && !isEmpty(value)) {
    return type === 'center' ? (
      <Title {...value} key={type} />
    ) : (
      <NavButton {...value} key={type} />
    );
  }
  return type === 'center' ? null : <DummyNavButton key={type} />;
}

function populateChildren(propChildren) {
  const childrenArray = [];

  const leftComponent = generateChild(propChildren.leftComponent, 'left');
  const centerComponent = generateChild(propChildren.centerComponent, 'center');
  const rightComponent = generateChild(propChildren.rightComponent, 'right');

  childrenArray.push(leftComponent, centerComponent, rightComponent);

  return childrenArray;
}

const Header = props => {
  const {
    children,
    statusBarProps,
    leftComponent,
    centerComponent,
    rightComponent,
    backgroundColor,
    outerContainerStyles,
    innerContainerStyles,
    ...attributes
  } = props;

  let propChildren = [];

  if (leftComponent || centerComponent || rightComponent) {
    propChildren = populateChildren({
      leftComponent,
      centerComponent,
      rightComponent,
    });
  }

  return (
    <View
      {...attributes}
      style={[
        styles.outerContainer,
        backgroundColor && { backgroundColor },
        outerContainerStyles,
      ]}
    >
      <StatusBar {...statusBarProps} />
      <View style={[styles.innerContainer, innerContainerStyles]}>
        {propChildren.length > 0 ? propChildren : children}
      </View>
    </View>
  );
};

Header.propTypes = {
  leftComponent: PropTypes.object,
  centerComponent: PropTypes.object,
  rightComponent: PropTypes.object,
  backgroundColor: PropTypes.string,
  outerContainerStyles: ViewPropTypes.style,
  innerContainerStyles: ViewPropTypes.style,
  children: PropTypes.oneOfType([
    PropTypes.element,
    PropTypes.arrayOf(PropTypes.element),
  ]),
  statusBarProps: PropTypes.object,
};

const styles = StyleSheet.create({
  innerContainer: {
    flex: 1,
    flexDirection: 'row',
    justifyContent: 'space-between',
    alignItems: 'flex-end',
  },
  outerContainer: {
    backgroundColor: '#476DC5',
    borderBottomColor: '#f2f2f2',
    borderBottomWidth: 1,
    padding: 15,
    height: 70,
  },
});

export default Header;
<|endoftext|>


<commit_before>'use strict'

const store = {
  'more': `<svg style="width:100%;height:100%" viewBox="0 0 24 24">
    <path fill="currentColor" d="M12,16A2,2 0 0,1 14,18A2,2 0 0,1 12,20A2,2 0 0,1 10,18A2,2 0 0,1 12,16M12,10A2,2 0 0,1 14,12A2,2 0 0,1 12,14A2,2 0 0,1 10,12A2,2 0 0,1 12,10M12,4A2,2 0 0,1 14,6A2,2 0 0,1 12,8A2,2 0 0,1 10,6A2,2 0 0,1 12,4Z" />
  </svg>`,
  'add-key': `<svg style="width:100%;height:100%" viewBox="0 0 24 24">
    <path fill="currentColor" d="M6.5,3C8.46,3 10.13,4.25 10.74,6H22V9H18V12H15V9H10.74C10.13,10.75 8.46,12 6.5,12C4,12 2,10 2,7.5C2,5 4,3 6.5,3M6.5,6A1.5,1.5 0 0,0 5,7.5A1.5,1.5 0 0,0 6.5,9A1.5,1.5 0 0,0 8,7.5A1.5,1.5 0 0,0 6.5,6M8,17H11V14H13V17H16V19H13V22H11V19H8V17Z" />
  </svg>`,
  'verify': `<svg style="width:100%;height:100%" viewBox="0 0 24 24">
    <path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z" />
  </svg>`,
  'sign': `<svg style="width:100%;height:100%" viewBox="0 0 24 24">
    <path fill="currentColor" d="M20.71,7.04C21.1,6.65 21.1,6 20.71,5.63L18.37,3.29C18,2.9 17.35,2.9 16.96,3.29L15.12,5.12L18.87,8.87M3,17.25V21H6.75L17.81,9.93L14.06,6.18L3,17.25Z" />
  </svg>`, // materialdesignicons.com pencil
  'decrypt': `<svg style="width:100%;height:100%" viewBox="0 0 24 24">
    <path fill="currentColor" d="M18,20V10H6V20H18M18,8A2,2 0 0,1 20,10V20A2,2 0 0,1 18,22H6C4.89,22 4,21.1 4,20V10A2,2 0 0,1 6,8H15V6A3,3 0 0,0 12,3A3,3 0 0,0 9,6H7A5,5 0 0,1 12,1A5,5 0 0,1 17,6V8H18M12,17A2,2 0 0,1 10,15A2,2 0 0,1 12,13A2,2 0 0,1 14,15A2,2 0 0,1 12,17Z" />
  </svg>`,
  'encrypt': `<svg style="width:100%;height:100%" viewBox="0 0 24 24">
    <path fill="currentColor" d="M12,17A2,2 0 0,0 14,15C14,13.89 13.1,13 12,13A2,2 0 0,0 10,15A2,2 0 0,0 12,17M18,8A2,2 0 0,1 20,10V20A2,2 0 0,1 18,22H6A2,2 0 0,1 4,20V10C4,8.89 4.9,8 6,8H7V6A5,5 0 0,1 12,1A5,5 0 0,1 17,6V8H18M12,3A3,3 0 0,0 9,6V8H15V6A3,3 0 0,0 12,3Z" />
  </svg>`, // materialdesignicons.com lock
  'plus': `<svg style="width:100%;height:100%" viewBox="0 0 24 24">
    <path fill="currentColor" d="M19,13H13V19H11V13H5V11H11V5H13V11H19V13Z" />
  </svg>`, // materialdesignicons.com plus
}

export const getIcon = (name) => {
  return store.hasOwnProperty(name) ? store[name] : 'n/a'
}
<commit_msg>Update icons<commit_after>'use strict'

const store = {
  'more': `<svg style="width:100%;height:100%" viewBox="0 0 24 24">
    <path fill="currentColor" d="M12,16A2,2 0 0,1 14,18A2,2 0 0,1 12,20A2,2 0 0,1 10,18A2,2 0 0,1 12,16M12,10A2,2 0 0,1 14,12A2,2 0 0,1 12,14A2,2 0 0,1 10,12A2,2 0 0,1 12,10M12,4A2,2 0 0,1 14,6A2,2 0 0,1 12,8A2,2 0 0,1 10,6A2,2 0 0,1 12,4Z" />
  </svg>`,
  'add-key': `<svg style="width:100%;height:100%" viewBox="0 0 24 24">
    <path fill="currentColor" d="M6.5,3C8.46,3 10.13,4.25 10.74,6H22V9H18V12H15V9H10.74C10.13,10.75 8.46,12 6.5,12C4,12 2,10 2,7.5C2,5 4,3 6.5,3M6.5,6A1.5,1.5 0 0,0 5,7.5A1.5,1.5 0 0,0 6.5,9A1.5,1.5 0 0,0 8,7.5A1.5,1.5 0 0,0 6.5,6M8,17H11V14H13V17H16V19H13V22H11V19H8V17Z" />
  </svg>`,
  'verify': `<svg style="width:100%;height:100%" viewBox="0 0 24 24">
    <path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z" />
  </svg>`,
  'sign': `<svg style="width:100%;height:100%" viewBox="0 0 24 24">
    <path fill="currentColor" d="M20.71,7.04C21.1,6.65 21.1,6 20.71,5.63L18.37,3.29C18,2.9 17.35,2.9 16.96,3.29L15.12,5.12L18.87,8.87M3,17.25V21H6.75L17.81,9.93L14.06,6.18L3,17.25Z" />
  </svg>`, // materialdesignicons.com pencil
  'decrypt': `<svg style="width:100%;height:100%" viewBox="0 0 24 24">
    <path fill="currentColor" d="M18,8A2,2 0 0,1 20,10V20A2,2 0 0,1 18,22H6C4.89,22 4,21.1 4,20V10A2,2 0 0,1 6,8H15V6A3,3 0 0,0 12,3A3,3 0 0,0 9,6H7A5,5 0 0,1 12,1A5,5 0 0,1 17,6V8H18M12,17A2,2 0 0,0 14,15A2,2 0 0,0 12,13A2,2 0 0,0 10,15A2,2 0 0,0 12,17Z" />
  </svg>`,
  'encrypt': `<svg style="width:100%;height:100%" viewBox="0 0 24 24">
    <path fill="currentColor" d="M12,17A2,2 0 0,0 14,15C14,13.89 13.1,13 12,13A2,2 0 0,0 10,15A2,2 0 0,0 12,17M18,8A2,2 0 0,1 20,10V20A2,2 0 0,1 18,22H6A2,2 0 0,1 4,20V10C4,8.89 4.9,8 6,8H7V6A5,5 0 0,1 12,1A5,5 0 0,1 17,6V8H18M12,3A3,3 0 0,0 9,6V8H15V6A3,3 0 0,0 12,3Z" />
  </svg>`, // materialdesignicons.com lock
  'plus': `<svg style="width:100%;height:100%" viewBox="0 0 24 24">
    <path fill="currentColor" d="M19,13H13V19H11V13H5V11H11V5H13V11H19V13Z" />
  </svg>`, // materialdesignicons.com plus
}

export const getIcon = (name) => {
  return store.hasOwnProperty(name) ? store[name] : 'n/a'
}
<|endoftext|>


<commit_before>'use strict';

/*!
 * Collection
 * https://github.com/kobezzza/Collection
 *
 * Released under the MIT license
 * https://github.com/kobezzza/Collection/blob/master/LICENSE
 */

import { IGNORE, FALSE, EMPTY } from '../consts/primitives';

export const asyncTypes = {
	'stream': true,
	'isIDBRequest': true
};

export const mapSet = {
	'map': true,
	'set': true
};

export const weakTypes = {
	'weakMap': true,
	'weakSet': true
};

export const iterators = {
	'iterator': true,
	'asyncIterator': true,
	'generator': true,
	'stream': true,
	'idbRequest': true
};

/**
 * Returns true if the specified value is a function
 *
 * @param {?} obj - source value
 * @return {boolean}
 */
export function isFunction(obj) {
	return typeof obj === 'function';
}

/**
 * Returns true if the specified value is a number
 *
 * @param {?} obj - source value
 * @return {boolean}
 */
export function isNumber(obj) {
	return typeof obj === 'number';
}

/**
 * Returns true if the specified value is a string
 *
 * @param {?} obj - source value
 * @return {boolean}
 */
export function isString(obj) {
	return typeof obj === 'string';
}

/**
 * Returns true if the specified value is a boolean
 *
 * @param {?} obj - source value
 * @return {boolean}
 */
export function isBoolean(obj) {
	return typeof obj === 'boolean';
}

/**
 * Returns true if the specified value is an array
 *
 * @param {?} obj - source value
 * @return {boolean}
 */
export function isArray(obj) {
	return Array.isArray(obj) || obj instanceof Array;
}

/**
 * Returns true if the specified value is a Map instance
 *
 * @param {?} obj - source value
 * @return {boolean}
 */
export function isMap(obj) {
	return typeof Map === 'function' && obj instanceof Map;
}

/**
 * Returns true if the specified value is a WeakMap instance
 *
 * @param {?} obj - source value
 * @return {boolean}
 */
export function isWeakMap(obj) {
	return typeof WeakMap === 'function' && obj instanceof WeakMap;
}

/**
 * Returns true if the specified value is a Set instance
 *
 * @param {?} obj - source value
 * @return {boolean}
 */
export function isSet(obj) {
	return typeof Set === 'function' && obj instanceof Set;
}

/**
 * Returns true if the specified value is a WeakSet instance
 *
 * @param {?} obj - source value
 * @return {boolean}
 */
export function isWeakSet(obj) {
	return typeof WeakSet === 'function' && obj instanceof WeakSet;
}

/**
 * Returns true if the specified value is a Promise instance
 *
 * @param {?} obj - source value
 * @return {boolean}
 */
export function isPromise(obj) {
	return Boolean(obj && isFunction(obj.then) && isFunction(obj.catch));
}

/**
 * Returns true if the specified value is a plain object
 *
 * @param {?} obj - source value
 * @return {boolean}
 */
export function isPlainObject(obj) {
	return Boolean(obj) && obj.constructor === Object;
}

const objectTypes = {
	'object': true,
	'function': true
};

/**
 * Returns true if the specified value is an object instance
 *
 * @param {?} obj - source value
 * @return {boolean}
 */
export function isObjectInstance(obj) {
	return Boolean(obj) && objectTypes[typeof obj];
}

const
	isFuncRgxp = /\[object Function]/,
	toString = {}.toString;

/**
 * Returns true if the specified value is an array or like an array
 *
 * @param {?} obj - source value
 * @return {boolean}
 */
export function isLikeArray(obj) {
	const res = isArray(obj) ||
		(obj &&

			// The hack for PhantomJS,
			// because it has strange bug for HTMLCollection and NodeList:
			// typeof 'function' && instanceof Function = false
			isObjectInstance(obj) && !isFuncRgxp.test(toString.call(obj)) &&

			(
				// If the object is like an array
				(obj.length > 0 && 0 in obj) || obj.length === 0
			)
		);

	return Boolean(res);
}

/**
 * Returns true if the specified value is a generator
 *
 * @param {?} obj - source value
 * @return {boolean}
 */
export function isGenerator(obj) {
	return isFunction(obj) && obj.constructor.name === 'GeneratorFunction';
}

/**
 * Returns true if the specified value is an iterator
 *
 * @param {?} obj - source value
 * @return {boolean}
 */
export function isIterator(obj) {
	return Boolean(
		obj && (typeof Symbol === 'function' ? obj[Symbol.iterator] : isFunction(obj['@@iterator']))
	);
}

/**
 * Returns true if the specified value is a stream
 *
 * @param {?} obj - source value
 * @return {boolean}
 */
export function isStream(obj) {
	return Boolean(
		obj &&
		isFunction(obj.addListener) &&
		isFunction(obj.removeListener) &&
		isFunction(obj.destroy) &&
		(
			isFunction(obj.write) && isFunction(obj.end) ||
			isFunction(obj.pipe) && isFunction(obj.read) && isFunction(obj.pause) && isFunction(obj.resume)
		)
	);
}

/**
 * Returns true if the specified value is a IDBRequest instance
 *
 * @param {?} obj - source value
 * @return {boolean}
 */
export function isIDBRequest(obj) {
	return typeof IDBRequest === 'function' && obj instanceof IDBRequest;
}

/**
 * Returns the current type of an object
 *
 * @param {Object} obj - source object
 * @param {?string=} [opt_use] - cycle type for iteration: for, for in, for of, async for of
 * @return {?string}
 */
export function getType(obj, opt_use) {
	if (!obj) {
		return null;
	}

	switch (opt_use) {
		case 'for':
			return 'array';

		case 'for in':
			return 'object';

		case 'for of':
			return 'iterator';

		case 'sync for of':
			return 'syncIterator';

		case 'async for of':
			return 'asyncIterator';

		default:
			if (obj === EMPTY) {
				return null;
			}

			if (isMap(obj)) {
				return 'map';
			}

			if (isWeakMap(obj)) {
				return 'weakMap';
			}

			if (isSet(obj)) {
				return 'set';
			}

			if (isWeakSet(obj)) {
				return 'weakSet';
			}

			if (isGenerator(obj)) {
				return 'generator';
			}

			if (isLikeArray(obj)) {
				return 'array';
			}

			if (isIterator(obj)) {
				return 'iterator';
			}

			if (isIDBRequest(obj)) {
				return 'idbRequest';
			}

			if (isStream(obj)) {
				return 'stream';
			}
	}

	return 'object';
}

export const
	isNative = /\[native code]/;

/**
 * Returns a new object with the same type as source
 *
 * @param {?} obj - source object
 * @return {?}
 */
export function getSameAs(obj) {
	if (!obj) {
		return false;
	}

	if (isArray(obj)) {
		return [];
	}

	if (isPlainObject(obj)) {
		return {};
	}

	if (isMap(obj)) {
		return new Map();
	}

	if (isSet(obj)) {
		return new Set();
	}

	return isFunction(obj.constructor) && !isNative.test(obj.constructor.toString()) ? {} : false;
}

/**
 * Returns true if the specified object is one of JS data structures
 *
 * @param {?} obj - source object
 * @return {boolean}
 */
export function isStructure(obj) {
	if (!obj) {
		return false;
	}

	if (isArray(obj) || isPlainObject(obj) || isMap(obj) || isSet(obj)) {
		return true;
	}

	return isFunction(obj.constructor) && !isNative.test(obj.constructor.toString());
}

/**
 * Returns true if a prototype of the specified object can be extended
 *
 * @param {?} obj - source object
 * @return {boolean}
 */
export function canExtendProto(obj) {
	if (!obj) {
		return false;
	}

	if (isArray(obj) || isPlainObject(obj)) {
		return true;
	}

	return isFunction(obj.constructor) && !isNative.test(obj.constructor.toString());
}

/**
 * Returns true if the specified object is positive (not equals FALSE and IGNORE)
 *
 * @param {?} obj - source object
 * @return {boolean}
 */
export function isPositive(obj) {
	return obj !== FALSE && obj !== IGNORE;
}
<commit_msg>Added sync for of to doc<commit_after>'use strict';

/*!
 * Collection
 * https://github.com/kobezzza/Collection
 *
 * Released under the MIT license
 * https://github.com/kobezzza/Collection/blob/master/LICENSE
 */

import { IGNORE, FALSE, EMPTY } from '../consts/primitives';

export const asyncTypes = {
	'stream': true,
	'isIDBRequest': true
};

export const mapSet = {
	'map': true,
	'set': true
};

export const weakTypes = {
	'weakMap': true,
	'weakSet': true
};

export const iterators = {
	'iterator': true,
	'asyncIterator': true,
	'generator': true,
	'stream': true,
	'idbRequest': true
};

/**
 * Returns true if the specified value is a function
 *
 * @param {?} obj - source value
 * @return {boolean}
 */
export function isFunction(obj) {
	return typeof obj === 'function';
}

/**
 * Returns true if the specified value is a number
 *
 * @param {?} obj - source value
 * @return {boolean}
 */
export function isNumber(obj) {
	return typeof obj === 'number';
}

/**
 * Returns true if the specified value is a string
 *
 * @param {?} obj - source value
 * @return {boolean}
 */
export function isString(obj) {
	return typeof obj === 'string';
}

/**
 * Returns true if the specified value is a boolean
 *
 * @param {?} obj - source value
 * @return {boolean}
 */
export function isBoolean(obj) {
	return typeof obj === 'boolean';
}

/**
 * Returns true if the specified value is an array
 *
 * @param {?} obj - source value
 * @return {boolean}
 */
export function isArray(obj) {
	return Array.isArray(obj) || obj instanceof Array;
}

/**
 * Returns true if the specified value is a Map instance
 *
 * @param {?} obj - source value
 * @return {boolean}
 */
export function isMap(obj) {
	return typeof Map === 'function' && obj instanceof Map;
}

/**
 * Returns true if the specified value is a WeakMap instance
 *
 * @param {?} obj - source value
 * @return {boolean}
 */
export function isWeakMap(obj) {
	return typeof WeakMap === 'function' && obj instanceof WeakMap;
}

/**
 * Returns true if the specified value is a Set instance
 *
 * @param {?} obj - source value
 * @return {boolean}
 */
export function isSet(obj) {
	return typeof Set === 'function' && obj instanceof Set;
}

/**
 * Returns true if the specified value is a WeakSet instance
 *
 * @param {?} obj - source value
 * @return {boolean}
 */
export function isWeakSet(obj) {
	return typeof WeakSet === 'function' && obj instanceof WeakSet;
}

/**
 * Returns true if the specified value is a Promise instance
 *
 * @param {?} obj - source value
 * @return {boolean}
 */
export function isPromise(obj) {
	return Boolean(obj && isFunction(obj.then) && isFunction(obj.catch));
}

/**
 * Returns true if the specified value is a plain object
 *
 * @param {?} obj - source value
 * @return {boolean}
 */
export function isPlainObject(obj) {
	return Boolean(obj) && obj.constructor === Object;
}

const objectTypes = {
	'object': true,
	'function': true
};

/**
 * Returns true if the specified value is an object instance
 *
 * @param {?} obj - source value
 * @return {boolean}
 */
export function isObjectInstance(obj) {
	return Boolean(obj) && objectTypes[typeof obj];
}

const
	isFuncRgxp = /\[object Function]/,
	toString = {}.toString;

/**
 * Returns true if the specified value is an array or like an array
 *
 * @param {?} obj - source value
 * @return {boolean}
 */
export function isLikeArray(obj) {
	const res = isArray(obj) ||
		(obj &&

			// The hack for PhantomJS,
			// because it has strange bug for HTMLCollection and NodeList:
			// typeof 'function' && instanceof Function = false
			isObjectInstance(obj) && !isFuncRgxp.test(toString.call(obj)) &&

			(
				// If the object is like an array
				(obj.length > 0 && 0 in obj) || obj.length === 0
			)
		);

	return Boolean(res);
}

/**
 * Returns true if the specified value is a generator
 *
 * @param {?} obj - source value
 * @return {boolean}
 */
export function isGenerator(obj) {
	return isFunction(obj) && obj.constructor.name === 'GeneratorFunction';
}

/**
 * Returns true if the specified value is an iterator
 *
 * @param {?} obj - source value
 * @return {boolean}
 */
export function isIterator(obj) {
	return Boolean(
		obj && (typeof Symbol === 'function' ? obj[Symbol.iterator] : isFunction(obj['@@iterator']))
	);
}

/**
 * Returns true if the specified value is a stream
 *
 * @param {?} obj - source value
 * @return {boolean}
 */
export function isStream(obj) {
	return Boolean(
		obj &&
		isFunction(obj.addListener) &&
		isFunction(obj.removeListener) &&
		isFunction(obj.destroy) &&
		(
			isFunction(obj.write) && isFunction(obj.end) ||
			isFunction(obj.pipe) && isFunction(obj.read) && isFunction(obj.pause) && isFunction(obj.resume)
		)
	);
}

/**
 * Returns true if the specified value is a IDBRequest instance
 *
 * @param {?} obj - source value
 * @return {boolean}
 */
export function isIDBRequest(obj) {
	return typeof IDBRequest === 'function' && obj instanceof IDBRequest;
}

/**
 * Returns the current type of an object
 *
 * @param {Object} obj - source object
 * @param {?string=} [opt_use] - cycle type for iteration: for, for in, for of, async for of, sync for of
 * @return {?string}
 */
export function getType(obj, opt_use) {
	if (!obj) {
		return null;
	}

	switch (opt_use) {
		case 'for':
			return 'array';

		case 'for in':
			return 'object';

		case 'for of':
			return 'iterator';

		case 'sync for of':
			return 'syncIterator';

		case 'async for of':
			return 'asyncIterator';

		default:
			if (obj === EMPTY) {
				return null;
			}

			if (isMap(obj)) {
				return 'map';
			}

			if (isWeakMap(obj)) {
				return 'weakMap';
			}

			if (isSet(obj)) {
				return 'set';
			}

			if (isWeakSet(obj)) {
				return 'weakSet';
			}

			if (isGenerator(obj)) {
				return 'generator';
			}

			if (isLikeArray(obj)) {
				return 'array';
			}

			if (isIterator(obj)) {
				return 'iterator';
			}

			if (isIDBRequest(obj)) {
				return 'idbRequest';
			}

			if (isStream(obj)) {
				return 'stream';
			}
	}

	return 'object';
}

export const
	isNative = /\[native code]/;

/**
 * Returns a new object with the same type as source
 *
 * @param {?} obj - source object
 * @return {?}
 */
export function getSameAs(obj) {
	if (!obj) {
		return false;
	}

	if (isArray(obj)) {
		return [];
	}

	if (isPlainObject(obj)) {
		return {};
	}

	if (isMap(obj)) {
		return new Map();
	}

	if (isSet(obj)) {
		return new Set();
	}

	return isFunction(obj.constructor) && !isNative.test(obj.constructor.toString()) ? {} : false;
}

/**
 * Returns true if the specified object is one of JS data structures
 *
 * @param {?} obj - source object
 * @return {boolean}
 */
export function isStructure(obj) {
	if (!obj) {
		return false;
	}

	if (isArray(obj) || isPlainObject(obj) || isMap(obj) || isSet(obj)) {
		return true;
	}

	return isFunction(obj.constructor) && !isNative.test(obj.constructor.toString());
}

/**
 * Returns true if a prototype of the specified object can be extended
 *
 * @param {?} obj - source object
 * @return {boolean}
 */
export function canExtendProto(obj) {
	if (!obj) {
		return false;
	}

	if (isArray(obj) || isPlainObject(obj)) {
		return true;
	}

	return isFunction(obj.constructor) && !isNative.test(obj.constructor.toString());
}

/**
 * Returns true if the specified object is positive (not equals FALSE and IGNORE)
 *
 * @param {?} obj - source object
 * @return {boolean}
 */
export function isPositive(obj) {
	return obj !== FALSE && obj !== IGNORE;
}
<|endoftext|>


<commit_before>'use strict';

const BP = require("@blueprint/core");

exports.alertClass = BP.Alert;
exports.breadcrumbClass = BP.Breadcrumb;
exports.buttonClass = BP.Button;
exports.anchorButtonClass = BP.AnchorButton;
exports.collapseClass = BP.Collapse;
exports.collapsibleListClass = BP.CollapsibleList;
exports.contextMenuTargetClass = BP.ContextMenuTarget;
exports.datePickerClass = BP.DatePicker;
exports.dateRangePickerClass = BP.DateRangePicker;
exports.timePickerClass = BP.TimePicker;
exports.dateTimePickerClass = BP.DateTimePicker;
exports.dateInputClass = BP.DateInput;
exports.dialogClass = BP.Dialog;
exports.editableTextClass = BP.EditableText;
exports.checkboxClass = BP.Checkbox;
exports.radioClass = BP.Radio;
exports.radioGroupClass = BP.RadioGroup;
exports.switchClass = BP.Switch;
exports.inputGroupClass = BP.InputGroup;
exports.hotkeyClass = BP.Hotkey;
exports.hotkeysClass = BP.Hotkeys;
exports.hotkeysTargetClass = BP.HotkeysTarget;
exports.menuClass = BP.Menu;
exports.menuItemClass = BP.MenuItem;
exports.menuDividerClass = BP.MenuDivider;
exports.navbarClass = BP.Navbar;
exports.nonIdealStateClass = BP.NonIdealState;
exports.overlayClass = BP.Overlay;
exports.popoverClass = BP.Popover;
exports.positionClass = BP.Position;
exports.portalClass = BP.Portal;
exports.progressBarClass = BP.ProgressBar;
exports.spinnerClass = BP.Spinner;
exports.sVGSpinnerClass = BP.SVGSpinner;
exports.sliderClass = BP.Slider;
exports.rangeSliderClass = BP.RangeSlider;
exports.tableClass = BP.Table;
exports.columnClass = BP.Column;
exports.cellClass = BP.Cell;
exports.columnHeaderCellClass = BP.ColumnHeaderCell;
exports.editableNameClass = BP.EditableName;
exports.editableCellClass = BP.EditableCell;
exports.tabsClass = BP.Tabs;
exports.tabListClass = BP.TabList;
exports.tabClass = BP.Tab;
exports.tabPanelClass = BP.TabPanel;
exports.tagClass = BP.Tag;
exports.toastClass = BP.Toast;
exports.toasterClass = BP.Toaster;
exports.tooltipClass = BP.Tooltip;
exports.treeClass = BP.Tree;

// Breadcrumb
// Button
// AnchorButton
// //Buttonm Groups doesn't have JavaScript API
// Collapse
// CollapsibleList
// ContextMenuTarget
// DatePicker
// DateRangePicker
// TimePicker
// DateTimePicker
// DateInput
// Dialog
// EditableText
// Checkbox
// Radio
// RadioGroup
// Switch
// InputGroup
// Hotkey, Hotkeys, HotkeysTarget
// Menu, MenuItem, MenuDivider
// Navbar
// NonIdealState
// Overlay
// Popover
// Popover, PopoverInteractionKind, Position
// Portal
// ProgressBar
// Spinner
// SVGSpinner
// Slider
// RangeSlider
// Table, Column, Cell, ColumnHeaderCell, EditableName, EditableCell
// Tabs, TabList, Tab, TabPanel
// Tag
// Toast, Toaster
// Tooltip
// Tree
<commit_msg>comments removed<commit_after>'use strict';

const BP = require("@blueprint/core");

exports.alertClass = BP.Alert;
exports.breadcrumbClass = BP.Breadcrumb;
exports.buttonClass = BP.Button;
exports.anchorButtonClass = BP.AnchorButton;
exports.collapseClass = BP.Collapse;
exports.collapsibleListClass = BP.CollapsibleList;
exports.contextMenuTargetClass = BP.ContextMenuTarget;
exports.datePickerClass = BP.DatePicker;
exports.dateRangePickerClass = BP.DateRangePicker;
exports.timePickerClass = BP.TimePicker;
exports.dateTimePickerClass = BP.DateTimePicker;
exports.dateInputClass = BP.DateInput;
exports.dialogClass = BP.Dialog;
exports.editableTextClass = BP.EditableText;
exports.checkboxClass = BP.Checkbox;
exports.radioClass = BP.Radio;
exports.radioGroupClass = BP.RadioGroup;
exports.switchClass = BP.Switch;
exports.inputGroupClass = BP.InputGroup;
exports.hotkeyClass = BP.Hotkey;
exports.hotkeysClass = BP.Hotkeys;
exports.hotkeysTargetClass = BP.HotkeysTarget;
exports.menuClass = BP.Menu;
exports.menuItemClass = BP.MenuItem;
exports.menuDividerClass = BP.MenuDivider;
exports.navbarClass = BP.Navbar;
exports.nonIdealStateClass = BP.NonIdealState;
exports.overlayClass = BP.Overlay;
exports.popoverClass = BP.Popover;
exports.positionClass = BP.Position;
exports.portalClass = BP.Portal;
exports.progressBarClass = BP.ProgressBar;
exports.spinnerClass = BP.Spinner;
exports.sVGSpinnerClass = BP.SVGSpinner;
exports.sliderClass = BP.Slider;
exports.rangeSliderClass = BP.RangeSlider;
exports.tableClass = BP.Table;
exports.columnClass = BP.Column;
exports.cellClass = BP.Cell;
exports.columnHeaderCellClass = BP.ColumnHeaderCell;
exports.editableNameClass = BP.EditableName;
exports.editableCellClass = BP.EditableCell;
exports.tabsClass = BP.Tabs;
exports.tabListClass = BP.TabList;
exports.tabClass = BP.Tab;
exports.tabPanelClass = BP.TabPanel;
exports.tagClass = BP.Tag;
exports.toastClass = BP.Toast;
exports.toasterClass = BP.Toaster;
exports.tooltipClass = BP.Tooltip;
exports.treeClass = BP.Tree;
<|endoftext|>


<commit_before>/*global $, o_O, todoapp */
(function( window ) {
	'use strict';

// represents a single todo item
var Todo = o_O.model.extend({
		title: '',
		completed: false
	},
	{
		initialize: function() {
			this.editing = o_O( false );
		},

		startEditing: function() {
			this.editing( true );
			var self = this;
			setTimeout(function() {
				$( self.el ).parent().find('input.edit').select();
			}, 0);
		},

		stopEditing: function() {
			var text = $.trim( this.title() );

			if ( text ) {
				this.title( text );
			} else {
				this.remove();
			}

			this.editing( false );
		},

		remove: function() {
			todoapp.todos.remove( this );
		},

		visible: function() {
			var filter = todoapp.filter(),
				completed = this.completed();

			return filter === '' ||
				 ( filter === 'completed' && completed ) ||
				 ( filter === 'active' && !completed );
		},

		klass: function() {
			if ( this.editing() ) {
				return 'editing';
			}
			if ( this.completed() ) {
				return 'completed';
			} else {
				return '';
			}
		}
	}
);

// main application
var TodoApp = o_O.model.extend({
		current: '',
		completedCount: 0,
		filter: ''
	}, {
		initialize: function() {
			var self = this;

			self.todos = o_O.array( this.todos() );

			this.todos.on( 'set:completed set:title add remove', function() {
				var completed = self.todos.filter(function( todo ) {
					return todo.completed();
				});

				self.completedCount( completed.length );
				self.persist();
			});

			this.remainingCount = o_O(function() {
				return self.todos.count() - self.completedCount();
			});

			// writeable computed observable
			// handles marking all complete/incomplete
			// or retrieving if this is true
			this.allCompleted = o_O(function( v ) {
				if ( !arguments.length ) {
					return !self.remainingCount();
				}

				self.todos.each(function( todo ) {
					todo.completed( v );
				});

				return v;
			});
		},

		add: function() {
			var text = $.trim( this.current() );

			if ( text ) {
				this.todos.unshift(Todo({
					title: text
				}));
				this.current('');
			}
		},

		removeCompleted: function() {
			this.todos.remove(function( todo ) {
				return todo.completed();
			});
			return false;
		},

		persist: function() {
			localStorage['todos-o_O'] = JSON.stringify( this.todos.toJSON() );
		},

		pluralize: function( word, count ) {
			return word + ( count === 1 ? '' : 's' );
		}
	}
);

function main() {
	// load todos
	var i, l,
		todos = [];

	try {
		todos = JSON.parse( localStorage['todos-o_O'] );
	} catch( e ) {}

	// create models
	for( i = 0, l = todos.length; i < l; i++ ) {
		todos[ i ] = Todo.create( todos[ i ] );
	}

	// create app
	window.todoapp = TodoApp({
		todos: todos
	});

	// bind to DOM element
	todoapp.bind('#todoapp');

	// setup Routing
	o_O.router()
		.add('*filter', function( filter ) {
			todoapp.filter( filter );

			$('#filters a')
				.removeClass('selected')
				.filter( '[href="#/' + filter + '"]' )
				.addClass('selected');
		})
		.start();
}

// a custom binding to handle the enter key
o_O.bindings.enterKey = function( func, $el ) {
	var ENTER_KEY = 13,
		context = this;

	$el.keyup(function( e ) {
		if ( e.which === ENTER_KEY ) {
			func.call( context );
		}
	});
};

o_O.bindingTypes.enterKey = 'outbound';

// kick it off
main();

})( window );<commit_msg>Funnyface.js: Indentation<commit_after>/*global $, o_O, todoapp */
(function( window ) {
	'use strict';

	// represents a single todo item
	var Todo = o_O.model.extend({
			title: '',
			completed: false
		},
		{
			initialize: function() {
				this.editing = o_O( false );
			},

			startEditing: function() {
				this.editing( true );
				var self = this;
				setTimeout(function() {
					$( self.el ).parent().find('input.edit').select();
				}, 0);
			},

			stopEditing: function() {
				var text = $.trim( this.title() );

				if ( text ) {
					this.title( text );
				} else {
					this.remove();
				}

				this.editing( false );
			},

			remove: function() {
				todoapp.todos.remove( this );
			},

			visible: function() {
				var filter = todoapp.filter(),
					completed = this.completed();

				return filter === '' ||
					 ( filter === 'completed' && completed ) ||
					 ( filter === 'active' && !completed );
			},

			klass: function() {
				if ( this.editing() ) {
					return 'editing';
				}
				if ( this.completed() ) {
					return 'completed';
				} else {
					return '';
				}
			}
		}
	);

	// main application
	var TodoApp = o_O.model.extend({
			current: '',
			completedCount: 0,
			filter: ''
		}, {
		initialize: function() {
			var self = this;

			self.todos = o_O.array( this.todos() );

			this.todos.on( 'set:completed set:title add remove', function() {
				var completed = self.todos.filter(function( todo ) {
					return todo.completed();
				});

				self.completedCount( completed.length );
				self.persist();
			});

			this.remainingCount = o_O(function() {
				return self.todos.count() - self.completedCount();
			});

			// writeable computed observable
			// handles marking all complete/incomplete
			// or retrieving if this is true
			this.allCompleted = o_O(function( v ) {
				if ( !arguments.length ) {
					return !self.remainingCount();
				}

				self.todos.each(function( todo ) {
					todo.completed( v );
				});

				return v;
			});
		},

		add: function() {
			var text = $.trim( this.current() );

			if ( text ) {
				this.todos.unshift(Todo({
					title: text
				}));
				this.current('');
			}
		},

		removeCompleted: function() {
			this.todos.remove(function( todo ) {
				return todo.completed();
			});
			return false;
		},

		persist: function() {
			localStorage['todos-o_O'] = JSON.stringify( this.todos.toJSON() );
		},

		pluralize: function( word, count ) {
			return word + ( count === 1 ? '' : 's' );
		}
	});

	function main() {
		// load todos
		var i, l,
			todos = [];

		try {
			todos = JSON.parse( localStorage['todos-o_O'] );
		} catch( e ) {}

		// create models
		for( i = 0, l = todos.length; i < l; i++ ) {
			todos[ i ] = Todo.create( todos[ i ] );
		}

		// create app
		window.todoapp = TodoApp({
			todos: todos
		});

		// bind to DOM element
		todoapp.bind('#todoapp');

		// setup Routing
		o_O.router()
			.add('*filter', function( filter ) {
				todoapp.filter( filter );

				$('#filters a')
					.removeClass('selected')
					.filter( '[href="#/' + filter + '"]' )
					.addClass('selected');
			})
			.start();
	}

	// a custom binding to handle the enter key
	o_O.bindings.enterKey = function( func, $el ) {
		var ENTER_KEY = 13,
			context = this;

		$el.keyup(function( e ) {
			if ( e.which === ENTER_KEY ) {
				func.call( context );
			}
		});
	};

	o_O.bindingTypes.enterKey = 'outbound';

	// kick it off
	main();

})( window );<|endoftext|>


<commit_before>
import styles from './HTMLNode.style'
import Transformable from '../core/Transformable'
import Sizeable from '../core/Sizeable'
import DeclarativeBase, {initDeclarativeBase, proxyGettersSetters} from './DeclarativeBase'

initDeclarativeBase()

class HTMLNode extends DeclarativeBase {
    construct() {
        super.construct()
    }

    getStyles() {
        return styles
    }

    // TODO: get these from somewhere dynamically, and do same for
    // proxyGettersSetters and _updateNodeProperty
    static get observedAttributes() { return [
        'opacity',
        'sizemode',
        'size',
        'align',
        'mountpoint',
        'rotation',
        'position',
        'scale',
        'origin',
        'skew',
    ]}

    attributeChangedCallback(...args) {
        super.attributeChangedCallback(...args)
        this._updateNodeProperty(...args)
    }

    _updateNodeProperty(attribute, oldValue, newValue) {
        // attributes on our HTML elements are the same name as those on
        // the Node class (the setters).
        if (newValue !== oldValue) {
            if (attribute == 'opacity')
                this[attribute] = window.parseFloat(newValue)
            else if (attribute == 'sizemode')
                this[attribute] = parseStringArray(newValue)
            else if (
                attribute == 'size'
                || attribute == 'align'
                || attribute == 'mountpoint'
                || attribute == 'rotation'
                || attribute == 'position'
                || attribute == 'scale'
                || attribute == 'origin'
                || attribute == 'skew'
            ) {
                this[attribute] = parseNumberArray(newValue)
            }
        }
    }
}

// This associates the Transformable getters/setters with the HTML-API classes,
// so that the same getters/setters can be called from HTML side of the API.
proxyGettersSetters(Transformable, HTMLNode)
proxyGettersSetters(Sizeable, HTMLNode)

function parseNumberArray(str) {
    checkIsNumberArrayString(str)
    const numbers = str.trim().split(/(?:\s*,\s*)|(?:\s+)/g)
    const length = numbers.length
    if (length > 0) numbers[0] = window.parseFloat(numbers[0])
    if (length > 1) numbers[1] = window.parseFloat(numbers[1])
    if (length > 2) numbers[2] = window.parseFloat(numbers[2])
    return numbers
}

function parseStringArray(str) {
    checkIsSizeArrayString(str)
    const strings = str.trim().toLowerCase().split(/(?:\s*,\s*)|(?:\s+)/g)
    const length = strings.length
    if (length > 0) strings[0] = strings[0]
    if (length > 1) strings[1] = strings[1]
    if (length > 2) strings[2] = strings[2]
    return strings
}

function checkIsNumberArrayString(str) {
    if (!str.match(/^\s*(((\s*(-|\+)?((\.\d+)|(\d+\.\d+)|(\d+)|(\d+(\.\d+)?e(-|\+)?(\d+)))\s*,){0,2}(\s*(-|\+)?((\.\d+)|(\d+\.\d+)|(\d+)|(\d+(\.\d+)?e(-|\+)?(\d+)))))|((\s*(-|\+)?((\.\d+)|(\d+\.\d+)|(\d+)|(\d+(\.\d+)?e(-|\+)?(\d+)))\s){0,2}(\s*(-|\+)?((\.\d+)|(\d+\.\d+)|(\d+)|(\d+(\.\d+)?e(-|\+)?(\d+))))))\s*$/g))
        throw new Error(`Attribute must be a comma- or space-separated sequence of up to three numbers, for example "1 2.5 3". Yours was "${str}".`)
}

function checkIsSizeArrayString(str) {
    if (!str.match(/^\s*(((\s*([a-zA-Z]+)\s*,){0,2}(\s*([a-zA-Z]+)))|((\s*([a-zA-Z]+)\s*){1,3}))\s*$/g))
        throw new Error(`Attribute must be a comma- or space-separated sequence of up to three strings, for example "literal proportional". Yours was "${str}".`)
}

export {HTMLNode as default}
<commit_msg>convert HTMLNode to lowclass<commit_after>
import Class from 'lowclass'
import styles from './HTMLNode.style'
import Transformable from '../core/Transformable'
import Sizeable from '../core/Sizeable'
import DeclarativeBase, {initDeclarativeBase, proxyGettersSetters} from './DeclarativeBase'

initDeclarativeBase()

const HTMLNode = Class().extends( DeclarativeBase, ({ Public, Private, Super }) => ({

    construct() {
        Super(this).construct()
    },

    getStyles() {
        return styles
    },

    static: {

        // TODO: get these from somewhere dynamically, and do same for
        // proxyGettersSetters and _updateNodeProperty
        observedAttributes: [
            'opacity',
            'sizemode',
            'size',
            'align',
            'mountpoint',
            'rotation',
            'position',
            'scale',
            'origin',
            'skew',
        ],

    },

    attributeChangedCallback(...args) {
        Super(this).attributeChangedCallback(...args)
        Private(this)._updateNodeProperty(...args)
    },

    private: {

        _updateNodeProperty(attribute, oldValue, newValue) {
            // attributes on our HTML elements are the same name as those on
            // the Node class (the setters).
            if (newValue !== oldValue) {
                if (attribute == 'opacity')
                    Public(this)[attribute] = window.parseFloat(newValue)
                else if (attribute == 'sizemode')
                    Public(this)[attribute] = parseStringArray(newValue)
                else if (
                    attribute == 'size'
                    || attribute == 'align'
                    || attribute == 'mountpoint'
                    || attribute == 'rotation'
                    || attribute == 'position'
                    || attribute == 'scale'
                    || attribute == 'origin'
                    || attribute == 'skew'
                ) {
                    Public(this)[attribute] = parseNumberArray(newValue)
                }
            }
        },

    },
}))

// This associates the Transformable getters/setters with the HTML-API classes,
// so that the same getters/setters can be called from HTML side of the API.
proxyGettersSetters(Transformable, HTMLNode)
proxyGettersSetters(Sizeable, HTMLNode)

function parseNumberArray(str) {
    checkIsNumberArrayString(str)
    const numbers = str.trim().split(/(?:\s*,\s*)|(?:\s+)/g)
    const length = numbers.length
    if (length > 0) numbers[0] = window.parseFloat(numbers[0])
    if (length > 1) numbers[1] = window.parseFloat(numbers[1])
    if (length > 2) numbers[2] = window.parseFloat(numbers[2])
    return numbers
}

function parseStringArray(str) {
    checkIsSizeArrayString(str)
    const strings = str.trim().toLowerCase().split(/(?:\s*,\s*)|(?:\s+)/g)
    const length = strings.length
    if (length > 0) strings[0] = strings[0]
    if (length > 1) strings[1] = strings[1]
    if (length > 2) strings[2] = strings[2]
    return strings
}

function checkIsNumberArrayString(str) {
    if (!str.match(/^\s*(((\s*(-|\+)?((\.\d+)|(\d+\.\d+)|(\d+)|(\d+(\.\d+)?e(-|\+)?(\d+)))\s*,){0,2}(\s*(-|\+)?((\.\d+)|(\d+\.\d+)|(\d+)|(\d+(\.\d+)?e(-|\+)?(\d+)))))|((\s*(-|\+)?((\.\d+)|(\d+\.\d+)|(\d+)|(\d+(\.\d+)?e(-|\+)?(\d+)))\s){0,2}(\s*(-|\+)?((\.\d+)|(\d+\.\d+)|(\d+)|(\d+(\.\d+)?e(-|\+)?(\d+))))))\s*$/g))
        throw new Error(`Attribute must be a comma- or space-separated sequence of up to three numbers, for example "1 2.5 3". Yours was "${str}".`)
}

function checkIsSizeArrayString(str) {
    if (!str.match(/^\s*(((\s*([a-zA-Z]+)\s*,){0,2}(\s*([a-zA-Z]+)))|((\s*([a-zA-Z]+)\s*){1,3}))\s*$/g))
        throw new Error(`Attribute must be a comma- or space-separated sequence of up to three strings, for example "literal proportional". Yours was "${str}".`)
}

export {HTMLNode as default}
<|endoftext|>