UNPKG

mini-program-cljs

Version:

1,610 lines (1,609 loc) 68.8 kB
/** @define {boolean} */ var COMPILED = false; /** @const */ var goog = goog || {}; /** * @const * @type {!Global} * @suppress {undefinedVars} */ goog.global = global; /** @type {(Object<string,(string|number|boolean)>|undefined)} */ goog.global.CLOSURE_UNCOMPILED_DEFINES; /** @type {(Object<string,(string|number|boolean)>|undefined)} */ goog.global.CLOSURE_DEFINES; /** * @param {?} val * @return {boolean} * @deprecated Use `val !== undefined` instead. */ goog.isDef = function(val) { return val !== void 0; }; /** * @param {?} val * @return {boolean} * @deprecated Use `typeof val === 'string'` instead. */ goog.isString = function(val) { return typeof val == "string"; }; /** * @param {?} val * @return {boolean} * @deprecated Use `typeof val === 'boolean'` instead. */ goog.isBoolean = function(val) { return typeof val == "boolean"; }; /** * @param {?} val * @return {boolean} * @deprecated Use `typeof val === 'number'` instead. */ goog.isNumber = function(val) { return typeof val == "number"; }; /** * @private * @param {string} name * @param {*=} opt_object * @param {Object=} opt_objectToExportTo */ goog.exportPath_ = function(name, opt_object, opt_objectToExportTo) { var parts = name.split("."); var cur = opt_objectToExportTo || goog.global; if (!(parts[0] in cur) && typeof cur.execScript != "undefined") { cur.execScript("var " + parts[0]); } for (var part; parts.length && (part = parts.shift());) { if (!parts.length && opt_object !== undefined) { cur[part] = opt_object; } else { if (cur[part] && cur[part] !== Object.prototype[part]) { cur = cur[part]; } else { cur = cur[part] = {}; } } } }; /** * @param {string} name * @param {T} defaultValue * @return {T} * @template T */ goog.define = function(name, defaultValue) { var value = defaultValue; if (!COMPILED) { var uncompiledDefines = goog.global.CLOSURE_UNCOMPILED_DEFINES; var defines = goog.global.CLOSURE_DEFINES; if (uncompiledDefines && /** @type {?} */ (uncompiledDefines).nodeType === undefined && Object.prototype.hasOwnProperty.call(uncompiledDefines, name)) { value = uncompiledDefines[name]; } else { if (defines && /** @type {?} */ (defines).nodeType === undefined && Object.prototype.hasOwnProperty.call(defines, name)) { value = defines[name]; } } } return value; }; /** @define {number} */ goog.FEATURESET_YEAR = goog.define("goog.FEATURESET_YEAR", 2012); /** @define {boolean} */ goog.DEBUG = goog.define("goog.DEBUG", true); /** @define {string} */ goog.LOCALE = goog.define("goog.LOCALE", "en"); /** @define {boolean} */ goog.TRUSTED_SITE = goog.define("goog.TRUSTED_SITE", true); /** @define {boolean} */ goog.STRICT_MODE_COMPATIBLE = goog.define("goog.STRICT_MODE_COMPATIBLE", false); /** @define {boolean} */ goog.DISALLOW_TEST_ONLY_CODE = goog.define("goog.DISALLOW_TEST_ONLY_CODE", COMPILED && !goog.DEBUG); /** @define {boolean} */ goog.ENABLE_CHROME_APP_SAFE_SCRIPT_LOADING = goog.define("goog.ENABLE_CHROME_APP_SAFE_SCRIPT_LOADING", false); /** * @param {string} name */ goog.provide = function(name) { if (goog.isInModuleLoader_()) { throw new Error("goog.provide cannot be used within a module."); } if (!COMPILED) { if (goog.isProvided_(name)) { throw new Error('Namespace "' + name + '" already declared.'); } } goog.constructNamespace_(name); }; /** * @private * @param {string} name * @param {Object=} opt_obj */ goog.constructNamespace_ = function(name, opt_obj) { if (!COMPILED) { delete goog.implicitNamespaces_[name]; var namespace = name; while (namespace = namespace.substring(0, namespace.lastIndexOf("."))) { if (goog.getObjectByName(namespace)) { break; } goog.implicitNamespaces_[namespace] = true; } } goog.exportPath_(name, opt_obj); }; /** * @param {?Window=} opt_window * @return {string} */ goog.getScriptNonce = function(opt_window) { if (opt_window && opt_window != goog.global) { return goog.getScriptNonce_(opt_window.document); } if (goog.cspNonce_ === null) { goog.cspNonce_ = goog.getScriptNonce_(goog.global.document); } return goog.cspNonce_; }; /** @private @const */ goog.NONCE_PATTERN_ = /^[\w+/_-]+[=]{0,2}$/; /** @private @type {?string} */ goog.cspNonce_ = null; /** * @private * @param {!Document} doc * @return {string} */ goog.getScriptNonce_ = function(doc) { var script = doc.querySelector && doc.querySelector("script[nonce]"); if (script) { var nonce = script["nonce"] || script.getAttribute("nonce"); if (nonce && goog.NONCE_PATTERN_.test(nonce)) { return nonce; } } return ""; }; /** @private */ goog.VALID_MODULE_RE_ = /^[a-zA-Z_$][a-zA-Z0-9._$]*$/; /** * @param {string} name * @return {void} */ goog.module = function(name) { if (typeof name !== "string" || !name || name.search(goog.VALID_MODULE_RE_) == -1) { throw new Error("Invalid module identifier"); } if (!goog.isInGoogModuleLoader_()) { throw new Error("Module " + name + " has been loaded incorrectly. Note, " + "modules cannot be loaded as normal scripts. They require some kind of " + "pre-processing step. You're likely trying to load a module via a " + "script tag or as a part of a concatenated bundle without rewriting the " + "module. For more info see: " + "https://github.com/google/closure-library/wiki/goog.module:-an-ES6-module-like-alternative-to-goog.provide."); } if (goog.moduleLoaderState_.moduleName) { throw new Error("goog.module may only be called once per module."); } goog.moduleLoaderState_.moduleName = name; if (!COMPILED) { if (goog.isProvided_(name)) { throw new Error('Namespace "' + name + '" already declared.'); } delete goog.implicitNamespaces_[name]; } }; /** * @param {string} name * @return {?} * @suppress {missingProvide} */ goog.module.get = function(name) { return goog.module.getInternal_(name); }; /** * @private * @param {string} name * @return {?} */ goog.module.getInternal_ = function(name) { if (!COMPILED) { if (name in goog.loadedModules_) { return goog.loadedModules_[name].exports; } else { if (!goog.implicitNamespaces_[name]) { var ns = goog.getObjectByName(name); return ns != null ? ns : null; } } } return null; }; /** @enum {string} */ goog.ModuleType = {ES6:"es6", GOOG:"goog"}; /** @private @type {?{moduleName:(string|undefined),declareLegacyNamespace:boolean,type:?goog.ModuleType}} */ goog.moduleLoaderState_ = null; /** * @private * @return {boolean} */ goog.isInModuleLoader_ = function() { return goog.isInGoogModuleLoader_() || goog.isInEs6ModuleLoader_(); }; /** * @private * @return {boolean} */ goog.isInGoogModuleLoader_ = function() { return !!goog.moduleLoaderState_ && goog.moduleLoaderState_.type == goog.ModuleType.GOOG; }; /** * @private * @return {boolean} */ goog.isInEs6ModuleLoader_ = function() { var inLoader = !!goog.moduleLoaderState_ && goog.moduleLoaderState_.type == goog.ModuleType.ES6; if (inLoader) { return true; } var jscomp = goog.global["$jscomp"]; if (jscomp) { if (typeof jscomp.getCurrentModulePath != "function") { return false; } return !!jscomp.getCurrentModulePath(); } return false; }; /** * @suppress {missingProvide} */ goog.module.declareLegacyNamespace = function() { if (!COMPILED && !goog.isInGoogModuleLoader_()) { throw new Error("goog.module.declareLegacyNamespace must be called from " + "within a goog.module"); } if (!COMPILED && !goog.moduleLoaderState_.moduleName) { throw new Error("goog.module must be called prior to " + "goog.module.declareLegacyNamespace."); } goog.moduleLoaderState_.declareLegacyNamespace = true; }; /** * @param {string} namespace * @suppress {missingProvide} */ goog.declareModuleId = function(namespace) { if (!COMPILED) { if (!goog.isInEs6ModuleLoader_()) { throw new Error("goog.declareModuleId may only be called from " + "within an ES6 module"); } if (goog.moduleLoaderState_ && goog.moduleLoaderState_.moduleName) { throw new Error("goog.declareModuleId may only be called once per module."); } if (namespace in goog.loadedModules_) { throw new Error('Module with namespace "' + namespace + '" already exists.'); } } if (goog.moduleLoaderState_) { goog.moduleLoaderState_.moduleName = namespace; } else { var jscomp = goog.global["$jscomp"]; if (!jscomp || typeof jscomp.getCurrentModulePath != "function") { throw new Error('Module with namespace "' + namespace + '" has been loaded incorrectly.'); } var exports = jscomp.require(jscomp.getCurrentModulePath()); goog.loadedModules_[namespace] = {exports:exports, type:goog.ModuleType.ES6, moduleId:namespace}; } }; /** * @param {string=} opt_message */ goog.setTestOnly = function(opt_message) { if (goog.DISALLOW_TEST_ONLY_CODE) { opt_message = opt_message || ""; throw new Error("Importing test-only code into non-debug environment" + (opt_message ? ": " + opt_message : ".")); } }; /** * @param {string} name */ goog.forwardDeclare = function(name) { }; goog.forwardDeclare("Document"); goog.forwardDeclare("HTMLScriptElement"); goog.forwardDeclare("XMLHttpRequest"); if (!COMPILED) { /** * @private * @param {string} name * @return {boolean} */ goog.isProvided_ = function(name) { return name in goog.loadedModules_ || !goog.implicitNamespaces_[name] && goog.getObjectByName(name) != null; }; /** @private @type {!Object<string,(boolean|undefined)>} */ goog.implicitNamespaces_ = {"goog.module":true}; } /** * @param {string} name * @param {Object=} opt_obj * @return {?} */ goog.getObjectByName = function(name, opt_obj) { var parts = name.split("."); var cur = opt_obj || goog.global; for (var i = 0; i < parts.length; i++) { cur = cur[parts[i]]; if (cur == null) { return null; } } return cur; }; /** * @param {!Object} obj * @param {Object=} opt_global * @deprecated Properties may be explicitly exported to the global scope, but this should no longer be done in bulk. */ goog.globalize = function(obj, opt_global) { var global = opt_global || goog.global; for (var x in obj) { global[x] = obj[x]; } }; /** * @param {string} relPath * @param {!Array<string>} provides * @param {!Array<string>} requires * @param {(boolean|!Object<?,string>)=} opt_loadFlags */ goog.addDependency = function(relPath, provides, requires, opt_loadFlags) { if (!COMPILED && goog.DEPENDENCIES_ENABLED) { goog.debugLoader_.addDependency(relPath, provides, requires, opt_loadFlags); } }; /** @define {boolean} */ goog.ENABLE_DEBUG_LOADER = goog.define("goog.ENABLE_DEBUG_LOADER", true); /** * @private * @param {string} msg */ goog.logToConsole_ = function(msg) { if (goog.global.console) { goog.global.console["error"](msg); } }; /** * @param {string} namespace * @return {?} */ goog.require = function(namespace) { if (!COMPILED) { if (goog.ENABLE_DEBUG_LOADER) { goog.debugLoader_.requested(namespace); } if (goog.isProvided_(namespace)) { if (goog.isInModuleLoader_()) { return goog.module.getInternal_(namespace); } } else { if (goog.ENABLE_DEBUG_LOADER) { var moduleLoaderState = goog.moduleLoaderState_; goog.moduleLoaderState_ = null; try { goog.debugLoader_.load_(namespace); } finally { goog.moduleLoaderState_ = moduleLoaderState; } } } return null; } }; /** * @param {string} namespace * @return {?} */ goog.requireType = function(namespace) { return {}; }; /** @type {string} */ goog.basePath = ""; /** @type {(string|undefined)} */ goog.global.CLOSURE_BASE_PATH; /** @type {(boolean|undefined)} */ goog.global.CLOSURE_NO_DEPS; /** @type {(function(string,string=):boolean|undefined)} */ goog.global.CLOSURE_IMPORT_SCRIPT; /** * @return {void} */ goog.nullFunction = function() { }; /** * @type {!Function} * @deprecated Use "@abstract" annotation instead of goog.abstractMethod in new code. See https://github.com/google/closure-compiler/wiki/@abstract-classes-and-methods */ goog.abstractMethod = function() { throw new Error("unimplemented abstract method"); }; /** * @param {!Function} ctor * @suppress {missingProperties} */ goog.addSingletonGetter = function(ctor) { /** * @type {(undefined|!Object)} * @suppress {underscore} */ ctor.instance_ = undefined; ctor.getInstance = function() { if (ctor.instance_) { return ctor.instance_; } if (goog.DEBUG) { goog.instantiatedSingletons_[goog.instantiatedSingletons_.length] = ctor; } return /** @type {(!Object|undefined)} */ (ctor.instance_) = new ctor; }; }; /** @private @type {!Array<!Function>} */ goog.instantiatedSingletons_ = []; /** @define {boolean} */ goog.LOAD_MODULE_USING_EVAL = goog.define("goog.LOAD_MODULE_USING_EVAL", true); /** @define {boolean} */ goog.SEAL_MODULE_EXPORTS = goog.define("goog.SEAL_MODULE_EXPORTS", goog.DEBUG); /** @private @const @type {!Object<string,{exports:?,type:string,moduleId:string}>} */ goog.loadedModules_ = {}; /** @const @type {boolean} */ goog.DEPENDENCIES_ENABLED = !COMPILED && goog.ENABLE_DEBUG_LOADER; /** @define {string} */ goog.TRANSPILE = goog.define("goog.TRANSPILE", "detect"); /** @define {boolean} */ goog.ASSUME_ES_MODULES_TRANSPILED = goog.define("goog.ASSUME_ES_MODULES_TRANSPILED", false); /** @define {string} */ goog.TRANSPILE_TO_LANGUAGE = goog.define("goog.TRANSPILE_TO_LANGUAGE", ""); /** @define {string} */ goog.TRANSPILER = goog.define("goog.TRANSPILER", "transpile.js"); /** @package @type {?boolean} */ goog.hasBadLetScoping = null; /** * @package * @return {boolean} */ goog.useSafari10Workaround = function() { if (goog.hasBadLetScoping == null) { var hasBadLetScoping; try { hasBadLetScoping = !eval('"use strict";' + "let x \x3d 1; function f() { return typeof x; };" + 'f() \x3d\x3d "number";'); } catch (e) { hasBadLetScoping = false; } goog.hasBadLetScoping = hasBadLetScoping; } return goog.hasBadLetScoping; }; /** * @package * @param {string} moduleDef * @return {string} */ goog.workaroundSafari10EvalBug = function(moduleDef) { return "(function(){" + moduleDef + "\n" + ";" + "})();\n"; }; /** * @param {(function(?):?|string)} moduleDef */ goog.loadModule = function(moduleDef) { var previousState = goog.moduleLoaderState_; try { goog.moduleLoaderState_ = {moduleName:"", declareLegacyNamespace:false, type:goog.ModuleType.GOOG}; var exports; if (goog.isFunction(moduleDef)) { exports = moduleDef.call(undefined, {}); } else { if (typeof moduleDef === "string") { if (goog.useSafari10Workaround()) { moduleDef = goog.workaroundSafari10EvalBug(moduleDef); } exports = goog.loadModuleFromSource_.call(undefined, moduleDef); } else { throw new Error("Invalid module definition"); } } var moduleName = goog.moduleLoaderState_.moduleName; if (typeof moduleName === "string" && moduleName) { if (goog.moduleLoaderState_.declareLegacyNamespace) { goog.constructNamespace_(moduleName, exports); } else { if (goog.SEAL_MODULE_EXPORTS && Object.seal && typeof exports == "object" && exports != null) { Object.seal(exports); } } var data = {exports:exports, type:goog.ModuleType.GOOG, moduleId:goog.moduleLoaderState_.moduleName}; goog.loadedModules_[moduleName] = data; } else { throw new Error('Invalid module name "' + moduleName + '"'); } } finally { goog.moduleLoaderState_ = previousState; } }; /** @private @const */ goog.loadModuleFromSource_ = /** @type {function(string):?} */ (function() { var exports = {}; eval(arguments[0]); return exports; }); /** * @private * @param {string} path * @return {string} */ goog.normalizePath_ = function(path) { var components = path.split("/"); var i = 0; while (i < components.length) { if (components[i] == ".") { components.splice(i, 1); } else { if (i && components[i] == ".." && components[i - 1] && components[i - 1] != "..") { components.splice(--i, 2); } else { i++; } } } return components.join("/"); }; /** @type {(function(string):string|undefined)} */ goog.global.CLOSURE_LOAD_FILE_SYNC; /** * @private * @param {string} src * @return {?string} */ goog.loadFileSync_ = function(src) { if (goog.global.CLOSURE_LOAD_FILE_SYNC) { return goog.global.CLOSURE_LOAD_FILE_SYNC(src); } else { try { /** @type {XMLHttpRequest} */ var xhr = new goog.global["XMLHttpRequest"]; xhr.open("get", src, false); xhr.send(); return xhr.status == 0 || xhr.status == 200 ? xhr.responseText : null; } catch (err) { return null; } } }; /** * @private * @param {string} code * @param {string} path * @param {string} target * @return {string} */ goog.transpile_ = function(code, path, target) { var jscomp = goog.global["$jscomp"]; if (!jscomp) { goog.global["$jscomp"] = jscomp = {}; } var transpile = jscomp.transpile; if (!transpile) { var transpilerPath = goog.basePath + goog.TRANSPILER; var transpilerCode = goog.loadFileSync_(transpilerPath); if (transpilerCode) { (function() { (0, eval)(transpilerCode + "\n//# sourceURL\x3d" + transpilerPath); }).call(goog.global); if (goog.global["$gwtExport"] && goog.global["$gwtExport"]["$jscomp"] && !goog.global["$gwtExport"]["$jscomp"]["transpile"]) { throw new Error('The transpiler did not properly export the "transpile" ' + "method. $gwtExport: " + JSON.stringify(goog.global["$gwtExport"])); } goog.global["$jscomp"].transpile = goog.global["$gwtExport"]["$jscomp"]["transpile"]; jscomp = goog.global["$jscomp"]; transpile = jscomp.transpile; } } if (!transpile) { var suffix = " requires transpilation but no transpiler was found."; transpile = jscomp.transpile = function(code, path) { goog.logToConsole_(path + suffix); return code; }; } return transpile(code, path, target); }; /** * @param {?} value * @return {string} */ goog.typeOf = function(value) { var s = typeof value; if (s == "object") { if (value) { if (value instanceof Array) { return "array"; } else { if (value instanceof Object) { return s; } } var className = Object.prototype.toString.call(/** @type {!Object} */ (value)); if (className == "[object Window]") { return "object"; } if (className == "[object Array]" || typeof value.length == "number" && typeof value.splice != "undefined" && typeof value.propertyIsEnumerable != "undefined" && !value.propertyIsEnumerable("splice")) { return "array"; } if (className == "[object Function]" || typeof value.call != "undefined" && typeof value.propertyIsEnumerable != "undefined" && !value.propertyIsEnumerable("call")) { return "function"; } } else { return "null"; } } else { if (s == "function" && typeof value.call == "undefined") { return "object"; } } return s; }; /** * @param {?} val * @return {boolean} * @deprecated Use `val === null` instead. */ goog.isNull = function(val) { return val === null; }; /** * @param {?} val * @return {boolean} * @deprecated Use `val != null` instead. */ goog.isDefAndNotNull = function(val) { return val != null; }; /** * @param {?} val * @return {boolean} */ goog.isArray = function(val) { return goog.typeOf(val) == "array"; }; /** * @param {?} val * @return {boolean} */ goog.isArrayLike = function(val) { var type = goog.typeOf(val); return type == "array" || type == "object" && typeof val.length == "number"; }; /** * @param {?} val * @return {boolean} */ goog.isDateLike = function(val) { return goog.isObject(val) && typeof val.getFullYear == "function"; }; /** * @param {?} val * @return {boolean} */ goog.isFunction = function(val) { return goog.typeOf(val) == "function"; }; /** * @param {?} val * @return {boolean} */ goog.isObject = function(val) { var type = typeof val; return type == "object" && val != null || type == "function"; }; /** * @param {Object} obj * @return {number} */ goog.getUid = function(obj) { return obj[goog.UID_PROPERTY_] || (obj[goog.UID_PROPERTY_] = ++goog.uidCounter_); }; /** * @param {!Object} obj * @return {boolean} */ goog.hasUid = function(obj) { return !!obj[goog.UID_PROPERTY_]; }; /** * @param {Object} obj */ goog.removeUid = function(obj) { if (obj !== null && "removeAttribute" in obj) { obj.removeAttribute(goog.UID_PROPERTY_); } try { delete obj[goog.UID_PROPERTY_]; } catch (ex) { } }; /** @private @type {string} */ goog.UID_PROPERTY_ = "closure_uid_" + (Math.random() * 1e9 >>> 0); /** @private @type {number} */ goog.uidCounter_ = 0; /** * @param {Object} obj * @return {number} * @deprecated Use goog.getUid instead. */ goog.getHashCode = goog.getUid; /** * @param {Object} obj * @deprecated Use goog.removeUid instead. */ goog.removeHashCode = goog.removeUid; /** * @param {*} obj * @return {*} * @deprecated goog.cloneObject is unsafe. Prefer the goog.object methods. */ goog.cloneObject = function(obj) { var type = goog.typeOf(obj); if (type == "object" || type == "array") { if (typeof obj.clone === "function") { return obj.clone(); } var clone = type == "array" ? [] : {}; for (var key in obj) { clone[key] = goog.cloneObject(obj[key]); } return clone; } return obj; }; /** * @private * @param {?function(this:T,...)} fn * @param {T} selfObj * @param {...*} var_args * @return {!Function} * @template T */ goog.bindNative_ = function(fn, selfObj, var_args) { return (/** @type {!Function} */ (fn.call.apply(fn.bind, arguments))); }; /** * @private * @param {?function(this:T,...)} fn * @param {T} selfObj * @param {...*} var_args * @return {!Function} * @template T */ goog.bindJs_ = function(fn, selfObj, var_args) { if (!fn) { throw new Error; } if (arguments.length > 2) { var boundArgs = Array.prototype.slice.call(arguments, 2); return function() { var newArgs = Array.prototype.slice.call(arguments); Array.prototype.unshift.apply(newArgs, boundArgs); return fn.apply(selfObj, newArgs); }; } else { return function() { return fn.apply(selfObj, arguments); }; } }; /** * @param {?function(this:T,...)} fn * @param {T} selfObj * @param {...*} var_args * @return {!Function} * @template T * @suppress {deprecated} */ goog.bind = function(fn, selfObj, var_args) { if (Function.prototype.bind && Function.prototype.bind.toString().indexOf("native code") != -1) { goog.bind = goog.bindNative_; } else { goog.bind = goog.bindJs_; } return goog.bind.apply(null, arguments); }; /** * @param {Function} fn * @param {...*} var_args * @return {!Function} */ goog.partial = function(fn, var_args) { var args = Array.prototype.slice.call(arguments, 1); return function() { var newArgs = args.slice(); newArgs.push.apply(newArgs, arguments); return fn.apply(/** @type {?} */ (this), newArgs); }; }; /** * @param {Object} target * @param {Object} source * @deprecated Prefer Object.assign */ goog.mixin = function(target, source) { for (var x in source) { target[x] = source[x]; } }; /** * @return {number} * @deprecated Use Date.now */ goog.now = goog.TRUSTED_SITE && Date.now || function() { return +new Date; }; /** * @param {string} script */ goog.globalEval = function(script) { if (goog.global.execScript) { goog.global.execScript(script, "JavaScript"); } else { if (goog.global.eval) { if (goog.evalWorksForGlobals_ == null) { try { goog.global.eval("var _evalTest_ \x3d 1;"); } catch (ignore) { } if (typeof goog.global["_evalTest_"] != "undefined") { try { delete goog.global["_evalTest_"]; } catch (ignore$0) { } goog.evalWorksForGlobals_ = true; } else { goog.evalWorksForGlobals_ = false; } } if (goog.evalWorksForGlobals_) { goog.global.eval(script); } else { /** @type {!Document} */ var doc = goog.global.document; var scriptElt = /** @type {!HTMLScriptElement} */ (doc.createElement("script")); scriptElt.type = "text/javascript"; scriptElt.defer = false; scriptElt.appendChild(doc.createTextNode(script)); doc.head.appendChild(scriptElt); doc.head.removeChild(scriptElt); } } else { throw new Error("goog.globalEval not available"); } } }; /** @private @type {?boolean} */ goog.evalWorksForGlobals_ = null; /** @private @type {(!Object<string,string>|undefined)} */ goog.cssNameMapping_; /** @private @type {(string|undefined)} */ goog.cssNameMappingStyle_; /** @type {(function(string):string|undefined)} */ goog.global.CLOSURE_CSS_NAME_MAP_FN; /** * @param {string} className * @param {string=} opt_modifier * @return {string} */ goog.getCssName = function(className, opt_modifier) { if (String(className).charAt(0) == ".") { throw new Error('className passed in goog.getCssName must not start with ".".' + " You passed: " + className); } var getMapping = function(cssName) { return goog.cssNameMapping_[cssName] || cssName; }; var renameByParts = function(cssName) { var parts = cssName.split("-"); var mapped = []; for (var i = 0; i < parts.length; i++) { mapped.push(getMapping(parts[i])); } return mapped.join("-"); }; var rename; if (goog.cssNameMapping_) { rename = goog.cssNameMappingStyle_ == "BY_WHOLE" ? getMapping : renameByParts; } else { rename = function(a) { return a; }; } var result = opt_modifier ? className + "-" + rename(opt_modifier) : rename(className); if (goog.global.CLOSURE_CSS_NAME_MAP_FN) { return goog.global.CLOSURE_CSS_NAME_MAP_FN(result); } return result; }; /** * @param {!Object} mapping * @param {string=} opt_style */ goog.setCssNameMapping = function(mapping, opt_style) { goog.cssNameMapping_ = mapping; goog.cssNameMappingStyle_ = opt_style; }; /** @type {(!Object<string,string>|undefined)} */ goog.global.CLOSURE_CSS_NAME_MAPPING; if (!COMPILED && goog.global.CLOSURE_CSS_NAME_MAPPING) { goog.cssNameMapping_ = goog.global.CLOSURE_CSS_NAME_MAPPING; } /** * @param {string} str * @param {Object<string,string>=} opt_values * @param {{html:boolean}=} opt_options * @return {string} */ goog.getMsg = function(str, opt_values, opt_options) { if (opt_options && opt_options.html) { str = str.replace(/</g, "\x26lt;"); } if (opt_values) { str = str.replace(/\{\$([^}]+)}/g, function(match, key) { return opt_values != null && key in opt_values ? opt_values[key] : match; }); } return str; }; /** * @param {string} a * @param {string} b * @return {string} */ goog.getMsgWithFallback = function(a, b) { return a; }; /** * @param {string} publicPath * @param {*} object * @param {Object=} opt_objectToExportTo */ goog.exportSymbol = function(publicPath, object, opt_objectToExportTo) { goog.exportPath_(publicPath, object, opt_objectToExportTo); }; /** * @param {Object} object * @param {string} publicName * @param {*} symbol */ goog.exportProperty = function(object, publicName, symbol) { object[publicName] = symbol; }; /** * @param {!Function} childCtor * @param {!Function} parentCtor * @suppress {strictMissingProperties} */ goog.inherits = function(childCtor, parentCtor) { /** @constructor */ function tempCtor() { } tempCtor.prototype = parentCtor.prototype; childCtor.superClass_ = parentCtor.prototype; childCtor.prototype = new tempCtor; /** @override */ childCtor.prototype.constructor = childCtor; /** * @param {!Object} me * @param {string} methodName * @param {...*} var_args * @return {*} */ childCtor.base = function(me, methodName, var_args) { var args = new Array(arguments.length - 2); for (var i = 2; i < arguments.length; i++) { args[i - 2] = arguments[i]; } return parentCtor.prototype[methodName].apply(me, args); }; }; /** * @param {!Object} me * @param {*=} opt_methodName * @param {...*} var_args * @return {*} * @suppress {es5Strict} * @deprecated goog.base is not strict mode compatible. Prefer the static "base" method added to the constructor by goog.inherits or ES6 classes and the "super" keyword. */ goog.base = function(me, opt_methodName, var_args) { var caller = arguments.callee.caller; if (goog.STRICT_MODE_COMPATIBLE || goog.DEBUG && !caller) { throw new Error("arguments.caller not defined. goog.base() cannot be used " + "with strict mode code. See " + "http://www.ecma-international.org/ecma-262/5.1/#sec-C"); } if (typeof caller.superClass_ !== "undefined") { var ctorArgs = new Array(arguments.length - 1); for (var i = 1; i < arguments.length; i++) { ctorArgs[i - 1] = arguments[i]; } return /** @type {!Function} */ (caller.superClass_).constructor.apply(me, ctorArgs); } if (typeof opt_methodName != "string" && typeof opt_methodName != "symbol") { throw new Error("method names provided to goog.base must be a string or a symbol"); } var args = new Array(arguments.length - 2); for (var i = 2; i < arguments.length; i++) { args[i - 2] = arguments[i]; } var foundCaller = false; for (var proto = me.constructor.prototype; proto; proto = Object.getPrototypeOf(proto)) { if (proto[opt_methodName] === caller) { foundCaller = true; } else { if (foundCaller) { return proto[opt_methodName].apply(me, args); } } } if (me[opt_methodName] === caller) { return me.constructor.prototype[opt_methodName].apply(me, args); } else { throw new Error("goog.base called from a method of one name " + "to a method of a different name"); } }; /** * @param {function()} fn */ goog.scope = function(fn) { if (goog.isInModuleLoader_()) { throw new Error("goog.scope is not supported within a module."); } fn.call(goog.global); }; if (!COMPILED) { goog.global["COMPILED"] = COMPILED; } /** * @param {Function} superClass * @param {goog.defineClass.ClassDescriptor} def * @return {!Function} * @deprecated Use ES6 class syntax instead. */ goog.defineClass = function(superClass, def) { var constructor = def.constructor; var statics = def.statics; if (!constructor || constructor == Object.prototype.constructor) { constructor = function() { throw new Error("cannot instantiate an interface (no constructor defined)."); }; } var cls = goog.defineClass.createSealingConstructor_(constructor, superClass); if (superClass) { goog.inherits(cls, superClass); } delete def.constructor; delete def.statics; goog.defineClass.applyProperties_(cls.prototype, def); if (statics != null) { if (statics instanceof Function) { statics(cls); } else { goog.defineClass.applyProperties_(cls, statics); } } return cls; }; /** @typedef {{constructor:(!Function|undefined),statics:(Object|undefined|function(Function):void)}} */ goog.defineClass.ClassDescriptor; /** @define {boolean} */ goog.defineClass.SEAL_CLASS_INSTANCES = goog.define("goog.defineClass.SEAL_CLASS_INSTANCES", goog.DEBUG); /** * @private * @param {!Function} ctr * @param {Function} superClass * @return {!Function} */ goog.defineClass.createSealingConstructor_ = function(ctr, superClass) { if (!goog.defineClass.SEAL_CLASS_INSTANCES) { return ctr; } var superclassSealable = !goog.defineClass.isUnsealable_(superClass); /** * @this {Object} * @return {?} */ var wrappedCtr = function() { var instance = ctr.apply(this, arguments) || this; instance[goog.UID_PROPERTY_] = instance[goog.UID_PROPERTY_]; if (this.constructor === wrappedCtr && superclassSealable && Object.seal instanceof Function) { Object.seal(instance); } return instance; }; return wrappedCtr; }; /** * @private * @param {Function} ctr * @return {boolean} */ goog.defineClass.isUnsealable_ = function(ctr) { return ctr && ctr.prototype && ctr.prototype[goog.UNSEALABLE_CONSTRUCTOR_PROPERTY_]; }; /** @private @const @type {!Array<string>} */ goog.defineClass.OBJECT_PROTOTYPE_FIELDS_ = ["constructor", "hasOwnProperty", "isPrototypeOf", "propertyIsEnumerable", "toLocaleString", "toString", "valueOf"]; /** * @private * @param {!Object} target * @param {!Object} source */ goog.defineClass.applyProperties_ = function(target, source) { var key; for (key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } for (var i = 0; i < goog.defineClass.OBJECT_PROTOTYPE_FIELDS_.length; i++) { key = goog.defineClass.OBJECT_PROTOTYPE_FIELDS_[i]; if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } }; /** * @param {!Function} ctr */ goog.tagUnsealableClass = function(ctr) { if (!COMPILED && goog.defineClass.SEAL_CLASS_INSTANCES) { ctr.prototype[goog.UNSEALABLE_CONSTRUCTOR_PROPERTY_] = true; } }; /** @private @const @type {string} */ goog.UNSEALABLE_CONSTRUCTOR_PROPERTY_ = "goog_defineClass_legacy_unsealable"; if (!COMPILED && goog.DEPENDENCIES_ENABLED) { /** * @private * @return {boolean} */ goog.inHtmlDocument_ = function() { /** @type {!Document} */ var doc = goog.global.document; return doc != null && "write" in doc; }; /** * @private * @return {boolean} */ goog.isDocumentLoading_ = function() { /** @type {!HTMLDocument} */ var doc = goog.global.document; return doc.attachEvent ? doc.readyState != "complete" : doc.readyState == "loading"; }; /** @private */ goog.findBasePath_ = function() { if (goog.global.CLOSURE_BASE_PATH != undefined && typeof goog.global.CLOSURE_BASE_PATH === "string") { goog.basePath = goog.global.CLOSURE_BASE_PATH; return; } else { if (!goog.inHtmlDocument_()) { return; } } /** @type {!Document} */ var doc = goog.global.document; var currentScript = doc.currentScript; if (currentScript) { var scripts = [currentScript]; } else { var scripts = doc.getElementsByTagName("SCRIPT"); } for (var i = scripts.length - 1; i >= 0; --i) { var script = /** @type {!HTMLScriptElement} */ (scripts[i]); var src = script.src; var qmark = src.lastIndexOf("?"); var l = qmark == -1 ? src.length : qmark; if (src.substr(l - 7, 7) == "base.js") { goog.basePath = src.substr(0, l - 7); return; } } }; goog.findBasePath_(); /** @final @struct @constructor */ goog.Transpiler = function() { /** @private @type {?Object<string,boolean>} */ this.requiresTranspilation_ = null; /** @private @type {string} */ this.transpilationTarget_ = goog.TRANSPILE_TO_LANGUAGE; }; /** * @private * @return {{target:string,map:!Object<string,boolean>}} */ goog.Transpiler.prototype.createRequiresTranspilation_ = function() { var transpilationTarget = "es3"; var /** !Object<string,boolean> */ requiresTranspilation = {"es3":false}; var transpilationRequiredForAllLaterModes = false; /** * @param {string} modeName * @param {function():boolean} isSupported */ function addNewerLanguageTranspilationCheck(modeName, isSupported) { if (transpilationRequiredForAllLaterModes) { requiresTranspilation[modeName] = true; } else { if (isSupported()) { transpilationTarget = modeName; requiresTranspilation[modeName] = false; } else { requiresTranspilation[modeName] = true; transpilationRequiredForAllLaterModes = true; } } } function/** boolean */ evalCheck(/** string */ code) { try { return !!eval(code); } catch (ignored) { return false; } } var userAgent = goog.global.navigator && goog.global.navigator.userAgent ? goog.global.navigator.userAgent : ""; addNewerLanguageTranspilationCheck("es5", function() { return evalCheck("[1,].length\x3d\x3d1"); }); addNewerLanguageTranspilationCheck("es6", function() { var re = /Edge\/(\d+)(\.\d)*/i; var edgeUserAgent = userAgent.match(re); if (edgeUserAgent) { return false; } var es6fullTest = "class X{constructor(){if(new.target!\x3dString)throw 1;this.x\x3d42}}" + "let q\x3dReflect.construct(X,[],String);if(q.x!\x3d42||!(q instanceof " + "String))throw 1;for(const a of[2,3]){if(a\x3d\x3d2)continue;function " + "f(z\x3d{a}){let a\x3d0;return z.a}{function f(){return 0;}}return f()" + "\x3d\x3d3}"; return evalCheck('(()\x3d\x3e{"use strict";' + es6fullTest + "})()"); }); addNewerLanguageTranspilationCheck("es7", function() { return evalCheck("2 ** 2 \x3d\x3d 4"); }); addNewerLanguageTranspilationCheck("es8", function() { return evalCheck("async () \x3d\x3e 1, true"); }); addNewerLanguageTranspilationCheck("es9", function() { return evalCheck("({...rest} \x3d {}), true"); }); addNewerLanguageTranspilationCheck("es_next", function() { return false; }); return {target:transpilationTarget, map:requiresTranspilation}; }; /** * @param {string} lang * @param {(string|undefined)} module * @return {boolean} */ goog.Transpiler.prototype.needsTranspile = function(lang, module) { if (goog.TRANSPILE == "always") { return true; } else { if (goog.TRANSPILE == "never") { return false; } else { if (!this.requiresTranspilation_) { var obj = this.createRequiresTranspilation_(); this.requiresTranspilation_ = obj.map; this.transpilationTarget_ = this.transpilationTarget_ || obj.target; } } } if (lang in this.requiresTranspilation_) { if (this.requiresTranspilation_[lang]) { return true; } else { if (goog.inHtmlDocument_() && module == "es6" && !("noModule" in goog.global.document.createElement("script"))) { return true; } else { return false; } } } else { throw new Error("Unknown language mode: " + lang); } }; /** * @param {string} code * @param {string} path * @return {string} */ goog.Transpiler.prototype.transpile = function(code, path) { return goog.transpile_(code, path, this.transpilationTarget_); }; /** @private @final @type {!goog.Transpiler} */ goog.transpiler_ = new goog.Transpiler; /** * @private * @param {string} str * @return {string} */ goog.protectScriptTag_ = function(str) { return str.replace(/<\/(SCRIPT)/ig, "\\x3c/$1"); }; /** @private @final @struct @constructor */ goog.DebugLoader_ = function() { /** @private @const @type {!Object<string,!goog.Dependency>} */ this.dependencies_ = {}; /** @private @const @type {!Object<string,string>} */ this.idToPath_ = {}; /** @private @const @type {!Object<string,boolean>} */ this.written_ = {}; /** @private @const @type {!Array<!goog.Dependency>} */ this.loadingDeps_ = []; /** @private @type {!Array<!goog.Dependency>} */ this.depsToLoad_ = []; /** @private @type {boolean} */ this.paused_ = false; /** @private @type {!goog.DependencyFactory} */ this.factory_ = new goog.DependencyFactory(goog.transpiler_); /** @private @const @type {!Object<string,!Function>} */ this.deferredCallbacks_ = {}; /** @private @const @type {!Array<string>} */ this.deferredQueue_ = []; }; /** * @param {!Array<string>} namespaces * @param {function():undefined} callback */ goog.DebugLoader_.prototype.bootstrap = function(namespaces, callback) { var cb = callback; function resolve() { if (cb) { goog.global.setTimeout(cb, 0); cb = null; } } if (!namespaces.length) { resolve(); return; } var deps = []; for (var i = 0; i < namespaces.length; i++) { var path = this.getPathFromDeps_(namespaces[i]); if (!path) { throw new Error("Unregonized namespace: " + namespaces[i]); } deps.push(this.dependencies_[path]); } var require = goog.require; var loaded = 0; for (var i = 0; i < namespaces.length; i++) { require(namespaces[i]); deps[i].onLoad(function() { if (++loaded == namespaces.length) { resolve(); } }); } }; goog.DebugLoader_.prototype.loadClosureDeps = function() { var relPath = "deps.js"; this.depsToLoad_.push(this.factory_.createDependency(goog.normalizePath_(goog.basePath + relPath), relPath, [], [], {}, false)); this.loadDeps_(); }; /** * @param {string} absPathOrId * @param {boolean=} opt_force */ goog.DebugLoader_.prototype.requested = function(absPathOrId, opt_force) { var path = this.getPathFromDeps_(absPathOrId); if (path && (opt_force || this.areDepsLoaded_(this.dependencies_[path].requires))) { var callback = this.deferredCallbacks_[path]; if (callback) { delete this.deferredCallbacks_[path]; callback(); } } }; /** * @param {!goog.DependencyFactory} factory */ goog.DebugLoader_.prototype.setDependencyFactory = function(factory) { this.factory_ = factory; }; /** * @private * @param {string} namespace */ goog.DebugLoader_.prototype.load_ = function(namespace) { if (!this.getPathFromDeps_(namespace)) { var errorMessage = "goog.require could not find: " + namespace; goog.logToConsole_(errorMessage); throw Error(errorMessage); } else { var loader = this; var deps = []; /** * @param {string} namespace */ var visit = function(namespace) { var path = loader.getPathFromDeps_(namespace); if (!path) { throw new Error("Bad dependency path or symbol: " + namespace); } if (loader.written_[path]) { return; } loader.written_[path] = true; var dep = loader.dependencies_[path]; for (var i = 0; i < dep.requires.length; i++) { if (!goog.isProvided_(dep.requires[i])) { visit(dep.requires[i]); } } deps.push(dep); }; visit(namespace); var wasLoading = !!this.depsToLoad_.length; this.depsToLoad_ = this.depsToLoad_.concat(deps); if (!this.paused_ && !wasLoading) { this.loadDeps_(); } } }; /** @private */ goog.DebugLoader_.prototype.loadDeps_ = function() { var loader = this; var paused = this.paused_; while (this.depsToLoad_.length && !paused) { (function() { var loadCallDone = false; var dep = loader.depsToLoad_.shift(); var loaded = false; loader.loading_(dep); var controller = {pause:function() { if (loadCallDone) { throw new Error("Cannot call pause after the call to load."); } else { paused = true; } }, resume:function() { if (loadCallDone) { loader.resume_(); } else { paused = false; } }, loaded:function() { if (loaded) { throw new Error("Double call to loaded."); } loaded = true; loader.loaded_(dep); }, pending:function() { var pending = []; for (var i = 0; i < loader.loadingDeps_.length; i++) { pending.push(loader.loadingDeps_[i]); } return pending; }, /** * @param {goog.ModuleType} type */ setModuleState:function(type) { goog.moduleLoaderState_ = {type:type, moduleName:"", declareLegacyNamespace:false}; }, /** @type {function(string,string,string=)} */ registerEs6ModuleExports:function(path, exports, opt_closureNamespace) { if (opt_closureNamespace) { goog.loadedModules_[opt_closureNamespace] = {exports:exports, type:goog.ModuleType.ES6, moduleId:opt_closureNamespace || ""}; } }, /** @type {function(string,?)} */ registerGoogModuleExports:function(moduleId, exports) { goog.loadedModules_[moduleId] = {exports:exports, type:goog.ModuleType.GOOG, moduleId:moduleId}; }, clearModuleState:function() { goog.moduleLoaderState_ = null; }, defer:function(callback) { if (loadCallDone) { throw new Error("Cannot register with defer after the call to load."); } loader.defer_(dep, callback); }, areDepsLoaded:function() { return loader.areDepsLoaded_(dep.requires); }}; try { dep.load(controller); } finally { loadCallDone = true; } })(); } if (paused) { this.pause_(); } }; /** @private */ goog.DebugLoader_.prototype.pause_ = function() { this.paused_ = true; }; /** @private */ goog.DebugLoader_.prototype.resume_ = function() { if (this.paused_) { this.paused_ = false; this.loadDeps_(); } }; /** * @private * @param {!goog.Dependency} dep */ goog.DebugLoader_.prototype.loading_ = function(dep) { this.loadingDeps_.push(dep); }; /** * @private * @param {!goog.Dependency} dep */ goog.DebugLoader_.prototype.loaded_ = function(dep) { for (var i = 0; i < this.loadingDeps_.length; i++) { if (this.loadingDeps_[i] == dep) { this.loadingDeps_.splice(i, 1); break; } } for (var i = 0; i < this.deferredQueue_.length; i++) { if (this.deferredQueue_[i] == dep.path) { this.deferredQueue_.splice(i, 1); break; } } if (this.loadingDeps_.length == this.deferredQueue_.length && !this.depsToLoad_.length) { while (this.deferredQueue_.length) { this.requested(this.deferredQueue_.shift(), true); } } dep.loaded(); }; /** * @private * @param {!Array<string>} pathsOrIds * @return {boolean} */ goog.DebugLoader_.prototype.areDepsLoaded_ = function(pathsOrIds) { for (var i = 0; i < pathsOrIds.length; i++) { var path = this.getPathFromDeps_(pathsOrIds[i]); if (!path || !(path in this.deferredCallbacks_) && !goog.isProvided_(pathsOrIds[i])) { return false; } } return true; }; /** * @private * @param {string} absPathOrId * @return {?string} */ goog.DebugLoader_.prototype.getPathFromDeps_ = function(absPathOrId) { if (absPathOrId in this.idToPath_) { return this.idToPath_[absPathOrId]; } else { if (absPathOrId in this.dependencies_) { return absPathOrId; } else { return null; } } }; /** * @private * @param {!goog.Dependency} dependency * @param {!Function} callback */ goog.DebugLoader_.prototype.defer_ = function(dependency, callback) { this.deferredCallbacks_[dependency.path] = callback; this.deferredQueue_.push(dependency.path); }; /** @record */ goog.LoadController = function() { }; goog.LoadController.prototype.pause = function() { }; goog.LoadController.prototype.resume = function() { }; goog.LoadController.prototype.loaded = function() { }; /** * @return {!Array<!goog.Dependency>} */ goog.LoadController.prototype.pending = function() { }; /** * @param {string} path * @param {?} exports * @param {string=} opt_closureNamespace */ goog.LoadController.prototype.registerEs6ModuleExports = function(path, exports, opt_closureNamespace) { }; /** * @param {goog.ModuleType} type */ goog.LoadController.prototype.setModuleState = function(type) { }; goog.LoadController.prototype.clearModuleState = function() { }; /** * @param {!Function} callback */ goog.LoadController.prototype.defer = function(callback) { }; /** * @return {boolean} */ goog.LoadController.prototype.areDepsLoaded = function() { }; /** * @struct * @constructor * @param {string} path * @param {string} relativePath * @param {!Array<string>} provides * @param {!Array<string>} requires * @param {!Object<string,string>} loadFlags */ goog.Dependency = function(path, relativePath, provides, requires, loadFlags) { /** @const */ this.path = path; /** @const */ this.relativePath = relativePath; /** @const */ this.provides = provides; /** @const */ this.requires = requires; /** @const */ this.loadFlags = loadFlags; /** @private @type {boolean} */ this.loaded_ = false; /** @private @type {!Array<function()>} */ this.loadCallbacks_ = []; }; /** * @return {string} */ goog.Dependency.prototype.getPathName = function() { var pathName = this.path; var protocolIndex = pathName.indexOf("://"); if (protocolIndex >= 0) { pathName = pathName.substring(protocolIndex + 3); var slashIndex = pathName.indexOf("/"); if (slashIndex >= 0) { pathName = pathName.substring(slashIndex + 1); } } return pathName; }; /** * @final * @param {function()} callback */ goog.Dependency.prototype.onLoad = function(callback) { if (this.loaded_) { callback(); } else { this.loadCallbacks_.push(callback); } }; /** @final */ goog.Dependency.prototype.loaded = function() { this.loaded_ = true; var callbacks = this.loadCallbacks_;