/**1* @license2* Copyright The Closure Library Authors.3* SPDX-License-Identifier: Apache-2.04*/56/**7* @fileoverview Bootstrap for the Google JS Library (Closure).8*9* In uncompiled mode base.js will attempt to load Closure's deps file, unless10* the global <code>CLOSURE_NO_DEPS</code> is set to true. This allows projects11* to include their own deps file(s) from different locations.12*13* Avoid including base.js more than once. This is strictly discouraged and not14* supported. goog.require(...) won't work properly in that case.15*16* @suppress {deprecated} Users cannot remove deprecated uses here.17* @provideGoog18*/192021/**22* @define {boolean} Overridden to true by the compiler.23*/24var COMPILED = false;252627/**28* Base namespace for the Closure library. Checks to see goog is already29* defined in the current scope before assigning to prevent clobbering if30* base.js is loaded more than once.31*32* @const33*/34var goog = goog || {};3536/**37* Reference to the global object.38* https://www.ecma-international.org/ecma-262/9.0/index.html#sec-global-object39*40* More info on this implementation here:41* https://docs.google.com/document/d/1NAeW4Wk7I7FV0Y2tcUFvQdGMc89k2vdgSXInw8_nvCI/edit42*43* @const44* @suppress {undefinedVars} self won't be referenced unless `this` is falsy.45* @type {!Global}46*/47goog.global =48// Check `this` first for backwards compatibility.49// Valid unless running as an ES module or in a function wrapper called50// without setting `this` properly.51// Note that base.js can't usefully be imported as an ES module, but it may52// be compiled into bundles that are loadable as ES modules.53this ||54// https://developer.mozilla.org/en-US/docs/Web/API/Window/self55// For in-page browser environments and workers.56self;575859/**60* A hook for overriding the define values in uncompiled mode.61*62* In uncompiled mode, `CLOSURE_UNCOMPILED_DEFINES` may be defined before63* loading base.js. If a key is defined in `CLOSURE_UNCOMPILED_DEFINES`,64* `goog.define` will use the value instead of the default value. This65* allows flags to be overwritten without compilation (this is normally66* accomplished with the compiler's "define" flag).67*68* Example:69* <pre>70* var CLOSURE_UNCOMPILED_DEFINES = {'goog.DEBUG': false};71* </pre>72*73* @type {Object<string, (string|number|boolean)>|undefined}74*/75goog.global.CLOSURE_UNCOMPILED_DEFINES;767778/**79* A hook for overriding the define values in uncompiled or compiled mode,80* like CLOSURE_UNCOMPILED_DEFINES but effective in compiled code. In81* uncompiled code CLOSURE_UNCOMPILED_DEFINES takes precedence.82*83* Also unlike CLOSURE_UNCOMPILED_DEFINES the values must be number, boolean or84* string literals or the compiler will emit an error.85*86* While any @define value may be set, only those set with goog.define will be87* effective for uncompiled code.88*89* Example:90* <pre>91* var CLOSURE_DEFINES = {'goog.DEBUG': false} ;92* </pre>93*94* Currently the Closure Compiler will only recognize very simple definitions of95* this value when looking for values to apply to compiled code and ignore all96* other references. Specifically, it looks the value defined at the variable97* declaration, as with the example above.98*99* TODO(user): Improve the recognized definitions.100*101* @type {!Object<string, (string|number|boolean)>|null|undefined}102*/103goog.global.CLOSURE_DEFINES;104105106/**107* Builds an object structure for the provided namespace path, ensuring that108* names that already exist are not overwritten. For example:109* "a.b.c" -> a = {};a.b={};a.b.c={};110* Used by goog.provide and goog.exportSymbol.111* @param {string} name The name of the object that this file defines.112* @param {*=} object The object to expose at the end of the path.113* @param {boolean=} overwriteImplicit If object is set and a previous call114* implicitly constructed the namespace given by name, this parameter115* controls whether object should overwrite the implicitly constructed116* namespace or be merged into it. Defaults to false.117* @param {?Object=} objectToExportTo The object to add the path to; if this118* field is not specified, its value defaults to `goog.global`.119* @private120*/121goog.exportPath_ = function(name, object, overwriteImplicit, objectToExportTo) {122var parts = name.split('.');123var cur = objectToExportTo || goog.global;124125// Internet Explorer exhibits strange behavior when throwing errors from126// methods externed in this manner. See the testExportSymbolExceptions in127// base_test.html for an example.128if (!(parts[0] in cur) && typeof cur.execScript != 'undefined') {129cur.execScript('var ' + parts[0]);130}131132for (var part; parts.length && (part = parts.shift());) {133if (!parts.length && object !== undefined) {134if (!overwriteImplicit && goog.isObject(object) &&135goog.isObject(cur[part])) {136// Merge properties on object (the input parameter) with the existing137// implicitly defined namespace, so as to not clobber previously138// defined child namespaces.139for (var prop in object) {140if (object.hasOwnProperty(prop)) {141cur[part][prop] = object[prop];142}143}144} else {145// Either there is no existing implicit namespace, or overwriteImplicit146// is set to true, so directly assign object (the input parameter) to147// the namespace.148cur[part] = object;149}150} else if (cur[part] && cur[part] !== Object.prototype[part]) {151cur = cur[part];152} else {153cur = cur[part] = {};154}155}156};157158159/**160* Defines a named value. In uncompiled mode, the value is retrieved from161* CLOSURE_DEFINES or CLOSURE_UNCOMPILED_DEFINES if the object is defined and162* has the property specified, and otherwise used the defined defaultValue.163* When compiled the default can be overridden using the compiler options or the164* value set in the CLOSURE_DEFINES object. Returns the defined value so that it165* can be used safely in modules. Note that the value type MUST be either166* boolean, number, or string.167*168* @param {string} name The distinguished name to provide.169* @param {T} defaultValue170* @return {T} The defined value.171* @template T172*/173goog.define = function(name, defaultValue) {174var value = defaultValue;175if (!COMPILED) {176var uncompiledDefines = goog.global.CLOSURE_UNCOMPILED_DEFINES;177var defines = goog.global.CLOSURE_DEFINES;178if (uncompiledDefines &&179// Anti DOM-clobbering runtime check (b/37736576).180/** @type {?} */ (uncompiledDefines).nodeType === undefined &&181Object.prototype.hasOwnProperty.call(uncompiledDefines, name)) {182value = uncompiledDefines[name];183} else if (184defines &&185// Anti DOM-clobbering runtime check (b/37736576).186/** @type {?} */ (defines).nodeType === undefined &&187Object.prototype.hasOwnProperty.call(defines, name)) {188value = defines[name];189}190}191return value;192};193194195/**196* @define {number} Integer year indicating the set of browser features that are197* guaranteed to be present. This is defined to include exactly features that198* work correctly on all "modern" browsers that are stable on January 1 of the199* specified year. For example,200* ```js201* if (goog.FEATURESET_YEAR >= 2019) {202* // use APIs known to be available on all major stable browsers Jan 1, 2019203* } else {204* // polyfill for older browsers205* }206* ```207* This is intended to be the primary define for removing208* unnecessary browser compatibility code (such as ponyfills and workarounds),209* and should inform the default value for most other defines:210* ```js211* const ASSUME_NATIVE_PROMISE =212* goog.define('ASSUME_NATIVE_PROMISE', goog.FEATURESET_YEAR >= 2016);213* ```214*215* The default assumption is that IE9 is the lowest supported browser, which was216* first available Jan 1, 2012.217*218* TODO(user): Reference more thorough documentation when it's available.219*/220goog.FEATURESET_YEAR = goog.define('goog.FEATURESET_YEAR', 2012);221222223/**224* @define {boolean} DEBUG is provided as a convenience so that debugging code225* that should not be included in a production. It can be easily stripped226* by specifying --define goog.DEBUG=false to the Closure Compiler aka227* JSCompiler. For example, most toString() methods should be declared inside an228* "if (goog.DEBUG)" conditional because they are generally used for debugging229* purposes and it is difficult for the JSCompiler to statically determine230* whether they are used.231*/232goog.DEBUG = goog.define('goog.DEBUG', true);233234235/**236* @define {string} LOCALE defines the locale being used for compilation. It is237* used to select locale specific data to be compiled in js binary. BUILD rule238* can specify this value by "--define goog.LOCALE=<locale_name>" as a compiler239* option.240*241* Take into account that the locale code format is important. You should use242* the canonical Unicode format with hyphen as a delimiter. Language must be243* lowercase, Language Script - Capitalized, Region - UPPERCASE.244* There are few examples: pt-BR, en, en-US, sr-Latin-BO, zh-Hans-CN.245*246* See more info about locale codes here:247* http://www.unicode.org/reports/tr35/#Unicode_Language_and_Locale_Identifiers248*249* For language codes you should use values defined by ISO 693-1. See it here250* http://www.w3.org/WAI/ER/IG/ert/iso639.htm. There is only one exception from251* this rule: the Hebrew language. For legacy reasons the old code (iw) should252* be used instead of the new code (he).253*254*/255goog.LOCALE = goog.define('goog.LOCALE', 'en'); // default to en256257258/**259* @define {boolean} Whether this code is running on trusted sites.260*261* On untrusted sites, several native functions can be defined or overridden by262* external libraries like Prototype, Datejs, and JQuery and setting this flag263* to false forces closure to use its own implementations when possible.264*265* If your JavaScript can be loaded by a third party site and you are wary about266* relying on non-standard implementations, specify267* "--define goog.TRUSTED_SITE=false" to the compiler.268*/269goog.TRUSTED_SITE = goog.define('goog.TRUSTED_SITE', true);270271272/**273* @define {boolean} Whether code that calls {@link goog.setTestOnly} should274* be disallowed in the compilation unit.275*/276goog.DISALLOW_TEST_ONLY_CODE =277goog.define('goog.DISALLOW_TEST_ONLY_CODE', COMPILED && !goog.DEBUG);278279280/**281* @define {boolean} Whether to use a Chrome app CSP-compliant method for282* loading scripts via goog.require. @see appendScriptSrcNode_.283*/284goog.ENABLE_CHROME_APP_SAFE_SCRIPT_LOADING =285goog.define('goog.ENABLE_CHROME_APP_SAFE_SCRIPT_LOADING', false);286287288/**289* Defines a namespace in Closure.290*291* A namespace may only be defined once in a codebase. It may be defined using292* goog.provide() or goog.module().293*294* The presence of one or more goog.provide() calls in a file indicates295* that the file defines the given objects/namespaces.296* Provided symbols must not be null or undefined.297*298* In addition, goog.provide() creates the object stubs for a namespace299* (for example, goog.provide("goog.foo.bar") will create the object300* goog.foo.bar if it does not already exist).301*302* Build tools also scan for provide/require/module statements303* to discern dependencies, build dependency files (see deps.js), etc.304*305* @see goog.require306* @see goog.module307* @param {string} name Namespace provided by this file in the form308* "goog.package.part".309* deprecated Use goog.module (see b/159289405)310*/311goog.provide = function(name) {312if (goog.isInModuleLoader_()) {313throw new Error('goog.provide cannot be used within a module.');314}315if (!COMPILED) {316// Ensure that the same namespace isn't provided twice.317// A goog.module/goog.provide maps a goog.require to a specific file318if (goog.isProvided_(name)) {319throw new Error('Namespace "' + name + '" already declared.');320}321}322323goog.constructNamespace_(name);324};325326327/**328* @param {string} name Namespace provided by this file in the form329* "goog.package.part".330* @param {?Object=} object The object to embed in the namespace.331* @param {boolean=} overwriteImplicit If object is set and a previous call332* implicitly constructed the namespace given by name, this parameter333* controls whether opt_obj should overwrite the implicitly constructed334* namespace or be merged into it. Defaults to false.335* @private336*/337goog.constructNamespace_ = function(name, object, overwriteImplicit) {338if (!COMPILED) {339delete goog.implicitNamespaces_[name];340341var namespace = name;342while ((namespace = namespace.substring(0, namespace.lastIndexOf('.')))) {343if (goog.getObjectByName(namespace)) {344break;345}346goog.implicitNamespaces_[namespace] = true;347}348}349350goog.exportPath_(name, object, overwriteImplicit);351};352353354/**355* According to the CSP3 spec a nonce must be a valid base64 string.356* @see https://www.w3.org/TR/CSP3/#grammardef-base64-value357* @private @const358*/359goog.NONCE_PATTERN_ = /^[\w+/_-]+[=]{0,2}$/;360361362/**363* Returns CSP nonce, if set for any script tag.364* @param {?Window=} opt_window The window context used to retrieve the nonce.365* Defaults to global context.366* @return {string} CSP nonce or empty string if no nonce is present.367* @private368*/369goog.getScriptNonce_ = function(opt_window) {370var doc = (opt_window || goog.global).document;371var script = doc.querySelector && doc.querySelector('script[nonce]');372if (script) {373// Try to get the nonce from the IDL property first, because browsers that374// implement additional nonce protection features (currently only Chrome) to375// prevent nonce stealing via CSS do not expose the nonce via attributes.376// See https://github.com/whatwg/html/issues/2369377var nonce = script['nonce'] || script.getAttribute('nonce');378if (nonce && goog.NONCE_PATTERN_.test(nonce)) {379return nonce;380}381}382return '';383};384385386/**387* Module identifier validation regexp.388* Note: This is a conservative check, it is very possible to be more lenient,389* the primary exclusion here is "/" and "\" and a leading ".", these390* restrictions are intended to leave the door open for using goog.require391* with relative file paths rather than module identifiers.392* @private393*/394goog.VALID_MODULE_RE_ = /^[a-zA-Z_$][a-zA-Z0-9._$]*$/;395396397/**398* Defines a module in Closure.399*400* Marks that this file must be loaded as a module and claims the namespace.401*402* A namespace may only be defined once in a codebase. It may be defined using403* goog.provide() or goog.module().404*405* goog.module() has three requirements:406* - goog.module may not be used in the same file as goog.provide.407* - goog.module must be the first statement in the file.408* - only one goog.module is allowed per file.409*410* When a goog.module annotated file is loaded, it is enclosed in411* a strict function closure. This means that:412* - any variables declared in a goog.module file are private to the file413* (not global), though the compiler is expected to inline the module.414* - The code must obey all the rules of "strict" JavaScript.415* - the file will be marked as "use strict"416*417* NOTE: unlike goog.provide, goog.module does not declare any symbols by418* itself. If declared symbols are desired, use419* goog.module.declareLegacyNamespace().420*421*422* See the public goog.module proposal: http://goo.gl/Va1hin423*424* @param {string} name Namespace provided by this file in the form425* "goog.package.part", is expected but not required.426* @return {void}427*/428goog.module = function(name) {429if (typeof name !== 'string' || !name ||430name.search(goog.VALID_MODULE_RE_) == -1) {431throw new Error('Invalid module identifier');432}433if (!goog.isInGoogModuleLoader_()) {434throw new Error(435'Module ' + name + ' has been loaded incorrectly. Note, ' +436'modules cannot be loaded as normal scripts. They require some kind of ' +437'pre-processing step. You\'re likely trying to load a module via a ' +438'script tag or as a part of a concatenated bundle without rewriting the ' +439'module. For more info see: ' +440'https://github.com/google/closure-library/wiki/goog.module:-an-ES6-module-like-alternative-to-goog.provide.');441}442if (goog.moduleLoaderState_.moduleName) {443throw new Error('goog.module may only be called once per module.');444}445446// Store the module name for the loader.447goog.moduleLoaderState_.moduleName = name;448if (!COMPILED) {449// Ensure that the same namespace isn't provided twice.450// A goog.module/goog.provide maps a goog.require to a specific file451if (goog.isProvided_(name)) {452throw new Error('Namespace "' + name + '" already declared.');453}454delete goog.implicitNamespaces_[name];455}456};457458459/**460* @param {string} name The module identifier.461* @return {?} The module exports for an already loaded module or null.462*463* Note: This is not an alternative to goog.require, it does not464* indicate a hard dependency, instead it is used to indicate465* an optional dependency or to access the exports of a module466* that has already been loaded.467* @suppress {missingProvide}468*/469goog.module.get = function(name) {470return goog.module.getInternal_(name);471};472473474/**475* @param {string} name The module identifier.476* @return {?} The module exports for an already loaded module or null.477* @private478*/479goog.module.getInternal_ = function(name) {480if (!COMPILED) {481if (name in goog.loadedModules_) {482return goog.loadedModules_[name].exports;483} else if (!goog.implicitNamespaces_[name]) {484var ns = goog.getObjectByName(name);485return ns != null ? ns : null;486}487}488return null;489};490491/**492* Types of modules the debug loader can load.493* @enum {string}494*/495goog.ModuleType = {496ES6: 'es6',497GOOG: 'goog'498};499500501/**502* @private {?{503* moduleName: (string|undefined),504* declareLegacyNamespace:boolean,505* type: ?goog.ModuleType506* }}507*/508goog.moduleLoaderState_ = null;509510511/**512* @private513* @return {boolean} Whether a goog.module or an es6 module is currently being514* initialized.515*/516goog.isInModuleLoader_ = function() {517return goog.isInGoogModuleLoader_() || goog.isInEs6ModuleLoader_();518};519520521/**522* @private523* @return {boolean} Whether a goog.module is currently being initialized.524*/525goog.isInGoogModuleLoader_ = function() {526return !!goog.moduleLoaderState_ &&527goog.moduleLoaderState_.type == goog.ModuleType.GOOG;528};529530531/**532* @private533* @return {boolean} Whether an es6 module is currently being initialized.534*/535goog.isInEs6ModuleLoader_ = function() {536var inLoader = !!goog.moduleLoaderState_ &&537goog.moduleLoaderState_.type == goog.ModuleType.ES6;538539if (inLoader) {540return true;541}542543var jscomp = goog.global['$jscomp'];544545if (jscomp) {546// jscomp may not have getCurrentModulePath if this is a compiled bundle547// that has some of the runtime, but not all of it. This can happen if548// optimizations are turned on so the unused runtime is removed but renaming549// and Closure pass are off (so $jscomp is still named $jscomp and the550// goog.provide/require calls still exist).551if (typeof jscomp.getCurrentModulePath != 'function') {552return false;553}554555// Bundled ES6 module.556return !!jscomp.getCurrentModulePath();557}558559return false;560};561562563/**564* Provide the module's exports as a globally accessible object under the565* module's declared name. This is intended to ease migration to goog.module566* for files that have existing usages.567* @suppress {missingProvide}568*/569goog.module.declareLegacyNamespace = function() {570if (!COMPILED && !goog.isInGoogModuleLoader_()) {571throw new Error(572'goog.module.declareLegacyNamespace must be called from ' +573'within a goog.module');574}575if (!COMPILED && !goog.moduleLoaderState_.moduleName) {576throw new Error(577'goog.module must be called prior to ' +578'goog.module.declareLegacyNamespace.');579}580goog.moduleLoaderState_.declareLegacyNamespace = true;581};582583584/**585* Associates an ES6 module with a Closure module ID so that is available via586* goog.require. The associated ID acts like a goog.module ID - it does not587* create any global names, it is merely available via goog.require /588* goog.module.get / goog.forwardDeclare / goog.requireType. goog.require and589* goog.module.get will return the entire module as if it was import *'d. This590* allows Closure files to reference ES6 modules for the sake of migration.591*592* @param {string} namespace593* @suppress {missingProvide}594*/595goog.declareModuleId = function(namespace) {596if (!COMPILED) {597if (!goog.isInEs6ModuleLoader_()) {598throw new Error(599'goog.declareModuleId may only be called from ' +600'within an ES6 module');601}602if (goog.moduleLoaderState_ && goog.moduleLoaderState_.moduleName) {603throw new Error(604'goog.declareModuleId may only be called once per module.');605}606if (namespace in goog.loadedModules_) {607throw new Error(608'Module with namespace "' + namespace + '" already exists.');609}610}611if (goog.moduleLoaderState_) {612// Not bundled - debug loading.613goog.moduleLoaderState_.moduleName = namespace;614} else {615// Bundled - not debug loading, no module loader state.616var jscomp = goog.global['$jscomp'];617if (!jscomp || typeof jscomp.getCurrentModulePath != 'function') {618throw new Error(619'Module with namespace "' + namespace +620'" has been loaded incorrectly.');621}622var exports = jscomp.require(jscomp.getCurrentModulePath());623goog.loadedModules_[namespace] = {624exports: exports,625type: goog.ModuleType.ES6,626moduleId: namespace627};628}629};630631632/**633* Marks that the current file should only be used for testing, and never for634* live code in production.635*636* In the case of unit tests, the message may optionally be an exact namespace637* for the test (e.g. 'goog.stringTest'). The linter will then ignore the extra638* provide (if not explicitly defined in the code).639*640* @param {string=} opt_message Optional message to add to the error that's641* raised when used in production code.642*/643goog.setTestOnly = function(opt_message) {644if (goog.DISALLOW_TEST_ONLY_CODE) {645opt_message = opt_message || '';646throw new Error(647'Importing test-only code into non-debug environment' +648(opt_message ? ': ' + opt_message : '.'));649}650};651652653/**654* Forward declares a symbol. This is an indication to the compiler that the655* symbol may be used in the source yet is not required and may not be provided656* in compilation.657*658* The most common usage of forward declaration is code that takes a type as a659* function parameter but does not need to require it. By forward declaring660* instead of requiring, no hard dependency is made, and (if not required661* elsewhere) the namespace may never be required and thus, not be pulled662* into the JavaScript binary. If it is required elsewhere, it will be type663* checked as normal.664*665* Before using goog.forwardDeclare, please read the documentation at666* https://github.com/google/closure-compiler/wiki/Bad-Type-Annotation to667* understand the options and tradeoffs when working with forward declarations.668*669* @param {string} name The namespace to forward declare in the form of670* "goog.package.part".671* @deprecated See go/noforwarddeclaration, Use `goog.requireType` instead.672*/673goog.forwardDeclare = function(name) {};674675676/**677* Forward declare type information. Used to assign types to goog.global678* referenced object that would otherwise result in unknown type references679* and thus block property disambiguation.680*/681goog.forwardDeclare('Document');682goog.forwardDeclare('HTMLScriptElement');683goog.forwardDeclare('XMLHttpRequest');684685686if (!COMPILED) {687/**688* Check if the given name has been goog.provided. This will return false for689* names that are available only as implicit namespaces.690* @param {string} name name of the object to look for.691* @return {boolean} Whether the name has been provided.692* @private693*/694goog.isProvided_ = function(name) {695return (name in goog.loadedModules_) ||696(!goog.implicitNamespaces_[name] && goog.getObjectByName(name) != null);697};698699/**700* Namespaces implicitly defined by goog.provide. For example,701* goog.provide('goog.events.Event') implicitly declares that 'goog' and702* 'goog.events' must be namespaces.703*704* @type {!Object<string, (boolean|undefined)>}705* @private706*/707goog.implicitNamespaces_ = {'goog.module': true};708709// NOTE: We add goog.module as an implicit namespace as goog.module is defined710// here and because the existing module package has not been moved yet out of711// the goog.module namespace. This satisifies both the debug loader and712// ahead-of-time dependency management.713}714715716/**717* Returns an object based on its fully qualified external name. The object718* is not found if null or undefined. If you are using a compilation pass that719* renames property names beware that using this function will not find renamed720* properties.721*722* @param {string} name The fully qualified name.723* @param {Object=} opt_obj The object within which to look; default is724* |goog.global|.725* @return {?} The value (object or primitive) or, if not found, null.726*/727goog.getObjectByName = function(name, opt_obj) {728var parts = name.split('.');729var cur = opt_obj || goog.global;730for (var i = 0; i < parts.length; i++) {731cur = cur[parts[i]];732if (cur == null) {733return null;734}735}736return cur;737};738739740/**741* Adds a dependency from a file to the files it requires.742* @param {string} relPath The path to the js file.743* @param {!Array<string>} provides An array of strings with744* the names of the objects this file provides.745* @param {!Array<string>} requires An array of strings with746* the names of the objects this file requires.747* @param {boolean|!Object<string>=} opt_loadFlags Parameters indicating748* how the file must be loaded. The boolean 'true' is equivalent749* to {'module': 'goog'} for backwards-compatibility. Valid properties750* and values include {'module': 'goog'} and {'lang': 'es6'}.751*/752goog.addDependency = function(relPath, provides, requires, opt_loadFlags) {753if (!COMPILED && goog.DEPENDENCIES_ENABLED) {754goog.debugLoader_.addDependency(relPath, provides, requires, opt_loadFlags);755}756};757758759// NOTE(nnaze): The debug DOM loader was included in base.js as an original way760// to do "debug-mode" development. The dependency system can sometimes be761// confusing, as can the debug DOM loader's asynchronous nature.762//763// With the DOM loader, a call to goog.require() is not blocking -- the script764// will not load until some point after the current script. If a namespace is765// needed at runtime, it needs to be defined in a previous script, or loaded via766// require() with its registered dependencies.767//768// User-defined namespaces may need their own deps file. For a reference on769// creating a deps file, see:770// Externally: https://developers.google.com/closure/library/docs/depswriter771//772// Because of legacy clients, the DOM loader can't be easily removed from773// base.js. Work was done to make it disableable or replaceable for774// different environments (DOM-less JavaScript interpreters like Rhino or V8,775// for example). See bootstrap/ for more information.776777778/**779* @define {boolean} Whether to enable the debug loader.780*781* If enabled, a call to goog.require() will attempt to load the namespace by782* appending a script tag to the DOM (if the namespace has been registered).783*784* If disabled, goog.require() will simply assert that the namespace has been785* provided (and depend on the fact that some outside tool correctly ordered786* the script).787*/788goog.ENABLE_DEBUG_LOADER = goog.define('goog.ENABLE_DEBUG_LOADER', false);789790791/**792* @param {string} msg793* @private794*/795goog.logToConsole_ = function(msg) {796if (goog.global.console) {797goog.global.console['error'](msg);798}799};800801802/**803* Implements a system for the dynamic resolution of dependencies that works in804* parallel with the BUILD system.805*806* Note that all calls to goog.require will be stripped by the compiler.807*808* @see goog.provide809* @param {string} namespace Namespace (as was given in goog.provide,810* goog.module, or goog.declareModuleId) in the form811* "goog.package.part".812* @return {?} If called within a goog.module or ES6 module file, the associated813* namespace or module otherwise null.814*/815goog.require = function(namespace) {816if (!COMPILED) {817// Might need to lazy load on old IE.818if (goog.ENABLE_DEBUG_LOADER) {819goog.debugLoader_.requested(namespace);820}821822// If the object already exists we do not need to do anything.823if (goog.isProvided_(namespace)) {824if (goog.isInModuleLoader_()) {825return goog.module.getInternal_(namespace);826}827} else if (goog.ENABLE_DEBUG_LOADER) {828var moduleLoaderState = goog.moduleLoaderState_;829goog.moduleLoaderState_ = null;830try {831goog.debugLoader_.load_(namespace);832} finally {833goog.moduleLoaderState_ = moduleLoaderState;834}835}836837return null;838}839};840841842/**843* Requires a symbol for its type information. This is an indication to the844* compiler that the symbol may appear in type annotations, yet it is not845* referenced at runtime.846*847* When called within a goog.module or ES6 module file, the return value may be848* assigned to or destructured into a variable, but it may not be otherwise used849* in code outside of a type annotation.850*851* Note that all calls to goog.requireType will be stripped by the compiler.852*853* @param {string} namespace Namespace (as was given in goog.provide,854* goog.module, or goog.declareModuleId) in the form855* "goog.package.part".856* @return {?}857*/858goog.requireType = function(namespace) {859// Return an empty object so that single-level destructuring of the return860// value doesn't crash at runtime when using the debug loader. Multi-level861// destructuring isn't supported.862return {};863};864865866/**867* Path for included scripts.868* @type {string}869*/870goog.basePath = '';871872873/**874* A hook for overriding the base path.875* @type {string|undefined}876*/877goog.global.CLOSURE_BASE_PATH;878879880/**881* Whether to attempt to load Closure's deps file. By default, when uncompiled,882* deps files will attempt to be loaded.883* @type {boolean|undefined}884*/885goog.global.CLOSURE_NO_DEPS;886887888/**889* A function to import a single script. This is meant to be overridden when890* Closure is being run in non-HTML contexts, such as web workers. It's defined891* in the global scope so that it can be set before base.js is loaded, which892* allows deps.js to be imported properly.893*894* The first parameter the script source, which is a relative URI. The second,895* optional parameter is the script contents, in the event the script needed896* transformation. It should return true if the script was imported, false897* otherwise.898* @type {(function(string, string=): boolean)|undefined}899*/900goog.global.CLOSURE_IMPORT_SCRIPT;901902903/**904* When defining a class Foo with an abstract method bar(), you can do:905* Foo.prototype.bar = goog.abstractMethod906*907* Now if a subclass of Foo fails to override bar(), an error will be thrown908* when bar() is invoked.909*910* @type {!Function}911* @throws {Error} when invoked to indicate the method should be overridden.912* @deprecated Use "@abstract" annotation instead of goog.abstractMethod in new913* code. See914* https://github.com/google/closure-compiler/wiki/@abstract-classes-and-methods915*/916goog.abstractMethod = function() {917throw new Error('unimplemented abstract method');918};919920921/**922* Adds a `getInstance` static method that always returns the same923* instance object.924* @param {!Function} ctor The constructor for the class to add the static925* method to.926* @suppress {missingProperties} 'instance_' isn't a property on 'Function'927* but we don't have a better type to use here.928*/929goog.addSingletonGetter = function(ctor) {930// instance_ is immediately set to prevent issues with sealed constructors931// such as are encountered when a constructor is returned as the export object932// of a goog.module in unoptimized code.933// Delcare type to avoid conformance violations that ctor.instance_ is unknown934/** @type {undefined|!Object} @suppress {underscore} */935ctor.instance_ = undefined;936ctor.getInstance = function() {937if (ctor.instance_) {938return ctor.instance_;939}940if (goog.DEBUG) {941// NOTE: JSCompiler can't optimize away Array#push.942goog.instantiatedSingletons_[goog.instantiatedSingletons_.length] = ctor;943}944// Cast to avoid conformance violations that ctor.instance_ is unknown945return /** @type {!Object|undefined} */ (ctor.instance_) = new ctor;946};947};948949950/**951* All singleton classes that have been instantiated, for testing. Don't read952* it directly, use the `goog.testing.singleton` module. The compiler953* removes this variable if unused.954* @type {!Array<!Function>}955* @private956*/957goog.instantiatedSingletons_ = [];958959960/**961* @define {boolean} Whether to load goog.modules using `eval` when using962* the debug loader. This provides a better debugging experience as the963* source is unmodified and can be edited using Chrome Workspaces or similar.964* However in some environments the use of `eval` is banned965* so we provide an alternative.966*/967goog.LOAD_MODULE_USING_EVAL = goog.define('goog.LOAD_MODULE_USING_EVAL', true);968969970/**971* @define {boolean} Whether the exports of goog.modules should be sealed when972* possible.973*/974goog.SEAL_MODULE_EXPORTS = goog.define('goog.SEAL_MODULE_EXPORTS', goog.DEBUG);975976977/**978* The registry of initialized modules:979* The module identifier or path to module exports map.980* @private @const {!Object<string, {exports:?,type:string,moduleId:string}>}981*/982goog.loadedModules_ = {};983984985/**986* True if the debug loader enabled and used.987* @const {boolean}988*/989goog.DEPENDENCIES_ENABLED = !COMPILED && goog.ENABLE_DEBUG_LOADER;990991992/**993* @define {string} How to decide whether to transpile. Valid values994* are 'always', 'never', and 'detect'. The default ('detect') is to995* use feature detection to determine which language levels need996* transpilation.997*/998// NOTE(sdh): we could expand this to accept a language level to bypass999// detection: e.g. goog.TRANSPILE == 'es5' would transpile ES6 files but1000// would leave ES3 and ES5 files alone.1001goog.TRANSPILE = goog.define('goog.TRANSPILE', 'detect');10021003/**1004* @define {boolean} If true assume that ES modules have already been1005* transpiled by the jscompiler (in the same way that transpile.js would1006* transpile them - to jscomp modules). Useful only for servers that wish to use1007* the debug loader and transpile server side. Thus this is only respected if1008* goog.TRANSPILE is "never".1009*/1010goog.ASSUME_ES_MODULES_TRANSPILED =1011goog.define('goog.ASSUME_ES_MODULES_TRANSPILED', false);101210131014/**1015* @define {string} Trusted Types policy name. If non-empty then Closure will1016* use Trusted Types.1017*/1018goog.TRUSTED_TYPES_POLICY_NAME =1019goog.define('goog.TRUSTED_TYPES_POLICY_NAME', 'goog');102010211022/**1023* @package {?boolean}1024* Visible for testing.1025*/1026goog.hasBadLetScoping = null;102710281029/**1030* @param {function(?):?|string} moduleDef The module definition.1031*/1032goog.loadModule = function(moduleDef) {1033// NOTE: we allow function definitions to be either in the from1034// of a string to eval (which keeps the original source intact) or1035// in a eval forbidden environment (CSP) we allow a function definition1036// which in its body must call `goog.module`, and return the exports1037// of the module.1038var previousState = goog.moduleLoaderState_;1039try {1040goog.moduleLoaderState_ = {1041moduleName: '',1042declareLegacyNamespace: false,1043type: goog.ModuleType.GOOG1044};1045var origExports = {};1046var exports = origExports;1047if (typeof moduleDef === 'function') {1048exports = moduleDef.call(undefined, exports);1049} else if (typeof moduleDef === 'string') {1050exports = goog.loadModuleFromSource_.call(undefined, exports, moduleDef);1051} else {1052throw new Error('Invalid module definition');1053}10541055var moduleName = goog.moduleLoaderState_.moduleName;1056if (typeof moduleName === 'string' && moduleName) {1057// Don't seal legacy namespaces as they may be used as a parent of1058// another namespace1059if (goog.moduleLoaderState_.declareLegacyNamespace) {1060// Whether exports was overwritten via default export assignment.1061// This is important for legacy namespaces as it dictates whether1062// previously a previously loaded implicit namespace should be clobbered1063// or not.1064var isDefaultExport = origExports !== exports;1065goog.constructNamespace_(moduleName, exports, isDefaultExport);1066} else if (1067goog.SEAL_MODULE_EXPORTS && Object.seal &&1068typeof exports == 'object' && exports != null) {1069Object.seal(exports);1070}10711072var data = {1073exports: exports,1074type: goog.ModuleType.GOOG,1075moduleId: goog.moduleLoaderState_.moduleName1076};1077goog.loadedModules_[moduleName] = data;1078} else {1079throw new Error('Invalid module name \"' + moduleName + '\"');1080}1081} finally {1082goog.moduleLoaderState_ = previousState;1083}1084};108510861087/**1088* @private @const1089*/1090goog.loadModuleFromSource_ =1091/** @type {function(!Object, string):?} */ (function(exports) {1092// NOTE: we avoid declaring parameters or local variables here to avoid1093// masking globals or leaking values into the module definition.1094'use strict';1095eval(goog.CLOSURE_EVAL_PREFILTER_.createScript(arguments[1]));1096return exports;1097});109810991100/**1101* Normalize a file path by removing redundant ".." and extraneous "." file1102* path components.1103* @param {string} path1104* @return {string}1105* @private1106*/1107goog.normalizePath_ = function(path) {1108var components = path.split('/');1109var i = 0;1110while (i < components.length) {1111if (components[i] == '.') {1112components.splice(i, 1);1113} else if (1114i && components[i] == '..' && components[i - 1] &&1115components[i - 1] != '..') {1116components.splice(--i, 2);1117} else {1118i++;1119}1120}1121return components.join('/');1122};112311241125/**1126* Provides a hook for loading a file when using Closure's goog.require() API1127* with goog.modules. In particular this hook is provided to support Node.js.1128*1129* @type {(function(string):string)|undefined}1130*/1131goog.global.CLOSURE_LOAD_FILE_SYNC;113211331134/**1135* Loads file by synchronous XHR. Should not be used in production environments.1136* @param {string} src Source URL.1137* @return {?string} File contents, or null if load failed.1138* @private1139*/1140goog.loadFileSync_ = function(src) {1141if (goog.global.CLOSURE_LOAD_FILE_SYNC) {1142return goog.global.CLOSURE_LOAD_FILE_SYNC(src);1143} else {1144try {1145/** @type {XMLHttpRequest} */1146var xhr = new goog.global['XMLHttpRequest']();1147xhr.open('get', src, false);1148xhr.send();1149// NOTE: Successful http: requests have a status of 200, but successful1150// file: requests may have a status of zero. Any other status, or a1151// thrown exception (particularly in case of file: requests) indicates1152// some sort of error, which we treat as a missing or unavailable file.1153return xhr.status == 0 || xhr.status == 200 ? xhr.responseText : null;1154} catch (err) {1155// No need to rethrow or log, since errors should show up on their own.1156return null;1157}1158}1159};11601161//==============================================================================1162// Language Enhancements1163//==============================================================================116411651166/**1167* This is a "fixed" version of the typeof operator. It differs from the typeof1168* operator in such a way that null returns 'null' and arrays return 'array'.1169* @param {?} value The value to get the type of.1170* @return {string} The name of the type.1171*/1172goog.typeOf = function(value) {1173var s = typeof value;11741175if (s != 'object') {1176return s;1177}11781179if (!value) {1180return 'null';1181}11821183if (Array.isArray(value)) {1184return 'array';1185}1186return s;1187};118811891190/**1191* Returns true if the object looks like an array. To qualify as array like1192* the value needs to be either a NodeList or an object with a Number length1193* property. Note that for this function neither strings nor functions are1194* considered "array-like".1195*1196* @param {?} val Variable to test.1197* @return {boolean} Whether variable is an array.1198*/1199goog.isArrayLike = function(val) {1200var type = goog.typeOf(val);1201// We do not use goog.isObject here in order to exclude function values.1202return type == 'array' || type == 'object' && typeof val.length == 'number';1203};120412051206/**1207* Returns true if the object looks like a Date. To qualify as Date-like the1208* value needs to be an object and have a getFullYear() function.1209* @param {?} val Variable to test.1210* @return {boolean} Whether variable is a like a Date.1211*/1212goog.isDateLike = function(val) {1213return goog.isObject(val) && typeof val.getFullYear == 'function';1214};121512161217/**1218* Returns true if the specified value is an object. This includes arrays and1219* functions.1220* @param {?} val Variable to test.1221* @return {boolean} Whether variable is an object.1222*/1223goog.isObject = function(val) {1224var type = typeof val;1225return type == 'object' && val != null || type == 'function';1226// return Object(val) === val also works, but is slower, especially if val is1227// not an object.1228};122912301231/**1232* Gets a unique ID for an object. This mutates the object so that further calls1233* with the same object as a parameter returns the same value. The unique ID is1234* guaranteed to be unique across the current session amongst objects that are1235* passed into `getUid`. There is no guarantee that the ID is unique or1236* consistent across sessions. It is unsafe to generate unique ID for function1237* prototypes.1238*1239* @param {Object} obj The object to get the unique ID for.1240* @return {number} The unique ID for the object.1241*/1242goog.getUid = function(obj) {1243// TODO(arv): Make the type stricter, do not accept null.1244return Object.prototype.hasOwnProperty.call(obj, goog.UID_PROPERTY_) &&1245obj[goog.UID_PROPERTY_] ||1246(obj[goog.UID_PROPERTY_] = ++goog.uidCounter_);1247};124812491250/**1251* Whether the given object is already assigned a unique ID.1252*1253* This does not modify the object.1254*1255* @param {!Object} obj The object to check.1256* @return {boolean} Whether there is an assigned unique id for the object.1257*/1258goog.hasUid = function(obj) {1259return !!obj[goog.UID_PROPERTY_];1260};126112621263/**1264* Removes the unique ID from an object. This is useful if the object was1265* previously mutated using `goog.getUid` in which case the mutation is1266* undone.1267* @param {Object} obj The object to remove the unique ID field from.1268*/1269goog.removeUid = function(obj) {1270// TODO(arv): Make the type stricter, do not accept null.12711272// In IE, DOM nodes are not instances of Object and throw an exception if we1273// try to delete. Instead we try to use removeAttribute.1274if (obj !== null && 'removeAttribute' in obj) {1275obj.removeAttribute(goog.UID_PROPERTY_);1276}12771278try {1279delete obj[goog.UID_PROPERTY_];1280} catch (ex) {1281}1282};128312841285/**1286* Name for unique ID property. Initialized in a way to help avoid collisions1287* with other closure JavaScript on the same page.1288* @type {string}1289* @private1290*/1291goog.UID_PROPERTY_ = 'closure_uid_' + ((Math.random() * 1e9) >>> 0);129212931294/**1295* Counter for UID.1296* @type {number}1297* @private1298*/1299goog.uidCounter_ = 0;130013011302/**1303* Clones a value. The input may be an Object, Array, or basic type. Objects and1304* arrays will be cloned recursively.1305*1306* WARNINGS:1307* <code>goog.cloneObject</code> does not detect reference loops. Objects that1308* refer to themselves will cause infinite recursion.1309*1310* <code>goog.cloneObject</code> is unaware of unique identifiers, and copies1311* UIDs created by <code>getUid</code> into cloned results.1312*1313* @param {*} obj The value to clone.1314* @return {*} A clone of the input value.1315* @deprecated goog.cloneObject is unsafe. Prefer the goog.object methods.1316*/1317goog.cloneObject = function(obj) {1318var type = goog.typeOf(obj);1319if (type == 'object' || type == 'array') {1320if (typeof obj.clone === 'function') {1321return obj.clone();1322}1323if (typeof Map !== 'undefined' && obj instanceof Map) {1324return new Map(obj);1325} else if (typeof Set !== 'undefined' && obj instanceof Set) {1326return new Set(obj);1327}1328var clone = type == 'array' ? [] : {};1329for (var key in obj) {1330clone[key] = goog.cloneObject(obj[key]);1331}1332return clone;1333}13341335return obj;1336};133713381339/**1340* A native implementation of goog.bind.1341* @param {?function(this:T, ...)} fn A function to partially apply.1342* @param {T} selfObj Specifies the object which this should point to when the1343* function is run.1344* @param {...*} var_args Additional arguments that are partially applied to the1345* function.1346* @return {!Function} A partially-applied form of the function goog.bind() was1347* invoked as a method of.1348* @template T1349* @private1350*/1351goog.bindNative_ = function(fn, selfObj, var_args) {1352return /** @type {!Function} */ (fn.call.apply(fn.bind, arguments));1353};135413551356/**1357* A pure-JS implementation of goog.bind.1358* @param {?function(this:T, ...)} fn A function to partially apply.1359* @param {T} selfObj Specifies the object which this should point to when the1360* function is run.1361* @param {...*} var_args Additional arguments that are partially applied to the1362* function.1363* @return {!Function} A partially-applied form of the function goog.bind() was1364* invoked as a method of.1365* @template T1366* @private1367*/1368goog.bindJs_ = function(fn, selfObj, var_args) {1369if (!fn) {1370throw new Error();1371}13721373if (arguments.length > 2) {1374var boundArgs = Array.prototype.slice.call(arguments, 2);1375return function() {1376// Prepend the bound arguments to the current arguments.1377var newArgs = Array.prototype.slice.call(arguments);1378Array.prototype.unshift.apply(newArgs, boundArgs);1379return fn.apply(selfObj, newArgs);1380};13811382} else {1383return function() {1384return fn.apply(selfObj, arguments);1385};1386}1387};138813891390/**1391* Partially applies this function to a particular 'this object' and zero or1392* more arguments. The result is a new function with some arguments of the first1393* function pre-filled and the value of this 'pre-specified'.1394*1395* Remaining arguments specified at call-time are appended to the pre-specified1396* ones.1397*1398* Also see: {@link #partial}.1399*1400* Usage:1401* <pre>var barMethBound = goog.bind(myFunction, myObj, 'arg1', 'arg2');1402* barMethBound('arg3', 'arg4');</pre>1403*1404* @param {?function(this:T, ...)} fn A function to partially apply.1405* @param {T} selfObj Specifies the object which this should point to when the1406* function is run.1407* @param {...*} var_args Additional arguments that are partially applied to the1408* function.1409* @return {!Function} A partially-applied form of the function goog.bind() was1410* invoked as a method of.1411* @template T1412* @suppress {deprecated} See above.1413* @deprecated use `=> {}` or Function.prototype.bind instead.1414*/1415goog.bind = function(fn, selfObj, var_args) {1416// TODO(nicksantos): narrow the type signature.1417if (Function.prototype.bind &&1418// NOTE(nicksantos): Somebody pulled base.js into the default Chrome1419// extension environment. This means that for Chrome extensions, they get1420// the implementation of Function.prototype.bind that calls goog.bind1421// instead of the native one. Even worse, we don't want to introduce a1422// circular dependency between goog.bind and Function.prototype.bind, so1423// we have to hack this to make sure it works correctly.1424Function.prototype.bind.toString().indexOf('native code') != -1) {1425goog.bind = goog.bindNative_;1426} else {1427goog.bind = goog.bindJs_;1428}1429return goog.bind.apply(null, arguments);1430};143114321433/**1434* Like goog.bind(), except that a 'this object' is not required. Useful when1435* the target function is already bound.1436*1437* Usage:1438* var g = goog.partial(f, arg1, arg2);1439* g(arg3, arg4);1440*1441* @param {Function} fn A function to partially apply.1442* @param {...*} var_args Additional arguments that are partially applied to fn.1443* @return {!Function} A partially-applied form of the function goog.partial()1444* was invoked as a method of.1445*/1446goog.partial = function(fn, var_args) {1447var args = Array.prototype.slice.call(arguments, 1);1448return function() {1449// Clone the array (with slice()) and append additional arguments1450// to the existing arguments.1451var newArgs = args.slice();1452newArgs.push.apply(newArgs, arguments);1453return fn.apply(/** @type {?} */ (this), newArgs);1454};1455};145614571458/**1459* @return {number} An integer value representing the number of milliseconds1460* between midnight, January 1, 1970 and the current time.1461* @deprecated Use Date.now1462*/1463goog.now = function() {1464return Date.now();1465};146614671468/**1469* Evals JavaScript in the global scope.1470*1471* Throws an exception if neither execScript or eval is defined.1472* @param {string|!TrustedScript} script JavaScript string.1473*/1474goog.globalEval = function(script) {1475(0, eval)(script);1476};147714781479/**1480* Optional map of CSS class names to obfuscated names used with1481* goog.getCssName().1482* @private {!Object<string, string>|undefined}1483* @see goog.setCssNameMapping1484*/1485goog.cssNameMapping_;148614871488/**1489* Optional obfuscation style for CSS class names. Should be set to either1490* 'BY_WHOLE' or 'BY_PART' if defined.1491* @type {string|undefined}1492* @private1493* @see goog.setCssNameMapping1494*/1495goog.cssNameMappingStyle_;1496149714981499/**1500* A hook for modifying the default behavior goog.getCssName. The function1501* if present, will receive the standard output of the goog.getCssName as1502* its input.1503*1504* @type {(function(string):string)|undefined}1505*/1506goog.global.CLOSURE_CSS_NAME_MAP_FN;150715081509/**1510* Handles strings that are intended to be used as CSS class names.1511*1512* This function works in tandem with @see goog.setCssNameMapping.1513*1514* Without any mapping set, the arguments are simple joined with a hyphen and1515* passed through unaltered.1516*1517* When there is a mapping, there are two possible styles in which these1518* mappings are used. In the BY_PART style, each part (i.e. in between hyphens)1519* of the passed in css name is rewritten according to the map. In the BY_WHOLE1520* style, the full css name is looked up in the map directly. If a rewrite is1521* not specified by the map, the compiler will output a warning.1522*1523* When the mapping is passed to the compiler, it will replace calls to1524* goog.getCssName with the strings from the mapping, e.g.1525* var x = goog.getCssName('foo');1526* var y = goog.getCssName(this.baseClass, 'active');1527* becomes:1528* var x = 'foo';1529* var y = this.baseClass + '-active';1530*1531* If one argument is passed it will be processed, if two are passed only the1532* modifier will be processed, as it is assumed the first argument was generated1533* as a result of calling goog.getCssName.1534*1535* @param {string} className The class name.1536* @param {string=} opt_modifier A modifier to be appended to the class name.1537* @return {string} The class name or the concatenation of the class name and1538* the modifier.1539*/1540goog.getCssName = function(className, opt_modifier) {1541// String() is used for compatibility with compiled soy where the passed1542// className can be non-string objects.1543if (String(className).charAt(0) == '.') {1544throw new Error(1545'className passed in goog.getCssName must not start with ".".' +1546' You passed: ' + className);1547}15481549var getMapping = function(cssName) {1550return goog.cssNameMapping_[cssName] || cssName;1551};15521553var renameByParts = function(cssName) {1554// Remap all the parts individually.1555var parts = cssName.split('-');1556var mapped = [];1557for (var i = 0; i < parts.length; i++) {1558mapped.push(getMapping(parts[i]));1559}1560return mapped.join('-');1561};15621563var rename;1564if (goog.cssNameMapping_) {1565rename =1566goog.cssNameMappingStyle_ == 'BY_WHOLE' ? getMapping : renameByParts;1567} else {1568rename = function(a) {1569return a;1570};1571}15721573var result =1574opt_modifier ? className + '-' + rename(opt_modifier) : rename(className);15751576// The special CLOSURE_CSS_NAME_MAP_FN allows users to specify further1577// processing of the class name.1578if (goog.global.CLOSURE_CSS_NAME_MAP_FN) {1579return goog.global.CLOSURE_CSS_NAME_MAP_FN(result);1580}15811582return result;1583};158415851586/**1587* Sets the map to check when returning a value from goog.getCssName(). Example:1588* <pre>1589* goog.setCssNameMapping({1590* "goog": "a",1591* "disabled": "b",1592* });1593*1594* var x = goog.getCssName('goog');1595* // The following evaluates to: "a a-b".1596* goog.getCssName('goog') + ' ' + goog.getCssName(x, 'disabled')1597* </pre>1598* When declared as a map of string literals to string literals, the JSCompiler1599* will replace all calls to goog.getCssName() using the supplied map if the1600* --process_closure_primitives flag is set.1601*1602* @param {!Object} mapping A map of strings to strings where keys are possible1603* arguments to goog.getCssName() and values are the corresponding values1604* that should be returned.1605* @param {string=} opt_style The style of css name mapping. There are two valid1606* options: 'BY_PART', and 'BY_WHOLE'.1607* @see goog.getCssName for a description.1608*/1609goog.setCssNameMapping = function(mapping, opt_style) {1610goog.cssNameMapping_ = mapping;1611goog.cssNameMappingStyle_ = opt_style;1612};161316141615/**1616* To use CSS renaming in compiled mode, one of the input files should have a1617* call to goog.setCssNameMapping() with an object literal that the JSCompiler1618* can extract and use to replace all calls to goog.getCssName(). In uncompiled1619* mode, JavaScript code should be loaded before this base.js file that declares1620* a global variable, CLOSURE_CSS_NAME_MAPPING, which is used below. This is1621* to ensure that the mapping is loaded before any calls to goog.getCssName()1622* are made in uncompiled mode.1623*1624* A hook for overriding the CSS name mapping.1625* @type {!Object<string, string>|undefined}1626*/1627goog.global.CLOSURE_CSS_NAME_MAPPING;162816291630if (!COMPILED && goog.global.CLOSURE_CSS_NAME_MAPPING) {1631// This does not call goog.setCssNameMapping() because the JSCompiler1632// requires that goog.setCssNameMapping() be called with an object literal.1633goog.cssNameMapping_ = goog.global.CLOSURE_CSS_NAME_MAPPING;1634}16351636/**1637* Options bag type for `goog.getMsg()` third argument.1638*1639* It is important to note that these options need to be known at compile time,1640* so they must always be provided to `goog.getMsg()` as an actual object1641* literal in the function call. Otherwise, closure-compiler will report an1642* error.1643* @record1644*/1645goog.GetMsgOptions = function() {};16461647/**1648* If `true`, escape '<' in the message string to '<'.1649*1650* Used by Closure Templates where the generated code size and performance is1651* critical which is why {@link goog.html.SafeHtmlFormatter} is not used.1652* The value must be literal `true` or `false`.1653* @type {boolean|undefined}1654*/1655goog.GetMsgOptions.prototype.html;16561657/**1658* If `true`, unescape common html entities: >, <, ', " and1659* &.1660*1661* Used for messages not in HTML context, such as with the `textContent`1662* property.1663* The value must be literal `true` or `false`.1664* @type {boolean|undefined}1665*/1666goog.GetMsgOptions.prototype.unescapeHtmlEntities;16671668/**1669* Associates placeholder names with strings showing how their values are1670* obtained.1671*1672* This field is intended for use in automatically generated JS code.1673* Human-written code should use meaningful placeholder names instead.1674*1675* closure-compiler uses this as the contents of the `<ph>` tag in the1676* XMB file it generates or defaults to `-` for historical reasons.1677*1678* Must be an object literal.1679* Ignored at runtime.1680* Keys are placeholder names.1681* Values are string literals indicating how the value is obtained.1682* Typically this is a snippet of source code.1683* @type {!Object<string, string>|undefined}1684*/1685goog.GetMsgOptions.prototype.original_code;16861687/**1688* Associates placeholder names with example values.1689*1690* closure-compiler uses this as the contents of the `<ex>` tag in the1691* XMB file it generates or defaults to `-` for historical reasons.1692*1693* Must be an object literal.1694* Ignored at runtime.1695* Keys are placeholder names.1696* Values are string literals containing example placeholder values.1697* (e.g. "George McFly" for a name placeholder)1698* @type {!Object<string, string>|undefined}1699*/1700goog.GetMsgOptions.prototype.example;17011702/**1703* Gets a localized message.1704*1705* This function is a compiler primitive. If you give the compiler a localized1706* message bundle, it will replace the string at compile-time with a localized1707* version, and expand goog.getMsg call to a concatenated string.1708*1709* Messages must be initialized in the form:1710* <code>1711* var MSG_NAME = goog.getMsg('Hello {$placeholder}', {'placeholder': 'world'});1712* </code>1713*1714* This function produces a string which should be treated as plain text. Use1715* {@link goog.html.SafeHtmlFormatter} in conjunction with goog.getMsg to1716* produce SafeHtml.1717*1718* @param {string} str Translatable string, places holders in the form {$foo}.1719* @param {!Object<string, string>=} opt_values Maps place holder name to value.1720* @param {!goog.GetMsgOptions=} opt_options see `goog.GetMsgOptions`1721* @return {string} message with placeholders filled.1722*/1723goog.getMsg = function(str, opt_values, opt_options) {1724if (opt_options && opt_options.html) {1725// Note that '&' is not replaced because the translation can contain HTML1726// entities.1727str = str.replace(/</g, '<');1728}1729if (opt_options && opt_options.unescapeHtmlEntities) {1730// Note that "&" must be the last to avoid "creating" new entities.1731str = str.replace(/</g, '<')1732.replace(/>/g, '>')1733.replace(/'/g, '\'')1734.replace(/"/g, '"')1735.replace(/&/g, '&');1736}1737if (opt_values) {1738str = str.replace(/\{\$([^}]+)}/g, function(match, key) {1739return (opt_values != null && key in opt_values) ? opt_values[key] :1740match;1741});1742}1743return str;1744};174517461747/**1748* Gets a localized message. If the message does not have a translation, gives a1749* fallback message.1750*1751* This is useful when introducing a new message that has not yet been1752* translated into all languages.1753*1754* This function is a compiler primitive. Must be used in the form:1755* <code>var x = goog.getMsgWithFallback(MSG_A, MSG_B);</code>1756* where MSG_A and MSG_B were initialized with goog.getMsg.1757*1758* @param {string} a The preferred message.1759* @param {string} b The fallback message.1760* @return {string} The best translated message.1761*/1762goog.getMsgWithFallback = function(a, b) {1763return a;1764};176517661767/**1768* Exposes an unobfuscated global namespace path for the given object.1769* Note that fields of the exported object *will* be obfuscated, unless they are1770* exported in turn via this function or goog.exportProperty.1771*1772* Also handy for making public items that are defined in anonymous closures.1773*1774* ex. goog.exportSymbol('public.path.Foo', Foo);1775*1776* ex. goog.exportSymbol('public.path.Foo.staticFunction', Foo.staticFunction);1777* public.path.Foo.staticFunction();1778*1779* ex. goog.exportSymbol('public.path.Foo.prototype.myMethod',1780* Foo.prototype.myMethod);1781* new public.path.Foo().myMethod();1782*1783* @param {string} publicPath Unobfuscated name to export.1784* @param {*} object Object the name should point to.1785* @param {?Object=} objectToExportTo The object to add the path to; default1786* is goog.global.1787*/1788goog.exportSymbol = function(publicPath, object, objectToExportTo) {1789goog.exportPath_(1790publicPath, object, /* overwriteImplicit= */ true, objectToExportTo);1791};179217931794/**1795* Exports a property unobfuscated into the object's namespace.1796* ex. goog.exportProperty(Foo, 'staticFunction', Foo.staticFunction);1797* ex. goog.exportProperty(Foo.prototype, 'myMethod', Foo.prototype.myMethod);1798* @param {Object} object Object whose static property is being exported.1799* @param {string} publicName Unobfuscated name to export.1800* @param {*} symbol Object the name should point to.1801*/1802goog.exportProperty = function(object, publicName, symbol) {1803object[publicName] = symbol;1804};180518061807/**1808* Inherit the prototype methods from one constructor into another.1809*1810* Usage:1811* <pre>1812* function ParentClass(a, b) { }1813* ParentClass.prototype.foo = function(a) { };1814*1815* function ChildClass(a, b, c) {1816* ChildClass.base(this, 'constructor', a, b);1817* }1818* goog.inherits(ChildClass, ParentClass);1819*1820* var child = new ChildClass('a', 'b', 'see');1821* child.foo(); // This works.1822* </pre>1823*1824* @param {!Function} childCtor Child class.1825* @param {!Function} parentCtor Parent class.1826* @suppress {strictMissingProperties} superClass_ and base is not defined on1827* Function.1828* @deprecated Use ECMAScript class syntax instead.1829*/1830goog.inherits = function(childCtor, parentCtor) {1831/** @constructor */1832function tempCtor() {}1833tempCtor.prototype = parentCtor.prototype;1834childCtor.superClass_ = parentCtor.prototype;1835childCtor.prototype = new tempCtor();1836/** @override */1837childCtor.prototype.constructor = childCtor;18381839/**1840* Calls superclass constructor/method.1841*1842* This function is only available if you use goog.inherits to1843* express inheritance relationships between classes.1844*1845* NOTE: This is a replacement for goog.base and for superClass_1846* property defined in childCtor.1847*1848* @param {!Object} me Should always be "this".1849* @param {string} methodName The method name to call. Calling1850* superclass constructor can be done with the special string1851* 'constructor'.1852* @param {...*} var_args The arguments to pass to superclass1853* method/constructor.1854* @return {*} The return value of the superclass method/constructor.1855*/1856childCtor.base = function(me, methodName, var_args) {1857// Copying using loop to avoid deop due to passing arguments object to1858// function. This is faster in many JS engines as of late 2014.1859var args = new Array(arguments.length - 2);1860for (var i = 2; i < arguments.length; i++) {1861args[i - 2] = arguments[i];1862}1863return parentCtor.prototype[methodName].apply(me, args);1864};1865};186618671868/**1869* Allow for aliasing within scope functions. This function exists for1870* uncompiled code - in compiled code the calls will be inlined and the aliases1871* applied. In uncompiled code the function is simply run since the aliases as1872* written are valid JavaScript.1873*1874*1875* @param {function()} fn Function to call. This function can contain aliases1876* to namespaces (e.g. "var dom = goog.dom") or classes1877* (e.g. "var Timer = goog.Timer").1878* @deprecated Use goog.module instead.1879*/1880goog.scope = function(fn) {1881if (goog.isInModuleLoader_()) {1882throw new Error('goog.scope is not supported within a module.');1883}1884fn.call(goog.global);1885};188618871888/*1889* To support uncompiled, strict mode bundles that use eval to divide source1890* like so:1891* eval('someSource;//# sourceUrl sourcefile.js');1892* We need to export the globally defined symbols "goog" and "COMPILED".1893* Exporting "goog" breaks the compiler optimizations, so we required that1894* be defined externally.1895* NOTE: We don't use goog.exportSymbol here because we don't want to trigger1896* extern generation when that compiler option is enabled.1897*/1898if (!COMPILED) {1899goog.global['COMPILED'] = COMPILED;1900}190119021903//==============================================================================1904// goog.defineClass implementation1905//==============================================================================190619071908/**1909* Creates a restricted form of a Closure "class":1910* - from the compiler's perspective, the instance returned from the1911* constructor is sealed (no new properties may be added). This enables1912* better checks.1913* - the compiler will rewrite this definition to a form that is optimal1914* for type checking and optimization (initially this will be a more1915* traditional form).1916*1917* @param {Function} superClass The superclass, Object or null.1918* @param {goog.defineClass.ClassDescriptor} def1919* An object literal describing1920* the class. It may have the following properties:1921* "constructor": the constructor function1922* "statics": an object literal containing methods to add to the constructor1923* as "static" methods or a function that will receive the constructor1924* function as its only parameter to which static properties can1925* be added.1926* all other properties are added to the prototype.1927* @return {!Function} The class constructor.1928* @deprecated Use ECMAScript class syntax instead.1929*/1930goog.defineClass = function(superClass, def) {1931// TODO(johnlenz): consider making the superClass an optional parameter.1932var constructor = def.constructor;1933var statics = def.statics;1934// Wrap the constructor prior to setting up the prototype and static methods.1935if (!constructor || constructor == Object.prototype.constructor) {1936constructor = function() {1937throw new Error(1938'cannot instantiate an interface (no constructor defined).');1939};1940}19411942var cls = goog.defineClass.createSealingConstructor_(constructor, superClass);1943if (superClass) {1944goog.inherits(cls, superClass);1945}19461947// Remove all the properties that should not be copied to the prototype.1948delete def.constructor;1949delete def.statics;19501951goog.defineClass.applyProperties_(cls.prototype, def);1952if (statics != null) {1953if (statics instanceof Function) {1954statics(cls);1955} else {1956goog.defineClass.applyProperties_(cls, statics);1957}1958}19591960return cls;1961};196219631964/**1965* @typedef {{1966* constructor: (!Function|undefined),1967* statics: (Object|undefined|function(Function):void)1968* }}1969*/1970goog.defineClass.ClassDescriptor;197119721973/**1974* @define {boolean} Whether the instances returned by goog.defineClass should1975* be sealed when possible.1976*1977* When sealing is disabled the constructor function will not be wrapped by1978* goog.defineClass, making it incompatible with ES6 class methods.1979*/1980goog.defineClass.SEAL_CLASS_INSTANCES =1981goog.define('goog.defineClass.SEAL_CLASS_INSTANCES', goog.DEBUG);198219831984/**1985* If goog.defineClass.SEAL_CLASS_INSTANCES is enabled and Object.seal is1986* defined, this function will wrap the constructor in a function that seals the1987* results of the provided constructor function.1988*1989* @param {!Function} ctr The constructor whose results maybe be sealed.1990* @param {Function} superClass The superclass constructor.1991* @return {!Function} The replacement constructor.1992* @private1993*/1994goog.defineClass.createSealingConstructor_ = function(ctr, superClass) {1995if (!goog.defineClass.SEAL_CLASS_INSTANCES) {1996// Do now wrap the constructor when sealing is disabled. Angular code1997// depends on this for injection to work properly.1998return ctr;1999}20002001// NOTE: The sealing behavior has been removed20022003/**2004* @this {Object}2005* @return {?}2006*/2007var wrappedCtr = function() {2008// Don't seal an instance of a subclass when it calls the constructor of2009// its super class as there is most likely still setup to do.2010var instance = ctr.apply(this, arguments) || this;2011instance[goog.UID_PROPERTY_] = instance[goog.UID_PROPERTY_];20122013return instance;2014};20152016return wrappedCtr;2017};2018201920202021// TODO(johnlenz): share these values with the goog.object2022/**2023* The names of the fields that are defined on Object.prototype.2024* @type {!Array<string>}2025* @private2026* @const2027*/2028goog.defineClass.OBJECT_PROTOTYPE_FIELDS_ = [2029'constructor', 'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable',2030'toLocaleString', 'toString', 'valueOf'2031];203220332034// TODO(johnlenz): share this function with the goog.object2035/**2036* @param {!Object} target The object to add properties to.2037* @param {!Object} source The object to copy properties from.2038* @private2039*/2040goog.defineClass.applyProperties_ = function(target, source) {2041// TODO(johnlenz): update this to support ES5 getters/setters20422043var key;2044for (key in source) {2045if (Object.prototype.hasOwnProperty.call(source, key)) {2046target[key] = source[key];2047}2048}20492050// For IE the for-in-loop does not contain any properties that are not2051// enumerable on the prototype object (for example isPrototypeOf from2052// Object.prototype) and it will also not include 'replace' on objects that2053// extend String and change 'replace' (not that it is common for anyone to2054// extend anything except Object).2055for (var i = 0; i < goog.defineClass.OBJECT_PROTOTYPE_FIELDS_.length; i++) {2056key = goog.defineClass.OBJECT_PROTOTYPE_FIELDS_[i];2057if (Object.prototype.hasOwnProperty.call(source, key)) {2058target[key] = source[key];2059}2060}2061};20622063/**2064* Returns the parameter.2065* @param {string} s2066* @return {string}2067* @private2068*/2069goog.identity_ = function(s) {2070return s;2071};207220732074/**2075* Creates Trusted Types policy if Trusted Types are supported by the browser.2076* The policy just blesses any string as a Trusted Type. It is not visibility2077* restricted because anyone can also call trustedTypes.createPolicy directly.2078* However, the allowed names should be restricted by a HTTP header and the2079* reference to the created policy should be visibility restricted.2080* @param {string} name2081* @return {?TrustedTypePolicy}2082*/2083goog.createTrustedTypesPolicy = function(name) {2084var policy = null;2085var policyFactory = goog.global.trustedTypes;2086if (!policyFactory || !policyFactory.createPolicy) {2087return policy;2088}2089// trustedTypes.createPolicy throws if called with a name that is already2090// registered, even in report-only mode. Until the API changes, catch the2091// error not to break the applications functionally. In such case, the code2092// will fall back to using regular Safe Types.2093// TODO(koto): Remove catching once createPolicy API stops throwing.2094try {2095policy = policyFactory.createPolicy(name, {2096createHTML: goog.identity_,2097createScript: goog.identity_,2098createScriptURL: goog.identity_2099});2100} catch (e) {2101goog.logToConsole_(e.message);2102}2103return policy;2104};21052106// There's a bug in the compiler where without collapse properties the2107// Closure namespace defines do not guard code correctly. To help reduce code2108// size also check for !COMPILED even though it redundant until this is fixed.2109if (!COMPILED && goog.DEPENDENCIES_ENABLED) {211021112112/**2113* Tries to detect whether the current browser is Edge, based on the user2114* agent. This matches only pre-Chromium Edge.2115* @see https://docs.microsoft.com/en-us/microsoft-edge/web-platform/user-agent-string2116* @return {boolean} True if the current browser is Edge.2117* @private2118*/2119goog.isEdge_ = function() {2120var userAgent = goog.global.navigator && goog.global.navigator.userAgent ?2121goog.global.navigator.userAgent :2122'';2123var edgeRe = /Edge\/(\d+)(\.\d)*/i;2124return !!userAgent.match(edgeRe);2125};212621272128/**2129* Tries to detect whether is in the context of an HTML document.2130* @return {boolean} True if it looks like HTML document.2131* @private2132*/2133goog.inHtmlDocument_ = function() {2134/** @type {!Document} */2135var doc = goog.global.document;2136return doc != null && 'write' in doc; // XULDocument misses write.2137};213821392140/**2141* We'd like to check for if the document readyState is 'loading'; however2142* there are bugs on IE 10 and below where the readyState being anything other2143* than 'complete' is not reliable.2144* @return {boolean}2145* @private2146*/2147goog.isDocumentLoading_ = function() {2148// attachEvent is available on IE 6 thru 10 only, and thus can be used to2149// detect those browsers.2150/** @type {!HTMLDocument} */2151var doc = goog.global.document;2152return doc.attachEvent ? doc.readyState != 'complete' :2153doc.readyState == 'loading';2154};215521562157/**2158* Tries to detect the base path of base.js script that bootstraps Closure.2159* @private2160*/2161goog.findBasePath_ = function() {2162if (goog.global.CLOSURE_BASE_PATH != undefined &&2163// Anti DOM-clobbering runtime check (b/37736576).2164typeof goog.global.CLOSURE_BASE_PATH === 'string') {2165goog.basePath = goog.global.CLOSURE_BASE_PATH;2166return;2167} else if (!goog.inHtmlDocument_()) {2168return;2169}2170/** @type {!Document} */2171var doc = goog.global.document;2172// If we have a currentScript available, use it exclusively.2173var currentScript = doc.currentScript;2174if (currentScript) {2175var scripts = [currentScript];2176} else {2177var scripts = doc.getElementsByTagName('SCRIPT');2178}2179// Search backwards since the current script is in almost all cases the one2180// that has base.js.2181for (var i = scripts.length - 1; i >= 0; --i) {2182var script = /** @type {!HTMLScriptElement} */ (scripts[i]);2183var src = script.src;2184var qmark = src.lastIndexOf('?');2185var l = qmark == -1 ? src.length : qmark;2186if (src.slice(l - 7, l) == 'base.js') {2187goog.basePath = src.slice(0, l - 7);2188return;2189}2190}2191};21922193goog.findBasePath_();21942195/**2196* Rewrites closing script tags in input to avoid ending an enclosing script2197* tag.2198*2199* @param {string} str2200* @return {string}2201* @private2202*/2203goog.protectScriptTag_ = function(str) {2204return str.replace(/<\/(SCRIPT)/ig, '\\x3c/$1');2205};220622072208/**2209* A debug loader is responsible for downloading and executing javascript2210* files in an unbundled, uncompiled environment.2211*2212* This can be custimized via the setDependencyFactory method, or by2213* CLOSURE_IMPORT_SCRIPT/CLOSURE_LOAD_FILE_SYNC.2214*2215* @struct @constructor @final @private2216*/2217goog.DebugLoader_ = function() {2218/** @private @const {!Object<string, !goog.Dependency>} */2219this.dependencies_ = {};2220/** @private @const {!Object<string, string>} */2221this.idToPath_ = {};2222/** @private @const {!Object<string, boolean>} */2223this.written_ = {};2224/** @private @const {!Array<!goog.Dependency>} */2225this.loadingDeps_ = [];2226/** @private {!Array<!goog.Dependency>} */2227this.depsToLoad_ = [];2228/** @private {boolean} */2229this.paused_ = false;2230/** @private {!goog.DependencyFactory} */2231this.factory_ = new goog.DependencyFactory();2232/** @private @const {!Object<string, !Function>} */2233this.deferredCallbacks_ = {};2234/** @private @const {!Array<string>} */2235this.deferredQueue_ = [];2236};22372238/**2239* @param {!Array<string>} namespaces2240* @param {function(): undefined} callback Function to call once all the2241* namespaces have loaded.2242*/2243goog.DebugLoader_.prototype.bootstrap = function(namespaces, callback) {2244var cb = callback;2245function resolve() {2246if (cb) {2247goog.global.setTimeout(cb, 0);2248cb = null;2249}2250}22512252if (!namespaces.length) {2253resolve();2254return;2255}22562257var deps = [];2258for (var i = 0; i < namespaces.length; i++) {2259var path = this.getPathFromDeps_(namespaces[i]);2260if (!path) {2261throw new Error('Unregonized namespace: ' + namespaces[i]);2262}2263deps.push(this.dependencies_[path]);2264}22652266var require = goog.require;2267var loaded = 0;2268for (var i = 0; i < namespaces.length; i++) {2269require(namespaces[i]);2270deps[i].onLoad(function() {2271if (++loaded == namespaces.length) {2272resolve();2273}2274});2275}2276};227722782279/**2280* Loads the Closure Dependency file.2281*2282* Exposed a public function so CLOSURE_NO_DEPS can be set to false, base2283* loaded, setDependencyFactory called, and then this called. i.e. allows2284* custom loading of the deps file.2285*/2286goog.DebugLoader_.prototype.loadClosureDeps = function() {2287// Circumvent addDependency, which would try to transpile deps.js if2288// transpile is set to always.2289var relPath = 'deps.js';2290this.depsToLoad_.push(this.factory_.createDependency(2291goog.normalizePath_(goog.basePath + relPath), relPath, [], [], {}));2292this.loadDeps_();2293};229422952296/**2297* Notifies the debug loader when a dependency has been requested.2298*2299* @param {string} absPathOrId Path of the dependency or goog id.2300* @param {boolean=} opt_force2301*/2302goog.DebugLoader_.prototype.requested = function(absPathOrId, opt_force) {2303var path = this.getPathFromDeps_(absPathOrId);2304if (path &&2305(opt_force || this.areDepsLoaded_(this.dependencies_[path].requires))) {2306var callback = this.deferredCallbacks_[path];2307if (callback) {2308delete this.deferredCallbacks_[path];2309callback();2310}2311}2312};231323142315/**2316* Sets the dependency factory, which can be used to create custom2317* goog.Dependency implementations to control how dependencies are loaded.2318*2319* @param {!goog.DependencyFactory} factory2320*/2321goog.DebugLoader_.prototype.setDependencyFactory = function(factory) {2322this.factory_ = factory;2323};232423252326/**2327* Travserses the dependency graph and queues the given dependency, and all of2328* its transitive dependencies, for loading and then starts loading if not2329* paused.2330*2331* @param {string} namespace2332* @private2333*/2334goog.DebugLoader_.prototype.load_ = function(namespace) {2335if (!this.getPathFromDeps_(namespace)) {2336var errorMessage = 'goog.require could not find: ' + namespace;2337goog.logToConsole_(errorMessage);2338} else {2339var loader = this;23402341var deps = [];23422343/** @param {string} namespace */2344var visit = function(namespace) {2345var path = loader.getPathFromDeps_(namespace);23462347if (!path) {2348throw new Error('Bad dependency path or symbol: ' + namespace);2349}23502351if (loader.written_[path]) {2352return;2353}23542355loader.written_[path] = true;23562357var dep = loader.dependencies_[path];2358for (var i = 0; i < dep.requires.length; i++) {2359if (!goog.isProvided_(dep.requires[i])) {2360visit(dep.requires[i]);2361}2362}23632364deps.push(dep);2365};23662367visit(namespace);23682369var wasLoading = !!this.depsToLoad_.length;2370this.depsToLoad_ = this.depsToLoad_.concat(deps);23712372if (!this.paused_ && !wasLoading) {2373this.loadDeps_();2374}2375}2376};237723782379/**2380* Loads any queued dependencies until they are all loaded or paused.2381*2382* @private2383*/2384goog.DebugLoader_.prototype.loadDeps_ = function() {2385var loader = this;2386var paused = this.paused_;23872388while (this.depsToLoad_.length && !paused) {2389(function() {2390var loadCallDone = false;2391var dep = loader.depsToLoad_.shift();23922393var loaded = false;2394loader.loading_(dep);23952396var controller = {2397pause: function() {2398if (loadCallDone) {2399throw new Error('Cannot call pause after the call to load.');2400} else {2401paused = true;2402}2403},2404resume: function() {2405if (loadCallDone) {2406loader.resume_();2407} else {2408// Some dep called pause and then resume in the same load call.2409// Just keep running this same loop.2410paused = false;2411}2412},2413loaded: function() {2414if (loaded) {2415throw new Error('Double call to loaded.');2416}24172418loaded = true;2419loader.loaded_(dep);2420},2421pending: function() {2422// Defensive copy.2423var pending = [];2424for (var i = 0; i < loader.loadingDeps_.length; i++) {2425pending.push(loader.loadingDeps_[i]);2426}2427return pending;2428},2429/**2430* @param {goog.ModuleType} type2431*/2432setModuleState: function(type) {2433goog.moduleLoaderState_ = {2434type: type,2435moduleName: '',2436declareLegacyNamespace: false2437};2438},2439/** @type {function(string, string, string=)} */2440registerEs6ModuleExports: function(2441path, exports, opt_closureNamespace) {2442if (opt_closureNamespace) {2443goog.loadedModules_[opt_closureNamespace] = {2444exports: exports,2445type: goog.ModuleType.ES6,2446moduleId: opt_closureNamespace || ''2447};2448}2449},2450/** @type {function(string, ?)} */2451registerGoogModuleExports: function(moduleId, exports) {2452goog.loadedModules_[moduleId] = {2453exports: exports,2454type: goog.ModuleType.GOOG,2455moduleId: moduleId2456};2457},2458clearModuleState: function() {2459goog.moduleLoaderState_ = null;2460},2461defer: function(callback) {2462if (loadCallDone) {2463throw new Error(2464'Cannot register with defer after the call to load.');2465}2466loader.defer_(dep, callback);2467},2468areDepsLoaded: function() {2469return loader.areDepsLoaded_(dep.requires);2470}2471};24722473try {2474dep.load(controller);2475} finally {2476loadCallDone = true;2477}2478})();2479}24802481if (paused) {2482this.pause_();2483}2484};248524862487/** @private */2488goog.DebugLoader_.prototype.pause_ = function() {2489this.paused_ = true;2490};249124922493/** @private */2494goog.DebugLoader_.prototype.resume_ = function() {2495if (this.paused_) {2496this.paused_ = false;2497this.loadDeps_();2498}2499};250025012502/**2503* Marks the given dependency as loading (load has been called but it has not2504* yet marked itself as finished). Useful for dependencies that want to know2505* what else is loading. Example: goog.modules cannot eval if there are2506* loading dependencies.2507*2508* @param {!goog.Dependency} dep2509* @private2510*/2511goog.DebugLoader_.prototype.loading_ = function(dep) {2512this.loadingDeps_.push(dep);2513};251425152516/**2517* Marks the given dependency as having finished loading and being available2518* for require.2519*2520* @param {!goog.Dependency} dep2521* @private2522*/2523goog.DebugLoader_.prototype.loaded_ = function(dep) {2524for (var i = 0; i < this.loadingDeps_.length; i++) {2525if (this.loadingDeps_[i] == dep) {2526this.loadingDeps_.splice(i, 1);2527break;2528}2529}25302531for (var i = 0; i < this.deferredQueue_.length; i++) {2532if (this.deferredQueue_[i] == dep.path) {2533this.deferredQueue_.splice(i, 1);2534break;2535}2536}25372538if (this.loadingDeps_.length == this.deferredQueue_.length &&2539!this.depsToLoad_.length) {2540// Something has asked to load these, but they may not be directly2541// required again later, so load them now that we know we're done loading2542// everything else. e.g. a goog module entry point.2543while (this.deferredQueue_.length) {2544this.requested(this.deferredQueue_.shift(), true);2545}2546}25472548dep.loaded();2549};255025512552/**2553* @param {!Array<string>} pathsOrIds2554* @return {boolean}2555* @private2556*/2557goog.DebugLoader_.prototype.areDepsLoaded_ = function(pathsOrIds) {2558for (var i = 0; i < pathsOrIds.length; i++) {2559var path = this.getPathFromDeps_(pathsOrIds[i]);2560if (!path ||2561(!(path in this.deferredCallbacks_) &&2562!goog.isProvided_(pathsOrIds[i]))) {2563return false;2564}2565}25662567return true;2568};256925702571/**2572* @param {string} absPathOrId2573* @return {?string}2574* @private2575*/2576goog.DebugLoader_.prototype.getPathFromDeps_ = function(absPathOrId) {2577if (absPathOrId in this.idToPath_) {2578return this.idToPath_[absPathOrId];2579} else if (absPathOrId in this.dependencies_) {2580return absPathOrId;2581} else {2582return null;2583}2584};258525862587/**2588* @param {!goog.Dependency} dependency2589* @param {!Function} callback2590* @private2591*/2592goog.DebugLoader_.prototype.defer_ = function(dependency, callback) {2593this.deferredCallbacks_[dependency.path] = callback;2594this.deferredQueue_.push(dependency.path);2595};259625972598/**2599* Interface for goog.Dependency implementations to have some control over2600* loading of dependencies.2601*2602* @record2603*/2604goog.LoadController = function() {};260526062607/**2608* Tells the controller to halt loading of more dependencies.2609*/2610goog.LoadController.prototype.pause = function() {};261126122613/**2614* Tells the controller to resume loading of more dependencies if paused.2615*/2616goog.LoadController.prototype.resume = function() {};261726182619/**2620* Tells the controller that this dependency has finished loading.2621*2622* This causes this to be removed from pending() and any load callbacks to2623* fire.2624*/2625goog.LoadController.prototype.loaded = function() {};262626272628/**2629* List of dependencies on which load has been called but which have not2630* called loaded on their controller. This includes the current dependency.2631*2632* @return {!Array<!goog.Dependency>}2633*/2634goog.LoadController.prototype.pending = function() {};263526362637/**2638* Registers an object as an ES6 module's exports so that goog.modules may2639* require it by path.2640*2641* @param {string} path Full path of the module.2642* @param {?} exports2643* @param {string=} opt_closureNamespace Closure namespace to associate with2644* this module.2645*/2646goog.LoadController.prototype.registerEs6ModuleExports = function(2647path, exports, opt_closureNamespace) {};264826492650/**2651* Sets the current module state.2652*2653* @param {goog.ModuleType} type Type of module.2654*/2655goog.LoadController.prototype.setModuleState = function(type) {};265626572658/**2659* Clears the current module state.2660*/2661goog.LoadController.prototype.clearModuleState = function() {};266226632664/**2665* Registers a callback to call once the dependency is actually requested2666* via goog.require + all of the immediate dependencies have been loaded or2667* all other files have been loaded. Allows for lazy loading until2668* require'd without pausing dependency loading, which is needed on old IE.2669*2670* @param {!Function} callback2671*/2672goog.LoadController.prototype.defer = function(callback) {};267326742675/**2676* @return {boolean}2677*/2678goog.LoadController.prototype.areDepsLoaded = function() {};267926802681/**2682* Basic super class for all dependencies Closure Library can load.2683*2684* This default implementation is designed to load untranspiled, non-module2685* scripts in a web broswer.2686*2687* For goog.modules see {@see goog.GoogModuleDependency}.2688* For untranspiled ES6 modules {@see goog.Es6ModuleDependency}.2689*2690* @param {string} path Absolute path of this script.2691* @param {string} relativePath Path of this script relative to goog.basePath.2692* @param {!Array<string>} provides goog.provided or goog.module symbols2693* in this file.2694* @param {!Array<string>} requires goog symbols or relative paths to Closure2695* this depends on.2696* @param {!Object<string, string>} loadFlags2697* @struct @constructor2698*/2699goog.Dependency = function(2700path, relativePath, provides, requires, loadFlags) {2701/** @const */2702this.path = path;2703/** @const */2704this.relativePath = relativePath;2705/** @const */2706this.provides = provides;2707/** @const */2708this.requires = requires;2709/** @const */2710this.loadFlags = loadFlags;2711/** @private {boolean} */2712this.loaded_ = false;2713/** @private {!Array<function()>} */2714this.loadCallbacks_ = [];2715};271627172718/**2719* @return {string} The pathname part of this dependency's path if it is a2720* URI.2721*/2722goog.Dependency.prototype.getPathName = function() {2723var pathName = this.path;2724var protocolIndex = pathName.indexOf('://');2725if (protocolIndex >= 0) {2726pathName = pathName.substring(protocolIndex + 3);2727var slashIndex = pathName.indexOf('/');2728if (slashIndex >= 0) {2729pathName = pathName.substring(slashIndex + 1);2730}2731}2732return pathName;2733};273427352736/**2737* @param {function()} callback Callback to fire as soon as this has loaded.2738* @final2739*/2740goog.Dependency.prototype.onLoad = function(callback) {2741if (this.loaded_) {2742callback();2743} else {2744this.loadCallbacks_.push(callback);2745}2746};274727482749/**2750* Marks this dependency as loaded and fires any callbacks registered with2751* onLoad.2752* @final2753*/2754goog.Dependency.prototype.loaded = function() {2755this.loaded_ = true;2756var callbacks = this.loadCallbacks_;2757this.loadCallbacks_ = [];2758for (var i = 0; i < callbacks.length; i++) {2759callbacks[i]();2760}2761};276227632764/**2765* Whether or not document.written / appended script tags should be deferred.2766*2767* @private {boolean}2768*/2769goog.Dependency.defer_ = false;277027712772/**2773* Map of script ready / state change callbacks. Old IE cannot handle putting2774* these properties on goog.global.2775*2776* @private @const {!Object<string, function(?):undefined>}2777*/2778goog.Dependency.callbackMap_ = {};277927802781/**2782* @param {function(...?):?} callback2783* @return {string}2784* @private2785*/2786goog.Dependency.registerCallback_ = function(callback) {2787var key = Math.random().toString(32);2788goog.Dependency.callbackMap_[key] = callback;2789return key;2790};279127922793/**2794* @param {string} key2795* @private2796*/2797goog.Dependency.unregisterCallback_ = function(key) {2798delete goog.Dependency.callbackMap_[key];2799};280028012802/**2803* @param {string} key2804* @param {...?} var_args2805* @private2806* @suppress {unusedPrivateMembers}2807*/2808goog.Dependency.callback_ = function(key, var_args) {2809if (key in goog.Dependency.callbackMap_) {2810var callback = goog.Dependency.callbackMap_[key];2811var args = [];2812for (var i = 1; i < arguments.length; i++) {2813args.push(arguments[i]);2814}2815callback.apply(undefined, args);2816} else {2817var errorMessage = 'Callback key ' + key +2818' does not exist (was base.js loaded more than once?).';2819throw Error(errorMessage);2820}2821};282228232824/**2825* Starts loading this dependency. This dependency can pause loading if it2826* needs to and resume it later via the controller interface.2827*2828* When this is loaded it should call controller.loaded(). Note that this will2829* end up calling the loaded method of this dependency; there is no need to2830* call it explicitly.2831*2832* @param {!goog.LoadController} controller2833*/2834goog.Dependency.prototype.load = function(controller) {2835if (goog.global.CLOSURE_IMPORT_SCRIPT) {2836if (goog.global.CLOSURE_IMPORT_SCRIPT(this.path)) {2837controller.loaded();2838} else {2839controller.pause();2840}2841return;2842}28432844if (!goog.inHtmlDocument_()) {2845goog.logToConsole_(2846'Cannot use default debug loader outside of HTML documents.');2847if (this.relativePath == 'deps.js') {2848// Some old code is relying on base.js auto loading deps.js failing with2849// no error before later setting CLOSURE_IMPORT_SCRIPT.2850// CLOSURE_IMPORT_SCRIPT should be set *before* base.js is loaded, or2851// CLOSURE_NO_DEPS set to true.2852goog.logToConsole_(2853'Consider setting CLOSURE_IMPORT_SCRIPT before loading base.js, ' +2854'or setting CLOSURE_NO_DEPS to true.');2855controller.loaded();2856} else {2857controller.pause();2858}2859return;2860}28612862/** @type {!HTMLDocument} */2863var doc = goog.global.document;28642865// If the user tries to require a new symbol after document load,2866// something has gone terribly wrong. Doing a document.write would2867// wipe out the page. This does not apply to the CSP-compliant method2868// of writing script tags.2869if (doc.readyState == 'complete' &&2870!goog.ENABLE_CHROME_APP_SAFE_SCRIPT_LOADING) {2871// Certain test frameworks load base.js multiple times, which tries2872// to write deps.js each time. If that happens, just fail silently.2873// These frameworks wipe the page between each load of base.js, so this2874// is OK.2875var isDeps = /\bdeps.js$/.test(this.path);2876if (isDeps) {2877controller.loaded();2878return;2879} else {2880throw Error('Cannot write "' + this.path + '" after document load');2881}2882}28832884var nonce = goog.getScriptNonce_();2885if (!goog.ENABLE_CHROME_APP_SAFE_SCRIPT_LOADING &&2886goog.isDocumentLoading_()) {2887var key;2888var callback = function(script) {2889if (script.readyState && script.readyState != 'complete') {2890script.onload = callback;2891return;2892}2893goog.Dependency.unregisterCallback_(key);2894controller.loaded();2895};2896key = goog.Dependency.registerCallback_(callback);28972898var defer = goog.Dependency.defer_ ? ' defer' : '';2899var nonceAttr = nonce ? ' nonce="' + nonce + '"' : '';2900var script = '<script src="' + this.path + '"' + nonceAttr + defer +2901' id="script-' + key + '"><\/script>';29022903script += '<script' + nonceAttr + '>';29042905if (goog.Dependency.defer_) {2906script += 'document.getElementById(\'script-' + key +2907'\').onload = function() {\n' +2908' goog.Dependency.callback_(\'' + key + '\', this);\n' +2909'};\n';2910} else {2911script += 'goog.Dependency.callback_(\'' + key +2912'\', document.getElementById(\'script-' + key + '\'));';2913}29142915script += '<\/script>';29162917doc.write(2918goog.TRUSTED_TYPES_POLICY_ ?2919goog.TRUSTED_TYPES_POLICY_.createHTML(script) :2920script);2921} else {2922var scriptEl =2923/** @type {!HTMLScriptElement} */ (doc.createElement('script'));2924scriptEl.defer = goog.Dependency.defer_;2925scriptEl.async = false;29262927// If CSP nonces are used, propagate them to dynamically created scripts.2928// This is necessary to allow nonce-based CSPs without 'strict-dynamic'.2929if (nonce) {2930scriptEl.nonce = nonce;2931}29322933scriptEl.onload = function() {2934scriptEl.onload = null;2935controller.loaded();2936};29372938scriptEl.src = goog.TRUSTED_TYPES_POLICY_ ?2939goog.TRUSTED_TYPES_POLICY_.createScriptURL(this.path) :2940this.path;2941doc.head.appendChild(scriptEl);2942}2943};294429452946/**2947* @param {string} path Absolute path of this script.2948* @param {string} relativePath Path of this script relative to goog.basePath.2949* @param {!Array<string>} provides Should be an empty array.2950* TODO(johnplaisted) add support for adding closure namespaces to ES62951* modules for interop purposes.2952* @param {!Array<string>} requires goog symbols or relative paths to Closure2953* this depends on.2954* @param {!Object<string, string>} loadFlags2955* @struct @constructor2956* @extends {goog.Dependency}2957*/2958goog.Es6ModuleDependency = function(2959path, relativePath, provides, requires, loadFlags) {2960goog.Es6ModuleDependency.base(2961this, 'constructor', path, relativePath, provides, requires, loadFlags);2962};2963goog.inherits(goog.Es6ModuleDependency, goog.Dependency);296429652966/**2967* @override2968* @param {!goog.LoadController} controller2969*/2970goog.Es6ModuleDependency.prototype.load = function(controller) {2971if (goog.global.CLOSURE_IMPORT_SCRIPT) {2972if (goog.global.CLOSURE_IMPORT_SCRIPT(this.path)) {2973controller.loaded();2974} else {2975controller.pause();2976}2977return;2978}29792980if (!goog.inHtmlDocument_()) {2981goog.logToConsole_(2982'Cannot use default debug loader outside of HTML documents.');2983controller.pause();2984return;2985}29862987/** @type {!HTMLDocument} */2988var doc = goog.global.document;29892990var dep = this;29912992// TODO(johnplaisted): Does document.writing really speed up anything? Any2993// difference between this and just waiting for interactive mode and then2994// appending?2995function write(src, contents) {2996var nonceAttr = '';2997var nonce = goog.getScriptNonce_();2998if (nonce) {2999nonceAttr = ' nonce="' + nonce + '"';3000}30013002if (contents) {3003var script = '<script type="module" crossorigin' + nonceAttr + '>' +3004contents + '</' +3005'script>';3006doc.write(3007goog.TRUSTED_TYPES_POLICY_ ?3008goog.TRUSTED_TYPES_POLICY_.createHTML(script) :3009script);3010} else {3011var script = '<script type="module" crossorigin src="' + src + '"' +3012nonceAttr + '></' +3013'script>';3014doc.write(3015goog.TRUSTED_TYPES_POLICY_ ?3016goog.TRUSTED_TYPES_POLICY_.createHTML(script) :3017script);3018}3019}30203021function append(src, contents) {3022var scriptEl =3023/** @type {!HTMLScriptElement} */ (doc.createElement('script'));3024scriptEl.defer = true;3025scriptEl.async = false;3026scriptEl.type = 'module';3027scriptEl.setAttribute('crossorigin', true);30283029// If CSP nonces are used, propagate them to dynamically created scripts.3030// This is necessary to allow nonce-based CSPs without 'strict-dynamic'.3031var nonce = goog.getScriptNonce_();3032if (nonce) {3033scriptEl.nonce = nonce;3034}30353036if (contents) {3037scriptEl.text = goog.TRUSTED_TYPES_POLICY_ ?3038goog.TRUSTED_TYPES_POLICY_.createScript(contents) :3039contents;3040} else {3041scriptEl.src = goog.TRUSTED_TYPES_POLICY_ ?3042goog.TRUSTED_TYPES_POLICY_.createScriptURL(src) :3043src;3044}30453046doc.head.appendChild(scriptEl);3047}30483049var create;30503051if (goog.isDocumentLoading_()) {3052create = write;3053// We can ONLY call document.write if we are guaranteed that any3054// non-module script tags document.written after this are deferred.3055// Small optimization, in theory document.writing is faster.3056goog.Dependency.defer_ = true;3057} else {3058create = append;3059}30603061// Write 4 separate tags here:3062// 1) Sets the module state at the correct time (just before execution).3063// 2) A src node for this, which just hopefully lets the browser load it a3064// little early (no need to parse #3).3065// 3) Import the module and register it.3066// 4) Clear the module state at the correct time. Guaranteed to run even3067// if there is an error in the module (#3 will not run if there is an3068// error in the module).3069var beforeKey = goog.Dependency.registerCallback_(function() {3070goog.Dependency.unregisterCallback_(beforeKey);3071controller.setModuleState(goog.ModuleType.ES6);3072});3073create(undefined, 'goog.Dependency.callback_("' + beforeKey + '")');30743075// TODO(johnplaisted): Does this really speed up anything?3076create(this.path, undefined);30773078var registerKey = goog.Dependency.registerCallback_(function(exports) {3079goog.Dependency.unregisterCallback_(registerKey);3080controller.registerEs6ModuleExports(3081dep.path, exports, goog.moduleLoaderState_.moduleName);3082});3083create(3084undefined,3085'import * as m from "' + this.path + '"; goog.Dependency.callback_("' +3086registerKey + '", m)');30873088var afterKey = goog.Dependency.registerCallback_(function() {3089goog.Dependency.unregisterCallback_(afterKey);3090controller.clearModuleState();3091controller.loaded();3092});3093create(undefined, 'goog.Dependency.callback_("' + afterKey + '")');3094};309530963097/**3098* Superclass of any dependency that needs to be loaded into memory,3099* transformed, and then eval'd (goog.modules and transpiled files).3100*3101* @param {string} path Absolute path of this script.3102* @param {string} relativePath Path of this script relative to goog.basePath.3103* @param {!Array<string>} provides goog.provided or goog.module symbols3104* in this file.3105* @param {!Array<string>} requires goog symbols or relative paths to Closure3106* this depends on.3107* @param {!Object<string, string>} loadFlags3108* @struct @constructor @abstract3109* @extends {goog.Dependency}3110*/3111goog.TransformedDependency = function(3112path, relativePath, provides, requires, loadFlags) {3113goog.TransformedDependency.base(3114this, 'constructor', path, relativePath, provides, requires, loadFlags);3115/** @private {?string} */3116this.contents_ = null;31173118/**3119* Whether to lazily make the synchronous XHR (when goog.require'd) or make3120* the synchronous XHR when initially loading. On FireFox 61 there is a bug3121* where an ES6 module cannot make a synchronous XHR (rather, it can, but if3122* it does then no other ES6 modules will load after).3123*3124* tl;dr we lazy load due to bugs on older browsers and eager load due to3125* bugs on newer ones.3126*3127* https://bugzilla.mozilla.org/show_bug.cgi?id=14770903128*3129* @private @const {boolean}3130*/3131this.lazyFetch_ = !goog.inHtmlDocument_() ||3132!('noModule' in goog.global.document.createElement('script'));3133};3134goog.inherits(goog.TransformedDependency, goog.Dependency);313531363137/**3138* @override3139* @param {!goog.LoadController} controller3140*/3141goog.TransformedDependency.prototype.load = function(controller) {3142var dep = this;31433144function fetch() {3145dep.contents_ = goog.loadFileSync_(dep.path);31463147if (dep.contents_) {3148dep.contents_ = dep.transform(dep.contents_);3149if (dep.contents_) {3150dep.contents_ += '\n//# sourceURL=' + dep.path;3151}3152}3153}31543155if (goog.global.CLOSURE_IMPORT_SCRIPT) {3156fetch();3157if (this.contents_ &&3158goog.global.CLOSURE_IMPORT_SCRIPT('', this.contents_)) {3159this.contents_ = null;3160controller.loaded();3161} else {3162controller.pause();3163}3164return;3165}316631673168var isEs6 = this.loadFlags['module'] == goog.ModuleType.ES6;31693170if (!this.lazyFetch_) {3171fetch();3172}31733174function load() {3175if (dep.lazyFetch_) {3176fetch();3177}31783179if (!dep.contents_) {3180// loadFileSync_ or transform are responsible. Assume they logged an3181// error.3182return;3183}31843185if (isEs6) {3186controller.setModuleState(goog.ModuleType.ES6);3187}31883189var namespace;31903191try {3192var contents = dep.contents_;3193dep.contents_ = null;3194goog.globalEval(goog.CLOSURE_EVAL_PREFILTER_.createScript(contents));3195if (isEs6) {3196namespace = goog.moduleLoaderState_.moduleName;3197}3198} finally {3199if (isEs6) {3200controller.clearModuleState();3201}3202}32033204if (isEs6) {3205// Due to circular dependencies this may not be available for require3206// right now.3207goog.global['$jscomp']['require']['ensure'](3208[dep.getPathName()], function() {3209controller.registerEs6ModuleExports(3210dep.path,3211goog.global['$jscomp']['require'](dep.getPathName()),3212namespace);3213});3214}32153216controller.loaded();3217}32183219// Do not fetch now; in FireFox 47 the synchronous XHR doesn't block all3220// events. If we fetched now and then document.write'd the contents the3221// document.write would be an eval and would execute too soon! Instead write3222// a script tag to fetch and eval synchronously at the correct time.3223function fetchInOwnScriptThenLoad() {3224/** @type {!HTMLDocument} */3225var doc = goog.global.document;32263227var key = goog.Dependency.registerCallback_(function() {3228goog.Dependency.unregisterCallback_(key);3229load();3230});32313232var nonce = goog.getScriptNonce_();3233var nonceAttr = nonce ? ' nonce="' + nonce + '"' : '';3234var script = '<script' + nonceAttr + '>' +3235goog.protectScriptTag_('goog.Dependency.callback_("' + key + '");') +3236'</' +3237'script>';3238doc.write(3239goog.TRUSTED_TYPES_POLICY_ ?3240goog.TRUSTED_TYPES_POLICY_.createHTML(script) :3241script);3242}32433244// If one thing is pending it is this.3245var anythingElsePending = controller.pending().length > 1;32463247// Additionally if we are meant to defer scripts but the page is still3248// loading (e.g. an ES6 module is loading) then also defer. Or if we are3249// meant to defer and anything else is pending then defer (those may be3250// scripts that did not need transformation and are just script tags with3251// defer set to true, and we need to evaluate after that deferred script).3252var needsAsyncLoading = goog.Dependency.defer_ &&3253(anythingElsePending || goog.isDocumentLoading_());32543255if (needsAsyncLoading) {3256// Note that we only defer when we have to rather than 100% of the time.3257// Always defering would work, but then in theory the order of3258// goog.require calls would then matter. We want to enforce that most of3259// the time the order of the require calls does not matter.3260controller.defer(function() {3261load();3262});3263return;3264}3265// TODO(johnplaisted): Externs are missing onreadystatechange for3266// HTMLDocument.3267/** @type {?} */3268var doc = goog.global.document;32693270var isInternetExplorerOrEdge = goog.inHtmlDocument_() &&3271('ActiveXObject' in goog.global || goog.isEdge_());32723273// Don't delay in any version of IE or pre-Chromium Edge. There's a bug3274// around this that will cause out of order script execution. This means3275// that on older IE ES6 modules will load too early (while the document is3276// still loading + the dom is not available). The other option is to load3277// too late (when the document is complete and the onload even will never3278// fire). This seems to be the lesser of two evils as scripts already act3279// like the former.3280if (isEs6 && goog.inHtmlDocument_() && goog.isDocumentLoading_() &&3281!isInternetExplorerOrEdge) {3282goog.Dependency.defer_ = true;3283// Transpiled ES6 modules still need to load like regular ES6 modules,3284// aka only after the document is interactive.3285controller.pause();3286var oldCallback = doc.onreadystatechange;3287doc.onreadystatechange = function() {3288if (doc.readyState == 'interactive') {3289doc.onreadystatechange = oldCallback;3290load();3291controller.resume();3292}3293if (typeof oldCallback === 'function') {3294oldCallback.apply(undefined, arguments);3295}3296};3297} else {3298// Always eval on old IE.3299if (!goog.inHtmlDocument_() || !goog.isDocumentLoading_()) {3300load();3301} else {3302fetchInOwnScriptThenLoad();3303}3304}3305};330633073308/**3309* @param {string} contents3310* @return {string}3311* @abstract3312*/3313goog.TransformedDependency.prototype.transform = function(contents) {};331433153316/**3317* An ES6 module dependency that was transpiled to a jscomp module outside3318* of the debug loader, e.g. server side.3319*3320* @param {string} path Absolute path of this script.3321* @param {string} relativePath Path of this script relative to goog.basePath.3322* @param {!Array<string>} provides goog.provided or goog.module symbols3323* in this file.3324* @param {!Array<string>} requires goog symbols or relative paths to Closure3325* this depends on.3326* @param {!Object<string, string>} loadFlags3327* @struct @constructor3328* @extends {goog.TransformedDependency}3329*/3330goog.PreTranspiledEs6ModuleDependency = function(3331path, relativePath, provides, requires, loadFlags) {3332goog.PreTranspiledEs6ModuleDependency.base(3333this, 'constructor', path, relativePath, provides, requires, loadFlags);3334};3335goog.inherits(3336goog.PreTranspiledEs6ModuleDependency, goog.TransformedDependency);333733383339/**3340* @override3341* @param {string} contents3342* @return {string}3343*/3344goog.PreTranspiledEs6ModuleDependency.prototype.transform = function(3345contents) {3346return contents;3347};334833493350/**3351* A goog.module, transpiled or not. Will always perform some minimal3352* transformation even when not transpiled to wrap in a goog.loadModule3353* statement.3354*3355* @param {string} path Absolute path of this script.3356* @param {string} relativePath Path of this script relative to goog.basePath.3357* @param {!Array<string>} provides goog.provided or goog.module symbols3358* in this file.3359* @param {!Array<string>} requires goog symbols or relative paths to Closure3360* this depends on.3361* @param {!Object<string, string>} loadFlags3362* @struct @constructor3363* @extends {goog.TransformedDependency}3364*/3365goog.GoogModuleDependency = function(3366path, relativePath, provides, requires, loadFlags) {3367goog.GoogModuleDependency.base(3368this, 'constructor', path, relativePath, provides, requires, loadFlags);3369};3370goog.inherits(goog.GoogModuleDependency, goog.TransformedDependency);337133723373/**3374* @override3375* @param {string} contents3376* @return {string}3377*/3378goog.GoogModuleDependency.prototype.transform = function(contents) {3379if (!goog.LOAD_MODULE_USING_EVAL || goog.global.JSON === undefined) {3380return '' +3381'goog.loadModule(function(exports) {' +3382'"use strict";' + contents +3383'\n' + // terminate any trailing single line comment.3384';return exports' +3385'});' +3386'\n//# sourceURL=' + this.path + '\n';3387} else {3388return '' +3389'goog.loadModule(' +3390goog.global.JSON.stringify(3391contents + '\n//# sourceURL=' + this.path + '\n') +3392');';3393}3394};339533963397/**3398* @param {string} relPath3399* @param {!Array<string>|undefined} provides3400* @param {!Array<string>} requires3401* @param {boolean|!Object<string>=} opt_loadFlags3402* @see goog.addDependency3403*/3404goog.DebugLoader_.prototype.addDependency = function(3405relPath, provides, requires, opt_loadFlags) {3406provides = provides || [];3407relPath = relPath.replace(/\\/g, '/');3408var path = goog.normalizePath_(goog.basePath + relPath);3409if (!opt_loadFlags || typeof opt_loadFlags === 'boolean') {3410opt_loadFlags = opt_loadFlags ? {'module': goog.ModuleType.GOOG} : {};3411}3412var dep = this.factory_.createDependency(3413path, relPath, provides, requires, opt_loadFlags);3414this.dependencies_[path] = dep;3415for (var i = 0; i < provides.length; i++) {3416this.idToPath_[provides[i]] = path;3417}3418this.idToPath_[relPath] = path;3419};342034213422/**3423* Creates goog.Dependency instances for the debug loader to load.3424*3425* Should be overridden to have the debug loader use custom subclasses of3426* goog.Dependency.3427*3428* @struct @constructor3429*/3430goog.DependencyFactory = function() {};343134323433/**3434* @param {string} path Absolute path of the file.3435* @param {string} relativePath Path relative to closure’s base.js.3436* @param {!Array<string>} provides Array of provided goog.provide/module ids.3437* @param {!Array<string>} requires Array of required goog.provide/module /3438* relative ES6 module paths.3439* @param {!Object<string, string>} loadFlags3440* @return {!goog.Dependency}3441*/3442goog.DependencyFactory.prototype.createDependency = function(3443path, relativePath, provides, requires, loadFlags) {34443445if (loadFlags['module'] == goog.ModuleType.GOOG) {3446return new goog.GoogModuleDependency(3447path, relativePath, provides, requires, loadFlags);3448} else {3449if (loadFlags['module'] == goog.ModuleType.ES6) {3450if (goog.ASSUME_ES_MODULES_TRANSPILED) {3451return new goog.PreTranspiledEs6ModuleDependency(3452path, relativePath, provides, requires, loadFlags);3453} else {3454return new goog.Es6ModuleDependency(3455path, relativePath, provides, requires, loadFlags);3456}3457} else {3458return new goog.Dependency(3459path, relativePath, provides, requires, loadFlags);3460}3461}3462};346334643465/** @private @const */3466goog.debugLoader_ = new goog.DebugLoader_();346734683469/**3470* Loads the Closure Dependency file.3471*3472* Exposed a public function so CLOSURE_NO_DEPS can be set to false, base3473* loaded, setDependencyFactory called, and then this called. i.e. allows3474* custom loading of the deps file.3475*/3476goog.loadClosureDeps = function() {3477goog.debugLoader_.loadClosureDeps();3478};347934803481/**3482* Sets the dependency factory, which can be used to create custom3483* goog.Dependency implementations to control how dependencies are loaded.3484*3485* Note: if you wish to call this function and provide your own implemnetation3486* it is a wise idea to set CLOSURE_NO_DEPS to true, otherwise the dependency3487* file and all of its goog.addDependency calls will use the default factory.3488* You can call goog.loadClosureDeps to load the Closure dependency file3489* later, after your factory is injected.3490*3491* @param {!goog.DependencyFactory} factory3492*/3493goog.setDependencyFactory = function(factory) {3494goog.debugLoader_.setDependencyFactory(factory);3495};349634973498/**3499* Trusted Types policy for the debug loader.3500* @private @const {?TrustedTypePolicy}3501*/3502goog.TRUSTED_TYPES_POLICY_ = goog.TRUSTED_TYPES_POLICY_NAME ?3503goog.createTrustedTypesPolicy(goog.TRUSTED_TYPES_POLICY_NAME + '#base') :3504null;35053506if (!goog.global.CLOSURE_NO_DEPS) {3507goog.debugLoader_.loadClosureDeps();3508}350935103511/**3512* Bootstraps the given namespaces and calls the callback once they are3513* available either via goog.require. This is a replacement for using3514* `goog.require` to bootstrap Closure JavaScript. Previously a `goog.require`3515* in an HTML file would guarantee that the require'd namespace was available3516* in the next immediate script tag. With ES6 modules this no longer a3517* guarantee.3518*3519* @param {!Array<string>} namespaces3520* @param {function(): ?} callback Function to call once all the namespaces3521* have loaded. Always called asynchronously.3522*/3523goog.bootstrap = function(namespaces, callback) {3524goog.debugLoader_.bootstrap(namespaces, callback);3525};3526}352735283529if (!COMPILED) {3530var isChrome87 = false;3531// Cannot run check for Chrome <87 bug in case of strict CSP environments.3532// TODO(user): Remove once Chrome <87 bug is no longer a problem.3533try {3534isChrome87 = eval(goog.global.trustedTypes.emptyScript) !==3535goog.global.trustedTypes.emptyScript;3536} catch (err) {3537}35383539/**3540* Trusted Types for running dev servers.3541*3542* @private @const3543*/3544goog.CLOSURE_EVAL_PREFILTER_ =3545// Detect Chrome <87 bug with TT and eval.3546goog.global.trustedTypes && isChrome87 &&3547goog.createTrustedTypesPolicy('goog#base#devonly#eval') ||3548{createScript: goog.identity_};3549}3550355135523553