var CLOSURE_NO_DEPS = true;
window.polymerSkipLoadingFontRoboto = true;
(function(){window.ga=function(){},
/**
    @license
    Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
    The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
    The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
    Code distributed by Google as part of the polymer project is also
    subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
    */
window.JSCompiler_renameProperty=function(e,t){return e};
/**
    @license
    Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
    The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
    The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
    Code distributed by Google as part of the polymer project is also
    subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
    */
let CSS_URL_RX=/(url\()([^)]*)(\))/g,ABS_URL=/(^\/[^\/])|(^#)|(^[\w-\d]*:)/,workingURL,resolveDoc;function resolveUrl(e,t){if(e&&ABS_URL.test(e))return e;if("//"===e)return e;if(void 0===workingURL){workingURL=!1;try{const e=new URL("b","http://a");e.pathname="c%20d",workingURL="http://a/c%20d"===e.href}catch(e){}}if(t||(t=document.baseURI||window.location.href),workingURL)try{return new URL(e,t).href}catch(t){return e}return resolveDoc||(resolveDoc=document.implementation.createHTMLDocument("temp"),resolveDoc.base=resolveDoc.createElement("base"),resolveDoc.head.appendChild(resolveDoc.base),resolveDoc.anchor=resolveDoc.createElement("a"),resolveDoc.body.appendChild(resolveDoc.anchor)),resolveDoc.base.href=t,resolveDoc.anchor.href=e,resolveDoc.anchor.href||e}function resolveCss(e,t){return e.replace(CSS_URL_RX,(function(e,n,r,i){return n+"'"+resolveUrl(r.replace(/["']/g,""),t)+"'"+i}))}function pathFromUrl(e){return e.substring(0,e.lastIndexOf("/")+1)}
/**
    @license
    Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
    The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
    The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
    Code distributed by Google as part of the polymer project is also
    subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
    */const useShadow=!window.ShadyDOM||!window.ShadyDOM.inUse;Boolean(!window.ShadyCSS||window.ShadyCSS.nativeCss);const supportsAdoptingStyleSheets=useShadow&&"adoptedStyleSheets"in Document.prototype&&"replaceSync"in CSSStyleSheet.prototype&&(()=>{try{const e=new CSSStyleSheet;e.replaceSync("");const t=document.createElement("div");return t.attachShadow({mode:"open"}),t.shadowRoot.adoptedStyleSheets=[e],t.shadowRoot.adoptedStyleSheets[0]===e}catch(e){return!1}})();let rootPath=window.Polymer&&window.Polymer.rootPath||pathFromUrl(document.baseURI||window.location.href),sanitizeDOMValue=window.Polymer&&window.Polymer.sanitizeDOMValue||void 0,passiveTouchGestures=window.Polymer&&window.Polymer.setPassiveTouchGestures||!1,strictTemplatePolicy=window.Polymer&&window.Polymer.strictTemplatePolicy||!1;const setStrictTemplatePolicy=function(e){strictTemplatePolicy=e};let allowTemplateFromDomModule=window.Polymer&&window.Polymer.allowTemplateFromDomModule||!1,legacyOptimizations=window.Polymer&&window.Polymer.legacyOptimizations||!1,legacyWarnings=window.Polymer&&window.Polymer.legacyWarnings||!1,syncInitialRender=window.Polymer&&window.Polymer.syncInitialRender||!1,legacyUndefined=window.Polymer&&window.Polymer.legacyUndefined||!1,orderedComputed=window.Polymer&&window.Polymer.orderedComputed||!1,removeNestedTemplates=window.Polymer&&window.Polymer.removeNestedTemplates||!1,fastDomIf=window.Polymer&&window.Polymer.fastDomIf||!1,suppressTemplateNotifications=window.Polymer&&window.Polymer.suppressTemplateNotifications||!1,legacyNoObservedAttributes=window.Polymer&&window.Polymer.legacyNoObservedAttributes||!1,useAdoptedStyleSheetsWithBuiltCSS=window.Polymer&&window.Polymer.useAdoptedStyleSheetsWithBuiltCSS||!1;setStrictTemplatePolicy(!0);
/**
    @license
    Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
    The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
    The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
    Code distributed by Google as part of the polymer project is also
    subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
    */
let modules={},lcModules={};function setModule(e,t){modules[e]=lcModules[e.toLowerCase()]=t}function findModule(e){return modules[e]||lcModules[e.toLowerCase()]}function styleOutsideTemplateCheck(e){e.querySelector("style")&&console.warn("dom-module %s has style outside template",e.id)}class DomModule extends HTMLElement{static get observedAttributes(){return["id"]}static import(e,t){if(e){let n=findModule(e);return n&&t?n.querySelector(t):n}return null}attributeChangedCallback(e,t,n,r){t!==n&&this.register()}get assetpath(){if(!this.__assetpath){const e=window.HTMLImports&&HTMLImports.importForElement?HTMLImports.importForElement(this)||document:this.ownerDocument,t=resolveUrl(this.getAttribute("assetpath")||"",e.baseURI);this.__assetpath=pathFromUrl(t)}return this.__assetpath}register(e){if(e=e||this.id){if(strictTemplatePolicy&&void 0!==findModule(e))throw setModule(e,null),new Error(`strictTemplatePolicy: dom-module ${e} re-registered`);this.id=e,setModule(e,this),styleOutsideTemplateCheck(this)}}}function registerStyleDomModule(e){const{moduleName:t,styleContent:n}=e,r=document.createElement("dom-module"),i=document.createElement("template"),a=[];e.styleDependencies&&e.styleDependencies.forEach((e=>{const t=document.createElement("style");t.setAttribute("include",e),a.push(t)}));const o=document.createElement("style");Object.assign(o,{textContent:n}),a.forEach((e=>{i.content.appendChild(e)})),i.content.appendChild(o),r.appendChild(i),r.register(t)}
/*! *****************************************************************************
    Copyright (c) Microsoft Corporation.

    Permission to use, copy, modify, and/or distribute this software for any
    purpose with or without fee is hereby granted.

    THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
    REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
    AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
    INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
    LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
    OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
    PERFORMANCE OF THIS SOFTWARE.
    ***************************************************************************** */
function __decorate(e,t,n,r){var i,a=arguments.length,o=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o}function __metadata(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function __awaiter$1(e,t,n,r){return new(n||(n=Promise))((function(i,a){function o(e){try{l(r.next(e))}catch(e){a(e)}}function s(e){try{l(r.throw(e))}catch(e){a(e)}}function l(e){e.done?i(e.value):(function t(e){return e instanceof n?e:new n((function(t){t(e)}))})(e.value).then(o,s)}l((r=r.apply(e,t||[])).next())}))}
/**
     * @license
     * Copyright (c) 2016 The Polymer Project Authors. All rights reserved.
     * This code may only be used under the BSD style license found at
     * http://polymer.github.io/LICENSE.txt The complete set of authors may be found
     * at http://polymer.github.io/AUTHORS.txt The complete set of contributors may
     * be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by
     * Google as part of the polymer project is also subject to an additional IP
     * rights grant found at http://polymer.github.io/PATENTS.txt
     */function customElement(e){return t=>{if(e)if(t.hasOwnProperty("is")){if(e!==t.is)throw new Error(`custom element tag names do not match: (${e} !== ${t.is})`)}else Object.defineProperty(t,"is",{value:e});window.customElements.define(t.is,t)}}function createProperty(e,t,n){e.constructor.hasOwnProperty("properties")||Object.defineProperty(e.constructor,"properties",{value:{}}),e.constructor.properties[t]=Object.assign({},e.constructor.properties[t],n)}function property(e){return(t,n)=>{createProperty(t,n,e)}}function observe(...e){return(t,n)=>{t.constructor.hasOwnProperty("observers")||Object.defineProperty(t.constructor,"observers",{value:[]}),t.constructor.observers.push(`${n}(${e.join(",")})`)}}function computed(e,...t){return(n,r,i)=>{const a=`__compute${r}`;Object.defineProperty(n,a,{value:i.get}),i.get=void 0;createProperty(n,r,{computed:`${a}(${[e,...t].join(",")})`})}}
/**
    @license
    Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
    The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
    The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
    Code distributed by Google as part of the polymer project is also
    subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
    */DomModule.prototype.modules=modules,customElements.define("dom-module",DomModule),registerStyleDomModule({moduleName:"vz-projector-styles",styleContent:"\n    :host {\n      --paper-input-container-label: {\n        font-size: 14px;\n      }\n      --paper-input-container-input: {\n        font-size: 14px;\n      }\n      /* TODO: Figure out why this doesn't work */\n      --paper-dropdown-menu-input: {\n        font-size: 14px;\n      }\n    }\n\n    paper-button {\n      background: #e3e3e3;\n      margin-left: 0;\n      text-transform: none;\n    }\n\n    paper-dropdown-menu paper-item {\n      font-size: 13px;\n    }\n\n    paper-tooltip {\n      max-width: 200px;\n      --paper-tooltip: {\n        font-size: 12px;\n      }\n    }\n\n    paper-checkbox {\n      --paper-checkbox-checked-color: #880e4f;\n    }\n\n    paper-toggle-button {\n      --paper-toggle-button-checked-bar-color: #880e4f;\n      --paper-toggle-button-checked-button-color: #880e4f;\n      --paper-toggle-button-checked-ink-color: #880e4f;\n    }\n\n    paper-icon-button {\n      border-radius: 50%;\n    }\n\n    paper-icon-button[active] {\n      color: white;\n      background-color: #880e4f;\n    }\n\n    .slider {\n      display: flex;\n      align-items: center;\n      margin-bottom: 10px;\n      justify-content: space-between;\n    }\n\n    .slider span {\n      width: 35px;\n      text-align: right;\n    }\n\n    .slider label {\n      align-items: center;\n      display: flex;\n    }\n\n    .help-icon {\n      height: 15px;\n      left: 2px;\n      min-width: 15px;\n      min-height: 15px;\n      margin: 0;\n      padding: 0;\n      top: -2px;\n      width: 15px;\n    }\n\n    .ink-panel {\n      display: flex;\n      flex-direction: column;\n      font-size: 14px;\n    }\n\n    .ink-panel h4 {\n      border-bottom: 1px solid #ddd;\n      font-size: 14px;\n      font-weight: 500;\n      margin: 0;\n      margin-bottom: 10px;\n      padding-bottom: 5px;\n    }\n\n    .ink-panel-header {\n      border-bottom: 1px solid rgba(0, 0, 0, 0.1);\n      border-top: 1px solid rgba(0, 0, 0, 0.1);\n      height: 50px;\n    }\n\n    .ink-panel-content {\n      display: none;\n      height: 100%;\n    }\n\n    .ink-panel-content.active {\n      display: block;\n    }\n\n    .ink-panel-content h3 {\n      font-weight: 500;\n      font-size: 14px;\n      margin-top: 20px;\n      margin-bottom: 5px;\n      text-transform: uppercase;\n    }\n\n    .ink-panel-header h3 {\n      font-weight: 500;\n      font-size: 14px;\n      margin: 0;\n      padding: 0 24px;\n      text-transform: uppercase;\n    }\n\n    /* - Tabs */\n    .ink-tab-group {\n      align-items: center;\n      box-sizing: border-box;\n      display: flex;\n      height: 100%;\n      justify-content: space-around;\n    }\n\n    .ink-tab-group .projection-tab {\n      color: rgba(0, 0, 0, 0.5);\n      cursor: pointer;\n      font-weight: 300;\n      line-height: 49px;\n      padding: 0 12px;\n      text-align: center;\n      text-transform: uppercase;\n    }\n\n    .ink-tab-group .projection-tab:hover {\n      color: black;\n    }\n\n    .ink-tab-group .projection-tab.active {\n      border-bottom: 2px solid black;\n      color: black;\n      font-weight: 500;\n    }\n\n    h4 {\n      margin: 30px 0 10px 0;\n    }\n\n    .dismiss-dialog-note {\n      margin-top: 25px;\n      font-size: 11px;\n      text-align: right;\n    }\n  "});let dedupeId$1=0;const dedupingMixin=function(e){let t=e.__mixinApplications;t||(t=new WeakMap,e.__mixinApplications=t);let n=dedupeId$1++;return function r(i){let a=i.__mixinSet;if(a&&a[n])return i;let o=t,s=o.get(i);if(!s){s=e(i),o.set(i,s);let t=Object.create(s.__mixinSet||a||null);t[n]=!0,s.__mixinSet=t}return s}},MODULE_STYLE_LINK_SELECTOR="link[rel=import][type~=css]",INCLUDE_ATTR="include",SHADY_UNSCOPED_ATTR="shady-unscoped";
/**
    @license
    Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
    The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
    The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
    Code distributed by Google as part of the polymer project is also
    subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
    */function importModule(e){return DomModule.import(e)}function styleForImport(e){const t=resolveCss((e.body?e.body:e).textContent,e.baseURI),n=document.createElement("style");return n.textContent=t,n}function stylesFromModules(e){const t=e.trim().split(/\s+/),n=[];for(let e=0;e<t.length;e++)n.push(...stylesFromModule(t[e]));return n}function stylesFromModule(e){const t=importModule(e);if(!t)return console.warn("Could not find style data in module named",e),[];if(void 0===t._styles){const e=[];e.push(..._stylesFromModuleImports(t));const n=t.querySelector("template");n&&e.push(...stylesFromTemplate(n,t.assetpath)),t._styles=e}return t._styles}function stylesFromTemplate(e,t){if(!e._styles){const n=[],r=e.content.querySelectorAll("style");for(let e=0;e<r.length;e++){let i=r[e],a=i.getAttribute(INCLUDE_ATTR);a&&n.push(...stylesFromModules(a).filter((function(e,t,n){return n.indexOf(e)===t}))),t&&(i.textContent=resolveCss(i.textContent,t)),n.push(i)}e._styles=n}return e._styles}function stylesFromModuleImports(e){let t=importModule(e);return t?_stylesFromModuleImports(t):[]}function _stylesFromModuleImports(e){const t=[],n=e.querySelectorAll(MODULE_STYLE_LINK_SELECTOR);for(let e=0;e<n.length;e++){let r=n[e];if(r.import){const e=r.import,n=r.hasAttribute(SHADY_UNSCOPED_ATTR);if(n&&!e._unscopedStyle){const t=styleForImport(e);t.setAttribute(SHADY_UNSCOPED_ATTR,""),e._unscopedStyle=t}else e._style||(e._style=styleForImport(e));t.push(n?e._unscopedStyle:e._style)}}return t}function cssFromModules(e){let t=e.trim().split(/\s+/),n="";for(let e=0;e<t.length;e++)n+=cssFromModule(t[e]);return n}function cssFromModule(e){let t=importModule(e);if(t&&void 0===t._cssText){let e=_cssFromModuleImports(t),n=t.querySelector("template");n&&(e+=cssFromTemplate(n,t.assetpath)),t._cssText=e||null}return t||console.warn("Could not find style data in module named",e),t&&t._cssText||""}function cssFromTemplate(e,t){let n="";const r=stylesFromTemplate(e,t);for(let e=0;e<r.length;e++){let t=r[e];t.parentNode&&t.parentNode.removeChild(t),n+=t.textContent}return n}function _cssFromModuleImports(e){let t="",n=_stylesFromModuleImports(e);for(let e=0;e<n.length;e++)t+=n[e].textContent;return t}
/**
    @license
    Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
    The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
    The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
    Code distributed by Google as part of the polymer project is also
    subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
    */const wrap=window.ShadyDOM&&window.ShadyDOM.noPatch&&window.ShadyDOM.wrap?window.ShadyDOM.wrap:window.ShadyDOM?e=>ShadyDOM.patch(e):e=>e;
/**
    @license
    Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
    The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
    The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
    Code distributed by Google as part of the polymer project is also
    subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
    */function isPath(e){return e.indexOf(".")>=0}function root(e){let t=e.indexOf(".");return-1===t?e:e.slice(0,t)}function isAncestor(e,t){return 0===e.indexOf(t+".")}function isDescendant(e,t){return 0===t.indexOf(e+".")}function translate(e,t,n){return t+n.slice(e.length)}function matches$1(e,t){return e===t||isAncestor(e,t)||isDescendant(e,t)}function normalize$2(e){if(Array.isArray(e)){let t=[];for(let n=0;n<e.length;n++){let r=e[n].toString().split(".");for(let e=0;e<r.length;e++)t.push(r[e])}return t.join(".")}return e}function split$1(e){return Array.isArray(e)?normalize$2(e).split("."):e.toString().split(".")}function get$1(e,t,n){let r=e,i=split$1(t);for(let e=0;e<i.length;e++){if(!r)return;r=r[i[e]]}return n&&(n.path=i.join(".")),r}function set$1(e,t,n){let r=e,i=split$1(t),a=i[i.length-1];if(i.length>1){for(let e=0;e<i.length-1;e++){if(r=r[i[e]],!r)return}r[a]=n}else r[t]=n;return i.join(".")}
/**
    @license
    Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
    The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
    The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
    Code distributed by Google as part of the polymer project is also
    subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
    */const caseMap={},DASH_TO_CAMEL=/-[a-z]/g,CAMEL_TO_DASH=/([A-Z])/g;function dashToCamelCase(e){return caseMap[e]||(caseMap[e]=e.indexOf("-")<0?e:e.replace(DASH_TO_CAMEL,(e=>e[1].toUpperCase())))}function camelToDashCase(e){return caseMap[e]||(caseMap[e]=e.replace(CAMEL_TO_DASH,"-$1").toLowerCase())}
/**
    @license
    Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
    The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
    The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
    Code distributed by Google as part of the polymer project is also
    subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
    */let microtaskCurrHandle=0,microtaskLastHandle=0,microtaskCallbacks=[],microtaskNodeContent=0,microtaskScheduled=!1,microtaskNode=document.createTextNode("");function microtaskFlush(){microtaskScheduled=!1;const e=microtaskCallbacks.length;for(let t=0;t<e;t++){let e=microtaskCallbacks[t];if(e)try{e()}catch(e){setTimeout((()=>{throw e}))}}microtaskCallbacks.splice(0,e),microtaskLastHandle+=e}new window.MutationObserver(microtaskFlush).observe(microtaskNode,{characterData:!0});const timeOut={after:e=>({run:t=>window.setTimeout(t,e),cancel(e){window.clearTimeout(e)}}),run:(e,t)=>window.setTimeout(e,t),cancel(e){window.clearTimeout(e)}},animationFrame={run:e=>window.requestAnimationFrame(e),cancel(e){window.cancelAnimationFrame(e)}},idlePeriod={run:e=>window.requestIdleCallback?window.requestIdleCallback(e):window.setTimeout(e,16),cancel(e){window.cancelIdleCallback?window.cancelIdleCallback(e):window.clearTimeout(e)}},microTask={run:e=>(microtaskScheduled||(microtaskScheduled=!0,microtaskNode.textContent=microtaskNodeContent++),microtaskCallbacks.push(e),microtaskCurrHandle++),cancel(e){const t=e-microtaskLastHandle;if(t>=0){if(!microtaskCallbacks[t])throw new Error("invalid async handle: "+e);microtaskCallbacks[t]=null}}},microtask=microTask,PropertiesChanged=dedupingMixin((e=>class extends e{static createProperties(e){const t=this.prototype;for(let n in e)n in t||t._createPropertyAccessor(n)}static attributeNameForProperty(e){return e.toLowerCase()}static typeForProperty(e){}_createPropertyAccessor(e,t){this._addPropertyToAttributeMap(e),this.hasOwnProperty(JSCompiler_renameProperty("__dataHasAccessor",this))||(this.__dataHasAccessor=Object.assign({},this.__dataHasAccessor)),this.__dataHasAccessor[e]||(this.__dataHasAccessor[e]=!0,this._definePropertyAccessor(e,t))}_addPropertyToAttributeMap(e){this.hasOwnProperty(JSCompiler_renameProperty("__dataAttributes",this))||(this.__dataAttributes=Object.assign({},this.__dataAttributes));let t=this.__dataAttributes[e];return t||(t=this.constructor.attributeNameForProperty(e),this.__dataAttributes[t]=e),t}_definePropertyAccessor(e,t){Object.defineProperty(this,e,{get(){return this.__data[e]},set:t?function(){}:function(t){this._setPendingProperty(e,t,!0)&&this._invalidateProperties()}})}constructor(){super(),this.__dataEnabled=!1,this.__dataReady=!1,this.__dataInvalid=!1,this.__data={},this.__dataPending=null,this.__dataOld=null,this.__dataInstanceProps=null,this.__dataCounter=0,this.__serializing=!1,this._initializeProperties()}ready(){this.__dataReady=!0,this._flushProperties()}_initializeProperties(){for(let e in this.__dataHasAccessor)this.hasOwnProperty(e)&&(this.__dataInstanceProps=this.__dataInstanceProps||{},this.__dataInstanceProps[e]=this[e],delete this[e])}_initializeInstanceProperties(e){Object.assign(this,e)}_setProperty(e,t){this._setPendingProperty(e,t)&&this._invalidateProperties()}_getProperty(e){return this.__data[e]}_setPendingProperty(e,t,n){let r=this.__data[e],i=this._shouldPropertyChange(e,t,r);return i&&(this.__dataPending||(this.__dataPending={},this.__dataOld={}),this.__dataOld&&!(e in this.__dataOld)&&(this.__dataOld[e]=r),this.__data[e]=t,this.__dataPending[e]=t),i}_isPropertyPending(e){return!(!this.__dataPending||!this.__dataPending.hasOwnProperty(e))}_invalidateProperties(){!this.__dataInvalid&&this.__dataReady&&(this.__dataInvalid=!0,microtask.run((()=>{this.__dataInvalid&&(this.__dataInvalid=!1,this._flushProperties())})))}_enableProperties(){this.__dataEnabled||(this.__dataEnabled=!0,this.__dataInstanceProps&&(this._initializeInstanceProperties(this.__dataInstanceProps),this.__dataInstanceProps=null),this.ready())}_flushProperties(){this.__dataCounter++;const e=this.__data,t=this.__dataPending,n=this.__dataOld;this._shouldPropertiesChange(e,t,n)&&(this.__dataPending=null,this.__dataOld=null,this._propertiesChanged(e,t,n)),this.__dataCounter--}_shouldPropertiesChange(e,t,n){return Boolean(t)}_propertiesChanged(e,t,n){}_shouldPropertyChange(e,t,n){return n!==t&&(n==n||t==t)}attributeChangedCallback(e,t,n,r){t!==n&&this._attributeToProperty(e,n),super.attributeChangedCallback&&super.attributeChangedCallback(e,t,n,r)}_attributeToProperty(e,t,n){if(!this.__serializing){const r=this.__dataAttributes,i=r&&r[e]||e;this[i]=this._deserializeValue(t,n||this.constructor.typeForProperty(i))}}_propertyToAttribute(e,t,n){this.__serializing=!0,this._valueToNodeAttribute(this,n=arguments.length<3?this[e]:n,t||this.constructor.attributeNameForProperty(e)),this.__serializing=!1}_valueToNodeAttribute(e,t,n){const r=this._serializeValue(t);"class"!==n&&"name"!==n&&"slot"!==n||(e=wrap(e)),void 0===r?e.removeAttribute(n):e.setAttribute(n,r)}_serializeValue(e){switch(typeof e){case"boolean":return e?"":void 0;default:return null!=e?e.toString():void 0}}_deserializeValue(e,t){switch(t){case Boolean:return null!==e;case Number:return Number(e);default:return e}}})),nativeProperties={};let proto$1=HTMLElement.prototype;for(;proto$1;){let e=Object.getOwnPropertyNames(proto$1);for(let t=0;t<e.length;t++)nativeProperties[e[t]]=!0;proto$1=Object.getPrototypeOf(proto$1)}function saveAccessorValue(e,t){if(!nativeProperties[t]){let n=e[t];void 0!==n&&(e.__data?e._setPendingProperty(t,n):(e.__dataProto?e.hasOwnProperty(JSCompiler_renameProperty("__dataProto",e))||(e.__dataProto=Object.create(e.__dataProto)):e.__dataProto={},e.__dataProto[t]=n))}}const PropertyAccessors=dedupingMixin((e=>{const t=PropertiesChanged(e);return class extends t{static createPropertiesForAttributes(){let e=this.observedAttributes;for(let t=0;t<e.length;t++)this.prototype._createPropertyAccessor(dashToCamelCase(e[t]))}static attributeNameForProperty(e){return camelToDashCase(e)}_initializeProperties(){this.__dataProto&&(this._initializeProtoProperties(this.__dataProto),this.__dataProto=null),super._initializeProperties()}_initializeProtoProperties(e){for(let t in e)this._setProperty(t,e[t])}_ensureAttribute(e,t){const n=this;n.hasAttribute(e)||this._valueToNodeAttribute(n,t,e)}_serializeValue(e){switch(typeof e){case"object":if(e instanceof Date)return e.toString();if(e)try{return JSON.stringify(e)}catch(e){return""}default:return super._serializeValue(e)}}_deserializeValue(e,t){let n;switch(t){case Object:try{n=JSON.parse(e)}catch(t){n=e}break;case Array:try{n=JSON.parse(e)}catch(t){n=null,console.warn(`Polymer::Attributes: couldn't decode Array as JSON: ${e}`)}break;case Date:n=isNaN(e)?String(e):Number(e),n=new Date(n);break;default:n=super._deserializeValue(e,t)}return n}_definePropertyAccessor(e,t){saveAccessorValue(this,e),super._definePropertyAccessor(e,t)}_hasAccessor(e){return this.__dataHasAccessor&&this.__dataHasAccessor[e]}_isPropertyPending(e){return Boolean(this.__dataPending&&e in this.__dataPending)}}})),templateExtensions={"dom-if":!0,"dom-repeat":!0};
/**
    @license
    Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
    The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
    The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
    Code distributed by Google as part of the polymer project is also
    subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
    */let placeholderBugDetect=!1,placeholderBug=!1;function hasPlaceholderBug(){if(!placeholderBugDetect){placeholderBugDetect=!0;const e=document.createElement("textarea");e.placeholder="a",placeholderBug=e.placeholder===e.textContent}return placeholderBug}function fixPlaceholder(e){hasPlaceholderBug()&&"textarea"===e.localName&&e.placeholder&&e.placeholder===e.textContent&&(e.textContent=null)}function wrapTemplateExtension(e){let t=e.getAttribute("is");if(t&&templateExtensions[t]){let n=e;for(n.removeAttribute("is"),e=n.ownerDocument.createElement(t),n.parentNode.replaceChild(e,n),e.appendChild(n);n.attributes.length;)e.setAttribute(n.attributes[0].name,n.attributes[0].value),n.removeAttribute(n.attributes[0].name)}return e}function findTemplateNode(e,t){let n=t.parentInfo&&findTemplateNode(e,t.parentInfo);if(!n)return e;for(let e=n.firstChild,r=0;e;e=e.nextSibling)if(t.parentIndex===r++)return e}function applyIdToMap(e,t,n,r){r.id&&(t[r.id]=n)}function applyEventListener(e,t,n){if(n.events&&n.events.length)for(let r,i=0,a=n.events;i<a.length&&(r=a[i]);i++)e._addMethodEventListenerToNode(t,r.name,r.value,e)}function applyTemplateInfo(e,t,n,r){n.templateInfo&&(t._templateInfo=n.templateInfo,t._parentTemplateInfo=r)}function createNodeEventHandler(e,t,n){e=e._methodHost||e;return function(t){e[n]?e[n](t,t.detail):console.warn("listener method `"+n+"` not defined")}}const TemplateStamp=dedupingMixin((e=>class extends e{static _parseTemplate(e,t){if(!e._templateInfo){let n=e._templateInfo={};n.nodeInfoList=[],n.nestedTemplate=Boolean(t),n.stripWhiteSpace=t&&t.stripWhiteSpace||e.hasAttribute("strip-whitespace"),this._parseTemplateContent(e,n,{parent:null})}return e._templateInfo}static _parseTemplateContent(e,t,n){return this._parseTemplateNode(e.content,t,n)}static _parseTemplateNode(e,t,n){let r=!1,i=e;return"template"!=i.localName||i.hasAttribute("preserve-content")?"slot"===i.localName&&(t.hasInsertionPoint=!0):r=this._parseTemplateNestedTemplate(i,t,n)||r,fixPlaceholder(i),i.firstChild&&this._parseTemplateChildNodes(i,t,n),i.hasAttributes&&i.hasAttributes()&&(r=this._parseTemplateNodeAttributes(i,t,n)||r),r||n.noted}static _parseTemplateChildNodes(e,t,n){if("script"!==e.localName&&"style"!==e.localName)for(let r,i=e.firstChild,a=0;i;i=r){if("template"==i.localName&&(i=wrapTemplateExtension(i)),r=i.nextSibling,i.nodeType===Node.TEXT_NODE){let n=r;for(;n&&n.nodeType===Node.TEXT_NODE;)i.textContent+=n.textContent,r=n.nextSibling,e.removeChild(n),n=r;if(t.stripWhiteSpace&&!i.textContent.trim()){e.removeChild(i);continue}}let o={parentIndex:a,parentInfo:n};this._parseTemplateNode(i,t,o)&&(o.infoIndex=t.nodeInfoList.push(o)-1),i.parentNode&&a++}}static _parseTemplateNestedTemplate(e,t,n){let r=e,i=this._parseTemplate(r,t);return(i.content=r.content.ownerDocument.createDocumentFragment()).appendChild(r.content),n.templateInfo=i,!0}static _parseTemplateNodeAttributes(e,t,n){let r=!1,i=Array.from(e.attributes);for(let a,o=i.length-1;a=i[o];o--)r=this._parseTemplateNodeAttribute(e,t,n,a.name,a.value)||r;return r}static _parseTemplateNodeAttribute(e,t,n,r,i){return"on-"===r.slice(0,3)?(e.removeAttribute(r),n.events=n.events||[],n.events.push({name:r.slice(3),value:i}),!0):"id"===r&&(n.id=i,!0)}static _contentForTemplate(e){let t=e._templateInfo;return t&&t.content||e.content}_stampTemplate(e,t){e&&!e.content&&window.HTMLTemplateElement&&HTMLTemplateElement.decorate&&HTMLTemplateElement.decorate(e);let n=(t=t||this.constructor._parseTemplate(e)).nodeInfoList,r=document.importNode(t.content||e.content,!0);r.__noInsertionPoint=!t.hasInsertionPoint;let i=r.nodeList=new Array(n.length);r.$={};for(let e,a=0,o=n.length;a<o&&(e=n[a]);a++){let n=i[a]=findTemplateNode(r,e);applyIdToMap(this,r.$,n,e),applyTemplateInfo(this,n,e,t),applyEventListener(this,n,e)}return r=r,r}_addMethodEventListenerToNode(e,t,n,r){let i=createNodeEventHandler(r=r||e,t,n);return this._addEventListenerToNode(e,t,i),i}_addEventListenerToNode(e,t,n){e.addEventListener(t,n)}_removeEventListenerFromNode(e,t,n){e.removeEventListener(t,n)}}));
/**
     * @fileoverview
     * @suppress {checkPrototypalTypes}
     * @license Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
     * This code may only be used under the BSD style license found at
     * http://polymer.github.io/LICENSE.txt The complete set of authors may be found
     * at http://polymer.github.io/AUTHORS.txt The complete set of contributors may
     * be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by
     * Google as part of the polymer project is also subject to an additional IP
     * rights grant found at http://polymer.github.io/PATENTS.txt
     */let dedupeId=0;const NOOP=[],TYPES={COMPUTE:"__computeEffects",REFLECT:"__reflectEffects",NOTIFY:"__notifyEffects",PROPAGATE:"__propagateEffects",OBSERVE:"__observeEffects",READ_ONLY:"__readOnly"},COMPUTE_INFO="__computeInfo",capitalAttributeRegex=/[A-Z]/;function ensureOwnEffectMap(e,t,n){let r=e[t];if(r){if(!e.hasOwnProperty(t)&&(r=e[t]=Object.create(e[t]),n))for(let e in r){let t=r[e],n=r[e]=Array(t.length);for(let e=0;e<t.length;e++)n[e]=t[e]}}else r=e[t]={};return r}function runEffects(e,t,n,r,i,a){if(t){let o=!1;const s=dedupeId++;for(let l in n){let c=t[i?root(l):l];if(c)for(let t,h=0,u=c.length;h<u&&(t=c[h]);h++)t.info&&t.info.lastRun===s||i&&!pathMatchesTrigger(l,t.trigger)||(t.info&&(t.info.lastRun=s),t.fn(e,l,n,r,t.info,i,a),o=!0)}return o}return!1}function runEffectsForProperty(e,t,n,r,i,a,o,s){let l=!1,c=t[o?root(r):r];if(c)for(let t,h=0,u=c.length;h<u&&(t=c[h]);h++)t.info&&t.info.lastRun===n||o&&!pathMatchesTrigger(r,t.trigger)||(t.info&&(t.info.lastRun=n),t.fn(e,r,i,a,t.info,o,s),l=!0);return l}function pathMatchesTrigger(e,t){if(t){let n=t.name;return n==e||!(!t.structured||!isAncestor(n,e))||!(!t.wildcard||!isDescendant(n,e))}return!0}function runObserverEffect(e,t,n,r,i){let a="string"==typeof i.method?e[i.method]:i.method,o=i.property;a?a.call(e,e.__data[o],r[o]):i.dynamicFn||console.warn("observer method `"+i.method+"` not defined")}function runNotifyEffects(e,t,n,r,i){let a,o,s=e[TYPES.NOTIFY],l=dedupeId++;for(let o in t)t[o]&&(s&&runEffectsForProperty(e,s,l,o,n,r,i)||i&&notifyPath(e,o,n))&&(a=!0);a&&(o=e.__dataHost)&&o._invalidateProperties&&o._invalidateProperties()}function notifyPath(e,t,n){let r=root(t);if(r!==t){return dispatchNotifyEvent(e,camelToDashCase(r)+"-changed",n[t],t),!0}return!1}function dispatchNotifyEvent(e,t,n,r){let i={value:n,queueProperty:!0};r&&(i.path=r),wrap(e).dispatchEvent(new CustomEvent(t,{detail:i}))}function runNotifyEffect(e,t,n,r,i,a){let o=(a?root(t):t)!=t?t:null,s=o?get$1(e,o):e.__data[t];o&&void 0===s&&(s=n[t]),dispatchNotifyEvent(e,i.eventName,s,o)}function handleNotification(e,t,n,r,i){let a,o=e.detail,s=o&&o.path;s?(r=translate(n,r,s),a=o&&o.value):a=e.currentTarget[n],a=i?!a:a,t[TYPES.READ_ONLY]&&t[TYPES.READ_ONLY][r]||!t._setPendingPropertyOrPath(r,a,!0,Boolean(s))||o&&o.queueProperty||t._invalidateProperties()}function runReflectEffect(e,t,n,r,i){let a=e.__data[t];sanitizeDOMValue&&(a=sanitizeDOMValue(a,i.attrName,"attribute",e)),e._propertyToAttribute(t,i.attrName,a)}function runComputedEffects(e,t,n,r){let i=e[TYPES.COMPUTE];if(i)if(orderedComputed){dedupeId++;const a=getComputedOrder(e),o=[];for(let e in t)enqueueEffectsFor(e,i,o,a,r);let s;for(;s=o.shift();)runComputedEffect(e,"",t,n,s)&&enqueueEffectsFor(s.methodInfo,i,o,a,r);Object.assign(n,e.__dataOld),Object.assign(t,e.__dataPending),e.__dataPending=null}else{let a=t;for(;runEffects(e,i,a,n,r);)Object.assign(n,e.__dataOld),Object.assign(t,e.__dataPending),a=e.__dataPending,e.__dataPending=null}}const insertEffect=(e,t,n)=>{let r=0,i=t.length-1,a=-1;for(;r<=i;){const o=r+i>>1,s=n.get(t[o].methodInfo)-n.get(e.methodInfo);if(s<0)r=o+1;else{if(!(s>0)){a=o;break}i=o-1}}a<0&&(a=i+1),t.splice(a,0,e)},enqueueEffectsFor=(e,t,n,r,i)=>{const a=t[i?root(e):e];if(a)for(let t=0;t<a.length;t++){const o=a[t];o.info.lastRun===dedupeId||i&&!pathMatchesTrigger(e,o.trigger)||(o.info.lastRun=dedupeId,insertEffect(o.info,n,r))}};function getComputedOrder(e){let t=e.constructor.__orderedComputedDeps;if(!t){t=new Map;const n=e[TYPES.COMPUTE];let r,{counts:i,ready:a,total:o}=dependencyCounts(e);for(;r=a.shift();){t.set(r,t.size);const e=n[r];e&&e.forEach((e=>{const t=e.info.methodInfo;--o,0==--i[t]&&a.push(t)}))}if(0!==o){console.warn(`Computed graph for ${e.localName} incomplete; circular?`)}e.constructor.__orderedComputedDeps=t}return t}function dependencyCounts(e){const t=e[COMPUTE_INFO],n={},r=e[TYPES.COMPUTE],i=[];let a=0;for(let e in t){const r=t[e];a+=n[e]=r.args.filter((e=>!e.literal)).length+(r.dynamicFn?1:0)}for(let e in r)t[e]||i.push(e);return{counts:n,ready:i,total:a}}function runComputedEffect(e,t,n,r,i){let a=runMethodEffect(e,t,n,r,i);if(a===NOOP)return!1;let o=i.methodInfo;return e.__dataHasAccessor&&e.__dataHasAccessor[o]?e._setPendingProperty(o,a,!0):(e[o]=a,!1)}function computeLinkedPaths(e,t,n){let r=e.__dataLinkedPaths;if(r){let i;for(let a in r){let o=r[a];isDescendant(a,t)?(i=translate(a,o,t),e._setPendingPropertyOrPath(i,n,!0,!0)):isDescendant(o,t)&&(i=translate(o,a,t),e._setPendingPropertyOrPath(i,n,!0,!0))}}}function addBinding(e,t,n,r,i,a,o){n.bindings=n.bindings||[];let s={kind:r,target:i,parts:a,literal:o,isCompound:1!==a.length};if(n.bindings.push(s),shouldAddListener(s)){let{event:e,negate:t}=s.parts[0];s.listenerEvent=e||camelToDashCase(i)+"-changed",s.listenerNegate=t}let l=t.nodeInfoList.length;for(let n=0;n<s.parts.length;n++){let r=s.parts[n];r.compoundIndex=n,addEffectForBindingPart(e,t,s,r,l)}}function addEffectForBindingPart(e,t,n,r,i){if(!r.literal)if("attribute"===n.kind&&"-"===n.target[0])console.warn("Cannot set attribute "+n.target+' because "-" is not a valid attribute starting character');else{let a=r.dependencies,o={index:i,binding:n,part:r,evaluator:e};for(let n=0;n<a.length;n++){let r=a[n];"string"==typeof r&&(r=parseArg(r),r.wildcard=!0),e._addTemplatePropertyEffect(t,r.rootProperty,{fn:runBindingEffect,info:o,trigger:r})}}}function runBindingEffect(e,t,n,r,i,a,o){let s=o[i.index],l=i.binding,c=i.part;if(a&&c.source&&t.length>c.source.length&&"property"==l.kind&&!l.isCompound&&s.__isPropertyEffectsClient&&s.__dataHasAccessor&&s.__dataHasAccessor[l.target]){let r=n[t];t=translate(c.source,l.target,t),s._setPendingPropertyOrPath(t,r,!1,!0)&&e._enqueueClient(s)}else{let o=i.evaluator._evaluateBinding(e,c,t,n,r,a);o!==NOOP&&applyBindingValue(e,s,l,c,o)}}function applyBindingValue(e,t,n,r,i){if(i=computeBindingValue(t,i,n,r),sanitizeDOMValue&&(i=sanitizeDOMValue(i,n.target,n.kind,t)),"attribute"==n.kind)e._valueToNodeAttribute(t,i,n.target);else{let r=n.target;t.__isPropertyEffectsClient&&t.__dataHasAccessor&&t.__dataHasAccessor[r]?t[TYPES.READ_ONLY]&&t[TYPES.READ_ONLY][r]||t._setPendingProperty(r,i)&&e._enqueueClient(t):e._setUnmanagedPropertyToNode(t,r,i)}}function computeBindingValue(e,t,n,r){if(n.isCompound){let i=e.__dataCompoundStorage[n.target];i[r.compoundIndex]=t,t=i.join("")}return"attribute"!==n.kind&&("textContent"!==n.target&&("value"!==n.target||"input"!==e.localName&&"textarea"!==e.localName)||(t=null==t?"":t)),t}function shouldAddListener(e){return Boolean(e.target)&&"attribute"!=e.kind&&"text"!=e.kind&&!e.isCompound&&"{"===e.parts[0].mode}function setupBindings(e,t){let{nodeList:n,nodeInfoList:r}=t;if(r.length)for(let t=0;t<r.length;t++){let i=n[t],a=r[t].bindings;if(a)for(let t=0;t<a.length;t++){let n=a[t];setupCompoundStorage(i,n),addNotifyListener(i,e,n)}i.__dataHost=e}}function setupCompoundStorage(e,t){if(t.isCompound){let n=e.__dataCompoundStorage||(e.__dataCompoundStorage={}),r=t.parts,i=new Array(r.length);for(let e=0;e<r.length;e++)i[e]=r[e].literal;let a=t.target;n[a]=i,t.literal&&"property"==t.kind&&("className"===a&&(e=wrap(e)),e[a]=t.literal)}}function addNotifyListener(e,t,n){if(n.listenerEvent){let r=n.parts[0];e.addEventListener(n.listenerEvent,(function(e){handleNotification(e,t,n.target,r.source,r.negate)}))}}function createMethodEffect(e,t,n,r,i,a){let o={methodName:t.methodName,args:t.args,methodInfo:i,dynamicFn:a=t.static||a&&("object"!=typeof a||a[t.methodName])};for(let i,a=0;a<t.args.length&&(i=t.args[a]);a++)i.literal||e._addPropertyEffect(i.rootProperty,n,{fn:r,info:o,trigger:i});return a&&e._addPropertyEffect(t.methodName,n,{fn:r,info:o}),o}function runMethodEffect(e,t,n,r,i){let a=e._methodHost||e,o=a[i.methodName];if(o){let r=e._marshalArgs(i.args,t,n);return r===NOOP?NOOP:o.apply(a,r)}i.dynamicFn||console.warn("method `"+i.methodName+"` not defined")}const emptyArray=[],IDENT="(?:[a-zA-Z_$][\\w.:$\\-*]*)",NUMBER="(?:[-+]?[0-9]*\\.?[0-9]+(?:[eE][-+]?[0-9]+)?)",SQUOTE_STRING="(?:'(?:[^'\\\\]|\\\\.)*')",DQUOTE_STRING='(?:"(?:[^"\\\\]|\\\\.)*")',STRING="(?:"+SQUOTE_STRING+"|"+DQUOTE_STRING+")",ARGUMENT="(?:("+IDENT+"|"+NUMBER+"|"+STRING+")\\s*)",ARGUMENTS="(?:"+ARGUMENT+"(?:,\\s*"+ARGUMENT+")*)",ARGUMENT_LIST="(?:\\(\\s*(?:"+ARGUMENTS+"?)\\)\\s*)",BINDING="("+IDENT+"\\s*"+ARGUMENT_LIST+"?)",OPEN_BRACKET="(\\[\\[|{{)\\s*",CLOSE_BRACKET="(?:]]|}})",NEGATE="(?:(!)\\s*)?",EXPRESSION=OPEN_BRACKET+NEGATE+BINDING+CLOSE_BRACKET,bindingRegex=new RegExp(EXPRESSION,"g");function literalFromParts(e){let t="";for(let n=0;n<e.length;n++){t+=e[n].literal||""}return t}function parseMethod(e){let t=e.match(/([^\s]+?)\(([\s\S]*)\)/);if(t){let e={methodName:t[1],static:!0,args:emptyArray};if(t[2].trim()){return parseArgs(t[2].replace(/\\,/g,"&comma;").split(","),e)}return e}return null}function parseArgs(e,t){return t.args=e.map((function(e){let n=parseArg(e);return n.literal||(t.static=!1),n}),this),t}function parseArg(e){let t=e.trim().replace(/&comma;/g,",").replace(/\\(.)/g,"$1"),n={name:t,value:"",literal:!1},r=t[0];switch("-"===r&&(r=t[1]),r>="0"&&r<="9"&&(r="#"),r){case"'":case'"':n.value=t.slice(1,-1),n.literal=!0;break;case"#":n.value=Number(t),n.literal=!0}return n.literal||(n.rootProperty=root(t),n.structured=isPath(t),n.structured&&(n.wildcard=".*"==t.slice(-2),n.wildcard&&(n.name=t.slice(0,-2)))),n}function getArgValue(e,t,n){let r=get$1(e,n);return void 0===r&&(r=t[n]),r}function notifySplices(e,t,n,r){const i={indexSplices:r};legacyUndefined&&!e._overrideLegacyUndefined&&(t.splices=i),e.notifyPath(n+".splices",i),e.notifyPath(n+".length",t.length),legacyUndefined&&!e._overrideLegacyUndefined&&(i.indexSplices=[])}function notifySplice(e,t,n,r,i,a){notifySplices(e,t,n,[{index:r,addedCount:i,removed:a,object:t,type:"splice"}])}function upper(e){return e[0].toUpperCase()+e.substring(1)}const PropertyEffects=dedupingMixin((e=>{const t=TemplateStamp(PropertyAccessors(e));return class extends t{constructor(){super(),this.__isPropertyEffectsClient=!0}get PROPERTY_EFFECT_TYPES(){return TYPES}_initializeProperties(){super._initializeProperties(),this._registerHost(),this.__dataClientsReady=!1,this.__dataPendingClients=null,this.__dataToNotify=null,this.__dataLinkedPaths=null,this.__dataHasPaths=!1,this.__dataCompoundStorage=this.__dataCompoundStorage||null,this.__dataHost=this.__dataHost||null,this.__dataTemp={},this.__dataClientsInitialized=!1}_registerHost(){if(hostStack.length){let e=hostStack[hostStack.length-1];e._enqueueClient(this),this.__dataHost=e}}_initializeProtoProperties(e){this.__data=Object.create(e),this.__dataPending=Object.create(e),this.__dataOld={}}_initializeInstanceProperties(e){let t=this[TYPES.READ_ONLY];for(let n in e)t&&t[n]||(this.__dataPending=this.__dataPending||{},this.__dataOld=this.__dataOld||{},this.__data[n]=this.__dataPending[n]=e[n])}_addPropertyEffect(e,t,n){this._createPropertyAccessor(e,t==TYPES.READ_ONLY);let r=ensureOwnEffectMap(this,t,!0)[e];r||(r=this[t][e]=[]),r.push(n)}_removePropertyEffect(e,t,n){let r=ensureOwnEffectMap(this,t,!0)[e],i=r.indexOf(n);i>=0&&r.splice(i,1)}_hasPropertyEffect(e,t){let n=this[t];return Boolean(n&&n[e])}_hasReadOnlyEffect(e){return this._hasPropertyEffect(e,TYPES.READ_ONLY)}_hasNotifyEffect(e){return this._hasPropertyEffect(e,TYPES.NOTIFY)}_hasReflectEffect(e){return this._hasPropertyEffect(e,TYPES.REFLECT)}_hasComputedEffect(e){return this._hasPropertyEffect(e,TYPES.COMPUTE)}_setPendingPropertyOrPath(e,t,n,r){if(r||root(Array.isArray(e)?e[0]:e)!==e){if(!r){let n=get$1(this,e);if(!(e=set$1(this,e,t))||!super._shouldPropertyChange(e,t,n))return!1}if(this.__dataHasPaths=!0,this._setPendingProperty(e,t,n))return computeLinkedPaths(this,e,t),!0}else{if(this.__dataHasAccessor&&this.__dataHasAccessor[e])return this._setPendingProperty(e,t,n);this[e]=t}return!1}_setUnmanagedPropertyToNode(e,t,n){n===e[t]&&"object"!=typeof n||("className"===t&&(e=wrap(e)),e[t]=n)}_setPendingProperty(e,t,n){let r=this.__dataHasPaths&&isPath(e);return!!this._shouldPropertyChange(e,t,(r?this.__dataTemp:this.__data)[e])&&(this.__dataPending||(this.__dataPending={},this.__dataOld={}),e in this.__dataOld||(this.__dataOld[e]=this.__data[e]),r?this.__dataTemp[e]=t:this.__data[e]=t,this.__dataPending[e]=t,(r||this[TYPES.NOTIFY]&&this[TYPES.NOTIFY][e])&&(this.__dataToNotify=this.__dataToNotify||{},this.__dataToNotify[e]=n),!0)}_setProperty(e,t){this._setPendingProperty(e,t,!0)&&this._invalidateProperties()}_invalidateProperties(){this.__dataReady&&this._flushProperties()}_enqueueClient(e){this.__dataPendingClients=this.__dataPendingClients||[],e!==this&&this.__dataPendingClients.push(e)}_flushClients(){this.__dataClientsReady?this.__enableOrFlushClients():(this.__dataClientsReady=!0,this._readyClients(),this.__dataReady=!0)}__enableOrFlushClients(){let e=this.__dataPendingClients;if(e){this.__dataPendingClients=null;for(let t=0;t<e.length;t++){let n=e[t];n.__dataEnabled?n.__dataPending&&n._flushProperties():n._enableProperties()}}}_readyClients(){this.__enableOrFlushClients()}setProperties(e,t){for(let n in e)!t&&this[TYPES.READ_ONLY]&&this[TYPES.READ_ONLY][n]||this._setPendingPropertyOrPath(n,e[n],!0);this._invalidateProperties()}ready(){this._flushProperties(),this.__dataClientsReady||this._flushClients(),this.__dataPending&&this._flushProperties()}_propertiesChanged(e,t,n){let r,i=this.__dataHasPaths;this.__dataHasPaths=!1,runComputedEffects(this,t,n,i),r=this.__dataToNotify,this.__dataToNotify=null,this._propagatePropertyChanges(t,n,i),this._flushClients(),runEffects(this,this[TYPES.REFLECT],t,n,i),runEffects(this,this[TYPES.OBSERVE],t,n,i),r&&runNotifyEffects(this,r,t,n,i),1==this.__dataCounter&&(this.__dataTemp={})}_propagatePropertyChanges(e,t,n){this[TYPES.PROPAGATE]&&runEffects(this,this[TYPES.PROPAGATE],e,t,n),this.__templateInfo&&this._runEffectsForTemplate(this.__templateInfo,e,t,n)}_runEffectsForTemplate(e,t,n,r){const i=(t,r)=>{runEffects(this,e.propertyEffects,t,n,r,e.nodeList);for(let i=e.firstChild;i;i=i.nextSibling)this._runEffectsForTemplate(i,t,n,r)};e.runEffects?e.runEffects(i,t,r):i(t,r)}linkPaths(e,t){e=normalize$2(e),t=normalize$2(t),this.__dataLinkedPaths=this.__dataLinkedPaths||{},this.__dataLinkedPaths[e]=t}unlinkPaths(e){e=normalize$2(e),this.__dataLinkedPaths&&delete this.__dataLinkedPaths[e]}notifySplices(e,t){let n={path:""};notifySplices(this,get$1(this,e,n),n.path,t)}get(e,t){return get$1(t||this,e)}set(e,t,n){n?set$1(n,e,t):this[TYPES.READ_ONLY]&&this[TYPES.READ_ONLY][e]||this._setPendingPropertyOrPath(e,t,!0)&&this._invalidateProperties()}push(e,...t){let n={path:""},r=get$1(this,e,n),i=r.length,a=r.push(...t);return t.length&&notifySplice(this,r,n.path,i,t.length,[]),a}pop(e){let t={path:""},n=get$1(this,e,t),r=Boolean(n.length),i=n.pop();return r&&notifySplice(this,n,t.path,n.length,0,[i]),i}splice(e,t,n,...r){let i,a={path:""},o=get$1(this,e,a);return t<0?t=o.length-Math.floor(-t):t&&(t=Math.floor(t)),i=2===arguments.length?o.splice(t):o.splice(t,n,...r),(r.length||i.length)&&notifySplice(this,o,a.path,t,r.length,i),i}shift(e){let t={path:""},n=get$1(this,e,t),r=Boolean(n.length),i=n.shift();return r&&notifySplice(this,n,t.path,0,0,[i]),i}unshift(e,...t){let n={path:""},r=get$1(this,e,n),i=r.unshift(...t);return t.length&&notifySplice(this,r,n.path,0,t.length,[]),i}notifyPath(e,t){let n;if(1==arguments.length){let r={path:""};t=get$1(this,e,r),n=r.path}else n=Array.isArray(e)?normalize$2(e):e;this._setPendingPropertyOrPath(n,t,!0,!0)&&this._invalidateProperties()}_createReadOnlyProperty(e,t){this._addPropertyEffect(e,TYPES.READ_ONLY),t&&(this["_set"+upper(e)]=function(t){this._setProperty(e,t)})}_createPropertyObserver(e,t,n){let r={property:e,method:t,dynamicFn:Boolean(n)};this._addPropertyEffect(e,TYPES.OBSERVE,{fn:runObserverEffect,info:r,trigger:{name:e}}),n&&this._addPropertyEffect(t,TYPES.OBSERVE,{fn:runObserverEffect,info:r,trigger:{name:t}})}_createMethodObserver(e,t){let n=parseMethod(e);if(!n)throw new Error("Malformed observer expression '"+e+"'");createMethodEffect(this,n,TYPES.OBSERVE,runMethodEffect,null,t)}_createNotifyingProperty(e){this._addPropertyEffect(e,TYPES.NOTIFY,{fn:runNotifyEffect,info:{eventName:camelToDashCase(e)+"-changed",property:e}})}_createReflectedProperty(e){let t=this.constructor.attributeNameForProperty(e);"-"===t[0]?console.warn("Property "+e+" cannot be reflected to attribute "+t+' because "-" is not a valid starting attribute name. Use a lowercase first letter for the property instead.'):this._addPropertyEffect(e,TYPES.REFLECT,{fn:runReflectEffect,info:{attrName:t}})}_createComputedProperty(e,t,n){let r=parseMethod(t);if(!r)throw new Error("Malformed computed expression '"+t+"'");const i=createMethodEffect(this,r,TYPES.COMPUTE,runComputedEffect,e,n);ensureOwnEffectMap(this,COMPUTE_INFO)[e]=i}_marshalArgs(e,t,n){const r=this.__data,i=[];for(let a=0,o=e.length;a<o;a++){let{name:o,structured:s,wildcard:l,value:c,literal:h}=e[a];if(!h)if(l){const e=isDescendant(o,t),i=getArgValue(r,n,e?t:o);c={path:e?t:o,value:i,base:e?get$1(r,o):i}}else c=s?getArgValue(r,n,o):r[o];if(legacyUndefined&&!this._overrideLegacyUndefined&&void 0===c&&e.length>1)return NOOP;i[a]=c}return i}static addPropertyEffect(e,t,n){this.prototype._addPropertyEffect(e,t,n)}static createPropertyObserver(e,t,n){this.prototype._createPropertyObserver(e,t,n)}static createMethodObserver(e,t){this.prototype._createMethodObserver(e,t)}static createNotifyingProperty(e){this.prototype._createNotifyingProperty(e)}static createReadOnlyProperty(e,t){this.prototype._createReadOnlyProperty(e,t)}static createReflectedProperty(e){this.prototype._createReflectedProperty(e)}static createComputedProperty(e,t,n){this.prototype._createComputedProperty(e,t,n)}static bindTemplate(e){return this.prototype._bindTemplate(e)}_bindTemplate(e,t){let n=this.constructor._parseTemplate(e),r=this.__preBoundTemplateInfo==n;if(!r)for(let e in n.propertyEffects)this._createPropertyAccessor(e);if(t)if(n=Object.create(n),n.wasPreBound=r,this.__templateInfo){const t=e._parentTemplateInfo||this.__templateInfo,r=t.lastChild;n.parent=t,t.lastChild=n,n.previousSibling=r,r?r.nextSibling=n:t.firstChild=n}else this.__templateInfo=n;else this.__preBoundTemplateInfo=n;return n}static _addTemplatePropertyEffect(e,t,n){(e.hostProps=e.hostProps||{})[t]=!0;let r=e.propertyEffects=e.propertyEffects||{};(r[t]=r[t]||[]).push(n)}_stampTemplate(e,t){t=t||this._bindTemplate(e,!0),hostStack.push(this);let n=super._stampTemplate(e,t);if(hostStack.pop(),t.nodeList=n.nodeList,!t.wasPreBound){let e=t.childNodes=[];for(let t=n.firstChild;t;t=t.nextSibling)e.push(t)}return n.templateInfo=t,setupBindings(this,t),this.__dataClientsReady&&(this._runEffectsForTemplate(t,this.__data,null,!1),this._flushClients()),n}_removeBoundDom(e){const t=e.templateInfo,{previousSibling:n,nextSibling:r,parent:i}=t;n?n.nextSibling=r:i&&(i.firstChild=r),r?r.previousSibling=n:i&&(i.lastChild=n),t.nextSibling=t.previousSibling=null;let a=t.childNodes;for(let e=0;e<a.length;e++){let t=a[e];wrap(wrap(t).parentNode).removeChild(t)}}static _parseTemplateNode(e,n,r){let i=t._parseTemplateNode.call(this,e,n,r);if(e.nodeType===Node.TEXT_NODE){let t=this._parseBindings(e.textContent,n);t&&(e.textContent=literalFromParts(t)||" ",addBinding(this,n,r,"text","textContent",t),i=!0)}return i}static _parseTemplateNodeAttribute(e,n,r,i,a){let o=this._parseBindings(a,n);if(o){let t=i,a="property";capitalAttributeRegex.test(i)?a="attribute":"$"==i[i.length-1]&&(i=i.slice(0,-1),a="attribute");let s=literalFromParts(o);return s&&"attribute"==a&&("class"==i&&e.hasAttribute("class")&&(s+=" "+e.getAttribute(i)),e.setAttribute(i,s)),"attribute"==a&&"disable-upgrade$"==t&&e.setAttribute(i,""),"input"===e.localName&&"value"===t&&e.setAttribute(t,""),e.removeAttribute(t),"property"===a&&(i=dashToCamelCase(i)),addBinding(this,n,r,a,i,o,s),!0}return t._parseTemplateNodeAttribute.call(this,e,n,r,i,a)}static _parseTemplateNestedTemplate(e,n,r){let i=t._parseTemplateNestedTemplate.call(this,e,n,r);const a=e.parentNode,o=r.templateInfo,s="dom-if"===a.localName;removeNestedTemplates&&(s||"dom-repeat"===a.localName)&&(a.removeChild(e),(r=r.parentInfo).templateInfo=o,r.noted=!0,i=!1);let l=o.hostProps;if(fastDomIf&&s)l&&(n.hostProps=Object.assign(n.hostProps||{},l),removeNestedTemplates||(r.parentInfo.noted=!0));else{let e="{";for(let t in l){addBinding(this,n,r,"property","_host_"+t,[{mode:e,source:t,dependencies:[t],hostProp:!0}])}}return i}static _parseBindings(e,t){let n,r=[],i=0;for(;null!==(n=bindingRegex.exec(e));){n.index>i&&r.push({literal:e.slice(i,n.index)});let a=n[1][0],o=Boolean(n[2]),s=n[3].trim(),l=!1,c="",h=-1;"{"==a&&(h=s.indexOf("::"))>0&&(c=s.substring(h+2),s=s.substring(0,h),l=!0);let u=parseMethod(s),d=[];if(u){let{args:e,methodName:n}=u;for(let t=0;t<e.length;t++){let n=e[t];n.literal||d.push(n)}let r=t.dynamicFns;(r&&r[n]||u.static)&&(d.push(n),u.dynamicFn=!0)}else d.push(s);r.push({source:s,mode:a,negate:o,customEvent:l,signature:u,dependencies:d,event:c}),i=bindingRegex.lastIndex}if(i&&i<e.length){let t=e.substring(i);t&&r.push({literal:t})}return r.length?r:null}static _evaluateBinding(e,t,n,r,i,a){let o;return o=t.signature?runMethodEffect(e,n,r,i,t.signature):n!=t.source?get$1(e,t.source):a&&isPath(n)?get$1(e,n):e.__data[n],t.negate&&(o=!o),o}}})),hostStack=[];
/**
    @license
    Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
    The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
    The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
    Code distributed by Google as part of the polymer project is also
    subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
    */
function register$1(e){}
/**
    @license
    Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
    The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
    The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
    Code distributed by Google as part of the polymer project is also
    subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
    */function normalizeProperties(e){const t={};for(let n in e){const r=e[n];t[n]="function"==typeof r?{type:r}:r}return t}const PropertiesMixin=dedupingMixin((e=>{const t=PropertiesChanged(e);function n(e){const t=Object.getPrototypeOf(e);return t.prototype instanceof i?t:null}function r(e){if(!e.hasOwnProperty(JSCompiler_renameProperty("__ownProperties",e))){let t=null;if(e.hasOwnProperty(JSCompiler_renameProperty("properties",e))){const n=e.properties;n&&(t=normalizeProperties(n))}e.__ownProperties=t}return e.__ownProperties}class i extends t{static get observedAttributes(){if(!this.hasOwnProperty(JSCompiler_renameProperty("__observedAttributes",this))){register$1(this.prototype);const e=this._properties;this.__observedAttributes=e?Object.keys(e).map((e=>this.prototype._addPropertyToAttributeMap(e))):[]}return this.__observedAttributes}static finalize(){if(!this.hasOwnProperty(JSCompiler_renameProperty("__finalized",this))){const e=n(this);e&&e.finalize(),this.__finalized=!0,this._finalizeClass()}}static _finalizeClass(){const e=r(this);e&&this.createProperties(e)}static get _properties(){if(!this.hasOwnProperty(JSCompiler_renameProperty("__properties",this))){const e=n(this);this.__properties=Object.assign({},e&&e._properties,r(this))}return this.__properties}static typeForProperty(e){const t=this._properties[e];return t&&t.type}_initializeProperties(){this.constructor.finalize(),super._initializeProperties()}connectedCallback(){super.connectedCallback&&super.connectedCallback(),this._enableProperties()}disconnectedCallback(){super.disconnectedCallback&&super.disconnectedCallback()}}return i})),version="3.4.1",builtCSS=window.ShadyCSS&&window.ShadyCSS.cssBuild,ElementMixin=dedupingMixin((e=>{const t=PropertiesMixin(PropertyEffects(e));function n(e,t,n,r){n.computed&&(n.readOnly=!0),n.computed&&(e._hasReadOnlyEffect(t)?console.warn(`Cannot redefine computed property '${t}'.`):e._createComputedProperty(t,n.computed,r)),n.readOnly&&!e._hasReadOnlyEffect(t)?e._createReadOnlyProperty(t,!n.computed):!1===n.readOnly&&e._hasReadOnlyEffect(t)&&console.warn(`Cannot make readOnly property '${t}' non-readOnly.`),n.reflectToAttribute&&!e._hasReflectEffect(t)?e._createReflectedProperty(t):!1===n.reflectToAttribute&&e._hasReflectEffect(t)&&console.warn(`Cannot make reflected property '${t}' non-reflected.`),n.notify&&!e._hasNotifyEffect(t)?e._createNotifyingProperty(t):!1===n.notify&&e._hasNotifyEffect(t)&&console.warn(`Cannot make notify property '${t}' non-notify.`),n.observer&&e._createPropertyObserver(t,n.observer,r[n.observer]),e._addPropertyToAttributeMap(t)}return class extends t{static get polymerElementVersion(){return version}static _finalizeClass(){t._finalizeClass.call(this);const e=(function n(e){return e.hasOwnProperty(JSCompiler_renameProperty("__ownObservers",e))||(e.__ownObservers=e.hasOwnProperty(JSCompiler_renameProperty("observers",e))?e.observers:null),e.__ownObservers})(this);e&&this.createObservers(e,this._properties),this._prepareTemplate()}static _prepareTemplate(){let e=this.template;e&&("string"==typeof e?(console.error("template getter must return HTMLTemplateElement"),e=null):legacyOptimizations||(e=e.cloneNode(!0))),this.prototype._template=e}static createProperties(e){for(let t in e)n(this.prototype,t,e[t],e)}static createObservers(e,t){const n=this.prototype;for(let r=0;r<e.length;r++)n._createMethodObserver(e[r],t)}static get template(){if(!this.hasOwnProperty(JSCompiler_renameProperty("_template",this))){const e=this.prototype.hasOwnProperty(JSCompiler_renameProperty("_template",this.prototype))?this.prototype._template:void 0;this._template=void 0!==e?e:this.hasOwnProperty(JSCompiler_renameProperty("is",this))&&(function t(e){let t=null;if(e&&(!strictTemplatePolicy||allowTemplateFromDomModule)&&(t=DomModule.import(e,"template"),strictTemplatePolicy&&!t))throw new Error(`strictTemplatePolicy: expecting dom-module or null template for ${e}`);return t})(this.is)||Object.getPrototypeOf(this.prototype).constructor.template}return this._template}static set template(e){this._template=e}static get importPath(){if(!this.hasOwnProperty(JSCompiler_renameProperty("_importPath",this))){const e=this.importMeta;if(e)this._importPath=pathFromUrl(e.url);else{const e=DomModule.import(this.is);this._importPath=e&&e.assetpath||Object.getPrototypeOf(this.prototype).constructor.importPath}}return this._importPath}constructor(){super()}_initializeProperties(){this.constructor.finalize(),this.constructor._finalizeTemplate(this.localName),super._initializeProperties(),this.rootPath=rootPath,this.importPath=this.constructor.importPath;let e=(function t(e){if(!e.hasOwnProperty(JSCompiler_renameProperty("__propertyDefaults",e))){e.__propertyDefaults=null;let t=e._properties;for(let n in t){let r=t[n];"value"in r&&(e.__propertyDefaults=e.__propertyDefaults||{},e.__propertyDefaults[n]=r)}}return e.__propertyDefaults})(this.constructor);if(e)for(let t in e){let n=e[t];if(this._canApplyPropertyDefault(t)){let e="function"==typeof n.value?n.value.call(this):n.value;this._hasAccessor(t)?this._setPendingProperty(t,e,!0):this[t]=e}}}_canApplyPropertyDefault(e){return!this.hasOwnProperty(e)}static _processStyleText(e,t){return resolveCss(e,t)}static _finalizeTemplate(e){const t=this.prototype._template;if(t&&!t.__polymerFinalized){t.__polymerFinalized=!0;const n=this.importPath;!(function r(e,t,n,i){if(!builtCSS){const r=t.content.querySelectorAll("style"),a=stylesFromTemplate(t),o=stylesFromModuleImports(n),s=t.content.firstElementChild;for(let n=0;n<o.length;n++){let r=o[n];r.textContent=e._processStyleText(r.textContent,i),t.content.insertBefore(r,s)}let l=0;for(let t=0;t<a.length;t++){let n=a[t],o=r[l];o!==n?(n=n.cloneNode(!0),o.parentNode.insertBefore(n,o)):l++,n.textContent=e._processStyleText(n.textContent,i)}}if(window.ShadyCSS&&window.ShadyCSS.prepareTemplate(t,n),useAdoptedStyleSheetsWithBuiltCSS&&builtCSS&&supportsAdoptingStyleSheets){const n=t.content.querySelectorAll("style");if(n){let t="";Array.from(n).forEach((e=>{t+=e.textContent,e.parentNode.removeChild(e)})),e._styleSheet=new CSSStyleSheet,e._styleSheet.replaceSync(t)}}})(this,t,e,n?resolveUrl(n):""),this.prototype._bindTemplate(t)}}connectedCallback(){window.ShadyCSS&&this._template&&window.ShadyCSS.styleElement(this),super.connectedCallback()}ready(){this._template&&(this.root=this._stampTemplate(this._template),this.$=this.root.$),super.ready()}_readyClients(){this._template&&(this.root=this._attachDom(this.root)),super._readyClients()}_attachDom(e){const t=wrap(this);if(t.attachShadow)return e?(t.shadowRoot||(t.attachShadow({mode:"open",shadyUpgradeFragment:e}),t.shadowRoot.appendChild(e),this.constructor._styleSheet&&(t.shadowRoot.adoptedStyleSheets=[this.constructor._styleSheet])),syncInitialRender&&window.ShadyDOM&&window.ShadyDOM.flushInitial(t.shadowRoot),t.shadowRoot):null;throw new Error("ShadowDOM not available. PolymerElement can create dom as children instead of in ShadowDOM by setting `this.root = this;` before `ready`.")}updateStyles(e){window.ShadyCSS&&window.ShadyCSS.styleSubtree(this,e)}resolveUrl(e,t){return!t&&this.importPath&&(t=resolveUrl(this.importPath)),resolveUrl(e,t)}static _parseTemplateContent(e,n,r){return n.dynamicFns=n.dynamicFns||this._properties,t._parseTemplateContent.call(this,e,n,r)}static _addTemplatePropertyEffect(e,n,r){return!legacyWarnings||n in this._properties||r.info.part.signature&&r.info.part.signature.static||r.info.part.hostProp||e.nestedTemplate||console.warn(`Property '${n}' used in template but not declared in 'properties'; attribute will not be observed.`),t._addTemplatePropertyEffect.call(this,e,n,r)}}}));
/**
     * @fileoverview
     * @suppress {checkPrototypalTypes}
     * @license Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
     * This code may only be used under the BSD style license found at
     * http://polymer.github.io/LICENSE.txt The complete set of authors may be found
     * at http://polymer.github.io/AUTHORS.txt The complete set of contributors may
     * be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by
     * Google as part of the polymer project is also subject to an additional IP
     * rights grant found at http://polymer.github.io/PATENTS.txt
     */
/**
    @license
    Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
    The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
    The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
    Code distributed by Google as part of the polymer project is also
    subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
    */
class LiteralString{constructor(e){this.value=e.toString()}toString(){return this.value}}function literalValue(e){if(e instanceof LiteralString)return e.value;throw new Error(`non-literal value passed to Polymer's htmlLiteral function: ${e}`)}function htmlValue(e){if(e instanceof HTMLTemplateElement)return e.innerHTML;if(e instanceof LiteralString)return literalValue(e);throw new Error(`non-template value passed to Polymer's html function: ${e}`)}const html=function e(t,...n){const r=document.createElement("template");return r.innerHTML=n.reduce(((e,n,r)=>e+htmlValue(n)+t[r+1]),t[0]),r},PolymerElement=ElementMixin(HTMLElement),nativeShadow=!(window.ShadyDOM&&window.ShadyDOM.inUse);
/**
    @license
    Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
    The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
    The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
    Code distributed by Google as part of the polymer project is also
    subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
    */let nativeCssVariables_,cssBuild;function calcCssVariables(e){nativeCssVariables_=(!e||!e.shimcssproperties)&&(nativeShadow||Boolean(!navigator.userAgent.match(/AppleWebKit\/601|Edge\/15/)&&window.CSS&&CSS.supports&&CSS.supports("box-shadow","0 0 0 var(--foo)")))}window.ShadyCSS&&void 0!==window.ShadyCSS.cssBuild&&(cssBuild=window.ShadyCSS.cssBuild);const disableRuntime=Boolean(window.ShadyCSS&&window.ShadyCSS.disableRuntime);window.ShadyCSS&&void 0!==window.ShadyCSS.nativeCss?nativeCssVariables_=window.ShadyCSS.nativeCss:window.ShadyCSS?(calcCssVariables(window.ShadyCSS),window.ShadyCSS=void 0):calcCssVariables(window.WebComponents&&window.WebComponents.flags);const nativeCssVariables=nativeCssVariables_;
/**
    @license
    Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
    The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
    The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
    Code distributed by Google as part of the polymer project is also
    subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
    */class StyleNode{constructor(){this.start=0,this.end=0,this.previous=null,this.parent=null,this.rules=null,this.parsedCssText="",this.cssText="",this.atRule=!1,this.type=0,this.keyframesName="",this.selector="",this.parsedSelector=""}}function parse(e){return parseCss(lex(e=clean(e)),e)}function clean(e){return e.replace(RX.comments,"").replace(RX.port,"")}function lex(e){let t=new StyleNode;t.start=0,t.end=e.length;let n=t;for(let r=0,i=e.length;r<i;r++)if(e[r]===OPEN_BRACE){n.rules||(n.rules=[]);let e=n,t=e.rules[e.rules.length-1]||null;n=new StyleNode,n.start=r+1,n.parent=e,n.previous=t,e.rules.push(n)}else e[r]===CLOSE_BRACE&&(n.end=r+1,n=n.parent||t);return t}function parseCss(e,t){let n=t.substring(e.start,e.end-1);if(e.parsedCssText=e.cssText=n.trim(),e.parent){n=t.substring(e.previous?e.previous.end:e.parent.start,e.start-1),n=_expandUnicodeEscapes(n),n=n.replace(RX.multipleSpaces," "),n=n.substring(n.lastIndexOf(";")+1);let r=e.parsedSelector=e.selector=n.trim();e.atRule=0===r.indexOf(AT_START),e.atRule?0===r.indexOf(MEDIA_START)?e.type=types.MEDIA_RULE:r.match(RX.keyframesRule)&&(e.type=types.KEYFRAMES_RULE,e.keyframesName=e.selector.split(RX.multipleSpaces).pop()):e.type=0===r.indexOf(VAR_START)?types.MIXIN_RULE:types.STYLE_RULE}let r=e.rules;if(r)for(let e,n=0,i=r.length;n<i&&(e=r[n]);n++)parseCss(e,t);return e}function _expandUnicodeEscapes(e){return e.replace(/\\([0-9a-f]{1,6})\s/gi,(function(){let e=arguments[1],t=6-e.length;for(;t--;)e="0"+e;return"\\"+e}))}function stringify(e,t,n=""){let r="";if(e.cssText||e.rules){let n=e.rules;if(n&&!_hasMixinRules(n))for(let e,i=0,a=n.length;i<a&&(e=n[i]);i++)r=stringify(e,t,r);else r=t?e.cssText:removeCustomProps(e.cssText),r=r.trim(),r&&(r="  "+r+"\n")}return r&&(e.selector&&(n+=e.selector+" "+OPEN_BRACE+"\n"),n+=r,e.selector&&(n+=CLOSE_BRACE+"\n\n")),n}function _hasMixinRules(e){let t=e[0];return Boolean(t)&&Boolean(t.selector)&&0===t.selector.indexOf(VAR_START)}function removeCustomProps(e){return removeCustomPropApply(e=removeCustomPropAssignment(e))}function removeCustomPropAssignment(e){return e.replace(RX.customProp,"").replace(RX.mixinProp,"")}function removeCustomPropApply(e){return e.replace(RX.mixinApply,"").replace(RX.varApply,"")}const types={STYLE_RULE:1,KEYFRAMES_RULE:7,MEDIA_RULE:4,MIXIN_RULE:1e3},OPEN_BRACE="{",CLOSE_BRACE="}",RX={comments:/\/\*[^*]*\*+([^/*][^*]*\*+)*\//gim,port:/@import[^;]*;/gim,customProp:/(?:^[^;\-\s}]+)?--[^;{}]*?:[^{};]*?(?:[;\n]|$)/gim,mixinProp:/(?:^[^;\-\s}]+)?--[^;{}]*?:[^{};]*?{[^}]*?}(?:[;\n]|$)?/gim,mixinApply:/@apply\s*\(?[^);]*\)?\s*(?:[;\n]|$)?/gim,varApply:/[^;:]*?:[^;]*?var\([^;]*\)(?:[;\n]|$)?/gim,keyframesRule:/^@[^\s]*keyframes/,multipleSpaces:/\s+/g},VAR_START="--",MEDIA_START="@media",AT_START="@",VAR_ASSIGN=/(?:^|[;\s{]\s*)(--[\w-]*?)\s*:\s*(?:((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};{])+)|\{([^}]*)\}(?:(?=[;\s}])|$))/gi,MIXIN_MATCH=/(?:^|\W+)@apply\s*\(?([^);\n]*)\)?/gi,MEDIA_MATCH=/@media\s(.*)/,styleTextSet=new Set,scopingAttribute="shady-unscoped";function processUnscopedStyle(e){const t=e.textContent;if(!styleTextSet.has(t)){styleTextSet.add(t);const e=document.createElement("style");e.setAttribute("shady-unscoped",""),e.textContent=t,document.head.appendChild(e)}}function isUnscopedStyle(e){return e.hasAttribute(scopingAttribute)}
/**
    @license
    Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
    The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
    The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
    Code distributed by Google as part of the polymer project is also
    subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
    */function toCssText(e,t){return e?("string"==typeof e&&(e=parse(e)),t&&forEachRule(e,t),stringify(e,nativeCssVariables)):""}function rulesForStyle(e){return!e.__cssRules&&e.textContent&&(e.__cssRules=parse(e.textContent)),e.__cssRules||null}function forEachRule(e,t,n,r){if(!e)return;let i=!1,a=e.type;if(r&&a===types.MEDIA_RULE){let t=e.selector.match(MEDIA_MATCH);t&&(window.matchMedia(t[1]).matches||(i=!0))}a===types.STYLE_RULE?t(e):n&&a===types.KEYFRAMES_RULE?n(e):a===types.MIXIN_RULE&&(i=!0);let o=e.rules;if(o&&!i)for(let e,i=0,a=o.length;i<a&&(e=o[i]);i++)forEachRule(e,t,n,r)}function findMatchingParen(e,t){let n=0;for(let r=t,i=e.length;r<i;r++)if("("===e[r])n++;else if(")"===e[r]&&0==--n)return r;return-1}function processVariableAndFallback(e,t){let n=e.indexOf("var(");if(-1===n)return t(e,"","","");let r=findMatchingParen(e,n+3),i=e.substring(n+4,r),a=e.substring(0,n),o=processVariableAndFallback(e.substring(r+1),t),s=i.indexOf(",");return-1===s?t(a,i.trim(),"",o):t(a,i.substring(0,s).trim(),i.substring(s+1).trim(),o)}function getIsExtends(e){let t=e.localName,n="",r="";return t?t.indexOf("-")>-1?n=t:(r=t,n=e.getAttribute&&e.getAttribute("is")||""):(n=e.is,r=e.extends),{is:n,typeExtension:r}}function gatherStyleText(e){const t=[],n=e.querySelectorAll("style");for(let e=0;e<n.length;e++){const r=n[e];isUnscopedStyle(r)?nativeShadow||(processUnscopedStyle(r),r.parentNode.removeChild(r)):(t.push(r.textContent),r.parentNode.removeChild(r))}return t.join("").trim()}window.ShadyDOM&&window;const CSS_BUILD_ATTR="css-build";function getCssBuild(e){if(void 0!==cssBuild)return cssBuild;if(void 0===e.__cssBuild){const t=e.getAttribute(CSS_BUILD_ATTR);if(t)e.__cssBuild=t;else{const t=getBuildComment(e);""!==t&&removeBuildComment(e),e.__cssBuild=t}}return e.__cssBuild||""}function elementHasBuiltCss(e){return""!==getCssBuild(e)}function getBuildComment(e){const t="template"===e.localName?e.content.firstChild:e.firstChild;if(t instanceof Comment){const e=t.textContent.trim().split(":");if(e[0]===CSS_BUILD_ATTR)return e[1]}return""}function removeBuildComment(e){const t="template"===e.localName?e.content.firstChild:e.firstChild;t.parentNode.removeChild(t)}
/**
    @license
    Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
    The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
    The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
    Code distributed by Google as part of the polymer project is also
    subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
    */function updateNativeProperties(e,t){for(let n in t)null===n?e.style.removeProperty(n):e.style.setProperty(n,t[n])}function getComputedStyleValue(e,t){const n=window.getComputedStyle(e).getPropertyValue(t);return n?n.trim():""}function detectMixin(e){const t=MIXIN_MATCH.test(e)||VAR_ASSIGN.test(e);return MIXIN_MATCH.lastIndex=0,VAR_ASSIGN.lastIndex=0,t}
/**
    @license
    Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
    The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
    The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
    Code distributed by Google as part of the polymer project is also
    subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
    */const APPLY_NAME_CLEAN=/;\s*/m,INITIAL_INHERIT=/^\s*(initial)|(inherit)\s*$/,IMPORTANT=/\s*!important/,MIXIN_VAR_SEP="_-_";class MixinMap{constructor(){this._map={}}set(e,t){e=e.trim(),this._map[e]={properties:t,dependants:{}}}get(e){return e=e.trim(),this._map[e]||null}}let invalidCallback=null;class ApplyShim{constructor(){this._currentElement=null,this._measureElement=null,this._map=new MixinMap}detectMixin(e){return detectMixin(e)}gatherStyles(e){const t=gatherStyleText(e.content);if(t){const n=document.createElement("style");return n.textContent=t,e.content.insertBefore(n,e.content.firstChild),n}return null}transformTemplate(e,t){void 0===e._gatheredStyle&&(e._gatheredStyle=this.gatherStyles(e));const n=e._gatheredStyle;return n?this.transformStyle(n,t):null}transformStyle(e,t=""){let n=rulesForStyle(e);return this.transformRules(n,t),e.textContent=toCssText(n),n}transformCustomStyle(e){let t=rulesForStyle(e);return forEachRule(t,(e=>{":root"===e.selector&&(e.selector="html"),this.transformRule(e)})),e.textContent=toCssText(t),t}transformRules(e,t){this._currentElement=t,forEachRule(e,(e=>{this.transformRule(e)})),this._currentElement=null}transformRule(e){e.cssText=this.transformCssText(e.parsedCssText,e),":root"===e.selector&&(e.selector=":host > *")}transformCssText(e,t){return e=e.replace(VAR_ASSIGN,((e,n,r,i)=>this._produceCssProperties(e,n,r,i,t))),this._consumeCssProperties(e,t)}_getInitialValueForProperty(e){return this._measureElement||(this._measureElement=document.createElement("meta"),this._measureElement.setAttribute("apply-shim-measure",""),this._measureElement.style.all="initial",document.head.appendChild(this._measureElement)),window.getComputedStyle(this._measureElement).getPropertyValue(e)}_fallbacksFromPreviousRules(e){let t=e;for(;t.parent;)t=t.parent;const n={};let r=!1;return forEachRule(t,(t=>{r=r||t===e,r||t.selector===e.selector&&Object.assign(n,this._cssTextToMap(t.parsedCssText))})),n}_consumeCssProperties(e,t){let n=null;for(;n=MIXIN_MATCH.exec(e);){let r=n[0],i=n[1],a=n.index,o=a+r.indexOf("@apply"),s=a+r.length,l=e.slice(0,o),c=e.slice(s),h=t?this._fallbacksFromPreviousRules(t):{};Object.assign(h,this._cssTextToMap(l));let u=this._atApplyToCssProperties(i,h);e=`${l}${u}${c}`,MIXIN_MATCH.lastIndex=a+u.length}return e}_atApplyToCssProperties(e,t){e=e.replace(APPLY_NAME_CLEAN,"");let n=[],r=this._map.get(e);if(r||(this._map.set(e,{}),r=this._map.get(e)),r){let i,a,o;this._currentElement&&(r.dependants[this._currentElement]=!0);const s=r.properties;for(i in s)o=t&&t[i],a=[i,": var(",e,MIXIN_VAR_SEP,i],o&&a.push(",",o.replace(IMPORTANT,"")),a.push(")"),IMPORTANT.test(s[i])&&a.push(" !important"),n.push(a.join(""))}return n.join("; ")}_replaceInitialOrInherit(e,t){let n=INITIAL_INHERIT.exec(t);return n&&(t=n[1]?this._getInitialValueForProperty(e):"apply-shim-inherit"),t}_cssTextToMap(e,t=!1){let n,r,i=e.split(";"),a={};for(let e,o,s=0;s<i.length;s++)e=i[s],e&&(o=e.split(":"),o.length>1&&(n=o[0].trim(),r=o.slice(1).join(":"),t&&(r=this._replaceInitialOrInherit(n,r)),a[n]=r));return a}_invalidateMixinEntry(e){if(invalidCallback)for(let t in e.dependants)t!==this._currentElement&&invalidCallback(t)}_produceCssProperties(e,t,n,r,i){if(n&&processVariableAndFallback(n,((e,t)=>{t&&this._map.get(t)&&(r=`@apply ${t};`)})),!r)return e;let a=this._consumeCssProperties(""+r,i),o=e.slice(0,e.indexOf("--")),s=this._cssTextToMap(a,!0),l=s,c=this._map.get(t),h=c&&c.properties;h?l=Object.assign(Object.create(h),s):this._map.set(t,l);let u,d,p=[],m=!1;for(u in l)d=s[u],void 0===d&&(d="initial"),h&&!(u in h)&&(m=!0),p.push(`${t}${MIXIN_VAR_SEP}${u}: ${d}`);return m&&this._invalidateMixinEntry(c),c&&(c.properties=l),n&&(o=`${e};${o}`),`${o}${p.join("; ")};`}}ApplyShim.prototype.detectMixin=ApplyShim.prototype.detectMixin,ApplyShim.prototype.transformStyle=ApplyShim.prototype.transformStyle,ApplyShim.prototype.transformCustomStyle=ApplyShim.prototype.transformCustomStyle,ApplyShim.prototype.transformRules=ApplyShim.prototype.transformRules,ApplyShim.prototype.transformRule=ApplyShim.prototype.transformRule,ApplyShim.prototype.transformTemplate=ApplyShim.prototype.transformTemplate,ApplyShim.prototype._separator=MIXIN_VAR_SEP,Object.defineProperty(ApplyShim.prototype,"invalidCallback",{get:()=>invalidCallback,set(e){invalidCallback=e}});
/**
    @license
    Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
    The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
    The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
    Code distributed by Google as part of the polymer project is also
    subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
    */
const templateMap={},CURRENT_VERSION="_applyShimCurrentVersion",NEXT_VERSION="_applyShimNextVersion",VALIDATING_VERSION="_applyShimValidatingVersion",promise=Promise.resolve();
/**
    @license
    Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
    The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
    The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
    Code distributed by Google as part of the polymer project is also
    subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
    */function invalidate(e){let t=templateMap[e];t&&invalidateTemplate(t)}function invalidateTemplate(e){e[CURRENT_VERSION]=e[CURRENT_VERSION]||0,e[VALIDATING_VERSION]=e[VALIDATING_VERSION]||0,e[NEXT_VERSION]=(e[NEXT_VERSION]||0)+1}function templateIsValid(e){return e[CURRENT_VERSION]===e[NEXT_VERSION]}function templateIsValidating(e){return!templateIsValid(e)&&e[VALIDATING_VERSION]===e[NEXT_VERSION]}function startValidatingTemplate(e){e[VALIDATING_VERSION]=e[NEXT_VERSION],e._validating||(e._validating=!0,promise.then((function(){e[CURRENT_VERSION]=e[NEXT_VERSION],e._validating=!1})))}
/**
    @license
    Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
    The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
    The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
    Code distributed by Google as part of the polymer project is also
    subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
    */let readyPromise=null,whenReady=window.HTMLImports&&window.HTMLImports.whenReady||null,resolveFn;function documentWait(e){requestAnimationFrame((function(){whenReady?whenReady(e):(readyPromise||(readyPromise=new Promise((e=>{resolveFn=e})),"complete"===document.readyState?resolveFn():document.addEventListener("readystatechange",(()=>{"complete"===document.readyState&&resolveFn()}))),readyPromise.then((function(){e&&e()})))}))}
/**
    @license
    Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
    The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
    The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
    Code distributed by Google as part of the polymer project is also
    subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
    */const SEEN_MARKER="__seenByShadyCSS",CACHED_STYLE="__shadyCSSCachedStyle";let transformFn=null,validateFn=null;class CustomStyleInterface$1{constructor(){this.customStyles=[],this.enqueued=!1,documentWait((()=>{window.ShadyCSS.flushCustomStyles&&window.ShadyCSS.flushCustomStyles()}))}enqueueDocumentValidation(){!this.enqueued&&validateFn&&(this.enqueued=!0,documentWait(validateFn))}addCustomStyle(e){e[SEEN_MARKER]||(e[SEEN_MARKER]=!0,this.customStyles.push(e),this.enqueueDocumentValidation())}getStyleForCustomStyle(e){if(e[CACHED_STYLE])return e[CACHED_STYLE];let t;return t=e.getStyle?e.getStyle():e,t}processStyles(){const e=this.customStyles;for(let t=0;t<e.length;t++){const n=e[t];if(n[CACHED_STYLE])continue;const r=this.getStyleForCustomStyle(n);if(r){const e=r.__appliedElement||r;transformFn&&transformFn(e),n[CACHED_STYLE]=e}}return e}}CustomStyleInterface$1.prototype.addCustomStyle=CustomStyleInterface$1.prototype.addCustomStyle,CustomStyleInterface$1.prototype.getStyleForCustomStyle=CustomStyleInterface$1.prototype.getStyleForCustomStyle,CustomStyleInterface$1.prototype.processStyles=CustomStyleInterface$1.prototype.processStyles,Object.defineProperties(CustomStyleInterface$1.prototype,{transformCallback:{get:()=>transformFn,set(e){transformFn=e}},validateCallback:{get:()=>validateFn,set(e){let t=!1;validateFn||(t=!0),validateFn=e,t&&this.enqueueDocumentValidation()}}});
/**
    @license
    Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
    The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
    The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
    Code distributed by Google as part of the polymer project is also
    subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
    */
const applyShim=new ApplyShim;class ApplyShimInterface{constructor(){this.customStyleInterface=null,applyShim.invalidCallback=invalidate}ensure(){this.customStyleInterface||window.ShadyCSS.CustomStyleInterface&&(this.customStyleInterface=window.ShadyCSS.CustomStyleInterface,this.customStyleInterface.transformCallback=e=>{applyShim.transformCustomStyle(e)},this.customStyleInterface.validateCallback=()=>{requestAnimationFrame((()=>{this.customStyleInterface.enqueued&&this.flushCustomStyles()}))})}prepareTemplate(e,t){if(this.ensure(),elementHasBuiltCss(e))return;templateMap[t]=e;let n=applyShim.transformTemplate(e,t);e._styleAst=n}flushCustomStyles(){if(this.ensure(),!this.customStyleInterface)return;let e=this.customStyleInterface.processStyles();if(this.customStyleInterface.enqueued){for(let t=0;t<e.length;t++){let n=this.customStyleInterface.getStyleForCustomStyle(e[t]);n&&applyShim.transformCustomStyle(n)}this.customStyleInterface.enqueued=!1}}styleSubtree(e,t){if(this.ensure(),t&&updateNativeProperties(e,t),e.shadowRoot){this.styleElement(e);let t=e.shadowRoot.children||e.shadowRoot.childNodes;for(let e=0;e<t.length;e++)this.styleSubtree(t[e])}else{let t=e.children||e.childNodes;for(let e=0;e<t.length;e++)this.styleSubtree(t[e])}}styleElement(e){this.ensure();let{is:t}=getIsExtends(e),n=templateMap[t];if((!n||!elementHasBuiltCss(n))&&n&&!templateIsValid(n)){templateIsValidating(n)||(this.prepareTemplate(n,t),startValidatingTemplate(n));let r=e.shadowRoot;if(r){let e=r.querySelector("style");e&&(e.__cssRules=n._styleAst,e.textContent=toCssText(n._styleAst))}}}styleDocument(e){this.ensure(),this.styleSubtree(document.body,e)}}if(!window.ShadyCSS||!window.ShadyCSS.ScopingShim){const e=new ApplyShimInterface;let t=window.ShadyCSS&&window.ShadyCSS.CustomStyleInterface;window.ShadyCSS={prepareTemplate(t,n,r){e.flushCustomStyles(),e.prepareTemplate(t,n)},prepareTemplateStyles(e,t,n){window.ShadyCSS.prepareTemplate(e,t,n)},prepareTemplateDom(e,t){},styleSubtree(t,n){e.flushCustomStyles(),e.styleSubtree(t,n)},styleElement(t){e.flushCustomStyles(),e.styleElement(t)},styleDocument(t){e.flushCustomStyles(),e.styleDocument(t)},getComputedStyleValue:(e,t)=>getComputedStyleValue(e,t),flushCustomStyles(){e.flushCustomStyles()},nativeCss:nativeCssVariables,nativeShadow:nativeShadow,cssBuild:cssBuild,disableRuntime:disableRuntime},t&&(window.ShadyCSS.CustomStyleInterface=t)}window.ShadyCSS.ApplyShim=applyShim;
/**
    @license
    Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
    The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
    The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
    Code distributed by Google as part of the polymer project is also
    subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
    */
class Debouncer{constructor(){this._asyncModule=null,this._callback=null,this._timer=null}setConfig(e,t){this._asyncModule=e,this._callback=t,this._timer=this._asyncModule.run((()=>{this._timer=null,debouncerQueue.delete(this),this._callback()}))}cancel(){this.isActive()&&(this._cancelAsync(),debouncerQueue.delete(this))}_cancelAsync(){this.isActive()&&(this._asyncModule.cancel(this._timer),this._timer=null)}flush(){this.isActive()&&(this.cancel(),this._callback())}isActive(){return null!=this._timer}static debounce(e,t,n){return e instanceof Debouncer?e._cancelAsync():e=new Debouncer,e.setConfig(t,n),e}}let debouncerQueue=new Set;const enqueueDebouncer=function(e){debouncerQueue.add(e)},flushDebouncers=function(){const e=Boolean(debouncerQueue.size);return debouncerQueue.forEach((e=>{try{e.flush()}catch(e){setTimeout((()=>{throw e}))}})),e};
/**
    @license
    Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
    The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
    The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
    Code distributed by Google as part of the polymer project is also
    subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
    */
let HAS_NATIVE_TA="string"==typeof document.head.style.touchAction,GESTURE_KEY="__polymerGestures",HANDLED_OBJ="__polymerGesturesHandled",TOUCH_ACTION="__polymerGesturesTouchAction",TAP_DISTANCE=25,TRACK_DISTANCE=5,TRACK_LENGTH=2,MOUSE_TIMEOUT=2500,MOUSE_EVENTS=["mousedown","mousemove","mouseup","click"],MOUSE_WHICH_TO_BUTTONS=[0,1,4,2],MOUSE_HAS_BUTTONS=(function(){try{return 1===new MouseEvent("test",{buttons:1}).buttons}catch(e){return!1}})();function isMouseEvent(e){return MOUSE_EVENTS.indexOf(e)>-1}let supportsPassive=!1;function PASSIVE_TOUCH(e){if(!isMouseEvent(e)&&"touchend"!==e)return HAS_NATIVE_TA&&supportsPassive&&passiveTouchGestures?{passive:!0}:void 0}!(function(){try{let e=Object.defineProperty({},"passive",{get(){supportsPassive=!0}});window.addEventListener("test",null,e),window.removeEventListener("test",null,e)}catch(e){}})();let IS_TOUCH_ONLY=navigator.userAgent.match(/iP(?:[oa]d|hone)|Android/);const clickedLabels=[],labellable={button:!0,input:!0,keygen:!0,meter:!0,output:!0,textarea:!0,progress:!0,select:!0},canBeDisabled={button:!0,command:!0,fieldset:!0,input:!0,keygen:!0,optgroup:!0,option:!0,select:!0,textarea:!0};function canBeLabelled(e){return labellable[e.localName]||!1}function matchingLabels(e){let t=Array.prototype.slice.call(e.labels||[]);if(!t.length){t=[];let n=e.getRootNode();if(e.id){let r=n.querySelectorAll(`label[for = ${e.id}]`);for(let e=0;e<r.length;e++)t.push(r[e])}}return t}let mouseCanceller=function(e){let t=e.sourceCapabilities;if((!t||t.firesTouchEvents)&&(e[HANDLED_OBJ]={skip:!0},"click"===e.type)){let t=!1,n=getComposedPath(e);for(let e=0;e<n.length;e++){if(n[e].nodeType===Node.ELEMENT_NODE)if("label"===n[e].localName)clickedLabels.push(n[e]);else if(canBeLabelled(n[e])){let r=matchingLabels(n[e]);for(let e=0;e<r.length;e++)t=t||clickedLabels.indexOf(r[e])>-1}if(n[e]===POINTERSTATE.mouse.target)return}if(t)return;e.preventDefault(),e.stopPropagation()}};function setupTeardownMouseCanceller(e){let t=IS_TOUCH_ONLY?["click"]:MOUSE_EVENTS;for(let n,r=0;r<t.length;r++)n=t[r],e?(clickedLabels.length=0,document.addEventListener(n,mouseCanceller,!0)):document.removeEventListener(n,mouseCanceller,!0)}function ignoreMouse(e){POINTERSTATE.mouse.mouseIgnoreJob||setupTeardownMouseCanceller(!0);POINTERSTATE.mouse.target=getComposedPath(e)[0],POINTERSTATE.mouse.mouseIgnoreJob=Debouncer.debounce(POINTERSTATE.mouse.mouseIgnoreJob,timeOut.after(MOUSE_TIMEOUT),(function(){setupTeardownMouseCanceller(),POINTERSTATE.mouse.target=null,POINTERSTATE.mouse.mouseIgnoreJob=null}))}function hasLeftMouseButton(e){let t=e.type;if(!isMouseEvent(t))return!1;if("mousemove"===t){let t=void 0===e.buttons?1:e.buttons;return e instanceof window.MouseEvent&&!MOUSE_HAS_BUTTONS&&(t=MOUSE_WHICH_TO_BUTTONS[e.which]||0),Boolean(1&t)}return 0===(void 0===e.button?0:e.button)}function isSyntheticClick(e){if("click"===e.type){if(0===e.detail)return!0;let t=_findOriginalTarget(e);if(!t.nodeType||t.nodeType!==Node.ELEMENT_NODE)return!0;let n=t.getBoundingClientRect(),r=e.pageX,i=e.pageY;return!(r>=n.left&&r<=n.right&&i>=n.top&&i<=n.bottom)}return!1}let POINTERSTATE={mouse:{target:null,mouseIgnoreJob:null},touch:{x:0,y:0,id:-1,scrollDecided:!1}};function firstTouchAction(e){let t="auto",n=getComposedPath(e);for(let e,r=0;r<n.length;r++)if(e=n[r],e[TOUCH_ACTION]){t=e[TOUCH_ACTION];break}return t}function trackDocument(e,t,n){e.movefn=t,e.upfn=n,document.addEventListener("mousemove",t),document.addEventListener("mouseup",n)}function untrackDocument(e){document.removeEventListener("mousemove",e.movefn),document.removeEventListener("mouseup",e.upfn),e.movefn=null,e.upfn=null}document.addEventListener("touchend",ignoreMouse,!!supportsPassive&&{passive:!0});const getComposedPath=window.ShadyDOM&&window.ShadyDOM.noPatch?window.ShadyDOM.composedPath:e=>e.composedPath&&e.composedPath()||[],gestures={},recognizers=[];function deepTargetFind(e,t){let n=document.elementFromPoint(e,t),r=n;for(;r&&r.shadowRoot&&!window.ShadyDOM;){let i=r;if(r=r.shadowRoot.elementFromPoint(e,t),i===r)break;r&&(n=r)}return n}function _findOriginalTarget(e){const t=getComposedPath(e);return t.length>0?t[0]:e.target}function _handleNative(e){let t,n=e.type,r=e.currentTarget[GESTURE_KEY];if(!r)return;let i=r[n];if(i){if(!e[HANDLED_OBJ]&&(e[HANDLED_OBJ]={},"touch"===n.slice(0,5))){let t=(e=e).changedTouches[0];if("touchstart"===n&&1===e.touches.length&&(POINTERSTATE.touch.id=t.identifier),POINTERSTATE.touch.id!==t.identifier)return;HAS_NATIVE_TA||"touchstart"!==n&&"touchmove"!==n||_handleTouchAction(e)}if(t=e[HANDLED_OBJ],!t.skip){for(let n,r=0;r<recognizers.length;r++)n=recognizers[r],i[n.name]&&!t[n.name]&&n.flow&&n.flow.start.indexOf(e.type)>-1&&n.reset&&n.reset();for(let r,a=0;a<recognizers.length;a++)r=recognizers[a],i[r.name]&&!t[r.name]&&(t[r.name]=!0,r[n](e))}}}function _handleTouchAction(e){let t=e.changedTouches[0],n=e.type;if("touchstart"===n)POINTERSTATE.touch.x=t.clientX,POINTERSTATE.touch.y=t.clientY,POINTERSTATE.touch.scrollDecided=!1;else if("touchmove"===n){if(POINTERSTATE.touch.scrollDecided)return;POINTERSTATE.touch.scrollDecided=!0;let n=firstTouchAction(e),r=!1,i=Math.abs(POINTERSTATE.touch.x-t.clientX),a=Math.abs(POINTERSTATE.touch.y-t.clientY);e.cancelable&&("none"===n?r=!0:"pan-x"===n?r=a>i:"pan-y"===n&&(r=i>a)),r?e.preventDefault():prevent("track")}}function addListener(e,t,n){return!!gestures[t]&&(_add(e,t,n),!0)}function removeListener(e,t,n){return!!gestures[t]&&(_remove(e,t,n),!0)}function _add(e,t,n){let r=gestures[t],i=r.deps,a=r.name,o=e[GESTURE_KEY];o||(e[GESTURE_KEY]=o={});for(let t,n,r=0;r<i.length;r++)t=i[r],IS_TOUCH_ONLY&&isMouseEvent(t)&&"click"!==t||(n=o[t],n||(o[t]=n={_count:0}),0===n._count&&e.addEventListener(t,_handleNative,PASSIVE_TOUCH(t)),n[a]=(n[a]||0)+1,n._count=(n._count||0)+1);e.addEventListener(t,n),r.touchAction&&setTouchAction(e,r.touchAction)}function _remove(e,t,n){let r=gestures[t],i=r.deps,a=r.name,o=e[GESTURE_KEY];if(o)for(let t,n,r=0;r<i.length;r++)t=i[r],n=o[t],n&&n[a]&&(n[a]=(n[a]||1)-1,n._count=(n._count||1)-1,0===n._count&&e.removeEventListener(t,_handleNative,PASSIVE_TOUCH(t)));e.removeEventListener(t,n)}function register(e){recognizers.push(e);for(let t=0;t<e.emits.length;t++)gestures[e.emits[t]]=e}function _findRecognizerByEvent(e){for(let t,n=0;n<recognizers.length;n++){t=recognizers[n];for(let n,r=0;r<t.emits.length;r++)if(n=t.emits[r],n===e)return t}return null}function setTouchAction(e,t){HAS_NATIVE_TA&&e instanceof HTMLElement&&microTask.run((()=>{e.style.touchAction=t})),e[TOUCH_ACTION]=t}function _fire(e,t,n){let r=new Event(t,{bubbles:!0,cancelable:!0,composed:!0});if(r.detail=n,wrap(e).dispatchEvent(r),r.defaultPrevented){let e=n.preventer||n.sourceEvent;e&&e.preventDefault&&e.preventDefault()}}function prevent(e){let t=_findRecognizerByEvent(e);t.info&&(t.info.prevent=!0)}function downupFire(e,t,n,r){t&&_fire(t,e,{x:n.clientX,y:n.clientY,sourceEvent:n,preventer:r,prevent:function(e){return prevent(e)}})}function trackHasMovedEnough(e,t,n){if(e.prevent)return!1;if(e.started)return!0;let r=Math.abs(e.x-t),i=Math.abs(e.y-n);return r>=TRACK_DISTANCE||i>=TRACK_DISTANCE}function trackFire(e,t,n){if(!t)return;let r,i=e.moves[e.moves.length-2],a=e.moves[e.moves.length-1],o=0;i&&(r=a.x-i.x,o=a.y-i.y),_fire(t,"track",{state:e.state,x:n.clientX,y:n.clientY,dx:a.x-e.x,dy:a.y-e.y,ddx:r,ddy:o,sourceEvent:n,hover:function(){return deepTargetFind(n.clientX,n.clientY)}})}function trackForward(e,t,n){let r=Math.abs(t.clientX-e.x),i=Math.abs(t.clientY-e.y),a=_findOriginalTarget(n||t);!a||canBeDisabled[a.localName]&&a.hasAttribute("disabled")||(isNaN(r)||isNaN(i)||r<=TAP_DISTANCE&&i<=TAP_DISTANCE||isSyntheticClick(t))&&(e.prevent||_fire(a,"tap",{x:t.clientX,y:t.clientY,sourceEvent:t,preventer:n}))}register({name:"downup",deps:["mousedown","touchstart","touchend"],flow:{start:["mousedown","touchstart"],end:["mouseup","touchend"]},emits:["down","up"],info:{movefn:null,upfn:null},reset:function(){untrackDocument(this.info)},mousedown:function(e){if(!hasLeftMouseButton(e))return;let t=_findOriginalTarget(e),n=this;trackDocument(this.info,(function e(r){hasLeftMouseButton(r)||(downupFire("up",t,r),untrackDocument(n.info))}),(function e(r){hasLeftMouseButton(r)&&downupFire("up",t,r),untrackDocument(n.info)})),downupFire("down",t,e)},touchstart:function(e){downupFire("down",_findOriginalTarget(e),e.changedTouches[0],e)},touchend:function(e){downupFire("up",_findOriginalTarget(e),e.changedTouches[0],e)}}),register({name:"track",touchAction:"none",deps:["mousedown","touchstart","touchmove","touchend"],flow:{start:["mousedown","touchstart"],end:["mouseup","touchend"]},emits:["track"],info:{x:0,y:0,state:"start",started:!1,moves:[],addMove:function(e){this.moves.length>TRACK_LENGTH&&this.moves.shift(),this.moves.push(e)},movefn:null,upfn:null,prevent:!1},reset:function(){this.info.state="start",this.info.started=!1,this.info.moves=[],this.info.x=0,this.info.y=0,this.info.prevent=!1,untrackDocument(this.info)},mousedown:function(e){if(!hasLeftMouseButton(e))return;let t=_findOriginalTarget(e),n=this,r=function e(r){let i=r.clientX,a=r.clientY;trackHasMovedEnough(n.info,i,a)&&(n.info.state=n.info.started?"mouseup"===r.type?"end":"track":"start","start"===n.info.state&&prevent("tap"),n.info.addMove({x:i,y:a}),hasLeftMouseButton(r)||(n.info.state="end",untrackDocument(n.info)),t&&trackFire(n.info,t,r),n.info.started=!0)};trackDocument(this.info,r,(function e(t){n.info.started&&r(t),untrackDocument(n.info)})),this.info.x=e.clientX,this.info.y=e.clientY},touchstart:function(e){let t=e.changedTouches[0];this.info.x=t.clientX,this.info.y=t.clientY},touchmove:function(e){let t=_findOriginalTarget(e),n=e.changedTouches[0],r=n.clientX,i=n.clientY;trackHasMovedEnough(this.info,r,i)&&("start"===this.info.state&&prevent("tap"),this.info.addMove({x:r,y:i}),trackFire(this.info,t,n),this.info.state="track",this.info.started=!0)},touchend:function(e){let t=_findOriginalTarget(e),n=e.changedTouches[0];this.info.started&&(this.info.state="end",this.info.addMove({x:n.clientX,y:n.clientY}),trackFire(this.info,t,n))}}),register({name:"tap",deps:["mousedown","click","touchstart","touchend"],flow:{start:["mousedown","touchstart"],end:["click","touchend"]},emits:["tap"],info:{x:NaN,y:NaN,prevent:!1},reset:function(){this.info.x=NaN,this.info.y=NaN,this.info.prevent=!1},mousedown:function(e){hasLeftMouseButton(e)&&(this.info.x=e.clientX,this.info.y=e.clientY)},click:function(e){hasLeftMouseButton(e)&&trackForward(this.info,e)},touchstart:function(e){const t=e.changedTouches[0];this.info.x=t.clientX,this.info.y=t.clientY},touchend:function(e){trackForward(this.info,e.changedTouches[0],e)}});const findOriginalTarget=_findOriginalTarget,GestureEventListeners=dedupingMixin((e=>class extends e{_addEventListenerToNode(e,t,n){addListener(e,t,n)||super._addEventListenerToNode(e,t,n)}_removeEventListenerFromNode(e,t,n){removeListener(e,t,n)||super._removeEventListenerFromNode(e,t,n)}})),HOST_DIR=/:host\(:dir\((ltr|rtl)\)\)/g,HOST_DIR_REPLACMENT=':host([dir="$1"])',EL_DIR=/([\s\w-#\.\[\]\*]*):dir\((ltr|rtl)\)/g,EL_DIR_REPLACMENT=':host([dir="$2"]) $1',DIR_CHECK=/:dir\((?:ltr|rtl)\)/,SHIM_SHADOW=Boolean(window.ShadyDOM&&window.ShadyDOM.inUse),DIR_INSTANCES=[];
/**
    @license
    Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
    The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
    The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
    Code distributed by Google as part of the polymer project is also
    subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
    */let observer=null,documentDir="";function getRTL(){documentDir=document.documentElement.getAttribute("dir")}function setRTL(e){if(!e.__autoDirOptOut){e.setAttribute("dir",documentDir)}}function updateDirection(){getRTL(),documentDir=document.documentElement.getAttribute("dir");for(let e=0;e<DIR_INSTANCES.length;e++)setRTL(DIR_INSTANCES[e])}function takeRecords(){observer&&observer.takeRecords().length&&updateDirection()}const DirMixin=dedupingMixin((e=>{SHIM_SHADOW||observer||(getRTL(),observer=new MutationObserver(updateDirection),observer.observe(document.documentElement,{attributes:!0,attributeFilter:["dir"]}));const t=PropertyAccessors(e);class n extends t{static _processStyleText(e,n){return e=t._processStyleText.call(this,e,n),!SHIM_SHADOW&&DIR_CHECK.test(e)&&(e=this._replaceDirInCssText(e),this.__activateDir=!0),e}static _replaceDirInCssText(e){let t=e;return t=t.replace(HOST_DIR,HOST_DIR_REPLACMENT),t=t.replace(EL_DIR,EL_DIR_REPLACMENT),t}constructor(){super(),this.__autoDirOptOut=!1}ready(){super.ready(),this.__autoDirOptOut=this.hasAttribute("dir")}connectedCallback(){t.prototype.connectedCallback&&super.connectedCallback(),this.constructor.__activateDir&&(takeRecords(),DIR_INSTANCES.push(this),setRTL(this))}disconnectedCallback(){if(t.prototype.disconnectedCallback&&super.disconnectedCallback(),this.constructor.__activateDir){const e=DIR_INSTANCES.indexOf(this);e>-1&&DIR_INSTANCES.splice(e,1)}}}return n.__activateDir=!1,n}));
/**
    @license
    Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
    The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
    The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
    Code distributed by Google as part of the polymer project is also
    subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
    */let scheduled=!1,beforeRenderQueue=[],afterRenderQueue=[];function schedule(){scheduled=!0,requestAnimationFrame((function(){scheduled=!1,flushQueue(beforeRenderQueue),setTimeout((function(){runQueue(afterRenderQueue)}))}))}function flushQueue(e){for(;e.length;)callMethod(e.shift())}function runQueue(e){for(let t=0,n=e.length;t<n;t++)callMethod(e.shift())}function callMethod(e){const t=e[0],n=e[1],r=e[2];try{n.apply(t,r)}catch(e){setTimeout((()=>{throw e}))}}function afterNextRender(e,t,n){scheduled||schedule(),afterRenderQueue.push([e,t,n])}
/**
    @license
    Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
    The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
    The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
    Code distributed by Google as part of the polymer project is also
    subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
    */function resolve(){document.body.removeAttribute("unresolved")}
/**
    @license
    Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
    The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
    The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
    Code distributed by Google as part of the polymer project is also
    subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
    */
function newSplice(e,t,n){return{index:e,removed:t,addedCount:n}}"interactive"===document.readyState||"complete"===document.readyState?resolve():window.addEventListener("DOMContentLoaded",resolve);const EDIT_LEAVE=0,EDIT_UPDATE=1,EDIT_ADD=2,EDIT_DELETE=3;function calcEditDistances(e,t,n,r,i,a){let o=a-i+1,s=n-t+1,l=new Array(o);for(let e=0;e<o;e++)l[e]=new Array(s),l[e][0]=e;for(let e=0;e<s;e++)l[0][e]=e;for(let n=1;n<o;n++)for(let a=1;a<s;a++)if(equals$1(e[t+a-1],r[i+n-1]))l[n][a]=l[n-1][a-1];else{let e=l[n-1][a]+1,t=l[n][a-1]+1;l[n][a]=e<t?e:t}return l}function spliceOperationsFromEditDistances(e){let t=e.length-1,n=e[0].length-1,r=e[t][n],i=[];for(;t>0||n>0;){if(0==t){i.push(EDIT_ADD),n--;continue}if(0==n){i.push(EDIT_DELETE),t--;continue}let a,o=e[t-1][n-1],s=e[t-1][n],l=e[t][n-1];a=s<l?s<o?s:o:l<o?l:o,a==o?(o==r?i.push(EDIT_LEAVE):(i.push(EDIT_UPDATE),r=o),t--,n--):a==s?(i.push(EDIT_DELETE),t--,r=s):(i.push(EDIT_ADD),n--,r=l)}return i.reverse(),i}function calcSplices(e,t,n,r,i,a){let o,s=0,l=0,c=Math.min(n-t,a-i);if(0==t&&0==i&&(s=sharedPrefix(e,r,c)),n==e.length&&a==r.length&&(l=sharedSuffix(e,r,c-s)),i+=s,a-=l,(n-=l)-(t+=s)==0&&a-i==0)return[];if(t==n){for(o=newSplice(t,[],0);i<a;)o.removed.push(r[i++]);return[o]}if(i==a)return[newSplice(t,[],n-t)];let h=spliceOperationsFromEditDistances(calcEditDistances(e,t,n,r,i,a));o=void 0;let u=[],d=t,p=i;for(let e=0;e<h.length;e++)switch(h[e]){case EDIT_LEAVE:o&&(u.push(o),o=void 0),d++,p++;break;case EDIT_UPDATE:o||(o=newSplice(d,[],0)),o.addedCount++,d++,o.removed.push(r[p]),p++;break;case EDIT_ADD:o||(o=newSplice(d,[],0)),o.addedCount++,d++;break;case EDIT_DELETE:o||(o=newSplice(d,[],0)),o.removed.push(r[p]),p++}return o&&u.push(o),u}function sharedPrefix(e,t,n){for(let r=0;r<n;r++)if(!equals$1(e[r],t[r]))return r;return n}function sharedSuffix(e,t,n){let r=e.length,i=t.length,a=0;for(;a<n&&equals$1(e[--r],t[--i]);)a++;return a}function calculateSplices(e,t){return calcSplices(e,0,e.length,t,0,t.length)}function equals$1(e,t){return e===t}
/**
    @license
    Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
    The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
    The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
    Code distributed by Google as part of the polymer project is also
    subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
    */function isSlot(e){return"slot"===e.localName}let FlattenedNodesObserver=class{static getFlattenedNodes(e){const t=wrap(e);return isSlot(e)?(e=e,t.assignedNodes({flatten:!0})):Array.from(t.childNodes).map((e=>isSlot(e)?wrap(e=e).assignedNodes({flatten:!0}):[e])).reduce(((e,t)=>e.concat(t)),[])}constructor(e,t){this._shadyChildrenObserver=null,this._nativeChildrenObserver=null,this._connected=!1,this._target=e,this.callback=t,this._effectiveNodes=[],this._observer=null,this._scheduled=!1,this._boundSchedule=()=>{this._schedule()},this.connect(),this._schedule()}connect(){isSlot(this._target)?this._listenSlots([this._target]):wrap(this._target).children&&(this._listenSlots(wrap(this._target).children),window.ShadyDOM?this._shadyChildrenObserver=window.ShadyDOM.observeChildren(this._target,(e=>{this._processMutations(e)})):(this._nativeChildrenObserver=new MutationObserver((e=>{this._processMutations(e)})),this._nativeChildrenObserver.observe(this._target,{childList:!0}))),this._connected=!0}disconnect(){isSlot(this._target)?this._unlistenSlots([this._target]):wrap(this._target).children&&(this._unlistenSlots(wrap(this._target).children),window.ShadyDOM&&this._shadyChildrenObserver?(window.ShadyDOM.unobserveChildren(this._shadyChildrenObserver),this._shadyChildrenObserver=null):this._nativeChildrenObserver&&(this._nativeChildrenObserver.disconnect(),this._nativeChildrenObserver=null)),this._connected=!1}_schedule(){this._scheduled||(this._scheduled=!0,microTask.run((()=>this.flush())))}_processMutations(e){this._processSlotMutations(e),this.flush()}_processSlotMutations(e){if(e)for(let t=0;t<e.length;t++){let n=e[t];n.addedNodes&&this._listenSlots(n.addedNodes),n.removedNodes&&this._unlistenSlots(n.removedNodes)}}flush(){if(!this._connected)return!1;window.ShadyDOM&&ShadyDOM.flush(),this._nativeChildrenObserver?this._processSlotMutations(this._nativeChildrenObserver.takeRecords()):this._shadyChildrenObserver&&this._processSlotMutations(this._shadyChildrenObserver.takeRecords()),this._scheduled=!1;let e={target:this._target,addedNodes:[],removedNodes:[]},t=this.constructor.getFlattenedNodes(this._target),n=calculateSplices(t,this._effectiveNodes);for(let t,r=0;r<n.length&&(t=n[r]);r++)for(let n,r=0;r<t.removed.length&&(n=t.removed[r]);r++)e.removedNodes.push(n);for(let r,i=0;i<n.length&&(r=n[i]);i++)for(let n=r.index;n<r.index+r.addedCount;n++)e.addedNodes.push(t[n]);this._effectiveNodes=t;let r=!1;return(e.addedNodes.length||e.removedNodes.length)&&(r=!0,this.callback.call(this._target,e)),r}_listenSlots(e){for(let t=0;t<e.length;t++){let n=e[t];isSlot(n)&&n.addEventListener("slotchange",this._boundSchedule)}}_unlistenSlots(e){for(let t=0;t<e.length;t++){let n=e[t];isSlot(n)&&n.removeEventListener("slotchange",this._boundSchedule)}}};
/**
    @license
    Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
    The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
    The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
    Code distributed by Google as part of the polymer project is also
    subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
    */const flush=function(){let e,t;do{e=window.ShadyDOM&&ShadyDOM.flush(),window.ShadyCSS&&window.ShadyCSS.ScopingShim&&window.ShadyCSS.ScopingShim.flush(),t=flushDebouncers()}while(e||t)},p$2=Element.prototype,normalizedMatchesSelector=p$2.matches||p$2.matchesSelector||p$2.mozMatchesSelector||p$2.msMatchesSelector||p$2.oMatchesSelector||p$2.webkitMatchesSelector,matchesSelector=function(e,t){return normalizedMatchesSelector.call(e,t)};
/**
    @license
    Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
    The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
    The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
    Code distributed by Google as part of the polymer project is also
    subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
    */class DomApiNative{constructor(e){window.ShadyDOM&&window.ShadyDOM.inUse&&window.ShadyDOM.patch(e),this.node=e}observeNodes(e){return new FlattenedNodesObserver(this.node,e)}unobserveNodes(e){e.disconnect()}notifyObserver(){}deepContains(e){if(wrap(this.node).contains(e))return!0;let t=e,n=e.ownerDocument;for(;t&&t!==n&&t!==this.node;)t=wrap(t).parentNode||wrap(t).host;return t===this.node}getOwnerRoot(){return wrap(this.node).getRootNode()}getDistributedNodes(){return"slot"===this.node.localName?wrap(this.node).assignedNodes({flatten:!0}):[]}getDestinationInsertionPoints(){let e=[],t=wrap(this.node).assignedSlot;for(;t;)e.push(t),t=wrap(t).assignedSlot;return e}importNode(e,t){let n=this.node instanceof Document?this.node:this.node.ownerDocument;return wrap(n).importNode(e,t)}getEffectiveChildNodes(){return FlattenedNodesObserver.getFlattenedNodes(this.node)}queryDistributedElements(e){let t=this.getEffectiveChildNodes(),n=[];for(let r,i=0,a=t.length;i<a&&(r=t[i]);i++)r.nodeType===Node.ELEMENT_NODE&&matchesSelector(r,e)&&n.push(r);return n}get activeElement(){let e=this.node;return void 0!==e._activeElement?e._activeElement:e.activeElement}}function forwardMethods(e,t){for(let n=0;n<t.length;n++){let r=t[n];e[r]=function(){return this.node[r].apply(this.node,arguments)}}}function forwardReadOnlyProperties(e,t){for(let n=0;n<t.length;n++){let r=t[n];Object.defineProperty(e,r,{get:function(){return this.node[r]},configurable:!0})}}function forwardProperties(e,t){for(let n=0;n<t.length;n++){let r=t[n];Object.defineProperty(e,r,{get:function(){return this.node[r]},set:function(e){this.node[r]=e},configurable:!0})}}class EventApi{constructor(e){this.event=e}get rootTarget(){return this.path[0]}get localTarget(){return this.event.target}get path(){return this.event.composedPath()}}let DomApiImpl=DomApiNative;if(window.ShadyDOM&&window.ShadyDOM.inUse&&window.ShadyDOM.noPatch&&window.ShadyDOM.Wrapper){class e extends window.ShadyDOM.Wrapper{}Object.getOwnPropertyNames(DomApiNative.prototype).forEach((t=>{"activeElement"!=t&&(e.prototype[t]=DomApiNative.prototype[t])})),forwardReadOnlyProperties(e.prototype,["classList"]),DomApiImpl=e,Object.defineProperties(EventApi.prototype,{localTarget:{get(){const e=this.event.currentTarget,t=e&&dom$1(e).getOwnerRoot(),n=this.path;for(let e=0;e<n.length;e++){const r=n[e];if(dom$1(r).getOwnerRoot()===t)return r}},configurable:!0},path:{get(){return window.ShadyDOM.composedPath(this.event)},configurable:!0}})}else forwardMethods(DomApiNative.prototype,["cloneNode","appendChild","insertBefore","removeChild","replaceChild","setAttribute","removeAttribute","querySelector","querySelectorAll"]),forwardReadOnlyProperties(DomApiNative.prototype,["parentNode","firstChild","lastChild","nextSibling","previousSibling","firstElementChild","lastElementChild","nextElementSibling","previousElementSibling","childNodes","children","classList"]),forwardProperties(DomApiNative.prototype,["textContent","innerHTML","className"]);const dom$1=function(e){if((e=e||document)instanceof DomApiImpl)return e;if(e instanceof EventApi)return e;let t=e.__domApi;return t||(t=e instanceof Event?new EventApi(e):new DomApiImpl(e),e.__domApi=t),t},ShadyDOM$1=window.ShadyDOM,ShadyCSS=window.ShadyCSS;
/**
    @license
    Copyright (c) 2019 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
    The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
    The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
    Code distributed by Google as part of the polymer project is also
    subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
    */function sameScope(e,t){return wrap(e).getRootNode()===t}function scopeSubtree(e,t=!1){if(!ShadyDOM$1||!ShadyCSS)return null;if(!ShadyDOM$1.handlesDynamicScoping)return null;const n=ShadyCSS.ScopingShim;if(!n)return null;const r=n.scopeForNode(e),i=wrap(e).getRootNode(),a=e=>{if(!sameScope(e,i))return;const t=Array.from(ShadyDOM$1.nativeMethods.querySelectorAll.call(e,"*"));t.push(e);for(let e=0;e<t.length;e++){const a=t[e];if(!sameScope(a,i))continue;const o=n.currentScopeForNode(a);o!==r&&(""!==o&&n.unscopeNode(a,o),n.scopeNode(a,r))}};if(a(e),t){const t=new MutationObserver((e=>{for(let t=0;t<e.length;t++){const n=e[t];for(let e=0;e<n.addedNodes.length;e++){const t=n.addedNodes[e];t.nodeType===Node.ELEMENT_NODE&&a(t)}}}));return t.observe(e,{childList:!0,subtree:!0}),t}return null}
/**
     * @fileoverview
     * @suppress {checkPrototypalTypes}
     * @license Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
     * This code may only be used under the BSD style license found at
     * http://polymer.github.io/LICENSE.txt The complete set of authors may be found
     * at http://polymer.github.io/AUTHORS.txt The complete set of contributors may
     * be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by
     * Google as part of the polymer project is also subject to an additional IP
     * rights grant found at http://polymer.github.io/PATENTS.txt
     */const DISABLED_ATTR$1="disable-upgrade",findObservedAttributesGetter=e=>{for(;e;){const t=Object.getOwnPropertyDescriptor(e,"observedAttributes");if(t)return t.get;e=Object.getPrototypeOf(e.prototype).constructor}return()=>[]};dedupingMixin((e=>{const t=ElementMixin(e);let n=findObservedAttributesGetter(t);return class extends t{constructor(){super()}static get observedAttributes(){return n.call(this).concat(DISABLED_ATTR$1)}_initializeProperties(){this.hasAttribute(DISABLED_ATTR$1)?this.__isUpgradeDisabled=!0:super._initializeProperties()}_enableProperties(){this.__isUpgradeDisabled||super._enableProperties()}_canApplyPropertyDefault(e){return super._canApplyPropertyDefault(e)&&!(this.__isUpgradeDisabled&&this._isPropertyPending(e))}attributeChangedCallback(e,t,n,r){e==DISABLED_ATTR$1?this.__isUpgradeDisabled&&null==n&&(super._initializeProperties(),this.__isUpgradeDisabled=!1,wrap(this).isConnected&&super.connectedCallback()):super.attributeChangedCallback(e,t,n,r)}connectedCallback(){this.__isUpgradeDisabled||super.connectedCallback()}disconnectedCallback(){this.__isUpgradeDisabled||super.disconnectedCallback()}}}));
/**
    @license
    Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
    The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
    The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
    Code distributed by Google as part of the polymer project is also
    subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
    */
const DISABLED_ATTR="disable-upgrade";let styleInterface=window.ShadyCSS;const LegacyElementMixin=dedupingMixin((e=>{const t=GestureEventListeners(ElementMixin(e)),n=builtCSS?t:DirMixin(t),r=findObservedAttributesGetter(n),i={x:"pan-x",y:"pan-y",none:"none",all:"auto"};class a extends n{constructor(){super()}static get importMeta(){return this.prototype.importMeta}created(){}__attributeReaction(e,t,n){(this.__dataAttributes&&this.__dataAttributes[e]||e===DISABLED_ATTR)&&this.attributeChangedCallback(e,t,n,null)}setAttribute(e,t){if(legacyNoObservedAttributes&&!this._legacyForceObservedAttributes){const n=this.getAttribute(e);super.setAttribute(e,t),this.__attributeReaction(e,n,String(t))}else super.setAttribute(e,t)}removeAttribute(e){if(legacyNoObservedAttributes&&!this._legacyForceObservedAttributes){const t=this.getAttribute(e);super.removeAttribute(e),this.__attributeReaction(e,t,null)}else super.removeAttribute(e)}static get observedAttributes(){return legacyNoObservedAttributes&&!this.prototype._legacyForceObservedAttributes?(this.hasOwnProperty(JSCompiler_renameProperty("__observedAttributes",this))||(this.__observedAttributes=[],register$1(this.prototype)),this.__observedAttributes):r.call(this).concat(DISABLED_ATTR)}_enableProperties(){this.__isUpgradeDisabled||super._enableProperties()}_canApplyPropertyDefault(e){return super._canApplyPropertyDefault(e)&&!(this.__isUpgradeDisabled&&this._isPropertyPending(e))}connectedCallback(){this.__needsAttributesAtConnected&&this._takeAttributes(),this.__isUpgradeDisabled||(super.connectedCallback(),this.isAttached=!0,this.attached())}attached(){}disconnectedCallback(){this.__isUpgradeDisabled||(super.disconnectedCallback(),this.isAttached=!1,this.detached())}detached(){}attributeChangedCallback(e,t,n,r){t!==n&&(e==DISABLED_ATTR?this.__isUpgradeDisabled&&null==n&&(this._initializeProperties(),this.__isUpgradeDisabled=!1,wrap(this).isConnected&&this.connectedCallback()):(super.attributeChangedCallback(e,t,n,r),this.attributeChanged(e,t,n)))}attributeChanged(e,t,n){}_initializeProperties(){if(legacyOptimizations&&this.hasAttribute(DISABLED_ATTR))this.__isUpgradeDisabled=!0;else{let e=Object.getPrototypeOf(this);e.hasOwnProperty(JSCompiler_renameProperty("__hasRegisterFinished",e))||(this._registered(),e.__hasRegisterFinished=!0),super._initializeProperties(),this.root=this,this.created(),legacyNoObservedAttributes&&!this._legacyForceObservedAttributes&&(this.hasAttributes()?this._takeAttributes():this.parentNode||(this.__needsAttributesAtConnected=!0)),this._applyListeners()}}_takeAttributes(){const e=this.attributes;for(let t=0,n=e.length;t<n;t++){const n=e[t];this.__attributeReaction(n.name,null,n.value)}}_registered(){}ready(){this._ensureAttributes(),super.ready()}_ensureAttributes(){}_applyListeners(){}serialize(e){return this._serializeValue(e)}deserialize(e,t){return this._deserializeValue(e,t)}reflectPropertyToAttribute(e,t,n){this._propertyToAttribute(e,t,n)}serializeValueToAttribute(e,t,n){this._valueToNodeAttribute(n||this,e,t)}extend(e,t){if(!e||!t)return e||t;let n=Object.getOwnPropertyNames(t);for(let r,i=0;i<n.length&&(r=n[i]);i++){let n=Object.getOwnPropertyDescriptor(t,r);n&&Object.defineProperty(e,r,n)}return e}mixin(e,t){for(let n in t)e[n]=t[n];return e}chainObject(e,t){return e&&t&&e!==t&&(e.__proto__=t),e}instanceTemplate(e){let t=this.constructor._contentForTemplate(e);return document.importNode(t,!0)}fire(e,t,n){n=n||{},t=null==t?{}:t;let r=new Event(e,{bubbles:void 0===n.bubbles||n.bubbles,cancelable:Boolean(n.cancelable),composed:void 0===n.composed||n.composed});return r.detail=t,wrap(n.node||this).dispatchEvent(r),r}listen(e,t,n){e=e||this;let r=this.__boundListeners||(this.__boundListeners=new WeakMap),i=r.get(e);i||(i={},r.set(e,i));let a=t+n;i[a]||(i[a]=this._addMethodEventListenerToNode(e,t,n,this))}unlisten(e,t,n){e=e||this;let r=this.__boundListeners&&this.__boundListeners.get(e),i=t+n,a=r&&r[i];a&&(this._removeEventListenerFromNode(e,t,a),r[i]=null)}setScrollDirection(e,t){setTouchAction(t||this,i[e]||"auto")}$$(e){return this.root.querySelector(e)}get domHost(){let e=wrap(this).getRootNode();return e instanceof DocumentFragment?e.host:e}distributeContent(){const e=dom$1(this);window.ShadyDOM&&e.shadowRoot&&ShadyDOM.flush()}getEffectiveChildNodes(){return dom$1(this).getEffectiveChildNodes()}queryDistributedElements(e){return dom$1(this).queryDistributedElements(e)}getEffectiveChildren(){return this.getEffectiveChildNodes().filter((function(e){return e.nodeType===Node.ELEMENT_NODE}))}getEffectiveTextContent(){let e=this.getEffectiveChildNodes(),t=[];for(let n,r=0;n=e[r];r++)n.nodeType!==Node.COMMENT_NODE&&t.push(n.textContent);return t.join("")}queryEffectiveChildren(e){let t=this.queryDistributedElements(e);return t&&t[0]}queryAllEffectiveChildren(e){return this.queryDistributedElements(e)}getContentChildNodes(e){let t=this.root.querySelector(e||"slot");return t?dom$1(t).getDistributedNodes():[]}getContentChildren(e){return this.getContentChildNodes(e).filter((function(e){return e.nodeType===Node.ELEMENT_NODE}))}isLightDescendant(e){const t=this;return t!==e&&wrap(t).contains(e)&&wrap(t).getRootNode()===wrap(e).getRootNode()}isLocalDescendant(e){return this.root===wrap(e).getRootNode()}scopeSubtree(e,t=!1){return scopeSubtree(e,t)}getComputedStyleValue(e){return styleInterface.getComputedStyleValue(this,e)}debounce(e,t,n){return this._debouncers=this._debouncers||{},this._debouncers[e]=Debouncer.debounce(this._debouncers[e],n>0?timeOut.after(n):microTask,t.bind(this))}isDebouncerActive(e){this._debouncers=this._debouncers||{};let t=this._debouncers[e];return!(!t||!t.isActive())}flushDebouncer(e){this._debouncers=this._debouncers||{};let t=this._debouncers[e];t&&t.flush()}cancelDebouncer(e){this._debouncers=this._debouncers||{};let t=this._debouncers[e];t&&t.cancel()}async(e,t){return t>0?timeOut.run(e.bind(this),t):~microTask.run(e.bind(this))}cancelAsync(e){e<0?microTask.cancel(~e):timeOut.cancel(e)}create(e,t){let n=document.createElement(e);if(t)if(n.setProperties)n.setProperties(t);else for(let e in t)n[e]=t[e];return n}elementMatches(e,t){return matchesSelector(t||this,e)}toggleAttribute(e,t){let n=this;return 3===arguments.length&&(n=arguments[2]),1==arguments.length&&(t=!n.hasAttribute(e)),t?(wrap(n).setAttribute(e,""),!0):(wrap(n).removeAttribute(e),!1)}toggleClass(e,t,n){n=n||this,1==arguments.length&&(t=!n.classList.contains(e)),t?n.classList.add(e):n.classList.remove(e)}transform(e,t){(t=t||this).style.webkitTransform=e,t.style.transform=e}translate3d(e,t,n,r){this.transform("translate3d("+e+","+t+","+n+")",r=r||this)}arrayDelete(e,t){let n;if(Array.isArray(e)){if(n=e.indexOf(t),n>=0)return e.splice(n,1)}else{if(n=get$1(this,e).indexOf(t),n>=0)return this.splice(e,n,1)}return null}_logger(e,t){switch(Array.isArray(t)&&1===t.length&&Array.isArray(t[0])&&(t=t[0]),e){case"log":case"warn":case"error":console[e](...t)}}_log(...e){this._logger("log",e)}_warn(...e){this._logger("warn",e)}_error(...e){this._logger("error",e)}_logf(e,...t){return["[%s::%s]",this.is,e,...t]}}return a.prototype.is="",a})),lifecycleProps={attached:!0,detached:!0,ready:!0,created:!0,beforeRegister:!0,registered:!0,attributeChanged:!0,listeners:!0,hostAttributes:!0},excludeOnInfo={attached:!0,detached:!0,ready:!0,created:!0,beforeRegister:!0,registered:!0,attributeChanged:!0,behaviors:!0,_noAccessors:!0},excludeOnBehaviors=Object.assign({listeners:!0,hostAttributes:!0,properties:!0,observers:!0},excludeOnInfo);
/**
    @license
    Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
    The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
    The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
    Code distributed by Google as part of the polymer project is also
    subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
    */function copyProperties(e,t,n){const r=e._noAccessors,i=Object.getOwnPropertyNames(e);for(let a=0;a<i.length;a++){let o=i[a];if(!(o in n))if(r)t[o]=e[o];else{let n=Object.getOwnPropertyDescriptor(e,o);n&&(n.configurable=!0,Object.defineProperty(t,o,n))}}}function applyBehaviors(e,t,n){for(let r=0;r<t.length;r++)applyInfo(e,t[r],n,excludeOnBehaviors)}function applyInfo(e,t,n,r){copyProperties(t,e,r);for(let e in lifecycleProps)t[e]&&(n[e]=n[e]||[],n[e].push(t[e]))}function flattenBehaviors(e,t,n){t=t||[];for(let r=e.length-1;r>=0;r--){let i=e[r];i?Array.isArray(i)?flattenBehaviors(i,t):t.indexOf(i)<0&&(!n||n.indexOf(i)<0)&&t.unshift(i):console.warn("behavior is null, check for missing or 404 import")}return t}function mergeProperties(e,t){for(const n in t){const r=e[n],i=t[n];e[n]=!("value"in i)&&r&&"value"in r?Object.assign({value:r.value},i):i}}const LegacyElement=LegacyElementMixin(HTMLElement);function GenerateClassFromInfo(e,t,n){let r;const i={};class a extends t{static _finalizeClass(){if(this.hasOwnProperty(JSCompiler_renameProperty("generatedFrom",this))){if(r)for(let e,t=0;t<r.length;t++)e=r[t],e.properties&&this.createProperties(e.properties),e.observers&&this.createObservers(e.observers,e.properties);e.properties&&this.createProperties(e.properties),e.observers&&this.createObservers(e.observers,e.properties),this._prepareTemplate()}else t._finalizeClass.call(this)}static get properties(){const t={};if(r)for(let e=0;e<r.length;e++)mergeProperties(t,r[e].properties);return mergeProperties(t,e.properties),t}static get observers(){let t=[];if(r)for(let e,n=0;n<r.length;n++)e=r[n],e.observers&&(t=t.concat(e.observers));return e.observers&&(t=t.concat(e.observers)),t}created(){super.created();const e=i.created;if(e)for(let t=0;t<e.length;t++)e[t].call(this)}_registered(){const e=a.prototype;if(!e.hasOwnProperty(JSCompiler_renameProperty("__hasRegisterFinished",e))){e.__hasRegisterFinished=!0,super._registered(),legacyOptimizations&&o(e);const t=Object.getPrototypeOf(this);let n=i.beforeRegister;if(n)for(let e=0;e<n.length;e++)n[e].call(t);if(n=i.registered,n)for(let e=0;e<n.length;e++)n[e].call(t)}}_applyListeners(){super._applyListeners();const e=i.listeners;if(e)for(let t=0;t<e.length;t++){const n=e[t];if(n)for(let e in n)this._addMethodEventListenerToNode(this,e,n[e])}}_ensureAttributes(){const e=i.hostAttributes;if(e)for(let t=e.length-1;t>=0;t--){const n=e[t];for(let e in n)this._ensureAttribute(e,n[e])}super._ensureAttributes()}ready(){super.ready();let e=i.ready;if(e)for(let t=0;t<e.length;t++)e[t].call(this)}attached(){super.attached();let e=i.attached;if(e)for(let t=0;t<e.length;t++)e[t].call(this)}detached(){super.detached();let e=i.detached;if(e)for(let t=0;t<e.length;t++)e[t].call(this)}attributeChanged(e,t,n){super.attributeChanged();let r=i.attributeChanged;if(r)for(let i=0;i<r.length;i++)r[i].call(this,e,t,n)}}if(n){Array.isArray(n)||(n=[n]);let e=t.prototype.behaviors;r=flattenBehaviors(n,null,e),a.prototype.behaviors=e?e.concat(n):r}const o=t=>{r&&applyBehaviors(t,r,i),applyInfo(t,e,i,excludeOnInfo)};return legacyOptimizations||o(a.prototype),a.generatedFrom=e,a}const Class=function(e,t){e||console.warn("Polymer.Class requires `info` argument");let n=t?t(LegacyElement):LegacyElement;return n=GenerateClassFromInfo(e,n,e.behaviors),n.is=n.prototype.is=e.is,n},Polymer=function(e){let t;return t="function"==typeof e?e:Polymer.Class(e),e._legacyForceObservedAttributes&&(t.prototype._legacyForceObservedAttributes=e._legacyForceObservedAttributes),customElements.define(t.is,t),t};
/**
    @license
    Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
    The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
    The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
    Code distributed by Google as part of the polymer project is also
    subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
    */
/**
    @license
    Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
    The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
    The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
    Code distributed by Google as part of the polymer project is also
    subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
    */
function mutablePropertyChange$1(e,t,n,r,i){let a;i&&(a="object"==typeof n&&null!==n,a&&(r=e.__dataTemp[t]));let o=r!==n&&(r==r||n==n);return a&&o&&(e.__dataTemp[t]=n),o}Polymer.Class=Class;const MutableData=dedupingMixin((e=>class extends e{_shouldPropertyChange(e,t,n){return mutablePropertyChange$1(this,e,t,n,!0)}})),OptionalMutableData=dedupingMixin((e=>class extends e{static get properties(){return{mutableData:Boolean}}_shouldPropertyChange(e,t,n){return mutablePropertyChange$1(this,e,t,n,this.mutableData)}}));MutableData._mutablePropertyChange=mutablePropertyChange$1;
/**
    @license
    Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
    The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
    The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
    Code distributed by Google as part of the polymer project is also
    subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
    */
let newInstance=null;function HTMLTemplateElementExtension(){return newInstance}HTMLTemplateElementExtension.prototype=Object.create(HTMLTemplateElement.prototype,{constructor:{value:HTMLTemplateElementExtension,writable:!0}});const DataTemplate=PropertyEffects(HTMLTemplateElementExtension),MutableDataTemplate=MutableData(DataTemplate);function upgradeTemplate(e,t){newInstance=e,Object.setPrototypeOf(e,t.prototype),new t,newInstance=null}const templateInstanceBase=PropertyEffects(class{});function showHideChildren(e,t){for(let n=0;n<t.length;n++){let r=t[n];if(Boolean(e)!=Boolean(r.__hideTemplateChildren__))if(r.nodeType===Node.TEXT_NODE)e?(r.__polymerTextContent__=r.textContent,r.textContent=""):r.textContent=r.__polymerTextContent__;else if("slot"===r.localName)if(e)r.__polymerReplaced__=document.createComment("hidden-slot"),wrap(wrap(r).parentNode).replaceChild(r.__polymerReplaced__,r);else{const e=r.__polymerReplaced__;e&&wrap(wrap(e).parentNode).replaceChild(r,e)}else r.style&&(e?(r.__polymerDisplay__=r.style.display,r.style.display="none"):r.style.display=r.__polymerDisplay__);r.__hideTemplateChildren__=e,r._showHideChildren&&r._showHideChildren(e)}}class TemplateInstanceBase extends templateInstanceBase{constructor(e){super(),this._configureProperties(e),this.root=this._stampTemplate(this.__dataHost);let t=[];this.children=t;for(let e=this.root.firstChild;e;e=e.nextSibling)t.push(e),e.__templatizeInstance=this;this.__templatizeOwner&&this.__templatizeOwner.__hideTemplateChildren__&&this._showHideChildren(!0);let n=this.__templatizeOptions;(e&&n.instanceProps||!n.instanceProps)&&this._enableProperties()}_configureProperties(e){if(this.__templatizeOptions.forwardHostProp)for(let e in this.__hostProps)this._setPendingProperty(e,this.__dataHost["_host_"+e]);for(let t in e)this._setPendingProperty(t,e[t])}forwardHostProp(e,t){this._setPendingPropertyOrPath(e,t,!1,!0)&&this.__dataHost._enqueueClient(this)}_addEventListenerToNode(e,t,n){if(this._methodHost&&this.__templatizeOptions.parentModel)this._methodHost._addEventListenerToNode(e,t,(e=>{e.model=this,n(e)}));else{let r=this.__dataHost.__dataHost;r&&r._addEventListenerToNode(e,t,n)}}_showHideChildren(e){showHideChildren(e,this.children)}_setUnmanagedPropertyToNode(e,t,n){e.__hideTemplateChildren__&&e.nodeType==Node.TEXT_NODE&&"textContent"==t?e.__polymerTextContent__=n:super._setUnmanagedPropertyToNode(e,t,n)}get parentModel(){let e=this.__parentModel;if(!e){let t;e=this;do{e=e.__dataHost.__dataHost}while((t=e.__templatizeOptions)&&!t.parentModel);this.__parentModel=e}return e}dispatchEvent(e){return!0}}const MutableTemplateInstanceBase=MutableData(TemplateInstanceBase);function findMethodHost(e){let t=e.__dataHost;return t&&t._methodHost||t}function createTemplatizerClass(e,t,n){let r=n.mutableData?MutableTemplateInstanceBase:TemplateInstanceBase;templatize.mixin&&(r=templatize.mixin(r));let i=class extends r{};return i.prototype.__templatizeOptions=n,i.prototype._bindTemplate(e),addNotifyEffects(i,e,t,n),i}function addPropagateEffects(e,t,n,r){let i=n.forwardHostProp;if(i&&t.hasHostProps){const a="template"==e.localName;let o=t.templatizeTemplateClass;if(!o){if(a){let e=n.mutableData?MutableDataTemplate:DataTemplate;class r extends e{}o=t.templatizeTemplateClass=r}else{const n=e.constructor;class r extends n{}o=t.templatizeTemplateClass=r}let s=t.hostProps;for(let e in s)o.prototype._addPropertyEffect("_host_"+e,o.prototype.PROPERTY_EFFECT_TYPES.PROPAGATE,{fn:createForwardHostPropEffect(e,i)}),o.prototype._createNotifyingProperty("_host_"+e);legacyWarnings&&r&&warnOnUndeclaredProperties(t,n,r)}if(e.__dataProto&&Object.assign(e.__data,e.__dataProto),a)upgradeTemplate(e,o),e.__dataTemp={},e.__dataPending=null,e.__dataOld=null,e._enableProperties();else{Object.setPrototypeOf(e,o.prototype);const n=t.hostProps;for(let t in n)if(t="_host_"+t,t in e){const n=e[t];delete e[t],e.__data[t]=n}}}}function createForwardHostPropEffect(e,t){return function e(n,r,i){t.call(n.__templatizeOwner,r.substring("_host_".length),i[r])}}function addNotifyEffects(e,t,n,r){let i=n.hostProps||{};for(let t in r.instanceProps){delete i[t];let n=r.notifyInstanceProp;n&&e.prototype._addPropertyEffect(t,e.prototype.PROPERTY_EFFECT_TYPES.NOTIFY,{fn:createNotifyInstancePropEffect(t,n)})}if(r.forwardHostProp&&t.__dataHost)for(let t in i)n.hasHostProps||(n.hasHostProps=!0),e.prototype._addPropertyEffect(t,e.prototype.PROPERTY_EFFECT_TYPES.NOTIFY,{fn:createNotifyHostPropEffect()})}function createNotifyInstancePropEffect(e,t){return function e(n,r,i){t.call(n.__templatizeOwner,n,r,i[r])}}function createNotifyHostPropEffect(){return function e(t,n,r){t.__dataHost._setPendingPropertyOrPath("_host_"+n,r[n],!0,!0)}}function templatize(e,t,n){if(strictTemplatePolicy&&!findMethodHost(e))throw new Error("strictTemplatePolicy: template owner not trusted");if(n=n||{},e.__templatizeOwner)throw new Error("A <template> can only be templatized once");e.__templatizeOwner=t;let r=(t?t.constructor:TemplateInstanceBase)._parseTemplate(e),i=r.templatizeInstanceClass;i||(i=createTemplatizerClass(e,r,n),r.templatizeInstanceClass=i);const a=findMethodHost(e);addPropagateEffects(e,r,n,a);let o=class extends i{};return o.prototype._methodHost=a,o.prototype.__dataHost=e,o.prototype.__templatizeOwner=t,o.prototype.__hostProps=r.hostProps,o=o,o}function warnOnUndeclaredProperties(e,t,n){const r=n.constructor._properties,{propertyEffects:i}=e,{instanceProps:a}=t;for(let e in i)if(!(r[e]||a&&a[e])){const t=i[e];for(let n=0;n<t.length;n++){const{part:r}=t[n].info;if(!r.signature||!r.signature.static){console.warn(`Property '${e}' used in template but not declared in 'properties'; attribute will not be observed.`);break}}}}function modelForElement(e,t){let n;for(;t;)if(n=t.__dataHost?t:t.__templatizeInstance){if(n.__dataHost==e)return n;t=n.__dataHost}else t=wrap(t).parentNode;return null}
/**
    @license
    Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
    The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
    The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
    Code distributed by Google as part of the polymer project is also
    subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
    */const Templatizer={templatize(e,t){this._templatizerTemplate=e,this.ctor=templatize(e,this,{mutableData:Boolean(t),parentModel:this._parentModel,instanceProps:this._instanceProps,forwardHostProp:this._forwardHostPropV2,notifyInstanceProp:this._notifyInstancePropV2})},stamp(e){return new this.ctor(e)},modelForElement(e){return modelForElement(this._templatizerTemplate,e)}};
/**
    @license
    Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
    The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
    The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
    Code distributed by Google as part of the polymer project is also
    subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
    */let elementsHidden=!1;function hideElementsGlobally(){if(legacyOptimizations&&!useShadow){if(!elementsHidden){elementsHidden=!0;const e=document.createElement("style");e.textContent="dom-bind,dom-if,dom-repeat{display:none;}",document.head.appendChild(e)}return!0}return!1}
/**
    @license
    Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
    The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
    The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
    Code distributed by Google as part of the polymer project is also
    subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
    */const domBindBase=GestureEventListeners(OptionalMutableData(PropertyEffects(HTMLElement)));class DomBind extends domBindBase{static get observedAttributes(){return["mutable-data"]}constructor(){if(super(),strictTemplatePolicy)throw new Error("strictTemplatePolicy: dom-bind not allowed");this.root=null,this.$=null,this.__children=null}attributeChangedCallback(e,t,n,r){this.mutableData=!0}connectedCallback(){hideElementsGlobally()||(this.style.display="none"),this.render()}disconnectedCallback(){this.__removeChildren()}__insertChildren(){wrap(wrap(this).parentNode).insertBefore(this.root,this)}__removeChildren(){if(this.__children)for(let e=0;e<this.__children.length;e++)this.root.appendChild(this.__children[e])}render(){let e;if(!this.__children){if(e=e||this.querySelector("template"),!e){let t=new MutationObserver((()=>{if(e=this.querySelector("template"),!e)throw new Error("dom-bind requires a <template> child");t.disconnect(),this.render()}));return void t.observe(this,{childList:!0})}this.root=this._stampTemplate(e),this.$=this.root.$,this.__children=[];for(let e=this.root.firstChild;e;e=e.nextSibling)this.__children[this.__children.length]=e;this._enableProperties()}this.__insertChildren(),this.dispatchEvent(new CustomEvent("dom-change",{bubbles:!0,composed:!0}))}}customElements.define("dom-bind",DomBind);
/**
    @license
    Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
    The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
    The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
    Code distributed by Google as part of the polymer project is also
    subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
    */
const domRepeatBase=OptionalMutableData(PolymerElement);class DomRepeat extends domRepeatBase{static get is(){return"dom-repeat"}static get template(){return null}static get properties(){return{items:{type:Array},as:{type:String,value:"item"},indexAs:{type:String,value:"index"},itemsIndexAs:{type:String,value:"itemsIndex"},sort:{type:Function,observer:"__sortChanged"},filter:{type:Function,observer:"__filterChanged"},observe:{type:String,observer:"__observeChanged"},delay:Number,renderedItemCount:{type:Number,notify:!suppressTemplateNotifications,readOnly:!0},initialCount:{type:Number},targetFramerate:{type:Number,value:20},_targetFrameTime:{type:Number,computed:"__computeFrameTime(targetFramerate)"},notifyDomChange:{type:Boolean},reuseChunkedInstances:{type:Boolean}}}static get observers(){return["__itemsChanged(items.*)"]}constructor(){super(),this.__instances=[],this.__renderDebouncer=null,this.__itemsIdxToInstIdx={},this.__chunkCount=null,this.__renderStartTime=null,this.__itemsArrayChanged=!1,this.__shouldMeasureChunk=!1,this.__shouldContinueChunking=!1,this.__chunkingId=0,this.__sortFn=null,this.__filterFn=null,this.__observePaths=null,this.__ctor=null,this.__isDetached=!0,this.template=null}disconnectedCallback(){super.disconnectedCallback(),this.__isDetached=!0;for(let e=0;e<this.__instances.length;e++)this.__detachInstance(e)}connectedCallback(){if(super.connectedCallback(),hideElementsGlobally()||(this.style.display="none"),this.__isDetached){this.__isDetached=!1;let e=wrap(wrap(this).parentNode);for(let t=0;t<this.__instances.length;t++)this.__attachInstance(t,e)}}__ensureTemplatized(){if(!this.__ctor){const e=this;let t=this.template=e._templateInfo?e:this.querySelector("template");if(!t){let e=new MutationObserver((()=>{if(!this.querySelector("template"))throw new Error("dom-repeat requires a <template> child");e.disconnect(),this.__render()}));return e.observe(this,{childList:!0}),!1}let n={};n[this.as]=!0,n[this.indexAs]=!0,n[this.itemsIndexAs]=!0,this.__ctor=templatize(t,this,{mutableData:this.mutableData,parentModel:!0,instanceProps:n,forwardHostProp:function(e,t){let n=this.__instances;for(let r,i=0;i<n.length&&(r=n[i]);i++)r.forwardHostProp(e,t)},notifyInstanceProp:function(e,t,n){if(matches$1(this.as,t)){let r=e[this.itemsIndexAs];t==this.as&&(this.items[r]=n);let i=translate(this.as,`${JSCompiler_renameProperty("items",this)}.${r}`,t);this.notifyPath(i,n)}}})}return!0}__getMethodHost(){return this.__dataHost._methodHost||this.__dataHost}__functionFromPropertyValue(e){if("string"==typeof e){let t=e,n=this.__getMethodHost();return function(){return n[t].apply(n,arguments)}}return e}__sortChanged(e){this.__sortFn=this.__functionFromPropertyValue(e),this.items&&this.__debounceRender(this.__render)}__filterChanged(e){this.__filterFn=this.__functionFromPropertyValue(e),this.items&&this.__debounceRender(this.__render)}__computeFrameTime(e){return Math.ceil(1e3/e)}__observeChanged(){this.__observePaths=this.observe&&this.observe.replace(".*",".").split(" ")}__handleObservedPaths(e){if(this.__sortFn||this.__filterFn)if(e){if(this.__observePaths){let t=this.__observePaths;for(let n=0;n<t.length;n++)0===e.indexOf(t[n])&&this.__debounceRender(this.__render,this.delay)}}else this.__debounceRender(this.__render,this.delay)}__itemsChanged(e){this.items&&!Array.isArray(this.items)&&console.warn("dom-repeat expected array for `items`, found",this.items),this.__handleItemPath(e.path,e.value)||("items"===e.path&&(this.__itemsArrayChanged=!0),this.__debounceRender(this.__render))}__debounceRender(e,t=0){this.__renderDebouncer=Debouncer.debounce(this.__renderDebouncer,t>0?timeOut.after(t):microTask,e.bind(this)),enqueueDebouncer(this.__renderDebouncer)}render(){this.__debounceRender(this.__render),flush()}__render(){if(!this.__ensureTemplatized())return;let e=this.items||[];const t=this.__sortAndFilterItems(e),n=this.__calculateLimit(t.length);this.__updateInstances(e,n,t),this.initialCount&&(this.__shouldMeasureChunk||this.__shouldContinueChunking)&&(cancelAnimationFrame(this.__chunkingId),this.__chunkingId=requestAnimationFrame((()=>this.__continueChunking()))),this._setRenderedItemCount(this.__instances.length),suppressTemplateNotifications&&!this.notifyDomChange||this.dispatchEvent(new CustomEvent("dom-change",{bubbles:!0,composed:!0}))}__sortAndFilterItems(e){let t=new Array(e.length);for(let n=0;n<e.length;n++)t[n]=n;return this.__filterFn&&(t=t.filter(((t,n,r)=>this.__filterFn(e[t],n,r)))),this.__sortFn&&t.sort(((t,n)=>this.__sortFn(e[t],e[n]))),t}__calculateLimit(e){let t=e;const n=this.__instances.length;if(this.initialCount){let r;!this.__chunkCount||this.__itemsArrayChanged&&!this.reuseChunkedInstances?(t=Math.min(e,this.initialCount),r=Math.max(t-n,0),this.__chunkCount=r||1):(r=Math.min(Math.max(e-n,0),this.__chunkCount),t=Math.min(n+r,e)),this.__shouldMeasureChunk=r===this.__chunkCount,this.__shouldContinueChunking=t<e,this.__renderStartTime=performance.now()}return this.__itemsArrayChanged=!1,t}__continueChunking(){if(this.__shouldMeasureChunk){const e=performance.now()-this.__renderStartTime;this.__chunkCount=Math.round(this.__chunkCount*(this._targetFrameTime/e))||1}this.__shouldContinueChunking&&this.__debounceRender(this.__render)}__updateInstances(e,t,n){const r=this.__itemsIdxToInstIdx={};let i;for(i=0;i<t;i++){let t=this.__instances[i],a=n[i],o=e[a];r[a]=i,t?(t._setPendingProperty(this.as,o),t._setPendingProperty(this.indexAs,i),t._setPendingProperty(this.itemsIndexAs,a),t._flushProperties()):this.__insertInstance(o,i,a)}for(let e=this.__instances.length-1;e>=i;e--)this.__detachAndRemoveInstance(e)}__detachInstance(e){let t=this.__instances[e];const n=wrap(t.root);for(let e=0;e<t.children.length;e++){n.appendChild(t.children[e])}return t}__attachInstance(e,t){t.insertBefore(this.__instances[e].root,this)}__detachAndRemoveInstance(e){this.__detachInstance(e),this.__instances.splice(e,1)}__stampInstance(e,t,n){let r={};return r[this.as]=e,r[this.indexAs]=t,r[this.itemsIndexAs]=n,new this.__ctor(r)}__insertInstance(e,t,n){const r=this.__stampInstance(e,t,n);let i=this.__instances[t+1],a=i?i.children[0]:this;return wrap(wrap(this).parentNode).insertBefore(r.root,a),this.__instances[t]=r,r}_showHideChildren(e){for(let t=0;t<this.__instances.length;t++)this.__instances[t]._showHideChildren(e)}__handleItemPath(e,t){let n=e.slice(6),r=n.indexOf("."),i=r<0?n:n.substring(0,r);if(i==parseInt(i,10)){let e=r<0?"":n.substring(r+1);this.__handleObservedPaths(e);let a=this.__instances[this.__itemsIdxToInstIdx[i]];if(a){a._setPendingPropertyOrPath(this.as+(e?"."+e:""),t,!1,!0),a._flushProperties()}return!0}}itemForElement(e){let t=this.modelForElement(e);return t&&t[this.as]}indexForElement(e){let t=this.modelForElement(e);return t&&t[this.indexAs]}modelForElement(e){return modelForElement(this.template,e)}}customElements.define(DomRepeat.is,DomRepeat);
/**
    @license
    Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
    The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
    The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
    Code distributed by Google as part of the polymer project is also
    subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
    */
class DomIfBase extends PolymerElement{static get is(){return"dom-if"}static get template(){return null}static get properties(){return{if:{type:Boolean,observer:"__debounceRender"},restamp:{type:Boolean,observer:"__debounceRender"},notifyDomChange:{type:Boolean}}}constructor(){super(),this.__renderDebouncer=null,this._lastIf=!1,this.__hideTemplateChildren__=!1}__debounceRender(){this.__renderDebouncer=Debouncer.debounce(this.__renderDebouncer,microTask,(()=>this.__render())),enqueueDebouncer(this.__renderDebouncer)}disconnectedCallback(){super.disconnectedCallback();const e=wrap(this).parentNode;e&&(e.nodeType!=Node.DOCUMENT_FRAGMENT_NODE||wrap(e).host)||this.__teardownInstance()}connectedCallback(){super.connectedCallback(),hideElementsGlobally()||(this.style.display="none"),this.if&&this.__debounceRender()}__ensureTemplate(){if(!this.__template){const e=this;let t=e._templateInfo?e:wrap(e).querySelector("template");if(!t){let e=new MutationObserver((()=>{if(!wrap(this).querySelector("template"))throw new Error("dom-if requires a <template> child");e.disconnect(),this.__render()}));return e.observe(this,{childList:!0}),!1}this.__template=t}return!0}__ensureInstance(){let e=wrap(this).parentNode;if(this.__hasInstance()){let t=this.__getInstanceNodes();if(t&&t.length){if(wrap(this).previousSibling!==t[t.length-1])for(let n,r=0;r<t.length&&(n=t[r]);r++)wrap(e).insertBefore(n,this)}}else{if(!e)return!1;if(!this.__ensureTemplate())return!1;this.__createAndInsertInstance(e)}return!0}render(){flush()}__render(){if(this.if){if(!this.__ensureInstance())return}else this.restamp&&this.__teardownInstance();this._showHideChildren(),suppressTemplateNotifications&&!this.notifyDomChange||this.if==this._lastIf||(this.dispatchEvent(new CustomEvent("dom-change",{bubbles:!0,composed:!0})),this._lastIf=this.if)}__hasInstance(){}__getInstanceNodes(){}__createAndInsertInstance(e){}__teardownInstance(){}_showHideChildren(){}}class DomIfFast extends DomIfBase{constructor(){super(),this.__instance=null,this.__syncInfo=null}__hasInstance(){return Boolean(this.__instance)}__getInstanceNodes(){return this.__instance.templateInfo.childNodes}__createAndInsertInstance(e){const t=this.__dataHost||this;if(strictTemplatePolicy&&!this.__dataHost)throw new Error("strictTemplatePolicy: template owner not trusted");const n=t._bindTemplate(this.__template,!0);n.runEffects=(e,t,n)=>{let r=this.__syncInfo;if(this.if)r&&(this.__syncInfo=null,this._showHideChildren(),t=Object.assign(r.changedProps,t)),e(t,n);else if(this.__instance)if(r||(r=this.__syncInfo={runEffects:e,changedProps:{}}),n)for(const e in t){const t=root(e);r.changedProps[t]=this.__dataHost[t]}else Object.assign(r.changedProps,t)},this.__instance=t._stampTemplate(this.__template,n),wrap(e).insertBefore(this.__instance,this)}__syncHostProperties(){const e=this.__syncInfo;e&&(this.__syncInfo=null,e.runEffects(e.changedProps,!1))}__teardownInstance(){this.__instance&&((this.__dataHost||this)._removeBoundDom(this.__instance),this.__instance=null,this.__syncInfo=null)}_showHideChildren(){const e=this.__hideTemplateChildren__||!this.if;this.__instance&&Boolean(this.__instance.__hidden)!==e&&(this.__instance.__hidden=e,showHideChildren(e,this.__instance.templateInfo.childNodes)),e||this.__syncHostProperties()}}class DomIfLegacy extends DomIfBase{constructor(){super(),this.__ctor=null,this.__instance=null,this.__invalidProps=null}__hasInstance(){return Boolean(this.__instance)}__getInstanceNodes(){return this.__instance.children}__createAndInsertInstance(e){this.__ctor||(this.__ctor=templatize(this.__template,this,{mutableData:!0,forwardHostProp:function(e,t){this.__instance&&(this.if?this.__instance.forwardHostProp(e,t):(this.__invalidProps=this.__invalidProps||Object.create(null),this.__invalidProps[root(e)]=!0))}})),this.__instance=new this.__ctor,wrap(e).insertBefore(this.__instance.root,this)}__teardownInstance(){if(this.__instance){let e=this.__instance.children;if(e&&e.length){let t=wrap(e[0]).parentNode;if(t){t=wrap(t);for(let n,r=0;r<e.length&&(n=e[r]);r++)t.removeChild(n)}}this.__invalidProps=null,this.__instance=null}}__syncHostProperties(){let e=this.__invalidProps;if(e){this.__invalidProps=null;for(let t in e)this.__instance._setPendingProperty(t,this.__dataHost[t]);this.__instance._flushProperties()}}_showHideChildren(){const e=this.__hideTemplateChildren__||!this.if;this.__instance&&Boolean(this.__instance.__hidden)!==e&&(this.__instance.__hidden=e,this.__instance._showHideChildren(e)),e||this.__syncHostProperties()}}const DomIf=fastDomIf?DomIfFast:DomIfLegacy;customElements.define(DomIf.is,DomIf);
/**
    @license
    Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
    The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
    The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
    Code distributed by Google as part of the polymer project is also
    subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
    */
let ArraySelectorMixin=dedupingMixin((e=>{let t=ElementMixin(e);return class extends t{static get properties(){return{items:{type:Array},multi:{type:Boolean,value:!1},selected:{type:Object,notify:!0},selectedItem:{type:Object,notify:!0},toggle:{type:Boolean,value:!1}}}static get observers(){return["__updateSelection(multi, items.*)"]}constructor(){super(),this.__lastItems=null,this.__lastMulti=null,this.__selectedMap=null}__updateSelection(e,t){let n=t.path;if(n==JSCompiler_renameProperty("items",this)){let n=t.base||[],r=this.__lastItems;if(e!==this.__lastMulti&&this.clearSelection(),r){let e=calculateSplices(n,r);this.__applySplices(e)}this.__lastItems=n,this.__lastMulti=e}else if(t.path==`${JSCompiler_renameProperty("items",this)}.splices`)this.__applySplices(t.value.indexSplices);else{let e=n.slice(`${JSCompiler_renameProperty("items",this)}.`.length),t=parseInt(e,10);e.indexOf(".")<0&&e==t&&this.__deselectChangedIdx(t)}}__applySplices(e){let t=this.__selectedMap;for(let n=0;n<e.length;n++){let r=e[n];t.forEach(((e,n)=>{e<r.index||t.set(n,e>=r.index+r.removed.length?e+r.addedCount-r.removed.length:-1)}));for(let e=0;e<r.addedCount;e++){let n=r.index+e;t.has(this.items[n])&&t.set(this.items[n],n)}}this.__updateLinks();let n=0;t.forEach(((e,r)=>{e<0?(this.multi?this.splice(JSCompiler_renameProperty("selected",this),n,1):this.selected=this.selectedItem=null,t.delete(r)):n++}))}__updateLinks(){if(this.__dataLinkedPaths={},this.multi){let e=0;this.__selectedMap.forEach((t=>{t>=0&&this.linkPaths(`${JSCompiler_renameProperty("items",this)}.${t}`,`${JSCompiler_renameProperty("selected",this)}.${e++}`)}))}else this.__selectedMap.forEach((e=>{this.linkPaths(JSCompiler_renameProperty("selected",this),`${JSCompiler_renameProperty("items",this)}.${e}`),this.linkPaths(JSCompiler_renameProperty("selectedItem",this),`${JSCompiler_renameProperty("items",this)}.${e}`)}))}clearSelection(){this.__dataLinkedPaths={},this.__selectedMap=new Map,this.selected=this.multi?[]:null,this.selectedItem=null}isSelected(e){return this.__selectedMap.has(e)}isIndexSelected(e){return this.isSelected(this.items[e])}__deselectChangedIdx(e){let t=this.__selectedIndexForItemIndex(e);if(t>=0){let e=0;this.__selectedMap.forEach(((n,r)=>{t==e++&&this.deselect(r)}))}}__selectedIndexForItemIndex(e){let t=this.__dataLinkedPaths[`${JSCompiler_renameProperty("items",this)}.${e}`];if(t)return parseInt(t.slice(`${JSCompiler_renameProperty("selected",this)}.`.length),10)}deselect(e){let t=this.__selectedMap.get(e);if(t>=0){let n;this.__selectedMap.delete(e),this.multi&&(n=this.__selectedIndexForItemIndex(t)),this.__updateLinks(),this.multi?this.splice(JSCompiler_renameProperty("selected",this),n,1):this.selected=this.selectedItem=null}}deselectIndex(e){this.deselect(this.items[e])}select(e){this.selectIndex(this.items.indexOf(e))}selectIndex(e){let t=this.items[e];this.isSelected(t)?this.toggle&&this.deselectIndex(e):(this.multi||this.__selectedMap.clear(),this.__selectedMap.set(t,e),this.__updateLinks(),this.multi?this.push(JSCompiler_renameProperty("selected",this),t):this.selected=this.selectedItem=t)}}})),baseArraySelector=ArraySelectorMixin(PolymerElement);class ArraySelector extends baseArraySelector{static get is(){return"array-selector"}static get template(){return null}}customElements.define(ArraySelector.is,ArraySelector);
/**
    @license
    Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
    The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
    The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
    Code distributed by Google as part of the polymer project is also
    subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
    */
const customStyleInterface=new CustomStyleInterface$1;window.ShadyCSS||(window.ShadyCSS={prepareTemplate(e,t,n){},prepareTemplateDom(e,t){},prepareTemplateStyles(e,t,n){},styleSubtree(e,t){customStyleInterface.processStyles(),updateNativeProperties(e,t)},styleElement(e){customStyleInterface.processStyles()},styleDocument(e){customStyleInterface.processStyles(),updateNativeProperties(document.body,e)},getComputedStyleValue:(e,t)=>getComputedStyleValue(e,t),flushCustomStyles(){},nativeCss:nativeCssVariables,nativeShadow:nativeShadow,cssBuild:cssBuild,disableRuntime:disableRuntime}),window.ShadyCSS.CustomStyleInterface=customStyleInterface;
/**
    @license
    Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
    The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
    The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
    Code distributed by Google as part of the polymer project is also
    subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
    */
const attr="include",CustomStyleInterface=window.ShadyCSS.CustomStyleInterface;class CustomStyle extends HTMLElement{constructor(){super(),this._style=null,CustomStyleInterface.addCustomStyle(this)}getStyle(){if(this._style)return this._style;const e=this.querySelector("style");if(!e)return null;this._style=e;const t=e.getAttribute(attr);return t&&(e.removeAttribute(attr),e.textContent=cssFromModules(t)+e.textContent),this.ownerDocument!==window.document&&window.document.head.appendChild(this),this._style}}
/**
    @license
    Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
    The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
    The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
    Code distributed by Google as part of the polymer project is also
    subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
    */
let mutablePropertyChange;window.customElements.define("custom-style",CustomStyle),mutablePropertyChange=MutableData._mutablePropertyChange;const OptionalMutableDataBehavior={properties:{mutableData:Boolean},_shouldPropertyChange(e,t,n){return mutablePropertyChange(this,e,t,n,this.mutableData)}},Base=LegacyElementMixin(HTMLElement).prototype;
/**
    @license
    Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
    The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
    The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
    Code distributed by Google as part of the polymer project is also
    subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
    */
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */
var ORPHANS=new Set;const IronResizableBehavior={properties:{_parentResizable:{type:Object,observer:"_parentResizableChanged"},_notifyingDescendant:{type:Boolean,value:!1}},listeners:{"iron-request-resize-notifications":"_onIronRequestResizeNotifications"},created:function(){this._interestedResizables=[],this._boundNotifyResize=this.notifyResize.bind(this),this._boundOnDescendantIronResize=this._onDescendantIronResize.bind(this)},attached:function(){this._requestResizeNotifications()},detached:function(){this._parentResizable?this._parentResizable.stopResizeNotificationsFor(this):(ORPHANS.delete(this),window.removeEventListener("resize",this._boundNotifyResize)),this._parentResizable=null},notifyResize:function(){this.isAttached&&(this._interestedResizables.forEach((function(e){this.resizerShouldNotify(e)&&this._notifyDescendant(e)}),this),this._fireResize())},assignParentResizable:function(e){this._parentResizable&&this._parentResizable.stopResizeNotificationsFor(this),this._parentResizable=e,e&&-1===e._interestedResizables.indexOf(this)&&(e._interestedResizables.push(this),e._subscribeIronResize(this))},stopResizeNotificationsFor:function(e){var t=this._interestedResizables.indexOf(e);t>-1&&(this._interestedResizables.splice(t,1),this._unsubscribeIronResize(e))},_subscribeIronResize:function(e){e.addEventListener("iron-resize",this._boundOnDescendantIronResize)},_unsubscribeIronResize:function(e){e.removeEventListener("iron-resize",this._boundOnDescendantIronResize)},resizerShouldNotify:function(e){return!0},_onDescendantIronResize:function(e){this._notifyingDescendant?e.stopPropagation():useShadow||this._fireResize()},_fireResize:function(){this.fire("iron-resize",null,{node:this,bubbles:!1})},_onIronRequestResizeNotifications:function(e){var t=dom$1(e).rootTarget;t!==this&&(t.assignParentResizable(this),this._notifyDescendant(t),e.stopPropagation())},_parentResizableChanged:function(e){e&&window.removeEventListener("resize",this._boundNotifyResize)},_notifyDescendant:function(e){this.isAttached&&(this._notifyingDescendant=!0,e.notifyResize(),this._notifyingDescendant=!1)},_requestResizeNotifications:function(){if(this.isAttached)if("loading"===document.readyState){var e=this._requestResizeNotifications.bind(this);document.addEventListener("readystatechange",(function t(){document.removeEventListener("readystatechange",t),e()}))}else this._findParent(),this._parentResizable?this._parentResizable._interestedResizables.forEach((function(e){e!==this&&e._findParent()}),this):(ORPHANS.forEach((function(e){e!==this&&e._findParent()}),this),window.addEventListener("resize",this._boundNotifyResize),this.notifyResize())},_findParent:function(){this.assignParentResizable(null),this.fire("iron-request-resize-notifications",null,{node:this,bubbles:!0,cancelable:!0}),this._parentResizable?ORPHANS.delete(this):ORPHANS.add(this)}};
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */Polymer({_template:html`
    <style>
      :host {
        display: block;
        transition-duration: var(--iron-collapse-transition-duration, 300ms);
        /* Safari 10 needs this property prefixed to correctly apply the custom property */
        -webkit-transition-duration: var(--iron-collapse-transition-duration, 300ms);
        overflow: visible;
      }

      :host(.iron-collapse-closed) {
        display: none;
      }

      :host(:not(.iron-collapse-opened)) {
        overflow: hidden;
      }
    </style>

    <slot></slot>
`,is:"iron-collapse",behaviors:[IronResizableBehavior],properties:{horizontal:{type:Boolean,value:!1,observer:"_horizontalChanged"},opened:{type:Boolean,value:!1,notify:!0,observer:"_openedChanged"},transitioning:{type:Boolean,notify:!0,readOnly:!0},noAnimation:{type:Boolean},_desiredSize:{type:String,value:""}},get dimension(){return this.horizontal?"width":"height"},get _dimensionMax(){return this.horizontal?"maxWidth":"maxHeight"},get _dimensionMaxCss(){return this.horizontal?"max-width":"max-height"},hostAttributes:{role:"group","aria-hidden":"true"},listeners:{transitionend:"_onTransitionEnd"},toggle:function(){this.opened=!this.opened},show:function(){this.opened=!0},hide:function(){this.opened=!1},updateSize:function(e,t){e="auto"===e?"":e;var n=t&&!this.noAnimation&&this.isAttached&&this._desiredSize!==e;if(this._desiredSize=e,this._updateTransition(!1),n){var r=this._calcSize();""===e&&(this.style[this._dimensionMax]="",e=this._calcSize()),this.style[this._dimensionMax]=r,this.scrollTop=this.scrollTop,this._updateTransition(!0),n=e!==r}this.style[this._dimensionMax]=e,n||this._transitionEnd()},enableTransition:function(e){Base._warn("`enableTransition()` is deprecated, use `noAnimation` instead."),this.noAnimation=!e},_updateTransition:function(e){this.style.transitionDuration=e&&!this.noAnimation?"":"0s"},_horizontalChanged:function(){this.style.transitionProperty=this._dimensionMaxCss,this.style["maxWidth"===this._dimensionMax?"maxHeight":"maxWidth"]="",this.updateSize(this.opened?"auto":"0px",!1)},_openedChanged:function(){this.setAttribute("aria-hidden",!this.opened),this._setTransitioning(!0),this.toggleClass("iron-collapse-closed",!1),this.toggleClass("iron-collapse-opened",!1),this.updateSize(this.opened?"auto":"0px",!0),this.opened&&this.focus()},_transitionEnd:function(){this.style[this._dimensionMax]=this._desiredSize,this.toggleClass("iron-collapse-closed",!this.opened),this.toggleClass("iron-collapse-opened",this.opened),this._updateTransition(!1),this.notifyResize(),this._setTransitioning(!1)},_onTransitionEnd:function(e){dom$1(e).rootTarget===this&&this._transitionEnd()},_calcSize:function(){return this.getBoundingClientRect()[this.dimension]+"px"}});
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */
const template$n=html`
/* Most common used flex styles*/
<dom-module id="iron-flex">
  <template>
    <style>
      .layout.horizontal,
      .layout.vertical {
        display: -ms-flexbox;
        display: -webkit-flex;
        display: flex;
      }

      .layout.inline {
        display: -ms-inline-flexbox;
        display: -webkit-inline-flex;
        display: inline-flex;
      }

      .layout.horizontal {
        -ms-flex-direction: row;
        -webkit-flex-direction: row;
        flex-direction: row;
      }

      .layout.vertical {
        -ms-flex-direction: column;
        -webkit-flex-direction: column;
        flex-direction: column;
      }

      .layout.wrap {
        -ms-flex-wrap: wrap;
        -webkit-flex-wrap: wrap;
        flex-wrap: wrap;
      }

      .layout.no-wrap {
        -ms-flex-wrap: nowrap;
        -webkit-flex-wrap: nowrap;
        flex-wrap: nowrap;
      }

      .layout.center,
      .layout.center-center {
        -ms-flex-align: center;
        -webkit-align-items: center;
        align-items: center;
      }

      .layout.center-justified,
      .layout.center-center {
        -ms-flex-pack: center;
        -webkit-justify-content: center;
        justify-content: center;
      }

      .flex {
        -ms-flex: 1 1 0.000000001px;
        -webkit-flex: 1;
        flex: 1;
        -webkit-flex-basis: 0.000000001px;
        flex-basis: 0.000000001px;
      }

      .flex-auto {
        -ms-flex: 1 1 auto;
        -webkit-flex: 1 1 auto;
        flex: 1 1 auto;
      }

      .flex-none {
        -ms-flex: none;
        -webkit-flex: none;
        flex: none;
      }
    </style>
  </template>
</dom-module>
/* Basic flexbox reverse styles */
<dom-module id="iron-flex-reverse">
  <template>
    <style>
      .layout.horizontal-reverse,
      .layout.vertical-reverse {
        display: -ms-flexbox;
        display: -webkit-flex;
        display: flex;
      }

      .layout.horizontal-reverse {
        -ms-flex-direction: row-reverse;
        -webkit-flex-direction: row-reverse;
        flex-direction: row-reverse;
      }

      .layout.vertical-reverse {
        -ms-flex-direction: column-reverse;
        -webkit-flex-direction: column-reverse;
        flex-direction: column-reverse;
      }

      .layout.wrap-reverse {
        -ms-flex-wrap: wrap-reverse;
        -webkit-flex-wrap: wrap-reverse;
        flex-wrap: wrap-reverse;
      }
    </style>
  </template>
</dom-module>
/* Flexbox alignment */
<dom-module id="iron-flex-alignment">
  <template>
    <style>
      /**
       * Alignment in cross axis.
       */
      .layout.start {
        -ms-flex-align: start;
        -webkit-align-items: flex-start;
        align-items: flex-start;
      }

      .layout.center,
      .layout.center-center {
        -ms-flex-align: center;
        -webkit-align-items: center;
        align-items: center;
      }

      .layout.end {
        -ms-flex-align: end;
        -webkit-align-items: flex-end;
        align-items: flex-end;
      }

      .layout.baseline {
        -ms-flex-align: baseline;
        -webkit-align-items: baseline;
        align-items: baseline;
      }

      /**
       * Alignment in main axis.
       */
      .layout.start-justified {
        -ms-flex-pack: start;
        -webkit-justify-content: flex-start;
        justify-content: flex-start;
      }

      .layout.center-justified,
      .layout.center-center {
        -ms-flex-pack: center;
        -webkit-justify-content: center;
        justify-content: center;
      }

      .layout.end-justified {
        -ms-flex-pack: end;
        -webkit-justify-content: flex-end;
        justify-content: flex-end;
      }

      .layout.around-justified {
        -ms-flex-pack: distribute;
        -webkit-justify-content: space-around;
        justify-content: space-around;
      }

      .layout.justified {
        -ms-flex-pack: justify;
        -webkit-justify-content: space-between;
        justify-content: space-between;
      }

      /**
       * Self alignment.
       */
      .self-start {
        -ms-align-self: flex-start;
        -webkit-align-self: flex-start;
        align-self: flex-start;
      }

      .self-center {
        -ms-align-self: center;
        -webkit-align-self: center;
        align-self: center;
      }

      .self-end {
        -ms-align-self: flex-end;
        -webkit-align-self: flex-end;
        align-self: flex-end;
      }

      .self-stretch {
        -ms-align-self: stretch;
        -webkit-align-self: stretch;
        align-self: stretch;
      }

      .self-baseline {
        -ms-align-self: baseline;
        -webkit-align-self: baseline;
        align-self: baseline;
      }

      /**
       * multi-line alignment in main axis.
       */
      .layout.start-aligned {
        -ms-flex-line-pack: start;  /* IE10 */
        -ms-align-content: flex-start;
        -webkit-align-content: flex-start;
        align-content: flex-start;
      }

      .layout.end-aligned {
        -ms-flex-line-pack: end;  /* IE10 */
        -ms-align-content: flex-end;
        -webkit-align-content: flex-end;
        align-content: flex-end;
      }

      .layout.center-aligned {
        -ms-flex-line-pack: center;  /* IE10 */
        -ms-align-content: center;
        -webkit-align-content: center;
        align-content: center;
      }

      .layout.between-aligned {
        -ms-flex-line-pack: justify;  /* IE10 */
        -ms-align-content: space-between;
        -webkit-align-content: space-between;
        align-content: space-between;
      }

      .layout.around-aligned {
        -ms-flex-line-pack: distribute;  /* IE10 */
        -ms-align-content: space-around;
        -webkit-align-content: space-around;
        align-content: space-around;
      }
    </style>
  </template>
</dom-module>
/* Non-flexbox positioning helper styles */
<dom-module id="iron-flex-factors">
  <template>
    <style>
      .flex,
      .flex-1 {
        -ms-flex: 1 1 0.000000001px;
        -webkit-flex: 1;
        flex: 1;
        -webkit-flex-basis: 0.000000001px;
        flex-basis: 0.000000001px;
      }

      .flex-2 {
        -ms-flex: 2;
        -webkit-flex: 2;
        flex: 2;
      }

      .flex-3 {
        -ms-flex: 3;
        -webkit-flex: 3;
        flex: 3;
      }

      .flex-4 {
        -ms-flex: 4;
        -webkit-flex: 4;
        flex: 4;
      }

      .flex-5 {
        -ms-flex: 5;
        -webkit-flex: 5;
        flex: 5;
      }

      .flex-6 {
        -ms-flex: 6;
        -webkit-flex: 6;
        flex: 6;
      }

      .flex-7 {
        -ms-flex: 7;
        -webkit-flex: 7;
        flex: 7;
      }

      .flex-8 {
        -ms-flex: 8;
        -webkit-flex: 8;
        flex: 8;
      }

      .flex-9 {
        -ms-flex: 9;
        -webkit-flex: 9;
        flex: 9;
      }

      .flex-10 {
        -ms-flex: 10;
        -webkit-flex: 10;
        flex: 10;
      }

      .flex-11 {
        -ms-flex: 11;
        -webkit-flex: 11;
        flex: 11;
      }

      .flex-12 {
        -ms-flex: 12;
        -webkit-flex: 12;
        flex: 12;
      }
    </style>
  </template>
</dom-module>
<dom-module id="iron-positioning">
  <template>
    <style>
      .block {
        display: block;
      }

      [hidden] {
        display: none !important;
      }

      .invisible {
        visibility: hidden !important;
      }

      .relative {
        position: relative;
      }

      .fit {
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
      }

      body.fullbleed {
        margin: 0;
        height: 100vh;
      }

      .scroll {
        -webkit-overflow-scrolling: touch;
        overflow: auto;
      }

      /* fixed position */
      .fixed-bottom,
      .fixed-left,
      .fixed-right,
      .fixed-top {
        position: fixed;
      }

      .fixed-top {
        top: 0;
        left: 0;
        right: 0;
      }

      .fixed-right {
        top: 0;
        right: 0;
        bottom: 0;
      }

      .fixed-bottom {
        right: 0;
        bottom: 0;
        left: 0;
      }

      .fixed-left {
        top: 0;
        bottom: 0;
        left: 0;
      }
    </style>
  </template>
</dom-module>
`;template$n.setAttribute("style","display: none;"),document.head.appendChild(template$n.content);
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */
const template$m=html`
<custom-style>
  <style is="custom-style">
    [hidden] {
      display: none !important;
    }
  </style>
</custom-style>
<custom-style>
  <style is="custom-style">
    html {

      --layout: {
        display: -ms-flexbox;
        display: -webkit-flex;
        display: flex;
      };

      --layout-inline: {
        display: -ms-inline-flexbox;
        display: -webkit-inline-flex;
        display: inline-flex;
      };

      --layout-horizontal: {
        @apply --layout;

        -ms-flex-direction: row;
        -webkit-flex-direction: row;
        flex-direction: row;
      };

      --layout-horizontal-reverse: {
        @apply --layout;

        -ms-flex-direction: row-reverse;
        -webkit-flex-direction: row-reverse;
        flex-direction: row-reverse;
      };

      --layout-vertical: {
        @apply --layout;

        -ms-flex-direction: column;
        -webkit-flex-direction: column;
        flex-direction: column;
      };

      --layout-vertical-reverse: {
        @apply --layout;

        -ms-flex-direction: column-reverse;
        -webkit-flex-direction: column-reverse;
        flex-direction: column-reverse;
      };

      --layout-wrap: {
        -ms-flex-wrap: wrap;
        -webkit-flex-wrap: wrap;
        flex-wrap: wrap;
      };

      --layout-wrap-reverse: {
        -ms-flex-wrap: wrap-reverse;
        -webkit-flex-wrap: wrap-reverse;
        flex-wrap: wrap-reverse;
      };

      --layout-flex-auto: {
        -ms-flex: 1 1 auto;
        -webkit-flex: 1 1 auto;
        flex: 1 1 auto;
      };

      --layout-flex-none: {
        -ms-flex: none;
        -webkit-flex: none;
        flex: none;
      };

      --layout-flex: {
        -ms-flex: 1 1 0.000000001px;
        -webkit-flex: 1;
        flex: 1;
        -webkit-flex-basis: 0.000000001px;
        flex-basis: 0.000000001px;
      };

      --layout-flex-2: {
        -ms-flex: 2;
        -webkit-flex: 2;
        flex: 2;
      };

      --layout-flex-3: {
        -ms-flex: 3;
        -webkit-flex: 3;
        flex: 3;
      };

      --layout-flex-4: {
        -ms-flex: 4;
        -webkit-flex: 4;
        flex: 4;
      };

      --layout-flex-5: {
        -ms-flex: 5;
        -webkit-flex: 5;
        flex: 5;
      };

      --layout-flex-6: {
        -ms-flex: 6;
        -webkit-flex: 6;
        flex: 6;
      };

      --layout-flex-7: {
        -ms-flex: 7;
        -webkit-flex: 7;
        flex: 7;
      };

      --layout-flex-8: {
        -ms-flex: 8;
        -webkit-flex: 8;
        flex: 8;
      };

      --layout-flex-9: {
        -ms-flex: 9;
        -webkit-flex: 9;
        flex: 9;
      };

      --layout-flex-10: {
        -ms-flex: 10;
        -webkit-flex: 10;
        flex: 10;
      };

      --layout-flex-11: {
        -ms-flex: 11;
        -webkit-flex: 11;
        flex: 11;
      };

      --layout-flex-12: {
        -ms-flex: 12;
        -webkit-flex: 12;
        flex: 12;
      };

      /* alignment in cross axis */

      --layout-start: {
        -ms-flex-align: start;
        -webkit-align-items: flex-start;
        align-items: flex-start;
      };

      --layout-center: {
        -ms-flex-align: center;
        -webkit-align-items: center;
        align-items: center;
      };

      --layout-end: {
        -ms-flex-align: end;
        -webkit-align-items: flex-end;
        align-items: flex-end;
      };

      --layout-baseline: {
        -ms-flex-align: baseline;
        -webkit-align-items: baseline;
        align-items: baseline;
      };

      /* alignment in main axis */

      --layout-start-justified: {
        -ms-flex-pack: start;
        -webkit-justify-content: flex-start;
        justify-content: flex-start;
      };

      --layout-center-justified: {
        -ms-flex-pack: center;
        -webkit-justify-content: center;
        justify-content: center;
      };

      --layout-end-justified: {
        -ms-flex-pack: end;
        -webkit-justify-content: flex-end;
        justify-content: flex-end;
      };

      --layout-around-justified: {
        -ms-flex-pack: distribute;
        -webkit-justify-content: space-around;
        justify-content: space-around;
      };

      --layout-justified: {
        -ms-flex-pack: justify;
        -webkit-justify-content: space-between;
        justify-content: space-between;
      };

      --layout-center-center: {
        @apply --layout-center;
        @apply --layout-center-justified;
      };

      /* self alignment */

      --layout-self-start: {
        -ms-align-self: flex-start;
        -webkit-align-self: flex-start;
        align-self: flex-start;
      };

      --layout-self-center: {
        -ms-align-self: center;
        -webkit-align-self: center;
        align-self: center;
      };

      --layout-self-end: {
        -ms-align-self: flex-end;
        -webkit-align-self: flex-end;
        align-self: flex-end;
      };

      --layout-self-stretch: {
        -ms-align-self: stretch;
        -webkit-align-self: stretch;
        align-self: stretch;
      };

      --layout-self-baseline: {
        -ms-align-self: baseline;
        -webkit-align-self: baseline;
        align-self: baseline;
      };

      /* multi-line alignment in main axis */

      --layout-start-aligned: {
        -ms-flex-line-pack: start;  /* IE10 */
        -ms-align-content: flex-start;
        -webkit-align-content: flex-start;
        align-content: flex-start;
      };

      --layout-end-aligned: {
        -ms-flex-line-pack: end;  /* IE10 */
        -ms-align-content: flex-end;
        -webkit-align-content: flex-end;
        align-content: flex-end;
      };

      --layout-center-aligned: {
        -ms-flex-line-pack: center;  /* IE10 */
        -ms-align-content: center;
        -webkit-align-content: center;
        align-content: center;
      };

      --layout-between-aligned: {
        -ms-flex-line-pack: justify;  /* IE10 */
        -ms-align-content: space-between;
        -webkit-align-content: space-between;
        align-content: space-between;
      };

      --layout-around-aligned: {
        -ms-flex-line-pack: distribute;  /* IE10 */
        -ms-align-content: space-around;
        -webkit-align-content: space-around;
        align-content: space-around;
      };

      /*******************************
                Other Layout
      *******************************/

      --layout-block: {
        display: block;
      };

      --layout-invisible: {
        visibility: hidden !important;
      };

      --layout-relative: {
        position: relative;
      };

      --layout-fit: {
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
      };

      --layout-scroll: {
        -webkit-overflow-scrolling: touch;
        overflow: auto;
      };

      --layout-fullbleed: {
        margin: 0;
        height: 100vh;
      };

      /* fixed position */

      --layout-fixed-top: {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
      };

      --layout-fixed-right: {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
      };

      --layout-fixed-bottom: {
        position: fixed;
        right: 0;
        bottom: 0;
        left: 0;
      };

      --layout-fixed-left: {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
      };

    }
  </style>
</custom-style>`;template$m.setAttribute("style","display: none;"),document.head.appendChild(template$m.content);var style=document.createElement("style");style.textContent="[hidden] { display: none !important; }",document.head.appendChild(style);
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */
class IronMeta{constructor(e){IronMeta[" "](e),this.type=e&&e.type||"default",this.key=e&&e.key,e&&"value"in e&&(this.value=e.value)}get value(){var e=this.type,t=this.key;if(e&&t)return IronMeta.types[e]&&IronMeta.types[e][t]}set value(e){var t=this.type,n=this.key;t&&n&&(t=IronMeta.types[t]=IronMeta.types[t]||{},null==e?delete t[n]:t[n]=e)}get list(){if(this.type){var e=IronMeta.types[this.type];return e?Object.keys(e).map((function(e){return metaDatas[this.type][e]}),this):[]}}byKey(e){return this.key=e,this.value}}IronMeta[" "]=function(){},IronMeta.types={};var metaDatas=IronMeta.types;Polymer({is:"iron-meta",properties:{type:{type:String,value:"default"},key:{type:String},value:{type:String,notify:!0},self:{type:Boolean,observer:"_selfChanged"},__meta:{type:Boolean,computed:"__computeMeta(type, key, value)"}},hostAttributes:{hidden:!0},__computeMeta:function(e,t,n){var r=new IronMeta({type:e,key:t});return void 0!==n&&n!==r.value?r.value=n:this.value!==r.value&&(this.value=r.value),r},get list(){return this.__meta&&this.__meta.list},_selfChanged:function(e){e&&(this.value=this)},byKey:function(e){return new IronMeta({type:this.type,key:e}).value}}),
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */
Polymer({_template:html`
    <style>
      :host {
        @apply --layout-inline;
        @apply --layout-center-center;
        position: relative;

        vertical-align: middle;

        fill: var(--iron-icon-fill-color, currentcolor);
        stroke: var(--iron-icon-stroke-color, none);

        width: var(--iron-icon-width, 24px);
        height: var(--iron-icon-height, 24px);
        @apply --iron-icon;
      }

      :host([hidden]) {
        display: none;
      }
    </style>
`,is:"iron-icon",properties:{icon:{type:String},theme:{type:String},src:{type:String},_meta:{value:Base.create("iron-meta",{type:"iconset"})}},observers:["_updateIcon(_meta, isAttached)","_updateIcon(theme, isAttached)","_srcChanged(src, isAttached)","_iconChanged(icon, isAttached)"],_DEFAULT_ICONSET:"icons",_iconChanged:function(e){var t=(e||"").split(":");this._iconName=t.pop(),this._iconsetName=t.pop()||this._DEFAULT_ICONSET,this._updateIcon()},_srcChanged:function(e){this._updateIcon()},_usesIconset:function(){return this.icon||!this.src},_updateIcon:function(){this._usesIconset()?(this._img&&this._img.parentNode&&dom$1(this.root).removeChild(this._img),""===this._iconName?this._iconset&&this._iconset.removeIcon(this):this._iconsetName&&this._meta&&(this._iconset=this._meta.byKey(this._iconsetName),this._iconset?(this._iconset.applyIcon(this,this._iconName,this.theme),this.unlisten(window,"iron-iconset-added","_updateIcon")):this.listen(window,"iron-iconset-added","_updateIcon"))):(this._iconset&&this._iconset.removeIcon(this),this._img||(this._img=document.createElement("img"),this._img.style.width="100%",this._img.style.height="100%",this._img.draggable=!1),this._img.src=this.src,dom$1(this.root).appendChild(this._img))}}),
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */
Polymer({is:"iron-iconset-svg",properties:{name:{type:String,observer:"_nameChanged"},size:{type:Number,value:24},rtlMirroring:{type:Boolean,value:!1},useGlobalRtlAttribute:{type:Boolean,value:!1}},created:function(){this._meta=new IronMeta({type:"iconset",key:null,value:null})},attached:function(){this.style.display="none"},getIconNames:function(){return this._icons=this._createIconMap(),Object.keys(this._icons).map((function(e){return this.name+":"+e}),this)},applyIcon:function(e,t){this.removeIcon(e);var n=this._cloneIcon(t,this.rtlMirroring&&this._targetIsRTL(e));if(n){var r=dom$1(e.root||e);return r.insertBefore(n,r.childNodes[0]),e._svgIcon=n}return null},removeIcon:function(e){e._svgIcon&&(dom$1(e.root||e).removeChild(e._svgIcon),e._svgIcon=null)},_targetIsRTL:function(e){if(null==this.__targetIsRTL)if(this.useGlobalRtlAttribute){var t=document.body&&document.body.hasAttribute("dir")?document.body:document.documentElement;this.__targetIsRTL="rtl"===t.getAttribute("dir")}else e&&e.nodeType!==Node.ELEMENT_NODE&&(e=e.host),this.__targetIsRTL=e&&"rtl"===window.getComputedStyle(e).direction;return this.__targetIsRTL},_nameChanged:function(){this._meta.value=null,this._meta.key=this.name,this._meta.value=this,this.async((function(){this.fire("iron-iconset-added",this,{node:window})}))},_createIconMap:function(){var e=Object.create(null);return dom$1(this).querySelectorAll("[id]").forEach((function(t){e[t.id]=t})),e},_cloneIcon:function(e,t){return this._icons=this._icons||this._createIconMap(),this._prepareSvgClone(this._icons[e],this.size,t)},_prepareSvgClone:function(e,t,n){if(e){var r=e.cloneNode(!0),i=document.createElementNS("http://www.w3.org/2000/svg","svg"),a=r.getAttribute("viewBox")||"0 0 "+t+" "+t,o="pointer-events: none; display: block; width: 100%; height: 100%;";return n&&r.hasAttribute("mirror-in-rtl")&&(o+="-webkit-transform:scale(-1,1);transform:scale(-1,1);transform-origin:center;"),i.setAttribute("viewBox",a),i.setAttribute("preserveAspectRatio","xMidYMid meet"),i.setAttribute("focusable","false"),i.style.cssText=o,i.appendChild(r).removeAttribute("id"),i}return null}});
/**
    @license
    Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */
const template$l=html`<iron-iconset-svg name="image" size="24">
<svg><defs>
<g id="add-a-photo"><path d="M3 4V1h2v3h3v2H5v3H3V6H0V4h3zm3 6V7h3V4h7l1.83 2H21c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H5c-1.1 0-2-.9-2-2V10h3zm7 9c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm-3.2-5c0 1.77 1.43 3.2 3.2 3.2s3.2-1.43 3.2-3.2-1.43-3.2-3.2-3.2-3.2 1.43-3.2 3.2z"></path></g>
<g id="add-to-photos"><path d="M4 6H2v14c0 1.1.9 2 2 2h14v-2H4V6zm16-4H8c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-1 9h-4v4h-2v-4H9V9h4V5h2v4h4v2z"></path></g>
<g id="adjust"><path d="M12 2C6.49 2 2 6.49 2 12s4.49 10 10 10 10-4.49 10-10S17.51 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm3-8c0 1.66-1.34 3-3 3s-3-1.34-3-3 1.34-3 3-3 3 1.34 3 3z"></path></g>
<g id="assistant"><path d="M19 2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h4l3 3 3-3h4c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-5.12 10.88L12 17l-1.88-4.12L6 11l4.12-1.88L12 5l1.88 4.12L18 11l-4.12 1.88z"></path></g>
<g id="assistant-photo"><path d="M14.4 6L14 4H5v17h2v-7h5.6l.4 2h7V6z"></path></g>
<g id="audiotrack"><path d="M12 3v9.28c-.47-.17-.97-.28-1.5-.28C8.01 12 6 14.01 6 16.5S8.01 21 10.5 21c2.31 0 4.2-1.75 4.45-4H15V6h4V3h-7z"></path></g>
<g id="blur-circular"><path d="M10 9c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm0 4c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zM7 9.5c-.28 0-.5.22-.5.5s.22.5.5.5.5-.22.5-.5-.22-.5-.5-.5zm3 7c-.28 0-.5.22-.5.5s.22.5.5.5.5-.22.5-.5-.22-.5-.5-.5zm-3-3c-.28 0-.5.22-.5.5s.22.5.5.5.5-.22.5-.5-.22-.5-.5-.5zm3-6c.28 0 .5-.22.5-.5s-.22-.5-.5-.5-.5.22-.5.5.22.5.5.5zM14 9c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm0-1.5c.28 0 .5-.22.5-.5s-.22-.5-.5-.5-.5.22-.5.5.22.5.5.5zm3 6c-.28 0-.5.22-.5.5s.22.5.5.5.5-.22.5-.5-.22-.5-.5-.5zm0-4c-.28 0-.5.22-.5.5s.22.5.5.5.5-.22.5-.5-.22-.5-.5-.5zM12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8zm2-3.5c-.28 0-.5.22-.5.5s.22.5.5.5.5-.22.5-.5-.22-.5-.5-.5zm0-3.5c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1z"></path></g>
<g id="blur-linear"><path d="M5 17.5c.83 0 1.5-.67 1.5-1.5s-.67-1.5-1.5-1.5-1.5.67-1.5 1.5.67 1.5 1.5 1.5zM9 13c.55 0 1-.45 1-1s-.45-1-1-1-1 .45-1 1 .45 1 1 1zm0-4c.55 0 1-.45 1-1s-.45-1-1-1-1 .45-1 1 .45 1 1 1zM3 21h18v-2H3v2zM5 9.5c.83 0 1.5-.67 1.5-1.5S5.83 6.5 5 6.5 3.5 7.17 3.5 8 4.17 9.5 5 9.5zm0 4c.83 0 1.5-.67 1.5-1.5s-.67-1.5-1.5-1.5-1.5.67-1.5 1.5.67 1.5 1.5 1.5zM9 17c.55 0 1-.45 1-1s-.45-1-1-1-1 .45-1 1 .45 1 1 1zm8-.5c.28 0 .5-.22.5-.5s-.22-.5-.5-.5-.5.22-.5.5.22.5.5.5zM3 3v2h18V3H3zm14 5.5c.28 0 .5-.22.5-.5s-.22-.5-.5-.5-.5.22-.5.5.22.5.5.5zm0 4c.28 0 .5-.22.5-.5s-.22-.5-.5-.5-.5.22-.5.5.22.5.5.5zM13 9c.55 0 1-.45 1-1s-.45-1-1-1-1 .45-1 1 .45 1 1 1zm0 4c.55 0 1-.45 1-1s-.45-1-1-1-1 .45-1 1 .45 1 1 1zm0 4c.55 0 1-.45 1-1s-.45-1-1-1-1 .45-1 1 .45 1 1 1z"></path></g>
<g id="blur-off"><path d="M14 7c.55 0 1-.45 1-1s-.45-1-1-1-1 .45-1 1 .45 1 1 1zm-.2 4.48l.2.02c.83 0 1.5-.67 1.5-1.5s-.67-1.5-1.5-1.5-1.5.67-1.5 1.5l.02.2c.09.67.61 1.19 1.28 1.28zM14 3.5c.28 0 .5-.22.5-.5s-.22-.5-.5-.5-.5.22-.5.5.22.5.5.5zm-4 0c.28 0 .5-.22.5-.5s-.22-.5-.5-.5-.5.22-.5.5.22.5.5.5zm11 7c.28 0 .5-.22.5-.5s-.22-.5-.5-.5-.5.22-.5.5.22.5.5.5zM10 7c.55 0 1-.45 1-1s-.45-1-1-1-1 .45-1 1 .45 1 1 1zm8 8c.55 0 1-.45 1-1s-.45-1-1-1-1 .45-1 1 .45 1 1 1zm0-4c.55 0 1-.45 1-1s-.45-1-1-1-1 .45-1 1 .45 1 1 1zm0-4c.55 0 1-.45 1-1s-.45-1-1-1-1 .45-1 1 .45 1 1 1zm-4 13.5c-.28 0-.5.22-.5.5s.22.5.5.5.5-.22.5-.5-.22-.5-.5-.5zM2.5 5.27l3.78 3.78L6 9c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1c0-.1-.03-.19-.06-.28l2.81 2.81c-.71.11-1.25.73-1.25 1.47 0 .83.67 1.5 1.5 1.5.74 0 1.36-.54 1.47-1.25l2.81 2.81c-.09-.03-.18-.06-.28-.06-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1c0-.1-.03-.19-.06-.28l3.78 3.78L20 20.23 3.77 4 2.5 5.27zM10 17c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm11-3.5c-.28 0-.5.22-.5.5s.22.5.5.5.5-.22.5-.5-.22-.5-.5-.5zM6 13c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zM3 9.5c-.28 0-.5.22-.5.5s.22.5.5.5.5-.22.5-.5-.22-.5-.5-.5zm7 11c-.28 0-.5.22-.5.5s.22.5.5.5.5-.22.5-.5-.22-.5-.5-.5zM6 17c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm-3-3.5c-.28 0-.5.22-.5.5s.22.5.5.5.5-.22.5-.5-.22-.5-.5-.5z"></path></g>
<g id="blur-on"><path d="M6 13c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm0 4c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm0-8c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm-3 .5c-.28 0-.5.22-.5.5s.22.5.5.5.5-.22.5-.5-.22-.5-.5-.5zM6 5c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm15 5.5c.28 0 .5-.22.5-.5s-.22-.5-.5-.5-.5.22-.5.5.22.5.5.5zM14 7c.55 0 1-.45 1-1s-.45-1-1-1-1 .45-1 1 .45 1 1 1zm0-3.5c.28 0 .5-.22.5-.5s-.22-.5-.5-.5-.5.22-.5.5.22.5.5.5zm-11 10c-.28 0-.5.22-.5.5s.22.5.5.5.5-.22.5-.5-.22-.5-.5-.5zm7 7c-.28 0-.5.22-.5.5s.22.5.5.5.5-.22.5-.5-.22-.5-.5-.5zm0-17c.28 0 .5-.22.5-.5s-.22-.5-.5-.5-.5.22-.5.5.22.5.5.5zM10 7c.55 0 1-.45 1-1s-.45-1-1-1-1 .45-1 1 .45 1 1 1zm0 5.5c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5zm8 .5c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm0 4c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm0-8c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm0-4c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm3 8.5c-.28 0-.5.22-.5.5s.22.5.5.5.5-.22.5-.5-.22-.5-.5-.5zM14 17c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm0 3.5c-.28 0-.5.22-.5.5s.22.5.5.5.5-.22.5-.5-.22-.5-.5-.5zm-4-12c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5zm0 8.5c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm4-4.5c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5zm0-4c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5z"></path></g>
<g id="brightness-1"><circle cx="12" cy="12" r="10"></circle></g>
<g id="brightness-2"><path d="M10 2c-1.82 0-3.53.5-5 1.35C7.99 5.08 10 8.3 10 12s-2.01 6.92-5 8.65C6.47 21.5 8.18 22 10 22c5.52 0 10-4.48 10-10S15.52 2 10 2z"></path></g>
<g id="brightness-3"><path d="M9 2c-1.05 0-2.05.16-3 .46 4.06 1.27 7 5.06 7 9.54 0 4.48-2.94 8.27-7 9.54.95.3 1.95.46 3 .46 5.52 0 10-4.48 10-10S14.52 2 9 2z"></path></g>
<g id="brightness-4"><path d="M20 8.69V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12 20 8.69zM12 18c-.89 0-1.74-.2-2.5-.55C11.56 16.5 13 14.42 13 12s-1.44-4.5-3.5-5.45C10.26 6.2 11.11 6 12 6c3.31 0 6 2.69 6 6s-2.69 6-6 6z"></path></g>
<g id="brightness-5"><path d="M20 15.31L23.31 12 20 8.69V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69zM12 18c-3.31 0-6-2.69-6-6s2.69-6 6-6 6 2.69 6 6-2.69 6-6 6z"></path></g>
<g id="brightness-6"><path d="M20 15.31L23.31 12 20 8.69V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69zM12 18V6c3.31 0 6 2.69 6 6s-2.69 6-6 6z"></path></g>
<g id="brightness-7"><path d="M20 8.69V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12 20 8.69zM12 18c-3.31 0-6-2.69-6-6s2.69-6 6-6 6 2.69 6 6-2.69 6-6 6zm0-10c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4-1.79-4-4-4z"></path></g>
<g id="broken-image"><path d="M21 5v6.59l-3-3.01-4 4.01-4-4-4 4-3-3.01V5c0-1.1.9-2 2-2h14c1.1 0 2 .9 2 2zm-3 6.42l3 3.01V19c0 1.1-.9 2-2 2H5c-1.1 0-2-.9-2-2v-6.58l3 2.99 4-4 4 4 4-3.99z"></path></g>
<g id="brush"><path d="M7 14c-1.66 0-3 1.34-3 3 0 1.31-1.16 2-2 2 .92 1.22 2.49 2 4 2 2.21 0 4-1.79 4-4 0-1.66-1.34-3-3-3zm13.71-9.37l-1.34-1.34c-.39-.39-1.02-.39-1.41 0L9 12.25 11.75 15l8.96-8.96c.39-.39.39-1.02 0-1.41z"></path></g>
<g id="burst-mode"><path d="M1 5h2v14H1zm4 0h2v14H5zm17 0H10c-.55 0-1 .45-1 1v12c0 .55.45 1 1 1h12c.55 0 1-.45 1-1V6c0-.55-.45-1-1-1zM11 17l2.5-3.15L15.29 16l2.5-3.22L21 17H11z"></path></g>
<g id="camera"><path d="M9.4 10.5l4.77-8.26C13.47 2.09 12.75 2 12 2c-2.4 0-4.6.85-6.32 2.25l3.66 6.35.06-.1zM21.54 9c-.92-2.92-3.15-5.26-6-6.34L11.88 9h9.66zm.26 1h-7.49l.29.5 4.76 8.25C21 16.97 22 14.61 22 12c0-.69-.07-1.35-.2-2zM8.54 12l-3.9-6.75C3.01 7.03 2 9.39 2 12c0 .69.07 1.35.2 2h7.49l-1.15-2zm-6.08 3c.92 2.92 3.15 5.26 6 6.34L12.12 15H2.46zm11.27 0l-3.9 6.76c.7.15 1.42.24 2.17.24 2.4 0 4.6-.85 6.32-2.25l-3.66-6.35-.93 1.6z"></path></g>
<g id="camera-alt"><circle cx="12" cy="12" r="3.2"></circle><path d="M9 2L7.17 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2h-3.17L15 2H9zm3 15c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5z"></path></g>
<g id="camera-front"><path d="M10 20H5v2h5v2l3-3-3-3v2zm4 0v2h5v-2h-5zM12 8c1.1 0 2-.9 2-2s-.9-2-2-2-1.99.9-1.99 2S10.9 8 12 8zm5-8H7C5.9 0 5 .9 5 2v14c0 1.1.9 2 2 2h10c1.1 0 2-.9 2-2V2c0-1.1-.9-2-2-2zM7 2h10v10.5c0-1.67-3.33-2.5-5-2.5s-5 .83-5 2.5V2z"></path></g>
<g id="camera-rear"><path d="M10 20H5v2h5v2l3-3-3-3v2zm4 0v2h5v-2h-5zm3-20H7C5.9 0 5 .9 5 2v14c0 1.1.9 2 2 2h10c1.1 0 2-.9 2-2V2c0-1.1-.9-2-2-2zm-5 6c-1.11 0-2-.9-2-2s.89-2 1.99-2 2 .9 2 2C14 5.1 13.1 6 12 6z"></path></g>
<g id="camera-roll"><path d="M14 5c0-1.1-.9-2-2-2h-1V2c0-.55-.45-1-1-1H6c-.55 0-1 .45-1 1v1H4c-1.1 0-2 .9-2 2v15c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2h8V5h-8zm-2 13h-2v-2h2v2zm0-9h-2V7h2v2zm4 9h-2v-2h2v2zm0-9h-2V7h2v2zm4 9h-2v-2h2v2zm0-9h-2V7h2v2z"></path></g>
<g id="center-focus-strong"><path d="M12 8c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4-1.79-4-4-4zm-7 7H3v4c0 1.1.9 2 2 2h4v-2H5v-4zM5 5h4V3H5c-1.1 0-2 .9-2 2v4h2V5zm14-2h-4v2h4v4h2V5c0-1.1-.9-2-2-2zm0 16h-4v2h4c1.1 0 2-.9 2-2v-4h-2v4z"></path></g>
<g id="center-focus-weak"><path d="M5 15H3v4c0 1.1.9 2 2 2h4v-2H5v-4zM5 5h4V3H5c-1.1 0-2 .9-2 2v4h2V5zm14-2h-4v2h4v4h2V5c0-1.1-.9-2-2-2zm0 16h-4v2h4c1.1 0 2-.9 2-2v-4h-2v4zM12 8c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4-1.79-4-4-4zm0 6c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2z"></path></g>
<g id="collections"><path d="M22 16V4c0-1.1-.9-2-2-2H8c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2zm-11-4l2.03 2.71L16 11l4 5H8l3-4zM2 6v14c0 1.1.9 2 2 2h14v-2H4V6H2z"></path></g>
<g id="collections-bookmark"><path d="M4 6H2v14c0 1.1.9 2 2 2h14v-2H4V6zm16-4H8c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm0 10l-2.5-1.5L15 12V4h5v8z"></path></g>
<g id="color-lens"><path d="M12 3c-4.97 0-9 4.03-9 9s4.03 9 9 9c.83 0 1.5-.67 1.5-1.5 0-.39-.15-.74-.39-1.01-.23-.26-.38-.61-.38-.99 0-.83.67-1.5 1.5-1.5H16c2.76 0 5-2.24 5-5 0-4.42-4.03-8-9-8zm-5.5 9c-.83 0-1.5-.67-1.5-1.5S5.67 9 6.5 9 8 9.67 8 10.5 7.33 12 6.5 12zm3-4C8.67 8 8 7.33 8 6.5S8.67 5 9.5 5s1.5.67 1.5 1.5S10.33 8 9.5 8zm5 0c-.83 0-1.5-.67-1.5-1.5S13.67 5 14.5 5s1.5.67 1.5 1.5S15.33 8 14.5 8zm3 4c-.83 0-1.5-.67-1.5-1.5S16.67 9 17.5 9s1.5.67 1.5 1.5-.67 1.5-1.5 1.5z"></path></g>
<g id="colorize"><path d="M20.71 5.63l-2.34-2.34c-.39-.39-1.02-.39-1.41 0l-3.12 3.12-1.93-1.91-1.41 1.41 1.42 1.42L3 16.25V21h4.75l8.92-8.92 1.42 1.42 1.41-1.41-1.92-1.92 3.12-3.12c.4-.4.4-1.03.01-1.42zM6.92 19L5 17.08l8.06-8.06 1.92 1.92L6.92 19z"></path></g>
<g id="compare"><path d="M10 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h5v2h2V1h-2v2zm0 15H5l5-6v6zm9-15h-5v2h5v13l-5-6v9h5c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2z"></path></g>
<g id="control-point"><path d="M13 7h-2v4H7v2h4v4h2v-4h4v-2h-4V7zm-1-5C6.49 2 2 6.49 2 12s4.49 10 10 10 10-4.49 10-10S17.51 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z"></path></g>
<g id="control-point-duplicate"><path d="M16 8h-2v3h-3v2h3v3h2v-3h3v-2h-3zM2 12c0-2.79 1.64-5.2 4.01-6.32V3.52C2.52 4.76 0 8.09 0 12s2.52 7.24 6.01 8.48v-2.16C3.64 17.2 2 14.79 2 12zm13-9c-4.96 0-9 4.04-9 9s4.04 9 9 9 9-4.04 9-9-4.04-9-9-9zm0 16c-3.86 0-7-3.14-7-7s3.14-7 7-7 7 3.14 7 7-3.14 7-7 7z"></path></g>
<g id="crop"><path d="M17 15h2V7c0-1.1-.9-2-2-2H9v2h8v8zM7 17V1H5v4H1v2h4v10c0 1.1.9 2 2 2h10v4h2v-4h4v-2H7z"></path></g>
<g id="crop-16-9"><path d="M19 6H5c-1.1 0-2 .9-2 2v8c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2zm0 10H5V8h14v8z"></path></g>
<g id="crop-3-2"><path d="M19 4H5c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 14H5V6h14v12z"></path></g>
<g id="crop-5-4"><path d="M19 5H5c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 12H5V7h14v10z"></path></g>
<g id="crop-7-5"><path d="M19 7H5c-1.1 0-2 .9-2 2v6c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V9c0-1.1-.9-2-2-2zm0 8H5V9h14v6z"></path></g>
<g id="crop-din"><path d="M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H5V5h14v14z"></path></g>
<g id="crop-free"><path d="M3 5v4h2V5h4V3H5c-1.1 0-2 .9-2 2zm2 10H3v4c0 1.1.9 2 2 2h4v-2H5v-4zm14 4h-4v2h4c1.1 0 2-.9 2-2v-4h-2v4zm0-16h-4v2h4v4h2V5c0-1.1-.9-2-2-2z"></path></g>
<g id="crop-landscape"><path d="M19 5H5c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 12H5V7h14v10z"></path></g>
<g id="crop-original"><path d="M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H5V5h14v14zm-5.04-6.71l-2.75 3.54-1.96-2.36L6.5 17h11l-3.54-4.71z"></path></g>
<g id="crop-portrait"><path d="M17 3H7c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h10c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H7V5h10v14z"></path></g>
<g id="crop-rotate"><path d="M7.47 21.49C4.2 19.93 1.86 16.76 1.5 13H0c.51 6.16 5.66 11 11.95 11 .23 0 .44-.02.66-.03L8.8 20.15l-1.33 1.34zM12.05 0c-.23 0-.44.02-.66.04l3.81 3.81 1.33-1.33C19.8 4.07 22.14 7.24 22.5 11H24c-.51-6.16-5.66-11-11.95-11zM16 14h2V8c0-1.11-.9-2-2-2h-6v2h6v6zm-8 2V4H6v2H4v2h2v8c0 1.1.89 2 2 2h8v2h2v-2h2v-2H8z"></path></g>
<g id="crop-square"><path d="M18 4H6c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 14H6V6h12v12z"></path></g>
<g id="dehaze"><path d="M2 15.5v2h20v-2H2zm0-5v2h20v-2H2zm0-5v2h20v-2H2z"></path></g>
<g id="details"><path d="M3 4l9 16 9-16H3zm3.38 2h11.25L12 16 6.38 6z"></path></g>
<g id="edit"><path d="M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.39-.39-1.02-.39-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z"></path></g>
<g id="exposure"><path d="M15 17v2h2v-2h2v-2h-2v-2h-2v2h-2v2h2zm5-15H4c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zM5 5h6v2H5V5zm15 15H4L20 4v16z"></path></g>
<g id="exposure-neg-1"><path d="M4 11v2h8v-2H4zm15 7h-2V7.38L14 8.4V6.7L18.7 5h.3v13z"></path></g>
<g id="exposure-neg-2"><path d="M15.05 16.29l2.86-3.07c.38-.39.72-.79 1.04-1.18.32-.39.59-.78.82-1.17.23-.39.41-.78.54-1.17s.19-.79.19-1.18c0-.53-.09-1.02-.27-1.46-.18-.44-.44-.81-.78-1.11-.34-.31-.77-.54-1.26-.71-.51-.16-1.08-.24-1.72-.24-.69 0-1.31.11-1.85.32-.54.21-1 .51-1.36.88-.37.37-.65.8-.84 1.3-.18.47-.27.97-.28 1.5h2.14c.01-.31.05-.6.13-.87.09-.29.23-.54.4-.75.18-.21.41-.37.68-.49.27-.12.6-.18.96-.18.31 0 .58.05.81.15.23.1.43.25.59.43.16.18.28.4.37.65.08.25.13.52.13.81 0 .22-.03.43-.08.65-.06.22-.15.45-.29.7-.14.25-.32.53-.56.83-.23.3-.52.65-.88 1.03l-4.17 4.55V18H21v-1.71h-5.95zM2 11v2h8v-2H2z"></path></g>
<g id="exposure-plus-1"><path d="M10 7H8v4H4v2h4v4h2v-4h4v-2h-4V7zm10 11h-2V7.38L15 8.4V6.7L19.7 5h.3v13z"></path></g>
<g id="exposure-plus-2"><path d="M16.05 16.29l2.86-3.07c.38-.39.72-.79 1.04-1.18.32-.39.59-.78.82-1.17.23-.39.41-.78.54-1.17.13-.39.19-.79.19-1.18 0-.53-.09-1.02-.27-1.46-.18-.44-.44-.81-.78-1.11-.34-.31-.77-.54-1.26-.71-.51-.16-1.08-.24-1.72-.24-.69 0-1.31.11-1.85.32-.54.21-1 .51-1.36.88-.37.37-.65.8-.84 1.3-.18.47-.27.97-.28 1.5h2.14c.01-.31.05-.6.13-.87.09-.29.23-.54.4-.75.18-.21.41-.37.68-.49.27-.12.6-.18.96-.18.31 0 .58.05.81.15.23.1.43.25.59.43.16.18.28.4.37.65.08.25.13.52.13.81 0 .22-.03.43-.08.65-.06.22-.15.45-.29.7-.14.25-.32.53-.56.83-.23.3-.52.65-.88 1.03l-4.17 4.55V18H22v-1.71h-5.95zM8 7H6v4H2v2h4v4h2v-4h4v-2H8V7z"></path></g>
<g id="exposure-zero"><path d="M16.14 12.5c0 1-.1 1.85-.3 2.55-.2.7-.48 1.27-.83 1.7-.36.44-.79.75-1.3.95-.51.2-1.07.3-1.7.3-.62 0-1.18-.1-1.69-.3-.51-.2-.95-.51-1.31-.95-.36-.44-.65-1.01-.85-1.7-.2-.7-.3-1.55-.3-2.55v-2.04c0-1 .1-1.85.3-2.55.2-.7.48-1.26.84-1.69.36-.43.8-.74 1.31-.93C10.81 5.1 11.38 5 12 5c.63 0 1.19.1 1.7.29.51.19.95.5 1.31.93.36.43.64.99.84 1.69.2.7.3 1.54.3 2.55v2.04zm-2.11-2.36c0-.64-.05-1.18-.13-1.62-.09-.44-.22-.79-.4-1.06-.17-.27-.39-.46-.64-.58-.25-.13-.54-.19-.86-.19-.32 0-.61.06-.86.18s-.47.31-.64.58c-.17.27-.31.62-.4 1.06s-.13.98-.13 1.62v2.67c0 .64.05 1.18.14 1.62.09.45.23.81.4 1.09s.39.48.64.61.54.19.87.19c.33 0 .62-.06.87-.19s.46-.33.63-.61c.17-.28.3-.64.39-1.09.09-.45.13-.99.13-1.62v-2.66z"></path></g>
<g id="filter"><path d="M15.96 10.29l-2.75 3.54-1.96-2.36L8.5 15h11l-3.54-4.71zM3 5H1v16c0 1.1.9 2 2 2h16v-2H3V5zm18-4H7c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V3c0-1.1-.9-2-2-2zm0 16H7V3h14v14z"></path></g>
<g id="filter-1"><path d="M3 5H1v16c0 1.1.9 2 2 2h16v-2H3V5zm11 10h2V5h-4v2h2v8zm7-14H7c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V3c0-1.1-.9-2-2-2zm0 16H7V3h14v14z"></path></g>
<g id="filter-2"><path d="M3 5H1v16c0 1.1.9 2 2 2h16v-2H3V5zm18-4H7c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V3c0-1.1-.9-2-2-2zm0 16H7V3h14v14zm-4-4h-4v-2h2c1.1 0 2-.89 2-2V7c0-1.11-.9-2-2-2h-4v2h4v2h-2c-1.1 0-2 .89-2 2v4h6v-2z"></path></g>
<g id="filter-3"><path d="M21 1H7c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V3c0-1.1-.9-2-2-2zm0 16H7V3h14v14zM3 5H1v16c0 1.1.9 2 2 2h16v-2H3V5zm14 8v-1.5c0-.83-.67-1.5-1.5-1.5.83 0 1.5-.67 1.5-1.5V7c0-1.11-.9-2-2-2h-4v2h4v2h-2v2h2v2h-4v2h4c1.1 0 2-.89 2-2z"></path></g>
<g id="filter-4"><path d="M3 5H1v16c0 1.1.9 2 2 2h16v-2H3V5zm12 10h2V5h-2v4h-2V5h-2v6h4v4zm6-14H7c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V3c0-1.1-.9-2-2-2zm0 16H7V3h14v14z"></path></g>
<g id="filter-5"><path d="M21 1H7c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V3c0-1.1-.9-2-2-2zm0 16H7V3h14v14zM3 5H1v16c0 1.1.9 2 2 2h16v-2H3V5zm14 8v-2c0-1.11-.9-2-2-2h-2V7h4V5h-6v6h4v2h-4v2h4c1.1 0 2-.89 2-2z"></path></g>
<g id="filter-6"><path d="M3 5H1v16c0 1.1.9 2 2 2h16v-2H3V5zm18-4H7c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V3c0-1.1-.9-2-2-2zm0 16H7V3h14v14zm-8-2h2c1.1 0 2-.89 2-2v-2c0-1.11-.9-2-2-2h-2V7h4V5h-4c-1.1 0-2 .89-2 2v6c0 1.11.9 2 2 2zm0-4h2v2h-2v-2z"></path></g>
<g id="filter-7"><path d="M3 5H1v16c0 1.1.9 2 2 2h16v-2H3V5zm18-4H7c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V3c0-1.1-.9-2-2-2zm0 16H7V3h14v14zm-8-2l4-8V5h-6v2h4l-4 8h2z"></path></g>
<g id="filter-8"><path d="M3 5H1v16c0 1.1.9 2 2 2h16v-2H3V5zm18-4H7c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V3c0-1.1-.9-2-2-2zm0 16H7V3h14v14zm-8-2h2c1.1 0 2-.89 2-2v-1.5c0-.83-.67-1.5-1.5-1.5.83 0 1.5-.67 1.5-1.5V7c0-1.11-.9-2-2-2h-2c-1.1 0-2 .89-2 2v1.5c0 .83.67 1.5 1.5 1.5-.83 0-1.5.67-1.5 1.5V13c0 1.11.9 2 2 2zm0-8h2v2h-2V7zm0 4h2v2h-2v-2z"></path></g>
<g id="filter-9"><path d="M3 5H1v16c0 1.1.9 2 2 2h16v-2H3V5zm18-4H7c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V3c0-1.1-.9-2-2-2zm0 16H7V3h14v14zM15 5h-2c-1.1 0-2 .89-2 2v2c0 1.11.9 2 2 2h2v2h-4v2h4c1.1 0 2-.89 2-2V7c0-1.11-.9-2-2-2zm0 4h-2V7h2v2z"></path></g>
<g id="filter-9-plus"><path d="M3 5H1v16c0 1.1.9 2 2 2h16v-2H3V5zm11 7V8c0-1.11-.9-2-2-2h-1c-1.1 0-2 .89-2 2v1c0 1.11.9 2 2 2h1v1H9v2h3c1.1 0 2-.89 2-2zm-3-3V8h1v1h-1zm10-8H7c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V3c0-1.1-.9-2-2-2zm0 8h-2V7h-2v2h-2v2h2v2h2v-2h2v6H7V3h14v6z"></path></g>
<g id="filter-b-and-w"><path d="M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16l-7-8v8H5l7-8V5h7v14z"></path></g>
<g id="filter-center-focus"><path d="M5 15H3v4c0 1.1.9 2 2 2h4v-2H5v-4zM5 5h4V3H5c-1.1 0-2 .9-2 2v4h2V5zm14-2h-4v2h4v4h2V5c0-1.1-.9-2-2-2zm0 16h-4v2h4c1.1 0 2-.9 2-2v-4h-2v4zM12 9c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3z"></path></g>
<g id="filter-drama"><path d="M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.61 5.64 5.36 8.04 2.35 8.36 0 10.9 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96zM19 18H6c-2.21 0-4-1.79-4-4s1.79-4 4-4 4 1.79 4 4h2c0-2.76-1.86-5.08-4.4-5.78C8.61 6.88 10.2 6 12 6c3.03 0 5.5 2.47 5.5 5.5v.5H19c1.65 0 3 1.35 3 3s-1.35 3-3 3z"></path></g>
<g id="filter-frames"><path d="M20 4h-4l-4-4-4 4H4c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 16H4V6h4.52l3.52-3.5L15.52 6H20v14zM18 8H6v10h12"></path></g>
<g id="filter-hdr"><path d="M14 6l-3.75 5 2.85 3.8-1.6 1.2C9.81 13.75 7 10 7 10l-6 8h22L14 6z"></path></g>
<g id="filter-none"><path d="M3 5H1v16c0 1.1.9 2 2 2h16v-2H3V5zm18-4H7c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V3c0-1.1-.9-2-2-2zm0 16H7V3h14v14z"></path></g>
<g id="filter-tilt-shift"><path d="M11 4.07V2.05c-2.01.2-3.84 1-5.32 2.21L7.1 5.69c1.11-.86 2.44-1.44 3.9-1.62zm7.32.19C16.84 3.05 15.01 2.25 13 2.05v2.02c1.46.18 2.79.76 3.9 1.62l1.42-1.43zM19.93 11h2.02c-.2-2.01-1-3.84-2.21-5.32L18.31 7.1c.86 1.11 1.44 2.44 1.62 3.9zM5.69 7.1L4.26 5.68C3.05 7.16 2.25 8.99 2.05 11h2.02c.18-1.46.76-2.79 1.62-3.9zM4.07 13H2.05c.2 2.01 1 3.84 2.21 5.32l1.43-1.43c-.86-1.1-1.44-2.43-1.62-3.89zM15 12c0-1.66-1.34-3-3-3s-3 1.34-3 3 1.34 3 3 3 3-1.34 3-3zm3.31 4.9l1.43 1.43c1.21-1.48 2.01-3.32 2.21-5.32h-2.02c-.18 1.45-.76 2.78-1.62 3.89zM13 19.93v2.02c2.01-.2 3.84-1 5.32-2.21l-1.43-1.43c-1.1.86-2.43 1.44-3.89 1.62zm-7.32-.19C7.16 20.95 9 21.75 11 21.95v-2.02c-1.46-.18-2.79-.76-3.9-1.62l-1.42 1.43z"></path></g>
<g id="filter-vintage"><path d="M18.7 12.4c-.28-.16-.57-.29-.86-.4.29-.11.58-.24.86-.4 1.92-1.11 2.99-3.12 3-5.19-1.79-1.03-4.07-1.11-6 0-.28.16-.54.35-.78.54.05-.31.08-.63.08-.95 0-2.22-1.21-4.15-3-5.19C10.21 1.85 9 3.78 9 6c0 .32.03.64.08.95-.24-.2-.5-.39-.78-.55-1.92-1.11-4.2-1.03-6 0 0 2.07 1.07 4.08 3 5.19.28.16.57.29.86.4-.29.11-.58.24-.86.4-1.92 1.11-2.99 3.12-3 5.19 1.79 1.03 4.07 1.11 6 0 .28-.16.54-.35.78-.54-.05.32-.08.64-.08.96 0 2.22 1.21 4.15 3 5.19 1.79-1.04 3-2.97 3-5.19 0-.32-.03-.64-.08-.95.24.2.5.38.78.54 1.92 1.11 4.2 1.03 6 0-.01-2.07-1.08-4.08-3-5.19zM12 16c-2.21 0-4-1.79-4-4s1.79-4 4-4 4 1.79 4 4-1.79 4-4 4z"></path></g>
<g id="flare"><path d="M7 11H1v2h6v-2zm2.17-3.24L7.05 5.64 5.64 7.05l2.12 2.12 1.41-1.41zM13 1h-2v6h2V1zm5.36 6.05l-1.41-1.41-2.12 2.12 1.41 1.41 2.12-2.12zM17 11v2h6v-2h-6zm-5-2c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3zm2.83 7.24l2.12 2.12 1.41-1.41-2.12-2.12-1.41 1.41zm-9.19.71l1.41 1.41 2.12-2.12-1.41-1.41-2.12 2.12zM11 23h2v-6h-2v6z"></path></g>
<g id="flash-auto"><path d="M3 2v12h3v9l7-12H9l4-9H3zm16 0h-2l-3.2 9h1.9l.7-2h3.2l.7 2h1.9L19 2zm-2.15 5.65L18 4l1.15 3.65h-2.3z"></path></g>
<g id="flash-off"><path d="M3.27 3L2 4.27l5 5V13h3v9l3.58-6.14L17.73 20 19 18.73 3.27 3zM17 10h-4l4-8H7v2.18l8.46 8.46L17 10z"></path></g>
<g id="flash-on"><path d="M7 2v11h3v9l7-12h-4l4-8z"></path></g>
<g id="flip"><path d="M15 21h2v-2h-2v2zm4-12h2V7h-2v2zM3 5v14c0 1.1.9 2 2 2h4v-2H5V5h4V3H5c-1.1 0-2 .9-2 2zm16-2v2h2c0-1.1-.9-2-2-2zm-8 20h2V1h-2v22zm8-6h2v-2h-2v2zM15 5h2V3h-2v2zm4 8h2v-2h-2v2zm0 8c1.1 0 2-.9 2-2h-2v2z"></path></g>
<g id="gradient"><path d="M11 9h2v2h-2zm-2 2h2v2H9zm4 0h2v2h-2zm2-2h2v2h-2zM7 9h2v2H7zm12-6H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM9 18H7v-2h2v2zm4 0h-2v-2h2v2zm4 0h-2v-2h2v2zm2-7h-2v2h2v2h-2v-2h-2v2h-2v-2h-2v2H9v-2H7v2H5v-2h2v-2H5V5h14v6z"></path></g>
<g id="grain"><path d="M10 12c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zM6 8c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 8c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm12-8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm-4 8c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm4-4c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm-4-4c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm-4-4c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"></path></g>
<g id="grid-off"><path d="M8 4v1.45l2 2V4h4v4h-3.45l2 2H14v1.45l2 2V10h4v4h-3.45l2 2H20v1.45l2 2V4c0-1.1-.9-2-2-2H4.55l2 2H8zm8 0h4v4h-4V4zM1.27 1.27L0 2.55l2 2V20c0 1.1.9 2 2 2h15.46l2 2 1.27-1.27L1.27 1.27zM10 12.55L11.45 14H10v-1.45zm-6-6L5.45 8H4V6.55zM8 20H4v-4h4v4zm0-6H4v-4h3.45l.55.55V14zm6 6h-4v-4h3.45l.55.54V20zm2 0v-1.46L17.46 20H16z"></path></g>
<g id="grid-on"><path d="M20 2H4c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zM8 20H4v-4h4v4zm0-6H4v-4h4v4zm0-6H4V4h4v4zm6 12h-4v-4h4v4zm0-6h-4v-4h4v4zm0-6h-4V4h4v4zm6 12h-4v-4h4v4zm0-6h-4v-4h4v4zm0-6h-4V4h4v4z"></path></g>
<g id="hdr-off"><path d="M17.5 15v-2h1.1l.9 2H21l-.9-2.1c.5-.2.9-.8.9-1.4v-1c0-.8-.7-1.5-1.5-1.5H16v4.9l1.1 1.1h.4zm0-4.5h2v1h-2v-1zm-4.5 0v.4l1.5 1.5v-1.9c0-.8-.7-1.5-1.5-1.5h-1.9l1.5 1.5h.4zm-3.5-1l-7-7-1.1 1L6.9 9h-.4v2h-2V9H3v6h1.5v-2.5h2V15H8v-4.9l1.5 1.5V15h3.4l7.6 7.6 1.1-1.1-12.1-12z"></path></g>
<g id="hdr-on"><path d="M21 11.5v-1c0-.8-.7-1.5-1.5-1.5H16v6h1.5v-2h1.1l.9 2H21l-.9-2.1c.5-.3.9-.8.9-1.4zm-1.5 0h-2v-1h2v1zm-13-.5h-2V9H3v6h1.5v-2.5h2V15H8V9H6.5v2zM13 9H9.5v6H13c.8 0 1.5-.7 1.5-1.5v-3c0-.8-.7-1.5-1.5-1.5zm0 4.5h-2v-3h2v3z"></path></g>
<g id="hdr-strong"><path d="M17 6c-3.31 0-6 2.69-6 6s2.69 6 6 6 6-2.69 6-6-2.69-6-6-6zM5 8c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4-1.79-4-4-4zm0 6c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2z"></path></g>
<g id="hdr-weak"><path d="M5 8c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4-1.79-4-4-4zm12-2c-3.31 0-6 2.69-6 6s2.69 6 6 6 6-2.69 6-6-2.69-6-6-6zm0 10c-2.21 0-4-1.79-4-4s1.79-4 4-4 4 1.79 4 4-1.79 4-4 4z"></path></g>
<g id="healing"><path d="M17.73 12.02l3.98-3.98c.39-.39.39-1.02 0-1.41l-4.34-4.34c-.39-.39-1.02-.39-1.41 0l-3.98 3.98L8 2.29C7.8 2.1 7.55 2 7.29 2c-.25 0-.51.1-.7.29L2.25 6.63c-.39.39-.39 1.02 0 1.41l3.98 3.98L2.25 16c-.39.39-.39 1.02 0 1.41l4.34 4.34c.39.39 1.02.39 1.41 0l3.98-3.98 3.98 3.98c.2.2.45.29.71.29.26 0 .51-.1.71-.29l4.34-4.34c.39-.39.39-1.02 0-1.41l-3.99-3.98zM12 9c.55 0 1 .45 1 1s-.45 1-1 1-1-.45-1-1 .45-1 1-1zm-4.71 1.96L3.66 7.34l3.63-3.63 3.62 3.62-3.62 3.63zM10 13c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm2 2c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm2-4c.55 0 1 .45 1 1s-.45 1-1 1-1-.45-1-1 .45-1 1-1zm2.66 9.34l-3.63-3.62 3.63-3.63 3.62 3.62-3.62 3.63z"></path></g>
<g id="image"><path d="M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2zM8.5 13.5l2.5 3.01L14.5 12l4.5 6H5l3.5-4.5z"></path></g>
<g id="image-aspect-ratio"><path d="M16 10h-2v2h2v-2zm0 4h-2v2h2v-2zm-8-4H6v2h2v-2zm4 0h-2v2h2v-2zm8-6H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 14H4V6h16v12z"></path></g>
<g id="iso"><path d="M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM5.5 7.5h2v-2H9v2h2V9H9v2H7.5V9h-2V7.5zM19 19H5L19 5v14zm-2-2v-1.5h-5V17h5z"></path></g>
<g id="landscape"><path d="M14 6l-3.75 5 2.85 3.8-1.6 1.2C9.81 13.75 7 10 7 10l-6 8h22L14 6z"></path></g>
<g id="leak-add"><path d="M6 3H3v3c1.66 0 3-1.34 3-3zm8 0h-2c0 4.97-4.03 9-9 9v2c6.08 0 11-4.93 11-11zm-4 0H8c0 2.76-2.24 5-5 5v2c3.87 0 7-3.13 7-7zm0 18h2c0-4.97 4.03-9 9-9v-2c-6.07 0-11 4.93-11 11zm8 0h3v-3c-1.66 0-3 1.34-3 3zm-4 0h2c0-2.76 2.24-5 5-5v-2c-3.87 0-7 3.13-7 7z"></path></g>
<g id="leak-remove"><path d="M10 3H8c0 .37-.04.72-.12 1.06l1.59 1.59C9.81 4.84 10 3.94 10 3zM3 4.27l2.84 2.84C5.03 7.67 4.06 8 3 8v2c1.61 0 3.09-.55 4.27-1.46L8.7 9.97C7.14 11.24 5.16 12 3 12v2c2.71 0 5.19-.99 7.11-2.62l2.5 2.5C10.99 15.81 10 18.29 10 21h2c0-2.16.76-4.14 2.03-5.69l1.43 1.43C14.55 17.91 14 19.39 14 21h2c0-1.06.33-2.03.89-2.84L19.73 21 21 19.73 4.27 3 3 4.27zM14 3h-2c0 1.5-.37 2.91-1.02 4.16l1.46 1.46C13.42 6.98 14 5.06 14 3zm5.94 13.12c.34-.08.69-.12 1.06-.12v-2c-.94 0-1.84.19-2.66.52l1.6 1.6zm-4.56-4.56l1.46 1.46C18.09 12.37 19.5 12 21 12v-2c-2.06 0-3.98.58-5.62 1.56z"></path></g>
<g id="lens"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2z"></path></g>
<g id="linked-camera"><circle cx="12" cy="14" r="3.2"></circle><path d="M16 3.33c2.58 0 4.67 2.09 4.67 4.67H22c0-3.31-2.69-6-6-6v1.33M16 6c1.11 0 2 .89 2 2h1.33c0-1.84-1.49-3.33-3.33-3.33V6"></path><path d="M17 9c0-1.11-.89-2-2-2V4H9L7.17 6H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V9h-5zm-5 10c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5z"></path></g>
<g id="looks"><path d="M12 10c-3.86 0-7 3.14-7 7h2c0-2.76 2.24-5 5-5s5 2.24 5 5h2c0-3.86-3.14-7-7-7zm0-4C5.93 6 1 10.93 1 17h2c0-4.96 4.04-9 9-9s9 4.04 9 9h2c0-6.07-4.93-11-11-11z"></path></g>
<g id="looks-3"><path d="M19.01 3h-14c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-4 7.5c0 .83-.67 1.5-1.5 1.5.83 0 1.5.67 1.5 1.5V15c0 1.11-.9 2-2 2h-4v-2h4v-2h-2v-2h2V9h-4V7h4c1.1 0 2 .89 2 2v1.5z"></path></g>
<g id="looks-4"><path d="M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-4 14h-2v-4H9V7h2v4h2V7h2v10z"></path></g>
<g id="looks-5"><path d="M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-4 6h-4v2h2c1.1 0 2 .89 2 2v2c0 1.11-.9 2-2 2H9v-2h4v-2H9V7h6v2z"></path></g>
<g id="looks-6"><path d="M11 15h2v-2h-2v2zm8-12H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-4 6h-4v2h2c1.1 0 2 .89 2 2v2c0 1.11-.9 2-2 2h-2c-1.1 0-2-.89-2-2V9c0-1.11.9-2 2-2h4v2z"></path></g>
<g id="looks-one"><path d="M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-5 14h-2V9h-2V7h4v10z"></path></g>
<g id="looks-two"><path d="M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-4 8c0 1.11-.9 2-2 2h-2v2h4v2H9v-4c0-1.11.9-2 2-2h2V9H9V7h4c1.1 0 2 .89 2 2v2z"></path></g>
<g id="loupe"><path d="M13 7h-2v4H7v2h4v4h2v-4h4v-2h-4V7zm-1-5C6.49 2 2 6.49 2 12s4.49 10 10 10h8c1.1 0 2-.9 2-2v-8c0-5.51-4.49-10-10-10zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z"></path></g>
<g id="monochrome-photos"><path d="M20 5h-3.2L15 3H9L7.2 5H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 14h-8v-1c-2.8 0-5-2.2-5-5s2.2-5 5-5V7h8v12zm-3-6c0-2.8-2.2-5-5-5v1.8c1.8 0 3.2 1.4 3.2 3.2s-1.4 3.2-3.2 3.2V18c2.8 0 5-2.2 5-5zm-8.2 0c0 1.8 1.4 3.2 3.2 3.2V9.8c-1.8 0-3.2 1.4-3.2 3.2z"></path></g>
<g id="movie-creation"><path d="M18 4l2 4h-3l-2-4h-2l2 4h-3l-2-4H8l2 4H7L5 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V4h-4z"></path></g>
<g id="movie-filter"><path d="M18 4l2 3h-3l-2-3h-2l2 3h-3l-2-3H8l2 3H7L5 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V4h-4zm-6.75 11.25L10 18l-1.25-2.75L6 14l2.75-1.25L10 10l1.25 2.75L14 14l-2.75 1.25zm5.69-3.31L16 14l-.94-2.06L13 11l2.06-.94L16 8l.94 2.06L19 11l-2.06.94z"></path></g>
<g id="music-note"><path d="M12 3v10.55c-.59-.34-1.27-.55-2-.55-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4V7h4V3h-6z"></path></g>
<g id="nature"><path d="M13 16.12c3.47-.41 6.17-3.36 6.17-6.95 0-3.87-3.13-7-7-7s-7 3.13-7 7c0 3.47 2.52 6.34 5.83 6.89V20H5v2h14v-2h-6v-3.88z"></path></g>
<g id="nature-people"><path d="M22.17 9.17c0-3.87-3.13-7-7-7s-7 3.13-7 7c0 3.47 2.52 6.34 5.83 6.89V20H6v-3h1v-4c0-.55-.45-1-1-1H3c-.55 0-1 .45-1 1v4h1v5h16v-2h-3v-3.88c3.47-.41 6.17-3.36 6.17-6.95zM4.5 11c.83 0 1.5-.67 1.5-1.5S5.33 8 4.5 8 3 8.67 3 9.5 3.67 11 4.5 11z"></path></g>
<g id="navigate-before"><path d="M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"></path></g>
<g id="navigate-next"><path d="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"></path></g>
<g id="palette"><path d="M12 3c-4.97 0-9 4.03-9 9s4.03 9 9 9c.83 0 1.5-.67 1.5-1.5 0-.39-.15-.74-.39-1.01-.23-.26-.38-.61-.38-.99 0-.83.67-1.5 1.5-1.5H16c2.76 0 5-2.24 5-5 0-4.42-4.03-8-9-8zm-5.5 9c-.83 0-1.5-.67-1.5-1.5S5.67 9 6.5 9 8 9.67 8 10.5 7.33 12 6.5 12zm3-4C8.67 8 8 7.33 8 6.5S8.67 5 9.5 5s1.5.67 1.5 1.5S10.33 8 9.5 8zm5 0c-.83 0-1.5-.67-1.5-1.5S13.67 5 14.5 5s1.5.67 1.5 1.5S15.33 8 14.5 8zm3 4c-.83 0-1.5-.67-1.5-1.5S16.67 9 17.5 9s1.5.67 1.5 1.5-.67 1.5-1.5 1.5z"></path></g>
<g id="panorama"><path d="M23 18V6c0-1.1-.9-2-2-2H3c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2zM8.5 12.5l2.5 3.01L14.5 11l4.5 6H5l3.5-4.5z"></path></g>
<g id="panorama-fish-eye"><path d="M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z"></path></g>
<g id="panorama-horizontal"><path d="M20 6.54v10.91c-2.6-.77-5.28-1.16-8-1.16-2.72 0-5.4.39-8 1.16V6.54c2.6.77 5.28 1.16 8 1.16 2.72.01 5.4-.38 8-1.16M21.43 4c-.1 0-.2.02-.31.06C18.18 5.16 15.09 5.7 12 5.7c-3.09 0-6.18-.55-9.12-1.64-.11-.04-.22-.06-.31-.06-.34 0-.57.23-.57.63v14.75c0 .39.23.62.57.62.1 0 .2-.02.31-.06 2.94-1.1 6.03-1.64 9.12-1.64 3.09 0 6.18.55 9.12 1.64.11.04.21.06.31.06.33 0 .57-.23.57-.63V4.63c0-.4-.24-.63-.57-.63z"></path></g>
<g id="panorama-vertical"><path d="M19.94 21.12c-1.1-2.94-1.64-6.03-1.64-9.12 0-3.09.55-6.18 1.64-9.12.04-.11.06-.22.06-.31 0-.34-.23-.57-.63-.57H4.63c-.4 0-.63.23-.63.57 0 .1.02.2.06.31C5.16 5.82 5.71 8.91 5.71 12c0 3.09-.55 6.18-1.64 9.12-.05.11-.07.22-.07.31 0 .33.23.57.63.57h14.75c.39 0 .63-.24.63-.57-.01-.1-.03-.2-.07-.31zM6.54 20c.77-2.6 1.16-5.28 1.16-8 0-2.72-.39-5.4-1.16-8h10.91c-.77 2.6-1.16 5.28-1.16 8 0 2.72.39 5.4 1.16 8H6.54z"></path></g>
<g id="panorama-wide-angle"><path d="M12 6c2.45 0 4.71.2 7.29.64.47 1.78.71 3.58.71 5.36 0 1.78-.24 3.58-.71 5.36-2.58.44-4.84.64-7.29.64s-4.71-.2-7.29-.64C4.24 15.58 4 13.78 4 12c0-1.78.24-3.58.71-5.36C7.29 6.2 9.55 6 12 6m0-2c-2.73 0-5.22.24-7.95.72l-.93.16-.25.9C2.29 7.85 2 9.93 2 12s.29 4.15.87 6.22l.25.89.93.16c2.73.49 5.22.73 7.95.73s5.22-.24 7.95-.72l.93-.16.25-.89c.58-2.08.87-4.16.87-6.23s-.29-4.15-.87-6.22l-.25-.89-.93-.16C17.22 4.24 14.73 4 12 4z"></path></g>
<g id="photo"><path d="M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2zM8.5 13.5l2.5 3.01L14.5 12l4.5 6H5l3.5-4.5z"></path></g>
<g id="photo-album"><path d="M18 2H6c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zM6 4h5v8l-2.5-1.5L6 12V4zm0 15l3-3.86 2.14 2.58 3-3.86L18 19H6z"></path></g>
<g id="photo-camera"><circle cx="12" cy="12" r="3.2"></circle><path d="M9 2L7.17 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2h-3.17L15 2H9zm3 15c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5z"></path></g>
<g id="photo-filter"><path d="M19.02 10v9H5V5h9V3H5.02c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2v-9h-2zM17 10l.94-2.06L20 7l-2.06-.94L17 4l-.94 2.06L14 7l2.06.94zm-3.75.75L12 8l-1.25 2.75L8 12l2.75 1.25L12 16l1.25-2.75L16 12z"></path></g>
<g id="photo-library"><path d="M22 16V4c0-1.1-.9-2-2-2H8c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2zm-11-4l2.03 2.71L16 11l4 5H8l3-4zM2 6v14c0 1.1.9 2 2 2h14v-2H4V6H2z"></path></g>
<g id="photo-size-select-actual"><path d="M21 3H3C2 3 1 4 1 5v14c0 1.1.9 2 2 2h18c1 0 2-1 2-2V5c0-1-1-2-2-2zM5 17l3.5-4.5 2.5 3.01L14.5 11l4.5 6H5z"></path></g>
<g id="photo-size-select-large"><path d="M21 15h2v2h-2v-2zm0-4h2v2h-2v-2zm2 8h-2v2c1 0 2-1 2-2zM13 3h2v2h-2V3zm8 4h2v2h-2V7zm0-4v2h2c0-1-1-2-2-2zM1 7h2v2H1V7zm16-4h2v2h-2V3zm0 16h2v2h-2v-2zM3 3C2 3 1 4 1 5h2V3zm6 0h2v2H9V3zM5 3h2v2H5V3zm-4 8v8c0 1.1.9 2 2 2h12V11H1zm2 8l2.5-3.21 1.79 2.15 2.5-3.22L13 19H3z"></path></g>
<g id="photo-size-select-small"><path d="M23 15h-2v2h2v-2zm0-4h-2v2h2v-2zm0 8h-2v2c1 0 2-1 2-2zM15 3h-2v2h2V3zm8 4h-2v2h2V7zm-2-4v2h2c0-1-1-2-2-2zM3 21h8v-6H1v4c0 1.1.9 2 2 2zM3 7H1v2h2V7zm12 12h-2v2h2v-2zm4-16h-2v2h2V3zm0 16h-2v2h2v-2zM3 3C2 3 1 4 1 5h2V3zm0 8H1v2h2v-2zm8-8H9v2h2V3zM7 3H5v2h2V3z"></path></g>
<g id="picture-as-pdf"><path d="M20 2H8c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-8.5 7.5c0 .83-.67 1.5-1.5 1.5H9v2H7.5V7H10c.83 0 1.5.67 1.5 1.5v1zm5 2c0 .83-.67 1.5-1.5 1.5h-2.5V7H15c.83 0 1.5.67 1.5 1.5v3zm4-3H19v1h1.5V11H19v2h-1.5V7h3v1.5zM9 9.5h1v-1H9v1zM4 6H2v14c0 1.1.9 2 2 2h14v-2H4V6zm10 5.5h1v-3h-1v3z"></path></g>
<g id="portrait"><path d="M12 12.25c1.24 0 2.25-1.01 2.25-2.25S13.24 7.75 12 7.75 9.75 8.76 9.75 10s1.01 2.25 2.25 2.25zm4.5 4c0-1.5-3-2.25-4.5-2.25s-4.5.75-4.5 2.25V17h9v-.75zM19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H5V5h14v14z"></path></g>
<g id="remove-red-eye"><path d="M12 4.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5c-1.73-4.39-6-7.5-11-7.5zM12 17c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5zm0-8c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3z"></path></g>
<g id="rotate-90-degrees-ccw"><path d="M7.34 6.41L.86 12.9l6.49 6.48 6.49-6.48-6.5-6.49zM3.69 12.9l3.66-3.66L11 12.9l-3.66 3.66-3.65-3.66zm15.67-6.26C17.61 4.88 15.3 4 13 4V.76L8.76 5 13 9.24V6c1.79 0 3.58.68 4.95 2.05 2.73 2.73 2.73 7.17 0 9.9C16.58 19.32 14.79 20 13 20c-.97 0-1.94-.21-2.84-.61l-1.49 1.49C10.02 21.62 11.51 22 13 22c2.3 0 4.61-.88 6.36-2.64 3.52-3.51 3.52-9.21 0-12.72z"></path></g>
<g id="rotate-left"><path d="M7.11 8.53L5.7 7.11C4.8 8.27 4.24 9.61 4.07 11h2.02c.14-.87.49-1.72 1.02-2.47zM6.09 13H4.07c.17 1.39.72 2.73 1.62 3.89l1.41-1.42c-.52-.75-.87-1.59-1.01-2.47zm1.01 5.32c1.16.9 2.51 1.44 3.9 1.61V17.9c-.87-.15-1.71-.49-2.46-1.03L7.1 18.32zM13 4.07V1L8.45 5.55 13 10V6.09c2.84.48 5 2.94 5 5.91s-2.16 5.43-5 5.91v2.02c3.95-.49 7-3.85 7-7.93s-3.05-7.44-7-7.93z"></path></g>
<g id="rotate-right"><path d="M15.55 5.55L11 1v3.07C7.06 4.56 4 7.92 4 12s3.05 7.44 7 7.93v-2.02c-2.84-.48-5-2.94-5-5.91s2.16-5.43 5-5.91V10l4.55-4.45zM19.93 11c-.17-1.39-.72-2.73-1.62-3.89l-1.42 1.42c.54.75.88 1.6 1.02 2.47h2.02zM13 17.9v2.02c1.39-.17 2.74-.71 3.9-1.61l-1.44-1.44c-.75.54-1.59.89-2.46 1.03zm3.89-2.42l1.42 1.41c.9-1.16 1.45-2.5 1.62-3.89h-2.02c-.14.87-.48 1.72-1.02 2.48z"></path></g>
<g id="slideshow"><path d="M10 8v8l5-4-5-4zm9-5H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H5V5h14v14z"></path></g>
<g id="straighten"><path d="M21 6H3c-1.1 0-2 .9-2 2v8c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2zm0 10H3V8h2v4h2V8h2v4h2V8h2v4h2V8h2v4h2V8h2v8z"></path></g>
<g id="style"><path d="M2.53 19.65l1.34.56v-9.03l-2.43 5.86c-.41 1.02.08 2.19 1.09 2.61zm19.5-3.7L17.07 3.98c-.31-.75-1.04-1.21-1.81-1.23-.26 0-.53.04-.79.15L7.1 5.95c-.75.31-1.21 1.03-1.23 1.8-.01.27.04.54.15.8l4.96 11.97c.31.76 1.05 1.22 1.83 1.23.26 0 .52-.05.77-.15l7.36-3.05c1.02-.42 1.51-1.59 1.09-2.6zM7.88 8.75c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm-2 11c0 1.1.9 2 2 2h1.45l-3.45-8.34v6.34z"></path></g>
<g id="switch-camera"><path d="M20 4h-3.17L15 2H9L7.17 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm-5 11.5V13H9v2.5L5.5 12 9 8.5V11h6V8.5l3.5 3.5-3.5 3.5z"></path></g>
<g id="switch-video"><path d="M18 9.5V6c0-.55-.45-1-1-1H3c-.55 0-1 .45-1 1v12c0 .55.45 1 1 1h14c.55 0 1-.45 1-1v-3.5l4 4v-13l-4 4zm-5 6V13H7v2.5L3.5 12 7 8.5V11h6V8.5l3.5 3.5-3.5 3.5z"></path></g>
<g id="tag-faces"><path d="M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8zm3.5-9c.83 0 1.5-.67 1.5-1.5S16.33 8 15.5 8 14 8.67 14 9.5s.67 1.5 1.5 1.5zm-7 0c.83 0 1.5-.67 1.5-1.5S9.33 8 8.5 8 7 8.67 7 9.5 7.67 11 8.5 11zm3.5 6.5c2.33 0 4.31-1.46 5.11-3.5H6.89c.8 2.04 2.78 3.5 5.11 3.5z"></path></g>
<g id="texture"><path d="M19.51 3.08L3.08 19.51c.09.34.27.65.51.9.25.24.56.42.9.51L20.93 4.49c-.19-.69-.73-1.23-1.42-1.41zM11.88 3L3 11.88v2.83L14.71 3h-2.83zM5 3c-1.1 0-2 .9-2 2v2l4-4H5zm14 18c.55 0 1.05-.22 1.41-.59.37-.36.59-.86.59-1.41v-2l-4 4h2zm-9.71 0h2.83L21 12.12V9.29L9.29 21z"></path></g>
<g id="timelapse"><path d="M16.24 7.76C15.07 6.59 13.54 6 12 6v6l-4.24 4.24c2.34 2.34 6.14 2.34 8.49 0 2.34-2.34 2.34-6.14-.01-8.48zM12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"></path></g>
<g id="timer"><path d="M15 1H9v2h6V1zm-4 13h2V8h-2v6zm8.03-6.61l1.42-1.42c-.43-.51-.9-.99-1.41-1.41l-1.42 1.42C16.07 4.74 14.12 4 12 4c-4.97 0-9 4.03-9 9s4.02 9 9 9 9-4.03 9-9c0-2.12-.74-4.07-1.97-5.61zM12 20c-3.87 0-7-3.13-7-7s3.13-7 7-7 7 3.13 7 7-3.13 7-7 7z"></path></g>
<g id="timer-10"><path d="M0 7.72V9.4l3-1V18h2V6h-.25L0 7.72zm23.78 6.65c-.14-.28-.35-.53-.63-.74-.28-.21-.61-.39-1.01-.53s-.85-.27-1.35-.38c-.35-.07-.64-.15-.87-.23-.23-.08-.41-.16-.55-.25-.14-.09-.23-.19-.28-.3-.05-.11-.08-.24-.08-.39 0-.14.03-.28.09-.41.06-.13.15-.25.27-.34.12-.1.27-.18.45-.24s.4-.09.64-.09c.25 0 .47.04.66.11.19.07.35.17.48.29.13.12.22.26.29.42.06.16.1.32.1.49h1.95c0-.39-.08-.75-.24-1.09-.16-.34-.39-.63-.69-.88-.3-.25-.66-.44-1.09-.59C21.49 9.07 21 9 20.46 9c-.51 0-.98.07-1.39.21-.41.14-.77.33-1.06.57-.29.24-.51.52-.67.84-.16.32-.23.65-.23 1.01s.08.69.23.96c.15.28.36.52.64.73.27.21.6.38.98.53.38.14.81.26 1.27.36.39.08.71.17.95.26s.43.19.57.29c.13.1.22.22.27.34.05.12.07.25.07.39 0 .32-.13.57-.4.77-.27.2-.66.29-1.17.29-.22 0-.43-.02-.64-.08-.21-.05-.4-.13-.56-.24-.17-.11-.3-.26-.41-.44-.11-.18-.17-.41-.18-.67h-1.89c0 .36.08.71.24 1.05.16.34.39.65.7.93.31.27.69.49 1.15.66.46.17.98.25 1.58.25.53 0 1.01-.06 1.44-.19.43-.13.8-.31 1.11-.54.31-.23.54-.51.71-.83.17-.32.25-.67.25-1.06-.02-.4-.09-.74-.24-1.02zm-9.96-7.32c-.34-.4-.75-.7-1.23-.88-.47-.18-1.01-.27-1.59-.27-.58 0-1.11.09-1.59.27-.48.18-.89.47-1.23.88-.34.41-.6.93-.79 1.59-.18.65-.28 1.45-.28 2.39v1.92c0 .94.09 1.74.28 2.39.19.66.45 1.19.8 1.6.34.41.75.71 1.23.89.48.18 1.01.28 1.59.28.59 0 1.12-.09 1.59-.28.48-.18.88-.48 1.22-.89.34-.41.6-.94.78-1.6.18-.65.28-1.45.28-2.39v-1.92c0-.94-.09-1.74-.28-2.39-.18-.66-.44-1.19-.78-1.59zm-.92 6.17c0 .6-.04 1.11-.12 1.53-.08.42-.2.76-.36 1.02-.16.26-.36.45-.59.57-.23.12-.51.18-.82.18-.3 0-.58-.06-.82-.18s-.44-.31-.6-.57c-.16-.26-.29-.6-.38-1.02-.09-.42-.13-.93-.13-1.53v-2.5c0-.6.04-1.11.13-1.52.09-.41.21-.74.38-1 .16-.25.36-.43.6-.55.24-.11.51-.17.81-.17.31 0 .58.06.81.17.24.11.44.29.6.55.16.25.29.58.37.99.08.41.13.92.13 1.52v2.51z"></path></g>
<g id="timer-3"><path d="M11.61 12.97c-.16-.24-.36-.46-.62-.65-.25-.19-.56-.35-.93-.48.3-.14.57-.3.8-.5.23-.2.42-.41.57-.64.15-.23.27-.46.34-.71.08-.24.11-.49.11-.73 0-.55-.09-1.04-.28-1.46-.18-.42-.44-.77-.78-1.06-.33-.28-.73-.5-1.2-.64-.45-.13-.97-.2-1.53-.2-.55 0-1.06.08-1.52.24-.47.17-.87.4-1.2.69-.33.29-.6.63-.78 1.03-.2.39-.29.83-.29 1.29h1.98c0-.26.05-.49.14-.69.09-.2.22-.38.38-.52.17-.14.36-.25.58-.33.22-.08.46-.12.73-.12.61 0 1.06.16 1.36.47.3.31.44.75.44 1.32 0 .27-.04.52-.12.74-.08.22-.21.41-.38.57-.17.16-.38.28-.63.37-.25.09-.55.13-.89.13H6.72v1.57H7.9c.34 0 .64.04.91.11.27.08.5.19.69.35.19.16.34.36.44.61.1.24.16.54.16.87 0 .62-.18 1.09-.53 1.42-.35.33-.84.49-1.45.49-.29 0-.56-.04-.8-.13-.24-.08-.44-.2-.61-.36-.17-.16-.3-.34-.39-.56-.09-.22-.14-.46-.14-.72H4.19c0 .55.11 1.03.32 1.45.21.42.5.77.86 1.05s.77.49 1.24.63.96.21 1.48.21c.57 0 1.09-.08 1.58-.23.49-.15.91-.38 1.26-.68.36-.3.64-.66.84-1.1.2-.43.3-.93.3-1.48 0-.29-.04-.58-.11-.86-.08-.25-.19-.51-.35-.76zm9.26 1.4c-.14-.28-.35-.53-.63-.74-.28-.21-.61-.39-1.01-.53s-.85-.27-1.35-.38c-.35-.07-.64-.15-.87-.23-.23-.08-.41-.16-.55-.25-.14-.09-.23-.19-.28-.3-.05-.11-.08-.24-.08-.39s.03-.28.09-.41c.06-.13.15-.25.27-.34.12-.1.27-.18.45-.24s.4-.09.64-.09c.25 0 .47.04.66.11.19.07.35.17.48.29.13.12.22.26.29.42.06.16.1.32.1.49h1.95c0-.39-.08-.75-.24-1.09-.16-.34-.39-.63-.69-.88-.3-.25-.66-.44-1.09-.59-.43-.15-.92-.22-1.46-.22-.51 0-.98.07-1.39.21-.41.14-.77.33-1.06.57-.29.24-.51.52-.67.84-.16.32-.23.65-.23 1.01s.08.68.23.96c.15.28.37.52.64.73.27.21.6.38.98.53.38.14.81.26 1.27.36.39.08.71.17.95.26s.43.19.57.29c.13.1.22.22.27.34.05.12.07.25.07.39 0 .32-.13.57-.4.77-.27.2-.66.29-1.17.29-.22 0-.43-.02-.64-.08-.21-.05-.4-.13-.56-.24-.17-.11-.3-.26-.41-.44-.11-.18-.17-.41-.18-.67h-1.89c0 .36.08.71.24 1.05.16.34.39.65.7.93.31.27.69.49 1.15.66.46.17.98.25 1.58.25.53 0 1.01-.06 1.44-.19.43-.13.8-.31 1.11-.54.31-.23.54-.51.71-.83.17-.32.25-.67.25-1.06-.02-.4-.09-.74-.24-1.02z"></path></g>
<g id="timer-off"><path d="M19.04 4.55l-1.42 1.42C16.07 4.74 14.12 4 12 4c-1.83 0-3.53.55-4.95 1.48l1.46 1.46C9.53 6.35 10.73 6 12 6c3.87 0 7 3.13 7 7 0 1.27-.35 2.47-.94 3.49l1.45 1.45C20.45 16.53 21 14.83 21 13c0-2.12-.74-4.07-1.97-5.61l1.42-1.42-1.41-1.42zM15 1H9v2h6V1zm-4 8.44l2 2V8h-2v1.44zM3.02 4L1.75 5.27 4.5 8.03C3.55 9.45 3 11.16 3 13c0 4.97 4.02 9 9 9 1.84 0 3.55-.55 4.98-1.5l2.5 2.5 1.27-1.27-7.71-7.71L3.02 4zM12 20c-3.87 0-7-3.13-7-7 0-1.28.35-2.48.95-3.52l9.56 9.56c-1.03.61-2.23.96-3.51.96z"></path></g>
<g id="tonality"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-1 17.93c-3.94-.49-7-3.85-7-7.93s3.05-7.44 7-7.93v15.86zm2-15.86c1.03.13 2 .45 2.87.93H13v-.93zM13 7h5.24c.25.31.48.65.68 1H13V7zm0 3h6.74c.08.33.15.66.19 1H13v-1zm0 9.93V19h2.87c-.87.48-1.84.8-2.87.93zM18.24 17H13v-1h5.92c-.2.35-.43.69-.68 1zm1.5-3H13v-1h6.93c-.04.34-.11.67-.19 1z"></path></g>
<g id="transform"><path d="M22 18v-2H8V4h2L7 1 4 4h2v2H2v2h4v8c0 1.1.9 2 2 2h8v2h-2l3 3 3-3h-2v-2h4zM10 8h6v6h2V8c0-1.1-.9-2-2-2h-6v2z"></path></g>
<g id="tune"><path d="M3 17v2h6v-2H3zM3 5v2h10V5H3zm10 16v-2h8v-2h-8v-2h-2v6h2zM7 9v2H3v2h4v2h2V9H7zm14 4v-2H11v2h10zm-6-4h2V7h4V5h-4V3h-2v6z"></path></g>
<g id="view-comfy"><path d="M3 9h4V5H3v4zm0 5h4v-4H3v4zm5 0h4v-4H8v4zm5 0h4v-4h-4v4zM8 9h4V5H8v4zm5-4v4h4V5h-4zm5 9h4v-4h-4v4zM3 19h4v-4H3v4zm5 0h4v-4H8v4zm5 0h4v-4h-4v4zm5 0h4v-4h-4v4zm0-14v4h4V5h-4z"></path></g>
<g id="view-compact"><path d="M3 19h6v-7H3v7zm7 0h12v-7H10v7zM3 5v6h19V5H3z"></path></g>
<g id="vignette"><path d="M21 3H3c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-9 15c-4.42 0-8-2.69-8-6s3.58-6 8-6 8 2.69 8 6-3.58 6-8 6z"></path></g>
<g id="wb-auto"><path d="M6.85 12.65h2.3L8 9l-1.15 3.65zM22 7l-1.2 6.29L19.3 7h-1.6l-1.49 6.29L15 7h-.76C12.77 5.17 10.53 4 8 4c-4.42 0-8 3.58-8 8s3.58 8 8 8c3.13 0 5.84-1.81 7.15-4.43l.1.43H17l1.5-6.1L20 16h1.75l2.05-9H22zm-11.7 9l-.7-2H6.4l-.7 2H3.8L7 7h2l3.2 9h-1.9z"></path></g>
<g id="wb-cloudy"><path d="M19.36 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.64-4.96z"></path></g>
<g id="wb-incandescent"><path d="M3.55 18.54l1.41 1.41 1.79-1.8-1.41-1.41-1.79 1.8zM11 22.45h2V19.5h-2v2.95zM4 10.5H1v2h3v-2zm11-4.19V1.5H9v4.81C7.21 7.35 6 9.28 6 11.5c0 3.31 2.69 6 6 6s6-2.69 6-6c0-2.22-1.21-4.15-3-5.19zm5 4.19v2h3v-2h-3zm-2.76 7.66l1.79 1.8 1.41-1.41-1.8-1.79-1.4 1.4z"></path></g>
<g id="wb-iridescent"><path d="M5 14.5h14v-6H5v6zM11 .55V3.5h2V.55h-2zm8.04 2.5l-1.79 1.79 1.41 1.41 1.8-1.79-1.42-1.41zM13 22.45V19.5h-2v2.95h2zm7.45-3.91l-1.8-1.79-1.41 1.41 1.79 1.8 1.42-1.42zM3.55 4.46l1.79 1.79 1.41-1.41-1.79-1.79-1.41 1.41zm1.41 15.49l1.79-1.8-1.41-1.41-1.79 1.79 1.41 1.42z"></path></g>
<g id="wb-sunny"><path d="M6.76 4.84l-1.8-1.79-1.41 1.41 1.79 1.79 1.42-1.41zM4 10.5H1v2h3v-2zm9-9.95h-2V3.5h2V.55zm7.45 3.91l-1.41-1.41-1.79 1.79 1.41 1.41 1.79-1.79zm-3.21 13.7l1.79 1.8 1.41-1.41-1.8-1.79-1.4 1.4zM20 10.5v2h3v-2h-3zm-8-5c-3.31 0-6 2.69-6 6s2.69 6 6 6 6-2.69 6-6-2.69-6-6-6zm-1 16.95h2V19.5h-2v2.95zm-7.45-3.91l1.41 1.41 1.79-1.8-1.41-1.41-1.79 1.8z"></path></g>
</defs></svg>
</iron-iconset-svg>`;document.head.appendChild(template$l.content);
/**
    @license
    Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */
const template$k=html`<iron-iconset-svg name="icons" size="24">
<svg><defs>
<g id="3d-rotation"><path d="M7.52 21.48C4.25 19.94 1.91 16.76 1.55 13H.05C.56 19.16 5.71 24 12 24l.66-.03-3.81-3.81-1.33 1.32zm.89-6.52c-.19 0-.37-.03-.52-.08-.16-.06-.29-.13-.4-.24-.11-.1-.2-.22-.26-.37-.06-.14-.09-.3-.09-.47h-1.3c0 .36.07.68.21.95.14.27.33.5.56.69.24.18.51.32.82.41.3.1.62.15.96.15.37 0 .72-.05 1.03-.15.32-.1.6-.25.83-.44s.42-.43.55-.72c.13-.29.2-.61.2-.97 0-.19-.02-.38-.07-.56-.05-.18-.12-.35-.23-.51-.1-.16-.24-.3-.4-.43-.17-.13-.37-.23-.61-.31.2-.09.37-.2.52-.33.15-.13.27-.27.37-.42.1-.15.17-.3.22-.46.05-.16.07-.32.07-.48 0-.36-.06-.68-.18-.96-.12-.28-.29-.51-.51-.69-.2-.19-.47-.33-.77-.43C9.1 8.05 8.76 8 8.39 8c-.36 0-.69.05-1 .16-.3.11-.57.26-.79.45-.21.19-.38.41-.51.67-.12.26-.18.54-.18.85h1.3c0-.17.03-.32.09-.45s.14-.25.25-.34c.11-.09.23-.17.38-.22.15-.05.3-.08.48-.08.4 0 .7.1.89.31.19.2.29.49.29.86 0 .18-.03.34-.08.49-.05.15-.14.27-.25.37-.11.1-.25.18-.41.24-.16.06-.36.09-.58.09H7.5v1.03h.77c.22 0 .42.02.6.07s.33.13.45.23c.12.11.22.24.29.4.07.16.1.35.1.57 0 .41-.12.72-.35.93-.23.23-.55.33-.95.33zm8.55-5.92c-.32-.33-.7-.59-1.14-.77-.43-.18-.92-.27-1.46-.27H12v8h2.3c.55 0 1.06-.09 1.51-.27.45-.18.84-.43 1.16-.76.32-.33.57-.73.74-1.19.17-.47.26-.99.26-1.57v-.4c0-.58-.09-1.1-.26-1.57-.18-.47-.43-.87-.75-1.2zm-.39 3.16c0 .42-.05.79-.14 1.13-.1.33-.24.62-.43.85-.19.23-.43.41-.71.53-.29.12-.62.18-.99.18h-.91V9.12h.97c.72 0 1.27.23 1.64.69.38.46.57 1.12.57 1.99v.4zM12 0l-.66.03 3.81 3.81 1.33-1.33c3.27 1.55 5.61 4.72 5.96 8.48h1.5C23.44 4.84 18.29 0 12 0z"></path></g>
<g id="accessibility"><path d="M12 2c1.1 0 2 .9 2 2s-.9 2-2 2-2-.9-2-2 .9-2 2-2zm9 7h-6v13h-2v-6h-2v6H9V9H3V7h18v2z"></path></g>
<g id="accessible"><circle cx="12" cy="4" r="2"></circle><path d="M19 13v-2c-1.54.02-3.09-.75-4.07-1.83l-1.29-1.43c-.17-.19-.38-.34-.61-.45-.01 0-.01-.01-.02-.01H13c-.35-.2-.75-.3-1.19-.26C10.76 7.11 10 8.04 10 9.09V15c0 1.1.9 2 2 2h5v5h2v-5.5c0-1.1-.9-2-2-2h-3v-3.45c1.29 1.07 3.25 1.94 5 1.95zm-6.17 5c-.41 1.16-1.52 2-2.83 2-1.66 0-3-1.34-3-3 0-1.31.84-2.41 2-2.83V12.1c-2.28.46-4 2.48-4 4.9 0 2.76 2.24 5 5 5 2.42 0 4.44-1.72 4.9-4h-2.07z"></path></g>
<g id="account-balance"><path d="M4 10v7h3v-7H4zm6 0v7h3v-7h-3zM2 22h19v-3H2v3zm14-12v7h3v-7h-3zm-4.5-9L2 6v2h19V6l-9.5-5z"></path></g>
<g id="account-balance-wallet"><path d="M21 18v1c0 1.1-.9 2-2 2H5c-1.11 0-2-.9-2-2V5c0-1.1.89-2 2-2h14c1.1 0 2 .9 2 2v1h-9c-1.11 0-2 .9-2 2v8c0 1.1.89 2 2 2h9zm-9-2h10V8H12v8zm4-2.5c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5z"></path></g>
<g id="account-box"><path d="M3 5v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2H5c-1.11 0-2 .9-2 2zm12 4c0 1.66-1.34 3-3 3s-3-1.34-3-3 1.34-3 3-3 3 1.34 3 3zm-9 8c0-2 4-3.1 6-3.1s6 1.1 6 3.1v1H6v-1z"></path></g>
<g id="account-circle"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 3c1.66 0 3 1.34 3 3s-1.34 3-3 3-3-1.34-3-3 1.34-3 3-3zm0 14.2c-2.5 0-4.71-1.28-6-3.22.03-1.99 4-3.08 6-3.08 1.99 0 5.97 1.09 6 3.08-1.29 1.94-3.5 3.22-6 3.22z"></path></g>
<g id="add"><path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path></g>
<g id="add-alert"><path d="M10.01 21.01c0 1.1.89 1.99 1.99 1.99s1.99-.89 1.99-1.99h-3.98zm8.87-4.19V11c0-3.25-2.25-5.97-5.29-6.69v-.72C13.59 2.71 12.88 2 12 2s-1.59.71-1.59 1.59v.72C7.37 5.03 5.12 7.75 5.12 11v5.82L3 18.94V20h18v-1.06l-2.12-2.12zM16 13.01h-3v3h-2v-3H8V11h3V8h2v3h3v2.01z"></path></g>
<g id="add-box"><path d="M19 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-2 10h-4v4h-2v-4H7v-2h4V7h2v4h4v2z"></path></g>
<g id="add-circle"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm5 11h-4v4h-2v-4H7v-2h4V7h2v4h4v2z"></path></g>
<g id="add-circle-outline"><path d="M13 7h-2v4H7v2h4v4h2v-4h4v-2h-4V7zm-1-5C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z"></path></g>
<g id="add-shopping-cart"><path d="M11 9h2V6h3V4h-3V1h-2v3H8v2h3v3zm-4 9c-1.1 0-1.99.9-1.99 2S5.9 22 7 22s2-.9 2-2-.9-2-2-2zm10 0c-1.1 0-1.99.9-1.99 2s.89 2 1.99 2 2-.9 2-2-.9-2-2-2zm-9.83-3.25l.03-.12.9-1.63h7.45c.75 0 1.41-.41 1.75-1.03l3.86-7.01L19.42 4h-.01l-1.1 2-2.76 5H8.53l-.13-.27L6.16 6l-.95-2-.94-2H1v2h2l3.6 7.59-1.35 2.45c-.16.28-.25.61-.25.96 0 1.1.9 2 2 2h12v-2H7.42c-.13 0-.25-.11-.25-.25z"></path></g>
<g id="alarm"><path d="M22 5.72l-4.6-3.86-1.29 1.53 4.6 3.86L22 5.72zM7.88 3.39L6.6 1.86 2 5.71l1.29 1.53 4.59-3.85zM12.5 8H11v6l4.75 2.85.75-1.23-4-2.37V8zM12 4c-4.97 0-9 4.03-9 9s4.02 9 9 9c4.97 0 9-4.03 9-9s-4.03-9-9-9zm0 16c-3.87 0-7-3.13-7-7s3.13-7 7-7 7 3.13 7 7-3.13 7-7 7z"></path></g>
<g id="alarm-add"><path d="M7.88 3.39L6.6 1.86 2 5.71l1.29 1.53 4.59-3.85zM22 5.72l-4.6-3.86-1.29 1.53 4.6 3.86L22 5.72zM12 4c-4.97 0-9 4.03-9 9s4.02 9 9 9c4.97 0 9-4.03 9-9s-4.03-9-9-9zm0 16c-3.87 0-7-3.13-7-7s3.13-7 7-7 7 3.13 7 7-3.13 7-7 7zm1-11h-2v3H8v2h3v3h2v-3h3v-2h-3V9z"></path></g>
<g id="alarm-off"><path d="M12 6c3.87 0 7 3.13 7 7 0 .84-.16 1.65-.43 2.4l1.52 1.52c.58-1.19.91-2.51.91-3.92 0-4.97-4.03-9-9-9-1.41 0-2.73.33-3.92.91L9.6 6.43C10.35 6.16 11.16 6 12 6zm10-.28l-4.6-3.86-1.29 1.53 4.6 3.86L22 5.72zM2.92 2.29L1.65 3.57 2.98 4.9l-1.11.93 1.42 1.42 1.11-.94.8.8C3.83 8.69 3 10.75 3 13c0 4.97 4.02 9 9 9 2.25 0 4.31-.83 5.89-2.2l2.2 2.2 1.27-1.27L3.89 3.27l-.97-.98zm13.55 16.1C15.26 19.39 13.7 20 12 20c-3.87 0-7-3.13-7-7 0-1.7.61-3.26 1.61-4.47l9.86 9.86zM8.02 3.28L6.6 1.86l-.86.71 1.42 1.42.86-.71z"></path></g>
<g id="alarm-on"><path d="M22 5.72l-4.6-3.86-1.29 1.53 4.6 3.86L22 5.72zM7.88 3.39L6.6 1.86 2 5.71l1.29 1.53 4.59-3.85zM12 4c-4.97 0-9 4.03-9 9s4.02 9 9 9c4.97 0 9-4.03 9-9s-4.03-9-9-9zm0 16c-3.87 0-7-3.13-7-7s3.13-7 7-7 7 3.13 7 7-3.13 7-7 7zm-1.46-5.47L8.41 12.4l-1.06 1.06 3.18 3.18 6-6-1.06-1.06-4.93 4.95z"></path></g>
<g id="all-out"><path d="M16.21 4.16l4 4v-4zm4 12l-4 4h4zm-12 4l-4-4v4zm-4-12l4-4h-4zm12.95-.95c-2.73-2.73-7.17-2.73-9.9 0s-2.73 7.17 0 9.9 7.17 2.73 9.9 0 2.73-7.16 0-9.9zm-1.1 8.8c-2.13 2.13-5.57 2.13-7.7 0s-2.13-5.57 0-7.7 5.57-2.13 7.7 0 2.13 5.57 0 7.7z"></path></g>
<g id="android"><path d="M6 18c0 .55.45 1 1 1h1v3.5c0 .83.67 1.5 1.5 1.5s1.5-.67 1.5-1.5V19h2v3.5c0 .83.67 1.5 1.5 1.5s1.5-.67 1.5-1.5V19h1c.55 0 1-.45 1-1V8H6v10zM3.5 8C2.67 8 2 8.67 2 9.5v7c0 .83.67 1.5 1.5 1.5S5 17.33 5 16.5v-7C5 8.67 4.33 8 3.5 8zm17 0c-.83 0-1.5.67-1.5 1.5v7c0 .83.67 1.5 1.5 1.5s1.5-.67 1.5-1.5v-7c0-.83-.67-1.5-1.5-1.5zm-4.97-5.84l1.3-1.3c.2-.2.2-.51 0-.71-.2-.2-.51-.2-.71 0l-1.48 1.48C13.85 1.23 12.95 1 12 1c-.96 0-1.86.23-2.66.63L7.85.15c-.2-.2-.51-.2-.71 0-.2.2-.2.51 0 .71l1.31 1.31C6.97 3.26 6 5.01 6 7h12c0-1.99-.97-3.75-2.47-4.84zM10 5H9V4h1v1zm5 0h-1V4h1v1z"></path></g>
<g id="announcement"><path d="M20 2H4c-1.1 0-1.99.9-1.99 2L2 22l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-7 9h-2V5h2v6zm0 4h-2v-2h2v2z"></path></g>
<g id="apps"><path d="M4 8h4V4H4v4zm6 12h4v-4h-4v4zm-6 0h4v-4H4v4zm0-6h4v-4H4v4zm6 0h4v-4h-4v4zm6-10v4h4V4h-4zm-6 4h4V4h-4v4zm6 6h4v-4h-4v4zm0 6h4v-4h-4v4z"></path></g>
<g id="archive"><path d="M20.54 5.23l-1.39-1.68C18.88 3.21 18.47 3 18 3H6c-.47 0-.88.21-1.16.55L3.46 5.23C3.17 5.57 3 6.02 3 6.5V19c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V6.5c0-.48-.17-.93-.46-1.27zM12 17.5L6.5 12H10v-2h4v2h3.5L12 17.5zM5.12 5l.81-1h12l.94 1H5.12z"></path></g>
<g id="arrow-back"><path d="M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z"></path></g>
<g id="arrow-downward"><path d="M20 12l-1.41-1.41L13 16.17V4h-2v12.17l-5.58-5.59L4 12l8 8 8-8z"></path></g>
<g id="arrow-drop-down"><path d="M7 10l5 5 5-5z"></path></g>
<g id="arrow-drop-down-circle"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 12l-4-4h8l-4 4z"></path></g>
<g id="arrow-drop-up"><path d="M7 14l5-5 5 5z"></path></g>
<g id="arrow-forward"><path d="M12 4l-1.41 1.41L16.17 11H4v2h12.17l-5.58 5.59L12 20l8-8z"></path></g>
<g id="arrow-upward"><path d="M4 12l1.41 1.41L11 7.83V20h2V7.83l5.58 5.59L20 12l-8-8-8 8z"></path></g>
<g id="aspect-ratio"><path d="M19 12h-2v3h-3v2h5v-5zM7 9h3V7H5v5h2V9zm14-6H3c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16.01H3V4.99h18v14.02z"></path></g>
<g id="assessment"><path d="M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM9 17H7v-7h2v7zm4 0h-2V7h2v10zm4 0h-2v-4h2v4z"></path></g>
<g id="assignment"><path d="M19 3h-4.18C14.4 1.84 13.3 1 12 1c-1.3 0-2.4.84-2.82 2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-7 0c.55 0 1 .45 1 1s-.45 1-1 1-1-.45-1-1 .45-1 1-1zm2 14H7v-2h7v2zm3-4H7v-2h10v2zm0-4H7V7h10v2z"></path></g>
<g id="assignment-ind"><path d="M19 3h-4.18C14.4 1.84 13.3 1 12 1c-1.3 0-2.4.84-2.82 2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-7 0c.55 0 1 .45 1 1s-.45 1-1 1-1-.45-1-1 .45-1 1-1zm0 4c1.66 0 3 1.34 3 3s-1.34 3-3 3-3-1.34-3-3 1.34-3 3-3zm6 12H6v-1.4c0-2 4-3.1 6-3.1s6 1.1 6 3.1V19z"></path></g>
<g id="assignment-late"><path d="M19 3h-4.18C14.4 1.84 13.3 1 12 1c-1.3 0-2.4.84-2.82 2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-6 15h-2v-2h2v2zm0-4h-2V8h2v6zm-1-9c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1z"></path></g>
<g id="assignment-return"><path d="M19 3h-4.18C14.4 1.84 13.3 1 12 1c-1.3 0-2.4.84-2.82 2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-7 0c.55 0 1 .45 1 1s-.45 1-1 1-1-.45-1-1 .45-1 1-1zm4 12h-4v3l-5-5 5-5v3h4v4z"></path></g>
<g id="assignment-returned"><path d="M19 3h-4.18C14.4 1.84 13.3 1 12 1c-1.3 0-2.4.84-2.82 2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-7 0c.55 0 1 .45 1 1s-.45 1-1 1-1-.45-1-1 .45-1 1-1zm0 15l-5-5h3V9h4v4h3l-5 5z"></path></g>
<g id="assignment-turned-in"><path d="M19 3h-4.18C14.4 1.84 13.3 1 12 1c-1.3 0-2.4.84-2.82 2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-7 0c.55 0 1 .45 1 1s-.45 1-1 1-1-.45-1-1 .45-1 1-1zm-2 14l-4-4 1.41-1.41L10 14.17l6.59-6.59L18 9l-8 8z"></path></g>
<g id="attachment"><path d="M2 12.5C2 9.46 4.46 7 7.5 7H18c2.21 0 4 1.79 4 4s-1.79 4-4 4H9.5C8.12 15 7 13.88 7 12.5S8.12 10 9.5 10H17v2H9.41c-.55 0-.55 1 0 1H18c1.1 0 2-.9 2-2s-.9-2-2-2H7.5C5.57 9 4 10.57 4 12.5S5.57 16 7.5 16H17v2H7.5C4.46 18 2 15.54 2 12.5z"></path></g>
<g id="autorenew"><path d="M12 6v3l4-4-4-4v3c-4.42 0-8 3.58-8 8 0 1.57.46 3.03 1.24 4.26L6.7 14.8c-.45-.83-.7-1.79-.7-2.8 0-3.31 2.69-6 6-6zm6.76 1.74L17.3 9.2c.44.84.7 1.79.7 2.8 0 3.31-2.69 6-6 6v-3l-4 4 4 4v-3c4.42 0 8-3.58 8-8 0-1.57-.46-3.03-1.24-4.26z"></path></g>
<g id="backspace"><path d="M22 3H7c-.69 0-1.23.35-1.59.88L0 12l5.41 8.11c.36.53.9.89 1.59.89h15c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-3 12.59L17.59 17 14 13.41 10.41 17 9 15.59 12.59 12 9 8.41 10.41 7 14 10.59 17.59 7 19 8.41 15.41 12 19 15.59z"></path></g>
<g id="backup"><path d="M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96zM14 13v4h-4v-4H7l5-5 5 5h-3z"></path></g>
<g id="block"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zM4 12c0-4.42 3.58-8 8-8 1.85 0 3.55.63 4.9 1.69L5.69 16.9C4.63 15.55 4 13.85 4 12zm8 8c-1.85 0-3.55-.63-4.9-1.69L18.31 7.1C19.37 8.45 20 10.15 20 12c0 4.42-3.58 8-8 8z"></path></g>
<g id="book"><path d="M18 2H6c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zM6 4h5v8l-2.5-1.5L6 12V4z"></path></g>
<g id="bookmark"><path d="M17 3H7c-1.1 0-1.99.9-1.99 2L5 21l7-3 7 3V5c0-1.1-.9-2-2-2z"></path></g>
<g id="bookmark-border"><path d="M17 3H7c-1.1 0-1.99.9-1.99 2L5 21l7-3 7 3V5c0-1.1-.9-2-2-2zm0 15l-5-2.18L7 18V5h10v13z"></path></g>
<g id="bug-report"><path d="M20 8h-2.81c-.45-.78-1.07-1.45-1.82-1.96L17 4.41 15.59 3l-2.17 2.17C12.96 5.06 12.49 5 12 5c-.49 0-.96.06-1.41.17L8.41 3 7 4.41l1.62 1.63C7.88 6.55 7.26 7.22 6.81 8H4v2h2.09c-.05.33-.09.66-.09 1v1H4v2h2v1c0 .34.04.67.09 1H4v2h2.81c1.04 1.79 2.97 3 5.19 3s4.15-1.21 5.19-3H20v-2h-2.09c.05-.33.09-.66.09-1v-1h2v-2h-2v-1c0-.34-.04-.67-.09-1H20V8zm-6 8h-4v-2h4v2zm0-4h-4v-2h4v2z"></path></g>
<g id="build"><path d="M22.7 19l-9.1-9.1c.9-2.3.4-5-1.5-6.9-2-2-5-2.4-7.4-1.3L9 6 6 9 1.6 4.7C.4 7.1.9 10.1 2.9 12.1c1.9 1.9 4.6 2.4 6.9 1.5l9.1 9.1c.4.4 1 .4 1.4 0l2.3-2.3c.5-.4.5-1.1.1-1.4z"></path></g>
<g id="cached"><path d="M19 8l-4 4h3c0 3.31-2.69 6-6 6-1.01 0-1.97-.25-2.8-.7l-1.46 1.46C8.97 19.54 10.43 20 12 20c4.42 0 8-3.58 8-8h3l-4-4zM6 12c0-3.31 2.69-6 6-6 1.01 0 1.97.25 2.8.7l1.46-1.46C15.03 4.46 13.57 4 12 4c-4.42 0-8 3.58-8 8H1l4 4 4-4H6z"></path></g>
<g id="camera-enhance"><path d="M9 3L7.17 5H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2h-3.17L15 3H9zm3 15c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5zm0-1l1.25-2.75L16 13l-2.75-1.25L12 9l-1.25 2.75L8 13l2.75 1.25z"></path></g>
<g id="cancel"><path d="M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2zm5 13.59L15.59 17 12 13.41 8.41 17 7 15.59 10.59 12 7 8.41 8.41 7 12 10.59 15.59 7 17 8.41 13.41 12 17 15.59z"></path></g>
<g id="card-giftcard"><path d="M20 6h-2.18c.11-.31.18-.65.18-1 0-1.66-1.34-3-3-3-1.05 0-1.96.54-2.5 1.35l-.5.67-.5-.68C10.96 2.54 10.05 2 9 2 7.34 2 6 3.34 6 5c0 .35.07.69.18 1H4c-1.11 0-1.99.89-1.99 2L2 19c0 1.11.89 2 2 2h16c1.11 0 2-.89 2-2V8c0-1.11-.89-2-2-2zm-5-2c.55 0 1 .45 1 1s-.45 1-1 1-1-.45-1-1 .45-1 1-1zM9 4c.55 0 1 .45 1 1s-.45 1-1 1-1-.45-1-1 .45-1 1-1zm11 15H4v-2h16v2zm0-5H4V8h5.08L7 10.83 8.62 12 11 8.76l1-1.36 1 1.36L15.38 12 17 10.83 14.92 8H20v6z"></path></g>
<g id="card-membership"><path d="M20 2H4c-1.11 0-2 .89-2 2v11c0 1.11.89 2 2 2h4v5l4-2 4 2v-5h4c1.11 0 2-.89 2-2V4c0-1.11-.89-2-2-2zm0 13H4v-2h16v2zm0-5H4V4h16v6z"></path></g>
<g id="card-travel"><path d="M20 6h-3V4c0-1.11-.89-2-2-2H9c-1.11 0-2 .89-2 2v2H4c-1.11 0-2 .89-2 2v11c0 1.11.89 2 2 2h16c1.11 0 2-.89 2-2V8c0-1.11-.89-2-2-2zM9 4h6v2H9V4zm11 15H4v-2h16v2zm0-5H4V8h3v2h2V8h6v2h2V8h3v6z"></path></g>
<g id="change-history"><path d="M12 7.77L18.39 18H5.61L12 7.77M12 4L2 20h20L12 4z"></path></g>
<g id="check"><path d="M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"></path></g>
<g id="check-box"><path d="M19 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.11 0 2-.9 2-2V5c0-1.1-.89-2-2-2zm-9 14l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"></path></g>
<g id="check-box-outline-blank"><path d="M19 5v14H5V5h14m0-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2z"></path></g>
<g id="check-circle"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"></path></g>
<g id="chevron-left"><path d="M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"></path></g>
<g id="chevron-right"><path d="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"></path></g>
<g id="chrome-reader-mode"><path d="M13 12h7v1.5h-7zm0-2.5h7V11h-7zm0 5h7V16h-7zM21 4H3c-1.1 0-2 .9-2 2v13c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 15h-9V6h9v13z"></path></g>
<g id="class"><path d="M18 2H6c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zM6 4h5v8l-2.5-1.5L6 12V4z"></path></g>
<g id="clear"><path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"></path></g>
<g id="close"><path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"></path></g>
<g id="cloud"><path d="M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96z"></path></g>
<g id="cloud-circle"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm4.5 14H8c-1.66 0-3-1.34-3-3s1.34-3 3-3l.14.01C8.58 8.28 10.13 7 12 7c2.21 0 4 1.79 4 4h.5c1.38 0 2.5 1.12 2.5 2.5S17.88 16 16.5 16z"></path></g>
<g id="cloud-done"><path d="M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96zM10 17l-3.5-3.5 1.41-1.41L10 14.17 15.18 9l1.41 1.41L10 17z"></path></g>
<g id="cloud-download"><path d="M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96zM17 13l-5 5-5-5h3V9h4v4h3z"></path></g>
<g id="cloud-off"><path d="M19.35 10.04C18.67 6.59 15.64 4 12 4c-1.48 0-2.85.43-4.01 1.17l1.46 1.46C10.21 6.23 11.08 6 12 6c3.04 0 5.5 2.46 5.5 5.5v.5H19c1.66 0 3 1.34 3 3 0 1.13-.64 2.11-1.56 2.62l1.45 1.45C23.16 18.16 24 16.68 24 15c0-2.64-2.05-4.78-4.65-4.96zM3 5.27l2.75 2.74C2.56 8.15 0 10.77 0 14c0 3.31 2.69 6 6 6h11.73l2 2L21 20.73 4.27 4 3 5.27zM7.73 10l8 8H6c-2.21 0-4-1.79-4-4s1.79-4 4-4h1.73z"></path></g>
<g id="cloud-queue"><path d="M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96zM19 18H6c-2.21 0-4-1.79-4-4s1.79-4 4-4h.71C7.37 7.69 9.48 6 12 6c3.04 0 5.5 2.46 5.5 5.5v.5H19c1.66 0 3 1.34 3 3s-1.34 3-3 3z"></path></g>
<g id="cloud-upload"><path d="M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96zM14 13v4h-4v-4H7l5-5 5 5h-3z"></path></g>
<g id="code"><path d="M9.4 16.6L4.8 12l4.6-4.6L8 6l-6 6 6 6 1.4-1.4zm5.2 0l4.6-4.6-4.6-4.6L16 6l6 6-6 6-1.4-1.4z"></path></g>
<g id="compare-arrows"><path d="M9.01 14H2v2h7.01v3L13 15l-3.99-4v3zm5.98-1v-3H22V8h-7.01V5L11 9l3.99 4z"></path></g>
<g id="content-copy"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"></path></g>
<g id="content-cut"><path d="M9.64 7.64c.23-.5.36-1.05.36-1.64 0-2.21-1.79-4-4-4S2 3.79 2 6s1.79 4 4 4c.59 0 1.14-.13 1.64-.36L10 12l-2.36 2.36C7.14 14.13 6.59 14 6 14c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4c0-.59-.13-1.14-.36-1.64L12 14l7 7h3v-1L9.64 7.64zM6 8c-1.1 0-2-.89-2-2s.9-2 2-2 2 .89 2 2-.9 2-2 2zm0 12c-1.1 0-2-.89-2-2s.9-2 2-2 2 .89 2 2-.9 2-2 2zm6-7.5c-.28 0-.5-.22-.5-.5s.22-.5.5-.5.5.22.5.5-.22.5-.5.5zM19 3l-6 6 2 2 7-7V3z"></path></g>
<g id="content-paste"><path d="M19 2h-4.18C14.4.84 13.3 0 12 0c-1.3 0-2.4.84-2.82 2H5c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-7 0c.55 0 1 .45 1 1s-.45 1-1 1-1-.45-1-1 .45-1 1-1zm7 18H5V4h2v3h10V4h2v16z"></path></g>
<g id="copyright"><path d="M10.08 10.86c.05-.33.16-.62.3-.87s.34-.46.59-.62c.24-.15.54-.22.91-.23.23.01.44.05.63.13.2.09.38.21.52.36s.25.33.34.53.13.42.14.64h1.79c-.02-.47-.11-.9-.28-1.29s-.4-.73-.7-1.01-.66-.5-1.08-.66-.88-.23-1.39-.23c-.65 0-1.22.11-1.7.34s-.88.53-1.2.92-.56.84-.71 1.36S8 11.29 8 11.87v.27c0 .58.08 1.12.23 1.64s.39.97.71 1.35.72.69 1.2.91 1.05.34 1.7.34c.47 0 .91-.08 1.32-.23s.77-.36 1.08-.63.56-.58.74-.94.29-.74.3-1.15h-1.79c-.01.21-.06.4-.15.58s-.21.33-.36.46-.32.23-.52.3c-.19.07-.39.09-.6.1-.36-.01-.66-.08-.89-.23-.25-.16-.45-.37-.59-.62s-.25-.55-.3-.88-.08-.67-.08-1v-.27c0-.35.03-.68.08-1.01zM12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z"></path></g>
<g id="create"><path d="M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.39-.39-1.02-.39-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z"></path></g>
<g id="create-new-folder"><path d="M20 6h-8l-2-2H4c-1.11 0-1.99.89-1.99 2L2 18c0 1.11.89 2 2 2h16c1.11 0 2-.89 2-2V8c0-1.11-.89-2-2-2zm-1 8h-3v3h-2v-3h-3v-2h3V9h2v3h3v2z"></path></g>
<g id="credit-card"><path d="M20 4H4c-1.11 0-1.99.89-1.99 2L2 18c0 1.11.89 2 2 2h16c1.11 0 2-.89 2-2V6c0-1.11-.89-2-2-2zm0 14H4v-6h16v6zm0-10H4V6h16v2z"></path></g>
<g id="dashboard"><path d="M3 13h8V3H3v10zm0 8h8v-6H3v6zm10 0h8V11h-8v10zm0-18v6h8V3h-8z"></path></g>
<g id="date-range"><path d="M9 11H7v2h2v-2zm4 0h-2v2h2v-2zm4 0h-2v2h2v-2zm2-7h-1V2h-2v2H8V2H6v2H5c-1.11 0-1.99.9-1.99 2L3 20c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 16H5V9h14v11z"></path></g>
<g id="delete"><path d="M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"></path></g>
<g id="delete-forever"><path d="M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zm2.46-7.12l1.41-1.41L12 12.59l2.12-2.12 1.41 1.41L13.41 14l2.12 2.12-1.41 1.41L12 15.41l-2.12 2.12-1.41-1.41L10.59 14l-2.13-2.12zM15.5 4l-1-1h-5l-1 1H5v2h14V4z"></path></g>
<g id="delete-sweep"><path d="M15 16h4v2h-4zm0-8h7v2h-7zm0 4h6v2h-6zM3 18c0 1.1.9 2 2 2h6c1.1 0 2-.9 2-2V8H3v10zM14 5h-3l-1-1H6L5 5H2v2h12z"></path></g>
<g id="description"><path d="M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zm2 16H8v-2h8v2zm0-4H8v-2h8v2zm-3-5V3.5L18.5 9H13z"></path></g>
<g id="dns"><path d="M20 13H4c-.55 0-1 .45-1 1v6c0 .55.45 1 1 1h16c.55 0 1-.45 1-1v-6c0-.55-.45-1-1-1zM7 19c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2zM20 3H4c-.55 0-1 .45-1 1v6c0 .55.45 1 1 1h16c.55 0 1-.45 1-1V4c0-.55-.45-1-1-1zM7 9c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2z"></path></g>
<g id="done"><path d="M9 16.2L4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4L9 16.2z"></path></g>
<g id="done-all"><path d="M18 7l-1.41-1.41-6.34 6.34 1.41 1.41L18 7zm4.24-1.41L11.66 16.17 7.48 12l-1.41 1.41L11.66 19l12-12-1.42-1.41zM.41 13.41L6 19l1.41-1.41L1.83 12 .41 13.41z"></path></g>
<g id="donut-large"><path d="M11 5.08V2c-5 .5-9 4.81-9 10s4 9.5 9 10v-3.08c-3-.48-6-3.4-6-6.92s3-6.44 6-6.92zM18.97 11H22c-.47-5-4-8.53-9-9v3.08C16 5.51 18.54 8 18.97 11zM13 18.92V22c5-.47 8.53-4 9-9h-3.03c-.43 3-2.97 5.49-5.97 5.92z"></path></g>
<g id="donut-small"><path d="M11 9.16V2c-5 .5-9 4.79-9 10s4 9.5 9 10v-7.16c-1-.41-2-1.52-2-2.84s1-2.43 2-2.84zM14.86 11H22c-.48-4.75-4-8.53-9-9v7.16c1 .3 1.52.98 1.86 1.84zM13 14.84V22c5-.47 8.52-4.25 9-9h-7.14c-.34.86-.86 1.54-1.86 1.84z"></path></g>
<g id="drafts"><path d="M21.99 8c0-.72-.37-1.35-.94-1.7L12 1 2.95 6.3C2.38 6.65 2 7.28 2 8v10c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2l-.01-10zM12 13L3.74 7.84 12 3l8.26 4.84L12 13z"></path></g>
<g id="eject"><path d="M5 17h14v2H5zm7-12L5.33 15h13.34z"></path></g>
<g id="error"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z"></path></g>
<g id="error-outline"><path d="M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"></path></g>
<g id="euro-symbol"><path d="M15 18.5c-2.51 0-4.68-1.42-5.76-3.5H15v-2H8.58c-.05-.33-.08-.66-.08-1s.03-.67.08-1H15V9H9.24C10.32 6.92 12.5 5.5 15 5.5c1.61 0 3.09.59 4.23 1.57L21 5.3C19.41 3.87 17.3 3 15 3c-3.92 0-7.24 2.51-8.48 6H3v2h3.06c-.04.33-.06.66-.06 1 0 .34.02.67.06 1H3v2h3.52c1.24 3.49 4.56 6 8.48 6 2.31 0 4.41-.87 6-2.3l-1.78-1.77c-1.13.98-2.6 1.57-4.22 1.57z"></path></g>
<g id="event"><path d="M17 12h-5v5h5v-5zM16 1v2H8V1H6v2H5c-1.11 0-1.99.9-1.99 2L3 19c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2h-1V1h-2zm3 18H5V8h14v11z"></path></g>
<g id="event-seat"><path d="M4 18v3h3v-3h10v3h3v-6H4zm15-8h3v3h-3zM2 10h3v3H2zm15 3H7V5c0-1.1.9-2 2-2h6c1.1 0 2 .9 2 2v8z"></path></g>
<g id="exit-to-app"><path d="M10.09 15.59L11.5 17l5-5-5-5-1.41 1.41L12.67 11H3v2h9.67l-2.58 2.59zM19 3H5c-1.11 0-2 .9-2 2v4h2V5h14v14H5v-4H3v4c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2z"></path></g>
<g id="expand-less"><path d="M12 8l-6 6 1.41 1.41L12 10.83l4.59 4.58L18 14z"></path></g>
<g id="expand-more"><path d="M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6z"></path></g>
<g id="explore"><path d="M12 10.9c-.61 0-1.1.49-1.1 1.1s.49 1.1 1.1 1.1c.61 0 1.1-.49 1.1-1.1s-.49-1.1-1.1-1.1zM12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm2.19 12.19L6 18l3.81-8.19L18 6l-3.81 8.19z"></path></g>
<g id="extension"><path d="M20.5 11H19V7c0-1.1-.9-2-2-2h-4V3.5C13 2.12 11.88 1 10.5 1S8 2.12 8 3.5V5H4c-1.1 0-1.99.9-1.99 2v3.8H3.5c1.49 0 2.7 1.21 2.7 2.7s-1.21 2.7-2.7 2.7H2V20c0 1.1.9 2 2 2h3.8v-1.5c0-1.49 1.21-2.7 2.7-2.7 1.49 0 2.7 1.21 2.7 2.7V22H17c1.1 0 2-.9 2-2v-4h1.5c1.38 0 2.5-1.12 2.5-2.5S21.88 11 20.5 11z"></path></g>
<g id="face"><path d="M9 11.75c-.69 0-1.25.56-1.25 1.25s.56 1.25 1.25 1.25 1.25-.56 1.25-1.25-.56-1.25-1.25-1.25zm6 0c-.69 0-1.25.56-1.25 1.25s.56 1.25 1.25 1.25 1.25-.56 1.25-1.25-.56-1.25-1.25-1.25zM12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8 0-.29.02-.58.05-.86 2.36-1.05 4.23-2.98 5.21-5.37C11.07 8.33 14.05 10 17.42 10c.78 0 1.53-.09 2.25-.26.21.71.33 1.47.33 2.26 0 4.41-3.59 8-8 8z"></path></g>
<g id="favorite"><path d="M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z"></path></g>
<g id="favorite-border"><path d="M16.5 3c-1.74 0-3.41.81-4.5 2.09C10.91 3.81 9.24 3 7.5 3 4.42 3 2 5.42 2 8.5c0 3.78 3.4 6.86 8.55 11.54L12 21.35l1.45-1.32C18.6 15.36 22 12.28 22 8.5 22 5.42 19.58 3 16.5 3zm-4.4 15.55l-.1.1-.1-.1C7.14 14.24 4 11.39 4 8.5 4 6.5 5.5 5 7.5 5c1.54 0 3.04.99 3.57 2.36h1.87C13.46 5.99 14.96 5 16.5 5c2 0 3.5 1.5 3.5 3.5 0 2.89-3.14 5.74-7.9 10.05z"></path></g>
<g id="feedback"><path d="M20 2H4c-1.1 0-1.99.9-1.99 2L2 22l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-7 12h-2v-2h2v2zm0-4h-2V6h2v4z"></path></g>
<g id="file-download"><path d="M19 9h-4V3H9v6H5l7 7 7-7zM5 18v2h14v-2H5z"></path></g>
<g id="file-upload"><path d="M9 16h6v-6h4l-7-7-7 7h4zm-4 2h14v2H5z"></path></g>
<g id="filter-list"><path d="M10 18h4v-2h-4v2zM3 6v2h18V6H3zm3 7h12v-2H6v2z"></path></g>
<g id="find-in-page"><path d="M20 19.59V8l-6-6H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c.45 0 .85-.15 1.19-.4l-4.43-4.43c-.8.52-1.74.83-2.76.83-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5c0 1.02-.31 1.96-.83 2.75L20 19.59zM9 13c0 1.66 1.34 3 3 3s3-1.34 3-3-1.34-3-3-3-3 1.34-3 3z"></path></g>
<g id="find-replace"><path d="M11 6c1.38 0 2.63.56 3.54 1.46L12 10h6V4l-2.05 2.05C14.68 4.78 12.93 4 11 4c-3.53 0-6.43 2.61-6.92 6H6.1c.46-2.28 2.48-4 4.9-4zm5.64 9.14c.66-.9 1.12-1.97 1.28-3.14H15.9c-.46 2.28-2.48 4-4.9 4-1.38 0-2.63-.56-3.54-1.46L10 12H4v6l2.05-2.05C7.32 17.22 9.07 18 11 18c1.55 0 2.98-.51 4.14-1.36L20 21.49 21.49 20l-4.85-4.86z"></path></g>
<g id="fingerprint"><path d="M17.81 4.47c-.08 0-.16-.02-.23-.06C15.66 3.42 14 3 12.01 3c-1.98 0-3.86.47-5.57 1.41-.24.13-.54.04-.68-.2-.13-.24-.04-.55.2-.68C7.82 2.52 9.86 2 12.01 2c2.13 0 3.99.47 6.03 1.52.25.13.34.43.21.67-.09.18-.26.28-.44.28zM3.5 9.72c-.1 0-.2-.03-.29-.09-.23-.16-.28-.47-.12-.7.99-1.4 2.25-2.5 3.75-3.27C9.98 4.04 14 4.03 17.15 5.65c1.5.77 2.76 1.86 3.75 3.25.16.22.11.54-.12.7-.23.16-.54.11-.7-.12-.9-1.26-2.04-2.25-3.39-2.94-2.87-1.47-6.54-1.47-9.4.01-1.36.7-2.5 1.7-3.4 2.96-.08.14-.23.21-.39.21zm6.25 12.07c-.13 0-.26-.05-.35-.15-.87-.87-1.34-1.43-2.01-2.64-.69-1.23-1.05-2.73-1.05-4.34 0-2.97 2.54-5.39 5.66-5.39s5.66 2.42 5.66 5.39c0 .28-.22.5-.5.5s-.5-.22-.5-.5c0-2.42-2.09-4.39-4.66-4.39-2.57 0-4.66 1.97-4.66 4.39 0 1.44.32 2.77.93 3.85.64 1.15 1.08 1.64 1.85 2.42.19.2.19.51 0 .71-.11.1-.24.15-.37.15zm7.17-1.85c-1.19 0-2.24-.3-3.1-.89-1.49-1.01-2.38-2.65-2.38-4.39 0-.28.22-.5.5-.5s.5.22.5.5c0 1.41.72 2.74 1.94 3.56.71.48 1.54.71 2.54.71.24 0 .64-.03 1.04-.1.27-.05.53.13.58.41.05.27-.13.53-.41.58-.57.11-1.07.12-1.21.12zM14.91 22c-.04 0-.09-.01-.13-.02-1.59-.44-2.63-1.03-3.72-2.1-1.4-1.39-2.17-3.24-2.17-5.22 0-1.62 1.38-2.94 3.08-2.94 1.7 0 3.08 1.32 3.08 2.94 0 1.07.93 1.94 2.08 1.94s2.08-.87 2.08-1.94c0-3.77-3.25-6.83-7.25-6.83-2.84 0-5.44 1.58-6.61 4.03-.39.81-.59 1.76-.59 2.8 0 .78.07 2.01.67 3.61.1.26-.03.55-.29.64-.26.1-.55-.04-.64-.29-.49-1.31-.73-2.61-.73-3.96 0-1.2.23-2.29.68-3.24 1.33-2.79 4.28-4.6 7.51-4.6 4.55 0 8.25 3.51 8.25 7.83 0 1.62-1.38 2.94-3.08 2.94s-3.08-1.32-3.08-2.94c0-1.07-.93-1.94-2.08-1.94s-2.08.87-2.08 1.94c0 1.71.66 3.31 1.87 4.51.95.94 1.86 1.46 3.27 1.85.27.07.42.35.35.61-.05.23-.26.38-.47.38z"></path></g>
<g id="first-page"><path d="M18.41 16.59L13.82 12l4.59-4.59L17 6l-6 6 6 6zM6 6h2v12H6z"></path></g>
<g id="flag"><path d="M14.4 6L14 4H5v17h2v-7h5.6l.4 2h7V6z"></path></g>
<g id="flight-land"><path d="M2.5 19h19v2h-19zm7.18-5.73l4.35 1.16 5.31 1.42c.8.21 1.62-.26 1.84-1.06.21-.8-.26-1.62-1.06-1.84l-5.31-1.42-2.76-9.02L10.12 2v8.28L5.15 8.95l-.93-2.32-1.45-.39v5.17l1.6.43 5.31 1.43z"></path></g>
<g id="flight-takeoff"><path d="M2.5 19h19v2h-19zm19.57-9.36c-.21-.8-1.04-1.28-1.84-1.06L14.92 10l-6.9-6.43-1.93.51 4.14 7.17-4.97 1.33-1.97-1.54-1.45.39 1.82 3.16.77 1.33 1.6-.43 5.31-1.42 4.35-1.16L21 11.49c.81-.23 1.28-1.05 1.07-1.85z"></path></g>
<g id="flip-to-back"><path d="M9 7H7v2h2V7zm0 4H7v2h2v-2zm0-8c-1.11 0-2 .9-2 2h2V3zm4 12h-2v2h2v-2zm6-12v2h2c0-1.1-.9-2-2-2zm-6 0h-2v2h2V3zM9 17v-2H7c0 1.1.89 2 2 2zm10-4h2v-2h-2v2zm0-4h2V7h-2v2zm0 8c1.1 0 2-.9 2-2h-2v2zM5 7H3v12c0 1.1.89 2 2 2h12v-2H5V7zm10-2h2V3h-2v2zm0 12h2v-2h-2v2z"></path></g>
<g id="flip-to-front"><path d="M3 13h2v-2H3v2zm0 4h2v-2H3v2zm2 4v-2H3c0 1.1.89 2 2 2zM3 9h2V7H3v2zm12 12h2v-2h-2v2zm4-18H9c-1.11 0-2 .9-2 2v10c0 1.1.89 2 2 2h10c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 12H9V5h10v10zm-8 6h2v-2h-2v2zm-4 0h2v-2H7v2z"></path></g>
<g id="folder"><path d="M10 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8l-2-2z"></path></g>
<g id="folder-open"><path d="M20 6h-8l-2-2H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2zm0 12H4V8h16v10z"></path></g>
<g id="folder-shared"><path d="M20 6h-8l-2-2H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2zm-5 3c1.1 0 2 .9 2 2s-.9 2-2 2-2-.9-2-2 .9-2 2-2zm4 8h-8v-1c0-1.33 2.67-2 4-2s4 .67 4 2v1z"></path></g>
<g id="font-download"><path d="M9.93 13.5h4.14L12 7.98zM20 2H4c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-4.05 16.5l-1.14-3H9.17l-1.12 3H5.96l5.11-13h1.86l5.11 13h-2.09z"></path></g>
<g id="forward"><path d="M12 8V4l8 8-8 8v-4H4V8z"></path></g>
<g id="fullscreen"><path d="M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z"></path></g>
<g id="fullscreen-exit"><path d="M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z"></path></g>
<g id="g-translate"><path d="M20 5h-9.12L10 2H4c-1.1 0-2 .9-2 2v13c0 1.1.9 2 2 2h7l1 3h8c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zM7.17 14.59c-2.25 0-4.09-1.83-4.09-4.09s1.83-4.09 4.09-4.09c1.04 0 1.99.37 2.74 1.07l.07.06-1.23 1.18-.06-.05c-.29-.27-.78-.59-1.52-.59-1.31 0-2.38 1.09-2.38 2.42s1.07 2.42 2.38 2.42c1.37 0 1.96-.87 2.12-1.46H7.08V9.91h3.95l.01.07c.04.21.05.4.05.61 0 2.35-1.61 4-3.92 4zm6.03-1.71c.33.6.74 1.18 1.19 1.7l-.54.53-.65-2.23zm.77-.76h-.99l-.31-1.04h3.99s-.34 1.31-1.56 2.74c-.52-.62-.89-1.23-1.13-1.7zM21 20c0 .55-.45 1-1 1h-7l2-2-.81-2.77.92-.92L17.79 18l.73-.73-2.71-2.68c.9-1.03 1.6-2.25 1.92-3.51H19v-1.04h-3.64V9h-1.04v1.04h-1.96L11.18 6H20c.55 0 1 .45 1 1v13z"></path></g>
<g id="gavel"><path d="M1 21h12v2H1zM5.245 8.07l2.83-2.827 14.14 14.142-2.828 2.828zM12.317 1l5.657 5.656-2.83 2.83-5.654-5.66zM3.825 9.485l5.657 5.657-2.828 2.828-5.657-5.657z"></path></g>
<g id="gesture"><path d="M4.59 6.89c.7-.71 1.4-1.35 1.71-1.22.5.2 0 1.03-.3 1.52-.25.42-2.86 3.89-2.86 6.31 0 1.28.48 2.34 1.34 2.98.75.56 1.74.73 2.64.46 1.07-.31 1.95-1.4 3.06-2.77 1.21-1.49 2.83-3.44 4.08-3.44 1.63 0 1.65 1.01 1.76 1.79-3.78.64-5.38 3.67-5.38 5.37 0 1.7 1.44 3.09 3.21 3.09 1.63 0 4.29-1.33 4.69-6.1H21v-2.5h-2.47c-.15-1.65-1.09-4.2-4.03-4.2-2.25 0-4.18 1.91-4.94 2.84-.58.73-2.06 2.48-2.29 2.72-.25.3-.68.84-1.11.84-.45 0-.72-.83-.36-1.92.35-1.09 1.4-2.86 1.85-3.52.78-1.14 1.3-1.92 1.3-3.28C8.95 3.69 7.31 3 6.44 3 5.12 3 3.97 4 3.72 4.25c-.36.36-.66.66-.88.93l1.75 1.71zm9.29 11.66c-.31 0-.74-.26-.74-.72 0-.6.73-2.2 2.87-2.76-.3 2.69-1.43 3.48-2.13 3.48z"></path></g>
<g id="get-app"><path d="M19 9h-4V3H9v6H5l7 7 7-7zM5 18v2h14v-2H5z"></path></g>
<g id="gif"><path d="M11.5 9H13v6h-1.5zM9 9H6c-.6 0-1 .5-1 1v4c0 .5.4 1 1 1h3c.6 0 1-.5 1-1v-2H8.5v1.5h-2v-3H10V10c0-.5-.4-1-1-1zm10 1.5V9h-4.5v6H16v-2h2v-1.5h-2v-1z"></path></g>
<g id="grade"><path d="M12 17.27L18.18 21l-1.64-7.03L22 9.24l-7.19-.61L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21z"></path></g>
<g id="group-work"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zM8 17.5c-1.38 0-2.5-1.12-2.5-2.5s1.12-2.5 2.5-2.5 2.5 1.12 2.5 2.5-1.12 2.5-2.5 2.5zM9.5 8c0-1.38 1.12-2.5 2.5-2.5s2.5 1.12 2.5 2.5-1.12 2.5-2.5 2.5S9.5 9.38 9.5 8zm6.5 9.5c-1.38 0-2.5-1.12-2.5-2.5s1.12-2.5 2.5-2.5 2.5 1.12 2.5 2.5-1.12 2.5-2.5 2.5z"></path></g>
<g id="help"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 17h-2v-2h2v2zm2.07-7.75l-.9.92C13.45 12.9 13 13.5 13 15h-2v-.5c0-1.1.45-2.1 1.17-2.83l1.24-1.26c.37-.36.59-.86.59-1.41 0-1.1-.9-2-2-2s-2 .9-2 2H8c0-2.21 1.79-4 4-4s4 1.79 4 4c0 .88-.36 1.68-.93 2.25z"></path></g>
<g id="help-outline"><path d="M11 18h2v-2h-2v2zm1-16C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm0-14c-2.21 0-4 1.79-4 4h2c0-1.1.9-2 2-2s2 .9 2 2c0 2-3 1.75-3 5h2c0-2.25 3-2.5 3-5 0-2.21-1.79-4-4-4z"></path></g>
<g id="highlight-off"><path d="M14.59 8L12 10.59 9.41 8 8 9.41 10.59 12 8 14.59 9.41 16 12 13.41 14.59 16 16 14.59 13.41 12 16 9.41 14.59 8zM12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z"></path></g>
<g id="history"><path d="M13 3c-4.97 0-9 4.03-9 9H1l3.89 3.89.07.14L9 12H6c0-3.87 3.13-7 7-7s7 3.13 7 7-3.13 7-7 7c-1.93 0-3.68-.79-4.94-2.06l-1.42 1.42C8.27 19.99 10.51 21 13 21c4.97 0 9-4.03 9-9s-4.03-9-9-9zm-1 5v5l4.28 2.54.72-1.21-3.5-2.08V8H12z"></path></g>
<g id="home"><path d="M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z"></path></g>
<g id="hourglass-empty"><path d="M6 2v6h.01L6 8.01 10 12l-4 4 .01.01H6V22h12v-5.99h-.01L18 16l-4-4 4-3.99-.01-.01H18V2H6zm10 14.5V20H8v-3.5l4-4 4 4zm-4-5l-4-4V4h8v3.5l-4 4z"></path></g>
<g id="hourglass-full"><path d="M6 2v6h.01L6 8.01 10 12l-4 4 .01.01H6V22h12v-5.99h-.01L18 16l-4-4 4-3.99-.01-.01H18V2H6z"></path></g>
<g id="http"><path d="M4.5 11h-2V9H1v6h1.5v-2.5h2V15H6V9H4.5v2zm2.5-.5h1.5V15H10v-4.5h1.5V9H7v1.5zm5.5 0H14V15h1.5v-4.5H17V9h-4.5v1.5zm9-1.5H18v6h1.5v-2h2c.8 0 1.5-.7 1.5-1.5v-1c0-.8-.7-1.5-1.5-1.5zm0 2.5h-2v-1h2v1z"></path></g>
<g id="https"><path d="M18 8h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2zm-6 9c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2zm3.1-9H8.9V6c0-1.71 1.39-3.1 3.1-3.1 1.71 0 3.1 1.39 3.1 3.1v2z"></path></g>
<g id="important-devices"><path d="M23 11.01L18 11c-.55 0-1 .45-1 1v9c0 .55.45 1 1 1h5c.55 0 1-.45 1-1v-9c0-.55-.45-.99-1-.99zM23 20h-5v-7h5v7zM20 2H2C.89 2 0 2.89 0 4v12c0 1.1.89 2 2 2h7v2H7v2h8v-2h-2v-2h2v-2H2V4h18v5h2V4c0-1.11-.9-2-2-2zm-8.03 7L11 6l-.97 3H7l2.47 1.76-.94 2.91 2.47-1.8 2.47 1.8-.94-2.91L15 9h-3.03z"></path></g>
<g id="inbox"><path d="M19 3H4.99c-1.11 0-1.98.89-1.98 2L3 19c0 1.1.88 2 1.99 2H19c1.1 0 2-.9 2-2V5c0-1.11-.9-2-2-2zm0 12h-4c0 1.66-1.35 3-3 3s-3-1.34-3-3H4.99V5H19v10z"></path></g>
<g id="indeterminate-check-box"><path d="M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-2 10H7v-2h10v2z"></path></g>
<g id="info"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z"></path></g>
<g id="info-outline"><path d="M11 17h2v-6h-2v6zm1-15C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zM11 9h2V7h-2v2z"></path></g>
<g id="input"><path d="M21 3.01H3c-1.1 0-2 .9-2 2V9h2V4.99h18v14.03H3V15H1v4.01c0 1.1.9 1.98 2 1.98h18c1.1 0 2-.88 2-1.98v-14c0-1.11-.9-2-2-2zM11 16l4-4-4-4v3H1v2h10v3z"></path></g>
<g id="invert-colors"><path d="M17.66 7.93L12 2.27 6.34 7.93c-3.12 3.12-3.12 8.19 0 11.31C7.9 20.8 9.95 21.58 12 21.58c2.05 0 4.1-.78 5.66-2.34 3.12-3.12 3.12-8.19 0-11.31zM12 19.59c-1.6 0-3.11-.62-4.24-1.76C6.62 16.69 6 15.19 6 13.59s.62-3.11 1.76-4.24L12 5.1v14.49z"></path></g>
<g id="label"><path d="M17.63 5.84C17.27 5.33 16.67 5 16 5L5 5.01C3.9 5.01 3 5.9 3 7v10c0 1.1.9 1.99 2 1.99L16 19c.67 0 1.27-.33 1.63-.84L22 12l-4.37-6.16z"></path></g>
<g id="label-outline"><path d="M17.63 5.84C17.27 5.33 16.67 5 16 5L5 5.01C3.9 5.01 3 5.9 3 7v10c0 1.1.9 1.99 2 1.99L16 19c.67 0 1.27-.33 1.63-.84L22 12l-4.37-6.16zM16 17H5V7h11l3.55 5L16 17z"></path></g>
<g id="language"><path d="M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zm6.93 6h-2.95c-.32-1.25-.78-2.45-1.38-3.56 1.84.63 3.37 1.91 4.33 3.56zM12 4.04c.83 1.2 1.48 2.53 1.91 3.96h-3.82c.43-1.43 1.08-2.76 1.91-3.96zM4.26 14C4.1 13.36 4 12.69 4 12s.1-1.36.26-2h3.38c-.08.66-.14 1.32-.14 2 0 .68.06 1.34.14 2H4.26zm.82 2h2.95c.32 1.25.78 2.45 1.38 3.56-1.84-.63-3.37-1.9-4.33-3.56zm2.95-8H5.08c.96-1.66 2.49-2.93 4.33-3.56C8.81 5.55 8.35 6.75 8.03 8zM12 19.96c-.83-1.2-1.48-2.53-1.91-3.96h3.82c-.43 1.43-1.08 2.76-1.91 3.96zM14.34 14H9.66c-.09-.66-.16-1.32-.16-2 0-.68.07-1.35.16-2h4.68c.09.65.16 1.32.16 2 0 .68-.07 1.34-.16 2zm.25 5.56c.6-1.11 1.06-2.31 1.38-3.56h2.95c-.96 1.65-2.49 2.93-4.33 3.56zM16.36 14c.08-.66.14-1.32.14-2 0-.68-.06-1.34-.14-2h3.38c.16.64.26 1.31.26 2s-.1 1.36-.26 2h-3.38z"></path></g>
<g id="last-page"><path d="M5.59 7.41L10.18 12l-4.59 4.59L7 18l6-6-6-6zM16 6h2v12h-2z"></path></g>
<g id="launch"><path d="M19 19H5V5h7V3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2v-7h-2v7zM14 3v2h3.59l-9.83 9.83 1.41 1.41L19 6.41V10h2V3h-7z"></path></g>
<g id="lightbulb-outline"><path d="M9 21c0 .55.45 1 1 1h4c.55 0 1-.45 1-1v-1H9v1zm3-19C8.14 2 5 5.14 5 9c0 2.38 1.19 4.47 3 5.74V17c0 .55.45 1 1 1h6c.55 0 1-.45 1-1v-2.26c1.81-1.27 3-3.36 3-5.74 0-3.86-3.14-7-7-7zm2.85 11.1l-.85.6V16h-4v-2.3l-.85-.6C7.8 12.16 7 10.63 7 9c0-2.76 2.24-5 5-5s5 2.24 5 5c0 1.63-.8 3.16-2.15 4.1z"></path></g>
<g id="line-style"><path d="M3 16h5v-2H3v2zm6.5 0h5v-2h-5v2zm6.5 0h5v-2h-5v2zM3 20h2v-2H3v2zm4 0h2v-2H7v2zm4 0h2v-2h-2v2zm4 0h2v-2h-2v2zm4 0h2v-2h-2v2zM3 12h8v-2H3v2zm10 0h8v-2h-8v2zM3 4v4h18V4H3z"></path></g>
<g id="line-weight"><path d="M3 17h18v-2H3v2zm0 3h18v-1H3v1zm0-7h18v-3H3v3zm0-9v4h18V4H3z"></path></g>
<g id="link"><path d="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"></path></g>
<g id="list"><path d="M3 13h2v-2H3v2zm0 4h2v-2H3v2zm0-8h2V7H3v2zm4 4h14v-2H7v2zm0 4h14v-2H7v2zM7 7v2h14V7H7z"></path></g>
<g id="lock"><path d="M18 8h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2zm-6 9c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2zm3.1-9H8.9V6c0-1.71 1.39-3.1 3.1-3.1 1.71 0 3.1 1.39 3.1 3.1v2z"></path></g>
<g id="lock-open"><path d="M12 17c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm6-9h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6h1.9c0-1.71 1.39-3.1 3.1-3.1 1.71 0 3.1 1.39 3.1 3.1v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2zm0 12H6V10h12v10z"></path></g>
<g id="lock-outline"><path d="M12 17c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm6-9h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2zM8.9 6c0-1.71 1.39-3.1 3.1-3.1s3.1 1.39 3.1 3.1v2H8.9V6zM18 20H6V10h12v10z"></path></g>
<g id="low-priority"><path d="M14 5h8v2h-8zm0 5.5h8v2h-8zm0 5.5h8v2h-8zM2 11.5C2 15.08 4.92 18 8.5 18H9v2l3-3-3-3v2h-.5C6.02 16 4 13.98 4 11.5S6.02 7 8.5 7H12V5H8.5C4.92 5 2 7.92 2 11.5z"></path></g>
<g id="loyalty"><path d="M21.41 11.58l-9-9C12.05 2.22 11.55 2 11 2H4c-1.1 0-2 .9-2 2v7c0 .55.22 1.05.59 1.42l9 9c.36.36.86.58 1.41.58.55 0 1.05-.22 1.41-.59l7-7c.37-.36.59-.86.59-1.41 0-.55-.23-1.06-.59-1.42zM5.5 7C4.67 7 4 6.33 4 5.5S4.67 4 5.5 4 7 4.67 7 5.5 6.33 7 5.5 7zm11.77 8.27L13 19.54l-4.27-4.27C8.28 14.81 8 14.19 8 13.5c0-1.38 1.12-2.5 2.5-2.5.69 0 1.32.28 1.77.74l.73.72.73-.73c.45-.45 1.08-.73 1.77-.73 1.38 0 2.5 1.12 2.5 2.5 0 .69-.28 1.32-.73 1.77z"></path></g>
<g id="mail"><path d="M20 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 4l-8 5-8-5V6l8 5 8-5v2z"></path></g>
<g id="markunread"><path d="M20 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 4l-8 5-8-5V6l8 5 8-5v2z"></path></g>
<g id="markunread-mailbox"><path d="M20 6H10v6H8V4h6V0H6v6H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2z"></path></g>
<g id="menu"><path d="M3 18h18v-2H3v2zm0-5h18v-2H3v2zm0-7v2h18V6H3z"></path></g>
<g id="more-horiz"><path d="M6 10c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm12 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm-6 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"></path></g>
<g id="more-vert"><path d="M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"></path></g>
<g id="motorcycle"><path d="M19.44 9.03L15.41 5H11v2h3.59l2 2H5c-2.8 0-5 2.2-5 5s2.2 5 5 5c2.46 0 4.45-1.69 4.9-4h1.65l2.77-2.77c-.21.54-.32 1.14-.32 1.77 0 2.8 2.2 5 5 5s5-2.2 5-5c0-2.65-1.97-4.77-4.56-4.97zM7.82 15C7.4 16.15 6.28 17 5 17c-1.63 0-3-1.37-3-3s1.37-3 3-3c1.28 0 2.4.85 2.82 2H5v2h2.82zM19 17c-1.66 0-3-1.34-3-3s1.34-3 3-3 3 1.34 3 3-1.34 3-3 3z"></path></g>
<g id="move-to-inbox"><path d="M19 3H4.99c-1.11 0-1.98.9-1.98 2L3 19c0 1.1.88 2 1.99 2H19c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 12h-4c0 1.66-1.35 3-3 3s-3-1.34-3-3H4.99V5H19v10zm-3-5h-2V7h-4v3H8l4 4 4-4z"></path></g>
<g id="next-week"><path d="M20 7h-4V5c0-.55-.22-1.05-.59-1.41C15.05 3.22 14.55 3 14 3h-4c-1.1 0-2 .9-2 2v2H4c-1.1 0-2 .9-2 2v11c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V9c0-1.1-.9-2-2-2zM10 5h4v2h-4V5zm1 13.5l-1-1 3-3-3-3 1-1 4 4-4 4z"></path></g>
<g id="note-add"><path d="M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zm2 14h-3v3h-2v-3H8v-2h3v-3h2v3h3v2zm-3-7V3.5L18.5 9H13z"></path></g>
<g id="offline-pin"><path d="M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10 10-4.5 10-10S17.5 2 12 2zm5 16H7v-2h10v2zm-6.7-4L7 10.7l1.4-1.4 1.9 1.9 5.3-5.3L17 7.3 10.3 14z"></path></g>
<g id="opacity"><path d="M17.66 8L12 2.35 6.34 8C4.78 9.56 4 11.64 4 13.64s.78 4.11 2.34 5.67 3.61 2.35 5.66 2.35 4.1-.79 5.66-2.35S20 15.64 20 13.64 19.22 9.56 17.66 8zM6 14c.01-2 .62-3.27 1.76-4.4L12 5.27l4.24 4.38C17.38 10.77 17.99 12 18 14H6z"></path></g>
<g id="open-in-browser"><path d="M19 4H5c-1.11 0-2 .9-2 2v12c0 1.1.89 2 2 2h4v-2H5V8h14v10h-4v2h4c1.1 0 2-.9 2-2V6c0-1.1-.89-2-2-2zm-7 6l-4 4h3v6h2v-6h3l-4-4z"></path></g>
<g id="open-in-new"><path d="M19 19H5V5h7V3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2v-7h-2v7zM14 3v2h3.59l-9.83 9.83 1.41 1.41L19 6.41V10h2V3h-7z"></path></g>
<g id="open-with"><path d="M10 9h4V6h3l-5-5-5 5h3v3zm-1 1H6V7l-5 5 5 5v-3h3v-4zm14 2l-5-5v3h-3v4h3v3l5-5zm-9 3h-4v3H7l5 5 5-5h-3v-3z"></path></g>
<g id="pageview"><path d="M11.5 9C10.12 9 9 10.12 9 11.5s1.12 2.5 2.5 2.5 2.5-1.12 2.5-2.5S12.88 9 11.5 9zM20 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm-3.21 14.21l-2.91-2.91c-.69.44-1.51.7-2.39.7C9.01 16 7 13.99 7 11.5S9.01 7 11.5 7 16 9.01 16 11.5c0 .88-.26 1.69-.7 2.39l2.91 2.9-1.42 1.42z"></path></g>
<g id="pan-tool"><path d="M23 5.5V20c0 2.2-1.8 4-4 4h-7.3c-1.08 0-2.1-.43-2.85-1.19L1 14.83s1.26-1.23 1.3-1.25c.22-.19.49-.29.79-.29.22 0 .42.06.6.16.04.01 4.31 2.46 4.31 2.46V4c0-.83.67-1.5 1.5-1.5S11 3.17 11 4v7h1V1.5c0-.83.67-1.5 1.5-1.5S15 .67 15 1.5V11h1V2.5c0-.83.67-1.5 1.5-1.5s1.5.67 1.5 1.5V11h1V5.5c0-.83.67-1.5 1.5-1.5s1.5.67 1.5 1.5z"></path></g>
<g id="payment"><path d="M20 4H4c-1.11 0-1.99.89-1.99 2L2 18c0 1.11.89 2 2 2h16c1.11 0 2-.89 2-2V6c0-1.11-.89-2-2-2zm0 14H4v-6h16v6zm0-10H4V6h16v2z"></path></g>
<g id="perm-camera-mic"><path d="M20 5h-3.17L15 3H9L7.17 5H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h7v-2.09c-2.83-.48-5-2.94-5-5.91h2c0 2.21 1.79 4 4 4s4-1.79 4-4h2c0 2.97-2.17 5.43-5 5.91V21h7c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm-6 8c0 1.1-.9 2-2 2s-2-.9-2-2V9c0-1.1.9-2 2-2s2 .9 2 2v4z"></path></g>
<g id="perm-contact-calendar"><path d="M19 3h-1V1h-2v2H8V1H6v2H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-7 3c1.66 0 3 1.34 3 3s-1.34 3-3 3-3-1.34-3-3 1.34-3 3-3zm6 12H6v-1c0-2 4-3.1 6-3.1s6 1.1 6 3.1v1z"></path></g>
<g id="perm-data-setting"><path d="M18.99 11.5c.34 0 .67.03 1 .07L20 0 0 20h11.56c-.04-.33-.07-.66-.07-1 0-4.14 3.36-7.5 7.5-7.5zm3.71 7.99c.02-.16.04-.32.04-.49 0-.17-.01-.33-.04-.49l1.06-.83c.09-.08.12-.21.06-.32l-1-1.73c-.06-.11-.19-.15-.31-.11l-1.24.5c-.26-.2-.54-.37-.85-.49l-.19-1.32c-.01-.12-.12-.21-.24-.21h-2c-.12 0-.23.09-.25.21l-.19 1.32c-.3.13-.59.29-.85.49l-1.24-.5c-.11-.04-.24 0-.31.11l-1 1.73c-.06.11-.04.24.06.32l1.06.83c-.02.16-.03.32-.03.49 0 .17.01.33.03.49l-1.06.83c-.09.08-.12.21-.06.32l1 1.73c.06.11.19.15.31.11l1.24-.5c.26.2.54.37.85.49l.19 1.32c.02.12.12.21.25.21h2c.12 0 .23-.09.25-.21l.19-1.32c.3-.13.59-.29.84-.49l1.25.5c.11.04.24 0 .31-.11l1-1.73c.06-.11.03-.24-.06-.32l-1.07-.83zm-3.71 1.01c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5z"></path></g>
<g id="perm-device-information"><path d="M13 7h-2v2h2V7zm0 4h-2v6h2v-6zm4-9.99L7 1c-1.1 0-2 .9-2 2v18c0 1.1.9 2 2 2h10c1.1 0 2-.9 2-2V3c0-1.1-.9-1.99-2-1.99zM17 19H7V5h10v14z"></path></g>
<g id="perm-identity"><path d="M12 5.9c1.16 0 2.1.94 2.1 2.1s-.94 2.1-2.1 2.1S9.9 9.16 9.9 8s.94-2.1 2.1-2.1m0 9c2.97 0 6.1 1.46 6.1 2.1v1.1H5.9V17c0-.64 3.13-2.1 6.1-2.1M12 4C9.79 4 8 5.79 8 8s1.79 4 4 4 4-1.79 4-4-1.79-4-4-4zm0 9c-2.67 0-8 1.34-8 4v3h16v-3c0-2.66-5.33-4-8-4z"></path></g>
<g id="perm-media"><path d="M2 6H0v5h.01L0 20c0 1.1.9 2 2 2h18v-2H2V6zm20-2h-8l-2-2H6c-1.1 0-1.99.9-1.99 2L4 16c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zM7 15l4.5-6 3.5 4.51 2.5-3.01L21 15H7z"></path></g>
<g id="perm-phone-msg"><path d="M20 15.5c-1.25 0-2.45-.2-3.57-.57-.35-.11-.74-.03-1.02.24l-2.2 2.2c-2.83-1.44-5.15-3.75-6.59-6.58l2.2-2.21c.28-.27.36-.66.25-1.01C8.7 6.45 8.5 5.25 8.5 4c0-.55-.45-1-1-1H4c-.55 0-1 .45-1 1 0 9.39 7.61 17 17 17 .55 0 1-.45 1-1v-3.5c0-.55-.45-1-1-1zM12 3v10l3-3h6V3h-9z"></path></g>
<g id="perm-scan-wifi"><path d="M12 3C6.95 3 3.15 4.85 0 7.23L12 22 24 7.25C20.85 4.87 17.05 3 12 3zm1 13h-2v-6h2v6zm-2-8V6h2v2h-2z"></path></g>
<g id="pets"><circle cx="4.5" cy="9.5" r="2.5"></circle><circle cx="9" cy="5.5" r="2.5"></circle><circle cx="15" cy="5.5" r="2.5"></circle><circle cx="19.5" cy="9.5" r="2.5"></circle><path d="M17.34 14.86c-.87-1.02-1.6-1.89-2.48-2.91-.46-.54-1.05-1.08-1.75-1.32-.11-.04-.22-.07-.33-.09-.25-.04-.52-.04-.78-.04s-.53 0-.79.05c-.11.02-.22.05-.33.09-.7.24-1.28.78-1.75 1.32-.87 1.02-1.6 1.89-2.48 2.91-1.31 1.31-2.92 2.76-2.62 4.79.29 1.02 1.02 2.03 2.33 2.32.73.15 3.06-.44 5.54-.44h.18c2.48 0 4.81.58 5.54.44 1.31-.29 2.04-1.31 2.33-2.32.31-2.04-1.3-3.49-2.61-4.8z"></path></g>
<g id="picture-in-picture"><path d="M19 7h-8v6h8V7zm2-4H3c-1.1 0-2 .9-2 2v14c0 1.1.9 1.98 2 1.98h18c1.1 0 2-.88 2-1.98V5c0-1.1-.9-2-2-2zm0 16.01H3V4.98h18v14.03z"></path></g>
<g id="picture-in-picture-alt"><path d="M19 11h-8v6h8v-6zm4 8V4.98C23 3.88 22.1 3 21 3H3c-1.1 0-2 .88-2 1.98V19c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2zm-2 .02H3V4.97h18v14.05z"></path></g>
<g id="play-for-work"><path d="M11 5v5.59H7.5l4.5 4.5 4.5-4.5H13V5h-2zm-5 9c0 3.31 2.69 6 6 6s6-2.69 6-6h-2c0 2.21-1.79 4-4 4s-4-1.79-4-4H6z"></path></g>
<g id="polymer"><path d="M19 4h-4L7.11 16.63 4.5 12 9 4H5L.5 12 5 20h4l7.89-12.63L19.5 12 15 20h4l4.5-8z"></path></g>
<g id="power-settings-new"><path d="M13 3h-2v10h2V3zm4.83 2.17l-1.42 1.42C17.99 7.86 19 9.81 19 12c0 3.87-3.13 7-7 7s-7-3.13-7-7c0-2.19 1.01-4.14 2.58-5.42L6.17 5.17C4.23 6.82 3 9.26 3 12c0 4.97 4.03 9 9 9s9-4.03 9-9c0-2.74-1.23-5.18-3.17-6.83z"></path></g>
<g id="pregnant-woman"><path d="M9 4c0-1.11.89-2 2-2s2 .89 2 2-.89 2-2 2-2-.89-2-2zm7 9c-.01-1.34-.83-2.51-2-3 0-1.66-1.34-3-3-3s-3 1.34-3 3v7h2v5h3v-5h3v-4z"></path></g>
<g id="print"><path d="M19 8H5c-1.66 0-3 1.34-3 3v6h4v4h12v-4h4v-6c0-1.66-1.34-3-3-3zm-3 11H8v-5h8v5zm3-7c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm-1-9H6v4h12V3z"></path></g>
<g id="query-builder"><path d="M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8zm.5-13H11v6l5.25 3.15.75-1.23-4.5-2.67z"></path></g>
<g id="question-answer"><path d="M21 6h-2v9H6v2c0 .55.45 1 1 1h11l4 4V7c0-.55-.45-1-1-1zm-4 6V3c0-.55-.45-1-1-1H3c-.55 0-1 .45-1 1v14l4-4h10c.55 0 1-.45 1-1z"></path></g>
<g id="radio-button-checked"><path d="M12 7c-2.76 0-5 2.24-5 5s2.24 5 5 5 5-2.24 5-5-2.24-5-5-5zm0-5C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"></path></g>
<g id="radio-button-unchecked"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"></path></g>
<g id="receipt"><path d="M18 17H6v-2h12v2zm0-4H6v-2h12v2zm0-4H6V7h12v2zM3 22l1.5-1.5L6 22l1.5-1.5L9 22l1.5-1.5L12 22l1.5-1.5L15 22l1.5-1.5L18 22l1.5-1.5L21 22V2l-1.5 1.5L18 2l-1.5 1.5L15 2l-1.5 1.5L12 2l-1.5 1.5L9 2 7.5 3.5 6 2 4.5 3.5 3 2v20z"></path></g>
<g id="record-voice-over"><circle cx="9" cy="9" r="4"></circle><path d="M9 15c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4zm7.76-9.64l-1.68 1.69c.84 1.18.84 2.71 0 3.89l1.68 1.69c2.02-2.02 2.02-5.07 0-7.27zM20.07 2l-1.63 1.63c2.77 3.02 2.77 7.56 0 10.74L20.07 16c3.9-3.89 3.91-9.95 0-14z"></path></g>
<g id="redeem"><path d="M20 6h-2.18c.11-.31.18-.65.18-1 0-1.66-1.34-3-3-3-1.05 0-1.96.54-2.5 1.35l-.5.67-.5-.68C10.96 2.54 10.05 2 9 2 7.34 2 6 3.34 6 5c0 .35.07.69.18 1H4c-1.11 0-1.99.89-1.99 2L2 19c0 1.11.89 2 2 2h16c1.11 0 2-.89 2-2V8c0-1.11-.89-2-2-2zm-5-2c.55 0 1 .45 1 1s-.45 1-1 1-1-.45-1-1 .45-1 1-1zM9 4c.55 0 1 .45 1 1s-.45 1-1 1-1-.45-1-1 .45-1 1-1zm11 15H4v-2h16v2zm0-5H4V8h5.08L7 10.83 8.62 12 11 8.76l1-1.36 1 1.36L15.38 12 17 10.83 14.92 8H20v6z"></path></g>
<g id="redo"><path d="M18.4 10.6C16.55 8.99 14.15 8 11.5 8c-4.65 0-8.58 3.03-9.96 7.22L3.9 16c1.05-3.19 4.05-5.5 7.6-5.5 1.95 0 3.73.72 5.12 1.88L13 16h9V7l-3.6 3.6z"></path></g>
<g id="refresh"><path d="M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4l-2.35 2.35z"></path></g>
<g id="remove"><path d="M19 13H5v-2h14v2z"></path></g>
<g id="remove-circle"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm5 11H7v-2h10v2z"></path></g>
<g id="remove-circle-outline"><path d="M7 11v2h10v-2H7zm5-9C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z"></path></g>
<g id="remove-shopping-cart"><path d="M22.73 22.73L2.77 2.77 2 2l-.73-.73L0 2.54l4.39 4.39 2.21 4.66-1.35 2.45c-.16.28-.25.61-.25.96 0 1.1.9 2 2 2h7.46l1.38 1.38c-.5.36-.83.95-.83 1.62 0 1.1.89 2 1.99 2 .67 0 1.26-.33 1.62-.84L21.46 24l1.27-1.27zM7.42 15c-.14 0-.25-.11-.25-.25l.03-.12.9-1.63h2.36l2 2H7.42zm8.13-2c.75 0 1.41-.41 1.75-1.03l3.58-6.49c.08-.14.12-.31.12-.48 0-.55-.45-1-1-1H6.54l9.01 9zM7 18c-1.1 0-1.99.9-1.99 2S5.9 22 7 22s2-.9 2-2-.9-2-2-2z"></path></g>
<g id="reorder"><path d="M3 15h18v-2H3v2zm0 4h18v-2H3v2zm0-8h18V9H3v2zm0-6v2h18V5H3z"></path></g>
<g id="reply"><path d="M10 9V5l-7 7 7 7v-4.1c5 0 8.5 1.6 11 5.1-1-5-4-10-11-11z"></path></g>
<g id="reply-all"><path d="M7 8V5l-7 7 7 7v-3l-4-4 4-4zm6 1V5l-7 7 7 7v-4.1c5 0 8.5 1.6 11 5.1-1-5-4-10-11-11z"></path></g>
<g id="report"><path d="M15.73 3H8.27L3 8.27v7.46L8.27 21h7.46L21 15.73V8.27L15.73 3zM12 17.3c-.72 0-1.3-.58-1.3-1.3 0-.72.58-1.3 1.3-1.3.72 0 1.3.58 1.3 1.3 0 .72-.58 1.3-1.3 1.3zm1-4.3h-2V7h2v6z"></path></g>
<g id="report-problem"><path d="M1 21h22L12 2 1 21zm12-3h-2v-2h2v2zm0-4h-2v-4h2v4z"></path></g>
<g id="restore"><path d="M13 3c-4.97 0-9 4.03-9 9H1l3.89 3.89.07.14L9 12H6c0-3.87 3.13-7 7-7s7 3.13 7 7-3.13 7-7 7c-1.93 0-3.68-.79-4.94-2.06l-1.42 1.42C8.27 19.99 10.51 21 13 21c4.97 0 9-4.03 9-9s-4.03-9-9-9zm-1 5v5l4.28 2.54.72-1.21-3.5-2.08V8H12z"></path></g>
<g id="restore-page"><path d="M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zm-2 16c-2.05 0-3.81-1.24-4.58-3h1.71c.63.9 1.68 1.5 2.87 1.5 1.93 0 3.5-1.57 3.5-3.5S13.93 9.5 12 9.5c-1.35 0-2.52.78-3.1 1.9l1.6 1.6h-4V9l1.3 1.3C8.69 8.92 10.23 8 12 8c2.76 0 5 2.24 5 5s-2.24 5-5 5z"></path></g>
<g id="room"><path d="M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7zm0 9.5c-1.38 0-2.5-1.12-2.5-2.5s1.12-2.5 2.5-2.5 2.5 1.12 2.5 2.5-1.12 2.5-2.5 2.5z"></path></g>
<g id="rounded-corner"><path d="M19 19h2v2h-2v-2zm0-2h2v-2h-2v2zM3 13h2v-2H3v2zm0 4h2v-2H3v2zm0-8h2V7H3v2zm0-4h2V3H3v2zm4 0h2V3H7v2zm8 16h2v-2h-2v2zm-4 0h2v-2h-2v2zm4 0h2v-2h-2v2zm-8 0h2v-2H7v2zm-4 0h2v-2H3v2zM21 8c0-2.76-2.24-5-5-5h-5v2h5c1.65 0 3 1.35 3 3v5h2V8z"></path></g>
<g id="rowing"><path d="M8.5 14.5L4 19l1.5 1.5L9 17h2l-2.5-2.5zM15 1c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm6 20.01L18 24l-2.99-3.01V19.5l-7.1-7.09c-.31.05-.61.07-.91.07v-2.16c1.66.03 3.61-.87 4.67-2.04l1.4-1.55c.19-.21.43-.38.69-.5.29-.14.62-.23.96-.23h.03C15.99 6.01 17 7.02 17 8.26v5.75c0 .84-.35 1.61-.92 2.16l-3.58-3.58v-2.27c-.63.52-1.43 1.02-2.29 1.39L16.5 18H18l3 3.01z"></path></g>
<g id="save"><path d="M17 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V7l-4-4zm-5 16c-1.66 0-3-1.34-3-3s1.34-3 3-3 3 1.34 3 3-1.34 3-3 3zm3-10H5V5h10v4z"></path></g>
<g id="schedule"><path d="M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8zm.5-13H11v6l5.25 3.15.75-1.23-4.5-2.67z"></path></g>
<g id="search"><path d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"></path></g>
<g id="select-all"><path d="M3 5h2V3c-1.1 0-2 .9-2 2zm0 8h2v-2H3v2zm4 8h2v-2H7v2zM3 9h2V7H3v2zm10-6h-2v2h2V3zm6 0v2h2c0-1.1-.9-2-2-2zM5 21v-2H3c0 1.1.9 2 2 2zm-2-4h2v-2H3v2zM9 3H7v2h2V3zm2 18h2v-2h-2v2zm8-8h2v-2h-2v2zm0 8c1.1 0 2-.9 2-2h-2v2zm0-12h2V7h-2v2zm0 8h2v-2h-2v2zm-4 4h2v-2h-2v2zm0-16h2V3h-2v2zM7 17h10V7H7v10zm2-8h6v6H9V9z"></path></g>
<g id="send"><path d="M2.01 21L23 12 2.01 3 2 10l15 2-15 2z"></path></g>
<g id="settings"><path d="M19.43 12.98c.04-.32.07-.64.07-.98s-.03-.66-.07-.98l2.11-1.65c.19-.15.24-.42.12-.64l-2-3.46c-.12-.22-.39-.3-.61-.22l-2.49 1c-.52-.4-1.08-.73-1.69-.98l-.38-2.65C14.46 2.18 14.25 2 14 2h-4c-.25 0-.46.18-.49.42l-.38 2.65c-.61.25-1.17.59-1.69.98l-2.49-1c-.23-.09-.49 0-.61.22l-2 3.46c-.13.22-.07.49.12.64l2.11 1.65c-.04.32-.07.65-.07.98s.03.66.07.98l-2.11 1.65c-.19.15-.24.42-.12.64l2 3.46c.12.22.39.3.61.22l2.49-1c.52.4 1.08.73 1.69.98l.38 2.65c.03.24.24.42.49.42h4c.25 0 .46-.18.49-.42l.38-2.65c.61-.25 1.17-.59 1.69-.98l2.49 1c.23.09.49 0 .61-.22l2-3.46c.12-.22.07-.49-.12-.64l-2.11-1.65zM12 15.5c-1.93 0-3.5-1.57-3.5-3.5s1.57-3.5 3.5-3.5 3.5 1.57 3.5 3.5-1.57 3.5-3.5 3.5z"></path></g>
<g id="settings-applications"><path d="M12 10c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm7-7H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.11 0 2-.9 2-2V5c0-1.1-.89-2-2-2zm-1.75 9c0 .23-.02.46-.05.68l1.48 1.16c.13.11.17.3.08.45l-1.4 2.42c-.09.15-.27.21-.43.15l-1.74-.7c-.36.28-.76.51-1.18.69l-.26 1.85c-.03.17-.18.3-.35.3h-2.8c-.17 0-.32-.13-.35-.29l-.26-1.85c-.43-.18-.82-.41-1.18-.69l-1.74.7c-.16.06-.34 0-.43-.15l-1.4-2.42c-.09-.15-.05-.34.08-.45l1.48-1.16c-.03-.23-.05-.46-.05-.69 0-.23.02-.46.05-.68l-1.48-1.16c-.13-.11-.17-.3-.08-.45l1.4-2.42c.09-.15.27-.21.43-.15l1.74.7c.36-.28.76-.51 1.18-.69l.26-1.85c.03-.17.18-.3.35-.3h2.8c.17 0 .32.13.35.29l.26 1.85c.43.18.82.41 1.18.69l1.74-.7c.16-.06.34 0 .43.15l1.4 2.42c.09.15.05.34-.08.45l-1.48 1.16c.03.23.05.46.05.69z"></path></g>
<g id="settings-backup-restore"><path d="M14 12c0-1.1-.9-2-2-2s-2 .9-2 2 .9 2 2 2 2-.9 2-2zm-2-9c-4.97 0-9 4.03-9 9H0l4 4 4-4H5c0-3.87 3.13-7 7-7s7 3.13 7 7-3.13 7-7 7c-1.51 0-2.91-.49-4.06-1.3l-1.42 1.44C8.04 20.3 9.94 21 12 21c4.97 0 9-4.03 9-9s-4.03-9-9-9z"></path></g>
<g id="settings-bluetooth"><path d="M11 24h2v-2h-2v2zm-4 0h2v-2H7v2zm8 0h2v-2h-2v2zm2.71-18.29L12 0h-1v7.59L6.41 3 5 4.41 10.59 10 5 15.59 6.41 17 11 12.41V20h1l5.71-5.71-4.3-4.29 4.3-4.29zM13 3.83l1.88 1.88L13 7.59V3.83zm1.88 10.46L13 16.17v-3.76l1.88 1.88z"></path></g>
<g id="settings-brightness"><path d="M21 3H3c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16.01H3V4.99h18v14.02zM8 16h2.5l1.5 1.5 1.5-1.5H16v-2.5l1.5-1.5-1.5-1.5V8h-2.5L12 6.5 10.5 8H8v2.5L6.5 12 8 13.5V16zm4-7c1.66 0 3 1.34 3 3s-1.34 3-3 3V9z"></path></g>
<g id="settings-cell"><path d="M7 24h2v-2H7v2zm4 0h2v-2h-2v2zm4 0h2v-2h-2v2zM16 .01L8 0C6.9 0 6 .9 6 2v16c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V2c0-1.1-.9-1.99-2-1.99zM16 16H8V4h8v12z"></path></g>
<g id="settings-ethernet"><path d="M7.77 6.76L6.23 5.48.82 12l5.41 6.52 1.54-1.28L3.42 12l4.35-5.24zM7 13h2v-2H7v2zm10-2h-2v2h2v-2zm-6 2h2v-2h-2v2zm6.77-7.52l-1.54 1.28L20.58 12l-4.35 5.24 1.54 1.28L23.18 12l-5.41-6.52z"></path></g>
<g id="settings-input-antenna"><path d="M12 5c-3.87 0-7 3.13-7 7h2c0-2.76 2.24-5 5-5s5 2.24 5 5h2c0-3.87-3.13-7-7-7zm1 9.29c.88-.39 1.5-1.26 1.5-2.29 0-1.38-1.12-2.5-2.5-2.5S9.5 10.62 9.5 12c0 1.02.62 1.9 1.5 2.29v3.3L7.59 21 9 22.41l3-3 3 3L16.41 21 13 17.59v-3.3zM12 1C5.93 1 1 5.93 1 12h2c0-4.97 4.03-9 9-9s9 4.03 9 9h2c0-6.07-4.93-11-11-11z"></path></g>
<g id="settings-input-component"><path d="M5 2c0-.55-.45-1-1-1s-1 .45-1 1v4H1v6h6V6H5V2zm4 14c0 1.3.84 2.4 2 2.82V23h2v-4.18c1.16-.41 2-1.51 2-2.82v-2H9v2zm-8 0c0 1.3.84 2.4 2 2.82V23h2v-4.18C6.16 18.4 7 17.3 7 16v-2H1v2zM21 6V2c0-.55-.45-1-1-1s-1 .45-1 1v4h-2v6h6V6h-2zm-8-4c0-.55-.45-1-1-1s-1 .45-1 1v4H9v6h6V6h-2V2zm4 14c0 1.3.84 2.4 2 2.82V23h2v-4.18c1.16-.41 2-1.51 2-2.82v-2h-6v2z"></path></g>
<g id="settings-input-composite"><path d="M5 2c0-.55-.45-1-1-1s-1 .45-1 1v4H1v6h6V6H5V2zm4 14c0 1.3.84 2.4 2 2.82V23h2v-4.18c1.16-.41 2-1.51 2-2.82v-2H9v2zm-8 0c0 1.3.84 2.4 2 2.82V23h2v-4.18C6.16 18.4 7 17.3 7 16v-2H1v2zM21 6V2c0-.55-.45-1-1-1s-1 .45-1 1v4h-2v6h6V6h-2zm-8-4c0-.55-.45-1-1-1s-1 .45-1 1v4H9v6h6V6h-2V2zm4 14c0 1.3.84 2.4 2 2.82V23h2v-4.18c1.16-.41 2-1.51 2-2.82v-2h-6v2z"></path></g>
<g id="settings-input-hdmi"><path d="M18 7V4c0-1.1-.9-2-2-2H8c-1.1 0-2 .9-2 2v3H5v6l3 6v3h8v-3l3-6V7h-1zM8 4h8v3h-2V5h-1v2h-2V5h-1v2H8V4z"></path></g>
<g id="settings-input-svideo"><path d="M8 11.5c0-.83-.67-1.5-1.5-1.5S5 10.67 5 11.5 5.67 13 6.5 13 8 12.33 8 11.5zm7-5c0-.83-.67-1.5-1.5-1.5h-3C9.67 5 9 5.67 9 6.5S9.67 8 10.5 8h3c.83 0 1.5-.67 1.5-1.5zM8.5 15c-.83 0-1.5.67-1.5 1.5S7.67 18 8.5 18s1.5-.67 1.5-1.5S9.33 15 8.5 15zM12 1C5.93 1 1 5.93 1 12s4.93 11 11 11 11-4.93 11-11S18.07 1 12 1zm0 20c-4.96 0-9-4.04-9-9s4.04-9 9-9 9 4.04 9 9-4.04 9-9 9zm5.5-11c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5zm-2 5c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5z"></path></g>
<g id="settings-overscan"><path d="M12.01 5.5L10 8h4l-1.99-2.5zM18 10v4l2.5-1.99L18 10zM6 10l-2.5 2.01L6 14v-4zm8 6h-4l2.01 2.5L14 16zm7-13H3c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16.01H3V4.99h18v14.02z"></path></g>
<g id="settings-phone"><path d="M13 9h-2v2h2V9zm4 0h-2v2h2V9zm3 6.5c-1.25 0-2.45-.2-3.57-.57-.35-.11-.74-.03-1.02.24l-2.2 2.2c-2.83-1.44-5.15-3.75-6.59-6.58l2.2-2.21c.28-.27.36-.66.25-1.01C8.7 6.45 8.5 5.25 8.5 4c0-.55-.45-1-1-1H4c-.55 0-1 .45-1 1 0 9.39 7.61 17 17 17 .55 0 1-.45 1-1v-3.5c0-.55-.45-1-1-1zM19 9v2h2V9h-2z"></path></g>
<g id="settings-power"><path d="M7 24h2v-2H7v2zm4 0h2v-2h-2v2zm2-22h-2v10h2V2zm3.56 2.44l-1.45 1.45C16.84 6.94 18 8.83 18 11c0 3.31-2.69 6-6 6s-6-2.69-6-6c0-2.17 1.16-4.06 2.88-5.12L7.44 4.44C5.36 5.88 4 8.28 4 11c0 4.42 3.58 8 8 8s8-3.58 8-8c0-2.72-1.36-5.12-3.44-6.56zM15 24h2v-2h-2v2z"></path></g>
<g id="settings-remote"><path d="M15 9H9c-.55 0-1 .45-1 1v12c0 .55.45 1 1 1h6c.55 0 1-.45 1-1V10c0-.55-.45-1-1-1zm-3 6c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2zM7.05 6.05l1.41 1.41C9.37 6.56 10.62 6 12 6s2.63.56 3.54 1.46l1.41-1.41C15.68 4.78 13.93 4 12 4s-3.68.78-4.95 2.05zM12 0C8.96 0 6.21 1.23 4.22 3.22l1.41 1.41C7.26 3.01 9.51 2 12 2s4.74 1.01 6.36 2.64l1.41-1.41C17.79 1.23 15.04 0 12 0z"></path></g>
<g id="settings-voice"><path d="M7 24h2v-2H7v2zm5-11c1.66 0 2.99-1.34 2.99-3L15 4c0-1.66-1.34-3-3-3S9 2.34 9 4v6c0 1.66 1.34 3 3 3zm-1 11h2v-2h-2v2zm4 0h2v-2h-2v2zm4-14h-1.7c0 3-2.54 5.1-5.3 5.1S6.7 13 6.7 10H5c0 3.41 2.72 6.23 6 6.72V20h2v-3.28c3.28-.49 6-3.31 6-6.72z"></path></g>
<g id="shop"><path d="M16 6V4c0-1.11-.89-2-2-2h-4c-1.11 0-2 .89-2 2v2H2v13c0 1.11.89 2 2 2h16c1.11 0 2-.89 2-2V6h-6zm-6-2h4v2h-4V4zM9 18V9l7.5 4L9 18z"></path></g>
<g id="shop-two"><path d="M3 9H1v11c0 1.11.89 2 2 2h14c1.11 0 2-.89 2-2H3V9zm15-4V3c0-1.11-.89-2-2-2h-4c-1.11 0-2 .89-2 2v2H5v11c0 1.11.89 2 2 2h14c1.11 0 2-.89 2-2V5h-5zm-6-2h4v2h-4V3zm0 12V8l5.5 3-5.5 4z"></path></g>
<g id="shopping-basket"><path d="M17.21 9l-4.38-6.56c-.19-.28-.51-.42-.83-.42-.32 0-.64.14-.83.43L6.79 9H2c-.55 0-1 .45-1 1 0 .09.01.18.04.27l2.54 9.27c.23.84 1 1.46 1.92 1.46h13c.92 0 1.69-.62 1.93-1.46l2.54-9.27L23 10c0-.55-.45-1-1-1h-4.79zM9 9l3-4.4L15 9H9zm3 8c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2z"></path></g>
<g id="shopping-cart"><path d="M7 18c-1.1 0-1.99.9-1.99 2S5.9 22 7 22s2-.9 2-2-.9-2-2-2zM1 2v2h2l3.6 7.59-1.35 2.45c-.16.28-.25.61-.25.96 0 1.1.9 2 2 2h12v-2H7.42c-.14 0-.25-.11-.25-.25l.03-.12.9-1.63h7.45c.75 0 1.41-.41 1.75-1.03l3.58-6.49c.08-.14.12-.31.12-.48 0-.55-.45-1-1-1H5.21l-.94-2H1zm16 16c-1.1 0-1.99.9-1.99 2s.89 2 1.99 2 2-.9 2-2-.9-2-2-2z"></path></g>
<g id="sort"><path d="M3 18h6v-2H3v2zM3 6v2h18V6H3zm0 7h12v-2H3v2z"></path></g>
<g id="speaker-notes"><path d="M20 2H4c-1.1 0-1.99.9-1.99 2L2 22l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zM8 14H6v-2h2v2zm0-3H6V9h2v2zm0-3H6V6h2v2zm7 6h-5v-2h5v2zm3-3h-8V9h8v2zm0-3h-8V6h8v2z"></path></g>
<g id="speaker-notes-off"><path d="M10.54 11l-.54-.54L7.54 8 6 6.46 2.38 2.84 1.27 1.73 0 3l2.01 2.01L2 22l4-4h9l5.73 5.73L22 22.46 17.54 18l-7-7zM8 14H6v-2h2v2zm-2-3V9l2 2H6zm14-9H4.08L10 7.92V6h8v2h-7.92l1 1H18v2h-4.92l6.99 6.99C21.14 17.95 22 17.08 22 16V4c0-1.1-.9-2-2-2z"></path></g>
<g id="spellcheck"><path d="M12.45 16h2.09L9.43 3H7.57L2.46 16h2.09l1.12-3h5.64l1.14 3zm-6.02-5L8.5 5.48 10.57 11H6.43zm15.16.59l-8.09 8.09L9.83 16l-1.41 1.41 5.09 5.09L23 13l-1.41-1.41z"></path></g>
<g id="star"><path d="M12 17.27L18.18 21l-1.64-7.03L22 9.24l-7.19-.61L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21z"></path></g>
<g id="star-border"><path d="M22 9.24l-7.19-.62L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21 12 17.27 18.18 21l-1.63-7.03L22 9.24zM12 15.4l-3.76 2.27 1-4.28-3.32-2.88 4.38-.38L12 6.1l1.71 4.04 4.38.38-3.32 2.88 1 4.28L12 15.4z"></path></g>
<g id="star-half"><path d="M22 9.24l-7.19-.62L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21 12 17.27 18.18 21l-1.63-7.03L22 9.24zM12 15.4V6.1l1.71 4.04 4.38.38-3.32 2.88 1 4.28L12 15.4z"></path></g>
<g id="stars"><path d="M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zm4.24 16L12 15.45 7.77 18l1.12-4.81-3.73-3.23 4.92-.42L12 5l1.92 4.53 4.92.42-3.73 3.23L16.23 18z"></path></g>
<g id="store"><path d="M20 4H4v2h16V4zm1 10v-2l-1-5H4l-1 5v2h1v6h10v-6h4v6h2v-6h1zm-9 4H6v-4h6v4z"></path></g>
<g id="subdirectory-arrow-left"><path d="M11 9l1.42 1.42L8.83 14H18V4h2v12H8.83l3.59 3.58L11 21l-6-6 6-6z"></path></g>
<g id="subdirectory-arrow-right"><path d="M19 15l-6 6-1.42-1.42L15.17 16H4V4h2v10h9.17l-3.59-3.58L13 9l6 6z"></path></g>
<g id="subject"><path d="M14 17H4v2h10v-2zm6-8H4v2h16V9zM4 15h16v-2H4v2zM4 5v2h16V5H4z"></path></g>
<g id="supervisor-account"><path d="M16.5 12c1.38 0 2.49-1.12 2.49-2.5S17.88 7 16.5 7C15.12 7 14 8.12 14 9.5s1.12 2.5 2.5 2.5zM9 11c1.66 0 2.99-1.34 2.99-3S10.66 5 9 5C7.34 5 6 6.34 6 8s1.34 3 3 3zm7.5 3c-1.83 0-5.5.92-5.5 2.75V19h11v-2.25c0-1.83-3.67-2.75-5.5-2.75zM9 13c-2.33 0-7 1.17-7 3.5V19h7v-2.25c0-.85.33-2.34 2.37-3.47C10.5 13.1 9.66 13 9 13z"></path></g>
<g id="swap-horiz"><path d="M6.99 11L3 15l3.99 4v-3H14v-2H6.99v-3zM21 9l-3.99-4v3H10v2h7.01v3L21 9z"></path></g>
<g id="swap-vert"><path d="M16 17.01V10h-2v7.01h-3L15 21l4-3.99h-3zM9 3L5 6.99h3V14h2V6.99h3L9 3z"></path></g>
<g id="swap-vertical-circle"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zM6.5 9L10 5.5 13.5 9H11v4H9V9H6.5zm11 6L14 18.5 10.5 15H13v-4h2v4h2.5z"></path></g>
<g id="system-update-alt"><path d="M12 16.5l4-4h-3v-9h-2v9H8l4 4zm9-13h-6v1.99h6v14.03H3V5.49h6V3.5H3c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2v-14c0-1.1-.9-2-2-2z"></path></g>
<g id="tab"><path d="M21 3H3c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H3V5h10v4h8v10z"></path></g>
<g id="tab-unselected"><path d="M1 9h2V7H1v2zm0 4h2v-2H1v2zm0-8h2V3c-1.1 0-2 .9-2 2zm8 16h2v-2H9v2zm-8-4h2v-2H1v2zm2 4v-2H1c0 1.1.9 2 2 2zM21 3h-8v6h10V5c0-1.1-.9-2-2-2zm0 14h2v-2h-2v2zM9 5h2V3H9v2zM5 21h2v-2H5v2zM5 5h2V3H5v2zm16 16c1.1 0 2-.9 2-2h-2v2zm0-8h2v-2h-2v2zm-8 8h2v-2h-2v2zm4 0h2v-2h-2v2z"></path></g>
<g id="text-format"><path d="M5 17v2h14v-2H5zm4.5-4.2h5l.9 2.2h2.1L12.75 4h-1.5L6.5 15h2.1l.9-2.2zM12 5.98L13.87 11h-3.74L12 5.98z"></path></g>
<g id="theaters"><path d="M18 3v2h-2V3H8v2H6V3H4v18h2v-2h2v2h8v-2h2v2h2V3h-2zM8 17H6v-2h2v2zm0-4H6v-2h2v2zm0-4H6V7h2v2zm10 8h-2v-2h2v2zm0-4h-2v-2h2v2zm0-4h-2V7h2v2z"></path></g>
<g id="thumb-down"><path d="M15 3H6c-.83 0-1.54.5-1.84 1.22l-3.02 7.05c-.09.23-.14.47-.14.73v1.91l.01.01L1 14c0 1.1.9 2 2 2h6.31l-.95 4.57-.03.32c0 .41.17.79.44 1.06L9.83 23l6.59-6.59c.36-.36.58-.86.58-1.41V5c0-1.1-.9-2-2-2zm4 0v12h4V3h-4z"></path></g>
<g id="thumb-up"><path d="M1 21h4V9H1v12zm22-11c0-1.1-.9-2-2-2h-6.31l.95-4.57.03-.32c0-.41-.17-.79-.44-1.06L14.17 1 7.59 7.59C7.22 7.95 7 8.45 7 9v10c0 1.1.9 2 2 2h9c.83 0 1.54-.5 1.84-1.22l3.02-7.05c.09-.23.14-.47.14-.73v-1.91l-.01-.01L23 10z"></path></g>
<g id="thumbs-up-down"><path d="M12 6c0-.55-.45-1-1-1H5.82l.66-3.18.02-.23c0-.31-.13-.59-.33-.8L5.38 0 .44 4.94C.17 5.21 0 5.59 0 6v6.5c0 .83.67 1.5 1.5 1.5h6.75c.62 0 1.15-.38 1.38-.91l2.26-5.29c.07-.17.11-.36.11-.55V6zm10.5 4h-6.75c-.62 0-1.15.38-1.38.91l-2.26 5.29c-.07.17-.11.36-.11.55V18c0 .55.45 1 1 1h5.18l-.66 3.18-.02.24c0 .31.13.59.33.8l.79.78 4.94-4.94c.27-.27.44-.65.44-1.06v-6.5c0-.83-.67-1.5-1.5-1.5z"></path></g>
<g id="timeline"><path d="M23 8c0 1.1-.9 2-2 2-.18 0-.35-.02-.51-.07l-3.56 3.55c.05.16.07.34.07.52 0 1.1-.9 2-2 2s-2-.9-2-2c0-.18.02-.36.07-.52l-2.55-2.55c-.16.05-.34.07-.52.07s-.36-.02-.52-.07l-4.55 4.56c.05.16.07.33.07.51 0 1.1-.9 2-2 2s-2-.9-2-2 .9-2 2-2c.18 0 .35.02.51.07l4.56-4.55C8.02 9.36 8 9.18 8 9c0-1.1.9-2 2-2s2 .9 2 2c0 .18-.02.36-.07.52l2.55 2.55c.16-.05.34-.07.52-.07s.36.02.52.07l3.55-3.56C19.02 8.35 19 8.18 19 8c0-1.1.9-2 2-2s2 .9 2 2z"></path></g>
<g id="toc"><path d="M3 9h14V7H3v2zm0 4h14v-2H3v2zm0 4h14v-2H3v2zm16 0h2v-2h-2v2zm0-10v2h2V7h-2zm0 6h2v-2h-2v2z"></path></g>
<g id="today"><path d="M19 3h-1V1h-2v2H8V1H6v2H5c-1.11 0-1.99.9-1.99 2L3 19c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H5V8h14v11zM7 10h5v5H7z"></path></g>
<g id="toll"><path d="M15 4c-4.42 0-8 3.58-8 8s3.58 8 8 8 8-3.58 8-8-3.58-8-8-8zm0 14c-3.31 0-6-2.69-6-6s2.69-6 6-6 6 2.69 6 6-2.69 6-6 6zM3 12c0-2.61 1.67-4.83 4-5.65V4.26C3.55 5.15 1 8.27 1 12s2.55 6.85 6 7.74v-2.09c-2.33-.82-4-3.04-4-5.65z"></path></g>
<g id="touch-app"><path d="M9 11.24V7.5C9 6.12 10.12 5 11.5 5S14 6.12 14 7.5v3.74c1.21-.81 2-2.18 2-3.74C16 5.01 13.99 3 11.5 3S7 5.01 7 7.5c0 1.56.79 2.93 2 3.74zm9.84 4.63l-4.54-2.26c-.17-.07-.35-.11-.54-.11H13v-6c0-.83-.67-1.5-1.5-1.5S10 6.67 10 7.5v10.74l-3.43-.72c-.08-.01-.15-.03-.24-.03-.31 0-.59.13-.79.33l-.79.8 4.94 4.94c.27.27.65.44 1.06.44h6.79c.75 0 1.33-.55 1.44-1.28l.75-5.27c.01-.07.02-.14.02-.2 0-.62-.38-1.16-.91-1.38z"></path></g>
<g id="track-changes"><path d="M19.07 4.93l-1.41 1.41C19.1 7.79 20 9.79 20 12c0 4.42-3.58 8-8 8s-8-3.58-8-8c0-4.08 3.05-7.44 7-7.93v2.02C8.16 6.57 6 9.03 6 12c0 3.31 2.69 6 6 6s6-2.69 6-6c0-1.66-.67-3.16-1.76-4.24l-1.41 1.41C15.55 9.9 16 10.9 16 12c0 2.21-1.79 4-4 4s-4-1.79-4-4c0-1.86 1.28-3.41 3-3.86v2.14c-.6.35-1 .98-1 1.72 0 1.1.9 2 2 2s2-.9 2-2c0-.74-.4-1.38-1-1.72V2h-1C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10c0-2.76-1.12-5.26-2.93-7.07z"></path></g>
<g id="translate"><path d="M12.87 15.07l-2.54-2.51.03-.03c1.74-1.94 2.98-4.17 3.71-6.53H17V4h-7V2H8v2H1v1.99h11.17C11.5 7.92 10.44 9.75 9 11.35 8.07 10.32 7.3 9.19 6.69 8h-2c.73 1.63 1.73 3.17 2.98 4.56l-5.09 5.02L4 19l5-5 3.11 3.11.76-2.04zM18.5 10h-2L12 22h2l1.12-3h4.75L21 22h2l-4.5-12zm-2.62 7l1.62-4.33L19.12 17h-3.24z"></path></g>
<g id="trending-down"><path d="M16 18l2.29-2.29-4.88-4.88-4 4L2 7.41 3.41 6l6 6 4-4 6.3 6.29L22 12v6z"></path></g>
<g id="trending-flat"><path d="M22 12l-4-4v3H3v2h15v3z"></path></g>
<g id="trending-up"><path d="M16 6l2.29 2.29-4.88 4.88-4-4L2 16.59 3.41 18l6-6 4 4 6.3-6.29L22 12V6z"></path></g>
<g id="turned-in"><path d="M17 3H7c-1.1 0-1.99.9-1.99 2L5 21l7-3 7 3V5c0-1.1-.9-2-2-2z"></path></g>
<g id="turned-in-not"><path d="M17 3H7c-1.1 0-1.99.9-1.99 2L5 21l7-3 7 3V5c0-1.1-.9-2-2-2zm0 15l-5-2.18L7 18V5h10v13z"></path></g>
<g id="unarchive"><path d="M20.55 5.22l-1.39-1.68C18.88 3.21 18.47 3 18 3H6c-.47 0-.88.21-1.15.55L3.46 5.22C3.17 5.57 3 6.01 3 6.5V19c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V6.5c0-.49-.17-.93-.45-1.28zM12 9.5l5.5 5.5H14v2h-4v-2H6.5L12 9.5zM5.12 5l.82-1h12l.93 1H5.12z"></path></g>
<g id="undo"><path d="M12.5 8c-2.65 0-5.05.99-6.9 2.6L2 7v9h9l-3.62-3.62c1.39-1.16 3.16-1.88 5.12-1.88 3.54 0 6.55 2.31 7.6 5.5l2.37-.78C21.08 11.03 17.15 8 12.5 8z"></path></g>
<g id="unfold-less"><path d="M7.41 18.59L8.83 20 12 16.83 15.17 20l1.41-1.41L12 14l-4.59 4.59zm9.18-13.18L15.17 4 12 7.17 8.83 4 7.41 5.41 12 10l4.59-4.59z"></path></g>
<g id="unfold-more"><path d="M12 5.83L15.17 9l1.41-1.41L12 3 7.41 7.59 8.83 9 12 5.83zm0 12.34L8.83 15l-1.41 1.41L12 21l4.59-4.59L15.17 15 12 18.17z"></path></g>
<g id="update"><path d="M21 10.12h-6.78l2.74-2.82c-2.73-2.7-7.15-2.8-9.88-.1-2.73 2.71-2.73 7.08 0 9.79 2.73 2.71 7.15 2.71 9.88 0C18.32 15.65 19 14.08 19 12.1h2c0 1.98-.88 4.55-2.64 6.29-3.51 3.48-9.21 3.48-12.72 0-3.5-3.47-3.53-9.11-.02-12.58 3.51-3.47 9.14-3.47 12.65 0L21 3v7.12zM12.5 8v4.25l3.5 2.08-.72 1.21L11 13V8h1.5z"></path></g>
<g id="verified-user"><path d="M12 1L3 5v6c0 5.55 3.84 10.74 9 12 5.16-1.26 9-6.45 9-12V5l-9-4zm-2 16l-4-4 1.41-1.41L10 14.17l6.59-6.59L18 9l-8 8z"></path></g>
<g id="view-agenda"><path d="M20 13H3c-.55 0-1 .45-1 1v6c0 .55.45 1 1 1h17c.55 0 1-.45 1-1v-6c0-.55-.45-1-1-1zm0-10H3c-.55 0-1 .45-1 1v6c0 .55.45 1 1 1h17c.55 0 1-.45 1-1V4c0-.55-.45-1-1-1z"></path></g>
<g id="view-array"><path d="M4 18h3V5H4v13zM18 5v13h3V5h-3zM8 18h9V5H8v13z"></path></g>
<g id="view-carousel"><path d="M7 19h10V4H7v15zm-5-2h4V6H2v11zM18 6v11h4V6h-4z"></path></g>
<g id="view-column"><path d="M10 18h5V5h-5v13zm-6 0h5V5H4v13zM16 5v13h5V5h-5z"></path></g>
<g id="view-day"><path d="M2 21h19v-3H2v3zM20 8H3c-.55 0-1 .45-1 1v6c0 .55.45 1 1 1h17c.55 0 1-.45 1-1V9c0-.55-.45-1-1-1zM2 3v3h19V3H2z"></path></g>
<g id="view-headline"><path d="M4 15h16v-2H4v2zm0 4h16v-2H4v2zm0-8h16V9H4v2zm0-6v2h16V5H4z"></path></g>
<g id="view-list"><path d="M4 14h4v-4H4v4zm0 5h4v-4H4v4zM4 9h4V5H4v4zm5 5h12v-4H9v4zm0 5h12v-4H9v4zM9 5v4h12V5H9z"></path></g>
<g id="view-module"><path d="M4 11h5V5H4v6zm0 7h5v-6H4v6zm6 0h5v-6h-5v6zm6 0h5v-6h-5v6zm-6-7h5V5h-5v6zm6-6v6h5V5h-5z"></path></g>
<g id="view-quilt"><path d="M10 18h5v-6h-5v6zm-6 0h5V5H4v13zm12 0h5v-6h-5v6zM10 5v6h11V5H10z"></path></g>
<g id="view-stream"><path d="M4 18h17v-6H4v6zM4 5v6h17V5H4z"></path></g>
<g id="view-week"><path d="M6 5H3c-.55 0-1 .45-1 1v12c0 .55.45 1 1 1h3c.55 0 1-.45 1-1V6c0-.55-.45-1-1-1zm14 0h-3c-.55 0-1 .45-1 1v12c0 .55.45 1 1 1h3c.55 0 1-.45 1-1V6c0-.55-.45-1-1-1zm-7 0h-3c-.55 0-1 .45-1 1v12c0 .55.45 1 1 1h3c.55 0 1-.45 1-1V6c0-.55-.45-1-1-1z"></path></g>
<g id="visibility"><path d="M12 4.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5c-1.73-4.39-6-7.5-11-7.5zM12 17c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5zm0-8c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3z"></path></g>
<g id="visibility-off"><path d="M12 7c2.76 0 5 2.24 5 5 0 .65-.13 1.26-.36 1.83l2.92 2.92c1.51-1.26 2.7-2.89 3.43-4.75-1.73-4.39-6-7.5-11-7.5-1.4 0-2.74.25-3.98.7l2.16 2.16C10.74 7.13 11.35 7 12 7zM2 4.27l2.28 2.28.46.46C3.08 8.3 1.78 10.02 1 12c1.73 4.39 6 7.5 11 7.5 1.55 0 3.03-.3 4.38-.84l.42.42L19.73 22 21 20.73 3.27 3 2 4.27zM7.53 9.8l1.55 1.55c-.05.21-.08.43-.08.65 0 1.66 1.34 3 3 3 .22 0 .44-.03.65-.08l1.55 1.55c-.67.33-1.41.53-2.2.53-2.76 0-5-2.24-5-5 0-.79.2-1.53.53-2.2zm4.31-.78l3.15 3.15.02-.16c0-1.66-1.34-3-3-3l-.17.01z"></path></g>
<g id="warning"><path d="M1 21h22L12 2 1 21zm12-3h-2v-2h2v2zm0-4h-2v-4h2v4z"></path></g>
<g id="watch-later"><path d="M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10 10-4.5 10-10S17.5 2 12 2zm4.2 14.2L11 13V7h1.5v5.2l4.5 2.7-.8 1.3z"></path></g>
<g id="weekend"><path d="M21 10c-1.1 0-2 .9-2 2v3H5v-3c0-1.1-.9-2-2-2s-2 .9-2 2v5c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2v-5c0-1.1-.9-2-2-2zm-3-5H6c-1.1 0-2 .9-2 2v2.15c1.16.41 2 1.51 2 2.82V14h12v-2.03c0-1.3.84-2.4 2-2.82V7c0-1.1-.9-2-2-2z"></path></g>
<g id="work"><path d="M20 6h-4V4c0-1.11-.89-2-2-2h-4c-1.11 0-2 .89-2 2v2H4c-1.11 0-1.99.89-1.99 2L2 19c0 1.11.89 2 2 2h16c1.11 0 2-.89 2-2V8c0-1.11-.89-2-2-2zm-6 0h-4V4h4v2z"></path></g>
<g id="youtube-searched-for"><path d="M17.01 14h-.8l-.27-.27c.98-1.14 1.57-2.61 1.57-4.23 0-3.59-2.91-6.5-6.5-6.5s-6.5 3-6.5 6.5H2l3.84 4 4.16-4H6.51C6.51 7 8.53 5 11.01 5s4.5 2.01 4.5 4.5c0 2.48-2.02 4.5-4.5 4.5-.65 0-1.26-.14-1.82-.38L7.71 15.1c.97.57 2.09.9 3.3.9 1.61 0 3.08-.59 4.22-1.57l.27.27v.79l5.01 4.99L22 19l-4.99-5z"></path></g>
<g id="zoom-in"><path d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14zm2.5-4h-2v2H9v-2H7V9h2V7h1v2h2v1z"></path></g>
<g id="zoom-out"><path d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14zM7 9h5v1H7z"></path></g>
</defs></svg>
</iron-iconset-svg>`;document.head.appendChild(template$k.content);
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */
var KEY_IDENTIFIER={"U+0008":"backspace","U+0009":"tab","U+001B":"esc","U+0020":"space","U+007F":"del"},KEY_CODE={8:"backspace",9:"tab",13:"enter",27:"esc",33:"pageup",34:"pagedown",35:"end",36:"home",32:"space",37:"left",38:"up",39:"right",40:"down",46:"del",106:"*"},MODIFIER_KEYS={shift:"shiftKey",ctrl:"ctrlKey",alt:"altKey",meta:"metaKey"},KEY_CHAR=/[a-z0-9*]/,IDENT_CHAR=/U\+/,ARROW_KEY=/^arrow/,SPACE_KEY=/^space(bar)?/,ESC_KEY=/^escape$/;function transformKey(e,t){var n="";if(e){var r=e.toLowerCase();" "===r||SPACE_KEY.test(r)?n="space":ESC_KEY.test(r)?n="esc":1==r.length?t&&!KEY_CHAR.test(r)||(n=r):n=ARROW_KEY.test(r)?r.replace("arrow",""):"multiply"==r?"*":r}return n}function transformKeyIdentifier(e){var t="";return e&&(e in KEY_IDENTIFIER?t=KEY_IDENTIFIER[e]:IDENT_CHAR.test(e)?(e=parseInt(e.replace("U+","0x"),16),t=String.fromCharCode(e).toLowerCase()):t=e.toLowerCase()),t}function transformKeyCode(e){var t="";return Number(e)&&(t=e>=65&&e<=90?String.fromCharCode(32+e):e>=112&&e<=123?"f"+(e-112+1):e>=48&&e<=57?String(e-48):e>=96&&e<=105?String(e-96):KEY_CODE[e]),t}function normalizedKeyForEvent(e,t){return e.key?transformKey(e.key,t):e.detail&&e.detail.key?transformKey(e.detail.key,t):transformKeyIdentifier(e.keyIdentifier)||transformKeyCode(e.keyCode)||""}function keyComboMatchesEvent(e,t){return normalizedKeyForEvent(t,e.hasModifiers)===e.key&&(!e.hasModifiers||!!t.shiftKey==!!e.shiftKey&&!!t.ctrlKey==!!e.ctrlKey&&!!t.altKey==!!e.altKey&&!!t.metaKey==!!e.metaKey)}function parseKeyComboString(e){return 1===e.length?{combo:e,key:e,event:"keydown"}:e.split("+").reduce((function(e,t){var n=t.split(":"),r=n[0],i=n[1];return r in MODIFIER_KEYS?(e[MODIFIER_KEYS[r]]=!0,e.hasModifiers=!0):(e.key=r,e.event=i||"keydown"),e}),{combo:e.split(":").shift()})}function parseEventString(e){return e.trim().split(" ").map((function(e){return parseKeyComboString(e)}))}const IronA11yKeysBehavior={properties:{keyEventTarget:{type:Object,value:function(){return this}},stopKeyboardEventPropagation:{type:Boolean,value:!1},_boundKeyHandlers:{type:Array,value:function(){return[]}},_imperativeKeyBindings:{type:Object,value:function(){return{}}}},observers:["_resetKeyEventListeners(keyEventTarget, _boundKeyHandlers)"],keyBindings:{},registered:function(){this._prepKeyBindings()},attached:function(){this._listenKeyEventListeners()},detached:function(){this._unlistenKeyEventListeners()},addOwnKeyBinding:function(e,t){this._imperativeKeyBindings[e]=t,this._prepKeyBindings(),this._resetKeyEventListeners()},removeOwnKeyBindings:function(){this._imperativeKeyBindings={},this._prepKeyBindings(),this._resetKeyEventListeners()},keyboardEventMatchesKeys:function(e,t){for(var n=parseEventString(t),r=0;r<n.length;++r)if(keyComboMatchesEvent(n[r],e))return!0;return!1},_collectKeyBindings:function(){var e=this.behaviors.map((function(e){return e.keyBindings}));return-1===e.indexOf(this.keyBindings)&&e.push(this.keyBindings),e},_prepKeyBindings:function(){for(var e in this._keyBindings={},this._collectKeyBindings().forEach((function(e){for(var t in e)this._addKeyBinding(t,e[t])}),this),this._imperativeKeyBindings)this._addKeyBinding(e,this._imperativeKeyBindings[e]);for(var t in this._keyBindings)this._keyBindings[t].sort((function(e,t){var n=e[0].hasModifiers;return n===t[0].hasModifiers?0:n?-1:1}))},_addKeyBinding:function(e,t){parseEventString(e).forEach((function(e){this._keyBindings[e.event]=this._keyBindings[e.event]||[],this._keyBindings[e.event].push([e,t])}),this)},_resetKeyEventListeners:function(){this._unlistenKeyEventListeners(),this.isAttached&&this._listenKeyEventListeners()},_listenKeyEventListeners:function(){this.keyEventTarget&&Object.keys(this._keyBindings).forEach((function(e){var t=this._onKeyBindingEvent.bind(this,this._keyBindings[e]);this._boundKeyHandlers.push([this.keyEventTarget,e,t]),this.keyEventTarget.addEventListener(e,t)}),this)},_unlistenKeyEventListeners:function(){for(var e;this._boundKeyHandlers.length;)(e=this._boundKeyHandlers.pop())[0].removeEventListener(e[1],e[2])},_onKeyBindingEvent:function(e,t){if(this.stopKeyboardEventPropagation&&t.stopPropagation(),!t.defaultPrevented)for(var n=0;n<e.length;n++){var r=e[n][0],i=e[n][1];if(keyComboMatchesEvent(r,t)&&(this._triggerKeyHandler(r,i,t),t.defaultPrevented))return}},_triggerKeyHandler:function(e,t,n){var r=Object.create(e);r.keyboardEvent=n;var i=new CustomEvent(e.event,{detail:r,cancelable:!0});this[t].call(this,i),i.defaultPrevented&&n.preventDefault()}},IronScrollTargetBehavior={properties:{scrollTarget:{type:HTMLElement,value:function(){return this._defaultScrollTarget}}},observers:["_scrollTargetChanged(scrollTarget, isAttached)"],_shouldHaveListener:!0,_scrollTargetChanged:function(e,t){if(this._oldScrollTarget&&(this._toggleScrollListener(!1,this._oldScrollTarget),this._oldScrollTarget=null),t)if("document"===e)this.scrollTarget=this._doc;else if("string"==typeof e){var n=this.domHost;this.scrollTarget=n&&n.$?n.$[e]:dom$1(this.ownerDocument).querySelector("#"+e)}else this._isValidScrollTarget()&&(this._oldScrollTarget=e,this._toggleScrollListener(this._shouldHaveListener,e))},_scrollHandler:function e(){},get _defaultScrollTarget(){return this._doc},get _doc(){return this.ownerDocument.documentElement},get _scrollTop(){return this._isValidScrollTarget()?this.scrollTarget===this._doc?window.pageYOffset:this.scrollTarget.scrollTop:0},get _scrollLeft(){return this._isValidScrollTarget()?this.scrollTarget===this._doc?window.pageXOffset:this.scrollTarget.scrollLeft:0},set _scrollTop(e){this.scrollTarget===this._doc?window.scrollTo(window.pageXOffset,e):this._isValidScrollTarget()&&(this.scrollTarget.scrollTop=e)},set _scrollLeft(e){this.scrollTarget===this._doc?window.scrollTo(e,window.pageYOffset):this._isValidScrollTarget()&&(this.scrollTarget.scrollLeft=e)},scroll:function(e,t){var n;"object"==typeof e?(n=e.left,t=e.top):n=e,n=n||0,t=t||0,this.scrollTarget===this._doc?window.scrollTo(n,t):this._isValidScrollTarget()&&(this.scrollTarget.scrollLeft=n,this.scrollTarget.scrollTop=t)},get _scrollTargetWidth(){return this._isValidScrollTarget()?this.scrollTarget===this._doc?window.innerWidth:this.scrollTarget.offsetWidth:0},get _scrollTargetHeight(){return this._isValidScrollTarget()?this.scrollTarget===this._doc?window.innerHeight:this.scrollTarget.offsetHeight:0},_isValidScrollTarget:function(){return this.scrollTarget instanceof HTMLElement},_toggleScrollListener:function(e,t){var n=t===this._doc?window:t;e?this._boundScrollHandler||(this._boundScrollHandler=this._scrollHandler.bind(this),n.addEventListener("scroll",this._boundScrollHandler)):this._boundScrollHandler&&(n.removeEventListener("scroll",this._boundScrollHandler),this._boundScrollHandler=null)},toggleScrollListener:function(e){this._shouldHaveListener=e,this._toggleScrollListener(e,this.scrollTarget)}};
/**
    @license
    Copyright (c) 2016 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */
/**
    @license
    Copyright (c) 2016 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */
var IOS=navigator.userAgent.match(/iP(?:hone|ad;(?: U;)? CPU) OS (\d+)/),IOS_TOUCH_SCROLLING=IOS&&IOS[1]>=8,DEFAULT_PHYSICAL_COUNT=3,HIDDEN_Y="-10000px",SECRET_TABINDEX=-100;Polymer({_template:html`
    <style>
      :host {
        display: block;
      }

      @media only screen and (-webkit-max-device-pixel-ratio: 1) {
        :host {
          will-change: transform;
        }
      }

      #items {
        @apply --iron-list-items-container;
        position: relative;
      }

      :host(:not([grid])) #items > ::slotted(*) {
        width: 100%;
      }

      #items > ::slotted(*) {
        box-sizing: border-box;
        margin: 0;
        position: absolute;
        top: 0;
        will-change: transform;
      }
    </style>

    <array-selector id="selector" items="{{items}}" selected="{{selectedItems}}" selected-item="{{selectedItem}}"></array-selector>

    <div id="items">
      <slot></slot>
    </div>
`,is:"iron-list",properties:{items:{type:Array},as:{type:String,value:"item"},indexAs:{type:String,value:"index"},selectedAs:{type:String,value:"selected"},grid:{type:Boolean,value:!1,reflectToAttribute:!0,observer:"_gridChanged"},selectionEnabled:{type:Boolean,value:!1},selectedItem:{type:Object,notify:!0},selectedItems:{type:Object,notify:!0},multiSelection:{type:Boolean,value:!1},scrollOffset:{type:Number,value:0}},observers:["_itemsChanged(items.*)","_selectionEnabledChanged(selectionEnabled)","_multiSelectionChanged(multiSelection)","_setOverflow(scrollTarget, scrollOffset)"],behaviors:[Templatizer,IronResizableBehavior,IronScrollTargetBehavior,OptionalMutableDataBehavior],_ratio:.5,_scrollerPaddingTop:0,_scrollPosition:0,_physicalSize:0,_physicalAverage:0,_physicalAverageCount:0,_physicalTop:0,_virtualCount:0,_estScrollHeight:0,_scrollHeight:0,_viewportHeight:0,_viewportWidth:0,_physicalItems:null,_physicalSizes:null,_firstVisibleIndexVal:null,_lastVisibleIndexVal:null,_maxPages:2,_focusedItem:null,_focusedVirtualIndex:-1,_focusedPhysicalIndex:-1,_offscreenFocusedItem:null,_focusBackfillItem:null,_itemsPerRow:1,_itemWidth:0,_rowHeight:0,_templateCost:0,_parentModel:!0,get _physicalBottom(){return this._physicalTop+this._physicalSize},get _scrollBottom(){return this._scrollPosition+this._viewportHeight},get _virtualEnd(){return this._virtualStart+this._physicalCount-1},get _hiddenContentSize(){return(this.grid?this._physicalRows*this._rowHeight:this._physicalSize)-this._viewportHeight},get _itemsParent(){return dom$1(dom$1(this._userTemplate).parentNode)},get _maxScrollTop(){return this._estScrollHeight-this._viewportHeight+this._scrollOffset},get _maxVirtualStart(){var e=this._convertIndexToCompleteRow(this._virtualCount);return Math.max(0,e-this._physicalCount)},set _virtualStart(e){e=this._clamp(e,0,this._maxVirtualStart),this.grid&&(e-=e%this._itemsPerRow),this._virtualStartVal=e},get _virtualStart(){return this._virtualStartVal||0},set _physicalStart(e){(e%=this._physicalCount)<0&&(e=this._physicalCount+e),this.grid&&(e-=e%this._itemsPerRow),this._physicalStartVal=e},get _physicalStart(){return this._physicalStartVal||0},get _physicalEnd(){return(this._physicalStart+this._physicalCount-1)%this._physicalCount},set _physicalCount(e){this._physicalCountVal=e},get _physicalCount(){return this._physicalCountVal||0},get _optPhysicalSize(){return 0===this._viewportHeight?1/0:this._viewportHeight*this._maxPages},get _isVisible(){return Boolean(this.offsetWidth||this.offsetHeight)},get firstVisibleIndex(){var e=this._firstVisibleIndexVal;if(null==e){var t=this._physicalTop+this._scrollOffset;e=this._iterateItems((function(e,n){return(t+=this._getPhysicalSizeIncrement(e))>this._scrollPosition?this.grid?n-n%this._itemsPerRow:n:this.grid&&this._virtualCount-1===n?n-n%this._itemsPerRow:void 0}))||0,this._firstVisibleIndexVal=e}return e},get lastVisibleIndex(){var e=this._lastVisibleIndexVal;if(null==e){if(this.grid)e=Math.min(this._virtualCount,this.firstVisibleIndex+this._estRowsInView*this._itemsPerRow-1);else{var t=this._physicalTop+this._scrollOffset;this._iterateItems((function(n,r){t<this._scrollBottom&&(e=r),t+=this._getPhysicalSizeIncrement(n)}))}this._lastVisibleIndexVal=e}return e},get _defaultScrollTarget(){return this},get _virtualRowCount(){return Math.ceil(this._virtualCount/this._itemsPerRow)},get _estRowsInView(){return Math.ceil(this._viewportHeight/this._rowHeight)},get _physicalRows(){return Math.ceil(this._physicalCount/this._itemsPerRow)},get _scrollOffset(){return this._scrollerPaddingTop+this.scrollOffset},ready:function(){this.addEventListener("focus",this._didFocus.bind(this),!0)},attached:function(){this._debounce("_render",this._render,animationFrame),this.listen(this,"iron-resize","_resizeHandler"),this.listen(this,"keydown","_keydownHandler")},detached:function(){this.unlisten(this,"iron-resize","_resizeHandler"),this.unlisten(this,"keydown","_keydownHandler")},_setOverflow:function(e){this.style.webkitOverflowScrolling=e===this?"touch":"",this.style.overflowY=e===this?"auto":"",this._lastVisibleIndexVal=null,this._firstVisibleIndexVal=null,this._debounce("_render",this._render,animationFrame)},updateViewportBoundaries:function(){var e=window.getComputedStyle(this);this._scrollerPaddingTop=this.scrollTarget===this?0:parseInt(e["padding-top"],10),this._isRTL=Boolean("rtl"===e.direction),this._viewportWidth=this.$.items.offsetWidth,this._viewportHeight=this._scrollTargetHeight,this.grid&&this._updateGridMetrics()},_scrollHandler:function(){var e=Math.max(0,Math.min(this._maxScrollTop,this._scrollTop)),t=e-this._scrollPosition,n=t>=0;if(this._scrollPosition=e,this._firstVisibleIndexVal=null,this._lastVisibleIndexVal=null,Math.abs(t)>this._physicalSize&&this._physicalSize>0){t-=this._scrollOffset;var r=Math.round(t/this._physicalAverage)*this._itemsPerRow;this._virtualStart=this._virtualStart+r,this._physicalStart=this._physicalStart+r,this._physicalTop=Math.min(Math.floor(this._virtualStart/this._itemsPerRow)*this._physicalAverage,this._scrollPosition),this._update()}else if(this._physicalCount>0){var i=this._getReusables(n);n?(this._physicalTop=i.physicalTop,this._virtualStart=this._virtualStart+i.indexes.length,this._physicalStart=this._physicalStart+i.indexes.length):(this._virtualStart=this._virtualStart-i.indexes.length,this._physicalStart=this._physicalStart-i.indexes.length),this._update(i.indexes,n?null:i.indexes),this._debounce("_increasePoolIfNeeded",this._increasePoolIfNeeded.bind(this,0),microTask)}},_getReusables:function(e){var t,n,r,i=[],a=this._hiddenContentSize*this._ratio,o=this._virtualStart,s=this._virtualEnd,l=this._physicalCount,c=this._physicalTop+this._scrollOffset,h=this._scrollPosition,u=this._scrollBottom;for(e?(t=this._physicalStart,n=h-c):(t=this._physicalEnd,n=this._physicalBottom+this._scrollOffset-u);n-=r=this._getPhysicalSizeIncrement(t),!(i.length>=l||n<=a);)if(e){if(s+i.length+1>=this._virtualCount)break;if(c+r>=h-this._scrollOffset)break;i.push(t),c+=r,t=(t+1)%l}else{if(o-i.length<=0)break;if(c+this._physicalSize-r<=u)break;i.push(t),c-=r,t=0===t?l-1:t-1}return{indexes:i,physicalTop:c-this._scrollOffset}},_update:function(e,t){if(!(e&&0===e.length||0===this._physicalCount)){if(this._manageFocus(),this._assignModels(e),this._updateMetrics(e),t)for(;t.length;){var n=t.pop();this._physicalTop-=this._getPhysicalSizeIncrement(n)}this._positionItems(),this._updateScrollerSize()}},_createPool:function(e){var t,n;this._ensureTemplatized();var r=new Array(e);for(t=0;t<e;t++)n=this.stamp(null),r[t]=n.root.querySelector("*"),this._itemsParent.appendChild(n.root);return r},_isClientFull:function(){return 0!=this._scrollBottom&&this._physicalBottom-1>=this._scrollBottom&&this._physicalTop<=this._scrollPosition},_increasePoolIfNeeded:function(e){var t=this._clamp(this._physicalCount+e,DEFAULT_PHYSICAL_COUNT,this._virtualCount-this._virtualStart);if(t=this._convertIndexToCompleteRow(t),this.grid){var n=t%this._itemsPerRow;n&&t-n<=this._physicalCount&&(t+=this._itemsPerRow),t-=n}var r=t-this._physicalCount,i=Math.round(.5*this._physicalCount);if(!(r<0)){if(r>0){var a=window.performance.now();[].push.apply(this._physicalItems,this._createPool(r));for(var o=0;o<r;o++)this._physicalSizes.push(0);this._physicalCount=this._physicalCount+r,this._physicalStart>this._physicalEnd&&this._isIndexRendered(this._focusedVirtualIndex)&&this._getPhysicalIndex(this._focusedVirtualIndex)<this._physicalEnd&&(this._physicalStart=this._physicalStart+r),this._update(),this._templateCost=(window.performance.now()-a)/r,i=Math.round(.5*this._physicalCount)}this._virtualEnd>=this._virtualCount-1||0===i||(this._isClientFull()?this._physicalSize<this._optPhysicalSize&&this._debounce("_increasePoolIfNeeded",this._increasePoolIfNeeded.bind(this,this._clamp(Math.round(50/this._templateCost),1,i)),idlePeriod):this._debounce("_increasePoolIfNeeded",this._increasePoolIfNeeded.bind(this,i),microTask))}},_render:function(){if(this.isAttached&&this._isVisible)if(0!==this._physicalCount){var e=this._getReusables(!0);this._physicalTop=e.physicalTop,this._virtualStart=this._virtualStart+e.indexes.length,this._physicalStart=this._physicalStart+e.indexes.length,this._update(e.indexes),this._update(),this._increasePoolIfNeeded(0)}else this._virtualCount>0&&(this.updateViewportBoundaries(),this._increasePoolIfNeeded(DEFAULT_PHYSICAL_COUNT))},_ensureTemplatized:function(){if(!this.ctor){this._userTemplate=this.queryEffectiveChildren("template"),this._userTemplate||console.warn("iron-list requires a template to be provided in light-dom");var e={__key__:!0};e[this.as]=!0,e[this.indexAs]=!0,e[this.selectedAs]=!0,e.tabIndex=!0,this._instanceProps=e,this.templatize(this._userTemplate,this.mutableData)}},_gridChanged:function(e,t){void 0!==t&&(this.notifyResize(),flush(),e&&this._updateGridMetrics())},_itemsChanged:function(e){if("items"===e.path)this._virtualStart=0,this._physicalTop=0,this._virtualCount=this.items?this.items.length:0,this._physicalIndexForKey={},this._firstVisibleIndexVal=null,this._lastVisibleIndexVal=null,this._physicalCount=this._physicalCount||0,this._physicalItems=this._physicalItems||[],this._physicalSizes=this._physicalSizes||[],this._physicalStart=0,this._scrollTop>this._scrollOffset&&this._resetScrollPosition(0),this._removeFocusedItem(),this._debounce("_render",this._render,animationFrame);else if("items.splices"===e.path){if(this._adjustVirtualIndex(e.value.indexSplices),this._virtualCount=this.items?this.items.length:0,e.value.indexSplices.some((function(e){return e.addedCount>0||e.removed.length>0}))){var t=this._getActiveElement();this.contains(t)&&t.blur()}var n=e.value.indexSplices.some((function(e){return e.index+e.addedCount>=this._virtualStart&&e.index<=this._virtualEnd}),this);this._isClientFull()&&!n||this._debounce("_render",this._render,animationFrame)}else"items.length"!==e.path&&this._forwardItemPath(e.path,e.value)},_forwardItemPath:function(e,t){var n,r,i,a=(e=e.slice(6)).indexOf(".");-1===a&&(a=e.length);var o=this.modelForElement(this._offscreenFocusedItem),s=parseInt(e.substring(0,a),10);(n=this._isIndexRendered(s))?(r=this._getPhysicalIndex(s),i=this.modelForElement(this._physicalItems[r])):o&&(i=o),i&&i[this.indexAs]===s&&(e=e.substring(a+1),i._setPendingPropertyOrPath(e=this.as+(e?"."+e:""),t,!1,!0),i._flushProperties&&i._flushProperties(),n&&(this._updateMetrics([r]),this._positionItems(),this._updateScrollerSize()))},_adjustVirtualIndex:function(e){e.forEach((function(e){if(e.removed.forEach(this._removeItem,this),e.index<this._virtualStart){var t=Math.max(e.addedCount-e.removed.length,e.index-this._virtualStart);this._virtualStart=this._virtualStart+t,this._focusedVirtualIndex>=0&&(this._focusedVirtualIndex=this._focusedVirtualIndex+t)}}),this)},_removeItem:function(e){this.$.selector.deselect(e),this._focusedItem&&this.modelForElement(this._focusedItem)[this.as]===e&&this._removeFocusedItem()},_iterateItems:function(e,t){var n,r,i,a;if(2===arguments.length&&t){for(a=0;a<t.length;a++)if(r=this._computeVidx(n=t[a]),null!=(i=e.call(this,n,r)))return i}else{for(n=this._physicalStart,r=this._virtualStart;n<this._physicalCount;n++,r++)if(null!=(i=e.call(this,n,r)))return i;for(n=0;n<this._physicalStart;n++,r++)if(null!=(i=e.call(this,n,r)))return i}},_computeVidx:function(e){return e>=this._physicalStart?this._virtualStart+(e-this._physicalStart):this._virtualStart+(this._physicalCount-this._physicalStart)+e},_assignModels:function(e){this._iterateItems((function(e,t){var n=this._physicalItems[e],r=this.items&&this.items[t];if(null!=r){var i=this.modelForElement(n);i.__key__=null,this._forwardProperty(i,this.as,r),this._forwardProperty(i,this.selectedAs,this.$.selector.isSelected(r)),this._forwardProperty(i,this.indexAs,t),this._forwardProperty(i,"tabIndex",this._focusedVirtualIndex===t?0:-1),this._physicalIndexForKey[i.__key__]=e,i._flushProperties&&i._flushProperties(!0),n.removeAttribute("hidden")}else n.setAttribute("hidden","")}),e)},_updateMetrics:function(e){flush();var t=0,n=0,r=this._physicalAverageCount,i=this._physicalAverage;this._iterateItems((function(e,r){n+=this._physicalSizes[e],this._physicalSizes[e]=this._physicalItems[e].offsetHeight,t+=this._physicalSizes[e],this._physicalAverageCount+=this._physicalSizes[e]?1:0}),e),this.grid?(this._updateGridMetrics(),this._physicalSize=Math.ceil(this._physicalCount/this._itemsPerRow)*this._rowHeight):(n=1===this._itemsPerRow?n:Math.ceil(this._physicalCount/this._itemsPerRow)*this._rowHeight,this._physicalSize=this._physicalSize+t-n,this._itemsPerRow=1),this._physicalAverageCount!==r&&(this._physicalAverage=Math.round((i*r+t)/this._physicalAverageCount))},_updateGridMetrics:function(){this._itemWidth=this._physicalCount>0?this._physicalItems[0].getBoundingClientRect().width:200,this._rowHeight=this._physicalCount>0?this._physicalItems[0].offsetHeight:200,this._itemsPerRow=this._itemWidth?Math.floor(this._viewportWidth/this._itemWidth):this._itemsPerRow},_positionItems:function(){this._adjustScrollPosition();var e=this._physicalTop;if(this.grid){var t=(this._viewportWidth-this._itemsPerRow*this._itemWidth)/2;this._iterateItems((function(n,r){var i=Math.floor(r%this._itemsPerRow*this._itemWidth+t);this._isRTL&&(i*=-1),this.translate3d(i+"px",e+"px",0,this._physicalItems[n]),this._shouldRenderNextRow(r)&&(e+=this._rowHeight)}))}else{const t=[];this._iterateItems((function(n,r){const i=this._physicalItems[n];this.translate3d(0,e+"px",0,i),e+=this._physicalSizes[n];const a=i.id;a&&t.push(a)})),t.length&&this.setAttribute("aria-owns",t.join(" "))}},_getPhysicalSizeIncrement:function(e){return this.grid?this._computeVidx(e)%this._itemsPerRow!=this._itemsPerRow-1?0:this._rowHeight:this._physicalSizes[e]},_shouldRenderNextRow:function(e){return e%this._itemsPerRow==this._itemsPerRow-1},_adjustScrollPosition:function(){var e=0===this._virtualStart?this._physicalTop:Math.min(this._scrollPosition+this._physicalTop,0);if(0!==e){this._physicalTop=this._physicalTop-e;var t=this._scrollPosition;!IOS_TOUCH_SCROLLING&&t>0&&this._resetScrollPosition(t-e)}},_resetScrollPosition:function(e){this.scrollTarget&&e>=0&&(this._scrollTop=e,this._scrollPosition=this._scrollTop)},_updateScrollerSize:function(e){this._estScrollHeight=this.grid?this._virtualRowCount*this._rowHeight:this._physicalBottom+Math.max(this._virtualCount-this._physicalCount-this._virtualStart,0)*this._physicalAverage,((e=(e=(e=e||0===this._scrollHeight)||this._scrollPosition>=this._estScrollHeight-this._physicalSize)||this.grid&&this.$.items.style.height<this._estScrollHeight)||Math.abs(this._estScrollHeight-this._scrollHeight)>=this._viewportHeight)&&(this.$.items.style.height=this._estScrollHeight+"px",this._scrollHeight=this._estScrollHeight)},scrollToItem:function(e){return this.scrollToIndex(this.items.indexOf(e))},scrollToIndex:function(e){if(!("number"!=typeof e||e<0||e>this.items.length-1)&&(flush(),0!==this._physicalCount)){e=this._clamp(e,0,this._virtualCount-1),(!this._isIndexRendered(e)||e>=this._maxVirtualStart)&&(this._virtualStart=this.grid?e-2*this._itemsPerRow:e-1),this._manageFocus(),this._assignModels(),this._updateMetrics(),this._physicalTop=Math.floor(this._virtualStart/this._itemsPerRow)*this._physicalAverage;for(var t=this._physicalStart,n=this._virtualStart,r=0,i=this._hiddenContentSize;n<e&&r<=i;)r+=this._getPhysicalSizeIncrement(t),t=(t+1)%this._physicalCount,n++;this._updateScrollerSize(!0),this._positionItems(),this._resetScrollPosition(this._physicalTop+this._scrollOffset+r),this._increasePoolIfNeeded(0),this._firstVisibleIndexVal=null,this._lastVisibleIndexVal=null}},_resetAverage:function(){this._physicalAverage=0,this._physicalAverageCount=0},_resizeHandler:function(){this._debounce("_render",(function(){this._firstVisibleIndexVal=null,this._lastVisibleIndexVal=null,this._isVisible?(this.updateViewportBoundaries(),this.toggleScrollListener(!0),this._resetAverage(),this._render()):this.toggleScrollListener(!1)}),animationFrame)},selectItem:function(e){return this.selectIndex(this.items.indexOf(e))},selectIndex:function(e){if(!(e<0||e>=this._virtualCount)){if(!this.multiSelection&&this.selectedItem&&this.clearSelection(),this._isIndexRendered(e)){var t=this.modelForElement(this._physicalItems[this._getPhysicalIndex(e)]);t&&(t[this.selectedAs]=!0),this.updateSizeForIndex(e)}this.$.selector.selectIndex(e)}},deselectItem:function(e){return this.deselectIndex(this.items.indexOf(e))},deselectIndex:function(e){if(!(e<0||e>=this._virtualCount)){if(this._isIndexRendered(e))this.modelForElement(this._physicalItems[this._getPhysicalIndex(e)])[this.selectedAs]=!1,this.updateSizeForIndex(e);this.$.selector.deselectIndex(e)}},toggleSelectionForItem:function(e){return this.toggleSelectionForIndex(this.items.indexOf(e))},toggleSelectionForIndex:function(e){(this.$.selector.isIndexSelected?this.$.selector.isIndexSelected(e):this.$.selector.isSelected(this.items[e]))?this.deselectIndex(e):this.selectIndex(e)},clearSelection:function(){this._iterateItems((function(e,t){this.modelForElement(this._physicalItems[e])[this.selectedAs]=!1})),this.$.selector.clearSelection()},_selectionEnabledChanged:function(e){(e?this.listen:this.unlisten).call(this,this,"tap","_selectionHandler")},_selectionHandler:function(e){var t=this.modelForElement(e.target);if(t){var n,r,i=dom$1(e).path[0],a=this._getActiveElement(),o=this._physicalItems[this._getPhysicalIndex(t[this.indexAs])];"input"!==i.localName&&"button"!==i.localName&&"select"!==i.localName&&(n=t.tabIndex,t.tabIndex=SECRET_TABINDEX,r=a?a.tabIndex:-1,t.tabIndex=n,a&&o!==a&&o.contains(a)&&r!==SECRET_TABINDEX||this.toggleSelectionForItem(t[this.as]))}},_multiSelectionChanged:function(e){this.clearSelection(),this.$.selector.multi=e},updateSizeForItem:function(e){return this.updateSizeForIndex(this.items.indexOf(e))},updateSizeForIndex:function(e){return this._isIndexRendered(e)?(this._updateMetrics([this._getPhysicalIndex(e)]),this._positionItems(),null):null},_manageFocus:function(){var e=this._focusedVirtualIndex;e>=0&&e<this._virtualCount?this._isIndexRendered(e)?this._restoreFocusedItem():this._createFocusBackfillItem():this._virtualCount>0&&this._physicalCount>0&&(this._focusedPhysicalIndex=this._physicalStart,this._focusedVirtualIndex=this._virtualStart,this._focusedItem=this._physicalItems[this._physicalStart])},_convertIndexToCompleteRow:function(e){return this._itemsPerRow=this._itemsPerRow||1,this.grid?Math.ceil(e/this._itemsPerRow)*this._itemsPerRow:e},_isIndexRendered:function(e){return e>=this._virtualStart&&e<=this._virtualEnd},_isIndexVisible:function(e){return e>=this.firstVisibleIndex&&e<=this.lastVisibleIndex},_getPhysicalIndex:function(e){return(this._physicalStart+(e-this._virtualStart))%this._physicalCount},focusItem:function(e){this._focusPhysicalItem(e)},_focusPhysicalItem:function(e){if(!(e<0||e>=this._virtualCount)){this._restoreFocusedItem(),this._isIndexRendered(e)||this.scrollToIndex(e);var t,n=this._physicalItems[this._getPhysicalIndex(e)],r=this.modelForElement(n);r.tabIndex=SECRET_TABINDEX,n.tabIndex===SECRET_TABINDEX&&(t=n),t||(t=dom$1(n).querySelector('[tabindex="'+SECRET_TABINDEX+'"]')),r.tabIndex=0,this._focusedVirtualIndex=e,t&&t.focus()}},_removeFocusedItem:function(){this._offscreenFocusedItem&&this._itemsParent.removeChild(this._offscreenFocusedItem),this._offscreenFocusedItem=null,this._focusBackfillItem=null,this._focusedItem=null,this._focusedVirtualIndex=-1,this._focusedPhysicalIndex=-1},_createFocusBackfillItem:function(){var e=this._focusedPhysicalIndex;if(!(this._offscreenFocusedItem||this._focusedVirtualIndex<0)){if(!this._focusBackfillItem){var t=this.stamp(null);this._focusBackfillItem=t.root.querySelector("*"),this._itemsParent.appendChild(t.root)}this._offscreenFocusedItem=this._physicalItems[e],this.modelForElement(this._offscreenFocusedItem).tabIndex=0,this._physicalItems[e]=this._focusBackfillItem,this._focusedPhysicalIndex=e,this.translate3d(0,HIDDEN_Y,0,this._offscreenFocusedItem)}},_restoreFocusedItem:function(){if(this._offscreenFocusedItem&&!(this._focusedVirtualIndex<0)){this._assignModels();var e=this._focusedPhysicalIndex=this._getPhysicalIndex(this._focusedVirtualIndex),t=this._physicalItems[e];if(t){var n=this.modelForElement(t),r=this.modelForElement(this._offscreenFocusedItem);n[this.as]===r[this.as]?(this._focusBackfillItem=t,n.tabIndex=-1,this._physicalItems[e]=this._offscreenFocusedItem,this.translate3d(0,HIDDEN_Y,0,this._focusBackfillItem)):(this._removeFocusedItem(),this._focusBackfillItem=null),this._offscreenFocusedItem=null}}},_didFocus:function(e){var t=this.modelForElement(e.target),n=this.modelForElement(this._focusedItem),r=null!==this._offscreenFocusedItem,i=this._focusedVirtualIndex;t&&(n===t?this._isIndexVisible(i)||this.scrollToIndex(i):(this._restoreFocusedItem(),n&&(n.tabIndex=-1),t.tabIndex=0,this._focusedVirtualIndex=i=t[this.indexAs],this._focusedPhysicalIndex=this._getPhysicalIndex(i),this._focusedItem=this._physicalItems[this._focusedPhysicalIndex],r&&!this._offscreenFocusedItem&&this._update()))},_keydownHandler:function(e){switch(e.keyCode){case 40:this._focusedVirtualIndex<this._virtualCount-1&&e.preventDefault(),this._focusPhysicalItem(this._focusedVirtualIndex+(this.grid?this._itemsPerRow:1));break;case 39:this.grid&&this._focusPhysicalItem(this._focusedVirtualIndex+(this._isRTL?-1:1));break;case 38:this._focusedVirtualIndex>0&&e.preventDefault(),this._focusPhysicalItem(this._focusedVirtualIndex-(this.grid?this._itemsPerRow:1));break;case 37:this.grid&&this._focusPhysicalItem(this._focusedVirtualIndex+(this._isRTL?1:-1));break;case 13:this._focusPhysicalItem(this._focusedVirtualIndex),this.selectionEnabled&&this._selectionHandler(e)}},_clamp:function(e,t,n){return Math.min(n,Math.max(t,e))},_debounce:function(e,t,n){this._debouncers=this._debouncers||{},this._debouncers[e]=Debouncer.debounce(this._debouncers[e],n,t.bind(this)),enqueueDebouncer(this._debouncers[e])},_forwardProperty:function(e,t,n){e._setPendingProperty(t,n)},_forwardHostPropV2:function(e,t){(this._physicalItems||[]).concat([this._offscreenFocusedItem,this._focusBackfillItem]).forEach((function(n){n&&this.modelForElement(n).forwardHostProp(e,t)}),this)},_notifyInstancePropV2:function(e,t,n){if(matches$1(this.as,t)){var r=e[this.indexAs];t==this.as&&(this.items[r]=n),this.notifyPath(translate(this.as,"items."+r,t),n)}},_getStampedChildren:function(){return this._physicalItems},_forwardInstancePath:function(e,t,n){0===t.indexOf(this.as+".")&&this.notifyPath("items."+e.__key__+"."+t.slice(this.as.length+1),n)},_forwardParentPath:function(e,t){(this._physicalItems||[]).concat([this._offscreenFocusedItem,this._focusBackfillItem]).forEach((function(n){n&&this.modelForElement(n).notifyPath(e,t)}),this)},_forwardParentProp:function(e,t){(this._physicalItems||[]).concat([this._offscreenFocusedItem,this._focusBackfillItem]).forEach((function(n){n&&(this.modelForElement(n)[e]=t)}),this)},_getActiveElement:function(){var e=this._itemsParent.node.domHost;return dom$1(e?e.root:document).activeElement}});
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */
class IronSelection{constructor(e){this.selection=[],this.selectCallback=e}get(){return this.multi?this.selection.slice():this.selection[0]}clear(e){this.selection.slice().forEach((function(t){(!e||e.indexOf(t)<0)&&this.setItemSelected(t,!1)}),this)}isSelected(e){return this.selection.indexOf(e)>=0}setItemSelected(e,t){if(null!=e&&t!==this.isSelected(e)){if(t)this.selection.push(e);else{var n=this.selection.indexOf(e);n>=0&&this.selection.splice(n,1)}this.selectCallback&&this.selectCallback(e,t)}}select(e){this.multi?this.toggle(e):this.get()!==e&&(this.setItemSelected(this.get(),!1),this.setItemSelected(e,!0))}toggle(e){this.setItemSelected(e,!this.isSelected(e))}}
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */const IronSelectableBehavior={properties:{attrForSelected:{type:String,value:null},selected:{type:String,notify:!0},selectedItem:{type:Object,readOnly:!0,notify:!0},activateEvent:{type:String,value:"tap",observer:"_activateEventChanged"},selectable:String,selectedClass:{type:String,value:"iron-selected"},selectedAttribute:{type:String,value:null},fallbackSelection:{type:String,value:null},items:{type:Array,readOnly:!0,notify:!0,value:function(){return[]}},_excludedLocalNames:{type:Object,value:function(){return{template:1,"dom-bind":1,"dom-if":1,"dom-repeat":1}}}},observers:["_updateAttrForSelected(attrForSelected)","_updateSelected(selected)","_checkFallback(fallbackSelection)"],created:function(){this._bindFilterItem=this._filterItem.bind(this),this._selection=new IronSelection(this._applySelection.bind(this))},attached:function(){this._observer=this._observeItems(this),this._addListener(this.activateEvent)},detached:function(){this._observer&&dom$1(this).unobserveNodes(this._observer),this._removeListener(this.activateEvent)},indexOf:function(e){return this.items?this.items.indexOf(e):-1},select:function(e){this.selected=e},selectPrevious:function(){var e=this.items.length,t=e-1;void 0!==this.selected&&(t=(Number(this._valueToIndex(this.selected))-1+e)%e),this.selected=this._indexToValue(t)},selectNext:function(){var e=0;void 0!==this.selected&&(e=(Number(this._valueToIndex(this.selected))+1)%this.items.length),this.selected=this._indexToValue(e)},selectIndex:function(e){this.select(this._indexToValue(e))},forceSynchronousItemUpdate:function(){this._observer&&"function"==typeof this._observer.flush?this._observer.flush():this._updateItems()},get _shouldUpdateSelection(){return null!=this.selected},_checkFallback:function(){this._updateSelected()},_addListener:function(e){this.listen(this,e,"_activateHandler")},_removeListener:function(e){this.unlisten(this,e,"_activateHandler")},_activateEventChanged:function(e,t){this._removeListener(t),this._addListener(e)},_updateItems:function(){var e=dom$1(this).queryDistributedElements(this.selectable||"*");e=Array.prototype.filter.call(e,this._bindFilterItem),this._setItems(e)},_updateAttrForSelected:function(){this.selectedItem&&(this.selected=this._valueForItem(this.selectedItem))},_updateSelected:function(){this._selectSelected(this.selected)},_selectSelected:function(e){if(this.items){var t=this._valueToItem(this.selected);t?this._selection.select(t):this._selection.clear(),this.fallbackSelection&&this.items.length&&void 0===this._selection.get()&&(this.selected=this.fallbackSelection)}},_filterItem:function(e){return!this._excludedLocalNames[e.localName]},_valueToItem:function(e){return null==e?null:this.items[this._valueToIndex(e)]},_valueToIndex:function(e){if(!this.attrForSelected)return Number(e);for(var t,n=0;t=this.items[n];n++)if(this._valueForItem(t)==e)return n},_indexToValue:function(e){if(!this.attrForSelected)return e;var t=this.items[e];return t?this._valueForItem(t):void 0},_valueForItem:function(e){if(!e)return null;if(!this.attrForSelected){var t=this.indexOf(e);return-1===t?null:t}var n=e[dashToCamelCase(this.attrForSelected)];return null!=n?n:e.getAttribute(this.attrForSelected)},_applySelection:function(e,t){this.selectedClass&&this.toggleClass(this.selectedClass,t,e),this.selectedAttribute&&this.toggleAttribute(this.selectedAttribute,t,e),this._selectionChange(),this.fire("iron-"+(t?"select":"deselect"),{item:e})},_selectionChange:function(){this._setSelectedItem(this._selection.get())},_observeItems:function(e){return dom$1(e).observeNodes((function(e){this._updateItems(),this._updateSelected(),this.fire("iron-items-changed",e,{bubbles:!1,cancelable:!1})}))},_activateHandler:function(e){for(var t=e.target,n=this.items;t&&t!=this;){var r=n.indexOf(t);if(r>=0){var i=this._indexToValue(r);return void this._itemActivate(i,t)}t=t.parentNode}},_itemActivate:function(e,t){this.fire("iron-activate",{selected:e,item:t},{cancelable:!0}).defaultPrevented||this.select(e)}};
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */Polymer({_template:html`
    <style>
      :host {
        display: block;
      }

      :host > ::slotted(:not(slot):not(.iron-selected)) {
        display: none !important;
      }
    </style>

    <slot></slot>
`,is:"iron-pages",behaviors:[IronResizableBehavior,IronSelectableBehavior],properties:{activateEvent:{type:String,value:null}},observers:["_selectedPageChanged(selected)"],_selectedPageChanged:function(e,t){this.async(this.notifyResize)}});
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */
const template$j=html`
<custom-style>
  <style is="custom-style">
    html {

      --shadow-transition: {
        transition: box-shadow 0.28s cubic-bezier(0.4, 0, 0.2, 1);
      };

      --shadow-none: {
        box-shadow: none;
      };

      /* from http://codepen.io/shyndman/pen/c5394ddf2e8b2a5c9185904b57421cdb */

      --shadow-elevation-2dp: {
        box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.14),
                    0 1px 5px 0 rgba(0, 0, 0, 0.12),
                    0 3px 1px -2px rgba(0, 0, 0, 0.2);
      };

      --shadow-elevation-3dp: {
        box-shadow: 0 3px 4px 0 rgba(0, 0, 0, 0.14),
                    0 1px 8px 0 rgba(0, 0, 0, 0.12),
                    0 3px 3px -2px rgba(0, 0, 0, 0.4);
      };

      --shadow-elevation-4dp: {
        box-shadow: 0 4px 5px 0 rgba(0, 0, 0, 0.14),
                    0 1px 10px 0 rgba(0, 0, 0, 0.12),
                    0 2px 4px -1px rgba(0, 0, 0, 0.4);
      };

      --shadow-elevation-6dp: {
        box-shadow: 0 6px 10px 0 rgba(0, 0, 0, 0.14),
                    0 1px 18px 0 rgba(0, 0, 0, 0.12),
                    0 3px 5px -1px rgba(0, 0, 0, 0.4);
      };

      --shadow-elevation-8dp: {
        box-shadow: 0 8px 10px 1px rgba(0, 0, 0, 0.14),
                    0 3px 14px 2px rgba(0, 0, 0, 0.12),
                    0 5px 5px -3px rgba(0, 0, 0, 0.4);
      };

      --shadow-elevation-12dp: {
        box-shadow: 0 12px 16px 1px rgba(0, 0, 0, 0.14),
                    0 4px 22px 3px rgba(0, 0, 0, 0.12),
                    0 6px 7px -4px rgba(0, 0, 0, 0.4);
      };

      --shadow-elevation-16dp: {
        box-shadow: 0 16px 24px 2px rgba(0, 0, 0, 0.14),
                    0  6px 30px 5px rgba(0, 0, 0, 0.12),
                    0  8px 10px -5px rgba(0, 0, 0, 0.4);
      };

      --shadow-elevation-24dp: {
        box-shadow: 0 24px 38px 3px rgba(0, 0, 0, 0.14),
                    0 9px 46px 8px rgba(0, 0, 0, 0.12),
                    0 11px 15px -7px rgba(0, 0, 0, 0.4);
      };
    }
  </style>
</custom-style>`;template$j.setAttribute("style","display: none;"),document.head.appendChild(template$j.content);
/**
    @license
    Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */
const template$i=html`
<dom-module id="paper-material-styles">
  <template>
    <style>
      html {
        --paper-material: {
          display: block;
          position: relative;
        };
        --paper-material-elevation-1: {
          @apply --shadow-elevation-2dp;
        };
        --paper-material-elevation-2: {
          @apply --shadow-elevation-4dp;
        };
        --paper-material-elevation-3: {
          @apply --shadow-elevation-6dp;
        };
        --paper-material-elevation-4: {
          @apply --shadow-elevation-8dp;
        };
        --paper-material-elevation-5: {
          @apply --shadow-elevation-16dp;
        };
      }
      .paper-material {
        @apply --paper-material;
      }
      .paper-material[elevation="1"] {
        @apply --paper-material-elevation-1;
      }
      .paper-material[elevation="2"] {
        @apply --paper-material-elevation-2;
      }
      .paper-material[elevation="3"] {
        @apply --paper-material-elevation-3;
      }
      .paper-material[elevation="4"] {
        @apply --paper-material-elevation-4;
      }
      .paper-material[elevation="5"] {
        @apply --paper-material-elevation-5;
      }

      /* Duplicate the styles because of https://github.com/webcomponents/shadycss/issues/193 */
      :host {
        --paper-material: {
          display: block;
          position: relative;
        };
        --paper-material-elevation-1: {
          @apply --shadow-elevation-2dp;
        };
        --paper-material-elevation-2: {
          @apply --shadow-elevation-4dp;
        };
        --paper-material-elevation-3: {
          @apply --shadow-elevation-6dp;
        };
        --paper-material-elevation-4: {
          @apply --shadow-elevation-8dp;
        };
        --paper-material-elevation-5: {
          @apply --shadow-elevation-16dp;
        };
      }
      :host(.paper-material) {
        @apply --paper-material;
      }
      :host(.paper-material[elevation="1"]) {
        @apply --paper-material-elevation-1;
      }
      :host(.paper-material[elevation="2"]) {
        @apply --paper-material-elevation-2;
      }
      :host(.paper-material[elevation="3"]) {
        @apply --paper-material-elevation-3;
      }
      :host(.paper-material[elevation="4"]) {
        @apply --paper-material-elevation-4;
      }
      :host(.paper-material[elevation="5"]) {
        @apply --paper-material-elevation-5;
      }
    </style>
  </template>
</dom-module>`;template$i.setAttribute("style","display: none;"),document.head.appendChild(template$i.content);
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */
const IronControlState={properties:{focused:{type:Boolean,value:!1,notify:!0,readOnly:!0,reflectToAttribute:!0},disabled:{type:Boolean,value:!1,notify:!0,observer:"_disabledChanged",reflectToAttribute:!0},_oldTabIndex:{type:String},_boundFocusBlurHandler:{type:Function,value:function(){return this._focusBlurHandler.bind(this)}}},observers:["_changedControlState(focused, disabled)"],ready:function(){this.addEventListener("focus",this._boundFocusBlurHandler,!0),this.addEventListener("blur",this._boundFocusBlurHandler,!0)},_focusBlurHandler:function(e){this._setFocused("focus"===e.type)},_disabledChanged:function(e,t){this.setAttribute("aria-disabled",e?"true":"false"),this.style.pointerEvents=e?"none":"",e?(this._oldTabIndex=this.getAttribute("tabindex"),this._setFocused(!1),this.tabIndex=-1,this.blur()):void 0!==this._oldTabIndex&&(null===this._oldTabIndex?this.removeAttribute("tabindex"):this.setAttribute("tabindex",this._oldTabIndex))},_changedControlState:function(){this._controlStateChanged&&this._controlStateChanged()}},IronButtonStateImpl={properties:{pressed:{type:Boolean,readOnly:!0,value:!1,reflectToAttribute:!0,observer:"_pressedChanged"},toggles:{type:Boolean,value:!1,reflectToAttribute:!0},active:{type:Boolean,value:!1,notify:!0,reflectToAttribute:!0},pointerDown:{type:Boolean,readOnly:!0,value:!1},receivedFocusFromKeyboard:{type:Boolean,readOnly:!0},ariaActiveAttribute:{type:String,value:"aria-pressed",observer:"_ariaActiveAttributeChanged"}},listeners:{down:"_downHandler",up:"_upHandler",tap:"_tapHandler"},observers:["_focusChanged(focused)","_activeChanged(active, ariaActiveAttribute)"],keyBindings:{"enter:keydown":"_asyncClick","space:keydown":"_spaceKeyDownHandler","space:keyup":"_spaceKeyUpHandler"},_mouseEventRe:/^mouse/,_tapHandler:function(){this.toggles?this._userActivate(!this.active):this.active=!1},_focusChanged:function(e){this._detectKeyboardFocus(e),e||this._setPressed(!1)},_detectKeyboardFocus:function(e){this._setReceivedFocusFromKeyboard(!this.pointerDown&&e)},_userActivate:function(e){this.active!==e&&(this.active=e,this.fire("change"))},_downHandler:function(e){this._setPointerDown(!0),this._setPressed(!0),this._setReceivedFocusFromKeyboard(!1)},_upHandler:function(){this._setPointerDown(!1),this._setPressed(!1)},_spaceKeyDownHandler:function(e){var t=e.detail.keyboardEvent,n=dom$1(t).localTarget;this.isLightDescendant(n)||(t.preventDefault(),t.stopImmediatePropagation(),this._setPressed(!0))},_spaceKeyUpHandler:function(e){var t=dom$1(e.detail.keyboardEvent).localTarget;this.isLightDescendant(t)||(this.pressed&&this._asyncClick(),this._setPressed(!1))},_asyncClick:function(){this.async((function(){this.click()}),1)},_pressedChanged:function(e){this._changedButtonState()},_ariaActiveAttributeChanged:function(e,t){t&&t!=e&&this.hasAttribute(t)&&this.removeAttribute(t)},_activeChanged:function(e,t){this.toggles?this.setAttribute(this.ariaActiveAttribute,e?"true":"false"):this.removeAttribute(this.ariaActiveAttribute),this._changedButtonState()},_controlStateChanged:function(){this.disabled?this._setPressed(!1):this._changedButtonState()},_changedButtonState:function(){this._buttonStateChanged&&this._buttonStateChanged()}},IronButtonState=[IronA11yKeysBehavior,IronButtonStateImpl];
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */
/**
    @license
    Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */
var Utility={distance:function(e,t,n,r){var i=e-n,a=t-r;return Math.sqrt(i*i+a*a)},now:window.performance&&window.performance.now?window.performance.now.bind(window.performance):Date.now};function ElementMetrics(e){this.element=e,this.width=this.boundingRect.width,this.height=this.boundingRect.height,this.size=Math.max(this.width,this.height)}function Ripple(e){this.element=e,this.color=window.getComputedStyle(e).color,this.wave=document.createElement("div"),this.waveContainer=document.createElement("div"),this.wave.style.backgroundColor=this.color,this.wave.classList.add("wave"),this.waveContainer.classList.add("wave-container"),dom$1(this.waveContainer).appendChild(this.wave),this.resetInteractionState()}ElementMetrics.prototype={get boundingRect(){return this.element.getBoundingClientRect()},furthestCornerDistanceFrom:function(e,t){var n=Utility.distance(e,t,0,0),r=Utility.distance(e,t,this.width,0),i=Utility.distance(e,t,0,this.height),a=Utility.distance(e,t,this.width,this.height);return Math.max(n,r,i,a)}},Ripple.MAX_RADIUS=300,Ripple.prototype={get recenters(){return this.element.recenters},get center(){return this.element.center},get mouseDownElapsed(){var e;return this.mouseDownStart?(e=Utility.now()-this.mouseDownStart,this.mouseUpStart&&(e-=this.mouseUpElapsed),e):0},get mouseUpElapsed(){return this.mouseUpStart?Utility.now()-this.mouseUpStart:0},get mouseDownElapsedSeconds(){return this.mouseDownElapsed/1e3},get mouseUpElapsedSeconds(){return this.mouseUpElapsed/1e3},get mouseInteractionSeconds(){return this.mouseDownElapsedSeconds+this.mouseUpElapsedSeconds},get initialOpacity(){return this.element.initialOpacity},get opacityDecayVelocity(){return this.element.opacityDecayVelocity},get radius(){var e=1.1*Math.min(Math.sqrt(this.containerMetrics.width*this.containerMetrics.width+this.containerMetrics.height*this.containerMetrics.height),Ripple.MAX_RADIUS)+5,t=e*(1-Math.pow(80,-(this.mouseInteractionSeconds/(1.1-e/Ripple.MAX_RADIUS*.2))));return Math.abs(t)},get opacity(){return this.mouseUpStart?Math.max(0,this.initialOpacity-this.mouseUpElapsedSeconds*this.opacityDecayVelocity):this.initialOpacity},get outerOpacity(){return Math.max(0,Math.min(.3*this.mouseUpElapsedSeconds,this.opacity))},get isOpacityFullyDecayed(){return this.opacity<.01&&this.radius>=Math.min(this.maxRadius,Ripple.MAX_RADIUS)},get isRestingAtMaxRadius(){return this.opacity>=this.initialOpacity&&this.radius>=Math.min(this.maxRadius,Ripple.MAX_RADIUS)},get isAnimationComplete(){return this.mouseUpStart?this.isOpacityFullyDecayed:this.isRestingAtMaxRadius},get translationFraction(){return Math.min(1,this.radius/this.containerMetrics.size*2/Math.sqrt(2))},get xNow(){return this.xEnd?this.xStart+this.translationFraction*(this.xEnd-this.xStart):this.xStart},get yNow(){return this.yEnd?this.yStart+this.translationFraction*(this.yEnd-this.yStart):this.yStart},get isMouseDown(){return this.mouseDownStart&&!this.mouseUpStart},resetInteractionState:function(){this.maxRadius=0,this.mouseDownStart=0,this.mouseUpStart=0,this.xStart=0,this.yStart=0,this.xEnd=0,this.yEnd=0,this.slideDistance=0,this.containerMetrics=new ElementMetrics(this.element)},draw:function(){var e,t,n;this.wave.style.opacity=this.opacity,e=this.radius/(this.containerMetrics.size/2),this.waveContainer.style.webkitTransform="translate("+(t=this.xNow-this.containerMetrics.width/2)+"px, "+(n=this.yNow-this.containerMetrics.height/2)+"px)",this.waveContainer.style.transform="translate3d("+t+"px, "+n+"px, 0)",this.wave.style.webkitTransform="scale("+e+","+e+")",this.wave.style.transform="scale3d("+e+","+e+",1)"},downAction:function(e){var t=this.containerMetrics.width/2,n=this.containerMetrics.height/2;this.resetInteractionState(),this.mouseDownStart=Utility.now(),this.center?(this.xStart=t,this.yStart=n,this.slideDistance=Utility.distance(this.xStart,this.yStart,this.xEnd,this.yEnd)):(this.xStart=e?e.detail.x-this.containerMetrics.boundingRect.left:this.containerMetrics.width/2,this.yStart=e?e.detail.y-this.containerMetrics.boundingRect.top:this.containerMetrics.height/2),this.recenters&&(this.xEnd=t,this.yEnd=n,this.slideDistance=Utility.distance(this.xStart,this.yStart,this.xEnd,this.yEnd)),this.maxRadius=this.containerMetrics.furthestCornerDistanceFrom(this.xStart,this.yStart),this.waveContainer.style.top=(this.containerMetrics.height-this.containerMetrics.size)/2+"px",this.waveContainer.style.left=(this.containerMetrics.width-this.containerMetrics.size)/2+"px",this.waveContainer.style.width=this.containerMetrics.size+"px",this.waveContainer.style.height=this.containerMetrics.size+"px"},upAction:function(e){this.isMouseDown&&(this.mouseUpStart=Utility.now())},remove:function(){dom$1(dom$1(this.waveContainer).parentNode).removeChild(this.waveContainer)}},Polymer({_template:html`
    <style>
      :host {
        display: block;
        position: absolute;
        border-radius: inherit;
        overflow: hidden;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;

        /* See PolymerElements/paper-behaviors/issues/34. On non-Chrome browsers,
         * creating a node (with a position:absolute) in the middle of an event
         * handler "interrupts" that event handler (which happens when the
         * ripple is created on demand) */
        pointer-events: none;
      }

      :host([animating]) {
        /* This resolves a rendering issue in Chrome (as of 40) where the
           ripple is not properly clipped by its parent (which may have
           rounded corners). See: http://jsbin.com/temexa/4

           Note: We only apply this style conditionally. Otherwise, the browser
           will create a new compositing layer for every ripple element on the
           page, and that would be bad. */
        -webkit-transform: translate(0, 0);
        transform: translate3d(0, 0, 0);
      }

      #background,
      #waves,
      .wave-container,
      .wave {
        pointer-events: none;
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
      }

      #background,
      .wave {
        opacity: 0;
      }

      #waves,
      .wave {
        overflow: hidden;
      }

      .wave-container,
      .wave {
        border-radius: 50%;
      }

      :host(.circle) #background,
      :host(.circle) #waves {
        border-radius: 50%;
      }

      :host(.circle) .wave-container {
        overflow: hidden;
      }
    </style>

    <div id="background"></div>
    <div id="waves"></div>
`,is:"paper-ripple",behaviors:[IronA11yKeysBehavior],properties:{initialOpacity:{type:Number,value:.25},opacityDecayVelocity:{type:Number,value:.8},recenters:{type:Boolean,value:!1},center:{type:Boolean,value:!1},ripples:{type:Array,value:function(){return[]}},animating:{type:Boolean,readOnly:!0,reflectToAttribute:!0,value:!1},holdDown:{type:Boolean,value:!1,observer:"_holdDownChanged"},noink:{type:Boolean,value:!1},_animating:{type:Boolean},_boundAnimate:{type:Function,value:function(){return this.animate.bind(this)}}},get target(){return this.keyEventTarget},keyBindings:{"enter:keydown":"_onEnterKeydown","space:keydown":"_onSpaceKeydown","space:keyup":"_onSpaceKeyup"},attached:function(){this.keyEventTarget=11==dom$1(this).parentNode.nodeType?dom$1(this).getOwnerRoot().host:dom$1(this).parentNode;var e=this.keyEventTarget;this.listen(e,"up","uiUpAction"),this.listen(e,"down","uiDownAction")},detached:function(){this.unlisten(this.keyEventTarget,"up","uiUpAction"),this.unlisten(this.keyEventTarget,"down","uiDownAction"),this.keyEventTarget=null},get shouldKeepAnimating(){for(var e=0;e<this.ripples.length;++e)if(!this.ripples[e].isAnimationComplete)return!0;return!1},simulatedRipple:function(){this.downAction(null),this.async((function(){this.upAction()}),1)},uiDownAction:function(e){this.noink||this.downAction(e)},downAction:function(e){this.holdDown&&this.ripples.length>0||(this.addRipple().downAction(e),this._animating||(this._animating=!0,this.animate()))},uiUpAction:function(e){this.noink||this.upAction(e)},upAction:function(e){this.holdDown||(this.ripples.forEach((function(t){t.upAction(e)})),this._animating=!0,this.animate())},onAnimationComplete:function(){this._animating=!1,this.$.background.style.backgroundColor="",this.fire("transitionend")},addRipple:function(){var e=new Ripple(this);return dom$1(this.$.waves).appendChild(e.waveContainer),this.$.background.style.backgroundColor=e.color,this.ripples.push(e),this._setAnimating(!0),e},removeRipple:function(e){var t=this.ripples.indexOf(e);t<0||(this.ripples.splice(t,1),e.remove(),this.ripples.length||this._setAnimating(!1))},animate:function(){if(this._animating){var e,t;for(e=0;e<this.ripples.length;++e)(t=this.ripples[e]).draw(),this.$.background.style.opacity=t.outerOpacity,t.isOpacityFullyDecayed&&!t.isRestingAtMaxRadius&&this.removeRipple(t);this.shouldKeepAnimating||0!==this.ripples.length?window.requestAnimationFrame(this._boundAnimate):this.onAnimationComplete()}},animateRipple:function(){return this.animate()},_onEnterKeydown:function(){this.uiDownAction(),this.async(this.uiUpAction,1)},_onSpaceKeydown:function(){this.uiDownAction()},_onSpaceKeyup:function(){this.uiUpAction()},_holdDownChanged:function(e,t){void 0!==t&&(e?this.downAction():this.upAction())}});
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */
const PaperRippleBehavior={properties:{noink:{type:Boolean,observer:"_noinkChanged"},_rippleContainer:{type:Object}},_buttonStateChanged:function(){this.focused&&this.ensureRipple()},_downHandler:function(e){IronButtonStateImpl._downHandler.call(this,e),this.pressed&&this.ensureRipple(e)},ensureRipple:function(e){if(!this.hasRipple()){this._ripple=this._createRipple(),this._ripple.noink=this.noink;var t=this._rippleContainer||this.root;if(t&&dom$1(t).appendChild(this._ripple),e){var n=dom$1(this._rippleContainer||this),r=dom$1(e).rootTarget;n.deepContains(r)&&this._ripple.uiDownAction(e)}}},getRipple:function(){return this.ensureRipple(),this._ripple},hasRipple:function(){return Boolean(this._ripple)},_createRipple:function(){return document.createElement("paper-ripple")},_noinkChanged:function(e){this.hasRipple()&&(this._ripple.noink=e)}},PaperButtonBehaviorImpl={properties:{elevation:{type:Number,reflectToAttribute:!0,readOnly:!0}},observers:["_calculateElevation(focused, disabled, active, pressed, receivedFocusFromKeyboard)","_computeKeyboardClass(receivedFocusFromKeyboard)"],hostAttributes:{role:"button",tabindex:"0",animated:!0},_calculateElevation:function(){var e=1;this.disabled?e=0:this.active||this.pressed?e=4:this.receivedFocusFromKeyboard&&(e=3),this._setElevation(e)},_computeKeyboardClass:function(e){this.toggleClass("keyboard-focus",e)},_spaceKeyDownHandler:function(e){IronButtonStateImpl._spaceKeyDownHandler.call(this,e),this.hasRipple()&&this.getRipple().ripples.length<1&&this._ripple.uiDownAction()},_spaceKeyUpHandler:function(e){IronButtonStateImpl._spaceKeyUpHandler.call(this,e),this.hasRipple()&&this._ripple.uiUpAction()}},PaperButtonBehavior=[IronButtonState,IronControlState,PaperRippleBehavior,PaperButtonBehaviorImpl],template$h=html`
  <style include="paper-material-styles">
    /* Need to specify the same specificity as the styles imported from paper-material. */
    :host {
      @apply --layout-inline;
      @apply --layout-center-center;
      position: relative;
      box-sizing: border-box;
      min-width: 5.14em;
      margin: 0 0.29em;
      background: transparent;
      -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
      -webkit-tap-highlight-color: transparent;
      font: inherit;
      text-transform: uppercase;
      outline-width: 0;
      border-radius: 3px;
      -moz-user-select: none;
      -ms-user-select: none;
      -webkit-user-select: none;
      user-select: none;
      cursor: pointer;
      z-index: 0;
      padding: 0.7em 0.57em;

      @apply --paper-font-common-base;
      @apply --paper-button;
    }

    :host([elevation="1"]) {
      @apply --paper-material-elevation-1;
    }

    :host([elevation="2"]) {
      @apply --paper-material-elevation-2;
    }

    :host([elevation="3"]) {
      @apply --paper-material-elevation-3;
    }

    :host([elevation="4"]) {
      @apply --paper-material-elevation-4;
    }

    :host([elevation="5"]) {
      @apply --paper-material-elevation-5;
    }

    :host([hidden]) {
      display: none !important;
    }

    :host([raised].keyboard-focus) {
      font-weight: bold;
      @apply --paper-button-raised-keyboard-focus;
    }

    :host(:not([raised]).keyboard-focus) {
      font-weight: bold;
      @apply --paper-button-flat-keyboard-focus;
    }

    :host([disabled]) {
      background: none;
      color: #a8a8a8;
      cursor: auto;
      pointer-events: none;

      @apply --paper-button-disabled;
    }

    :host([disabled][raised]) {
      background: #eaeaea;
    }


    :host([animated]) {
      @apply --shadow-transition;
    }

    paper-ripple {
      color: var(--paper-button-ink-color);
    }
  </style>

  <slot></slot>`;
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */template$h.setAttribute("strip-whitespace",""),Polymer({_template:template$h,is:"paper-button",behaviors:[PaperButtonBehavior],properties:{raised:{type:Boolean,reflectToAttribute:!0,value:!1,observer:"_calculateElevation"}},_calculateElevation:function(){this.raised?PaperButtonBehaviorImpl._calculateElevation.apply(this):this._setElevation(0)}});
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */
const template$g=html`
<custom-style>
  <style is="custom-style">
    html {

      /* Material Design color palette for Google products */

      --google-red-100: #f4c7c3;
      --google-red-300: #e67c73;
      --google-red-500: #db4437;
      --google-red-700: #c53929;

      --google-blue-100: #c6dafc;
      --google-blue-300: #7baaf7;
      --google-blue-500: #4285f4;
      --google-blue-700: #3367d6;

      --google-green-100: #b7e1cd;
      --google-green-300: #57bb8a;
      --google-green-500: #0f9d58;
      --google-green-700: #0b8043;

      --google-yellow-100: #fce8b2;
      --google-yellow-300: #f7cb4d;
      --google-yellow-500: #f4b400;
      --google-yellow-700: #f09300;

      --google-grey-100: #f5f5f5;
      --google-grey-300: #e0e0e0;
      --google-grey-500: #9e9e9e;
      --google-grey-700: #616161;

      /* Material Design color palette from online spec document */

      --paper-red-50: #ffebee;
      --paper-red-100: #ffcdd2;
      --paper-red-200: #ef9a9a;
      --paper-red-300: #e57373;
      --paper-red-400: #ef5350;
      --paper-red-500: #f44336;
      --paper-red-600: #e53935;
      --paper-red-700: #d32f2f;
      --paper-red-800: #c62828;
      --paper-red-900: #b71c1c;
      --paper-red-a100: #ff8a80;
      --paper-red-a200: #ff5252;
      --paper-red-a400: #ff1744;
      --paper-red-a700: #d50000;

      --paper-pink-50: #fce4ec;
      --paper-pink-100: #f8bbd0;
      --paper-pink-200: #f48fb1;
      --paper-pink-300: #f06292;
      --paper-pink-400: #ec407a;
      --paper-pink-500: #e91e63;
      --paper-pink-600: #d81b60;
      --paper-pink-700: #c2185b;
      --paper-pink-800: #ad1457;
      --paper-pink-900: #880e4f;
      --paper-pink-a100: #ff80ab;
      --paper-pink-a200: #ff4081;
      --paper-pink-a400: #f50057;
      --paper-pink-a700: #c51162;

      --paper-purple-50: #f3e5f5;
      --paper-purple-100: #e1bee7;
      --paper-purple-200: #ce93d8;
      --paper-purple-300: #ba68c8;
      --paper-purple-400: #ab47bc;
      --paper-purple-500: #9c27b0;
      --paper-purple-600: #8e24aa;
      --paper-purple-700: #7b1fa2;
      --paper-purple-800: #6a1b9a;
      --paper-purple-900: #4a148c;
      --paper-purple-a100: #ea80fc;
      --paper-purple-a200: #e040fb;
      --paper-purple-a400: #d500f9;
      --paper-purple-a700: #aa00ff;

      --paper-deep-purple-50: #ede7f6;
      --paper-deep-purple-100: #d1c4e9;
      --paper-deep-purple-200: #b39ddb;
      --paper-deep-purple-300: #9575cd;
      --paper-deep-purple-400: #7e57c2;
      --paper-deep-purple-500: #673ab7;
      --paper-deep-purple-600: #5e35b1;
      --paper-deep-purple-700: #512da8;
      --paper-deep-purple-800: #4527a0;
      --paper-deep-purple-900: #311b92;
      --paper-deep-purple-a100: #b388ff;
      --paper-deep-purple-a200: #7c4dff;
      --paper-deep-purple-a400: #651fff;
      --paper-deep-purple-a700: #6200ea;

      --paper-indigo-50: #e8eaf6;
      --paper-indigo-100: #c5cae9;
      --paper-indigo-200: #9fa8da;
      --paper-indigo-300: #7986cb;
      --paper-indigo-400: #5c6bc0;
      --paper-indigo-500: #3f51b5;
      --paper-indigo-600: #3949ab;
      --paper-indigo-700: #303f9f;
      --paper-indigo-800: #283593;
      --paper-indigo-900: #1a237e;
      --paper-indigo-a100: #8c9eff;
      --paper-indigo-a200: #536dfe;
      --paper-indigo-a400: #3d5afe;
      --paper-indigo-a700: #304ffe;

      --paper-blue-50: #e3f2fd;
      --paper-blue-100: #bbdefb;
      --paper-blue-200: #90caf9;
      --paper-blue-300: #64b5f6;
      --paper-blue-400: #42a5f5;
      --paper-blue-500: #2196f3;
      --paper-blue-600: #1e88e5;
      --paper-blue-700: #1976d2;
      --paper-blue-800: #1565c0;
      --paper-blue-900: #0d47a1;
      --paper-blue-a100: #82b1ff;
      --paper-blue-a200: #448aff;
      --paper-blue-a400: #2979ff;
      --paper-blue-a700: #2962ff;

      --paper-light-blue-50: #e1f5fe;
      --paper-light-blue-100: #b3e5fc;
      --paper-light-blue-200: #81d4fa;
      --paper-light-blue-300: #4fc3f7;
      --paper-light-blue-400: #29b6f6;
      --paper-light-blue-500: #03a9f4;
      --paper-light-blue-600: #039be5;
      --paper-light-blue-700: #0288d1;
      --paper-light-blue-800: #0277bd;
      --paper-light-blue-900: #01579b;
      --paper-light-blue-a100: #80d8ff;
      --paper-light-blue-a200: #40c4ff;
      --paper-light-blue-a400: #00b0ff;
      --paper-light-blue-a700: #0091ea;

      --paper-cyan-50: #e0f7fa;
      --paper-cyan-100: #b2ebf2;
      --paper-cyan-200: #80deea;
      --paper-cyan-300: #4dd0e1;
      --paper-cyan-400: #26c6da;
      --paper-cyan-500: #00bcd4;
      --paper-cyan-600: #00acc1;
      --paper-cyan-700: #0097a7;
      --paper-cyan-800: #00838f;
      --paper-cyan-900: #006064;
      --paper-cyan-a100: #84ffff;
      --paper-cyan-a200: #18ffff;
      --paper-cyan-a400: #00e5ff;
      --paper-cyan-a700: #00b8d4;

      --paper-teal-50: #e0f2f1;
      --paper-teal-100: #b2dfdb;
      --paper-teal-200: #80cbc4;
      --paper-teal-300: #4db6ac;
      --paper-teal-400: #26a69a;
      --paper-teal-500: #009688;
      --paper-teal-600: #00897b;
      --paper-teal-700: #00796b;
      --paper-teal-800: #00695c;
      --paper-teal-900: #004d40;
      --paper-teal-a100: #a7ffeb;
      --paper-teal-a200: #64ffda;
      --paper-teal-a400: #1de9b6;
      --paper-teal-a700: #00bfa5;

      --paper-green-50: #e8f5e9;
      --paper-green-100: #c8e6c9;
      --paper-green-200: #a5d6a7;
      --paper-green-300: #81c784;
      --paper-green-400: #66bb6a;
      --paper-green-500: #4caf50;
      --paper-green-600: #43a047;
      --paper-green-700: #388e3c;
      --paper-green-800: #2e7d32;
      --paper-green-900: #1b5e20;
      --paper-green-a100: #b9f6ca;
      --paper-green-a200: #69f0ae;
      --paper-green-a400: #00e676;
      --paper-green-a700: #00c853;

      --paper-light-green-50: #f1f8e9;
      --paper-light-green-100: #dcedc8;
      --paper-light-green-200: #c5e1a5;
      --paper-light-green-300: #aed581;
      --paper-light-green-400: #9ccc65;
      --paper-light-green-500: #8bc34a;
      --paper-light-green-600: #7cb342;
      --paper-light-green-700: #689f38;
      --paper-light-green-800: #558b2f;
      --paper-light-green-900: #33691e;
      --paper-light-green-a100: #ccff90;
      --paper-light-green-a200: #b2ff59;
      --paper-light-green-a400: #76ff03;
      --paper-light-green-a700: #64dd17;

      --paper-lime-50: #f9fbe7;
      --paper-lime-100: #f0f4c3;
      --paper-lime-200: #e6ee9c;
      --paper-lime-300: #dce775;
      --paper-lime-400: #d4e157;
      --paper-lime-500: #cddc39;
      --paper-lime-600: #c0ca33;
      --paper-lime-700: #afb42b;
      --paper-lime-800: #9e9d24;
      --paper-lime-900: #827717;
      --paper-lime-a100: #f4ff81;
      --paper-lime-a200: #eeff41;
      --paper-lime-a400: #c6ff00;
      --paper-lime-a700: #aeea00;

      --paper-yellow-50: #fffde7;
      --paper-yellow-100: #fff9c4;
      --paper-yellow-200: #fff59d;
      --paper-yellow-300: #fff176;
      --paper-yellow-400: #ffee58;
      --paper-yellow-500: #ffeb3b;
      --paper-yellow-600: #fdd835;
      --paper-yellow-700: #fbc02d;
      --paper-yellow-800: #f9a825;
      --paper-yellow-900: #f57f17;
      --paper-yellow-a100: #ffff8d;
      --paper-yellow-a200: #ffff00;
      --paper-yellow-a400: #ffea00;
      --paper-yellow-a700: #ffd600;

      --paper-amber-50: #fff8e1;
      --paper-amber-100: #ffecb3;
      --paper-amber-200: #ffe082;
      --paper-amber-300: #ffd54f;
      --paper-amber-400: #ffca28;
      --paper-amber-500: #ffc107;
      --paper-amber-600: #ffb300;
      --paper-amber-700: #ffa000;
      --paper-amber-800: #ff8f00;
      --paper-amber-900: #ff6f00;
      --paper-amber-a100: #ffe57f;
      --paper-amber-a200: #ffd740;
      --paper-amber-a400: #ffc400;
      --paper-amber-a700: #ffab00;

      --paper-orange-50: #fff3e0;
      --paper-orange-100: #ffe0b2;
      --paper-orange-200: #ffcc80;
      --paper-orange-300: #ffb74d;
      --paper-orange-400: #ffa726;
      --paper-orange-500: #ff9800;
      --paper-orange-600: #fb8c00;
      --paper-orange-700: #f57c00;
      --paper-orange-800: #ef6c00;
      --paper-orange-900: #e65100;
      --paper-orange-a100: #ffd180;
      --paper-orange-a200: #ffab40;
      --paper-orange-a400: #ff9100;
      --paper-orange-a700: #ff6500;

      --paper-deep-orange-50: #fbe9e7;
      --paper-deep-orange-100: #ffccbc;
      --paper-deep-orange-200: #ffab91;
      --paper-deep-orange-300: #ff8a65;
      --paper-deep-orange-400: #ff7043;
      --paper-deep-orange-500: #ff5722;
      --paper-deep-orange-600: #f4511e;
      --paper-deep-orange-700: #e64a19;
      --paper-deep-orange-800: #d84315;
      --paper-deep-orange-900: #bf360c;
      --paper-deep-orange-a100: #ff9e80;
      --paper-deep-orange-a200: #ff6e40;
      --paper-deep-orange-a400: #ff3d00;
      --paper-deep-orange-a700: #dd2c00;

      --paper-brown-50: #efebe9;
      --paper-brown-100: #d7ccc8;
      --paper-brown-200: #bcaaa4;
      --paper-brown-300: #a1887f;
      --paper-brown-400: #8d6e63;
      --paper-brown-500: #795548;
      --paper-brown-600: #6d4c41;
      --paper-brown-700: #5d4037;
      --paper-brown-800: #4e342e;
      --paper-brown-900: #3e2723;

      --paper-grey-50: #fafafa;
      --paper-grey-100: #f5f5f5;
      --paper-grey-200: #eeeeee;
      --paper-grey-300: #e0e0e0;
      --paper-grey-400: #bdbdbd;
      --paper-grey-500: #9e9e9e;
      --paper-grey-600: #757575;
      --paper-grey-700: #616161;
      --paper-grey-800: #424242;
      --paper-grey-900: #212121;

      --paper-blue-grey-50: #eceff1;
      --paper-blue-grey-100: #cfd8dc;
      --paper-blue-grey-200: #b0bec5;
      --paper-blue-grey-300: #90a4ae;
      --paper-blue-grey-400: #78909c;
      --paper-blue-grey-500: #607d8b;
      --paper-blue-grey-600: #546e7a;
      --paper-blue-grey-700: #455a64;
      --paper-blue-grey-800: #37474f;
      --paper-blue-grey-900: #263238;

      /* opacity for dark text on a light background */
      --dark-divider-opacity: 0.12;
      --dark-disabled-opacity: 0.38; /* or hint text or icon */
      --dark-secondary-opacity: 0.54;
      --dark-primary-opacity: 0.87;

      /* opacity for light text on a dark background */
      --light-divider-opacity: 0.12;
      --light-disabled-opacity: 0.3; /* or hint text or icon */
      --light-secondary-opacity: 0.7;
      --light-primary-opacity: 1.0;

    }

  </style>
</custom-style>
`;template$g.setAttribute("style","display: none;"),document.head.appendChild(template$g.content);
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */
const template$f=html`
<custom-style>
  <style is="custom-style">
    html {
      /*
       * You can use these generic variables in your elements for easy theming.
       * For example, if all your elements use \`--primary-text-color\` as its main
       * color, then switching from a light to a dark theme is just a matter of
       * changing the value of \`--primary-text-color\` in your application.
       */
      --primary-text-color: var(--light-theme-text-color);
      --primary-background-color: var(--light-theme-background-color);
      --secondary-text-color: var(--light-theme-secondary-color);
      --disabled-text-color: var(--light-theme-disabled-color);
      --divider-color: var(--light-theme-divider-color);
      --error-color: var(--paper-deep-orange-a700);

      /*
       * Primary and accent colors. Also see color.js for more colors.
       */
      --primary-color: var(--paper-indigo-500);
      --light-primary-color: var(--paper-indigo-100);
      --dark-primary-color: var(--paper-indigo-700);

      --accent-color: var(--paper-pink-a200);
      --light-accent-color: var(--paper-pink-a100);
      --dark-accent-color: var(--paper-pink-a400);


      /*
       * Material Design Light background theme
       */
      --light-theme-background-color: #ffffff;
      --light-theme-base-color: #000000;
      --light-theme-text-color: var(--paper-grey-900);
      --light-theme-secondary-color: #737373;  /* for secondary text and icons */
      --light-theme-disabled-color: #9b9b9b;  /* disabled/hint text */
      --light-theme-divider-color: #dbdbdb;

      /*
       * Material Design Dark background theme
       */
      --dark-theme-background-color: var(--paper-grey-900);
      --dark-theme-base-color: #ffffff;
      --dark-theme-text-color: #ffffff;
      --dark-theme-secondary-color: #bcbcbc;  /* for secondary text and icons */
      --dark-theme-disabled-color: #646464;  /* disabled/hint text */
      --dark-theme-divider-color: #3c3c3c;

      /*
       * Deprecated values because of their confusing names.
       */
      --text-primary-color: var(--dark-theme-text-color);
      --default-primary-color: var(--primary-color);
    }
  </style>
</custom-style>`;template$f.setAttribute("style","display: none;"),document.head.appendChild(template$f.content);
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */
const IronFormElementBehavior={properties:{name:{type:String},value:{notify:!0,type:String},required:{type:Boolean,value:!1}},attached:function(){},detached:function(){}};
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */let IronValidatableBehaviorMeta=null;const IronValidatableBehavior={properties:{validator:{type:String},invalid:{notify:!0,reflectToAttribute:!0,type:Boolean,value:!1,observer:"_invalidChanged"}},registered:function(){IronValidatableBehaviorMeta=new IronMeta({type:"validator"})},_invalidChanged:function(){this.invalid?this.setAttribute("aria-invalid","true"):this.removeAttribute("aria-invalid")},get _validator(){return IronValidatableBehaviorMeta&&IronValidatableBehaviorMeta.byKey(this.validator)},hasValidator:function(){return null!=this._validator},validate:function(e){return this.invalid=void 0===e&&void 0!==this.value?!this._getValidity(this.value):!this._getValidity(e),!this.invalid},_getValidity:function(e){return!this.hasValidator()||this._validator.validate(e)}},IronCheckedElementBehaviorImpl={properties:{checked:{type:Boolean,value:!1,reflectToAttribute:!0,notify:!0,observer:"_checkedChanged"},toggles:{type:Boolean,value:!0,reflectToAttribute:!0},value:{type:String,value:"on",observer:"_valueChanged"}},observers:["_requiredChanged(required)"],created:function(){this._hasIronCheckedElementBehavior=!0},_getValidity:function(e){return this.disabled||!this.required||this.checked},_requiredChanged:function(){this.required?this.setAttribute("aria-required","true"):this.removeAttribute("aria-required")},_checkedChanged:function(){this.active=this.checked,this.fire("iron-change")},_valueChanged:function(){null==this.value&&(this.value="on")}},IronCheckedElementBehavior=[IronFormElementBehavior,IronValidatableBehavior,IronCheckedElementBehaviorImpl],PaperInkyFocusBehaviorImpl={observers:["_focusedChanged(receivedFocusFromKeyboard)"],_focusedChanged:function(e){e&&this.ensureRipple(),this.hasRipple()&&(this._ripple.holdDown=e)},_createRipple:function(){var e=PaperRippleBehavior._createRipple();return e.id="ink",e.setAttribute("center",""),e.classList.add("circle"),e}},PaperInkyFocusBehavior=[IronButtonState,IronControlState,PaperRippleBehavior,PaperInkyFocusBehaviorImpl],PaperCheckedElementBehaviorImpl={_checkedChanged:function(){IronCheckedElementBehaviorImpl._checkedChanged.call(this),this.hasRipple()&&(this.checked?this._ripple.setAttribute("checked",""):this._ripple.removeAttribute("checked"))},_buttonStateChanged:function(){PaperRippleBehavior._buttonStateChanged.call(this),this.disabled||this.isAttached&&(this.checked=this.active)}},PaperCheckedElementBehavior=[PaperInkyFocusBehavior,IronCheckedElementBehavior,PaperCheckedElementBehaviorImpl],template$e=html`<style>
  :host {
    display: inline-block;
    white-space: nowrap;
    cursor: pointer;
    --calculated-paper-checkbox-size: var(--paper-checkbox-size, 18px);
    /* -1px is a sentinel for the default and is replaced in \`attached\`. */
    --calculated-paper-checkbox-ink-size: var(--paper-checkbox-ink-size, -1px);
    @apply --paper-font-common-base;
    line-height: 0;
    -webkit-tap-highlight-color: transparent;
  }

  :host([hidden]) {
    display: none !important;
  }

  :host(:focus) {
    outline: none;
  }

  .hidden {
    display: none;
  }

  #checkboxContainer {
    display: inline-block;
    position: relative;
    width: var(--calculated-paper-checkbox-size);
    height: var(--calculated-paper-checkbox-size);
    min-width: var(--calculated-paper-checkbox-size);
    margin: var(--paper-checkbox-margin, initial);
    vertical-align: var(--paper-checkbox-vertical-align, middle);
    background-color: var(--paper-checkbox-unchecked-background-color, transparent);
  }

  #ink {
    position: absolute;

    /* Center the ripple in the checkbox by negative offsetting it by
     * (inkWidth - rippleWidth) / 2 */
    top: calc(0px - (var(--calculated-paper-checkbox-ink-size) - var(--calculated-paper-checkbox-size)) / 2);
    left: calc(0px - (var(--calculated-paper-checkbox-ink-size) - var(--calculated-paper-checkbox-size)) / 2);
    width: var(--calculated-paper-checkbox-ink-size);
    height: var(--calculated-paper-checkbox-ink-size);
    color: var(--paper-checkbox-unchecked-ink-color, var(--primary-text-color));
    opacity: 0.6;
    pointer-events: none;
  }

  #ink:dir(rtl) {
    right: calc(0px - (var(--calculated-paper-checkbox-ink-size) - var(--calculated-paper-checkbox-size)) / 2);
    left: auto;
  }

  #ink[checked] {
    color: var(--paper-checkbox-checked-ink-color, var(--primary-color));
  }

  #checkbox {
    position: relative;
    box-sizing: border-box;
    height: 100%;
    border: solid 2px;
    border-color: var(--paper-checkbox-unchecked-color, var(--primary-text-color));
    border-radius: 2px;
    pointer-events: none;
    -webkit-transition: background-color 140ms, border-color 140ms;
    transition: background-color 140ms, border-color 140ms;

    -webkit-transition-duration: var(--paper-checkbox-animation-duration, 140ms);
    transition-duration: var(--paper-checkbox-animation-duration, 140ms);
  }

  /* checkbox checked animations */
  #checkbox.checked #checkmark {
    -webkit-animation: checkmark-expand 140ms ease-out forwards;
    animation: checkmark-expand 140ms ease-out forwards;

    -webkit-animation-duration: var(--paper-checkbox-animation-duration, 140ms);
    animation-duration: var(--paper-checkbox-animation-duration, 140ms);
  }

  @-webkit-keyframes checkmark-expand {
    0% {
      -webkit-transform: scale(0, 0) rotate(45deg);
    }
    100% {
      -webkit-transform: scale(1, 1) rotate(45deg);
    }
  }

  @keyframes checkmark-expand {
    0% {
      transform: scale(0, 0) rotate(45deg);
    }
    100% {
      transform: scale(1, 1) rotate(45deg);
    }
  }

  #checkbox.checked {
    background-color: var(--paper-checkbox-checked-color, var(--primary-color));
    border-color: var(--paper-checkbox-checked-color, var(--primary-color));
  }

  #checkmark {
    position: absolute;
    width: 36%;
    height: 70%;
    border-style: solid;
    border-top: none;
    border-left: none;
    border-right-width: calc(2/15 * var(--calculated-paper-checkbox-size));
    border-bottom-width: calc(2/15 * var(--calculated-paper-checkbox-size));
    border-color: var(--paper-checkbox-checkmark-color, white);
    -webkit-transform-origin: 97% 86%;
    transform-origin: 97% 86%;
    box-sizing: content-box; /* protect against page-level box-sizing */
  }

  #checkmark:dir(rtl) {
    -webkit-transform-origin: 50% 14%;
    transform-origin: 50% 14%;
  }

  /* label */
  #checkboxLabel {
    position: relative;
    display: inline-block;
    vertical-align: middle;
    padding-left: var(--paper-checkbox-label-spacing, 8px);
    white-space: normal;
    line-height: normal;
    color: var(--paper-checkbox-label-color, var(--primary-text-color));
    @apply --paper-checkbox-label;
  }

  :host([checked]) #checkboxLabel {
    color: var(--paper-checkbox-label-checked-color, var(--paper-checkbox-label-color, var(--primary-text-color)));
    @apply --paper-checkbox-label-checked;
  }

  #checkboxLabel:dir(rtl) {
    padding-right: var(--paper-checkbox-label-spacing, 8px);
    padding-left: 0;
  }

  #checkboxLabel[hidden] {
    display: none;
  }

  /* disabled state */

  :host([disabled]) #checkbox {
    opacity: 0.5;
    border-color: var(--paper-checkbox-unchecked-color, var(--primary-text-color));
  }

  :host([disabled][checked]) #checkbox {
    background-color: var(--paper-checkbox-unchecked-color, var(--primary-text-color));
    opacity: 0.5;
  }

  :host([disabled]) #checkboxLabel  {
    opacity: 0.65;
  }

  /* invalid state */
  #checkbox.invalid:not(.checked) {
    border-color: var(--paper-checkbox-error-color, var(--error-color));
  }
</style>

<div id="checkboxContainer">
  <div id="checkbox" class$="[[_computeCheckboxClass(checked, invalid)]]">
    <div id="checkmark" class$="[[_computeCheckmarkClass(checked)]]"></div>
  </div>
</div>

<div id="checkboxLabel"><slot></slot></div>`;
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */
if(template$e.setAttribute("strip-whitespace",""),Polymer({_template:template$e,is:"paper-checkbox",behaviors:[PaperCheckedElementBehavior],hostAttributes:{role:"checkbox","aria-checked":!1,tabindex:0},properties:{ariaActiveAttribute:{type:String,value:"aria-checked"}},attached:function(){afterNextRender(this,(function(){if("-1px"===this.getComputedStyleValue("--calculated-paper-checkbox-ink-size").trim()){var e=this.getComputedStyleValue("--calculated-paper-checkbox-size").trim(),t="px",n=e.match(/[A-Za-z]+$/);null!==n&&(t=n[0]);var r=parseFloat(e),i=8/3*r;"px"===t&&(i=Math.floor(i))%2!=r%2&&i++,this.updateStyles({"--paper-checkbox-ink-size":i+t})}}))},_computeCheckboxClass:function(e,t){var n="";return e&&(n+="checked "),t&&(n+="invalid"),n},_computeCheckmarkClass:function(e){return e?"":"hidden"},_createRipple:function(){return this._rippleContainer=this.$.checkboxContainer,PaperInkyFocusBehaviorImpl._createRipple.call(this)}}),!window.polymerSkipLoadingFontRoboto){const e=document.createElement("link");e.rel="stylesheet",e.type="text/css",e.crossOrigin="anonymous",e.href="https://fonts.googleapis.com/css?family=Roboto+Mono:400,700|Roboto:400,300,300italic,400italic,500,500italic,700,700italic",document.head.appendChild(e)}
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */const template$d=html`<custom-style>
  <style is="custom-style">
    html {

      /* Shared Styles */
      --paper-font-common-base: {
        font-family: 'Roboto', 'Noto', sans-serif;
        -webkit-font-smoothing: antialiased;
      };

      --paper-font-common-code: {
        font-family: 'Roboto Mono', 'Consolas', 'Menlo', monospace;
        -webkit-font-smoothing: antialiased;
      };

      --paper-font-common-expensive-kerning: {
        text-rendering: optimizeLegibility;
      };

      --paper-font-common-nowrap: {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      };

      /* Material Font Styles */

      --paper-font-display4: {
        @apply --paper-font-common-base;
        @apply --paper-font-common-nowrap;

        font-size: 112px;
        font-weight: 300;
        letter-spacing: -.044em;
        line-height: 120px;
      };

      --paper-font-display3: {
        @apply --paper-font-common-base;
        @apply --paper-font-common-nowrap;

        font-size: 56px;
        font-weight: 400;
        letter-spacing: -.026em;
        line-height: 60px;
      };

      --paper-font-display2: {
        @apply --paper-font-common-base;

        font-size: 45px;
        font-weight: 400;
        letter-spacing: -.018em;
        line-height: 48px;
      };

      --paper-font-display1: {
        @apply --paper-font-common-base;

        font-size: 34px;
        font-weight: 400;
        letter-spacing: -.01em;
        line-height: 40px;
      };

      --paper-font-headline: {
        @apply --paper-font-common-base;

        font-size: 24px;
        font-weight: 400;
        letter-spacing: -.012em;
        line-height: 32px;
      };

      --paper-font-title: {
        @apply --paper-font-common-base;
        @apply --paper-font-common-nowrap;

        font-size: 20px;
        font-weight: 500;
        line-height: 28px;
      };

      --paper-font-subhead: {
        @apply --paper-font-common-base;

        font-size: 16px;
        font-weight: 400;
        line-height: 24px;
      };

      --paper-font-body2: {
        @apply --paper-font-common-base;

        font-size: 14px;
        font-weight: 500;
        line-height: 24px;
      };

      --paper-font-body1: {
        @apply --paper-font-common-base;

        font-size: 14px;
        font-weight: 400;
        line-height: 20px;
      };

      --paper-font-caption: {
        @apply --paper-font-common-base;
        @apply --paper-font-common-nowrap;

        font-size: 12px;
        font-weight: 400;
        letter-spacing: 0.011em;
        line-height: 20px;
      };

      --paper-font-menu: {
        @apply --paper-font-common-base;
        @apply --paper-font-common-nowrap;

        font-size: 13px;
        font-weight: 500;
        line-height: 24px;
      };

      --paper-font-button: {
        @apply --paper-font-common-base;
        @apply --paper-font-common-nowrap;

        font-size: 14px;
        font-weight: 500;
        letter-spacing: 0.018em;
        line-height: 24px;
        text-transform: uppercase;
      };

      --paper-font-code2: {
        @apply --paper-font-common-code;

        font-size: 14px;
        font-weight: 700;
        line-height: 20px;
      };

      --paper-font-code1: {
        @apply --paper-font-common-code;

        font-size: 14px;
        font-weight: 500;
        line-height: 20px;
      };

    }

  </style>
</custom-style>`;template$d.setAttribute("style","display: none;"),document.head.appendChild(template$d.content);
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */
const $_documentContainer$4=document.createElement("template");$_documentContainer$4.setAttribute("style","display: none;"),$_documentContainer$4.innerHTML='<dom-module id="paper-dialog-shared-styles">\n  <template>\n    <style>\n      :host {\n        display: block;\n        margin: 24px 40px;\n\n        background: var(--paper-dialog-background-color, var(--primary-background-color));\n        color: var(--paper-dialog-color, var(--primary-text-color));\n\n        @apply --paper-font-body1;\n        @apply --shadow-elevation-16dp;\n        @apply --paper-dialog;\n      }\n\n      :host > ::slotted(*) {\n        margin-top: 20px;\n        padding: 0 24px;\n      }\n\n      :host > ::slotted(.no-padding) {\n        padding: 0;\n      }\n\n      \n      :host > ::slotted(*:first-child) {\n        margin-top: 24px;\n      }\n\n      :host > ::slotted(*:last-child) {\n        margin-bottom: 24px;\n      }\n\n      /* In 1.x, this selector was `:host > ::content h2`. In 2.x <slot> allows\n      to select direct children only, which increases the weight of this\n      selector, so we have to re-define first-child/last-child margins below. */\n      :host > ::slotted(h2) {\n        position: relative;\n        margin: 0;\n\n        @apply --paper-font-title;\n        @apply --paper-dialog-title;\n      }\n\n      /* Apply mixin again, in case it sets margin-top. */\n      :host > ::slotted(h2:first-child) {\n        margin-top: 24px;\n        @apply --paper-dialog-title;\n      }\n\n      /* Apply mixin again, in case it sets margin-bottom. */\n      :host > ::slotted(h2:last-child) {\n        margin-bottom: 24px;\n        @apply --paper-dialog-title;\n      }\n\n      :host > ::slotted(.paper-dialog-buttons),\n      :host > ::slotted(.buttons) {\n        position: relative;\n        padding: 8px 8px 8px 24px;\n        margin: 0;\n\n        color: var(--paper-dialog-button-color, var(--primary-color));\n\n        @apply --layout-horizontal;\n        @apply --layout-end-justified;\n      }\n    </style>\n  </template>\n</dom-module>',document.head.appendChild($_documentContainer$4.content);
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */
const NeonAnimatableBehavior={properties:{animationConfig:{type:Object},entryAnimation:{observer:"_entryAnimationChanged",type:String},exitAnimation:{observer:"_exitAnimationChanged",type:String}},_entryAnimationChanged:function(){this.animationConfig=this.animationConfig||{},this.animationConfig.entry=[{name:this.entryAnimation,node:this}]},_exitAnimationChanged:function(){this.animationConfig=this.animationConfig||{},this.animationConfig.exit=[{name:this.exitAnimation,node:this}]},_copyProperties:function(e,t){for(var n in t)e[n]=t[n]},_cloneConfig:function(e){var t={isClone:!0};return this._copyProperties(t,e),t},_getAnimationConfigRecursive:function(e,t,n){var r;if(this.animationConfig)if(this.animationConfig.value&&"function"==typeof this.animationConfig.value)this._warn(this._logf("playAnimation","Please put 'animationConfig' inside of your components 'properties' object instead of outside of it."));else if(r=e?this.animationConfig[e]:this.animationConfig,Array.isArray(r)||(r=[r]),r)for(var i,a=0;i=r[a];a++)if(i.animatable)i.animatable._getAnimationConfigRecursive(i.type||e,t,n);else if(i.id){var o=t[i.id];o?(o.isClone||(t[i.id]=this._cloneConfig(o),o=t[i.id]),this._copyProperties(o,i)):t[i.id]=i}else n.push(i)},getAnimationConfig:function(e){var t={},n=[];for(var r in this._getAnimationConfigRecursive(e,t,n),t)n.push(t[r]);return n}},NeonAnimationRunnerBehaviorImpl={_configureAnimations:function(e){var t=[],n=[];if(e.length>0)for(let t,r=0;t=e[r];r++){let e=document.createElement(t.name);if(e.isNeonAnimation){let r=null;e.configure||(e.configure=function(e){return null}),r=e.configure(t),n.push({result:r,config:t,neonAnimation:e})}else console.warn(this.is+":",t.name,"not found!")}for(var r=0;r<n.length;r++){let e=n[r].result,i=n[r].config,a=n[r].neonAnimation;try{"function"!=typeof e.cancel&&(e=document.timeline.play(e))}catch(t){e=null,console.warn("Couldnt play","(",i.name,").",t)}e&&t.push({neonAnimation:a,config:i,animation:e})}return t},_shouldComplete:function(e){for(var t=!0,n=0;n<e.length;n++)if("finished"!=e[n].animation.playState){t=!1;break}return t},_complete:function(e){for(var t=0;t<e.length;t++)e[t].neonAnimation.complete(e[t].config);for(t=0;t<e.length;t++)e[t].animation.cancel()},playAnimation:function(e,t){var n=this.getAnimationConfig(e);if(n){this._active=this._active||{},this._active[e]&&(this._complete(this._active[e]),delete this._active[e]);var r=this._configureAnimations(n);if(0!=r.length){this._active[e]=r;for(var i=0;i<r.length;i++)r[i].animation.onfinish=function(){this._shouldComplete(r)&&(this._complete(r),delete this._active[e],this.fire("neon-animation-finish",t,{bubbles:!1}))}.bind(this)}else this.fire("neon-animation-finish",t,{bubbles:!1})}},cancelAnimation:function(){for(var e in this._active){var t=this._active[e];for(var n in t)t[n].animation.cancel()}this._active={}}},NeonAnimationRunnerBehavior=[NeonAnimatableBehavior,NeonAnimationRunnerBehaviorImpl];
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */
let verticalScrollbarMaxWidthBugOffset;const getVerticalScrollbarMaxWidthBugOffset=()=>{if(void 0!==verticalScrollbarMaxWidthBugOffset)return verticalScrollbarMaxWidthBugOffset;const e=document.createElement("div");Object.assign(e.style,{overflow:"auto",position:"fixed",left:"0px",top:"0px",maxWidth:"100px",maxHeight:"100px"});const t=document.createElement("div");return t.style.width="200px",t.style.height="200px",e.appendChild(t),document.body.appendChild(e),verticalScrollbarMaxWidthBugOffset=Math.abs(e.offsetWidth-100)>1?e.offsetWidth-e.clientWidth:0,document.body.removeChild(e),verticalScrollbarMaxWidthBugOffset},IronFitBehavior={properties:{sizingTarget:{type:Object,value:function(){return this}},fitInto:{type:Object,value:window},noOverlap:{type:Boolean},positionTarget:{type:Element},horizontalAlign:{type:String},verticalAlign:{type:String},dynamicAlign:{type:Boolean},horizontalOffset:{type:Number,value:0,notify:!0},verticalOffset:{type:Number,value:0,notify:!0},autoFitOnAttach:{type:Boolean,value:!1},expandSizingTargetForScrollbars:{type:Boolean,value:!1},_fitInfo:{type:Object}},get _fitWidth(){return this.fitInto===window?this.fitInto.innerWidth:this.fitInto.getBoundingClientRect().width},get _fitHeight(){return this.fitInto===window?this.fitInto.innerHeight:this.fitInto.getBoundingClientRect().height},get _fitLeft(){return this.fitInto===window?0:this.fitInto.getBoundingClientRect().left},get _fitTop(){return this.fitInto===window?0:this.fitInto.getBoundingClientRect().top},get _defaultPositionTarget(){var e=dom$1(this).parentNode;return e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&(e=e.host),e},get _localeHorizontalAlign(){if(this._isRTL){if("right"===this.horizontalAlign)return"left";if("left"===this.horizontalAlign)return"right"}return this.horizontalAlign},get __shouldPosition(){return(this.horizontalAlign||this.verticalAlign)&&this.positionTarget},get _isRTL(){return void 0===this._memoizedIsRTL&&(this._memoizedIsRTL="rtl"==window.getComputedStyle(this).direction),this._memoizedIsRTL},attached:function(){this.positionTarget=this.positionTarget||this._defaultPositionTarget,this.autoFitOnAttach&&("none"===window.getComputedStyle(this).display?setTimeout(function(){this.fit()}.bind(this)):(window.ShadyDOM&&ShadyDOM.flush(),this.fit()))},detached:function(){this.__deferredFit&&(clearTimeout(this.__deferredFit),this.__deferredFit=null)},fit:function(){this.position(),this.constrain(),this.center()},_discoverInfo:function(){if(!this._fitInfo){var e=window.getComputedStyle(this),t=window.getComputedStyle(this.sizingTarget);this._fitInfo={inlineStyle:{top:this.style.top||"",left:this.style.left||"",position:this.style.position||""},sizerInlineStyle:{maxWidth:this.sizingTarget.style.maxWidth||"",maxHeight:this.sizingTarget.style.maxHeight||"",boxSizing:this.sizingTarget.style.boxSizing||""},positionedBy:{vertically:"auto"!==e.top?"top":"auto"!==e.bottom?"bottom":null,horizontally:"auto"!==e.left?"left":"auto"!==e.right?"right":null},sizedBy:{height:"none"!==t.maxHeight,width:"none"!==t.maxWidth,minWidth:parseInt(t.minWidth,10)||0,minHeight:parseInt(t.minHeight,10)||0},margin:{top:parseInt(e.marginTop,10)||0,right:parseInt(e.marginRight,10)||0,bottom:parseInt(e.marginBottom,10)||0,left:parseInt(e.marginLeft,10)||0}}}},resetFit:function(){var e=this._fitInfo||{};for(var t in e.sizerInlineStyle)this.sizingTarget.style[t]=e.sizerInlineStyle[t];for(var t in e.inlineStyle)this.style[t]=e.inlineStyle[t];this._fitInfo=null},refit:function(){var e=this.sizingTarget.scrollLeft,t=this.sizingTarget.scrollTop;this.resetFit(),this.fit(),this.sizingTarget.scrollLeft=e,this.sizingTarget.scrollTop=t},position:function(){if(!this.__shouldPosition)return;this._discoverInfo(),window.ShadyDOM&&window.ShadyDOM.flush(),this.style.position="fixed",this.sizingTarget.style.boxSizing="border-box",this.style.left="0px",this.style.top="0px";var e=this.getBoundingClientRect(),t=this.__getNormalizedRect(this.positionTarget),n=this.__getNormalizedRect(this.fitInto);let r,i,a,o;this.expandSizingTargetForScrollbars&&(r=this.sizingTarget.offsetWidth,i=this.sizingTarget.offsetHeight,a=this.sizingTarget.clientWidth,o=this.sizingTarget.clientHeight);var s=this._fitInfo.margin,l=this.__getPosition(this._localeHorizontalAlign,this.verticalAlign,{width:e.width+s.left+s.right,height:e.height+s.top+s.bottom},e,t,n),c=l.left+s.left,h=l.top+s.top,u=Math.min(n.right-s.right,c+e.width),d=Math.min(n.bottom-s.bottom,h+e.height);c=Math.max(n.left+s.left,Math.min(c,u-this._fitInfo.sizedBy.minWidth)),h=Math.max(n.top+s.top,Math.min(h,d-this._fitInfo.sizedBy.minHeight));const p=Math.max(u-c,this._fitInfo.sizedBy.minWidth),m=Math.max(d-h,this._fitInfo.sizedBy.minHeight);this.sizingTarget.style.maxWidth=p+"px",this.sizingTarget.style.maxHeight=m+"px";const f=c-e.left,g=h-e.top;if(this.style.left=`${f}px`,this.style.top=`${g}px`,this.expandSizingTargetForScrollbars){const e=this.sizingTarget.offsetHeight,t=e-this.sizingTarget.clientHeight-(i-o);if(t>0){const r=Math.min(n.height-s.top-s.bottom,m+t);this.sizingTarget.style.maxHeight=`${r}px`;const i=this.sizingTarget.offsetHeight,a=i-e;let o;"top"===l.verticalAlign?o=g:"middle"===l.verticalAlign?o=g-a/2:"bottom"===l.verticalAlign&&(o=g-a),o=Math.max(n.top+s.top,Math.min(o,n.bottom-s.bottom-i)),this.style.top=`${o}px`}const c=this.sizingTarget.offsetWidth,h=c-this.sizingTarget.clientWidth-(r-a);if(h>0){const e=getVerticalScrollbarMaxWidthBugOffset(),t=Math.min(n.width-s.left-s.right,p+h-e);this.sizingTarget.style.maxWidth=`${t}px`;const r=this.sizingTarget.offsetWidth+e,i=r-c;let a;"left"===l.horizontalAlign?a=f:"center"===l.horizontalAlign?a=f-i/2:"right"===l.horizontalAlign&&(a=f-i),a=Math.max(n.left+s.left,Math.min(a,n.right-s.right-r)),this.style.left=`${a}px`}}},constrain:function(){if(!this.__shouldPosition){this._discoverInfo();var e=this._fitInfo;e.positionedBy.vertically||(this.style.position="fixed",this.style.top="0px"),e.positionedBy.horizontally||(this.style.position="fixed",this.style.left="0px"),this.sizingTarget.style.boxSizing="border-box";var t=this.getBoundingClientRect();e.sizedBy.height||this.__sizeDimension(t,e.positionedBy.vertically,"top","bottom","Height"),e.sizedBy.width||this.__sizeDimension(t,e.positionedBy.horizontally,"left","right","Width")}},_sizeDimension:function(e,t,n,r,i){this.__sizeDimension(e,t,n,r,i)},__sizeDimension:function(e,t,n,r,i){var a=this._fitInfo,o=this.__getNormalizedRect(this.fitInto),s="Width"===i?o.width:o.height,l=t===r,c="offset"+i;this.sizingTarget.style["max"+i]=s-a.margin[l?n:r]-(l?s-e[r]:e[n])-(this[c]-this.sizingTarget[c])+"px"},center:function(){if(!this.__shouldPosition){this._discoverInfo();var e=this._fitInfo.positionedBy;if(!e.vertically||!e.horizontally){this.style.position="fixed",e.vertically||(this.style.top="0px"),e.horizontally||(this.style.left="0px");var t=this.getBoundingClientRect(),n=this.__getNormalizedRect(this.fitInto);if(!e.vertically)this.style.top=n.top-t.top+(n.height-t.height)/2+"px";if(!e.horizontally)this.style.left=n.left-t.left+(n.width-t.width)/2+"px"}}},__getNormalizedRect:function(e){return e===document.documentElement||e===window?{top:0,left:0,width:window.innerWidth,height:window.innerHeight,right:window.innerWidth,bottom:window.innerHeight}:e.getBoundingClientRect()},__getOffscreenArea:function(e,t,n){var r=Math.min(0,e.top)+Math.min(0,n.bottom-(e.top+t.height)),i=Math.min(0,e.left)+Math.min(0,n.right-(e.left+t.width));return Math.abs(r)*t.width+Math.abs(i)*t.height},__getPosition:function(e,t,n,r,i,a){var o,s=[{verticalAlign:"top",horizontalAlign:"left",top:i.top+this.verticalOffset,left:i.left+this.horizontalOffset},{verticalAlign:"top",horizontalAlign:"right",top:i.top+this.verticalOffset,left:i.right-n.width-this.horizontalOffset},{verticalAlign:"bottom",horizontalAlign:"left",top:i.bottom-n.height-this.verticalOffset,left:i.left+this.horizontalOffset},{verticalAlign:"bottom",horizontalAlign:"right",top:i.bottom-n.height-this.verticalOffset,left:i.right-n.width-this.horizontalOffset}];if(this.noOverlap){for(var l=0,c=s.length;l<c;l++){var h={};for(var u in s[l])h[u]=s[l][u];s.push(h)}s[0].top=s[1].top+=i.height,s[2].top=s[3].top-=i.height,s[4].left=s[6].left+=i.width,s[5].left=s[7].left-=i.width}t="auto"===t?null:t,(e="auto"===e?null:e)&&"center"!==e||(s.push({verticalAlign:"top",horizontalAlign:"center",top:i.top+this.verticalOffset+(this.noOverlap?i.height:0),left:i.left-r.width/2+i.width/2+this.horizontalOffset}),s.push({verticalAlign:"bottom",horizontalAlign:"center",top:i.bottom-n.height-this.verticalOffset-(this.noOverlap?i.height:0),left:i.left-r.width/2+i.width/2+this.horizontalOffset})),t&&"middle"!==t||(s.push({verticalAlign:"middle",horizontalAlign:"left",top:i.top-r.height/2+i.height/2+this.verticalOffset,left:i.left+this.horizontalOffset+(this.noOverlap?i.width:0)}),s.push({verticalAlign:"middle",horizontalAlign:"right",top:i.top-r.height/2+i.height/2+this.verticalOffset,left:i.right-n.width-this.horizontalOffset-(this.noOverlap?i.width:0)})),"middle"===t&&"center"===e&&s.push({verticalAlign:"middle",horizontalAlign:"center",top:i.top-r.height/2+i.height/2+this.verticalOffset,left:i.left-r.width/2+i.width/2+this.horizontalOffset});for(l=0;l<s.length;l++){var d=s[l],p=d.verticalAlign===t,m=d.horizontalAlign===e;if(!this.dynamicAlign&&!this.noOverlap&&p&&m){o=d;break}var f=(!t||p)&&(!e||m);if(this.dynamicAlign||f){if(d.offscreenArea=this.__getOffscreenArea(d,n,a),0===d.offscreenArea&&f){o=d;break}var g=d.offscreenArea-(o=o||d).offscreenArea;(g<0||0===g&&(p||m))&&(o=d)}}return o}};
/**
    @license
    Copyright (c) 2016 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */
var p$1=Element.prototype,matches=p$1.matches||p$1.matchesSelector||p$1.mozMatchesSelector||p$1.msMatchesSelector||p$1.oMatchesSelector||p$1.webkitMatchesSelector;class IronFocusablesHelperClass{getTabbableNodes(e){var t=[];return this._collectTabbableNodes(e,t)?this._sortByTabIndex(t):t}isFocusable(e){return matches.call(e,"input, select, textarea, button, object")?matches.call(e,":not([disabled])"):matches.call(e,"a[href], area[href], iframe, [tabindex], [contentEditable]")}isTabbable(e){return this.isFocusable(e)&&matches.call(e,':not([tabindex="-1"])')&&this._isVisible(e)}_normalizedTabIndex(e){if(this.isFocusable(e)){var t=e.getAttribute("tabindex")||0;return Number(t)}return-1}_collectTabbableNodes(e,t){if(e.nodeType!==Node.ELEMENT_NODE)return!1;var n=e;if(!this._isVisible(n))return!1;var r,i=this._normalizedTabIndex(n),a=i>0;i>=0&&t.push(n),r="content"===n.localName||"slot"===n.localName?dom$1(n).getDistributedNodes():dom$1(n.root||n).children;for(var o=0;o<r.length;o++)a=this._collectTabbableNodes(r[o],t)||a;return a}_isVisible(e){var t=e.style;return"hidden"!==t.visibility&&"none"!==t.display&&("hidden"!==(t=window.getComputedStyle(e)).visibility&&"none"!==t.display)}_sortByTabIndex(e){var t=e.length;if(t<2)return e;var n=Math.ceil(t/2),r=this._sortByTabIndex(e.slice(0,n)),i=this._sortByTabIndex(e.slice(n));return this._mergeSortByTabIndex(r,i)}_mergeSortByTabIndex(e,t){for(var n=[];e.length>0&&t.length>0;)this._hasLowerTabOrder(e[0],t[0])?n.push(t.shift()):n.push(e.shift());return n.concat(e,t)}_hasLowerTabOrder(e,t){var n=Math.max(e.tabIndex,0),r=Math.max(t.tabIndex,0);return 0===n||0===r?r>n:n>r}}const IronFocusablesHelper=new IronFocusablesHelperClass;
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */Polymer({_template:html`
    <style>
      :host {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: var(--iron-overlay-backdrop-background-color, #000);
        opacity: 0;
        transition: opacity 0.2s;
        pointer-events: none;
        @apply --iron-overlay-backdrop;
      }

      :host(.opened) {
        opacity: var(--iron-overlay-backdrop-opacity, 0.6);
        pointer-events: auto;
        @apply --iron-overlay-backdrop-opened;
      }
    </style>

    <slot></slot>
`,is:"iron-overlay-backdrop",properties:{opened:{reflectToAttribute:!0,type:Boolean,value:!1,observer:"_openedChanged"}},listeners:{transitionend:"_onTransitionend"},created:function(){this.__openedRaf=null},attached:function(){this.opened&&this._openedChanged(this.opened)},prepare:function(){this.opened&&!this.parentNode&&dom$1(document.body).appendChild(this)},open:function(){this.opened=!0},close:function(){this.opened=!1},complete:function(){this.opened||this.parentNode!==document.body||dom$1(this.parentNode).removeChild(this)},_onTransitionend:function(e){e&&e.target===this&&this.complete()},_openedChanged:function(e){if(e)this.prepare();else{var t=window.getComputedStyle(this);"0s"!==t.transitionDuration&&0!=t.opacity||this.complete()}this.isAttached&&(this.__openedRaf&&(window.cancelAnimationFrame(this.__openedRaf),this.__openedRaf=null),this.scrollTop=this.scrollTop,this.__openedRaf=window.requestAnimationFrame(function(){this.__openedRaf=null,this.toggleClass("opened",this.opened)}.bind(this)))}});
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */
class IronOverlayManagerClass{constructor(){this._overlays=[],this._minimumZ=101,this._backdropElement=null,addListener(document.documentElement,"tap",(function(){})),document.addEventListener("tap",this._onCaptureClick.bind(this),!0),document.addEventListener("focus",this._onCaptureFocus.bind(this),!0),document.addEventListener("keydown",this._onCaptureKeyDown.bind(this),!0)}get backdropElement(){return this._backdropElement||(this._backdropElement=document.createElement("iron-overlay-backdrop")),this._backdropElement}get deepActiveElement(){var e=document.activeElement;for(e&&e instanceof Element!=!1||(e=document.body);e.root&&dom$1(e.root).activeElement;)e=dom$1(e.root).activeElement;return e}_bringOverlayAtIndexToFront(e){var t=this._overlays[e];if(t){var n=this._overlays.length-1,r=this._overlays[n];if(r&&this._shouldBeBehindOverlay(t,r)&&n--,!(e>=n)){var i=Math.max(this.currentOverlayZ(),this._minimumZ);for(this._getZ(t)<=i&&this._applyOverlayZ(t,i);e<n;)this._overlays[e]=this._overlays[e+1],e++;this._overlays[n]=t}}}addOrRemoveOverlay(e){e.opened?this.addOverlay(e):this.removeOverlay(e)}addOverlay(e){var t=this._overlays.indexOf(e);if(t>=0)return this._bringOverlayAtIndexToFront(t),void this.trackBackdrop();var n=this._overlays.length,r=this._overlays[n-1],i=Math.max(this._getZ(r),this._minimumZ),a=this._getZ(e);r&&this._shouldBeBehindOverlay(e,r)&&(this._applyOverlayZ(r,i),n--,i=Math.max(this._getZ(this._overlays[n-1]),this._minimumZ));a<=i&&this._applyOverlayZ(e,i),this._overlays.splice(n,0,e),this.trackBackdrop()}removeOverlay(e){var t=this._overlays.indexOf(e);-1!==t&&(this._overlays.splice(t,1),this.trackBackdrop())}currentOverlay(){return this._overlays[this._overlays.length-1]}currentOverlayZ(){return this._getZ(this.currentOverlay())}ensureMinimumZ(e){this._minimumZ=Math.max(this._minimumZ,e)}focusOverlay(){var e=this.currentOverlay();e&&e._applyFocus()}trackBackdrop(){var e=this._overlayWithBackdrop();(e||this._backdropElement)&&(this.backdropElement.style.zIndex=this._getZ(e)-1,this.backdropElement.opened=!!e,this.backdropElement.prepare())}getBackdrops(){for(var e=[],t=0;t<this._overlays.length;t++)this._overlays[t].withBackdrop&&e.push(this._overlays[t]);return e}backdropZ(){return this._getZ(this._overlayWithBackdrop())-1}_overlayWithBackdrop(){for(var e=this._overlays.length-1;e>=0;e--)if(this._overlays[e].withBackdrop)return this._overlays[e]}_getZ(e){var t=this._minimumZ;if(e){var n=Number(e.style.zIndex||window.getComputedStyle(e).zIndex);n==n&&(t=n)}return t}_setZ(e,t){e.style.zIndex=t}_applyOverlayZ(e,t){this._setZ(e,t+2)}_overlayInPath(e){e=e||[];for(var t=0;t<e.length;t++)if(e[t]._manager===this)return e[t]}_onCaptureClick(e){var t=this._overlays.length-1;if(-1!==t)for(var n,r=dom$1(e).path;(n=this._overlays[t])&&this._overlayInPath(r)!==n&&(n._onCaptureClick(e),n.allowClickThrough);)t--}_onCaptureFocus(e){var t=this.currentOverlay();t&&t._onCaptureFocus(e)}_onCaptureKeyDown(e){var t=this.currentOverlay();t&&(IronA11yKeysBehavior.keyboardEventMatchesKeys(e,"esc")?t._onCaptureEsc(e):IronA11yKeysBehavior.keyboardEventMatchesKeys(e,"tab")&&t._onCaptureTab(e))}_shouldBeBehindOverlay(e,t){return!e.alwaysOnTop&&t.alwaysOnTop}}const IronOverlayManager=new IronOverlayManagerClass;
/**
    @license
    Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */var lastTouchPosition={pageX:0,pageY:0},lastRootTarget=null,lastScrollableNodes=[],scrollEvents=["wheel","mousewheel","DOMMouseScroll","touchstart","touchmove"],_boundScrollHandler,currentLockingElement;function pushScrollLock(e){_lockingElements.indexOf(e)>=0||(0===_lockingElements.length&&_lockScrollInteractions(),_lockingElements.push(e),currentLockingElement=_lockingElements[_lockingElements.length-1])}function removeScrollLock(e){var t=_lockingElements.indexOf(e);-1!==t&&(_lockingElements.splice(t,1),currentLockingElement=_lockingElements[_lockingElements.length-1],0===_lockingElements.length&&_unlockScrollInteractions())}const _lockingElements=[];function _scrollInteractionHandler(e){if(e.cancelable&&_shouldPreventScrolling(e)&&e.preventDefault(),e.targetTouches){var t=e.targetTouches[0];lastTouchPosition.pageX=t.pageX,lastTouchPosition.pageY=t.pageY}}function _lockScrollInteractions(){_boundScrollHandler=_boundScrollHandler||_scrollInteractionHandler.bind(void 0);for(var e=0,t=scrollEvents.length;e<t;e++)document.addEventListener(scrollEvents[e],_boundScrollHandler,{capture:!0,passive:!1})}function _unlockScrollInteractions(){for(var e=0,t=scrollEvents.length;e<t;e++)document.removeEventListener(scrollEvents[e],_boundScrollHandler,{capture:!0,passive:!1})}function _shouldPreventScrolling(e){var t=dom$1(e).rootTarget;if("touchmove"!==e.type&&lastRootTarget!==t&&(lastRootTarget=t,lastScrollableNodes=_getScrollableNodes(dom$1(e).path)),!lastScrollableNodes.length)return!0;if("touchstart"===e.type)return!1;var n=_getScrollInfo(e);return!_getScrollingNode(lastScrollableNodes,n.deltaX,n.deltaY)}function _getScrollableNodes(e){for(var t=[],n=e.indexOf(currentLockingElement),r=0;r<=n;r++)if(e[r].nodeType===Node.ELEMENT_NODE){var i=e[r],a=i.style;"scroll"!==a.overflow&&"auto"!==a.overflow&&(a=window.getComputedStyle(i)),"scroll"!==a.overflow&&"auto"!==a.overflow||t.push(i)}return t}function _getScrollingNode(e,t,n){if(t||n)for(var r=Math.abs(n)>=Math.abs(t),i=0;i<e.length;i++){var a=e[i];if(r?n<0?a.scrollTop>0:a.scrollTop<a.scrollHeight-a.clientHeight:t<0?a.scrollLeft>0:a.scrollLeft<a.scrollWidth-a.clientWidth)return a}}function _getScrollInfo(e){var t={deltaX:e.deltaX,deltaY:e.deltaY};if("deltaX"in e);else if("wheelDeltaX"in e&&"wheelDeltaY"in e)t.deltaX=-e.wheelDeltaX,t.deltaY=-e.wheelDeltaY;else if("wheelDelta"in e)t.deltaX=0,t.deltaY=-e.wheelDelta;else if("axis"in e)t.deltaX=1===e.axis?e.detail:0,t.deltaY=2===e.axis?e.detail:0;else if(e.targetTouches){var n=e.targetTouches[0];t.deltaX=lastTouchPosition.pageX-n.pageX,t.deltaY=lastTouchPosition.pageY-n.pageY}return t}
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */const IronOverlayBehaviorImpl={properties:{opened:{observer:"_openedChanged",type:Boolean,value:!1,notify:!0},canceled:{observer:"_canceledChanged",readOnly:!0,type:Boolean,value:!1},withBackdrop:{observer:"_withBackdropChanged",type:Boolean},noAutoFocus:{type:Boolean,value:!1},noCancelOnEscKey:{type:Boolean,value:!1},noCancelOnOutsideClick:{type:Boolean,value:!1},closingReason:{type:Object},restoreFocusOnClose:{type:Boolean,value:!1},allowClickThrough:{type:Boolean},alwaysOnTop:{type:Boolean},scrollAction:{type:String},_manager:{type:Object,value:IronOverlayManager},_focusedChild:{type:Object}},listeners:{"iron-resize":"_onIronResize"},observers:["__updateScrollObservers(isAttached, opened, scrollAction)"],get backdropElement(){return this._manager.backdropElement},get _focusNode(){return this._focusedChild||dom$1(this).querySelector("[autofocus]")||this},get _focusableNodes(){return IronFocusablesHelper.getTabbableNodes(this)},ready:function(){this.__isAnimating=!1,this.__shouldRemoveTabIndex=!1,this.__firstFocusableNode=this.__lastFocusableNode=null,this.__rafs={},this.__restoreFocusNode=null,this.__scrollTop=this.__scrollLeft=null,this.__onCaptureScroll=this.__onCaptureScroll.bind(this),this.__rootNodes=null,this._ensureSetup()},attached:function(){this.opened&&this._openedChanged(this.opened),this._observer=dom$1(this).observeNodes(this._onNodesChange)},detached:function(){for(var e in this._observer&&dom$1(this).unobserveNodes(this._observer),this._observer=null,this.__rafs)null!==this.__rafs[e]&&cancelAnimationFrame(this.__rafs[e]);this.__rafs={},this._manager.removeOverlay(this),this.__isAnimating&&(this.opened?this._finishRenderOpened():(this._applyFocus(),this._finishRenderClosed()))},toggle:function(){this._setCanceled(!1),this.opened=!this.opened},open:function(){this._setCanceled(!1),this.opened=!0},close:function(){this._setCanceled(!1),this.opened=!1},cancel:function(e){this.fire("iron-overlay-canceled",e,{cancelable:!0}).defaultPrevented||(this._setCanceled(!0),this.opened=!1)},invalidateTabbables:function(){this.__firstFocusableNode=this.__lastFocusableNode=null},_ensureSetup:function(){this._overlaySetup||(this._overlaySetup=!0,this.style.outline="none",this.style.display="none")},_openedChanged:function(e){e?this.removeAttribute("aria-hidden"):this.setAttribute("aria-hidden","true"),this.isAttached&&(this.__isAnimating=!0,this.__deraf("__openedChanged",this.__openedChanged))},_canceledChanged:function(){this.closingReason=this.closingReason||{},this.closingReason.canceled=this.canceled},_withBackdropChanged:function(){this.withBackdrop&&!this.hasAttribute("tabindex")?(this.setAttribute("tabindex","-1"),this.__shouldRemoveTabIndex=!0):this.__shouldRemoveTabIndex&&(this.removeAttribute("tabindex"),this.__shouldRemoveTabIndex=!1),this.opened&&this.isAttached&&this._manager.trackBackdrop()},_prepareRenderOpened:function(){this.__restoreFocusNode=this._manager.deepActiveElement,this._preparePositioning(),this.refit(),this._finishPositioning(),this.noAutoFocus&&document.activeElement===this._focusNode&&(this._focusNode.blur(),this.__restoreFocusNode.focus())},_renderOpened:function(){this._finishRenderOpened()},_renderClosed:function(){this._finishRenderClosed()},_finishRenderOpened:function(){this.notifyResize(),this.__isAnimating=!1,this.fire("iron-overlay-opened")},_finishRenderClosed:function(){this.style.display="none",this.style.zIndex="",this.notifyResize(),this.__isAnimating=!1,this.fire("iron-overlay-closed",this.closingReason)},_preparePositioning:function(){this.style.transition=this.style.webkitTransition="none",this.style.transform=this.style.webkitTransform="none",this.style.display=""},_finishPositioning:function(){this.style.display="none",this.scrollTop=this.scrollTop,this.style.transition=this.style.webkitTransition="",this.style.transform=this.style.webkitTransform="",this.style.display="",this.scrollTop=this.scrollTop},_applyFocus:function(){if(this.opened)this.noAutoFocus||this._focusNode.focus();else{if(this.restoreFocusOnClose&&this.__restoreFocusNode){var e=this._manager.deepActiveElement;(e===document.body||composedContains(this,e))&&this.__restoreFocusNode.focus()}this.__restoreFocusNode=null,this._focusNode.blur(),this._focusedChild=null}},_onCaptureClick:function(e){this.noCancelOnOutsideClick||this.cancel(e)},_onCaptureFocus:function(e){if(this.withBackdrop){var t=dom$1(e).path;-1===t.indexOf(this)?(e.stopPropagation(),this._applyFocus()):this._focusedChild=t[0]}},_onCaptureEsc:function(e){this.noCancelOnEscKey||this.cancel(e)},_onCaptureTab:function(e){if(this.withBackdrop){this.__ensureFirstLastFocusables();var t=e.shiftKey,n=t?this.__firstFocusableNode:this.__lastFocusableNode,r=t?this.__lastFocusableNode:this.__firstFocusableNode,i=!1;if(n===r)i=!0;else{var a=this._manager.deepActiveElement;i=a===n||a===this}i&&(e.preventDefault(),this._focusedChild=r,this._applyFocus())}},_onIronResize:function(){this.opened&&!this.__isAnimating&&this.__deraf("refit",this.refit)},_onNodesChange:function(){this.opened&&!this.__isAnimating&&(this.invalidateTabbables(),this.notifyResize())},__ensureFirstLastFocusables:function(){var e=this._focusableNodes;this.__firstFocusableNode=e[0],this.__lastFocusableNode=e[e.length-1]},__openedChanged:function(){this.opened?(this._prepareRenderOpened(),this._manager.addOverlay(this),this._applyFocus(),this._renderOpened()):(this._manager.removeOverlay(this),this._applyFocus(),this._renderClosed())},__deraf:function(e,t){var n=this.__rafs;null!==n[e]&&cancelAnimationFrame(n[e]),n[e]=requestAnimationFrame(function r(){n[e]=null,t.call(this)}.bind(this))},__updateScrollObservers:function(e,t,n){e&&t&&this.__isValidScrollAction(n)?("lock"===n&&(this.__saveScrollPosition(),pushScrollLock(this)),this.__addScrollListeners()):(removeScrollLock(this),this.__removeScrollListeners())},__addScrollListeners:function(){if(!this.__rootNodes){if(this.__rootNodes=[],useShadow)for(var e=this;e;)e.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&e.host&&this.__rootNodes.push(e),e=e.host||e.assignedSlot||e.parentNode;this.__rootNodes.push(document)}this.__rootNodes.forEach((function(e){e.addEventListener("scroll",this.__onCaptureScroll,{capture:!0,passive:!0})}),this)},__removeScrollListeners:function(){this.__rootNodes&&this.__rootNodes.forEach((function(e){e.removeEventListener("scroll",this.__onCaptureScroll,{capture:!0,passive:!0})}),this),this.isAttached||(this.__rootNodes=null)},__isValidScrollAction:function(e){return"lock"===e||"refit"===e||"cancel"===e},__onCaptureScroll:function(e){if(!(this.__isAnimating||dom$1(e).path.indexOf(this)>=0))switch(this.scrollAction){case"lock":this.__restoreScrollPosition();break;case"refit":this.__deraf("refit",this.refit);break;case"cancel":this.cancel(e)}},__saveScrollPosition:function(){document.scrollingElement?(this.__scrollTop=document.scrollingElement.scrollTop,this.__scrollLeft=document.scrollingElement.scrollLeft):(this.__scrollTop=Math.max(document.documentElement.scrollTop,document.body.scrollTop),this.__scrollLeft=Math.max(document.documentElement.scrollLeft,document.body.scrollLeft))},__restoreScrollPosition:function(){document.scrollingElement?(document.scrollingElement.scrollTop=this.__scrollTop,document.scrollingElement.scrollLeft=this.__scrollLeft):(document.documentElement.scrollTop=document.body.scrollTop=this.__scrollTop,document.documentElement.scrollLeft=document.body.scrollLeft=this.__scrollLeft)}},composedParent=e=>e.assignedSlot||e.parentNode||e.host,composedContains=(e,t)=>{for(let n=t;n;n=composedParent(n))if(n===e)return!0;return!1},IronOverlayBehavior=[IronFitBehavior,IronResizableBehavior,IronOverlayBehaviorImpl],PaperDialogBehaviorImpl={hostAttributes:{role:"dialog",tabindex:"-1"},properties:{modal:{type:Boolean,value:!1},__readied:{type:Boolean,value:!1}},observers:["_modalChanged(modal, __readied)"],listeners:{tap:"_onDialogClick"},ready:function(){this.__prevNoCancelOnOutsideClick=this.noCancelOnOutsideClick,this.__prevNoCancelOnEscKey=this.noCancelOnEscKey,this.__prevWithBackdrop=this.withBackdrop,this.__readied=!0},_modalChanged:function(e,t){t&&(e?(this.__prevNoCancelOnOutsideClick=this.noCancelOnOutsideClick,this.__prevNoCancelOnEscKey=this.noCancelOnEscKey,this.__prevWithBackdrop=this.withBackdrop,this.noCancelOnOutsideClick=!0,this.noCancelOnEscKey=!0,this.withBackdrop=!0):(this.noCancelOnOutsideClick=this.noCancelOnOutsideClick&&this.__prevNoCancelOnOutsideClick,this.noCancelOnEscKey=this.noCancelOnEscKey&&this.__prevNoCancelOnEscKey,this.withBackdrop=this.withBackdrop&&this.__prevWithBackdrop))},_updateClosingReasonConfirmed:function(e){this.closingReason=this.closingReason||{},this.closingReason.confirmed=e},_onDialogClick:function(e){for(var t=dom$1(e).path,n=0,r=t.indexOf(this);n<r;n++){var i=t[n];if(i.hasAttribute&&(i.hasAttribute("dialog-dismiss")||i.hasAttribute("dialog-confirm"))){this._updateClosingReasonConfirmed(i.hasAttribute("dialog-confirm")),this.close(),e.stopPropagation();break}}}},PaperDialogBehavior=[IronOverlayBehavior,PaperDialogBehaviorImpl];
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */
Polymer({_template:html`
    <style include="paper-dialog-shared-styles"></style>
    <slot></slot>
`,is:"paper-dialog",behaviors:[PaperDialogBehavior,NeonAnimationRunnerBehavior],listeners:{"neon-animation-finish":"_onNeonAnimationFinish"},_renderOpened:function(){this.cancelAnimation(),this.playAnimation("entry")},_renderClosed:function(){this.cancelAnimation(),this.playAnimation("exit")},_onNeonAnimationFinish:function(){this.opened?this._finishRenderOpened():this._finishRenderClosed()}}),
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */
Polymer({_template:html`
    <style>

      :host {
        display: block;
        @apply --layout-relative;
      }

      :host(.is-scrolled:not(:first-child))::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        height: 1px;
        background: var(--divider-color);
      }

      :host(.can-scroll:not(.scrolled-to-bottom):not(:last-child))::after {
        content: '';
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        height: 1px;
        background: var(--divider-color);
      }

      .scrollable {
        padding: 0 24px;

        @apply --layout-scroll;
        @apply --paper-dialog-scrollable;
      }

      .fit {
        @apply --layout-fit;
      }
    </style>

    <div id="scrollable" class="scrollable" on-scroll="updateScrollState">
      <slot></slot>
    </div>
`,is:"paper-dialog-scrollable",properties:{dialogElement:{type:Object}},get scrollTarget(){return this.$.scrollable},ready:function(){this._ensureTarget(),this.classList.add("no-padding")},attached:function(){this._ensureTarget(),requestAnimationFrame(this.updateScrollState.bind(this))},updateScrollState:function(){this.toggleClass("is-scrolled",this.scrollTarget.scrollTop>0),this.toggleClass("can-scroll",this.scrollTarget.offsetHeight<this.scrollTarget.scrollHeight),this.toggleClass("scrolled-to-bottom",this.scrollTarget.scrollTop+this.scrollTarget.offsetHeight>=this.scrollTarget.scrollHeight)},_ensureTarget:function(){this.dialogElement=this.dialogElement||this.parentElement,this.dialogElement&&this.dialogElement.behaviors&&this.dialogElement.behaviors.indexOf(PaperDialogBehaviorImpl)>=0?(this.dialogElement.sizingTarget=this.scrollTarget,this.scrollTarget.classList.remove("fit")):this.dialogElement&&this.scrollTarget.classList.add("fit")}});
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */
const IronA11yAnnouncer=Polymer({_template:html`
    <style>
      :host {
        display: inline-block;
        position: fixed;
        clip: rect(0px,0px,0px,0px);
      }
    </style>
    <div aria-live$="[[mode]]">[[_text]]</div>
`,is:"iron-a11y-announcer",properties:{mode:{type:String,value:"polite"},timeout:{type:Number,value:150},_text:{type:String,value:""}},created:function(){IronA11yAnnouncer.instance||(IronA11yAnnouncer.instance=this),document.addEventListener("iron-announce",this._onIronAnnounce.bind(this))},announce:function(e){this._text="",this.async((function(){this._text=e}),this.timeout)},_onIronAnnounce:function(e){e.detail&&e.detail.text&&this.announce(e.detail.text)}});IronA11yAnnouncer.instance=null,IronA11yAnnouncer.requestAvailability=function(){IronA11yAnnouncer.instance||(IronA11yAnnouncer.instance=document.createElement("iron-a11y-announcer")),document.body?document.body.appendChild(IronA11yAnnouncer.instance):document.addEventListener("load",(function(){document.body.appendChild(IronA11yAnnouncer.instance)}))},
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */
Polymer({_template:html`
    <style>
      :host {
        display: inline-block;
      }
    </style>
    <slot id="content"></slot>
`,is:"iron-input",behaviors:[IronValidatableBehavior],properties:{bindValue:{type:String,value:""},value:{type:String,computed:"_computeValue(bindValue)"},allowedPattern:{type:String},autoValidate:{type:Boolean,value:!1},_inputElement:Object},observers:["_bindValueChanged(bindValue, _inputElement)"],listeners:{input:"_onInput",keypress:"_onKeypress"},created:function(){IronA11yAnnouncer.requestAvailability(),this._previousValidInput="",this._patternAlreadyChecked=!1},attached:function(){this._observer=dom$1(this).observeNodes(function(e){this._initSlottedInput()}.bind(this))},detached:function(){this._observer&&(dom$1(this).unobserveNodes(this._observer),this._observer=null)},get inputElement(){return this._inputElement},_initSlottedInput:function(){this._inputElement=this.getEffectiveChildren()[0],this.inputElement&&this.inputElement.value&&(this.bindValue=this.inputElement.value),this.fire("iron-input-ready")},get _patternRegExp(){var e;if(this.allowedPattern)e=new RegExp(this.allowedPattern);else switch(this.inputElement.type){case"number":e=/[0-9.,e-]/}return e},_bindValueChanged:function(e,t){t&&(void 0===e?t.value=null:e!==t.value&&(this.inputElement.value=e),this.autoValidate&&this.validate(),this.fire("bind-value-changed",{value:e}))},_onInput:function(){this.allowedPattern&&!this._patternAlreadyChecked&&(this._checkPatternValidity()||(this._announceInvalidCharacter("Invalid string of characters not entered."),this.inputElement.value=this._previousValidInput));this.bindValue=this._previousValidInput=this.inputElement.value,this._patternAlreadyChecked=!1},_isPrintable:function(e){return!(8==e.keyCode||9==e.keyCode||13==e.keyCode||27==e.keyCode||0==e.charCode&&(19==e.keyCode||20==e.keyCode||45==e.keyCode||46==e.keyCode||144==e.keyCode||145==e.keyCode||e.keyCode>32&&e.keyCode<41||e.keyCode>111&&e.keyCode<124))},_onKeypress:function(e){if(this.allowedPattern||"number"===this.inputElement.type){var t=this._patternRegExp;if(t&&!(e.metaKey||e.ctrlKey||e.altKey)){this._patternAlreadyChecked=!0;var n=String.fromCharCode(e.charCode);this._isPrintable(e)&&!t.test(n)&&(e.preventDefault(),this._announceInvalidCharacter("Invalid character "+n+" not entered."))}}},_checkPatternValidity:function(){var e=this._patternRegExp;if(!e)return!0;for(var t=0;t<this.inputElement.value.length;t++)if(!e.test(this.inputElement.value[t]))return!1;return!0},validate:function(){if(!this.inputElement)return this.invalid=!1,!0;var e=this.inputElement.checkValidity();return e&&(this.required&&""===this.bindValue?e=!1:this.hasValidator()&&(e=IronValidatableBehavior.validate.call(this,this.bindValue))),this.invalid=!e,this.fire("iron-input-validate"),e},_announceInvalidCharacter:function(e){this.fire("iron-announce",{text:e})},_computeValue:function(e){return e}});
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */
const PaperInputAddonBehavior={attached:function(){this.fire("addon-attached")},update:function(e){}};
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */Polymer({_template:html`
    <style>
      :host {
        display: inline-block;
        float: right;

        @apply --paper-font-caption;
        @apply --paper-input-char-counter;
      }

      :host([hidden]) {
        display: none !important;
      }

      :host(:dir(rtl)) {
        float: left;
      }
    </style>

    <span>[[_charCounterStr]]</span>
`,is:"paper-input-char-counter",behaviors:[PaperInputAddonBehavior],properties:{_charCounterStr:{type:String,value:"0"}},update:function(e){if(e.inputElement){e.value=e.value||"";var t=e.value.toString().length.toString();e.inputElement.hasAttribute("maxlength")&&(t+="/"+e.inputElement.getAttribute("maxlength")),this._charCounterStr=t}}});
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */
const template$c=html`
<custom-style>
  <style is="custom-style">
    html {
      --paper-input-container-shared-input-style: {
        position: relative; /* to make a stacking context */
        outline: none;
        box-shadow: none;
        padding: 0;
        margin: 0;
        width: 100%;
        max-width: 100%;
        background: transparent;
        border: none;
        color: var(--paper-input-container-input-color, var(--primary-text-color));
        -webkit-appearance: none;
        text-align: inherit;
        vertical-align: var(--paper-input-container-input-align, bottom);

        @apply --paper-font-subhead;
      };
    }
  </style>
</custom-style>
`;template$c.setAttribute("style","display: none;"),document.head.appendChild(template$c.content),Polymer({_template:html`
    <style>
      :host {
        display: block;
        padding: 8px 0;
        @apply --paper-input-container;
      }

      :host([inline]) {
        display: inline-block;
      }

      :host([disabled]) {
        pointer-events: none;
        opacity: 0.33;

        @apply --paper-input-container-disabled;
      }

      :host([hidden]) {
        display: none !important;
      }

      [hidden] {
        display: none !important;
      }

      .floated-label-placeholder {
        @apply --paper-font-caption;
      }

      .underline {
        height: 2px;
        position: relative;
      }

      .focused-line {
        @apply --layout-fit;
        border-bottom: 2px solid var(--paper-input-container-focus-color, var(--primary-color));

        -webkit-transform-origin: center center;
        transform-origin: center center;
        -webkit-transform: scale3d(0,1,1);
        transform: scale3d(0,1,1);

        @apply --paper-input-container-underline-focus;
      }

      .underline.is-highlighted .focused-line {
        -webkit-transform: none;
        transform: none;
        -webkit-transition: -webkit-transform 0.25s;
        transition: transform 0.25s;

        @apply --paper-transition-easing;
      }

      .underline.is-invalid .focused-line {
        border-color: var(--paper-input-container-invalid-color, var(--error-color));
        -webkit-transform: none;
        transform: none;
        -webkit-transition: -webkit-transform 0.25s;
        transition: transform 0.25s;

        @apply --paper-transition-easing;
      }

      .unfocused-line {
        @apply --layout-fit;
        border-bottom: 1px solid var(--paper-input-container-color, var(--secondary-text-color));
        @apply --paper-input-container-underline;
      }

      :host([disabled]) .unfocused-line {
        border-bottom: 1px dashed;
        border-color: var(--paper-input-container-color, var(--secondary-text-color));
        @apply --paper-input-container-underline-disabled;
      }

      .input-wrapper {
        @apply --layout-horizontal;
        @apply --layout-center;
        position: relative;
      }

      .input-content {
        @apply --layout-flex-auto;
        @apply --layout-relative;
        max-width: 100%;
      }

      .input-content ::slotted(label),
      .input-content ::slotted(.paper-input-label) {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        font: inherit;
        color: var(--paper-input-container-color, var(--secondary-text-color));
        -webkit-transition: -webkit-transform 0.25s, width 0.25s;
        transition: transform 0.25s, width 0.25s;
        -webkit-transform-origin: left top;
        transform-origin: left top;
        /* Fix for safari not focusing 0-height date/time inputs with -webkit-apperance: none; */
        min-height: 1px;

        @apply --paper-font-common-nowrap;
        @apply --paper-font-subhead;
        @apply --paper-input-container-label;
        @apply --paper-transition-easing;
      }


      .input-content ::slotted(label):before,
      .input-content ::slotted(.paper-input-label):before {
        @apply --paper-input-container-label-before;
      }

      .input-content ::slotted(label):after,
      .input-content ::slotted(.paper-input-label):after {
        @apply --paper-input-container-label-after;
      }

      .input-content.label-is-floating ::slotted(label),
      .input-content.label-is-floating ::slotted(.paper-input-label) {
        -webkit-transform: translateY(-75%) scale(0.75);
        transform: translateY(-75%) scale(0.75);

        /* Since we scale to 75/100 of the size, we actually have 100/75 of the
        original space now available */
        width: 133%;

        @apply --paper-input-container-label-floating;
      }

      :host(:dir(rtl)) .input-content.label-is-floating ::slotted(label),
      :host(:dir(rtl)) .input-content.label-is-floating ::slotted(.paper-input-label) {
        right: 0;
        left: auto;
        -webkit-transform-origin: right top;
        transform-origin: right top;
      }

      .input-content.label-is-highlighted ::slotted(label),
      .input-content.label-is-highlighted ::slotted(.paper-input-label) {
        color: var(--paper-input-container-focus-color, var(--primary-color));

        @apply --paper-input-container-label-focus;
      }

      .input-content.is-invalid ::slotted(label),
      .input-content.is-invalid ::slotted(.paper-input-label) {
        color: var(--paper-input-container-invalid-color, var(--error-color));
      }

      .input-content.label-is-hidden ::slotted(label),
      .input-content.label-is-hidden ::slotted(.paper-input-label) {
        visibility: hidden;
      }

      .input-content ::slotted(input),
      .input-content ::slotted(iron-input),
      .input-content ::slotted(textarea),
      .input-content ::slotted(iron-autogrow-textarea),
      .input-content ::slotted(.paper-input-input) {
        @apply --paper-input-container-shared-input-style;
        /* The apply shim doesn't apply the nested color custom property,
          so we have to re-apply it here. */
        color: var(--paper-input-container-input-color, var(--primary-text-color));
        @apply --paper-input-container-input;
      }

      .input-content ::slotted(input)::-webkit-outer-spin-button,
      .input-content ::slotted(input)::-webkit-inner-spin-button {
        @apply --paper-input-container-input-webkit-spinner;
      }

      .input-content.focused ::slotted(input),
      .input-content.focused ::slotted(iron-input),
      .input-content.focused ::slotted(textarea),
      .input-content.focused ::slotted(iron-autogrow-textarea),
      .input-content.focused ::slotted(.paper-input-input) {
        @apply --paper-input-container-input-focus;
      }

      .input-content.is-invalid ::slotted(input),
      .input-content.is-invalid ::slotted(iron-input),
      .input-content.is-invalid ::slotted(textarea),
      .input-content.is-invalid ::slotted(iron-autogrow-textarea),
      .input-content.is-invalid ::slotted(.paper-input-input) {
        @apply --paper-input-container-input-invalid;
      }

      .prefix ::slotted(*) {
        display: inline-block;
        @apply --paper-font-subhead;
        @apply --layout-flex-none;
        @apply --paper-input-prefix;
      }

      .suffix ::slotted(*) {
        display: inline-block;
        @apply --paper-font-subhead;
        @apply --layout-flex-none;

        @apply --paper-input-suffix;
      }

      /* Firefox sets a min-width on the input, which can cause layout issues */
      .input-content ::slotted(input) {
        min-width: 0;
      }

      .input-content ::slotted(textarea) {
        resize: none;
      }

      .add-on-content {
        position: relative;
      }

      .add-on-content.is-invalid ::slotted(*) {
        color: var(--paper-input-container-invalid-color, var(--error-color));
      }

      .add-on-content.is-highlighted ::slotted(*) {
        color: var(--paper-input-container-focus-color, var(--primary-color));
      }
    </style>

    <div class="floated-label-placeholder" aria-hidden="true" hidden="[[noLabelFloat]]">&nbsp;</div>

    <div class="input-wrapper">
      <span class="prefix"><slot name="prefix"></slot></span>

      <div class$="[[_computeInputContentClass(noLabelFloat,alwaysFloatLabel,focused,invalid,_inputHasContent)]]" id="labelAndInputContainer">
        <slot name="label"></slot>
        <slot name="input"></slot>
      </div>

      <span class="suffix"><slot name="suffix"></slot></span>
    </div>

    <div class$="[[_computeUnderlineClass(focused,invalid)]]">
      <div class="unfocused-line"></div>
      <div class="focused-line"></div>
    </div>

    <div class$="[[_computeAddOnContentClass(focused,invalid)]]">
      <slot name="add-on"></slot>
    </div>
`,is:"paper-input-container",properties:{noLabelFloat:{type:Boolean,value:!1},alwaysFloatLabel:{type:Boolean,value:!1},attrForValue:{type:String,value:"bind-value"},autoValidate:{type:Boolean,value:!1},invalid:{observer:"_invalidChanged",type:Boolean,value:!1},focused:{readOnly:!0,type:Boolean,value:!1,notify:!0},_addons:{type:Array},_inputHasContent:{type:Boolean,value:!1},_inputSelector:{type:String,value:"input,iron-input,textarea,.paper-input-input"},_boundOnFocus:{type:Function,value:function(){return this._onFocus.bind(this)}},_boundOnBlur:{type:Function,value:function(){return this._onBlur.bind(this)}},_boundOnInput:{type:Function,value:function(){return this._onInput.bind(this)}},_boundValueChanged:{type:Function,value:function(){return this._onValueChanged.bind(this)}}},listeners:{"addon-attached":"_onAddonAttached","iron-input-validate":"_onIronInputValidate"},get _valueChangedEvent(){return this.attrForValue+"-changed"},get _propertyForValue(){return dashToCamelCase(this.attrForValue)},get _inputElement(){return dom$1(this).querySelector(this._inputSelector)},get _inputElementValue(){return this._inputElement[this._propertyForValue]||this._inputElement.value},ready:function(){this.__isFirstValueUpdate=!0,this._addons||(this._addons=[]),this.addEventListener("focus",this._boundOnFocus,!0),this.addEventListener("blur",this._boundOnBlur,!0)},attached:function(){this.attrForValue?this._inputElement.addEventListener(this._valueChangedEvent,this._boundValueChanged):this.addEventListener("input",this._onInput),this._inputElementValue&&""!=this._inputElementValue?this._handleValueAndAutoValidate(this._inputElement):this._handleValue(this._inputElement)},_onAddonAttached:function(e){this._addons||(this._addons=[]);var t=e.target;-1===this._addons.indexOf(t)&&(this._addons.push(t),this.isAttached&&this._handleValue(this._inputElement))},_onFocus:function(){this._setFocused(!0)},_onBlur:function(){this._setFocused(!1),this._handleValueAndAutoValidate(this._inputElement)},_onInput:function(e){this._handleValueAndAutoValidate(e.target)},_onValueChanged:function(e){var t=e.target;this.__isFirstValueUpdate&&(this.__isFirstValueUpdate=!1,void 0===t.value||""===t.value)||this._handleValueAndAutoValidate(e.target)},_handleValue:function(e){var t=this._inputElementValue;this._inputHasContent=!(!t&&0!==t&&("number"!==e.type||e.checkValidity())),this.updateAddons({inputElement:e,value:t,invalid:this.invalid})},_handleValueAndAutoValidate:function(e){var t;this.autoValidate&&e&&(t=e.validate?e.validate(this._inputElementValue):e.checkValidity(),this.invalid=!t);this._handleValue(e)},_onIronInputValidate:function(e){this.invalid=this._inputElement.invalid},_invalidChanged:function(){this._addons&&this.updateAddons({invalid:this.invalid})},updateAddons:function(e){for(var t,n=0;t=this._addons[n];n++)t.update(e)},_computeInputContentClass:function(e,t,n,r,i){var a="input-content";if(e)i&&(a+=" label-is-hidden"),r&&(a+=" is-invalid");else{var o=this.querySelector("label");t||i?(a+=" label-is-floating",this.$.labelAndInputContainer.style.position="static",r?a+=" is-invalid":n&&(a+=" label-is-highlighted")):(o&&(this.$.labelAndInputContainer.style.position="relative"),r&&(a+=" is-invalid"))}return n&&(a+=" focused"),a},_computeUnderlineClass:function(e,t){var n="underline";return t?n+=" is-invalid":e&&(n+=" is-highlighted"),n},_computeAddOnContentClass:function(e,t){var n="add-on-content";return t?n+=" is-invalid":e&&(n+=" is-highlighted"),n}}),
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */
Polymer({_template:html`
    <style>
      :host {
        display: inline-block;
        visibility: hidden;

        color: var(--paper-input-container-invalid-color, var(--error-color));

        @apply --paper-font-caption;
        @apply --paper-input-error;
        position: absolute;
        left:0;
        right:0;
      }

      :host([invalid]) {
        visibility: visible;
      }

      #a11yWrapper {
        visibility: hidden;
      }

      :host([invalid]) #a11yWrapper {
        visibility: visible;
      }
    </style>

    <!--
    If the paper-input-error element is directly referenced by an
    \`aria-describedby\` attribute, such as when used as a paper-input add-on,
    then applying \`visibility: hidden;\` to the paper-input-error element itself
    does not hide the error.

    For more information, see:
    https://www.w3.org/TR/accname-1.1/#mapping_additional_nd_description
    -->
    <div id="a11yWrapper">
      <slot></slot>
    </div>
`,is:"paper-input-error",behaviors:[PaperInputAddonBehavior],properties:{invalid:{readOnly:!0,reflectToAttribute:!0,type:Boolean}},update:function(e){this._setInvalid(e.invalid)}});
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */
const PaperInputHelper={NextLabelID:1,NextAddonID:1,NextInputID:1},PaperInputBehaviorImpl={properties:{label:{type:String},value:{notify:!0,type:String},disabled:{type:Boolean,value:!1},invalid:{type:Boolean,value:!1,notify:!0},allowedPattern:{type:String},type:{type:String},list:{type:String},pattern:{type:String},required:{type:Boolean,value:!1},errorMessage:{type:String},charCounter:{type:Boolean,value:!1},noLabelFloat:{type:Boolean,value:!1},alwaysFloatLabel:{type:Boolean,value:!1},autoValidate:{type:Boolean,value:!1},validator:{type:String},autocomplete:{type:String,value:"off"},autofocus:{type:Boolean,observer:"_autofocusChanged"},inputmode:{type:String},minlength:{type:Number},maxlength:{type:Number},min:{type:String},max:{type:String},step:{type:String},name:{type:String},placeholder:{type:String,value:""},readonly:{type:Boolean,value:!1},size:{type:Number},autocapitalize:{type:String,value:"none"},autocorrect:{type:String,value:"off"},autosave:{type:String},results:{type:Number},accept:{type:String},multiple:{type:Boolean},_ariaDescribedBy:{type:String,value:""},_ariaLabelledBy:{type:String,value:""},_inputId:{type:String,value:""}},listeners:{"addon-attached":"_onAddonAttached"},keyBindings:{"shift+tab:keydown":"_onShiftTabDown"},hostAttributes:{tabindex:0},get inputElement(){return this.$||(this.$={}),this.$.input||(this._generateInputId(),this.$.input=this.$$("#"+this._inputId)),this.$.input},get _focusableElement(){return this.inputElement},created:function(){this._typesThatHaveText=["date","datetime","datetime-local","month","time","week","file"]},attached:function(){this._updateAriaLabelledBy(),!PolymerElement&&this.inputElement&&-1!==this._typesThatHaveText.indexOf(this.inputElement.type)&&(this.alwaysFloatLabel=!0)},_appendStringWithSpace:function(e,t){return e=e?e+" "+t:t},_onAddonAttached:function(e){var t=dom$1(e).rootTarget;if(t.id)this._ariaDescribedBy=this._appendStringWithSpace(this._ariaDescribedBy,t.id);else{var n="paper-input-add-on-"+PaperInputHelper.NextAddonID++;t.id=n,this._ariaDescribedBy=this._appendStringWithSpace(this._ariaDescribedBy,n)}},validate:function(){return this.inputElement.validate()},_focusBlurHandler:function(e){IronControlState._focusBlurHandler.call(this,e),this.focused&&!this._shiftTabPressed&&this._focusableElement&&this._focusableElement.focus()},_onShiftTabDown:function(e){var t=this.getAttribute("tabindex");this._shiftTabPressed=!0,this.setAttribute("tabindex","-1"),this.async((function(){this.setAttribute("tabindex",t),this._shiftTabPressed=!1}),1)},_handleAutoValidate:function(){this.autoValidate&&this.validate()},updateValueAndPreserveCaret:function(e){try{var t=this.inputElement.selectionStart;this.value=e,this.inputElement.selectionStart=t,this.inputElement.selectionEnd=t}catch(t){this.value=e}},_computeAlwaysFloatLabel:function(e,t){return t||e},_updateAriaLabelledBy:function(){var e,t=dom$1(this.root).querySelector("label");t?(t.id?e=t.id:(e="paper-input-label-"+PaperInputHelper.NextLabelID++,t.id=e),this._ariaLabelledBy=e):this._ariaLabelledBy=""},_generateInputId:function(){this._inputId&&""!==this._inputId||(this._inputId="input-"+PaperInputHelper.NextInputID++)},_onChange:function(e){this.shadowRoot&&this.fire(e.type,{sourceEvent:e},{node:this,bubbles:e.bubbles,cancelable:e.cancelable})},_autofocusChanged:function(){if(this.autofocus&&this._focusableElement){var e=document.activeElement;e instanceof HTMLElement&&e!==document.body&&e!==document.documentElement||this._focusableElement.focus()}}},PaperInputBehavior=[IronControlState,IronA11yKeysBehavior,PaperInputBehaviorImpl];
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */
Polymer({is:"paper-input",_template:html`
    <style>
      :host {
        display: block;
      }

      :host([focused]) {
        outline: none;
      }

      :host([hidden]) {
        display: none !important;
      }

      input {
        /* Firefox sets a min-width on the input, which can cause layout issues */
        min-width: 0;
      }

      /* In 1.x, the <input> is distributed to paper-input-container, which styles it.
      In 2.x the <iron-input> is distributed to paper-input-container, which styles
      it, but in order for this to work correctly, we need to reset some
      of the native input's properties to inherit (from the iron-input) */
      iron-input > input {
        @apply --paper-input-container-shared-input-style;
        font-family: inherit;
        font-weight: inherit;
        font-size: inherit;
        letter-spacing: inherit;
        word-spacing: inherit;
        line-height: inherit;
        text-shadow: inherit;
        color: inherit;
        cursor: inherit;
      }

      input:disabled {
        @apply --paper-input-container-input-disabled;
      }

      input::-webkit-outer-spin-button,
      input::-webkit-inner-spin-button {
        @apply --paper-input-container-input-webkit-spinner;
      }

      input::-webkit-clear-button {
        @apply --paper-input-container-input-webkit-clear;
      }

      input::-webkit-calendar-picker-indicator {
        @apply --paper-input-container-input-webkit-calendar-picker-indicator;
      }

      input::-webkit-input-placeholder {
        color: var(--paper-input-container-color, var(--secondary-text-color));
      }

      input:-moz-placeholder {
        color: var(--paper-input-container-color, var(--secondary-text-color));
      }

      input::-moz-placeholder {
        color: var(--paper-input-container-color, var(--secondary-text-color));
      }

      input::-ms-clear {
        @apply --paper-input-container-ms-clear;
      }

      input::-ms-reveal {
        @apply --paper-input-container-ms-reveal;
      }

      input:-ms-input-placeholder {
        color: var(--paper-input-container-color, var(--secondary-text-color));
      }

      label {
        pointer-events: none;
      }
    </style>

    <paper-input-container id="container" no-label-float="[[noLabelFloat]]" always-float-label="[[_computeAlwaysFloatLabel(alwaysFloatLabel,placeholder)]]" auto-validate$="[[autoValidate]]" disabled$="[[disabled]]" invalid="[[invalid]]">

      <slot name="prefix" slot="prefix"></slot>

      <label hidden$="[[!label]]" aria-hidden="true" for$="[[_inputId]]" slot="label">[[label]]</label>

      <!-- Need to bind maxlength so that the paper-input-char-counter works correctly -->
      <iron-input bind-value="{{value}}" slot="input" class="input-element" id$="[[_inputId]]" maxlength$="[[maxlength]]" allowed-pattern="[[allowedPattern]]" invalid="{{invalid}}" validator="[[validator]]">
        <input aria-labelledby$="[[_ariaLabelledBy]]" aria-describedby$="[[_ariaDescribedBy]]" disabled$="[[disabled]]" title$="[[title]]" type$="[[type]]" pattern$="[[pattern]]" required$="[[required]]" autocomplete$="[[autocomplete]]" autofocus$="[[autofocus]]" inputmode$="[[inputmode]]" minlength$="[[minlength]]" maxlength$="[[maxlength]]" min$="[[min]]" max$="[[max]]" step$="[[step]]" name$="[[name]]" placeholder$="[[placeholder]]" readonly$="[[readonly]]" list$="[[list]]" size$="[[size]]" autocapitalize$="[[autocapitalize]]" autocorrect$="[[autocorrect]]" on-change="_onChange" tabindex$="[[tabIndex]]" autosave$="[[autosave]]" results$="[[results]]" accept$="[[accept]]" multiple$="[[multiple]]" role$="[[inputRole]]" aria-haspopup$="[[inputAriaHaspopup]]">
      </iron-input>

      <slot name="suffix" slot="suffix"></slot>

      <template is="dom-if" if="[[errorMessage]]">
        <paper-input-error aria-live="assertive" slot="add-on">[[errorMessage]]</paper-input-error>
      </template>

      <template is="dom-if" if="[[charCounter]]">
        <paper-input-char-counter slot="add-on"></paper-input-char-counter>
      </template>

    </paper-input-container>
  `,behaviors:[PaperInputBehavior,IronFormElementBehavior],properties:{value:{type:String},inputRole:{type:String,value:void 0},inputAriaHaspopup:{type:String,value:void 0}},get _focusableElement(){return this.inputElement._inputElement},listeners:{"iron-input-ready":"_onIronInputReady"},_onIronInputReady:function(){this.$.nativeInput||(this.$.nativeInput=this.$$("input")),this.inputElement&&-1!==this._typesThatHaveText.indexOf(this.$.nativeInput.type)&&(this.alwaysFloatLabel=!0),this.inputElement.bindValue&&this.$.container._handleValueAndAutoValidate(this.inputElement)}}),
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */
Polymer({_template:html`
    <style>
      :host {
        position: fixed;
      }

      #contentWrapper ::slotted(*) {
        overflow: auto;
      }

      #contentWrapper.animating ::slotted(*) {
        overflow: hidden;
        pointer-events: none;
      }
    </style>

    <div id="contentWrapper">
      <slot id="content" name="dropdown-content"></slot>
    </div>
`,is:"iron-dropdown",behaviors:[IronControlState,IronA11yKeysBehavior,IronOverlayBehavior,NeonAnimationRunnerBehavior],properties:{horizontalAlign:{type:String,value:"left",reflectToAttribute:!0},verticalAlign:{type:String,value:"top",reflectToAttribute:!0},openAnimationConfig:{type:Object},closeAnimationConfig:{type:Object},focusTarget:{type:Object},noAnimations:{type:Boolean,value:!1},allowOutsideScroll:{type:Boolean,value:!1,observer:"_allowOutsideScrollChanged"}},listeners:{"neon-animation-finish":"_onNeonAnimationFinish"},observers:["_updateOverlayPosition(positionTarget, verticalAlign, horizontalAlign, verticalOffset, horizontalOffset)"],get containedElement(){for(var e=dom$1(this.$.content).getDistributedNodes(),t=0,n=e.length;t<n;t++)if(e[t].nodeType===Node.ELEMENT_NODE)return e[t]},ready:function(){this.scrollAction||(this.scrollAction=this.allowOutsideScroll?"refit":"lock"),this._readied=!0},attached:function(){this.sizingTarget&&this.sizingTarget!==this||(this.sizingTarget=this.containedElement||this)},detached:function(){this.cancelAnimation()},_openedChanged:function(){this.opened&&this.disabled?this.cancel():(this.cancelAnimation(),this._updateAnimationConfig(),IronOverlayBehaviorImpl._openedChanged.apply(this,arguments))},_renderOpened:function(){!this.noAnimations&&this.animationConfig.open?(this.$.contentWrapper.classList.add("animating"),this.playAnimation("open")):IronOverlayBehaviorImpl._renderOpened.apply(this,arguments)},_renderClosed:function(){!this.noAnimations&&this.animationConfig.close?(this.$.contentWrapper.classList.add("animating"),this.playAnimation("close")):IronOverlayBehaviorImpl._renderClosed.apply(this,arguments)},_onNeonAnimationFinish:function(){this.$.contentWrapper.classList.remove("animating"),this.opened?this._finishRenderOpened():this._finishRenderClosed()},_updateAnimationConfig:function(){for(var e=this.containedElement,t=[].concat(this.openAnimationConfig||[]).concat(this.closeAnimationConfig||[]),n=0;n<t.length;n++)t[n].node=e;this.animationConfig={open:this.openAnimationConfig,close:this.closeAnimationConfig}},_updateOverlayPosition:function(){this.isAttached&&this.notifyResize()},_allowOutsideScrollChanged:function(e){this._readied&&(e?this.scrollAction&&"lock"!==this.scrollAction||(this.scrollAction="refit"):this.scrollAction="lock")},_applyFocus:function(){var e=this.focusTarget||this.containedElement;e&&this.opened&&!this.noAutoFocus?e.focus():IronOverlayBehaviorImpl._applyFocus.apply(this,arguments)}});
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */
const NeonAnimationBehavior={properties:{animationTiming:{type:Object,value:function(){return{duration:500,easing:"cubic-bezier(0.4, 0, 0.2, 1)",fill:"both"}}}},isNeonAnimation:!0,created:function(){document.body.animate||console.warn("No web animations detected. This element will not function without a web animations polyfill.")},timingFromConfig:function(e){if(e.timing)for(var t in e.timing)this.animationTiming[t]=e.timing[t];return this.animationTiming},setPrefixedProperty:function(e,t,n){for(var r,i={transform:["webkitTransform"],transformOrigin:["mozTransformOrigin","webkitTransformOrigin"]}[t],a=0;r=i[a];a++)e.style[r]=n;e.style[t]=n},complete:function(e){}};
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */Polymer({is:"fade-in-animation",behaviors:[NeonAnimationBehavior],configure:function(e){return this._effect=new KeyframeEffect(e.node,[{opacity:"0"},{opacity:"1"}],this.timingFromConfig(e)),this._effect}}),
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */
Polymer({is:"fade-out-animation",behaviors:[NeonAnimationBehavior],configure:function(e){return this._effect=new KeyframeEffect(e.node,[{opacity:"1"},{opacity:"0"}],this.timingFromConfig(e)),this._effect}}),
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */
Polymer({is:"paper-menu-grow-height-animation",_template:null,behaviors:[NeonAnimationBehavior],configure:function(e){var t=e.node,n=t.getBoundingClientRect().height;return this._effect=new KeyframeEffect(t,[{height:n/2+"px"},{height:n+"px"}],this.timingFromConfig(e)),this._effect}}),Polymer({is:"paper-menu-grow-width-animation",_template:null,behaviors:[NeonAnimationBehavior],configure:function(e){var t=e.node,n=t.getBoundingClientRect().width;return this._effect=new KeyframeEffect(t,[{width:n/2+"px"},{width:n+"px"}],this.timingFromConfig(e)),this._effect}}),Polymer({is:"paper-menu-shrink-width-animation",_template:null,behaviors:[NeonAnimationBehavior],configure:function(e){var t=e.node,n=t.getBoundingClientRect().width;return this._effect=new KeyframeEffect(t,[{width:n+"px"},{width:n-n/20+"px"}],this.timingFromConfig(e)),this._effect}}),Polymer({is:"paper-menu-shrink-height-animation",_template:null,behaviors:[NeonAnimationBehavior],configure:function(e){var t=e.node,n=t.getBoundingClientRect().height;return this.setPrefixedProperty(t,"transformOrigin","0 0"),this._effect=new KeyframeEffect(t,[{height:n+"px",transform:"translateY(0)"},{height:n/2+"px",transform:"translateY(-20px)"}],this.timingFromConfig(e)),this._effect}});
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */
var config={ANIMATION_CUBIC_BEZIER:"cubic-bezier(.3,.95,.5,1)",MAX_ANIMATION_TIME_MS:400};const PaperMenuButton=Polymer({_template:html`
    <style>
      :host {
        display: inline-block;
        position: relative;
        padding: 8px;
        outline: none;

        @apply --paper-menu-button;
      }

      :host([disabled]) {
        cursor: auto;
        color: var(--disabled-text-color);

        @apply --paper-menu-button-disabled;
      }

      iron-dropdown {
        @apply --paper-menu-button-dropdown;
      }

      .dropdown-content {
        @apply --shadow-elevation-2dp;

        position: relative;
        border-radius: 2px;
        background-color: var(--paper-menu-button-dropdown-background, var(--primary-background-color));

        @apply --paper-menu-button-content;
      }

      :host([vertical-align="top"]) .dropdown-content {
        margin-bottom: 20px;
        margin-top: -10px;
        top: 10px;
      }

      :host([vertical-align="bottom"]) .dropdown-content {
        bottom: 10px;
        margin-bottom: -10px;
        margin-top: 20px;
      }

      #trigger {
        cursor: pointer;
      }
    </style>

    <div id="trigger" on-tap="toggle">
      <slot name="dropdown-trigger"></slot>
    </div>

    <iron-dropdown id="dropdown" opened="{{opened}}" horizontal-align="[[horizontalAlign]]" vertical-align="[[verticalAlign]]" dynamic-align="[[dynamicAlign]]" horizontal-offset="[[horizontalOffset]]" vertical-offset="[[verticalOffset]]" no-overlap="[[noOverlap]]" open-animation-config="[[openAnimationConfig]]" close-animation-config="[[closeAnimationConfig]]" no-animations="[[noAnimations]]" focus-target="[[_dropdownContent]]" allow-outside-scroll="[[allowOutsideScroll]]" restore-focus-on-close="[[restoreFocusOnClose]]" on-iron-overlay-canceled="__onIronOverlayCanceled" expand-sizing-target-for-scrollbars="[[expandSizingTargetForScrollbars]]">
      <div slot="dropdown-content" class="dropdown-content">
        <slot id="content" name="dropdown-content"></slot>
      </div>
    </iron-dropdown>
`,is:"paper-menu-button",behaviors:[IronA11yKeysBehavior,IronControlState],properties:{opened:{type:Boolean,value:!1,notify:!0,observer:"_openedChanged"},horizontalAlign:{type:String,value:"left",reflectToAttribute:!0},verticalAlign:{type:String,value:"top",reflectToAttribute:!0},dynamicAlign:{type:Boolean},horizontalOffset:{type:Number,value:0,notify:!0},verticalOffset:{type:Number,value:0,notify:!0},noOverlap:{type:Boolean},noAnimations:{type:Boolean,value:!1},ignoreSelect:{type:Boolean,value:!1},closeOnActivate:{type:Boolean,value:!1},openAnimationConfig:{type:Object,value:function(){return[{name:"fade-in-animation",timing:{delay:100,duration:200}},{name:"paper-menu-grow-width-animation",timing:{delay:100,duration:150,easing:config.ANIMATION_CUBIC_BEZIER}},{name:"paper-menu-grow-height-animation",timing:{delay:100,duration:275,easing:config.ANIMATION_CUBIC_BEZIER}}]}},closeAnimationConfig:{type:Object,value:function(){return[{name:"fade-out-animation",timing:{duration:150}},{name:"paper-menu-shrink-width-animation",timing:{delay:100,duration:50,easing:config.ANIMATION_CUBIC_BEZIER}},{name:"paper-menu-shrink-height-animation",timing:{duration:200,easing:"ease-in"}}]}},allowOutsideScroll:{type:Boolean,value:!1},restoreFocusOnClose:{type:Boolean,value:!0},expandSizingTargetForScrollbars:{type:Boolean,value:!1},_dropdownContent:{type:Object}},hostAttributes:{role:"group","aria-haspopup":"true"},listeners:{"iron-activate":"_onIronActivate","iron-select":"_onIronSelect"},get contentElement(){for(var e=dom$1(this.$.content).getDistributedNodes(),t=0,n=e.length;t<n;t++)if(e[t].nodeType===Node.ELEMENT_NODE)return e[t]},toggle:function(){this.opened?this.close():this.open()},open:function(){this.disabled||this.$.dropdown.open()},close:function(){this.$.dropdown.close()},_onIronSelect:function(e){this.ignoreSelect||this.close()},_onIronActivate:function(e){this.closeOnActivate&&this.close()},_openedChanged:function(e,t){e?(this._dropdownContent=this.contentElement,this.fire("paper-dropdown-open")):null!=t&&this.fire("paper-dropdown-close")},_disabledChanged:function(e){IronControlState._disabledChanged.apply(this,arguments),e&&this.opened&&this.close()},__onIronOverlayCanceled:function(e){var t=this.$.trigger;dom$1(e.detail).path.indexOf(t)>-1&&e.preventDefault()}});Object.keys(config).forEach((function(e){PaperMenuButton[e]=config[e]}));
/**
    @license
    Copyright (c) 2016 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */
const $_documentContainer$3=document.createElement("template");$_documentContainer$3.setAttribute("style","display: none;"),$_documentContainer$3.innerHTML='<iron-iconset-svg name="paper-dropdown-menu" size="24">\n<svg><defs>\n<g id="arrow-drop-down"><path d="M7 10l5 5 5-5z"></path></g>\n</defs></svg>\n</iron-iconset-svg>',document.head.appendChild($_documentContainer$3.content);
/**
    @license
    Copyright (c) 2016 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */
const $_documentContainer$2=document.createElement("template");$_documentContainer$2.setAttribute("style","display: none;"),$_documentContainer$2.innerHTML='<dom-module id="paper-dropdown-menu-shared-styles">\n  <template>\n    <style>\n      :host {\n        display: inline-block;\n        position: relative;\n        text-align: left;\n\n        /* NOTE(cdata): Both values are needed, since some phones require the\n         * value to be `transparent`.\n         */\n        -webkit-tap-highlight-color: rgba(0,0,0,0);\n        -webkit-tap-highlight-color: transparent;\n\n        --paper-input-container-input: {\n          overflow: hidden;\n          white-space: nowrap;\n          text-overflow: ellipsis;\n          max-width: 100%;\n          box-sizing: border-box;\n          cursor: pointer;\n        };\n\n        @apply --paper-dropdown-menu;\n      }\n\n      /* paper-dropdown-menu and paper-dropdown-menu-light both delegate focus\n       * to other internal elements which manage focus styling. */\n      :host(:focus) {\n        outline: none;\n      }\n\n      :host(:dir(rtl)) {\n        text-align: right;\n\n        @apply(--paper-dropdown-menu);\n      }\n\n      :host([disabled]) {\n        @apply --paper-dropdown-menu-disabled;\n      }\n\n      :host([noink]) paper-ripple {\n        display: none;\n      }\n\n      :host([no-label-float]) paper-ripple {\n        top: 8px;\n      }\n\n      paper-ripple {\n        top: 12px;\n        left: 0px;\n        bottom: 8px;\n        right: 0px;\n\n        @apply --paper-dropdown-menu-ripple;\n      }\n\n      paper-menu-button {\n        display: block;\n        padding: 0;\n\n        @apply --paper-dropdown-menu-button;\n      }\n\n      paper-input {\n        @apply --paper-dropdown-menu-input;\n      }\n\n      iron-icon {\n        color: var(--disabled-text-color);\n\n        @apply --paper-dropdown-menu-icon;\n      }\n    </style>\n  </template>\n</dom-module>',document.head.appendChild($_documentContainer$2.content);
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */
const LegacyPolymerElementBase=LegacyElementMixin(HTMLElement);Polymer({_template:html`
    <style include="paper-dropdown-menu-shared-styles"></style>

    <paper-menu-button id="menuButton" vertical-align="[[verticalAlign]]" horizontal-align="[[horizontalAlign]]" dynamic-align="[[dynamicAlign]]" vertical-offset="[[_computeMenuVerticalOffset(noLabelFloat, verticalOffset)]]" disabled="[[disabled]]" no-animations="[[noAnimations]]" on-iron-select="_onIronSelect" on-iron-deselect="_onIronDeselect" opened="{{opened}}" close-on-activate allow-outside-scroll="[[allowOutsideScroll]]" restore-focus-on-close="[[restoreFocusOnClose]]" expand-sizing-target-for-scrollbars="[[expandSizingTargetForScrollbars]]">
      <!-- support hybrid mode: user might be using paper-menu-button 1.x which distributes via <content> -->
      <div class="dropdown-trigger" slot="dropdown-trigger">
        <paper-ripple></paper-ripple>
        <!-- paper-input has type="text" for a11y, do not remove -->
        <paper-input id="input" type="text" invalid="[[invalid]]" readonly disabled="[[disabled]]" value="[[value]]" placeholder="[[placeholder]]" error-message="[[errorMessage]]" always-float-label="[[alwaysFloatLabel]]" no-label-float="[[noLabelFloat]]" label="[[label]]" input-role="button" input-aria-haspopup="listbox" autocomplete="off">
          <!-- support hybrid mode: user might be using paper-input 1.x which distributes via <content> -->
          <iron-icon icon="paper-dropdown-menu:arrow-drop-down" suffix slot="suffix"></iron-icon>
        </paper-input>
      </div>
      <slot id="content" name="dropdown-content" slot="dropdown-content"></slot>
    </paper-menu-button>
`,is:"paper-dropdown-menu",behaviors:[IronButtonState,IronControlState,IronFormElementBehavior,IronValidatableBehavior],properties:{selectedItemLabel:{type:String,notify:!0,readOnly:!0},selectedItem:{type:Object,notify:!0,readOnly:!0},value:{type:String,notify:!0},label:{type:String},placeholder:{type:String},errorMessage:{type:String},opened:{type:Boolean,notify:!0,value:!1,observer:"_openedChanged"},allowOutsideScroll:{type:Boolean,value:!1},noLabelFloat:{type:Boolean,value:!1,reflectToAttribute:!0},alwaysFloatLabel:{type:Boolean,value:!1},noAnimations:{type:Boolean,value:!1},horizontalAlign:{type:String,value:"right"},verticalAlign:{type:String,value:"top"},verticalOffset:Number,dynamicAlign:{type:Boolean},restoreFocusOnClose:{type:Boolean,value:!0},expandSizingTargetForScrollbars:{type:Boolean,value:!1}},listeners:{tap:"_onTap"},keyBindings:{"up down":"open",esc:"close"},observers:["_selectedItemChanged(selectedItem)"],_attachDom(e){const t=wrap(this);return t.attachShadow({mode:"open",delegatesFocus:!0,shadyUpgradeFragment:e}),t.shadowRoot.appendChild(e),LegacyPolymerElementBase.prototype._attachDom.call(this,e)},focus(){this.$.input._focusableElement.focus()},attached:function(){var e=this.contentElement;e&&e.selectedItem&&this._setSelectedItem(e.selectedItem)},get contentElement(){for(var e=dom$1(this.$.content).getDistributedNodes(),t=0,n=e.length;t<n;t++)if(e[t].nodeType===Node.ELEMENT_NODE)return e[t]},open:function(){this.$.menuButton.open()},close:function(){this.$.menuButton.close()},_onIronSelect:function(e){this._setSelectedItem(e.detail.item)},_onIronDeselect:function(e){this._setSelectedItem(null)},_onTap:function(e){findOriginalTarget(e)===this&&this.open()},_selectedItemChanged:function(e){var t="";t=e?e.label||e.getAttribute("label")||e.textContent.trim():"",this.value=t,this._setSelectedItemLabel(t)},_computeMenuVerticalOffset:function(e,t){return t||(e?-4:8)},_getValidity:function(e){return this.disabled||!this.required||this.required&&!!this.value},_openedChanged:function(){var e=this.contentElement;e&&e.setAttribute("aria-expanded",this.opened?"true":"false")}});
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */
var SHADOW_WHEN_SCROLLING=1,SHADOW_ALWAYS=2,MODE_CONFIGS={outerScroll:{scroll:!0},shadowMode:{standard:SHADOW_ALWAYS,waterfall:SHADOW_WHEN_SCROLLING,"waterfall-tall":SHADOW_WHEN_SCROLLING},tallMode:{"waterfall-tall":!0}};Polymer({_template:html`
    <style>
      :host {
        @apply --layout-vertical;
        position: relative;
        height: 100%;
        @apply --paper-header-panel;
      }

      #mainContainer {
        @apply --layout-flex;
        position: relative;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
      }

      #mainPanel {
        @apply --layout-vertical;
        @apply --layout-flex;
        position: relative;
        min-height: 0;
        @apply --paper-header-panel-body;
      }

      #mainContainer {
        @apply --paper-header-panel-container;
      }

      /*
       * mode: scroll
       */
      :host([mode=scroll]) #mainContainer {
        @apply --paper-header-panel-scroll-container;
        overflow: visible;
      }

      :host([mode=scroll]) {
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
      }

      /*
       * mode: cover
       */
      :host([mode=cover]) #mainContainer {
        @apply --paper-header-panel-cover-container;
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
      }

      :host([mode=cover]) #mainPanel {
        position: static;
      }

      /*
       * mode: standard
       */
      :host([mode=standard]) #mainContainer {
        @apply --paper-header-panel-standard-container;
      }

      /*
       * mode: seamed
       */
      :host([mode=seamed]) #mainContainer {
        @apply --paper-header-panel-seamed-container;
      }


      /*
       * mode: waterfall
       */
      :host([mode=waterfall]) #mainContainer {
        @apply --paper-header-panel-waterfall-container;
      }

      /*
       * mode: waterfall-tall
       */
      :host([mode=waterfall-tall]) #mainContainer {
        @apply --paper-header-panel-waterfall-tall-container;
      }

      #dropShadow {
        transition: opacity 0.5s;
        height: 6px;
        box-shadow: inset 0px 5px 6px -3px rgba(0, 0, 0, 0.4);
        @apply --paper-header-panel-shadow;
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        opacity: 0;
        pointer-events: none;
      }

      #dropShadow.has-shadow {
        opacity: 1;
      }

      #mainContainer > ::slotted(.fit) {
        @apply --layout-fit;
      }

    </style>

    <slot id="headerSlot" name="header"></slot>

    <div id="mainPanel">
      <div id="mainContainer" class\$="[[_computeMainContainerClass(mode)]]">
        <slot></slot>
      </div>
      <div id="dropShadow"></div>
    </div>
`,is:"paper-header-panel",properties:{mode:{type:String,value:"standard",observer:"_modeChanged",reflectToAttribute:!0},shadow:{type:Boolean,value:!1},tallClass:{type:String,value:"tall"},atTop:{type:Boolean,value:!0,notify:!0,readOnly:!0,reflectToAttribute:!0}},observers:["_computeDropShadowHidden(atTop, mode, shadow)"],attached:function(){this._addListener(),this._keepScrollingState()},detached:function(){this._removeListener()},ready:function(){this.scrollHandler=this._scroll.bind(this),console.warn(this.is,"is deprecated. Please use app-layout instead!")},get header(){return dom$1(this.$.headerSlot).getDistributedNodes()[0]},get scroller(){return this._getScrollerForMode(this.mode)},get visibleShadow(){return this.$.dropShadow.classList.contains("has-shadow")},_computeDropShadowHidden:function(e,t,n){var r=MODE_CONFIGS.shadowMode[t];this.toggleClass("has-shadow",!!this.shadow||(r===SHADOW_ALWAYS||r===SHADOW_WHEN_SCROLLING&&!e),this.$.dropShadow)},_computeMainContainerClass:function(e){var t={};return t.flex="cover"!==e,Object.keys(t).filter((function(e){return t[e]})).join(" ")},_addListener:function(){this.scroller.addEventListener("scroll",this.scrollHandler)},_removeListener:function(){this.scroller.removeEventListener("scroll",this.scrollHandler)},_modeChanged:function(e,t){var n=MODE_CONFIGS,r=this.header;r&&(n.tallMode[t]&&!n.tallMode[e]?(r.classList.remove(this.tallClass),this.async((function(){r.classList.remove("animate")}),200)):this.toggleClass("animate",n.tallMode[e],r)),this._keepScrollingState()},_keepScrollingState:function(){var e=this.scroller,t=this.header;this._setAtTop(0===e.scrollTop),t&&this.tallClass&&MODE_CONFIGS.tallMode[this.mode]&&this.toggleClass(this.tallClass,this.atTop||t.classList.contains(this.tallClass)&&e.scrollHeight<this.offsetHeight,t)},_scroll:function(){this._keepScrollingState(),this.fire("content-scroll",{target:this.scroller},{bubbles:!1})},_getScrollerForMode:function(e){return MODE_CONFIGS.outerScroll[e]?this:this.$.mainContainer}}),
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */
Polymer({is:"paper-icon-button",_template:html`
    <style>
      :host {
        display: inline-block;
        position: relative;
        padding: 8px;
        outline: none;
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
        cursor: pointer;
        z-index: 0;
        line-height: 1;

        width: 40px;
        height: 40px;

        /*
          NOTE: Both values are needed, since some phones require the value to
          be \`transparent\`.
        */
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
        -webkit-tap-highlight-color: transparent;

        /* Because of polymer/2558, this style has lower specificity than * */
        box-sizing: border-box !important;

        @apply --paper-icon-button;
      }

      :host #ink {
        color: var(--paper-icon-button-ink-color, var(--primary-text-color));
        opacity: 0.6;
      }

      :host([disabled]) {
        color: var(--paper-icon-button-disabled-text, var(--disabled-text-color));
        pointer-events: none;
        cursor: auto;

        @apply --paper-icon-button-disabled;
      }

      :host([hidden]) {
        display: none !important;
      }

      :host(:hover) {
        @apply --paper-icon-button-hover;
      }

      iron-icon {
        --iron-icon-width: 100%;
        --iron-icon-height: 100%;
      }
    </style>

    <iron-icon id="icon" src="[[src]]" icon="[[icon]]"
               alt$="[[alt]]"></iron-icon>
  `,hostAttributes:{role:"button",tabindex:"0"},behaviors:[PaperInkyFocusBehavior],registered:function(){this._template.setAttribute("strip-whitespace","")},properties:{src:{type:String},icon:{type:String},alt:{type:String,observer:"_altChanged"}},_altChanged:function(e,t){var n=this.getAttribute("aria-label");n&&t!=n||this.setAttribute("aria-label",e)}}),
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */
Polymer({_template:html`
    <style>
      :host {
        display: inline-block;
        position: relative;
        width: 400px;
        border: 1px solid;
        padding: 2px;
        -moz-appearance: textarea;
        -webkit-appearance: textarea;
        overflow: hidden;
      }

      .mirror-text {
        visibility: hidden;
        word-wrap: break-word;
        @apply --iron-autogrow-textarea;
      }

      .fit {
        @apply --layout-fit;
      }

      textarea {
        position: relative;
        outline: none;
        border: none;
        resize: none;
        background: inherit;
        color: inherit;
        /* see comments in template */
        width: 100%;
        height: 100%;
        font-size: inherit;
        font-family: inherit;
        line-height: inherit;
        text-align: inherit;
        @apply --iron-autogrow-textarea;
      }

      textarea::-webkit-input-placeholder {
        @apply --iron-autogrow-textarea-placeholder;
      }

      textarea:-moz-placeholder {
        @apply --iron-autogrow-textarea-placeholder;
      }

      textarea::-moz-placeholder {
        @apply --iron-autogrow-textarea-placeholder;
      }

      textarea:-ms-input-placeholder {
        @apply --iron-autogrow-textarea-placeholder;
      }
    </style>

    <!-- the mirror sizes the input/textarea so it grows with typing -->
    <!-- use &#160; instead &nbsp; of to allow this element to be used in XHTML -->
    <div id="mirror" class="mirror-text" aria-hidden="true">&nbsp;</div>

    <!-- size the input/textarea with a div, because the textarea has intrinsic size in ff -->
    <div class="textarea-container fit">
      <textarea id="textarea" name$="[[name]]" aria-label$="[[label]]" autocomplete$="[[autocomplete]]" autofocus$="[[autofocus]]" autocapitalize$="[[autocapitalize]]" inputmode$="[[inputmode]]" placeholder$="[[placeholder]]" readonly$="[[readonly]]" required$="[[required]]" disabled$="[[disabled]]" rows$="[[rows]]" minlength$="[[minlength]]" maxlength$="[[maxlength]]"></textarea>
    </div>
`,is:"iron-autogrow-textarea",behaviors:[IronValidatableBehavior,IronControlState],properties:{value:{observer:"_valueChanged",type:String,notify:!0},bindValue:{observer:"_bindValueChanged",type:String,notify:!0},rows:{type:Number,value:1,observer:"_updateCached"},maxRows:{type:Number,value:0,observer:"_updateCached"},autocomplete:{type:String,value:"off"},autofocus:{type:Boolean,value:!1},autocapitalize:{type:String,value:"none"},inputmode:{type:String},placeholder:{type:String},readonly:{type:String},required:{type:Boolean},minlength:{type:Number},maxlength:{type:Number},label:{type:String}},listeners:{input:"_onInput"},get textarea(){return this.$.textarea},get selectionStart(){return this.$.textarea.selectionStart},get selectionEnd(){return this.$.textarea.selectionEnd},set selectionStart(e){this.$.textarea.selectionStart=e},set selectionEnd(e){this.$.textarea.selectionEnd=e},attached:function(){navigator.userAgent.match(/iP(?:[oa]d|hone)/)&&!navigator.userAgent.match(/OS 1[3456789]/)&&(this.$.textarea.style.marginLeft="-3px")},validate:function(){var e=this.$.textarea.validity.valid;return e&&(this.required&&""===this.value?e=!1:this.hasValidator()&&(e=IronValidatableBehavior.validate.call(this,this.value))),this.invalid=!e,this.fire("iron-input-validate"),e},_bindValueChanged:function(e){this.value=e},_valueChanged:function(e){var t=this.textarea;t&&(t.value!==e&&(t.value=e||0===e?e:""),this.bindValue=e,this.$.mirror.innerHTML=this._valueForMirror(),this.fire("bind-value-changed",{value:this.bindValue}))},_onInput:function(e){var t=dom$1(e).path;this.value=t?t[0].value:e.target.value},_constrain:function(e){var t;for(e=e||[""],t=this.maxRows>0&&e.length>this.maxRows?e.slice(0,this.maxRows):e.slice(0);this.rows>0&&t.length<this.rows;)t.push("");return t.join("<br/>")+"&#160;"},_valueForMirror:function(){var e=this.textarea;if(e)return this.tokens=e&&e.value?e.value.replace(/&/gm,"&amp;").replace(/"/gm,"&quot;").replace(/'/gm,"&#39;").replace(/</gm,"&lt;").replace(/>/gm,"&gt;").split("\n"):[""],this._constrain(this.tokens)},_updateCached:function(){this.$.mirror.innerHTML=this._constrain(this.tokens)}}),
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */
Polymer({_template:html`
    <style>
      :host {
        display: block;
      }

      :host([hidden]) {
        display: none !important;
      }

      label {
        pointer-events: none;
      }
    </style>

    <paper-input-container no-label-float$="[[noLabelFloat]]" always-float-label="[[_computeAlwaysFloatLabel(alwaysFloatLabel,placeholder)]]" auto-validate$="[[autoValidate]]" disabled$="[[disabled]]" invalid="[[invalid]]">

      <label hidden$="[[!label]]" aria-hidden="true" for$="[[_inputId]]" slot="label">[[label]]</label>

      <iron-autogrow-textarea class="paper-input-input" slot="input" id$="[[_inputId]]" aria-labelledby$="[[_ariaLabelledBy]]" aria-describedby$="[[_ariaDescribedBy]]" bind-value="{{value}}" invalid="{{invalid}}" validator$="[[validator]]" disabled$="[[disabled]]" autocomplete$="[[autocomplete]]" autofocus$="[[autofocus]]" inputmode$="[[inputmode]]" name$="[[name]]" placeholder$="[[placeholder]]" readonly$="[[readonly]]" required$="[[required]]" minlength$="[[minlength]]" maxlength$="[[maxlength]]" autocapitalize$="[[autocapitalize]]" rows$="[[rows]]" max-rows$="[[maxRows]]" on-change="_onChange"></iron-autogrow-textarea>

      <template is="dom-if" if="[[errorMessage]]">
        <paper-input-error aria-live="assertive" slot="add-on">[[errorMessage]]</paper-input-error>
      </template>

      <template is="dom-if" if="[[charCounter]]">
        <paper-input-char-counter slot="add-on"></paper-input-char-counter>
      </template>

    </paper-input-container>
`,is:"paper-textarea",behaviors:[PaperInputBehavior,IronFormElementBehavior],properties:{_ariaLabelledBy:{observer:"_ariaLabelledByChanged",type:String},_ariaDescribedBy:{observer:"_ariaDescribedByChanged",type:String},value:{type:String},rows:{type:Number,value:1},maxRows:{type:Number,value:0}},get selectionStart(){return this.$.input.textarea.selectionStart},set selectionStart(e){this.$.input.textarea.selectionStart=e},get selectionEnd(){return this.$.input.textarea.selectionEnd},set selectionEnd(e){this.$.input.textarea.selectionEnd=e},_ariaLabelledByChanged:function(e){this._focusableElement.setAttribute("aria-labelledby",e)},_ariaDescribedByChanged:function(e){this._focusableElement.setAttribute("aria-describedby",e)},get _focusableElement(){return this.inputElement.textarea}});
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */
const $_documentContainer$1=document.createElement("template");$_documentContainer$1.setAttribute("style","display: none;"),$_documentContainer$1.innerHTML="<dom-module id=\"paper-item-shared-styles\">\n  <template>\n    <style>\n      :host, .paper-item {\n        display: block;\n        position: relative;\n        min-height: var(--paper-item-min-height, 48px);\n        padding: 0px 16px;\n      }\n\n      .paper-item {\n        @apply --paper-font-subhead;\n        border:none;\n        outline: none;\n        background: white;\n        width: 100%;\n        text-align: left;\n      }\n\n      :host([hidden]), .paper-item[hidden] {\n        display: none !important;\n      }\n\n      :host(.iron-selected), .paper-item.iron-selected {\n        font-weight: var(--paper-item-selected-weight, bold);\n\n        @apply --paper-item-selected;\n      }\n\n      :host([disabled]), .paper-item[disabled] {\n        color: var(--paper-item-disabled-color, var(--disabled-text-color));\n\n        @apply --paper-item-disabled;\n      }\n\n      :host(:focus), .paper-item:focus {\n        position: relative;\n        outline: 0;\n\n        @apply --paper-item-focused;\n      }\n\n      :host(:focus):before, .paper-item:focus:before {\n        @apply --layout-fit;\n\n        background: currentColor;\n        content: '';\n        opacity: var(--dark-divider-opacity);\n        pointer-events: none;\n\n        @apply --paper-item-focused-before;\n      }\n    </style>\n  </template>\n</dom-module>",document.head.appendChild($_documentContainer$1.content);
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */
const PaperItemBehaviorImpl={hostAttributes:{role:"option",tabindex:"0"}},PaperItemBehavior=[IronButtonState,IronControlState,PaperItemBehaviorImpl];
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */
Polymer({_template:html`
    <style include="paper-item-shared-styles">
      :host {
        @apply --layout-horizontal;
        @apply --layout-center;
        @apply --paper-font-subhead;

        @apply --paper-item;
      }
    </style>
    <slot></slot>
`,is:"paper-item",behaviors:[PaperItemBehavior]}),
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */
Polymer({_template:html`
    <style>
      :host {
        overflow: hidden; /* needed for text-overflow: ellipsis to work on ff */
        @apply --layout-vertical;
        @apply --layout-center-justified;
        @apply --layout-flex;
      }

      :host([two-line]) {
        min-height: var(--paper-item-body-two-line-min-height, 72px);
      }

      :host([three-line]) {
        min-height: var(--paper-item-body-three-line-min-height, 88px);
      }

      :host > ::slotted(*) {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }

      :host > ::slotted([secondary]) {
        @apply --paper-font-body1;

        color: var(--paper-item-body-secondary-color, var(--secondary-text-color));

        @apply --paper-item-body-secondary;
      }
    </style>

    <slot></slot>
`,is:"paper-item-body"}),
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */
Polymer({_template:html`
    <style include="paper-item-shared-styles"></style>
    <style>
      :host {
        @apply --layout-horizontal;
        @apply --layout-center;
        @apply --paper-font-subhead;

        @apply --paper-item;
        @apply --paper-icon-item;
      }

      .content-icon {
        @apply --layout-horizontal;
        @apply --layout-center;

        width: var(--paper-item-icon-width, 56px);
        @apply --paper-item-icon;
      }
    </style>

    <div id="contentIcon" class="content-icon">
      <slot name="item-icon"></slot>
    </div>
    <slot></slot>
`,is:"paper-icon-item",behaviors:[PaperItemBehavior]});
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */
const IronMultiSelectableBehaviorImpl={properties:{multi:{type:Boolean,value:!1,observer:"multiChanged"},selectedValues:{type:Array,notify:!0,value:function(){return[]}},selectedItems:{type:Array,readOnly:!0,notify:!0,value:function(){return[]}}},observers:["_updateSelected(selectedValues.splices)"],select:function(e){this.multi?this._toggleSelected(e):this.selected=e},multiChanged:function(e){this._selection.multi=e,this._updateSelected()},get _shouldUpdateSelection(){return null!=this.selected||null!=this.selectedValues&&this.selectedValues.length},_updateAttrForSelected:function(){this.multi?this.selectedItems&&this.selectedItems.length>0&&(this.selectedValues=this.selectedItems.map((function(e){return this._indexToValue(this.indexOf(e))}),this).filter((function(e){return null!=e}),this)):IronSelectableBehavior._updateAttrForSelected.apply(this)},_updateSelected:function(){this.multi?this._selectMulti(this.selectedValues):this._selectSelected(this.selected)},_selectMulti:function(e){var t=(this._valuesToItems(e=e||[])||[]).filter((function(e){return null!=e}));this._selection.clear(t);for(var n=0;n<t.length;n++)this._selection.setItemSelected(t[n],!0);this.fallbackSelection&&!this._selection.get().length&&(this._valueToItem(this.fallbackSelection)&&this.select(this.fallbackSelection))},_selectionChange:function(){var e=this._selection.get();this.multi?(this._setSelectedItems(e),this._setSelectedItem(e.length?e[0]:null)):null!=e?(this._setSelectedItems([e]),this._setSelectedItem(e)):(this._setSelectedItems([]),this._setSelectedItem(null))},_toggleSelected:function(e){var t=this.selectedValues.indexOf(e);t<0?this.push("selectedValues",e):this.splice("selectedValues",t,1)},_valuesToItems:function(e){return null==e?null:e.map((function(e){return this._valueToItem(e)}),this)}},IronMultiSelectableBehavior=[IronSelectableBehavior,IronMultiSelectableBehaviorImpl],IronMenuBehaviorImpl={properties:{focusedItem:{observer:"_focusedItemChanged",readOnly:!0,type:Object},attrForItemTitle:{type:String},disabled:{type:Boolean,value:!1,observer:"_disabledChanged"}},_MODIFIER_KEYS:["Alt","AltGraph","CapsLock","Control","Fn","FnLock","Hyper","Meta","NumLock","OS","ScrollLock","Shift","Super","Symbol","SymbolLock"],_SEARCH_RESET_TIMEOUT_MS:1e3,_previousTabIndex:0,hostAttributes:{role:"menu"},observers:["_updateMultiselectable(multi)"],listeners:{focus:"_onFocus",keydown:"_onKeydown","iron-items-changed":"_onIronItemsChanged"},keyBindings:{up:"_onUpKey",down:"_onDownKey",esc:"_onEscKey","shift+tab:keydown":"_onShiftTabDown"},attached:function(){this._resetTabindices()},select:function(e){this._defaultFocusAsync&&(this.cancelAsync(this._defaultFocusAsync),this._defaultFocusAsync=null);var t=this._valueToItem(e);t&&t.hasAttribute("disabled")||(this._setFocusedItem(t),IronMultiSelectableBehaviorImpl.select.apply(this,arguments))},_resetTabindices:function(){var e=this.multi?this.selectedItems&&this.selectedItems[0]:this.selectedItem;this.items.forEach((function(t){t.setAttribute("tabindex",t===e?"0":"-1"),t.setAttribute("aria-selected",this._selection.isSelected(t))}),this)},_updateMultiselectable:function(e){e?this.setAttribute("aria-multiselectable","true"):this.removeAttribute("aria-multiselectable")},_focusWithKeyboardEvent:function(e){if(-1===this._MODIFIER_KEYS.indexOf(e.key)){this.cancelDebouncer("_clearSearchText");for(var t,n=this._searchText||"",r=(n+=(e.key&&1==e.key.length?e.key:String.fromCharCode(e.keyCode)).toLocaleLowerCase()).length,i=0;t=this.items[i];i++)if(!t.hasAttribute("disabled")){var a=this.attrForItemTitle||"textContent",o=(t[a]||t.getAttribute(a)||"").trim();if(!(o.length<r)&&o.slice(0,r).toLocaleLowerCase()==n){this._setFocusedItem(t);break}}this._searchText=n,this.debounce("_clearSearchText",this._clearSearchText,this._SEARCH_RESET_TIMEOUT_MS)}},_clearSearchText:function(){this._searchText=""},_focusPrevious:function(){for(var e=this.items.length,t=Number(this.indexOf(this.focusedItem)),n=1;n<e+1;n++){var r=this.items[(t-n+e)%e];if(!r.hasAttribute("disabled")){var i=dom$1(r).getOwnerRoot()||document;if(this._setFocusedItem(r),dom$1(i).activeElement==r)return}}},_focusNext:function(){for(var e=this.items.length,t=Number(this.indexOf(this.focusedItem)),n=1;n<e+1;n++){var r=this.items[(t+n)%e];if(!r.hasAttribute("disabled")){var i=dom$1(r).getOwnerRoot()||document;if(this._setFocusedItem(r),dom$1(i).activeElement==r)return}}},_applySelection:function(e,t){e.setAttribute("aria-selected",t?"true":"false"),IronSelectableBehavior._applySelection.apply(this,arguments)},_focusedItemChanged:function(e,t){t&&t.setAttribute("tabindex","-1"),!e||e.hasAttribute("disabled")||this.disabled||(e.setAttribute("tabindex","0"),e.focus())},_onIronItemsChanged:function(e){e.detail.addedNodes.length&&this._resetTabindices()},_onShiftTabDown:function(e){var t=this.getAttribute("tabindex");IronMenuBehaviorImpl._shiftTabPressed=!0,this._setFocusedItem(null),this.setAttribute("tabindex","-1"),this.async((function(){this.setAttribute("tabindex",t),IronMenuBehaviorImpl._shiftTabPressed=!1}),1)},_onFocus:function(e){if(!IronMenuBehaviorImpl._shiftTabPressed){var t=dom$1(e).rootTarget;(t===this||void 0===t.tabIndex||this.isLightDescendant(t))&&(this._defaultFocusAsync=this.async((function(){var e=this.multi?this.selectedItems&&this.selectedItems[0]:this.selectedItem;this._setFocusedItem(null),e?this._setFocusedItem(e):this.items[0]&&this._focusNext()})))}},_onUpKey:function(e){this._focusPrevious(),e.detail.keyboardEvent.preventDefault()},_onDownKey:function(e){this._focusNext(),e.detail.keyboardEvent.preventDefault()},_onEscKey:function(e){var t=this.focusedItem;t&&t.blur()},_onKeydown:function(e){this.keyboardEventMatchesKeys(e,"up down esc")||this._focusWithKeyboardEvent(e),e.stopPropagation()},_activateHandler:function(e){IronSelectableBehavior._activateHandler.call(this,e),e.stopPropagation()},_disabledChanged:function(e){e?(this._previousTabIndex=this.hasAttribute("tabindex")?this.tabIndex:0,this.removeAttribute("tabindex")):this.hasAttribute("tabindex")||this.setAttribute("tabindex",this._previousTabIndex)},_shiftTabPressed:!1},IronMenuBehavior=[IronMultiSelectableBehavior,IronA11yKeysBehavior,IronMenuBehaviorImpl];
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */
Polymer({_template:html`
    <style>
      :host {
        display: block;
        padding: 8px 0;

        background: var(--paper-listbox-background-color, var(--primary-background-color));
        color: var(--paper-listbox-color, var(--primary-text-color));

        @apply --paper-listbox;
      }
    </style>

    <slot></slot>
`,is:"paper-listbox",behaviors:[IronMenuBehavior],hostAttributes:{role:"listbox"}});
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */
const template$b=html`
<dom-module id="paper-material-shared-styles">
  <template>
    <style>
      :host {
        display: block;
        position: relative;
      }

      :host([elevation="1"]) {
        @apply --shadow-elevation-2dp;
      }

      :host([elevation="2"]) {
        @apply --shadow-elevation-4dp;
      }

      :host([elevation="3"]) {
        @apply --shadow-elevation-6dp;
      }

      :host([elevation="4"]) {
        @apply --shadow-elevation-8dp;
      }

      :host([elevation="5"]) {
        @apply --shadow-elevation-16dp;
      }
    </style>
  </template>
</dom-module>
`;template$b.setAttribute("style","display: none;"),document.body.appendChild(template$b.content),
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */
Polymer({_template:html`
    <style include="paper-material-shared-styles"></style>
    <style>
      :host([animated]) {
        @apply --shadow-transition;
      }
      :host {
        @apply --paper-material;
      }
    </style>

    <slot></slot>
`,is:"paper-material",properties:{elevation:{type:Number,reflectToAttribute:!0,value:1},animated:{type:Boolean,reflectToAttribute:!0,value:!1}}});
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */
const IronRangeBehavior={properties:{value:{type:Number,value:0,notify:!0,reflectToAttribute:!0},min:{type:Number,value:0,notify:!0},max:{type:Number,value:100,notify:!0},step:{type:Number,value:1,notify:!0},ratio:{type:Number,value:0,readOnly:!0,notify:!0}},observers:["_update(value, min, max, step)"],_calcRatio:function(e){return(this._clampValue(e)-this.min)/(this.max-this.min)},_clampValue:function(e){return Math.min(this.max,Math.max(this.min,this._calcStep(e)))},_calcStep:function(e){if(e=parseFloat(e),!this.step)return e;var t=Math.round((e-this.min)/this.step);return this.step<1?t/(1/this.step)+this.min:t*this.step+this.min},_validateValue:function(){var e=this._clampValue(this.value);return this.value=this.oldValue=isNaN(e)?this.oldValue:e,this.value!==e},_update:function(){this._validateValue(),this._setRatio(100*this._calcRatio(this.value))}};
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */Polymer({_template:html`
    <style>
      :host {
        display: block;
        width: 200px;
        position: relative;
        overflow: hidden;
      }

      :host([hidden]), [hidden] {
        display: none !important;
      }

      #progressContainer {
        @apply --paper-progress-container;
        position: relative;
      }

      #progressContainer,
      /* the stripe for the indeterminate animation*/
      .indeterminate::after {
        height: var(--paper-progress-height, 4px);
      }

      #primaryProgress,
      #secondaryProgress,
      .indeterminate::after {
        @apply --layout-fit;
      }

      #progressContainer,
      .indeterminate::after {
        background: var(--paper-progress-container-color, var(--google-grey-300));
      }

      :host(.transiting) #primaryProgress,
      :host(.transiting) #secondaryProgress {
        -webkit-transition-property: -webkit-transform;
        transition-property: transform;

        /* Duration */
        -webkit-transition-duration: var(--paper-progress-transition-duration, 0.08s);
        transition-duration: var(--paper-progress-transition-duration, 0.08s);

        /* Timing function */
        -webkit-transition-timing-function: var(--paper-progress-transition-timing-function, ease);
        transition-timing-function: var(--paper-progress-transition-timing-function, ease);

        /* Delay */
        -webkit-transition-delay: var(--paper-progress-transition-delay, 0s);
        transition-delay: var(--paper-progress-transition-delay, 0s);
      }

      #primaryProgress,
      #secondaryProgress {
        @apply --layout-fit;
        -webkit-transform-origin: left center;
        transform-origin: left center;
        -webkit-transform: scaleX(0);
        transform: scaleX(0);
        will-change: transform;
      }

      #primaryProgress {
        background: var(--paper-progress-active-color, var(--google-green-500));
      }

      #secondaryProgress {
        background: var(--paper-progress-secondary-color, var(--google-green-100));
      }

      :host([disabled]) #primaryProgress {
        background: var(--paper-progress-disabled-active-color, var(--google-grey-500));
      }

      :host([disabled]) #secondaryProgress {
        background: var(--paper-progress-disabled-secondary-color, var(--google-grey-300));
      }

      :host(:not([disabled])) #primaryProgress.indeterminate {
        -webkit-transform-origin: right center;
        transform-origin: right center;
        -webkit-animation: indeterminate-bar var(--paper-progress-indeterminate-cycle-duration, 2s) linear infinite;
        animation: indeterminate-bar var(--paper-progress-indeterminate-cycle-duration, 2s) linear infinite;
      }

      :host(:not([disabled])) #primaryProgress.indeterminate::after {
        content: "";
        -webkit-transform-origin: center center;
        transform-origin: center center;

        -webkit-animation: indeterminate-splitter var(--paper-progress-indeterminate-cycle-duration, 2s) linear infinite;
        animation: indeterminate-splitter var(--paper-progress-indeterminate-cycle-duration, 2s) linear infinite;
      }

      @-webkit-keyframes indeterminate-bar {
        0% {
          -webkit-transform: scaleX(1) translateX(-100%);
        }
        50% {
          -webkit-transform: scaleX(1) translateX(0%);
        }
        75% {
          -webkit-transform: scaleX(1) translateX(0%);
          -webkit-animation-timing-function: cubic-bezier(.28,.62,.37,.91);
        }
        100% {
          -webkit-transform: scaleX(0) translateX(0%);
        }
      }

      @-webkit-keyframes indeterminate-splitter {
        0% {
          -webkit-transform: scaleX(.75) translateX(-125%);
        }
        30% {
          -webkit-transform: scaleX(.75) translateX(-125%);
          -webkit-animation-timing-function: cubic-bezier(.42,0,.6,.8);
        }
        90% {
          -webkit-transform: scaleX(.75) translateX(125%);
        }
        100% {
          -webkit-transform: scaleX(.75) translateX(125%);
        }
      }

      @keyframes indeterminate-bar {
        0% {
          transform: scaleX(1) translateX(-100%);
        }
        50% {
          transform: scaleX(1) translateX(0%);
        }
        75% {
          transform: scaleX(1) translateX(0%);
          animation-timing-function: cubic-bezier(.28,.62,.37,.91);
        }
        100% {
          transform: scaleX(0) translateX(0%);
        }
      }

      @keyframes indeterminate-splitter {
        0% {
          transform: scaleX(.75) translateX(-125%);
        }
        30% {
          transform: scaleX(.75) translateX(-125%);
          animation-timing-function: cubic-bezier(.42,0,.6,.8);
        }
        90% {
          transform: scaleX(.75) translateX(125%);
        }
        100% {
          transform: scaleX(.75) translateX(125%);
        }
      }
    </style>

    <div id="progressContainer">
      <div id="secondaryProgress" hidden\$="[[_hideSecondaryProgress(secondaryRatio)]]"></div>
      <div id="primaryProgress"></div>
    </div>
`,is:"paper-progress",behaviors:[IronRangeBehavior],properties:{secondaryProgress:{type:Number,value:0},secondaryRatio:{type:Number,value:0,readOnly:!0},indeterminate:{type:Boolean,value:!1,observer:"_toggleIndeterminate"},disabled:{type:Boolean,value:!1,reflectToAttribute:!0,observer:"_disabledChanged"}},observers:["_progressChanged(secondaryProgress, value, min, max, indeterminate)"],hostAttributes:{role:"progressbar"},_toggleIndeterminate:function(e){this.toggleClass("indeterminate",e,this.$.primaryProgress)},_transformProgress:function(e,t){e.style.transform=e.style.webkitTransform="scaleX("+t/100+")"},_mainRatioChanged:function(e){this._transformProgress(this.$.primaryProgress,e)},_progressChanged:function(e,t,n,r,i){e=this._clampValue(e),t=this._clampValue(t);var a=100*this._calcRatio(e),o=100*this._calcRatio(t);this._setSecondaryRatio(a),this._transformProgress(this.$.secondaryProgress,a),this._transformProgress(this.$.primaryProgress,o),this.secondaryProgress=e,i?this.removeAttribute("aria-valuenow"):this.setAttribute("aria-valuenow",t),this.setAttribute("aria-valuemin",n),this.setAttribute("aria-valuemax",r)},_disabledChanged:function(e){this.setAttribute("aria-disabled",e?"true":"false")},_hideSecondaryProgress:function(e){return 0===e}});
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
    The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
    The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
    Code distributed by Google as part of the polymer project is also
    subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
    */
const template$a=html`
<style>
  :host {
    display: inline-block;
    line-height: 0;
    white-space: nowrap;
    cursor: pointer;
    @apply --paper-font-common-base;
    --calculated-paper-radio-button-size: var(--paper-radio-button-size, 16px);
    /* -1px is a sentinel for the default and is replace in \`attached\`. */
    --calculated-paper-radio-button-ink-size: var(--paper-radio-button-ink-size, -1px);
  }

  :host(:focus) {
    outline: none;
  }

  #radioContainer {
    @apply --layout-inline;
    @apply --layout-center-center;
    position: relative;
    width: var(--calculated-paper-radio-button-size);
    height: var(--calculated-paper-radio-button-size);
    vertical-align: middle;

    @apply --paper-radio-button-radio-container;
  }

  #ink {
    position: absolute;
    top: 50%;
    left: 50%;
    right: auto;
    width: var(--calculated-paper-radio-button-ink-size);
    height: var(--calculated-paper-radio-button-ink-size);
    color: var(--paper-radio-button-unchecked-ink-color, var(--primary-text-color));
    opacity: 0.6;
    pointer-events: none;
    -webkit-transform: translate(-50%, -50%);
    transform: translate(-50%, -50%);
  }

  #ink[checked] {
    color: var(--paper-radio-button-checked-ink-color, var(--primary-color));
  }

  #offRadio, #onRadio {
    position: absolute;
    box-sizing: border-box;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
  }

  #offRadio {
    border: 2px solid var(--paper-radio-button-unchecked-color, var(--primary-text-color));
    background-color: var(--paper-radio-button-unchecked-background-color, transparent);
    transition: border-color 0.28s;
  }

  #onRadio {
    background-color: var(--paper-radio-button-checked-color, var(--primary-color));
    -webkit-transform: scale(0);
    transform: scale(0);
    transition: -webkit-transform ease 0.28s;
    transition: transform ease 0.28s;
    will-change: transform;
  }

  :host([checked]) #offRadio {
    border-color: var(--paper-radio-button-checked-color, var(--primary-color));
  }

  :host([checked]) #onRadio {
    -webkit-transform: scale(0.5);
    transform: scale(0.5);
  }

  #radioLabel {
    line-height: normal;
    position: relative;
    display: inline-block;
    vertical-align: middle;
    margin-left: var(--paper-radio-button-label-spacing, 10px);
    white-space: normal;
    color: var(--paper-radio-button-label-color, var(--primary-text-color));

    @apply --paper-radio-button-label;
  }

  :host([checked]) #radioLabel {
    @apply --paper-radio-button-label-checked;
  }

  #radioLabel:dir(rtl) {
    margin-left: 0;
    margin-right: var(--paper-radio-button-label-spacing, 10px);
  }

  #radioLabel[hidden] {
    display: none;
  }

  /* disabled state */

  :host([disabled]) #offRadio {
    border-color: var(--paper-radio-button-unchecked-color, var(--primary-text-color));
    opacity: 0.5;
  }

  :host([disabled][checked]) #onRadio {
    background-color: var(--paper-radio-button-unchecked-color, var(--primary-text-color));
    opacity: 0.5;
  }

  :host([disabled]) #radioLabel {
    /* slightly darker than the button, so that it's readable */
    opacity: 0.65;
  }
</style>

<div id="radioContainer">
  <div id="offRadio"></div>
  <div id="onRadio"></div>
</div>

<div id="radioLabel"><slot></slot></div>`;template$a.setAttribute("strip-whitespace",""),Polymer({_template:template$a,is:"paper-radio-button",behaviors:[PaperCheckedElementBehavior],hostAttributes:{role:"radio","aria-checked":!1,tabindex:0},properties:{ariaActiveAttribute:{type:String,value:"aria-checked"}},ready:function(){this._rippleContainer=this.$.radioContainer},attached:function(){afterNextRender(this,(function(){if("-1px"===this.getComputedStyleValue("--calculated-paper-radio-button-ink-size").trim()){var e=parseFloat(this.getComputedStyleValue("--calculated-paper-radio-button-size").trim()),t=Math.floor(3*e);t%2!=e%2&&t++,this.updateStyles({"--paper-radio-button-ink-size":t+"px"})}}))}});
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */
const IronMenubarBehaviorImpl={hostAttributes:{role:"menubar"},keyBindings:{left:"_onLeftKey",right:"_onRightKey"},_onUpKey:function(e){this.focusedItem.click(),e.detail.keyboardEvent.preventDefault()},_onDownKey:function(e){this.focusedItem.click(),e.detail.keyboardEvent.preventDefault()},get _isRTL(){return"rtl"===window.getComputedStyle(this).direction},_onLeftKey:function(e){this._isRTL?this._focusNext():this._focusPrevious(),e.detail.keyboardEvent.preventDefault()},_onRightKey:function(e){this._isRTL?this._focusPrevious():this._focusNext(),e.detail.keyboardEvent.preventDefault()},_onKeydown:function(e){this.keyboardEventMatchesKeys(e,"up down left right esc")||this._focusWithKeyboardEvent(e)}},IronMenubarBehavior=[IronMenuBehavior,IronMenubarBehaviorImpl];
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */
Polymer({_template:html`
    <style>
      :host {
        display: inline-block;
      }

      :host ::slotted(*) {
        padding: var(--paper-radio-group-item-padding, 12px);
      }
    </style>

    <slot></slot>
`,is:"paper-radio-group",behaviors:[IronMenubarBehavior],hostAttributes:{role:"radiogroup"},properties:{attrForSelected:{type:String,value:"name"},selectedAttribute:{type:String,value:"checked"},selectable:{type:String,value:"paper-radio-button"},allowEmptySelection:{type:Boolean,value:!1}},select:function(e){var t=this._valueToItem(e);if(!t||!t.hasAttribute("disabled")){if(this.selected){var n=this._valueToItem(this.selected);if(this.selected==e){if(!this.allowEmptySelection)return void(n&&(n.checked=!0));e=""}n&&(n.checked=!1)}IronSelectableBehavior.select.apply(this,[e]),this.fire("paper-radio-group-changed")}},_activateFocusedItem:function(){this._itemActivate(this._valueForItem(this.focusedItem),this.focusedItem)},_onUpKey:function(e){this._focusPrevious(),e.preventDefault(),this._activateFocusedItem()},_onDownKey:function(e){this._focusNext(),e.preventDefault(),this._activateFocusedItem()},_onLeftKey:function(e){IronMenubarBehaviorImpl._onLeftKey.apply(this,arguments),this._activateFocusedItem()},_onRightKey:function(e){IronMenubarBehaviorImpl._onRightKey.apply(this,arguments),this._activateFocusedItem()}});
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */
const template$9=html`
  <style>
    :host {
      @apply --layout;
      @apply --layout-justified;
      @apply --layout-center;
      width: 200px;
      cursor: default;
      -webkit-user-select: none;
      -moz-user-select: none;
      -ms-user-select: none;
      user-select: none;
      -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
      --paper-progress-active-color: var(--paper-slider-active-color, var(--google-blue-700));
      --paper-progress-secondary-color: var(--paper-slider-secondary-color, var(--google-blue-300));
      --paper-progress-disabled-active-color: var(--paper-slider-disabled-active-color, var(--paper-grey-400));
      --paper-progress-disabled-secondary-color: var(--paper-slider-disabled-secondary-color, var(--paper-grey-400));
      --calculated-paper-slider-height: var(--paper-slider-height, 2px);
    }

    /* focus shows the ripple */
    :host(:focus) {
      outline: none;
    }

    /**
      * NOTE(keanulee): Though :host-context is not universally supported, some pages
      * still rely on paper-slider being flipped when dir="rtl" is set on body. For full
      * compatibility, dir="rtl" must be explicitly set on paper-slider.
      */
    :dir(rtl) #sliderContainer {
      -webkit-transform: scaleX(-1);
      transform: scaleX(-1);
    }

    /**
      * NOTE(keanulee): This is separate from the rule above because :host-context may
      * not be recognized.
      */
    :host([dir="rtl"]) #sliderContainer {
      -webkit-transform: scaleX(-1);
      transform: scaleX(-1);
    }

    /**
      * NOTE(keanulee): Needed to override the :host-context rule (where supported)
      * to support LTR sliders in RTL pages.
      */
    :host([dir="ltr"]) #sliderContainer {
      -webkit-transform: scaleX(1);
      transform: scaleX(1);
    }

    #sliderContainer {
      position: relative;
      width: 100%;
      height: calc(30px + var(--calculated-paper-slider-height));
      margin-left: calc(15px + var(--calculated-paper-slider-height)/2);
      margin-right: calc(15px + var(--calculated-paper-slider-height)/2);
    }

    #sliderContainer:focus {
      outline: 0;
    }

    #sliderContainer.editable {
      margin-top: 12px;
      margin-bottom: 12px;
    }

    .bar-container {
      position: absolute;
      top: 0;
      bottom: 0;
      left: 0;
      right: 0;
      overflow: hidden;
    }

    .ring > .bar-container {
      left: calc(5px + var(--calculated-paper-slider-height)/2);
      transition: left 0.18s ease;
    }

    .ring.expand.dragging > .bar-container {
      transition: none;
    }

    .ring.expand:not(.pin) > .bar-container {
      left: calc(8px + var(--calculated-paper-slider-height)/2);
    }

    #sliderBar {
      padding: 15px 0;
      width: 100%;
      background-color: var(--paper-slider-bar-color, transparent);
      --paper-progress-container-color: var(--paper-slider-container-color, var(--paper-grey-400));
      --paper-progress-height: var(--calculated-paper-slider-height);
    }

    .slider-markers {
      position: absolute;
      /* slider-knob is 30px + the slider-height so that the markers should start at a offset of 15px*/
      top: 15px;
      height: var(--calculated-paper-slider-height);
      left: 0;
      right: -1px;
      box-sizing: border-box;
      pointer-events: none;
      @apply --layout-horizontal;
    }

    .slider-marker {
      @apply --layout-flex;
    }
    .slider-markers::after,
    .slider-marker::after {
      content: "";
      display: block;
      margin-left: -1px;
      width: 2px;
      height: var(--calculated-paper-slider-height);
      border-radius: 50%;
      background-color: var(--paper-slider-markers-color, #000);
    }

    .slider-knob {
      position: absolute;
      left: 0;
      top: 0;
      margin-left: calc(-15px - var(--calculated-paper-slider-height)/2);
      width: calc(30px + var(--calculated-paper-slider-height));
      height: calc(30px + var(--calculated-paper-slider-height));
    }

    .transiting > .slider-knob {
      transition: left 0.08s ease;
    }

    .slider-knob:focus {
      outline: none;
    }

    .slider-knob.dragging {
      transition: none;
    }

    .snaps > .slider-knob.dragging {
      transition: -webkit-transform 0.08s ease;
      transition: transform 0.08s ease;
    }

    .slider-knob-inner {
      margin: 10px;
      width: calc(100% - 20px);
      height: calc(100% - 20px);
      background-color: var(--paper-slider-knob-color, var(--google-blue-700));
      border: 2px solid var(--paper-slider-knob-color, var(--google-blue-700));
      border-radius: 50%;

      -moz-box-sizing: border-box;
      box-sizing: border-box;

      transition-property: -webkit-transform, background-color, border;
      transition-property: transform, background-color, border;
      transition-duration: 0.18s;
      transition-timing-function: ease;
    }

    .expand:not(.pin) > .slider-knob > .slider-knob-inner {
      -webkit-transform: scale(1.5);
      transform: scale(1.5);
    }

    .ring > .slider-knob > .slider-knob-inner {
      background-color: var(--paper-slider-knob-start-color, transparent);
      border: 2px solid var(--paper-slider-knob-start-border-color, var(--paper-grey-400));
    }

    .slider-knob-inner::before {
      background-color: var(--paper-slider-pin-color, var(--google-blue-700));
    }

    .pin > .slider-knob > .slider-knob-inner::before {
      content: "";
      position: absolute;
      top: 0;
      left: 50%;
      margin-left: -13px;
      width: 26px;
      height: 26px;
      border-radius: 50% 50% 50% 0;

      -webkit-transform: rotate(-45deg) scale(0) translate(0);
      transform: rotate(-45deg) scale(0) translate(0);
    }

    .slider-knob-inner::before,
    .slider-knob-inner::after {
      transition: -webkit-transform .18s ease, background-color .18s ease;
      transition: transform .18s ease, background-color .18s ease;
    }

    .pin.ring > .slider-knob > .slider-knob-inner::before {
      background-color: var(--paper-slider-pin-start-color, var(--paper-grey-400));
    }

    .pin.expand > .slider-knob > .slider-knob-inner::before {
      -webkit-transform: rotate(-45deg) scale(1) translate(17px, -17px);
      transform: rotate(-45deg) scale(1) translate(17px, -17px);
    }

    .pin > .slider-knob > .slider-knob-inner::after {
      content: attr(value);
      position: absolute;
      top: 0;
      left: 50%;
      margin-left: -16px;
      width: 32px;
      height: 26px;
      text-align: center;
      color: var(--paper-slider-font-color, #fff);
      font-size: 10px;

      -webkit-transform: scale(0) translate(0);
      transform: scale(0) translate(0);
    }

    .pin.expand > .slider-knob > .slider-knob-inner::after {
      -webkit-transform: scale(1) translate(0, -17px);
      transform: scale(1) translate(0, -17px);
    }

    /* paper-input */
    .slider-input {
      width: 50px;
      overflow: hidden;
      --paper-input-container-input: {
        text-align: center;
        @apply --paper-slider-input-container-input;
      };
      @apply --paper-slider-input;
    }

    /* disabled state */
    #sliderContainer.disabled {
      pointer-events: none;
    }

    .disabled > .slider-knob > .slider-knob-inner {
      background-color: var(--paper-slider-disabled-knob-color, var(--paper-grey-400));
      border: 2px solid var(--paper-slider-disabled-knob-color, var(--paper-grey-400));
      -webkit-transform: scale3d(0.75, 0.75, 1);
      transform: scale3d(0.75, 0.75, 1);
    }

    .disabled.ring > .slider-knob > .slider-knob-inner {
      background-color: var(--paper-slider-knob-start-color, transparent);
      border: 2px solid var(--paper-slider-knob-start-border-color, var(--paper-grey-400));
    }

    paper-ripple {
      color: var(--paper-slider-knob-color, var(--google-blue-700));
    }
  </style>

  <div id="sliderContainer" class\$="[[_getClassNames(disabled, pin, snaps, immediateValue, min, expand, dragging, transiting, editable)]]">
    <div class="bar-container">
      <paper-progress disabled\$="[[disabled]]" id="sliderBar" aria-hidden="true" min="[[min]]" max="[[max]]" step="[[step]]" value="[[immediateValue]]" secondary-progress="[[secondaryProgress]]" on-down="_bardown" on-up="_resetKnob" on-track="_bartrack" on-tap="_barclick">
      </paper-progress>
    </div>

    <template is="dom-if" if="[[snaps]]">
      <div class="slider-markers">
        <template is="dom-repeat" items="[[markers]]">
          <div class="slider-marker"></div>
        </template>
      </div>
    </template>

    <div id="sliderKnob" class="slider-knob" on-down="_knobdown" on-up="_resetKnob" on-track="_onTrack" on-transitionend="_knobTransitionEnd">
        <div class="slider-knob-inner" value\$="[[immediateValue]]"></div>
    </div>
  </div>

  <template is="dom-if" if="[[editable]]">
    <paper-input id="input" type="number" step="[[step]]" min="[[min]]" max="[[max]]" class="slider-input" disabled\$="[[disabled]]" value="[[immediateValue]]" on-change="_changeValue" on-keydown="_inputKeyDown" no-label-float>
    </paper-input>
  </template>
`;template$9.setAttribute("strip-whitespace",""),Polymer({_template:template$9,is:"paper-slider",behaviors:[IronA11yKeysBehavior,IronFormElementBehavior,PaperInkyFocusBehavior,IronRangeBehavior],properties:{value:{type:Number,value:0},snaps:{type:Boolean,value:!1,notify:!0},pin:{type:Boolean,value:!1,notify:!0},secondaryProgress:{type:Number,value:0,notify:!0,observer:"_secondaryProgressChanged"},editable:{type:Boolean,value:!1},immediateValue:{type:Number,value:0,readOnly:!0,notify:!0},maxMarkers:{type:Number,value:0,notify:!0},expand:{type:Boolean,value:!1,readOnly:!0},ignoreBarTouch:{type:Boolean,value:!1},dragging:{type:Boolean,value:!1,readOnly:!0,notify:!0},transiting:{type:Boolean,value:!1,readOnly:!0},markers:{type:Array,readOnly:!0,value:function(){return[]}}},observers:["_updateKnob(value, min, max, snaps, step)","_valueChanged(value)","_immediateValueChanged(immediateValue)","_updateMarkers(maxMarkers, min, max, snaps)"],hostAttributes:{role:"slider",tabindex:0},keyBindings:{left:"_leftKey",right:"_rightKey","down pagedown home":"_decrementKey","up pageup end":"_incrementKey"},ready:function(){this.ignoreBarTouch&&setTouchAction(this.$.sliderBar,"auto")},increment:function(){this.value=this._clampValue(this.value+this.step)},decrement:function(){this.value=this._clampValue(this.value-this.step)},_updateKnob:function(e,t,n,r,i){this.setAttribute("aria-valuemin",t),this.setAttribute("aria-valuemax",n),this.setAttribute("aria-valuenow",e),this._positionKnob(100*this._calcRatio(e))},_valueChanged:function(){this.fire("value-change",{composed:!0})},_immediateValueChanged:function(){this.dragging?this.fire("immediate-value-change",{composed:!0}):this.value=this.immediateValue},_secondaryProgressChanged:function(){this.secondaryProgress=this._clampValue(this.secondaryProgress)},_expandKnob:function(){this._setExpand(!0)},_resetKnob:function(){this.cancelDebouncer("expandKnob"),this._setExpand(!1)},_positionKnob:function(e){this._setImmediateValue(this._calcStep(this._calcKnobPosition(e))),this._setRatio(100*this._calcRatio(this.immediateValue)),this.$.sliderKnob.style.left=this.ratio+"%",this.dragging&&(this._knobstartx=this.ratio*this._w/100,this.translate3d(0,0,0,this.$.sliderKnob))},_calcKnobPosition:function(e){return(this.max-this.min)*e/100+this.min},_onTrack:function(e){switch(e.stopPropagation(),e.detail.state){case"start":this._trackStart(e);break;case"track":this._trackX(e);break;case"end":this._trackEnd()}},_trackStart:function(e){this._setTransiting(!1),this._w=this.$.sliderBar.offsetWidth,this._x=this.ratio*this._w/100,this._startx=this._x,this._knobstartx=this._startx,this._minx=-this._startx,this._maxx=this._w-this._startx,this.$.sliderKnob.classList.add("dragging"),this._setDragging(!0)},_trackX:function(e){this.dragging||this._trackStart(e);var t=Math.min(this._maxx,Math.max(this._minx,e.detail.dx*(this._isRTL?-1:1)));this._x=this._startx+t;var n=this._calcStep(this._calcKnobPosition(this._x/this._w*100));this._setImmediateValue(n);var r=this._calcRatio(this.immediateValue)*this._w-this._knobstartx;this.translate3d(r+"px",0,0,this.$.sliderKnob)},_trackEnd:function(){var e=this.$.sliderKnob.style;this.$.sliderKnob.classList.remove("dragging"),this._setDragging(!1),this._resetKnob(),this.value=this.immediateValue,e.transform=e.webkitTransform="",this.fire("change",{composed:!0})},_knobdown:function(e){this._expandKnob(),e.preventDefault(),this.focus()},_bartrack:function(e){this._allowBarEvent(e)&&this._onTrack(e)},_barclick:function(e){this._w=this.$.sliderBar.offsetWidth;var t=this.$.sliderBar.getBoundingClientRect(),n=(e.detail.x-t.left)/this._w*100;this._isRTL&&(n=100-n);var r=this.ratio;this._setTransiting(!0),this._positionKnob(n),r===this.ratio&&this._setTransiting(!1),this.async((function(){this.fire("change",{composed:!0})})),e.preventDefault(),this.focus()},_bardown:function(e){this._allowBarEvent(e)&&(this.debounce("expandKnob",this._expandKnob,60),this._barclick(e))},_knobTransitionEnd:function(e){e.target===this.$.sliderKnob&&this._setTransiting(!1)},_updateMarkers:function(e,t,n,r){r||this._setMarkers([]);var i=Math.round((n-t)/this.step);i>e&&(i=e),(i<0||!isFinite(i))&&(i=0),this._setMarkers(new Array(i))},_mergeClasses:function(e){return Object.keys(e).filter((function(t){return e[t]})).join(" ")},_getClassNames:function(){return this._mergeClasses({disabled:this.disabled,pin:this.pin,snaps:this.snaps,ring:this.immediateValue<=this.min,expand:this.expand,dragging:this.dragging,transiting:this.transiting,editable:this.editable})},_allowBarEvent:function(e){return!this.ignoreBarTouch||e.detail.sourceEvent instanceof MouseEvent},get _isRTL(){return void 0===this.__isRTL&&(this.__isRTL="rtl"===window.getComputedStyle(this).direction),this.__isRTL},_leftKey:function(e){this._isRTL?this._incrementKey(e):this._decrementKey(e)},_rightKey:function(e){this._isRTL?this._decrementKey(e):this._incrementKey(e)},_incrementKey:function(e){this.disabled||("end"===e.detail.key?this.value=this.max:this.increment(),this.fire("change"),e.preventDefault())},_decrementKey:function(e){this.disabled||("home"===e.detail.key?this.value=this.min:this.decrement(),this.fire("change"),e.preventDefault())},_changeValue:function(e){this.value=e.target.value,this.fire("change",{composed:!0})},_inputKeyDown:function(e){e.stopPropagation()},_createRipple:function(){return this._rippleContainer=this.$.sliderKnob,PaperInkyFocusBehaviorImpl._createRipple.call(this)},_focusedChanged:function(e){e&&this.ensureRipple(),this.hasRipple()&&(this._ripple.style.display=e?"":"none",this._ripple.holdDown=e)}});
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */
const $_documentContainer=document.createElement("template");$_documentContainer.setAttribute("style","display: none;"),$_documentContainer.innerHTML="<dom-module id=\"paper-spinner-styles\">\n  <template>\n    <style>\n      /*\n      /**************************/\n      /* STYLES FOR THE SPINNER */\n      /**************************/\n\n      /*\n       * Constants:\n       *      ARCSIZE     = 270 degrees (amount of circle the arc takes up)\n       *      ARCTIME     = 1333ms (time it takes to expand and contract arc)\n       *      ARCSTARTROT = 216 degrees (how much the start location of the arc\n       *                                should rotate each time, 216 gives us a\n       *                                5 pointed star shape (it's 360/5 * 3).\n       *                                For a 7 pointed star, we might do\n       *                                360/7 * 3 = 154.286)\n       *      SHRINK_TIME = 400ms\n       */\n\n      :host {\n        display: inline-block;\n        position: relative;\n        width: 28px;\n        height: 28px;\n\n        /* 360 * ARCTIME / (ARCSTARTROT + (360-ARCSIZE)) */\n        --paper-spinner-container-rotation-duration: 1568ms;\n\n        /* ARCTIME */\n        --paper-spinner-expand-contract-duration: 1333ms;\n\n        /* 4 * ARCTIME */\n        --paper-spinner-full-cycle-duration: 5332ms;\n\n        /* SHRINK_TIME */\n        --paper-spinner-cooldown-duration: 400ms;\n      }\n\n      #spinnerContainer {\n        width: 100%;\n        height: 100%;\n\n        /* The spinner does not have any contents that would have to be\n         * flipped if the direction changes. Always use ltr so that the\n         * style works out correctly in both cases. */\n        direction: ltr;\n      }\n\n      #spinnerContainer.active {\n        -webkit-animation: container-rotate var(--paper-spinner-container-rotation-duration) linear infinite;\n        animation: container-rotate var(--paper-spinner-container-rotation-duration) linear infinite;\n      }\n\n      @-webkit-keyframes container-rotate {\n        to { -webkit-transform: rotate(360deg) }\n      }\n\n      @keyframes container-rotate {\n        to { transform: rotate(360deg) }\n      }\n\n      .spinner-layer {\n        position: absolute;\n        width: 100%;\n        height: 100%;\n        opacity: 0;\n        white-space: nowrap;\n        color: var(--paper-spinner-color, var(--google-blue-500));\n      }\n\n      .layer-1 {\n        color: var(--paper-spinner-layer-1-color, var(--google-blue-500));\n      }\n\n      .layer-2 {\n        color: var(--paper-spinner-layer-2-color, var(--google-red-500));\n      }\n\n      .layer-3 {\n        color: var(--paper-spinner-layer-3-color, var(--google-yellow-500));\n      }\n\n      .layer-4 {\n        color: var(--paper-spinner-layer-4-color, var(--google-green-500));\n      }\n\n      /**\n       * IMPORTANT NOTE ABOUT CSS ANIMATION PROPERTIES (keanulee):\n       *\n       * iOS Safari (tested on iOS 8.1) does not handle animation-delay very well - it doesn't\n       * guarantee that the animation will start _exactly_ after that value. So we avoid using\n       * animation-delay and instead set custom keyframes for each color (as layer-2undant as it\n       * seems).\n       */\n      .active .spinner-layer {\n        -webkit-animation-name: fill-unfill-rotate;\n        -webkit-animation-duration: var(--paper-spinner-full-cycle-duration);\n        -webkit-animation-timing-function: cubic-bezier(0.4, 0.0, 0.2, 1);\n        -webkit-animation-iteration-count: infinite;\n        animation-name: fill-unfill-rotate;\n        animation-duration: var(--paper-spinner-full-cycle-duration);\n        animation-timing-function: cubic-bezier(0.4, 0.0, 0.2, 1);\n        animation-iteration-count: infinite;\n        opacity: 1;\n      }\n\n      .active .spinner-layer.layer-1 {\n        -webkit-animation-name: fill-unfill-rotate, layer-1-fade-in-out;\n        animation-name: fill-unfill-rotate, layer-1-fade-in-out;\n      }\n\n      .active .spinner-layer.layer-2 {\n        -webkit-animation-name: fill-unfill-rotate, layer-2-fade-in-out;\n        animation-name: fill-unfill-rotate, layer-2-fade-in-out;\n      }\n\n      .active .spinner-layer.layer-3 {\n        -webkit-animation-name: fill-unfill-rotate, layer-3-fade-in-out;\n        animation-name: fill-unfill-rotate, layer-3-fade-in-out;\n      }\n\n      .active .spinner-layer.layer-4 {\n        -webkit-animation-name: fill-unfill-rotate, layer-4-fade-in-out;\n        animation-name: fill-unfill-rotate, layer-4-fade-in-out;\n      }\n\n      @-webkit-keyframes fill-unfill-rotate {\n        12.5% { -webkit-transform: rotate(135deg) } /* 0.5 * ARCSIZE */\n        25%   { -webkit-transform: rotate(270deg) } /* 1   * ARCSIZE */\n        37.5% { -webkit-transform: rotate(405deg) } /* 1.5 * ARCSIZE */\n        50%   { -webkit-transform: rotate(540deg) } /* 2   * ARCSIZE */\n        62.5% { -webkit-transform: rotate(675deg) } /* 2.5 * ARCSIZE */\n        75%   { -webkit-transform: rotate(810deg) } /* 3   * ARCSIZE */\n        87.5% { -webkit-transform: rotate(945deg) } /* 3.5 * ARCSIZE */\n        to    { -webkit-transform: rotate(1080deg) } /* 4   * ARCSIZE */\n      }\n\n      @keyframes fill-unfill-rotate {\n        12.5% { transform: rotate(135deg) } /* 0.5 * ARCSIZE */\n        25%   { transform: rotate(270deg) } /* 1   * ARCSIZE */\n        37.5% { transform: rotate(405deg) } /* 1.5 * ARCSIZE */\n        50%   { transform: rotate(540deg) } /* 2   * ARCSIZE */\n        62.5% { transform: rotate(675deg) } /* 2.5 * ARCSIZE */\n        75%   { transform: rotate(810deg) } /* 3   * ARCSIZE */\n        87.5% { transform: rotate(945deg) } /* 3.5 * ARCSIZE */\n        to    { transform: rotate(1080deg) } /* 4   * ARCSIZE */\n      }\n\n      @-webkit-keyframes layer-1-fade-in-out {\n        0% { opacity: 1 }\n        25% { opacity: 1 }\n        26% { opacity: 0 }\n        89% { opacity: 0 }\n        90% { opacity: 1 }\n        to { opacity: 1 }\n      }\n\n      @keyframes layer-1-fade-in-out {\n        0% { opacity: 1 }\n        25% { opacity: 1 }\n        26% { opacity: 0 }\n        89% { opacity: 0 }\n        90% { opacity: 1 }\n        to { opacity: 1 }\n      }\n\n      @-webkit-keyframes layer-2-fade-in-out {\n        0% { opacity: 0 }\n        15% { opacity: 0 }\n        25% { opacity: 1 }\n        50% { opacity: 1 }\n        51% { opacity: 0 }\n        to { opacity: 0 }\n      }\n\n      @keyframes layer-2-fade-in-out {\n        0% { opacity: 0 }\n        15% { opacity: 0 }\n        25% { opacity: 1 }\n        50% { opacity: 1 }\n        51% { opacity: 0 }\n        to { opacity: 0 }\n      }\n\n      @-webkit-keyframes layer-3-fade-in-out {\n        0% { opacity: 0 }\n        40% { opacity: 0 }\n        50% { opacity: 1 }\n        75% { opacity: 1 }\n        76% { opacity: 0 }\n        to { opacity: 0 }\n      }\n\n      @keyframes layer-3-fade-in-out {\n        0% { opacity: 0 }\n        40% { opacity: 0 }\n        50% { opacity: 1 }\n        75% { opacity: 1 }\n        76% { opacity: 0 }\n        to { opacity: 0 }\n      }\n\n      @-webkit-keyframes layer-4-fade-in-out {\n        0% { opacity: 0 }\n        65% { opacity: 0 }\n        75% { opacity: 1 }\n        90% { opacity: 1 }\n        to { opacity: 0 }\n      }\n\n      @keyframes layer-4-fade-in-out {\n        0% { opacity: 0 }\n        65% { opacity: 0 }\n        75% { opacity: 1 }\n        90% { opacity: 1 }\n        to { opacity: 0 }\n      }\n\n      .circle-clipper {\n        display: inline-block;\n        position: relative;\n        width: 50%;\n        height: 100%;\n        overflow: hidden;\n      }\n\n      /**\n       * Patch the gap that appear between the two adjacent div.circle-clipper while the\n       * spinner is rotating (appears on Chrome 50, Safari 9.1.1, and Edge).\n       */\n      .spinner-layer::after {\n        content: '';\n        left: 45%;\n        width: 10%;\n        border-top-style: solid;\n      }\n\n      .spinner-layer::after,\n      .circle-clipper .circle {\n        box-sizing: border-box;\n        position: absolute;\n        top: 0;\n        border-width: var(--paper-spinner-stroke-width, 3px);\n        border-radius: 50%;\n      }\n\n      .circle-clipper .circle {\n        bottom: 0;\n        width: 200%;\n        border-style: solid;\n        border-bottom-color: transparent !important;\n      }\n\n      .circle-clipper.left .circle {\n        left: 0;\n        border-right-color: transparent !important;\n        -webkit-transform: rotate(129deg);\n        transform: rotate(129deg);\n      }\n\n      .circle-clipper.right .circle {\n        left: -100%;\n        border-left-color: transparent !important;\n        -webkit-transform: rotate(-129deg);\n        transform: rotate(-129deg);\n      }\n\n      .active .gap-patch::after,\n      .active .circle-clipper .circle {\n        -webkit-animation-duration: var(--paper-spinner-expand-contract-duration);\n        -webkit-animation-timing-function: cubic-bezier(0.4, 0.0, 0.2, 1);\n        -webkit-animation-iteration-count: infinite;\n        animation-duration: var(--paper-spinner-expand-contract-duration);\n        animation-timing-function: cubic-bezier(0.4, 0.0, 0.2, 1);\n        animation-iteration-count: infinite;\n      }\n\n      .active .circle-clipper.left .circle {\n        -webkit-animation-name: left-spin;\n        animation-name: left-spin;\n      }\n\n      .active .circle-clipper.right .circle {\n        -webkit-animation-name: right-spin;\n        animation-name: right-spin;\n      }\n\n      @-webkit-keyframes left-spin {\n        0% { -webkit-transform: rotate(130deg) }\n        50% { -webkit-transform: rotate(-5deg) }\n        to { -webkit-transform: rotate(130deg) }\n      }\n\n      @keyframes left-spin {\n        0% { transform: rotate(130deg) }\n        50% { transform: rotate(-5deg) }\n        to { transform: rotate(130deg) }\n      }\n\n      @-webkit-keyframes right-spin {\n        0% { -webkit-transform: rotate(-130deg) }\n        50% { -webkit-transform: rotate(5deg) }\n        to { -webkit-transform: rotate(-130deg) }\n      }\n\n      @keyframes right-spin {\n        0% { transform: rotate(-130deg) }\n        50% { transform: rotate(5deg) }\n        to { transform: rotate(-130deg) }\n      }\n\n      #spinnerContainer.cooldown {\n        -webkit-animation: container-rotate var(--paper-spinner-container-rotation-duration) linear infinite, fade-out var(--paper-spinner-cooldown-duration) cubic-bezier(0.4, 0.0, 0.2, 1);\n        animation: container-rotate var(--paper-spinner-container-rotation-duration) linear infinite, fade-out var(--paper-spinner-cooldown-duration) cubic-bezier(0.4, 0.0, 0.2, 1);\n      }\n\n      @-webkit-keyframes fade-out {\n        0% { opacity: 1 }\n        to { opacity: 0 }\n      }\n\n      @keyframes fade-out {\n        0% { opacity: 1 }\n        to { opacity: 0 }\n      }\n    </style>\n  </template>\n</dom-module>",document.head.appendChild($_documentContainer.content);
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */
const PaperSpinnerBehavior={properties:{active:{type:Boolean,value:!1,reflectToAttribute:!0,observer:"__activeChanged"},alt:{type:String,value:"loading",observer:"__altChanged"},__coolingDown:{type:Boolean,value:!1}},__computeContainerClasses:function(e,t){return[e||t?"active":"",t?"cooldown":""].join(" ")},__activeChanged:function(e,t){this.__setAriaHidden(!e),this.__coolingDown=!e&&t},__altChanged:function(e){"loading"===e?this.alt=this.getAttribute("aria-label")||e:(this.__setAriaHidden(""===e),this.setAttribute("aria-label",e))},__setAriaHidden:function(e){var t="aria-hidden";e?this.setAttribute(t,"true"):this.removeAttribute(t)},__reset:function(){this.active=!1,this.__coolingDown=!1}},template$8=html`
  <style include="paper-spinner-styles"></style>

  <div id="spinnerContainer" class-name="[[__computeContainerClasses(active, __coolingDown)]]" on-animationend="__reset" on-webkit-animation-end="__reset">
    <div class="spinner-layer layer-1">
      <div class="circle-clipper left">
        <div class="circle"></div>
      </div>
      <div class="circle-clipper right">
        <div class="circle"></div>
      </div>
    </div>

    <div class="spinner-layer layer-2">
      <div class="circle-clipper left">
        <div class="circle"></div>
      </div>
      <div class="circle-clipper right">
        <div class="circle"></div>
      </div>
    </div>

    <div class="spinner-layer layer-3">
      <div class="circle-clipper left">
        <div class="circle"></div>
      </div>
      <div class="circle-clipper right">
        <div class="circle"></div>
      </div>
    </div>

    <div class="spinner-layer layer-4">
      <div class="circle-clipper left">
        <div class="circle"></div>
      </div>
      <div class="circle-clipper right">
        <div class="circle"></div>
      </div>
    </div>
  </div>
`;
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */template$8.setAttribute("strip-whitespace",""),Polymer({_template:template$8,is:"paper-spinner",behaviors:[PaperSpinnerBehavior]});
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */
const template$7=html`
  <style include="paper-spinner-styles"></style>

  <div id="spinnerContainer" class-name="[[__computeContainerClasses(active, __coolingDown)]]" on-animationend="__reset" on-webkit-animation-end="__reset">
    <div class="spinner-layer">
      <div class="circle-clipper left">
        <div class="circle"></div>
      </div>
      <div class="circle-clipper right">
        <div class="circle"></div>
      </div>
    </div>
  </div>
`;template$7.setAttribute("strip-whitespace",""),Polymer({_template:template$7,is:"paper-spinner-lite",behaviors:[PaperSpinnerBehavior]});
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
    The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
    The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
    Code distributed by Google as part of the polymer project is also
    subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
    */
const template$6=html`<iron-iconset-svg name="paper-tabs" size="24">
<svg><defs>
<g id="chevron-left"><path d="M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"></path></g>
<g id="chevron-right"><path d="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"></path></g>
</defs></svg>
</iron-iconset-svg>`;document.head.appendChild(template$6.content),
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
    The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
    The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
    Code distributed by Google as part of the polymer project is also
    subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
    */
Polymer({_template:html`
    <style>
      :host {
        @apply --layout-inline;
        @apply --layout-center;
        @apply --layout-center-justified;
        @apply --layout-flex-auto;

        position: relative;
        padding: 0 12px;
        overflow: hidden;
        cursor: pointer;
        vertical-align: middle;

        @apply --paper-font-common-base;
        @apply --paper-tab;
      }

      :host(:focus) {
        outline: none;
      }

      :host([link]) {
        padding: 0;
      }

      .tab-content {
        height: 100%;
        transform: translateZ(0);
          -webkit-transform: translateZ(0);
        transition: opacity 0.1s cubic-bezier(0.4, 0.0, 1, 1);
        @apply --layout-horizontal;
        @apply --layout-center-center;
        @apply --layout-flex-auto;
        @apply --paper-tab-content;
      }

      :host(:not(.iron-selected)) > .tab-content {
        opacity: 0.8;

        @apply --paper-tab-content-unselected;
      }

      :host(:focus) .tab-content {
        opacity: 1;
        font-weight: 700;

        @apply --paper-tab-content-focused;
      }

      paper-ripple {
        color: var(--paper-tab-ink, var(--paper-yellow-a100));
      }

      .tab-content > ::slotted(a) {
        @apply --layout-flex-auto;

        height: 100%;
      }
    </style>

    <div class="tab-content">
      <slot></slot>
    </div>
`,is:"paper-tab",behaviors:[IronControlState,IronButtonState,PaperRippleBehavior],properties:{link:{type:Boolean,value:!1,reflectToAttribute:!0}},hostAttributes:{role:"tab"},listeners:{down:"_updateNoink",tap:"_onTap"},attached:function(){this._updateNoink()},get _parentNoink(){var e=dom$1(this).parentNode;return!!e&&!!e.noink},_updateNoink:function(){this.noink=!!this.noink||!!this._parentNoink},_onTap:function(e){if(this.link){var t=this.queryEffectiveChildren("a");if(!t)return;if(e.target===t)return;t.click()}}}),
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
    The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
    The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
    Code distributed by Google as part of the polymer project is also
    subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
    */
Polymer({_template:html`
    <style>
      :host {
        @apply --layout;
        @apply --layout-center;

        height: 48px;
        font-size: 14px;
        font-weight: 500;
        overflow: hidden;
        -moz-user-select: none;
        -ms-user-select: none;
        -webkit-user-select: none;
        user-select: none;

        /* NOTE: Both values are needed, since some phones require the value to be \`transparent\`. */
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
        -webkit-tap-highlight-color: transparent;

        @apply --paper-tabs;
      }

      :host(:dir(rtl)) {
        @apply --layout-horizontal-reverse;
      }

      #tabsContainer {
        position: relative;
        height: 100%;
        white-space: nowrap;
        overflow: hidden;
        @apply --layout-flex-auto;
        @apply --paper-tabs-container;
      }

      #tabsContent {
        height: 100%;
        -moz-flex-basis: auto;
        -ms-flex-basis: auto;
        flex-basis: auto;
        @apply --paper-tabs-content;
      }

      #tabsContent.scrollable {
        position: absolute;
        white-space: nowrap;
      }

      #tabsContent:not(.scrollable),
      #tabsContent.scrollable.fit-container {
        @apply --layout-horizontal;
      }

      #tabsContent.scrollable.fit-container {
        min-width: 100%;
      }

      #tabsContent.scrollable.fit-container > ::slotted(*) {
        /* IE - prevent tabs from compressing when they should scroll. */
        -ms-flex: 1 0 auto;
        -webkit-flex: 1 0 auto;
        flex: 1 0 auto;
      }

      .hidden {
        display: none;
      }

      .not-visible {
        opacity: 0;
        cursor: default;
      }

      paper-icon-button {
        width: 48px;
        height: 48px;
        padding: 12px;
        margin: 0 4px;
      }

      #selectionBar {
        position: absolute;
        height: 0;
        bottom: 0;
        left: 0;
        right: 0;
        border-bottom: 2px solid var(--paper-tabs-selection-bar-color, var(--paper-yellow-a100));
          -webkit-transform: scale(0);
        transform: scale(0);
          -webkit-transform-origin: left center;
        transform-origin: left center;
          transition: -webkit-transform;
        transition: transform;

        @apply --paper-tabs-selection-bar;
      }

      #selectionBar.align-bottom {
        top: 0;
        bottom: auto;
      }

      #selectionBar.expand {
        transition-duration: 0.15s;
        transition-timing-function: cubic-bezier(0.4, 0.0, 1, 1);
      }

      #selectionBar.contract {
        transition-duration: 0.18s;
        transition-timing-function: cubic-bezier(0.0, 0.0, 0.2, 1);
      }

      #tabsContent > ::slotted(:not(#selectionBar)) {
        height: 100%;
      }
    </style>

    <paper-icon-button icon="paper-tabs:chevron-left" class$="[[_computeScrollButtonClass(_leftHidden, scrollable, hideScrollButtons)]]" on-up="_onScrollButtonUp" on-down="_onLeftScrollButtonDown" tabindex="-1"></paper-icon-button>

    <div id="tabsContainer" on-track="_scroll" on-down="_down">
      <div id="tabsContent" class$="[[_computeTabsContentClass(scrollable, fitContainer)]]">
        <div id="selectionBar" class$="[[_computeSelectionBarClass(noBar, alignBottom)]]" on-transitionend="_onBarTransitionEnd"></div>
        <slot></slot>
      </div>
    </div>

    <paper-icon-button icon="paper-tabs:chevron-right" class$="[[_computeScrollButtonClass(_rightHidden, scrollable, hideScrollButtons)]]" on-up="_onScrollButtonUp" on-down="_onRightScrollButtonDown" tabindex="-1"></paper-icon-button>
`,is:"paper-tabs",behaviors:[IronResizableBehavior,IronMenubarBehavior],properties:{noink:{type:Boolean,value:!1,observer:"_noinkChanged"},noBar:{type:Boolean,value:!1},noSlide:{type:Boolean,value:!1},scrollable:{type:Boolean,value:!1},fitContainer:{type:Boolean,value:!1},disableDrag:{type:Boolean,value:!1},hideScrollButtons:{type:Boolean,value:!1},alignBottom:{type:Boolean,value:!1},selectable:{type:String,value:"paper-tab"},autoselect:{type:Boolean,value:!1},autoselectDelay:{type:Number,value:0},_step:{type:Number,value:10},_holdDelay:{type:Number,value:1},_leftHidden:{type:Boolean,value:!1},_rightHidden:{type:Boolean,value:!1},_previousTab:{type:Object}},hostAttributes:{role:"tablist"},listeners:{"iron-resize":"_onTabSizingChanged","iron-items-changed":"_onTabSizingChanged","iron-select":"_onIronSelect","iron-deselect":"_onIronDeselect"},keyBindings:{"left:keyup right:keyup":"_onArrowKeyup"},created:function(){this._holdJob=null,this._pendingActivationItem=void 0,this._pendingActivationTimeout=void 0,this._bindDelayedActivationHandler=this._delayedActivationHandler.bind(this),this.addEventListener("blur",this._onBlurCapture.bind(this),!0)},ready:function(){this.setScrollDirection("y",this.$.tabsContainer)},detached:function(){this._cancelPendingActivation()},_noinkChanged:function(e){dom$1(this).querySelectorAll("paper-tab").forEach(e?this._setNoinkAttribute:this._removeNoinkAttribute)},_setNoinkAttribute:function(e){e.setAttribute("noink","")},_removeNoinkAttribute:function(e){e.removeAttribute("noink")},_computeScrollButtonClass:function(e,t,n){return!t||n?"hidden":e?"not-visible":""},_computeTabsContentClass:function(e,t){return e?"scrollable"+(t?" fit-container":""):" fit-container"},_computeSelectionBarClass:function(e,t){return e?"hidden":t?"align-bottom":""},_onTabSizingChanged:function(){this.debounce("_onTabSizingChanged",(function(){this._scroll(),this._tabChanged(this.selectedItem)}),10)},_onIronSelect:function(e){this._tabChanged(e.detail.item,this._previousTab),this._previousTab=e.detail.item,this.cancelDebouncer("tab-changed")},_onIronDeselect:function(e){this.debounce("tab-changed",(function(){this._tabChanged(null,this._previousTab),this._previousTab=null}),1)},_activateHandler:function(){this._cancelPendingActivation(),IronMenuBehaviorImpl._activateHandler.apply(this,arguments)},_scheduleActivation:function(e,t){this._pendingActivationItem=e,this._pendingActivationTimeout=this.async(this._bindDelayedActivationHandler,t)},_delayedActivationHandler:function(){var e=this._pendingActivationItem;this._pendingActivationItem=void 0,this._pendingActivationTimeout=void 0,e.fire(this.activateEvent,null,{bubbles:!0,cancelable:!0})},_cancelPendingActivation:function(){void 0!==this._pendingActivationTimeout&&(this.cancelAsync(this._pendingActivationTimeout),this._pendingActivationItem=void 0,this._pendingActivationTimeout=void 0)},_onArrowKeyup:function(e){this.autoselect&&this._scheduleActivation(this.focusedItem,this.autoselectDelay)},_onBlurCapture:function(e){e.target===this._pendingActivationItem&&this._cancelPendingActivation()},get _tabContainerScrollSize(){return Math.max(0,this.$.tabsContainer.scrollWidth-this.$.tabsContainer.offsetWidth)},_scroll:function(e,t){this.scrollable&&this._affectScroll(t&&-t.ddx||0)},_down:function(e){this.async((function(){this._defaultFocusAsync&&(this.cancelAsync(this._defaultFocusAsync),this._defaultFocusAsync=null)}),1)},_affectScroll:function(e){this.$.tabsContainer.scrollLeft+=e;var t=this.$.tabsContainer.scrollLeft;this._leftHidden=0===t,this._rightHidden=t===this._tabContainerScrollSize},_onLeftScrollButtonDown:function(){this._scrollToLeft(),this._holdJob=setInterval(this._scrollToLeft.bind(this),this._holdDelay)},_onRightScrollButtonDown:function(){this._scrollToRight(),this._holdJob=setInterval(this._scrollToRight.bind(this),this._holdDelay)},_onScrollButtonUp:function(){clearInterval(this._holdJob),this._holdJob=null},_scrollToLeft:function(){this._affectScroll(-this._step)},_scrollToRight:function(){this._affectScroll(this._step)},_tabChanged:function(e,t){if(!e)return this.$.selectionBar.classList.remove("expand"),this.$.selectionBar.classList.remove("contract"),void this._positionBar(0,0);var n=this.$.tabsContent.getBoundingClientRect(),r=n.width,i=e.getBoundingClientRect(),a=i.left-n.left;if(this._pos={width:this._calcPercent(i.width,r),left:this._calcPercent(a,r)},this.noSlide||null==t)return this.$.selectionBar.classList.remove("expand"),this.$.selectionBar.classList.remove("contract"),void this._positionBar(this._pos.width,this._pos.left);var o=t.getBoundingClientRect(),s=this.items.indexOf(t),l=this.items.indexOf(e);this.$.selectionBar.classList.add("expand");var c=s<l;this._isRTL&&(c=!c),c?this._positionBar(this._calcPercent(i.left+i.width-o.left,r)-5,this._left):this._positionBar(this._calcPercent(o.left+o.width-i.left,r)-5,this._calcPercent(a,r)+5),this.scrollable&&this._scrollToSelectedIfNeeded(i.width,a)},_scrollToSelectedIfNeeded:function(e,t){var n=t-this.$.tabsContainer.scrollLeft;(n<0||(n+=e-this.$.tabsContainer.offsetWidth)>0)&&(this.$.tabsContainer.scrollLeft+=n)},_calcPercent:function(e,t){return 100*e/t},_positionBar:function(e,t){t=t||0,this._width=e=e||0,this._left=t,this.transform("translateX("+t+"%) scaleX("+e/100+")",this.$.selectionBar)},_onBarTransitionEnd:function(e){var t=this.$.selectionBar.classList;t.contains("expand")?(t.remove("expand"),t.add("contract"),this._positionBar(this._pos.width,this._pos.left)):t.contains("contract")&&t.remove("contract")}});
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */
var currentToast=null;Polymer({_template:html`
    <style>
      :host {
        display: block;
        position: fixed;
        background-color: var(--paper-toast-background-color, #323232);
        color: var(--paper-toast-color, #f1f1f1);
        min-height: 48px;
        min-width: 288px;
        padding: 16px 24px;
        box-sizing: border-box;
        box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.26);
        border-radius: 2px;
        margin: 12px;
        font-size: 14px;
        cursor: default;
        -webkit-transition: -webkit-transform 0.3s, opacity 0.3s;
        transition: transform 0.3s, opacity 0.3s;
        opacity: 0;
        -webkit-transform: translateY(100px);
        transform: translateY(100px);
        @apply --paper-font-common-base;
      }

      :host(.capsule) {
        border-radius: 24px;
      }

      :host(.fit-bottom) {
        width: 100%;
        min-width: 0;
        border-radius: 0;
        margin: 0;
      }

      :host(.paper-toast-open) {
        opacity: 1;
        -webkit-transform: translateY(0px);
        transform: translateY(0px);
      }
    </style>

    <span id="label">{{text}}</span>
    <slot></slot>
`,is:"paper-toast",behaviors:[IronOverlayBehavior],properties:{fitInto:{type:Object,value:window,observer:"_onFitIntoChanged"},horizontalAlign:{type:String,value:"left"},verticalAlign:{type:String,value:"bottom"},duration:{type:Number,value:3e3},text:{type:String,value:""},noCancelOnOutsideClick:{type:Boolean,value:!0},noAutoFocus:{type:Boolean,value:!0}},listeners:{transitionend:"__onTransitionEnd"},get visible(){return Base._warn("`visible` is deprecated, use `opened` instead"),this.opened},get _canAutoClose(){return this.duration>0&&this.duration!==1/0},created:function(){this._autoClose=null,IronA11yAnnouncer.requestAvailability()},show:function(e){for(var t in"string"==typeof e&&(e={text:e}),e)0===t.indexOf("_")?Base._warn('The property "'+t+'" is private and was not set.'):t in this?this[t]=e[t]:Base._warn('The property "'+t+'" is not valid.');this.open()},hide:function(){this.close()},__onTransitionEnd:function(e){e&&e.target===this&&"opacity"===e.propertyName&&(this.opened?this._finishRenderOpened():this._finishRenderClosed())},_openedChanged:function(){null!==this._autoClose&&(this.cancelAsync(this._autoClose),this._autoClose=null),this.opened?(currentToast&&currentToast!==this&&currentToast.close(),currentToast=this,this.fire("iron-announce",{text:this.text}),this._canAutoClose&&(this._autoClose=this.async(this.close,this.duration))):currentToast===this&&(currentToast=null),IronOverlayBehaviorImpl._openedChanged.apply(this,arguments)},_renderOpened:function(){this.classList.add("paper-toast-open")},_renderClosed:function(){this.classList.remove("paper-toast-open")},_onFitIntoChanged:function(e){this.positionTarget=e}});
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
    The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
    The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
    Code distributed by Google as part of the polymer project is also
    subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
    */
const template$5=html`

    <style>
      :host {
        display: inline-block;
        @apply --layout-horizontal;
        @apply --layout-center;
        @apply --paper-font-common-base;
      }

      :host([disabled]) {
        pointer-events: none;
      }

      :host(:focus) {
        outline:none;
      }

      .toggle-bar {
        position: absolute;
        height: 100%;
        width: 100%;
        border-radius: 8px;
        pointer-events: none;
        opacity: 0.4;
        transition: background-color linear .08s;
        background-color: var(--paper-toggle-button-unchecked-bar-color, #000000);

        @apply --paper-toggle-button-unchecked-bar;
      }

      .toggle-button {
        position: absolute;
        top: -3px;
        left: 0;
        height: 20px;
        width: 20px;
        border-radius: 50%;
        box-shadow: 0 1px 5px 0 rgba(0, 0, 0, 0.6);
        transition: -webkit-transform linear .08s, background-color linear .08s;
        transition: transform linear .08s, background-color linear .08s;
        will-change: transform;
        background-color: var(--paper-toggle-button-unchecked-button-color, var(--paper-grey-50));

        @apply --paper-toggle-button-unchecked-button;
      }

      .toggle-button.dragging {
        -webkit-transition: none;
        transition: none;
      }

      :host([checked]:not([disabled])) .toggle-bar {
        opacity: 0.5;
        background-color: var(--paper-toggle-button-checked-bar-color, var(--primary-color));

        @apply --paper-toggle-button-checked-bar;
      }

      :host([disabled]) .toggle-bar {
        background-color: #000;
        opacity: 0.12;
      }

      :host([checked]) .toggle-button {
        -webkit-transform: translate(16px, 0);
        transform: translate(16px, 0);
      }

      :host([checked]:not([disabled])) .toggle-button {
        background-color: var(--paper-toggle-button-checked-button-color, var(--primary-color));

        @apply --paper-toggle-button-checked-button;
      }

      :host([disabled]) .toggle-button {
        background-color: #bdbdbd;
        opacity: 1;
      }

      .toggle-ink {
        position: absolute;
        top: -14px;
        left: -14px;
        right: auto;
        bottom: auto;
        width: 48px;
        height: 48px;
        opacity: 0.5;
        pointer-events: none;
        color: var(--paper-toggle-button-unchecked-ink-color, var(--primary-text-color));

        @apply --paper-toggle-button-unchecked-ink;
      }

      :host([checked]) .toggle-ink {
        color: var(--paper-toggle-button-checked-ink-color, var(--primary-color));

        @apply --paper-toggle-button-checked-ink;
      }

      .toggle-container {
        display: inline-block;
        position: relative;
        width: 36px;
        height: 14px;
        /* The toggle button has an absolute position of -3px; The extra 1px
        /* accounts for the toggle button shadow box. */
        margin: 4px 1px;
      }

      .toggle-label {
        position: relative;
        display: inline-block;
        vertical-align: middle;
        padding-left: var(--paper-toggle-button-label-spacing, 8px);
        pointer-events: none;
        color: var(--paper-toggle-button-label-color, var(--primary-text-color));
      }

      /* invalid state */
      :host([invalid]) .toggle-bar {
        background-color: var(--paper-toggle-button-invalid-bar-color, var(--error-color));
      }

      :host([invalid]) .toggle-button {
        background-color: var(--paper-toggle-button-invalid-button-color, var(--error-color));
      }

      :host([invalid]) .toggle-ink {
        color: var(--paper-toggle-button-invalid-ink-color, var(--error-color));
      }
    </style>

    <div class="toggle-container">
      <div id="toggleBar" class="toggle-bar"></div>
      <div id="toggleButton" class="toggle-button"></div>
    </div>

    <div class="toggle-label"><slot></slot></div>

  `;template$5.setAttribute("strip-whitespace",""),Polymer({_template:template$5,is:"paper-toggle-button",behaviors:[PaperCheckedElementBehavior],hostAttributes:{role:"button","aria-pressed":"false",tabindex:0},properties:{},listeners:{track:"_ontrack"},attached:function(){afterNextRender(this,(function(){setTouchAction(this,"pan-y")}))},_ontrack:function(e){var t=e.detail;"start"===t.state?this._trackStart(t):"track"===t.state?this._trackMove(t):"end"===t.state&&this._trackEnd(t)},_trackStart:function(e){this._width=this.$.toggleBar.offsetWidth/2,this._trackChecked=this.checked,this.$.toggleButton.classList.add("dragging")},_trackMove:function(e){var t=e.dx;this._x=Math.min(this._width,Math.max(0,this._trackChecked?this._width+t:t)),this.translate3d(this._x+"px",0,0,this.$.toggleButton),this._userActivate(this._x>this._width/2)},_trackEnd:function(e){this.$.toggleButton.classList.remove("dragging"),this.transform("",this.$.toggleButton)},_createRipple:function(){this._rippleContainer=this.$.toggleButton;var e=PaperRippleBehavior._createRipple();return e.id="ink",e.setAttribute("recenters",""),e.classList.add("circle","toggle-ink"),e}}),
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */
Polymer({_template:html`
    <style>
      :host {
        --calculated-paper-toolbar-height: var(--paper-toolbar-height, 64px);
        --calculated-paper-toolbar-sm-height: var(--paper-toolbar-sm-height, 56px);
        display: block;
        position: relative;
        box-sizing: border-box;
        -moz-box-sizing: border-box;
        height: var(--calculated-paper-toolbar-height);
        background: var(--paper-toolbar-background, var(--primary-color));
        color: var(--paper-toolbar-color, var(--dark-theme-text-color));
        @apply --paper-toolbar;
      }

      :host(.animate) {
        transition: var(--paper-toolbar-transition, height 0.18s ease-in);
      }

      :host(.medium-tall) {
        height: calc(var(--calculated-paper-toolbar-height) * 2);
        @apply --paper-toolbar-medium;
      }

      :host(.tall) {
        height: calc(var(--calculated-paper-toolbar-height) * 3);
        @apply --paper-toolbar-tall;
      }

      .toolbar-tools {
        position: relative;
        height: var(--calculated-paper-toolbar-height);
        padding: 0 16px;
        pointer-events: none;
        @apply --layout-horizontal;
        @apply --layout-center;
        @apply --paper-toolbar-content;
      }

      /*
       * TODO: Where should media query breakpoints live so they can be shared between elements?
       */

      @media (max-width: 600px) {
        :host {
          height: var(--calculated-paper-toolbar-sm-height);
        }

        :host(.medium-tall) {
          height: calc(var(--calculated-paper-toolbar-sm-height) * 2);
        }

        :host(.tall) {
          height: calc(var(--calculated-paper-toolbar-sm-height) * 3);
        }

        .toolbar-tools {
          height: var(--calculated-paper-toolbar-sm-height);
        }
      }

      #topBar {
        position: relative;
      }

      /* middle bar */
      #middleBar {
        position: absolute;
        top: 0;
        right: 0;
        left: 0;
      }

      :host(.tall) #middleBar,
      :host(.medium-tall) #middleBar {
        -webkit-transform: translateY(100%);
        transform: translateY(100%);
      }

      /* bottom bar */
      #bottomBar {
        position: absolute;
        right: 0;
        bottom: 0;
        left: 0;
      }

      /*
       * make elements (e.g. buttons) respond to mouse/touch events
       *
       * \`.toolbar-tools\` disables touch events so multiple toolbars can stack and not
       * absorb events. All children must have pointer events re-enabled to work as
       * expected.
       */
      .toolbar-tools > ::slotted(*:not([disabled])) {
        pointer-events: auto;
      }

      .toolbar-tools > ::slotted(.title) {
        @apply --paper-font-common-base;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        font-size: 20px;
        font-weight: 400;
        line-height: 1;
        pointer-events: none;
        @apply --layout-flex;
      }

      .toolbar-tools > ::slotted(.title) {
        margin-left: 56px;
      }

      .toolbar-tools > ::slotted(paper-icon-button + .title) {
        margin-left: 0;
      }

      /**
       * The --paper-toolbar-title mixin is applied here instead of above to
       * fix the issue with margin-left being ignored due to css ordering.
       */
      .toolbar-tools > ::slotted(.title) {
        @apply --paper-toolbar-title;
      }

      .toolbar-tools > ::slotted(paper-icon-button[icon=menu]) {
        margin-right: 24px;
      }

      .toolbar-tools > ::slotted(.fit) {
        position: absolute;
        top: auto;
        right: 0;
        bottom: 0;
        left: 0;
        width: auto;
        margin: 0;
      }

      /* TODO(noms): Until we have a better solution for classes that don't use
       * /deep/ create our own.
       */
      .start-justified {
        @apply --layout-start-justified;
      }

      .center-justified {
        @apply --layout-center-justified;
      }

      .end-justified {
        @apply --layout-end-justified;
      }

      .around-justified {
        @apply --layout-around-justified;
      }

      .justified {
        @apply --layout-justified;
      }
    </style>

    <div id="topBar" class\$="toolbar-tools [[_computeBarExtraClasses(justify)]]">
      <slot name="top"></slot>
    </div>

    <div id="middleBar" class\$="toolbar-tools [[_computeBarExtraClasses(middleJustify)]]">
      <slot name="middle"></slot>
    </div>

    <div id="bottomBar" class\$="toolbar-tools [[_computeBarExtraClasses(bottomJustify)]]">
      <slot name="bottom"></slot>
    </div>
`,is:"paper-toolbar",hostAttributes:{role:"toolbar"},properties:{bottomJustify:{type:String,value:""},justify:{type:String,value:""},middleJustify:{type:String,value:""}},ready:function(){console.warn(this.is,"is deprecated. Please use app-layout instead!")},attached:function(){this._observer=this._observe(this),this._updateAriaLabelledBy()},detached:function(){this._observer&&this._observer.disconnect()},_observe:function(e){var t=new MutationObserver(function(){this._updateAriaLabelledBy()}.bind(this));return t.observe(e,{childList:!0,subtree:!0}),t},_updateAriaLabelledBy:function(){flush();for(var e,t=[],n=Array.prototype.slice.call(dom$1(this.root).querySelectorAll("slot")).concat(Array.prototype.slice.call(dom$1(this.root).querySelectorAll("content"))),r=0;e=n[r];r++)for(var i,a=dom$1(e).getDistributedNodes(),o=0;i=a[o];o++)if(i.classList&&i.classList.contains("title"))if(i.id)t.push(i.id);else{var s="paper-toolbar-label-"+Math.floor(1e4*Math.random());i.id=s,t.push(s)}t.length>0&&this.setAttribute("aria-labelledby",t.join(" "))},_computeBarExtraClasses:function(e){return e?e+("justified"===e?"":"-justified"):""}}),
/**
    @license
    Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
    This code may only be used under the BSD style license found at
    http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
    http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
    found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
    part of the polymer project is also subject to an additional IP rights grant
    found at http://polymer.github.io/PATENTS.txt
    */
Polymer({_template:html`
    <style>
      :host {
        display: block;
        position: absolute;
        outline: none;
        z-index: 1002;
        -moz-user-select: none;
        -ms-user-select: none;
        -webkit-user-select: none;
        user-select: none;
        cursor: default;
      }

      #tooltip {
        display: block;
        outline: none;
        @apply --paper-font-common-base;
        font-size: 10px;
        line-height: 1;
        background-color: var(--paper-tooltip-background, #616161);
        color: var(--paper-tooltip-text-color, white);
        padding: 8px;
        border-radius: 2px;
        @apply --paper-tooltip;
      }

      @keyframes keyFrameScaleUp {
        0% {
          transform: scale(0.0);
        }
        100% {
          transform: scale(1.0);
        }
      }

      @keyframes keyFrameScaleDown {
        0% {
          transform: scale(1.0);
        }
        100% {
          transform: scale(0.0);
        }
      }

      @keyframes keyFrameFadeInOpacity {
        0% {
          opacity: 0;
        }
        100% {
          opacity: var(--paper-tooltip-opacity, 0.9);
        }
      }

      @keyframes keyFrameFadeOutOpacity {
        0% {
          opacity: var(--paper-tooltip-opacity, 0.9);
        }
        100% {
          opacity: 0;
        }
      }

      @keyframes keyFrameSlideDownIn {
        0% {
          transform: translateY(-2000px);
          opacity: 0;
        }
        10% {
          opacity: 0.2;
        }
        100% {
          transform: translateY(0);
          opacity: var(--paper-tooltip-opacity, 0.9);
        }
      }

      @keyframes keyFrameSlideDownOut {
        0% {
          transform: translateY(0);
          opacity: var(--paper-tooltip-opacity, 0.9);
        }
        10% {
          opacity: 0.2;
        }
        100% {
          transform: translateY(-2000px);
          opacity: 0;
        }
      }

      .fade-in-animation {
        opacity: 0;
        animation-delay: var(--paper-tooltip-delay-in, 500ms);
        animation-name: keyFrameFadeInOpacity;
        animation-iteration-count: 1;
        animation-timing-function: ease-in;
        animation-duration: var(--paper-tooltip-duration-in, 500ms);
        animation-fill-mode: forwards;
        @apply --paper-tooltip-animation;
      }

      .fade-out-animation {
        opacity: var(--paper-tooltip-opacity, 0.9);
        animation-delay: var(--paper-tooltip-delay-out, 0ms);
        animation-name: keyFrameFadeOutOpacity;
        animation-iteration-count: 1;
        animation-timing-function: ease-in;
        animation-duration: var(--paper-tooltip-duration-out, 500ms);
        animation-fill-mode: forwards;
        @apply --paper-tooltip-animation;
      }

      .scale-up-animation {
        transform: scale(0);
        opacity: var(--paper-tooltip-opacity, 0.9);
        animation-delay: var(--paper-tooltip-delay-in, 500ms);
        animation-name: keyFrameScaleUp;
        animation-iteration-count: 1;
        animation-timing-function: ease-in;
        animation-duration: var(--paper-tooltip-duration-in, 500ms);
        animation-fill-mode: forwards;
        @apply --paper-tooltip-animation;
      }

      .scale-down-animation {
        transform: scale(1);
        opacity: var(--paper-tooltip-opacity, 0.9);
        animation-delay: var(--paper-tooltip-delay-out, 500ms);
        animation-name: keyFrameScaleDown;
        animation-iteration-count: 1;
        animation-timing-function: ease-in;
        animation-duration: var(--paper-tooltip-duration-out, 500ms);
        animation-fill-mode: forwards;
        @apply --paper-tooltip-animation;
      }

      .slide-down-animation {
        transform: translateY(-2000px);
        opacity: 0;
        animation-delay: var(--paper-tooltip-delay-out, 500ms);
        animation-name: keyFrameSlideDownIn;
        animation-iteration-count: 1;
        animation-timing-function: cubic-bezier(0.0, 0.0, 0.2, 1);
        animation-duration: var(--paper-tooltip-duration-out, 500ms);
        animation-fill-mode: forwards;
        @apply --paper-tooltip-animation;
      }

      .slide-down-animation-out {
        transform: translateY(0);
        opacity: var(--paper-tooltip-opacity, 0.9);
        animation-delay: var(--paper-tooltip-delay-out, 500ms);
        animation-name: keyFrameSlideDownOut;
        animation-iteration-count: 1;
        animation-timing-function: cubic-bezier(0.4, 0.0, 1, 1);
        animation-duration: var(--paper-tooltip-duration-out, 500ms);
        animation-fill-mode: forwards;
        @apply --paper-tooltip-animation;
      }

      .cancel-animation {
        animation-delay: -30s !important;
      }

      /* Thanks IE 10. */

      .hidden {
        display: none !important;
      }
    </style>

    <div id="tooltip" class="hidden">
      <slot></slot>
    </div>
`,is:"paper-tooltip",hostAttributes:{role:"tooltip",tabindex:-1},properties:{for:{type:String,observer:"_findTarget"},manualMode:{type:Boolean,value:!1,observer:"_manualModeChanged"},position:{type:String,value:"bottom"},fitToVisibleBounds:{type:Boolean,value:!1},offset:{type:Number,value:14},marginTop:{type:Number,value:14},animationDelay:{type:Number,value:500,observer:"_delayChange"},animationEntry:{type:String,value:""},animationExit:{type:String,value:""},animationConfig:{type:Object,value:function(){return{entry:[{name:"fade-in-animation",node:this,timing:{delay:0}}],exit:[{name:"fade-out-animation",node:this}]}}},_showing:{type:Boolean,value:!1}},listeners:{webkitAnimationEnd:"_onAnimationEnd"},get target(){var e=dom$1(this).parentNode,t=dom$1(this).getOwnerRoot();return this.for?dom$1(t).querySelector("#"+this.for):e.nodeType==Node.DOCUMENT_FRAGMENT_NODE?t.host:e},attached:function(){this._findTarget()},detached:function(){this.manualMode||this._removeListeners()},playAnimation:function(e){"entry"===e?this.show():"exit"===e&&this.hide()},cancelAnimation:function(){this.$.tooltip.classList.add("cancel-animation")},show:function(){if(!this._showing){if(""===dom$1(this).textContent.trim()){for(var e=!0,t=dom$1(this).getEffectiveChildNodes(),n=0;n<t.length;n++)if(""!==t[n].textContent.trim()){e=!1;break}if(e)return}this._showing=!0,this.$.tooltip.classList.remove("hidden"),this.$.tooltip.classList.remove("cancel-animation"),this.$.tooltip.classList.remove(this._getAnimationType("exit")),this.updatePosition(),this._animationPlaying=!0,this.$.tooltip.classList.add(this._getAnimationType("entry"))}},hide:function(){if(this._showing){if(this._animationPlaying)return this._showing=!1,void this._cancelAnimation();this._onAnimationFinish(),this._showing=!1,this._animationPlaying=!0}},updatePosition:function(){if(this._target&&this.offsetParent){var e=this.offset;14!=this.marginTop&&14==this.offset&&(e=this.marginTop);var t,n,r=this.offsetParent.getBoundingClientRect(),i=this._target.getBoundingClientRect(),a=this.getBoundingClientRect(),o=(i.width-a.width)/2,s=(i.height-a.height)/2,l=i.left-r.left,c=i.top-r.top;switch(this.position){case"top":t=l+o,n=c-a.height-e;break;case"bottom":t=l+o,n=c+i.height+e;break;case"left":t=l-a.width-e,n=c+s;break;case"right":t=l+i.width+e,n=c+s}this.fitToVisibleBounds?(r.left+t+a.width>window.innerWidth?(this.style.right="0px",this.style.left="auto"):(this.style.left=Math.max(0,t)+"px",this.style.right="auto"),r.top+n+a.height>window.innerHeight?(this.style.bottom=r.height-c+e+"px",this.style.top="auto"):(this.style.top=Math.max(-r.top,n)+"px",this.style.bottom="auto")):(this.style.left=t+"px",this.style.top=n+"px")}},_addListeners:function(){this._target&&(this.listen(this._target,"mouseenter","show"),this.listen(this._target,"focus","show"),this.listen(this._target,"mouseleave","hide"),this.listen(this._target,"blur","hide"),this.listen(this._target,"tap","hide")),this.listen(this.$.tooltip,"animationend","_onAnimationEnd"),this.listen(this,"mouseenter","hide")},_findTarget:function(){this.manualMode||this._removeListeners(),this._target=this.target,this.manualMode||this._addListeners()},_delayChange:function(e){500!==e&&this.updateStyles({"--paper-tooltip-delay-in":e+"ms"})},_manualModeChanged:function(){this.manualMode?this._removeListeners():this._addListeners()},_cancelAnimation:function(){this.$.tooltip.classList.remove(this._getAnimationType("entry")),this.$.tooltip.classList.remove(this._getAnimationType("exit")),this.$.tooltip.classList.remove("cancel-animation"),this.$.tooltip.classList.add("hidden")},_onAnimationFinish:function(){this._showing&&(this.$.tooltip.classList.remove(this._getAnimationType("entry")),this.$.tooltip.classList.remove("cancel-animation"),this.$.tooltip.classList.add(this._getAnimationType("exit")))},_onAnimationEnd:function(){this._animationPlaying=!1,this._showing||(this.$.tooltip.classList.remove(this._getAnimationType("exit")),this.$.tooltip.classList.add("hidden"))},_getAnimationType:function(e){if("entry"===e&&""!==this.animationEntry)return this.animationEntry;if("exit"===e&&""!==this.animationExit)return this.animationExit;if(this.animationConfig[e]&&"string"==typeof this.animationConfig[e][0].name){if(this.animationConfig[e][0].timing&&this.animationConfig[e][0].timing.delay&&0!==this.animationConfig[e][0].timing.delay){var t=this.animationConfig[e][0].timing.delay;"entry"===e?this.updateStyles({"--paper-tooltip-delay-in":t+"ms"}):"exit"===e&&this.updateStyles({"--paper-tooltip-delay-out":t+"ms"})}return this.animationConfig[e][0].name}},_removeListeners:function(){this._target&&(this.unlisten(this._target,"mouseenter","show"),this.unlisten(this._target,"focus","show"),this.unlisten(this._target,"mouseleave","hide"),this.unlisten(this._target,"blur","hide"),this.unlisten(this._target,"tap","hide")),this.unlisten(this.$.tooltip,"animationend","_onAnimationEnd"),this.unlisten(this,"mouseenter","hide")}});class AnalyticsLogger{constructor(e,t){if("undefined"==typeof ga||null==ga)return this.eventLogging=!1,void(this.pageViewLogging=!1);this.eventLogging=t,this.pageViewLogging=e}logPageView(e){this.pageViewLogging&&ga("send",{hitType:"pageview",page:`/v/${e}`})}logProjectionChanged(e){this.eventLogging&&ga("send",{hitType:"event",eventCategory:"Projection",eventAction:"click",eventLabel:e})}logWebGLDisabled(){this.eventLogging&&ga("send",{hitType:"event",eventCategory:"Error",eventAction:"PageLoad",eventLabel:"WebGL_disabled"})}}var commonjsGlobal="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function getAugmentedNamespace(e){if(e.__esModule)return e;var t=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(e).forEach((function(n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})})),t}var numeric1_2_6={};(function(exports){var numeric=exports;void 0!==commonjsGlobal&&(commonjsGlobal.numeric=numeric),numeric.version="1.2.6",numeric.bench=function e(t,n){var r,i,a;for(void 0===n&&(n=15),i=.5,r=new Date;;){for(a=i*=2;a>3;a-=4)t(),t(),t(),t();for(;a>0;)t(),a--;if(new Date-r>n)break}for(a=i;a>3;a-=4)t(),t(),t(),t();for(;a>0;)t(),a--;return 1e3*(3*i-1)/(new Date-r)},numeric._myIndexOf=function e(t){var n,r=this.length;for(n=0;n<r;++n)if(this[n]===t)return n;return-1},numeric.myIndexOf=Array.prototype.indexOf?Array.prototype.indexOf:numeric._myIndexOf,numeric.Function=Function,numeric.precision=4,numeric.largeArray=50,numeric.prettyPrint=function e(t){function n(e){if(0===e)return"0";if(isNaN(e))return"NaN";if(e<0)return"-"+n(-e);if(isFinite(e)){var t=Math.floor(Math.log(e)/Math.log(10)),r=e/Math.pow(10,t),i=r.toPrecision(numeric.precision);return 10===parseFloat(i)&&(t++,i=(r=1).toPrecision(numeric.precision)),parseFloat(i).toString()+"e"+t.toString()}return"Infinity"}var r=[];return(function e(t){var i;if(void 0===t)return r.push(Array(numeric.precision+8).join(" ")),!1;if("string"==typeof t)return r.push('"'+t+'"'),!1;if("boolean"==typeof t)return r.push(t.toString()),!1;if("number"==typeof t){var a=n(t),o=t.toPrecision(numeric.precision),s=parseFloat(t.toString()).toString(),l=[a,o,s,parseFloat(o).toString(),parseFloat(s).toString()];for(i=1;i<l.length;i++)l[i].length<a.length&&(a=l[i]);return r.push(Array(numeric.precision+8-a.length).join(" ")+a),!1}if(null===t)return r.push("null"),!1;if("function"==typeof t){r.push(t.toString());var c=!1;for(i in t)t.hasOwnProperty(i)&&(r.push(c?",\n":"\n{"),c=!0,r.push(i),r.push(": \n"),e(t[i]));return c&&r.push("}\n"),!0}if(t instanceof Array){if(t.length>numeric.largeArray)return r.push("...Large Array..."),!0;c=!1;for(r.push("["),i=0;i<t.length;i++)i>0&&(r.push(","),c&&r.push("\n ")),c=e(t[i]);return r.push("]"),!0}for(i in r.push("{"),c=!1,t)t.hasOwnProperty(i)&&(c&&r.push(",\n"),c=!0,r.push(i),r.push(": \n"),e(t[i]));return r.push("}"),!0})(t),r.join("")},numeric.parseDate=function e(t){return(function e(t){if("string"==typeof t)return Date.parse(t.replace(/-/g,"/"));if(!(t instanceof Array))throw new Error("parseDate: parameter must be arrays of strings");var n,r=[];for(n=0;n<t.length;n++)r[n]=e(t[n]);return r})(t)},numeric.parseFloat=function e(t){return(function e(t){if("string"==typeof t)return parseFloat(t);if(!(t instanceof Array))throw new Error("parseFloat: parameter must be arrays of strings");var n,r=[];for(n=0;n<t.length;n++)r[n]=e(t[n]);return r})(t)},numeric.parseCSV=function e(t){var n,r,i,a=t.split("\n"),o=[],s=/(([^'",]*)|('[^']*')|("[^"]*")),/g,l=/^\s*(([+-]?[0-9]+(\.[0-9]*)?(e[+-]?[0-9]+)?)|([+-]?[0-9]*(\.[0-9]+)?(e[+-]?[0-9]+)?))\s*$/,c=0;for(r=0;r<a.length;r++){var h,u=(a[r]+",").match(s);if(u.length>0){for(o[c]=[],n=0;n<u.length;n++)h=(i=u[n]).substr(0,i.length-1),o[c][n]=l.test(h)?parseFloat(h):h;c++}}return o},numeric.toCSV=function e(t){var n,r,i,a,o;for(i=numeric.dim(t)[0],o=[],n=0;n<i;n++){for(a=[],r=0;r<i;r++)a[r]=t[n][r].toString();o[n]=a.join(", ")}return o.join("\n")+"\n"},numeric.getURL=function e(t){var n=new XMLHttpRequest;return n.open("GET",t,!1),n.send(),n},numeric.imageURL=function e(t){function n(e,t,n){void 0===t&&(t=0),void 0===n&&(n=e.length);var r,i=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117],a=-1;for(r=t;r<n;r++)a=a>>>8^i[255&(a^e[r])];return-1^a}var r,i,a,o,s,l,c,h,u,d,p=t[0].length,m=t[0][0].length,f=[137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,m>>24&255,m>>16&255,m>>8&255,255&m,p>>24&255,p>>16&255,p>>8&255,255&p,8,2,0,0,0,-1,-2,-3,-4,-5,-6,-7,-8,73,68,65,84,8,29];for(d=n(f,12,29),f[29]=d>>24&255,f[30]=d>>16&255,f[31]=d>>8&255,f[32]=255&d,r=1,i=0,c=0;c<p;c++){for(f.push(c<p-1?0:1),l=3*m+1+(0===c)>>8&255,f.push(s=3*m+1+(0===c)&255),f.push(l),f.push(255&~s),f.push(255&~l),0===c&&f.push(0),h=0;h<m;h++)for(a=0;a<3;a++)i=(i+(r=(r+(s=(s=t[a][c][h])>255?255:s<0?0:Math.round(s)))%65521))%65521,f.push(s);f.push(0)}return f.push((u=(i<<16)+r)>>24&255),f.push(u>>16&255),f.push(u>>8&255),f.push(255&u),f[33]=(o=f.length-41)>>24&255,f[34]=o>>16&255,f[35]=o>>8&255,f[36]=255&o,d=n(f,37),f.push(d>>24&255),f.push(d>>16&255),f.push(d>>8&255),f.push(255&d),f.push(0),f.push(0),f.push(0),f.push(0),f.push(73),f.push(69),f.push(78),f.push(68),f.push(174),f.push(66),f.push(96),f.push(130),"data:image/png;base64,"+(function g(e){var t,n,r,i,a,o,s,l=e.length,c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",h="";for(t=0;t<l;t+=3)a=((3&(n=e[t]))<<4)+((r=e[t+1])>>4),o=((15&r)<<2)+((i=e[t+2])>>6),s=63&i,t+1>=l?o=s=64:t+2>=l&&(s=64),h+=c.charAt(n>>2)+c.charAt(a)+c.charAt(o)+c.charAt(s);return h})(f)},numeric._dim=function e(t){for(var n=[];"object"==typeof t;)n.push(t.length),t=t[0];return n},numeric.dim=function e(t){var n;return"object"==typeof t?"object"==typeof(n=t[0])?"object"==typeof n[0]?numeric._dim(t):[t.length,n.length]:[t.length]:[]},numeric.mapreduce=function e(t,n){return Function("x","accum","_s","_k",'if(typeof accum === "undefined") accum = '+n+';\nif(typeof x === "number") { var xi = x; '+t+'; return accum; }\nif(typeof _s === "undefined") _s = numeric.dim(x);\nif(typeof _k === "undefined") _k = 0;\nvar _n = _s[_k];\nvar i,xi;\nif(_k < _s.length-1) {\n    for(i=_n-1;i>=0;i--) {\n        accum = arguments.callee(x[i],accum,_s,_k+1);\n    }    return accum;\n}\nfor(i=_n-1;i>=1;i-=2) { \n    xi = x[i];\n    '+t+";\n    xi = x[i-1];\n    "+t+";\n}\nif(i === 0) {\n    xi = x[i];\n    "+t+"\n}\nreturn accum;")},numeric.mapreduce2=function e(t,n){return Function("x","var n = x.length;\nvar i,xi;\n"+n+";\nfor(i=n-1;i!==-1;--i) { \n    xi = x[i];\n    "+t+";\n}\nreturn accum;")},numeric.same=function e(t,n){var r,i;if(!(t instanceof Array&&n instanceof Array))return!1;if((i=t.length)!==n.length)return!1;for(r=0;r<i;r++)if(t[r]!==n[r]){if("object"!=typeof t[r])return!1;if(!e(t[r],n[r]))return!1}return!0},numeric.rep=function e(t,n,r){void 0===r&&(r=0);var i,a=t[r],o=Array(a);if(r===t.length-1){for(i=a-2;i>=0;i-=2)o[i+1]=n,o[i]=n;return-1===i&&(o[0]=n),o}for(i=a-1;i>=0;i--)o[i]=numeric.rep(t,n,r+1);return o},numeric.dotMMsmall=function e(t,n){var r,i,a,o,s,l,c,h,u,d,p;for(o=t.length,s=n.length,l=n[0].length,c=Array(o),r=o-1;r>=0;r--){for(h=Array(l),u=t[r],a=l-1;a>=0;a--){for(d=u[s-1]*n[s-1][a],i=s-2;i>=1;i-=2)d+=u[i]*n[i][a]+u[p=i-1]*n[p][a];0===i&&(d+=u[0]*n[0][a]),h[a]=d}c[r]=h}return c},numeric._getCol=function e(t,n,r){var i;for(i=t.length-1;i>0;--i)r[i]=t[i][n],r[--i]=t[i][n];0===i&&(r[0]=t[0][n])},numeric.dotMMbig=function e(t,n){var r,i,a=numeric._getCol,o=n.length,s=Array(o),l=t.length,c=n[0].length,h=new Array(l),u=numeric.dotVV;for(--o,r=--l;-1!==r;--r)h[r]=Array(c);for(r=--c;-1!==r;--r)for(a(n,r,s),i=l;-1!==i;--i)h[i][r]=u(t[i],s);return h},numeric.dotMV=function e(t,n){var r,i=t.length,a=Array(i),o=numeric.dotVV;for(r=i-1;r>=0;r--)a[r]=o(t[r],n);return a},numeric.dotVM=function e(t,n){var r,i,a,o,s,l,c;for(a=t.length,o=n[0].length,s=Array(o),i=o-1;i>=0;i--){for(l=t[a-1]*n[a-1][i],r=a-2;r>=1;r-=2)l+=t[r]*n[r][i]+t[c=r-1]*n[c][i];0===r&&(l+=t[0]*n[0][i]),s[i]=l}return s},numeric.dotVV=function e(t,n){var r,i,a=t.length,o=t[a-1]*n[a-1];for(r=a-2;r>=1;r-=2)o+=t[r]*n[r]+t[i=r-1]*n[i];return 0===r&&(o+=t[0]*n[0]),o},numeric.dot=function e(t,n){var r=numeric.dim;switch(1e3*r(t).length+r(n).length){case 2002:return n.length<10?numeric.dotMMsmall(t,n):numeric.dotMMbig(t,n);case 2001:return numeric.dotMV(t,n);case 1002:return numeric.dotVM(t,n);case 1001:return numeric.dotVV(t,n);case 1e3:return numeric.mulVS(t,n);case 1:return numeric.mulSV(t,n);case 0:return t*n;default:throw new Error("numeric.dot only works on vectors and matrices")}},numeric.diag=function e(t){var n,r,i,a,o=t.length,s=Array(o);for(n=o-1;n>=0;n--){for(a=Array(o),r=n+2,i=o-1;i>=r;i-=2)a[i]=0,a[i-1]=0;for(i>n&&(a[i]=0),a[n]=t[n],i=n-1;i>=1;i-=2)a[i]=0,a[i-1]=0;0===i&&(a[0]=0),s[n]=a}return s},numeric.getDiag=function(e){var t,n=Math.min(e.length,e[0].length),r=Array(n);for(t=n-1;t>=1;--t)r[t]=e[t][t],r[--t]=e[t][t];return 0===t&&(r[0]=e[0][0]),r},numeric.identity=function e(t){return numeric.diag(numeric.rep([t],1))},numeric.pointwise=function e(t,n,r){void 0===r&&(r="");var i,a,o=[],s=/\[i\]$/,l="",c=!1;for(i=0;i<t.length;i++)s.test(t[i])?l=a=t[i].substring(0,t[i].length-3):a=t[i],"ret"===a&&(c=!0),o.push(a);return o[t.length]="_s",o[t.length+1]="_k",o[t.length+2]='if(typeof _s === "undefined") _s = numeric.dim('+l+');\nif(typeof _k === "undefined") _k = 0;\nvar _n = _s[_k];\nvar i'+(c?"":", ret = Array(_n)")+";\nif(_k < _s.length-1) {\n    for(i=_n-1;i>=0;i--) ret[i] = arguments.callee("+t.join(",")+",_s,_k+1);\n    return ret;\n}\n"+r+"\nfor(i=_n-1;i!==-1;--i) {\n    "+n+"\n}\nreturn ret;",Function.apply(null,o)},numeric.pointwise2=function e(t,n,r){void 0===r&&(r="");var i,a,o=[],s=/\[i\]$/,l="",c=!1;for(i=0;i<t.length;i++)s.test(t[i])?l=a=t[i].substring(0,t[i].length-3):a=t[i],"ret"===a&&(c=!0),o.push(a);return o[t.length]="var _n = "+l+".length;\nvar i"+(c?"":", ret = Array(_n)")+";\n"+r+"\nfor(i=_n-1;i!==-1;--i) {\n"+n+"\n}\nreturn ret;",Function.apply(null,o)},numeric._biforeach=function e(t,n,r,i,a){var o;if(i!==r.length-1)for(o=r[i]-1;o>=0;o--)e("object"==typeof t?t[o]:t,"object"==typeof n?n[o]:n,r,i+1,a);else a(t,n)},numeric._biforeach2=function e(t,n,r,i,a){if(i===r.length-1)return a(t,n);var o,s=r[i],l=Array(s);for(o=s-1;o>=0;--o)l[o]=e("object"==typeof t?t[o]:t,"object"==typeof n?n[o]:n,r,i+1,a);return l},numeric._foreach=function e(t,n,r,i){var a;if(r!==n.length-1)for(a=n[r]-1;a>=0;a--)e(t[a],n,r+1,i);else i(t)},numeric._foreach2=function e(t,n,r,i){if(r===n.length-1)return i(t);var a,o=n[r],s=Array(o);for(a=o-1;a>=0;a--)s[a]=e(t[a],n,r+1,i);return s},numeric.ops2={add:"+",sub:"-",mul:"*",div:"/",mod:"%",and:"&&",or:"||",eq:"===",neq:"!==",lt:"<",gt:">",leq:"<=",geq:">=",band:"&",bor:"|",bxor:"^",lshift:"<<",rshift:">>",rrshift:">>>"},numeric.opseq={addeq:"+=",subeq:"-=",muleq:"*=",diveq:"/=",modeq:"%=",lshifteq:"<<=",rshifteq:">>=",rrshifteq:">>>=",bandeq:"&=",boreq:"|=",bxoreq:"^="},numeric.mathfuns=["abs","acos","asin","atan","ceil","cos","exp","floor","log","round","sin","sqrt","tan","isNaN","isFinite"],numeric.mathfuns2=["atan2","pow","max","min"],numeric.ops1={neg:"-",not:"!",bnot:"~",clone:""},numeric.mapreducers={any:["if(xi) return true;","var accum = false;"],all:["if(!xi) return false;","var accum = true;"],sum:["accum += xi;","var accum = 0;"],prod:["accum *= xi;","var accum = 1;"],norm2Squared:["accum += xi*xi;","var accum = 0;"],norminf:["accum = max(accum,abs(xi));","var accum = 0, max = Math.max, abs = Math.abs;"],norm1:["accum += abs(xi)","var accum = 0, abs = Math.abs;"],sup:["accum = max(accum,xi);","var accum = -Infinity, max = Math.max;"],inf:["accum = min(accum,xi);","var accum = Infinity, min = Math.min;"]},(function(){var e,t;for(e=0;e<numeric.mathfuns2.length;++e)numeric.ops2[t=numeric.mathfuns2[e]]=t;for(e in numeric.ops2)if(numeric.ops2.hasOwnProperty(e)){t=numeric.ops2[e];var n,r,i="";-1!==numeric.myIndexOf.call(numeric.mathfuns2,e)?(i="var "+t+" = Math."+t+";\n",n=function(e,n,r){return e+" = "+t+"("+n+","+r+")"},r=function(e,n){return e+" = "+t+"("+e+","+n+")"}):(n=function(e,n,r){return e+" = "+n+" "+t+" "+r},r=numeric.opseq.hasOwnProperty(e+"eq")?function(e,n){return e+" "+t+"= "+n}:function(e,n){return e+" = "+e+" "+t+" "+n}),numeric[e+"VV"]=numeric.pointwise2(["x[i]","y[i]"],n("ret[i]","x[i]","y[i]"),i),numeric[e+"SV"]=numeric.pointwise2(["x","y[i]"],n("ret[i]","x","y[i]"),i),numeric[e+"VS"]=numeric.pointwise2(["x[i]","y"],n("ret[i]","x[i]","y"),i),numeric[e]=Function("var n = arguments.length, i, x = arguments[0], y;\nvar VV = numeric."+e+"VV, VS = numeric."+e+"VS, SV = numeric."+e+'SV;\nvar dim = numeric.dim;\nfor(i=1;i!==n;++i) { \n  y = arguments[i];\n  if(typeof x === "object") {\n      if(typeof y === "object") x = numeric._biforeach2(x,y,dim(x),0,VV);\n      else x = numeric._biforeach2(x,y,dim(x),0,VS);\n  } else if(typeof y === "object") x = numeric._biforeach2(x,y,dim(y),0,SV);\n  else '+r("x","y")+"\n}\nreturn x;\n"),numeric[t]=numeric[e],numeric[e+"eqV"]=numeric.pointwise2(["ret[i]","x[i]"],r("ret[i]","x[i]"),i),numeric[e+"eqS"]=numeric.pointwise2(["ret[i]","x"],r("ret[i]","x"),i),numeric[e+"eq"]=Function("var n = arguments.length, i, x = arguments[0], y;\nvar V = numeric."+e+"eqV, S = numeric."+e+'eqS\nvar s = numeric.dim(x);\nfor(i=1;i!==n;++i) { \n  y = arguments[i];\n  if(typeof y === "object") numeric._biforeach(x,y,s,0,V);\n  else numeric._biforeach(x,y,s,0,S);\n}\nreturn x;\n')}for(e=0;e<numeric.mathfuns2.length;++e)delete numeric.ops2[t=numeric.mathfuns2[e]];for(e=0;e<numeric.mathfuns.length;++e)numeric.ops1[t=numeric.mathfuns[e]]=t;for(e in numeric.ops1)numeric.ops1.hasOwnProperty(e)&&(i="",t=numeric.ops1[e],-1!==numeric.myIndexOf.call(numeric.mathfuns,e)&&Math.hasOwnProperty(t)&&(i="var "+t+" = Math."+t+";\n"),numeric[e+"eqV"]=numeric.pointwise2(["ret[i]"],"ret[i] = "+t+"(ret[i]);",i),numeric[e+"eq"]=Function("x",'if(typeof x !== "object") return '+t+"x\nvar i;\nvar V = numeric."+e+"eqV;\nvar s = numeric.dim(x);\nnumeric._foreach(x,s,0,V);\nreturn x;\n"),numeric[e+"V"]=numeric.pointwise2(["x[i]"],"ret[i] = "+t+"(x[i]);",i),numeric[e]=Function("x",'if(typeof x !== "object") return '+t+"(x)\nvar i;\nvar V = numeric."+e+"V;\nvar s = numeric.dim(x);\nreturn numeric._foreach2(x,s,0,V);\n"));for(e=0;e<numeric.mathfuns.length;++e)delete numeric.ops1[t=numeric.mathfuns[e]];for(e in numeric.mapreducers)numeric.mapreducers.hasOwnProperty(e)&&(numeric[e+"V"]=numeric.mapreduce2((t=numeric.mapreducers[e])[0],t[1]),numeric[e]=Function("x","s","k",t[1]+'if(typeof x !== "object") {    xi = x;\n'+t[0]+';\n    return accum;\n}if(typeof s === "undefined") s = numeric.dim(x);\nif(typeof k === "undefined") k = 0;\nif(k === s.length-1) return numeric.'+e+"V(x);\nvar xi;\nvar n = x.length, i;\nfor(i=n-1;i!==-1;--i) {\n   xi = arguments.callee(x[i]);\n"+t[0]+";\n}\nreturn accum;\n"))})(),numeric.truncVV=numeric.pointwise(["x[i]","y[i]"],"ret[i] = round(x[i]/y[i])*y[i];","var round = Math.round;"),numeric.truncVS=numeric.pointwise(["x[i]","y"],"ret[i] = round(x[i]/y)*y;","var round = Math.round;"),numeric.truncSV=numeric.pointwise(["x","y[i]"],"ret[i] = round(x/y[i])*y[i];","var round = Math.round;"),numeric.trunc=function e(t,n){return"object"==typeof t?"object"==typeof n?numeric.truncVV(t,n):numeric.truncVS(t,n):"object"==typeof n?numeric.truncSV(t,n):Math.round(t/n)*n},numeric.inv=function e(t){var n,r,i,a,o,s,l,c=numeric.dim(t),h=Math.abs,u=c[0],d=c[1],p=numeric.clone(t),m=numeric.identity(u);for(s=0;s<d;++s){var f=-1,g=-1;for(o=s;o!==u;++o)(l=h(p[o][s]))>g&&(f=o,g=l);for(r=p[f],p[f]=p[s],p[s]=r,a=m[f],m[f]=m[s],m[s]=a,t=r[s],l=s;l!==d;++l)r[l]/=t;for(l=d-1;-1!==l;--l)a[l]/=t;for(o=u-1;-1!==o;--o)if(o!==s){for(i=m[o],t=(n=p[o])[s],l=s+1;l!==d;++l)n[l]-=r[l]*t;for(l=d-1;l>0;--l)i[l]-=a[l]*t,i[--l]-=a[l]*t;0===l&&(i[0]-=a[0]*t)}}return m},numeric.det=function e(t){var n=numeric.dim(t);if(2!==n.length||n[0]!==n[1])throw new Error("numeric: det() only works on square matrices");var r,i,a,o,s,l,c,h,u=n[0],d=1,p=numeric.clone(t);for(i=0;i<u-1;i++){for(a=i,r=i+1;r<u;r++)Math.abs(p[r][i])>Math.abs(p[a][i])&&(a=r);for(a!==i&&(c=p[a],p[a]=p[i],p[i]=c,d*=-1),o=p[i],r=i+1;r<u;r++){for(l=(s=p[r])[i]/o[i],a=i+1;a<u-1;a+=2)h=a+1,s[a]-=o[a]*l,s[h]-=o[h]*l;a!==u&&(s[a]-=o[a]*l)}if(0===o[i])return 0;d*=o[i]}return d*p[i][i]},numeric.transpose=function e(t){var n,r,i,a,o,s=t.length,l=t[0].length,c=Array(l);for(r=0;r<l;r++)c[r]=Array(s);for(n=s-1;n>=1;n-=2){for(a=t[n],i=t[n-1],r=l-1;r>=1;--r)(o=c[r])[n]=a[r],o[n-1]=i[r],(o=c[--r])[n]=a[r],o[n-1]=i[r];0===r&&((o=c[0])[n]=a[0],o[n-1]=i[0])}if(0===n){for(i=t[0],r=l-1;r>=1;--r)c[r][0]=i[r],c[--r][0]=i[r];0===r&&(c[0][0]=i[0])}return c},numeric.negtranspose=function e(t){var n,r,i,a,o,s=t.length,l=t[0].length,c=Array(l);for(r=0;r<l;r++)c[r]=Array(s);for(n=s-1;n>=1;n-=2){for(a=t[n],i=t[n-1],r=l-1;r>=1;--r)(o=c[r])[n]=-a[r],o[n-1]=-i[r],(o=c[--r])[n]=-a[r],o[n-1]=-i[r];0===r&&((o=c[0])[n]=-a[0],o[n-1]=-i[0])}if(0===n){for(i=t[0],r=l-1;r>=1;--r)c[r][0]=-i[r],c[--r][0]=-i[r];0===r&&(c[0][0]=-i[0])}return c},numeric._random=function e(t,n){var r,i,a=t[n],o=Array(a);if(n===t.length-1){for(i=Math.random,r=a-1;r>=1;r-=2)o[r]=i(),o[r-1]=i();return 0===r&&(o[0]=i()),o}for(r=a-1;r>=0;r--)o[r]=e(t,n+1);return o},numeric.random=function e(t){return numeric._random(t,0)},numeric.norm2=function e(t){return Math.sqrt(numeric.norm2Squared(t))},numeric.linspace=function e(t,n,r){if(void 0===r&&(r=Math.max(Math.round(n-t)+1,1)),r<2)return 1===r?[t]:[];var i,a=Array(r);for(i=--r;i>=0;i--)a[i]=(i*n+(r-i)*t)/r;return a},numeric.getBlock=function e(t,n,r){var i=numeric.dim(t);return(function e(t,a){var o,s=n[a],l=r[a]-s,c=Array(l);if(a===i.length-1){for(o=l;o>=0;o--)c[o]=t[o+s];return c}for(o=l;o>=0;o--)c[o]=e(t[o+s],a+1);return c})(t,0)},numeric.setBlock=function e(t,n,r,i){var a=numeric.dim(t);return(function e(t,i,o){var s,l=n[o],c=r[o]-l;if(o===a.length-1)for(s=c;s>=0;s--)t[s+l]=i[s];for(s=c;s>=0;s--)e(t[s+l],i[s],o+1)})(t,i,0),t},numeric.getRange=function e(t,n,r){var i,a,o,s,l=n.length,c=r.length,h=Array(l);for(i=l-1;-1!==i;--i)for(h[i]=Array(c),o=h[i],s=t[n[i]],a=c-1;-1!==a;--a)o[a]=s[r[a]];return h},numeric.blockMatrix=function e(t){var n=numeric.dim(t);if(n.length<4)return numeric.blockMatrix([t]);var r,i,a,o,s,l=n[0],c=n[1];for(r=0,i=0,a=0;a<l;++a)r+=t[a][0].length;for(o=0;o<c;++o)i+=t[0][o][0].length;var h=Array(r);for(a=0;a<r;++a)h[a]=Array(i);var u,d,p,m,f,g=0;for(a=0;a<l;++a){for(u=i,o=c-1;-1!==o;--o)for(u-=(s=t[a][o])[0].length,p=s.length-1;-1!==p;--p)for(d=h[g+p],m=(f=s[p]).length-1;-1!==m;--m)d[u+m]=f[m];g+=t[a][0].length}return h},numeric.tensor=function e(t,n){if("number"==typeof t||"number"==typeof n)return numeric.mul(t,n);var r=numeric.dim(t),i=numeric.dim(n);if(1!==r.length||1!==i.length)throw new Error("numeric: tensor product is only defined for vectors");var a,o,s,l,c=r[0],h=i[0],u=Array(c);for(o=c-1;o>=0;o--){for(a=Array(h),l=t[o],s=h-1;s>=3;--s)a[s]=l*n[s],a[--s]=l*n[s],a[--s]=l*n[s],a[--s]=l*n[s];for(;s>=0;)a[s]=l*n[s],--s;u[o]=a}return u},numeric.T=function e(t,n){this.x=t,this.y=n},numeric.t=function e(t,n){return new numeric.T(t,n)},numeric.Tbinop=function e(t,n,r,i,a){var o;if("string"!=typeof a)for(o in a="",numeric)numeric.hasOwnProperty(o)&&(t.indexOf(o)>=0||n.indexOf(o)>=0||r.indexOf(o)>=0||i.indexOf(o)>=0)&&o.length>1&&(a+="var "+o+" = numeric."+o+";\n");return Function(["y"],"var x = this;\nif(!(y instanceof numeric.T)) { y = new numeric.T(y); }\n"+a+"\nif(x.y) {  if(y.y) {    return new numeric.T("+i+");\n  }\n  return new numeric.T("+r+");\n}\nif(y.y) {\n  return new numeric.T("+n+");\n}\nreturn new numeric.T("+t+");\n")},numeric.T.prototype.add=numeric.Tbinop("add(x.x,y.x)","add(x.x,y.x),y.y","add(x.x,y.x),x.y","add(x.x,y.x),add(x.y,y.y)"),numeric.T.prototype.sub=numeric.Tbinop("sub(x.x,y.x)","sub(x.x,y.x),neg(y.y)","sub(x.x,y.x),x.y","sub(x.x,y.x),sub(x.y,y.y)"),numeric.T.prototype.mul=numeric.Tbinop("mul(x.x,y.x)","mul(x.x,y.x),mul(x.x,y.y)","mul(x.x,y.x),mul(x.y,y.x)","sub(mul(x.x,y.x),mul(x.y,y.y)),add(mul(x.x,y.y),mul(x.y,y.x))"),numeric.T.prototype.reciprocal=function e(){var t=numeric.mul,n=numeric.div;if(this.y){var r=numeric.add(t(this.x,this.x),t(this.y,this.y));return new numeric.T(n(this.x,r),n(numeric.neg(this.y),r))}return new T(n(1,this.x))},numeric.T.prototype.div=function e(t){if(t instanceof numeric.T||(t=new numeric.T(t)),t.y)return this.mul(t.reciprocal());var e=numeric.div;return this.y?new numeric.T(e(this.x,t.x),e(this.y,t.x)):new numeric.T(e(this.x,t.x))},numeric.T.prototype.dot=numeric.Tbinop("dot(x.x,y.x)","dot(x.x,y.x),dot(x.x,y.y)","dot(x.x,y.x),dot(x.y,y.x)","sub(dot(x.x,y.x),dot(x.y,y.y)),add(dot(x.x,y.y),dot(x.y,y.x))"),numeric.T.prototype.transpose=function e(){var t=numeric.transpose,n=this.x,r=this.y;return r?new numeric.T(t(n),t(r)):new numeric.T(t(n))},numeric.T.prototype.transjugate=function e(){var t=numeric.transpose,n=this.x,r=this.y;return r?new numeric.T(t(n),numeric.negtranspose(r)):new numeric.T(t(n))},numeric.Tunop=function e(t,n,r){return"string"!=typeof r&&(r=""),Function("var x = this;\n"+r+"\nif(x.y) {  "+n+";\n}\n"+t+";\n")},numeric.T.prototype.exp=numeric.Tunop("return new numeric.T(ex)","return new numeric.T(mul(cos(x.y),ex),mul(sin(x.y),ex))","var ex = numeric.exp(x.x), cos = numeric.cos, sin = numeric.sin, mul = numeric.mul;"),numeric.T.prototype.conj=numeric.Tunop("return new numeric.T(x.x);","return new numeric.T(x.x,numeric.neg(x.y));"),numeric.T.prototype.neg=numeric.Tunop("return new numeric.T(neg(x.x));","return new numeric.T(neg(x.x),neg(x.y));","var neg = numeric.neg;"),numeric.T.prototype.sin=numeric.Tunop("return new numeric.T(numeric.sin(x.x))","return x.exp().sub(x.neg().exp()).div(new numeric.T(0,2));"),numeric.T.prototype.cos=numeric.Tunop("return new numeric.T(numeric.cos(x.x))","return x.exp().add(x.neg().exp()).div(2);"),numeric.T.prototype.abs=numeric.Tunop("return new numeric.T(numeric.abs(x.x));","return new numeric.T(numeric.sqrt(numeric.add(mul(x.x,x.x),mul(x.y,x.y))));","var mul = numeric.mul;"),numeric.T.prototype.log=numeric.Tunop("return new numeric.T(numeric.log(x.x));","var theta = new numeric.T(numeric.atan2(x.y,x.x)), r = x.abs();\nreturn new numeric.T(numeric.log(r.x),theta.x);"),numeric.T.prototype.norm2=numeric.Tunop("return numeric.norm2(x.x);","var f = numeric.norm2Squared;\nreturn Math.sqrt(f(x.x)+f(x.y));"),numeric.T.prototype.inv=function e(){var t=this;if(void 0===t.y)return new numeric.T(numeric.inv(t.x));var n,r,i,a,o,s,l,c,h,u,d,p,m,f,g,v,y,_,b=t.x.length,x=numeric.identity(b),S=numeric.rep([b,b],0),w=numeric.clone(t.x),C=numeric.clone(t.y);for(h=0;h<b;h++){for(p=(f=w[h][h])*f+(g=C[h][h])*g,d=h,u=h+1;u<b;u++)(m=(f=w[u][h])*f+(g=C[u][h])*g)>p&&(d=u,p=m);for(d!==h&&(_=w[h],w[h]=w[d],w[d]=_,_=C[h],C[h]=C[d],C[d]=_,_=x[h],x[h]=x[d],x[d]=_,_=S[h],S[h]=S[d],S[d]=_),o=x[h],s=S[h],f=(n=w[h])[h],g=(r=C[h])[h],u=h+1;u<b;u++)n[u]=((v=n[u])*f+(y=r[u])*g)/p,r[u]=(y*f-v*g)/p;for(u=0;u<b;u++)o[u]=((v=o[u])*f+(y=s[u])*g)/p,s[u]=(y*f-v*g)/p;for(u=h+1;u<b;u++){for(l=x[u],c=S[u],f=(i=w[u])[h],g=(a=C[u])[h],d=h+1;d<b;d++)i[d]-=(v=n[d])*f-(y=r[d])*g,a[d]-=y*f+v*g;for(d=0;d<b;d++)l[d]-=(v=o[d])*f-(y=s[d])*g,c[d]-=y*f+v*g}}for(h=b-1;h>0;h--)for(o=x[h],s=S[h],u=h-1;u>=0;u--)for(l=x[u],c=S[u],f=w[u][h],g=C[u][h],d=b-1;d>=0;d--)l[d]-=f*(v=o[d])-g*(y=s[d]),c[d]-=f*y+g*v;return new numeric.T(x,S)},numeric.T.prototype.get=function e(t){var n,r=this.x,i=this.y,a=0,o=t.length;if(i){for(;a<o;)r=r[n=t[a]],i=i[n],a++;return new numeric.T(r,i)}for(;a<o;)r=r[n=t[a]],a++;return new numeric.T(r)},numeric.T.prototype.set=function e(t,n){var r,i=this.x,a=this.y,o=0,s=t.length,l=n.x,c=n.y;if(0===s)return c?this.y=c:a&&(this.y=void 0),this.x=i,this;if(c){for(a||(a=numeric.rep(numeric.dim(i),0),this.y=a);o<s-1;)i=i[r=t[o]],a=a[r],o++;return i[r=t[o]]=l,a[r]=c,this}if(a){for(;o<s-1;)i=i[r=t[o]],a=a[r],o++;return i[r=t[o]]=l,a[r]=l instanceof Array?numeric.rep(numeric.dim(l),0):0,this}for(;o<s-1;)i=i[r=t[o]],o++;return i[r=t[o]]=l,this},numeric.T.prototype.getRows=function e(t,n){var r,i,a=n-t+1,o=Array(a),s=this.x,l=this.y;for(r=t;r<=n;r++)o[r-t]=s[r];if(l){for(i=Array(a),r=t;r<=n;r++)i[r-t]=l[r];return new numeric.T(o,i)}return new numeric.T(o)},numeric.T.prototype.setRows=function e(t,n,r){var i,a=this.x,o=this.y,s=r.x,l=r.y;for(i=t;i<=n;i++)a[i]=s[i-t];if(l)for(o||(o=numeric.rep(numeric.dim(a),0),this.y=o),i=t;i<=n;i++)o[i]=l[i-t];else if(o)for(i=t;i<=n;i++)o[i]=numeric.rep([s[i-t].length],0);return this},numeric.T.prototype.getRow=function e(t){var n=this.x,r=this.y;return r?new numeric.T(n[t],r[t]):new numeric.T(n[t])},numeric.T.prototype.setRow=function e(t,n){var r=this.x,i=this.y,a=n.x,o=n.y;return r[t]=a,o?(i||(i=numeric.rep(numeric.dim(r),0),this.y=i),i[t]=o):i&&(i=numeric.rep([a.length],0)),this},numeric.T.prototype.getBlock=function e(t,n){var r=this.x,i=this.y,a=numeric.getBlock;return i?new numeric.T(a(r,t,n),a(i,t,n)):new numeric.T(a(r,t,n))},numeric.T.prototype.setBlock=function e(t,n,r){r instanceof numeric.T||(r=new numeric.T(r));var i=this.x,a=this.y,o=numeric.setBlock,s=r.x,l=r.y;if(l)return a||(this.y=numeric.rep(numeric.dim(this),0),a=this.y),o(i,t,n,s),o(a,t,n,l),this;o(i,t,n,s),a&&o(a,t,n,numeric.rep(numeric.dim(s),0))},numeric.T.rep=function e(t,n){var r=numeric.T;n instanceof r||(n=new r(n));var i=n.x,a=n.y,o=numeric.rep;return a?new r(o(t,i),o(t,a)):new r(o(t,i))},numeric.T.diag=function e(t){t instanceof numeric.T||(t=new numeric.T(t));var n=t.x,r=t.y,e=numeric.diag;return r?new numeric.T(e(n),e(r)):new numeric.T(e(n))},numeric.T.eig=function e(){if(this.y)throw new Error("eig: not implemented for complex matrices.");return numeric.eig(this.x)},numeric.T.identity=function e(t){return new numeric.T(numeric.identity(t))},numeric.T.prototype.getDiag=function e(){var t=numeric,n=this.x,r=this.y;return r?new t.T(t.getDiag(n),t.getDiag(r)):new t.T(t.getDiag(n))},numeric.house=function e(t){var n=numeric.clone(t),r=(t[0]>=0?1:-1)*numeric.norm2(t);n[0]+=r;var i=numeric.norm2(n);if(0===i)throw new Error("eig: internal error");return numeric.div(n,i)},numeric.toUpperHessenberg=function e(t){var n=numeric.dim(t);if(2!==n.length||n[0]!==n[1])throw new Error("numeric: toUpperHessenberg() only works on square matrices");var r,i,a,o,s,l,c,h,u,d,p=n[0],m=numeric.clone(t),f=numeric.identity(p);for(i=0;i<p-2;i++){for(o=Array(p-i-1),r=i+1;r<p;r++)o[r-i-1]=m[r][i];if(numeric.norm2(o)>0){for(s=numeric.house(o),l=numeric.getBlock(m,[i+1,i],[p-1,p-1]),c=numeric.tensor(s,numeric.dot(s,l)),r=i+1;r<p;r++)for(h=m[r],u=c[r-i-1],a=i;a<p;a++)h[a]-=2*u[a-i];for(l=numeric.getBlock(m,[0,i+1],[p-1,p-1]),c=numeric.tensor(numeric.dot(l,s),s),r=0;r<p;r++)for(h=m[r],u=c[r],a=i+1;a<p;a++)h[a]-=2*u[a-i-1];for(l=Array(p-i-1),r=i+1;r<p;r++)l[r-i-1]=f[r];for(c=numeric.tensor(s,numeric.dot(s,l)),r=i+1;r<p;r++)for(d=f[r],u=c[r-i-1],a=0;a<p;a++)d[a]-=2*u[a]}}return{H:m,Q:f}},numeric.epsilon=2220446049250313e-31,numeric.QRFrancis=function(e,t){void 0===t&&(t=1e4),e=numeric.clone(e),numeric.clone(e);var n,r,i,a,o,s,l,c,h,u,d,p,m,f,g,v,y=numeric.dim(e)[0],_=numeric.identity(y);if(y<3)return{Q:_,B:[[0,y-1]]};var b=numeric.epsilon;for(v=0;v<t;v++){for(f=0;f<y-1;f++)if(Math.abs(e[f+1][f])<b*(Math.abs(e[f][f])+Math.abs(e[f+1][f+1]))){var x=numeric.QRFrancis(numeric.getBlock(e,[0,0],[f,f]),t),S=numeric.QRFrancis(numeric.getBlock(e,[f+1,f+1],[y-1,y-1]),t);for(u=Array(f+1),m=0;m<=f;m++)u[m]=_[m];for(d=numeric.dot(x.Q,u),m=0;m<=f;m++)_[m]=d[m];for(u=Array(y-f-1),m=f+1;m<y;m++)u[m-f-1]=_[m];for(d=numeric.dot(S.Q,u),m=f+1;m<y;m++)_[m]=d[m-f-1];return{Q:_,B:x.B.concat(numeric.add(S.B,f+1))}}var w,C,M;if(s=(i=e[y-2][y-2])+(a=e[y-1][y-1]),o=i*a-e[y-2][y-1]*e[y-1][y-2],l=numeric.getBlock(e,[0,0],[2,2]),s*s>=4*o)w=.5*(s+Math.sqrt(s*s-4*o)),C=.5*(s-Math.sqrt(s*s-4*o)),l=numeric.add(numeric.sub(numeric.dot(l,l),numeric.mul(l,w+C)),numeric.diag(numeric.rep([3],w*C)));else l=numeric.add(numeric.sub(numeric.dot(l,l),numeric.mul(l,s)),numeric.diag(numeric.rep([3],o)));for(r=numeric.house(n=[l[0][0],l[1][0],l[2][0]]),d=numeric.tensor(r,numeric.dot(r,u=[e[0],e[1],e[2]])),m=0;m<3;m++)for(h=e[m],p=d[m],g=0;g<y;g++)h[g]-=2*p[g];for(u=numeric.getBlock(e,[0,0],[y-1,2]),d=numeric.tensor(numeric.dot(u,r),r),m=0;m<y;m++)for(h=e[m],p=d[m],g=0;g<3;g++)h[g]-=2*p[g];for(d=numeric.tensor(r,numeric.dot(r,u=[_[0],_[1],_[2]])),m=0;m<3;m++)for(c=_[m],p=d[m],g=0;g<y;g++)c[g]-=2*p[g];for(f=0;f<y-2;f++){for(g=f;g<=f+1;g++)if(Math.abs(e[g+1][g])<b*(Math.abs(e[g][g])+Math.abs(e[g+1][g+1]))){x=numeric.QRFrancis(numeric.getBlock(e,[0,0],[g,g]),t),S=numeric.QRFrancis(numeric.getBlock(e,[g+1,g+1],[y-1,y-1]),t);for(u=Array(g+1),m=0;m<=g;m++)u[m]=_[m];for(d=numeric.dot(x.Q,u),m=0;m<=g;m++)_[m]=d[m];for(u=Array(y-g-1),m=g+1;m<y;m++)u[m-g-1]=_[m];for(d=numeric.dot(S.Q,u),m=g+1;m<y;m++)_[m]=d[m-g-1];return{Q:_,B:x.B.concat(numeric.add(S.B,g+1))}}for(M=Math.min(y-1,f+3),n=Array(M-f),m=f+1;m<=M;m++)n[m-f-1]=e[m][f];for(r=numeric.house(n),u=numeric.getBlock(e,[f+1,f],[M,y-1]),d=numeric.tensor(r,numeric.dot(r,u)),m=f+1;m<=M;m++)for(h=e[m],p=d[m-f-1],g=f;g<y;g++)h[g]-=2*p[g-f];for(u=numeric.getBlock(e,[0,f+1],[y-1,M]),d=numeric.tensor(numeric.dot(u,r),r),m=0;m<y;m++)for(h=e[m],p=d[m],g=f+1;g<=M;g++)h[g]-=2*p[g-f-1];for(u=Array(M-f),m=f+1;m<=M;m++)u[m-f-1]=_[m];for(d=numeric.tensor(r,numeric.dot(r,u)),m=f+1;m<=M;m++)for(c=_[m],p=d[m-f-1],g=0;g<y;g++)c[g]-=2*p[g]}}throw new Error("numeric: eigenvalue iteration does not converge -- increase maxiter?")},numeric.eig=function e(t,n){var r,i,a,o,s,l,c,h,u,d,p,m,f,g,v,y,_=numeric.toUpperHessenberg(t),b=numeric.QRFrancis(_.H,n),x=numeric.T,S=t.length,w=b.B,C=numeric.dot(b.Q,numeric.dot(_.H,numeric.transpose(b.Q))),M=new x(numeric.dot(b.Q,_.Q)),E=w.length,T=Math.sqrt;for(i=0;i<E;i++)if((r=w[i][0])===w[i][1]);else{if(s=C[r][r],c=C[o=r+1][r],h=C[o][o],0===(l=C[r][o])&&0===c)continue;(d=(u=-s-h)*u-4*(s*h-l*c))>=0?((v=(s-(p=u<0?-.5*(u-T(d)):-.5*(u+T(d))))*(s-p)+l*l)>(y=c*c+(h-p)*(h-p))?(f=(s-p)/(v=T(v)),g=l/v):(f=c/(y=T(y)),g=(h-p)/y),a=new x([[g,-f],[f,g]]),M.setRows(r,o,a.dot(M.getRows(r,o)))):(p=-.5*u,m=.5*T(-d),(v=(s-p)*(s-p)+l*l)>(y=c*c+(h-p)*(h-p))?(f=(s-p)/(v=T(v+m*m)),g=l/v,p=0,m/=v):(f=c/(y=T(y+m*m)),g=(h-p)/y,p=m/y,m=0),a=new x([[g,-f],[f,g]],[[p,m],[m,-p]]),M.setRows(r,o,a.dot(M.getRows(r,o))))}var I=M.dot(t).dot(M.transjugate()),A=numeric.T.identity(S=t.length);for(o=0;o<S;o++)if(o>0)for(i=o-1;i>=0;i--){var k=I.get([i,i]),P=I.get([o,o]);numeric.neq(k.x,P.x)||numeric.neq(k.y,P.y)?(p=I.getRow(i).getBlock([i],[o-1]),m=A.getRow(o).getBlock([i],[o-1]),A.set([o,i],I.get([i,o]).neg().sub(p.dot(m)).div(k.sub(P)))):A.setRow(o,A.getRow(i))}for(o=0;o<S;o++)p=A.getRow(o),A.setRow(o,p.div(p.norm2()));return A=A.transpose(),A=M.transjugate().dot(A),{lambda:I.getDiag(),E:A}},numeric.ccsSparse=function e(t){var n,r,i,a=t.length,o=[];for(r=a-1;-1!==r;--r)for(i in n=t[r]){for(i=parseInt(i);i>=o.length;)o[o.length]=0;0!==n[i]&&o[i]++}var s=o.length,l=Array(s+1);for(l[0]=0,r=0;r<s;++r)l[r+1]=l[r]+o[r];var c=Array(l[s]),h=Array(l[s]);for(r=a-1;-1!==r;--r)for(i in n=t[r])0!==n[i]&&(o[i]--,c[l[i]+o[i]]=r,h[l[i]+o[i]]=n[i]);return[l,c,h]},numeric.ccsFull=function e(t){var n,r,i,a=t[0],o=t[1],s=t[2],l=numeric.ccsDim(t),c=l[1],h=numeric.rep([l[0],c],0);for(n=0;n<c;n++)for(i=a[n+1],r=a[n];r<i;++r)h[o[r]][n]=s[r];return h},numeric.ccsTSolve=function e(t,n,r,i,a){var o,s,l,c,h,u,d,p=t[0],m=t[1],f=t[2],g=Math.max,v=0;function y(e){var t;if(0===r[e]){for(r[e]=1,t=p[e];t<p[e+1];++t)y(m[t]);a[v]=e,++v}}for(void 0===i&&(r=numeric.rep([p.length-1],0)),void 0===i&&(i=numeric.linspace(0,r.length-1)),void 0===a&&(a=[]),o=i.length-1;-1!==o;--o)y(i[o]);for(a.length=v,o=a.length-1;-1!==o;--o)r[a[o]]=0;for(o=i.length-1;-1!==o;--o)r[s=i[o]]=n[s];for(o=a.length-1;-1!==o;--o){for(c=g(p[(s=a[o])+1],l=p[s]),h=l;h!==c;++h)if(m[h]===s){r[s]/=f[h];break}for(d=r[s],h=l;h!==c;++h)(u=m[h])!==s&&(r[u]-=d*f[h])}return r},numeric.ccsDFS=function e(t){this.k=Array(t),this.k1=Array(t),this.j=Array(t)},numeric.ccsDFS.prototype.dfs=function e(t,n,r,i,a,o){var s,l,c,h=0,u=a.length,d=this.k,p=this.k1,m=this.j;if(0===i[t])for(i[t]=1,m[0]=t,d[0]=l=n[t],p[0]=c=n[t+1];;)if(l>=c){if(a[u]=m[h],0===h)return;++u,l=d[--h],c=p[h]}else 0===i[s=o[r[l]]]?(i[s]=1,d[h]=l,m[++h]=s,l=n[s],p[h]=c=n[s+1]):++l},numeric.ccsLPSolve=function e(t,n,r,i,a,o,s){var l,c,h,u,d,p,m,f,g,v=t[0],y=t[1],_=t[2],b=n[0],x=n[1],S=n[2];for(c=b[a],h=b[a+1],i.length=0,l=c;l<h;++l)s.dfs(o[x[l]],v,y,r,i,o);for(l=i.length-1;-1!==l;--l)r[i[l]]=0;for(l=c;l!==h;++l)r[u=o[x[l]]]=S[l];for(l=i.length-1;-1!==l;--l){for(p=v[(u=i[l])+1],m=d=v[u];m<p;++m)if(o[y[m]]===u){r[u]/=_[m];break}for(g=r[u],m=d;m<p;++m)(f=o[y[m]])!==u&&(r[f]-=g*_[m])}return r},numeric.ccsLUP1=function e(t,n){var r,i,a,o,s,l,c,h=t[0].length-1,u=[numeric.rep([h+1],0),[],[]],d=[numeric.rep([h+1],0),[],[]],p=u[0],m=u[1],f=u[2],g=d[0],v=d[1],y=d[2],_=numeric.rep([h],0),b=numeric.rep([h],0),x=numeric.ccsLPSolve,S=Math.abs,w=numeric.linspace(0,h-1),C=numeric.linspace(0,h-1),M=new numeric.ccsDFS(h);for(void 0===n&&(n=1),r=0;r<h;++r){for(x(u,t,_,b,r,C,M),o=-1,s=-1,i=b.length-1;-1!==i;--i)(a=b[i])<=r||(l=S(_[a]))>o&&(s=a,o=l);for(S(_[r])<n*o&&(i=w[r],w[r]=o=w[s],C[o]=r,w[s]=i,C[i]=s,o=_[r],_[r]=_[s],_[s]=o),s=g[r],c=_[r],m[o=p[r]]=w[r],f[o]=1,++o,i=b.length-1;-1!==i;--i)l=_[a=b[i]],b[i]=0,_[a]=0,a<=r?(v[s]=a,y[s]=l,++s):(m[o]=w[a],f[o]=l/c,++o);p[r+1]=o,g[r+1]=s}for(i=m.length-1;-1!==i;--i)m[i]=C[m[i]];return{L:u,U:d,P:w,Pinv:C}},numeric.ccsDFS0=function e(t){this.k=Array(t),this.k1=Array(t),this.j=Array(t)},numeric.ccsDFS0.prototype.dfs=function e(t,n,r,i,a,o,s){var l,c,h,u=0,d=a.length,p=this.k,m=this.k1,f=this.j;if(0===i[t])for(i[t]=1,f[0]=t,p[0]=c=n[o[t]],m[0]=h=n[o[t]+1];;){if(isNaN(c))throw new Error("Ow!");if(c>=h){if(a[d]=o[f[u]],0===u)return;++d,c=p[--u],h=m[u]}else 0===i[l=r[c]]?(i[l]=1,p[u]=c,f[++u]=l,c=n[l=o[l]],m[u]=h=n[l+1]):++c}},numeric.ccsLPSolve0=function e(t,n,r,i,a,o,s,l){var c,h,u,d,p,m,f,g,v,y=t[0],_=t[1],b=t[2],x=n[0],S=n[1],w=n[2];for(h=x[a],u=x[a+1],i.length=0,c=h;c<u;++c)l.dfs(S[c],y,_,r,i,o,s);for(c=i.length-1;-1!==c;--c)r[s[d=i[c]]]=0;for(c=h;c!==u;++c)r[d=S[c]]=w[c];for(c=i.length-1;-1!==c;--c){for(g=s[d=i[c]],m=y[d+1],f=p=y[d];f<m;++f)if(_[f]===g){r[g]/=b[f];break}for(v=r[g],f=p;f<m;++f)r[_[f]]-=v*b[f];r[g]=v}},numeric.ccsLUP0=function e(t,n){var r,i,a,o,s,l,c,h=t[0].length-1,u=[numeric.rep([h+1],0),[],[]],d=[numeric.rep([h+1],0),[],[]],p=u[0],m=u[1],f=u[2],g=d[0],v=d[1],y=d[2],_=numeric.rep([h],0),b=numeric.rep([h],0),x=numeric.ccsLPSolve0,S=Math.abs,w=numeric.linspace(0,h-1),C=numeric.linspace(0,h-1),M=new numeric.ccsDFS0(h);for(void 0===n&&(n=1),r=0;r<h;++r){for(x(u,t,_,b,r,C,w,M),o=-1,s=-1,i=b.length-1;-1!==i;--i)(a=b[i])<=r||(l=S(_[w[a]]))>o&&(s=a,o=l);for(S(_[w[r]])<n*o&&(i=w[r],w[r]=o=w[s],C[o]=r,w[s]=i,C[i]=s),s=g[r],c=_[w[r]],m[o=p[r]]=w[r],f[o]=1,++o,i=b.length-1;-1!==i;--i)l=_[w[a=b[i]]],b[i]=0,_[w[a]]=0,a<=r?(v[s]=a,y[s]=l,++s):(m[o]=w[a],f[o]=l/c,++o);p[r+1]=o,g[r+1]=s}for(i=m.length-1;-1!==i;--i)m[i]=C[m[i]];return{L:u,U:d,P:w,Pinv:C}},numeric.ccsLUP=numeric.ccsLUP0,numeric.ccsDim=function e(t){return[numeric.sup(t[1])+1,t[0].length-1]},numeric.ccsGetBlock=function e(t,n,r){var i=numeric.ccsDim(t),a=i[0],o=i[1];void 0===n?n=numeric.linspace(0,a-1):"number"==typeof n&&(n=[n]),void 0===r?r=numeric.linspace(0,o-1):"number"==typeof r&&(r=[r]);var s,l,c,h,u=n.length,d=r.length,p=numeric.rep([o],0),m=[],f=[],g=[p,m,f],v=t[0],y=t[1],_=t[2],b=numeric.rep([a],0),x=0,S=numeric.rep([a],0);for(l=0;l<d;++l){var w=v[h=r[l]],C=v[h+1];for(s=w;s<C;++s)S[c=y[s]]=1,b[c]=_[s];for(s=0;s<u;++s)S[n[s]]&&(m[x]=s,f[x]=b[n[s]],++x);for(s=w;s<C;++s)S[c=y[s]]=0;p[l+1]=x}return g},numeric.ccsDot=function e(t,n){var r,i,a,o,s,l,c,h,u,d,p=t[0],m=t[1],f=t[2],g=n[0],v=n[1],y=n[2],_=numeric.ccsDim(t),b=numeric.ccsDim(n),x=_[0],S=b[1],w=numeric.rep([x],0),C=numeric.rep([x],0),M=Array(x),E=numeric.rep([S],0),T=[],I=[],A=[E,T,I];for(a=0;a!==S;++a){for(s=g[a+1],h=0,i=o=g[a];i<s;++i)for(d=y[i],l=p[(u=v[i])+1],r=p[u];r<l;++r)0===C[c=m[r]]&&(M[h]=c,C[c]=1,h+=1),w[c]=w[c]+f[r]*d;for(E[a+1]=s=(o=E[a])+h,i=h-1;-1!==i;--i)T[d=o+i]=r=M[i],I[d]=w[r],C[r]=0,w[r]=0;E[a+1]=E[a]+h}return A},numeric.ccsLUPSolve=function e(t,n){var r=t.L,i=t.U,a=n[0],o=!1;"object"!=typeof a&&(a=(n=[[0,n.length],numeric.linspace(0,n.length-1),n])[0],o=!0);var s,l,c,h,u,d=n[1],p=n[2],m=r[0].length-1,f=a.length-1,g=numeric.rep([m],0),v=Array(m),y=numeric.rep([m],0),_=Array(m),b=numeric.rep([f+1],0),x=[],S=[],w=numeric.ccsTSolve,C=0;for(s=0;s<f;++s){for(h=0,c=a[s+1],l=a[s];l<c;++l)_[h]=u=t.Pinv[d[l]],y[u]=p[l],++h;for(_.length=h,w(r,y,g,_,v),l=_.length-1;-1!==l;--l)y[_[l]]=0;if(w(i,g,y,v,_),o)return y;for(l=v.length-1;-1!==l;--l)g[v[l]]=0;for(l=_.length-1;-1!==l;--l)x[C]=u=_[l],S[C]=y[u],y[u]=0,++C;b[s+1]=C}return[b,x,S]},numeric.ccsbinop=function e(t,n){return void 0===n&&(n=""),Function("X","Y","var Xi = X[0], Xj = X[1], Xv = X[2];\nvar Yi = Y[0], Yj = Y[1], Yv = Y[2];\nvar n = Xi.length-1,m = Math.max(numeric.sup(Xj),numeric.sup(Yj))+1;\nvar Zi = numeric.rep([n+1],0), Zj = [], Zv = [];\nvar x = numeric.rep([m],0),y = numeric.rep([m],0);\nvar xk,yk,zk;\nvar i,j,j0,j1,k,p=0;\n"+n+"for(i=0;i<n;++i) {\n  j0 = Xi[i]; j1 = Xi[i+1];\n  for(j=j0;j!==j1;++j) {\n    k = Xj[j];\n    x[k] = 1;\n    Zj[p] = k;\n    ++p;\n  }\n  j0 = Yi[i]; j1 = Yi[i+1];\n  for(j=j0;j!==j1;++j) {\n    k = Yj[j];\n    y[k] = Yv[j];\n    if(x[k] === 0) {\n      Zj[p] = k;\n      ++p;\n    }\n  }\n  Zi[i+1] = p;\n  j0 = Xi[i]; j1 = Xi[i+1];\n  for(j=j0;j!==j1;++j) x[Xj[j]] = Xv[j];\n  j0 = Zi[i]; j1 = Zi[i+1];\n  for(j=j0;j!==j1;++j) {\n    k = Zj[j];\n    xk = x[k];\n    yk = y[k];\n"+t+"\n    Zv[j] = zk;\n  }\n  j0 = Xi[i]; j1 = Xi[i+1];\n  for(j=j0;j!==j1;++j) x[Xj[j]] = 0;\n  j0 = Yi[i]; j1 = Yi[i+1];\n  for(j=j0;j!==j1;++j) y[Yj[j]] = 0;\n}\nreturn [Zi,Zj,Zv];")},(function(){var k,A,B,C;for(k in numeric.ops2)A=isFinite(eval("1"+numeric.ops2[k]+"0"))?"[Y[0],Y[1],numeric."+k+"(X,Y[2])]":"NaN",B=isFinite(eval("0"+numeric.ops2[k]+"1"))?"[X[0],X[1],numeric."+k+"(X[2],Y)]":"NaN",C=isFinite(eval("1"+numeric.ops2[k]+"0"))&&isFinite(eval("0"+numeric.ops2[k]+"1"))?"numeric.ccs"+k+"MM(X,Y)":"NaN",numeric["ccs"+k+"MM"]=numeric.ccsbinop("zk = xk "+numeric.ops2[k]+"yk;"),numeric["ccs"+k]=Function("X","Y",'if(typeof X === "number") return '+A+';\nif(typeof Y === "number") return '+B+";\nreturn "+C+";\n")})(),numeric.ccsScatter=function e(t){var n,r=t[0],i=t[1],a=t[2],o=numeric.sup(i)+1,s=r.length,l=numeric.rep([o],0),c=Array(s),h=Array(s),u=numeric.rep([o],0);for(n=0;n<s;++n)u[i[n]]++;for(n=0;n<o;++n)l[n+1]=l[n]+u[n];var d,p,m=l.slice(0);for(n=0;n<s;++n)c[d=m[p=i[n]]]=r[n],h[d]=a[n],m[p]=m[p]+1;return[l,c,h]},numeric.ccsGather=function e(t){var n,r,i,a,o=t[0],s=t[1],l=t[2],c=o.length-1,h=s.length,u=Array(h),d=Array(h),p=Array(h);for(a=0,n=0;n<c;++n)for(i=o[n+1],r=o[n];r!==i;++r)d[a]=n,u[a]=s[r],p[a]=l[r],++a;return[u,d,p]},numeric.sdim=function e(t,n,r){if(void 0===n&&(n=[]),"object"!=typeof t)return n;var i;for(i in void 0===r&&(r=0),r in n||(n[r]=0),t.length>n[r]&&(n[r]=t.length),t)t.hasOwnProperty(i)&&e(t[i],n,r+1);return n},numeric.sclone=function e(t,n,r){void 0===n&&(n=0),void 0===r&&(r=numeric.sdim(t).length);var i,a=Array(t.length);if(n===r-1){for(i in t)t.hasOwnProperty(i)&&(a[i]=t[i]);return a}for(i in t)t.hasOwnProperty(i)&&(a[i]=e(t[i],n+1,r));return a},numeric.sdiag=function e(t){var n,r,i=t.length,a=Array(i);for(n=i-1;n>=1;n-=2)r=n-1,a[n]=[],a[n][n]=t[n],a[r]=[],a[r][r]=t[r];return 0===n&&(a[0]=[],a[0][0]=t[n]),a},numeric.sidentity=function e(t){return numeric.sdiag(numeric.rep([t],1))},numeric.stranspose=function e(t){var n,r,i,a=[];for(n in t)if(t.hasOwnProperty(n))for(r in i=t[n])i.hasOwnProperty(r)&&("object"!=typeof a[r]&&(a[r]=[]),a[r][n]=i[r]);return a},numeric.sLUP=function e(t,n){throw new Error("The function numeric.sLUP had a bug in it and has been removed. Please use the new numeric.ccsLUP function instead.")},numeric.sdotMM=function e(t,n){var r,i,a,o,s,l,c,h=t.length,u=numeric.stranspose(n),d=u.length,p=Array(h);for(a=h-1;a>=0;a--){for(c=[],r=t[a],s=d-1;s>=0;s--){for(o in l=0,i=u[s],r)r.hasOwnProperty(o)&&o in i&&(l+=r[o]*i[o]);l&&(c[s]=l)}p[a]=c}return p},numeric.sdotMV=function e(t,n){var r,i,a,o,s=t.length,l=Array(s);for(i=s-1;i>=0;i--){for(a in o=0,r=t[i])r.hasOwnProperty(a)&&n[a]&&(o+=r[a]*n[a]);o&&(l[i]=o)}return l},numeric.sdotVM=function e(t,n){var r,i,a,o,s=[];for(r in t)if(t.hasOwnProperty(r))for(i in o=t[r],a=n[r])a.hasOwnProperty(i)&&(s[i]||(s[i]=0),s[i]+=o*a[i]);return s},numeric.sdotVV=function e(t,n){var r,i=0;for(r in t)t[r]&&n[r]&&(i+=t[r]*n[r]);return i},numeric.sdot=function e(t,n){var r=numeric.sdim(t).length,i=numeric.sdim(n).length;switch(1e3*r+i){case 0:return t*n;case 1001:return numeric.sdotVV(t,n);case 2001:return numeric.sdotMV(t,n);case 1002:return numeric.sdotVM(t,n);case 2002:return numeric.sdotMM(t,n);default:throw new Error("numeric.sdot not implemented for tensors of order "+r+" and "+i)}},numeric.sscatter=function e(t){var n,r,i,a,o=t.length,s=[];for(r=t[0].length-1;r>=0;--r)if(t[o-1][r]){for(a=s,i=0;i<o-2;i++)a[n=t[i][r]]||(a[n]=[]),a=a[n];a[t[i][r]]=t[i+1][r]}return s},numeric.sgather=function e(t,n,r){var i,a,o;for(a in void 0===n&&(n=[]),void 0===r&&(r=[]),i=r.length,t)if(t.hasOwnProperty(a))if(r[i]=parseInt(a),"number"==typeof(o=t[a])){if(o){if(0===n.length)for(a=i+1;a>=0;--a)n[a]=[];for(a=i;a>=0;--a)n[a].push(r[a]);n[i+1].push(o)}}else e(o,n,r);return r.length>i&&r.pop(),n},numeric.cLU=function e(t){var n,r,i,a,o,s,l=t[0],c=t[1],h=t[2],u=l.length,d=0;for(n=0;n<u;n++)l[n]>d&&(d=l[n]);d++;var p,m=Array(d),f=Array(d),g=numeric.rep([d],1/0),v=numeric.rep([d],-1/0);for(i=0;i<u;i++)(r=c[i])<g[n=l[i]]&&(g[n]=r),r>v[n]&&(v[n]=r);for(n=0;n<d-1;n++)v[n]>v[n+1]&&(v[n+1]=v[n]);for(n=d-1;n>=1;n--)g[n]<g[n-1]&&(g[n-1]=g[n]);for(n=0;n<d;n++)f[n]=numeric.rep([v[n]-g[n]+1],0),m[n]=numeric.rep([n-g[n]],0),n-g[n]+1,v[n]-n+1;for(i=0;i<u;i++)f[n=l[i]][c[i]-g[n]]=h[i];for(n=0;n<d-1;n++)for(a=n-g[n],b=f[n],r=n+1;g[r]<=n&&r<d;r++)if(s=v[n]-n,p=(x=f[r])[o=n-g[r]]/b[a]){for(i=1;i<=s;i++)x[i+o]-=p*b[i+a];m[r][n-g[r]]=p}var y,_,b=[],x=[],S=[],w=[],C=[],M=[];for(u=0,y=0,n=0;n<d;n++){for(a=g[n],o=v[n],_=f[n],r=n;r<=o;r++)_[r-a]&&(b[u]=n,x[u]=r,S[u]=_[r-a],u++);for(_=m[n],r=a;r<n;r++)_[r-a]&&(w[y]=n,C[y]=r,M[y]=_[r-a],y++);w[y]=n,C[y]=n,M[y]=1,y++}return{U:[b,x,S],L:[w,C,M]}},numeric.cLUsolve=function e(t,n){var r,i,a=t.L,o=t.U,s=numeric.clone(n),l=a[1],c=a[2],h=o[1],u=o[2],d=o[0].length,p=s.length;for(i=0,r=0;r<p;r++){for(;l[i]<r;)s[r]-=c[i]*s[l[i]],i++;i++}for(i=d-1,r=p-1;r>=0;r--){for(;h[i]>r;)s[r]-=u[i]*s[h[i]],i--;s[r]/=u[i],i--}return s},numeric.cgrid=function e(t,n){"number"==typeof t&&(t=[t,t]);var r,i,a,o=numeric.rep(t,-1);if("function"!=typeof n)switch(n){case"L":n=function(e,n){return e>=t[0]/2||n<t[1]/2};break;default:n=function(e,t){return!0}}for(a=0,r=1;r<t[0]-1;r++)for(i=1;i<t[1]-1;i++)n(r,i)&&(o[r][i]=a,a++);return o},numeric.cdelsq=function e(t){var n,r,i,a,o,s=[[-1,0],[0,-1],[0,1],[1,0]],l=numeric.dim(t),c=l[0],h=l[1],u=[],d=[],p=[];for(n=1;n<c-1;n++)for(r=1;r<h-1;r++)if(!(t[n][r]<0)){for(i=0;i<4;i++)t[a=n+s[i][0]][o=r+s[i][1]]<0||(u.push(t[n][r]),d.push(t[a][o]),p.push(-1));u.push(t[n][r]),d.push(t[n][r]),p.push(4)}return[u,d,p]},numeric.cdotMV=function e(t,n){var r,i,a,o=t[0],s=t[1],l=t[2],c=o.length;for(a=0,i=0;i<c;i++)o[i]>a&&(a=o[i]);for(a++,r=numeric.rep([a],0),i=0;i<c;i++)r[o[i]]+=l[i]*n[s[i]];return r},numeric.Spline=function e(t,n,r,i,a){this.x=t,this.yl=n,this.yr=r,this.kl=i,this.kr=a},numeric.Spline.prototype._at=function e(t,n){var r,i,a,o=this.x,s=this.yl,l=this.yr,c=this.kr,h=numeric.add,u=numeric.sub,d=numeric.mul;r=u(d(this.kl[n],o[n+1]-o[n]),u(l[n+1],s[n])),i=h(d(c[n+1],o[n]-o[n+1]),u(l[n+1],s[n]));var p=(a=(t-o[n])/(o[n+1]-o[n]))*(1-a);return h(h(h(d(1-a,s[n]),d(a,l[n+1])),d(r,p*(1-a))),d(i,p*a))},numeric.Spline.prototype.at=function e(t){if("number"==typeof t){var n,r,i,a=this.x,o=a.length,s=Math.floor;for(n=0,r=o-1;r-n>1;)a[i=s((n+r)/2)]<=t?n=i:r=i;return this._at(t,n)}o=t.length;var l,c=Array(o);for(l=o-1;-1!==l;--l)c[l]=this.at(t[l]);return c},numeric.Spline.prototype.diff=function e(){var t,n,r,i=this.x,a=this.yl,o=this.yr,s=this.kl,l=this.kr,c=a.length,h=s,u=l,d=Array(c),p=Array(c),m=numeric.add,f=numeric.mul,g=numeric.div,v=numeric.sub;for(t=c-1;-1!==t;--t)n=i[t+1]-i[t],r=v(o[t+1],a[t]),d[t]=g(m(f(r,6),f(s[t],-4*n),f(l[t+1],-2*n)),n*n),p[t+1]=g(m(f(r,-6),f(s[t],2*n),f(l[t+1],4*n)),n*n);return new numeric.Spline(i,h,u,d,p)},numeric.Spline.prototype.roots=function e(){function t(e){return e*e}var n=[],r=this.x,i=this.yl,a=this.yr,o=this.kl,s=this.kr;"number"==typeof i[0]&&(i=[i],a=[a],o=[o],s=[s]);var l,c,h,u,d,p,m,f,g,v,y,_,b,x,S,w,C,M,E,T,I,A,k,P=i.length,R=r.length-1,N=(n=Array(P),Math.sqrt);for(l=0;l!==P;++l){for(u=i[l],d=a[l],p=o[l],m=s[l],f=[],c=0;c!==R;c++){for(c>0&&d[c]*u[c]<0&&f.push(r[c]),b=(v=m[c+1]/(w=r[c+1]-r[c]))+3*(y=u[c])+2*(g=p[c]/w)-3*(_=d[c+1]),x=3*(v+g+2*(y-_)),(S=t(g-v+3*(y-_))+12*v*y)<=0?C=(M=b/x)>r[c]&&M<r[c+1]?[r[c],M,r[c+1]]:[r[c],r[c+1]]:(M=(b-N(S))/x,E=(b+N(S))/x,C=[r[c]],M>r[c]&&M<r[c+1]&&C.push(M),E>r[c]&&E<r[c+1]&&C.push(E),C.push(r[c+1])),M=this._at(I=C[0],c),h=0;h<C.length-1;h++)if(E=this._at(A=C[h+1],c),0!==M)if(0===E||M*E>0)I=A,M=E;else{for(var L=0;!((k=(M*A-E*I)/(M-E))<=I||k>=A);)if((T=this._at(k,c))*E>0)A=k,E=T,-1===L&&(M*=.5),L=-1;else{if(!(T*M>0))break;I=k,M=T,1===L&&(E*=.5),L=1}f.push(k),M=this._at(I=C[h+1],c)}else f.push(I),I=A,M=E;0===E&&f.push(A)}n[l]=f}return"number"==typeof this.yl[0]?n[0]:n},numeric.spline=function e(t,n,r,i){var a,o=t.length,s=[],l=[],c=[],h=numeric.sub,u=numeric.mul,d=numeric.add;for(a=o-2;a>=0;a--)l[a]=t[a+1]-t[a],c[a]=h(n[a+1],n[a]);"string"!=typeof r&&"string"!=typeof i||(r=i="periodic");var p=[[],[],[]];switch(typeof r){case"undefined":s[0]=u(3/(l[0]*l[0]),c[0]),p[0].push(0,0),p[1].push(0,1),p[2].push(2/l[0],1/l[0]);break;case"string":s[0]=d(u(3/(l[o-2]*l[o-2]),c[o-2]),u(3/(l[0]*l[0]),c[0])),p[0].push(0,0,0),p[1].push(o-2,0,1),p[2].push(1/l[o-2],2/l[o-2]+2/l[0],1/l[0]);break;default:s[0]=r,p[0].push(0),p[1].push(0),p[2].push(1)}for(a=1;a<o-1;a++)s[a]=d(u(3/(l[a-1]*l[a-1]),c[a-1]),u(3/(l[a]*l[a]),c[a])),p[0].push(a,a,a),p[1].push(a-1,a,a+1),p[2].push(1/l[a-1],2/l[a-1]+2/l[a],1/l[a]);switch(typeof i){case"undefined":s[o-1]=u(3/(l[o-2]*l[o-2]),c[o-2]),p[0].push(o-1,o-1),p[1].push(o-2,o-1),p[2].push(1/l[o-2],2/l[o-2]);break;case"string":p[1][p[1].length-1]=0;break;default:s[o-1]=i,p[0].push(o-1),p[1].push(o-1),p[2].push(1)}s="number"!=typeof s[0]?numeric.transpose(s):[s];var m=Array(s.length);if("string"==typeof r)for(a=m.length-1;-1!==a;--a)m[a]=numeric.ccsLUPSolve(numeric.ccsLUP(numeric.ccsScatter(p)),s[a]),m[a][o-1]=m[a][0];else for(a=m.length-1;-1!==a;--a)m[a]=numeric.cLUsolve(numeric.cLU(p),s[a]);return m="number"==typeof n[0]?m[0]:numeric.transpose(m),new numeric.Spline(t,n,n,m,m)},numeric.fftpow2=function e(t,n){var r=t.length;if(1!==r){var i,a,o=Math.cos,s=Math.sin,l=Array(r/2),c=Array(r/2),h=Array(r/2),u=Array(r/2);for(a=r/2,i=r-1;-1!==i;--i)h[--a]=t[i],u[a]=n[i],--i,l[a]=t[i],c[a]=n[i];e(l,c),e(h,u),a=r/2;var d,p,m,f=-6.283185307179586/r;for(i=r-1;-1!==i;--i)-1===--a&&(a=r/2-1),p=o(d=f*i),m=s(d),t[i]=l[a]+p*h[a]-m*u[a],n[i]=c[a]+p*u[a]+m*h[a]}},numeric._ifftpow2=function e(t,n){var r=t.length;if(1!==r){var i,a,o=Math.cos,s=Math.sin,l=Array(r/2),c=Array(r/2),h=Array(r/2),u=Array(r/2);for(a=r/2,i=r-1;-1!==i;--i)h[--a]=t[i],u[a]=n[i],--i,l[a]=t[i],c[a]=n[i];e(l,c),e(h,u),a=r/2;var d,p,m,f=6.283185307179586/r;for(i=r-1;-1!==i;--i)-1===--a&&(a=r/2-1),p=o(d=f*i),m=s(d),t[i]=l[a]+p*h[a]-m*u[a],n[i]=c[a]+p*u[a]+m*h[a]}},numeric.ifftpow2=function e(t,n){numeric._ifftpow2(t,n),numeric.diveq(t,t.length),numeric.diveq(n,n.length)},numeric.convpow2=function e(t,n,r,i){var a,o,s,l,c;for(numeric.fftpow2(t,n),numeric.fftpow2(r,i),a=t.length-1;-1!==a;--a)t[a]=(o=t[a])*(s=r[a])-(l=n[a])*(c=i[a]),n[a]=o*c+l*s;numeric.ifftpow2(t,n)},numeric.T.prototype.fft=function e(){var t,n,r=this.x,i=this.y,a=r.length,o=Math.log,s=o(2),l=Math.ceil(o(2*a-1)/s),c=Math.pow(2,l),h=numeric.rep([c],0),u=numeric.rep([c],0),d=Math.cos,p=Math.sin,m=-3.141592653589793/a,f=numeric.rep([c],0),g=numeric.rep([c],0);for(t=0;t<a;t++)f[t]=r[t];if(void 0!==i)for(t=0;t<a;t++)g[t]=i[t];for(h[0]=1,t=1;t<=c/2;t++)h[t]=d(n=m*t*t),u[t]=p(n),h[c-t]=d(n),u[c-t]=p(n);var v=new numeric.T(f,g),y=new numeric.T(h,u);return v=v.mul(y),numeric.convpow2(v.x,v.y,numeric.clone(y.x),numeric.neg(y.y)),(v=v.mul(y)).x.length=a,v.y.length=a,v},numeric.T.prototype.ifft=function e(){var t,n,r=this.x,i=this.y,a=r.length,o=Math.log,s=o(2),l=Math.ceil(o(2*a-1)/s),c=Math.pow(2,l),h=numeric.rep([c],0),u=numeric.rep([c],0),d=Math.cos,p=Math.sin,m=3.141592653589793/a,f=numeric.rep([c],0),g=numeric.rep([c],0);for(t=0;t<a;t++)f[t]=r[t];if(void 0!==i)for(t=0;t<a;t++)g[t]=i[t];for(h[0]=1,t=1;t<=c/2;t++)h[t]=d(n=m*t*t),u[t]=p(n),h[c-t]=d(n),u[c-t]=p(n);var v=new numeric.T(f,g),y=new numeric.T(h,u);return v=v.mul(y),numeric.convpow2(v.x,v.y,numeric.clone(y.x),numeric.neg(y.y)),(v=v.mul(y)).x.length=a,v.y.length=a,v.div(a)},numeric.gradient=function e(t,n){var r=n.length,i=t(n);if(isNaN(i))throw new Error("gradient: f(x) is a NaN!");var a,o,s,l,c,h,u,d,p,m=Math.max,f=numeric.clone(n),g=Array(r),v=(m=Math.max,Math.abs),y=Math.min,_=0;for(a=0;a<r;a++)for(var b=m(1e-6*i,1e-8);;){if(++_>20)throw new Error("Numerical gradient fails");if(f[a]=n[a]+b,o=t(f),f[a]=n[a]-b,s=t(f),f[a]=n[a],isNaN(o)||isNaN(s))b/=16;else{if(g[a]=(o-s)/(2*b),l=n[a]-b,c=n[a],h=n[a]+b,u=(o-i)/b,d=(i-s)/b,p=m(v(g[a]),v(i),v(o),v(s),v(l),v(c),v(h),1e-8),!(y(m(v(u-g[a]),v(d-g[a]),v(u-d))/p,b/p)>.001))break;b/=16}}return g},numeric.uncmin=function e(t,n,r,i,a,o,s){var l=numeric.gradient;void 0===s&&(s={}),void 0===r&&(r=1e-8),void 0===i&&(i=function(e){return l(t,e)}),void 0===a&&(a=1e3);var c,h,u=(n=numeric.clone(n)).length,d=t(n);if(isNaN(d))throw new Error("uncmin: f(x0) is a NaN!");var p=Math.max,m=numeric.norm2;r=p(r,numeric.epsilon);var f,g,v,y,_,b,x,S,w,C,M=s.Hinv||numeric.identity(u),E=numeric.dot,T=numeric.sub,I=numeric.add,A=numeric.tensor,k=numeric.div,P=numeric.mul,R=numeric.all,N=numeric.isFinite,L=numeric.neg,D=0,$="";for(g=i(n);D<a;){if("function"==typeof o&&o(D,n,d,g,M)){$="Callback returned true";break}if(!R(N(g))){$="Gradient has Infinity or NaN";break}if(!R(N(f=L(E(M,g))))){$="Search direction has Infinity or NaN";break}if((C=m(f))<r){$="Newton step smaller than tol";break}for(w=1,h=E(g,f),_=n;D<a&&!(w*C<r)&&(_=I(n,y=P(f,w)),(c=t(_))-d>=.1*w*h||isNaN(c));)w*=.5,++D;if(w*C<r){$="Line search step size smaller than tol";break}if(D===a){$="maxit reached during line search";break}S=E(b=T(v=i(_),g),y),x=E(M,b),M=T(I(M,P((S+E(b,x))/(S*S),A(y,y))),k(I(A(x,y),A(y,x)),S)),n=_,d=c,g=v,++D}return{solution:n,f:d,gradient:g,invHessian:M,iterations:D,message:$}},numeric.Dopri=function e(t,n,r,i,a,o,s){this.x=t,this.y=n,this.f=r,this.ymid=i,this.iterations=a,this.events=s,this.message=o},numeric.Dopri.prototype._at=function e(t,n){function r(e){return e*e}var i,a,o,s,l,c,h,u,d,p=this,m=p.x,f=p.y,g=p.f,v=numeric.add,y=numeric.mul,_=numeric.sub;return l=f[n+1],c=p.ymid[n],h=_(g[n],y(s=f[n],1/((i=m[n])-(o=i+.5*((a=m[n+1])-i)))+2/(i-a))),u=_(g[n+1],y(l,1/(a-o)+2/(a-i))),v(v(v(v(y(s,(d=[r(t-a)*(t-o)/r(i-a)/(i-o),r(t-i)*r(t-a)/r(i-o)/r(a-o),r(t-i)*(t-o)/r(a-i)/(a-o),(t-i)*r(t-a)*(t-o)/r(i-a)/(i-o),(t-a)*r(t-i)*(t-o)/r(i-a)/(a-o)])[0]),y(c,d[1])),y(l,d[2])),y(h,d[3])),y(u,d[4]))},numeric.Dopri.prototype.at=function e(t){var n,r,i,a=Math.floor;if("number"!=typeof t){var o=t.length,s=Array(o);for(n=o-1;-1!==n;--n)s[n]=this.at(t[n]);return s}var l=this.x;for(n=0,r=l.length-1;r-n>1;)l[i=a(.5*(n+r))]<=t?n=i:r=i;return this._at(t,n)},numeric.dopri=function e(t,n,r,i,a,o,s){void 0===a&&(a=1e-6),void 0===o&&(o=1e3);var l,c,h,u,d,p,m,f,g,v,y,_,b,x=[t],S=[r],w=[i(t,r)],C=[],M=[3/40,9/40],E=[44/45,-56/15,32/9],T=[19372/6561,-25360/2187,64448/6561,-212/729],I=[9017/3168,-355/33,46732/5247,49/176,-5103/18656],A=[35/384,0,500/1113,125/192,-2187/6784,11/84],k=[.10013431883002395,0,.3918321794184259,-.02982460176594817,.05893268337240795,-.04497888809104361,5618549.5/235043384],P=[.2,.3,.8,8/9,1,1],R=[-71/57600,0,71/16695,-71/1920,17253/339200,-22/525,1/40],N=0,L=(n-t)/10,D=0,$=numeric.add,z=numeric.mul,F=Math.min,O=Math.abs,B=numeric.norminf,V=Math.pow,H=numeric.any,U=numeric.lt,G=numeric.and,W=new numeric.Dopri(x,S,w,C,-1,"");for("function"==typeof s&&(y=s(t,r));t<n&&D<o;)if(++D,t+L>n&&(L=n-t),l=i(t+P[0]*L,$(r,z(.2*L,w[N]))),c=i(t+P[1]*L,$($(r,z(M[0]*L,w[N])),z(M[1]*L,l))),h=i(t+P[2]*L,$($($(r,z(E[0]*L,w[N])),z(E[1]*L,l)),z(E[2]*L,c))),u=i(t+P[3]*L,$($($($(r,z(T[0]*L,w[N])),z(T[1]*L,l)),z(T[2]*L,c)),z(T[3]*L,h))),d=i(t+P[4]*L,$($($($($(r,z(I[0]*L,w[N])),z(I[1]*L,l)),z(I[2]*L,c)),z(I[3]*L,h)),z(I[4]*L,u))),p=i(t+L,g=$($($($($(r,z(w[N],L*A[0])),z(c,L*A[2])),z(h,L*A[3])),z(u,L*A[4])),z(d,L*A[5]))),(v="number"==typeof(m=$($($($($(z(w[N],L*R[0]),z(c,L*R[2])),z(h,L*R[3])),z(u,L*R[4])),z(d,L*R[5])),z(p,L*R[6])))?O(m):B(m))>a){if(t+(L=.2*L*V(a/v,.25))===t){W.msg="Step size became too small";break}}else{if(C[N]=$($($($($($(r,z(w[N],L*k[0])),z(c,L*k[2])),z(h,L*k[3])),z(u,L*k[4])),z(d,L*k[5])),z(p,L*k[6])),x[++N]=t+L,S[N]=g,w[N]=p,"function"==typeof s){var j,q,X=t,K=t+.5*L;if(_=s(K,C[N-1]),H(b=G(U(y,0),U(0,_)))||(X=K,y=_,_=s(K=t+L,g),b=G(U(y,0),U(0,_))),H(b)){for(var Y,Z,J=0,Q=1,ee=1;;){if("number"==typeof y)q=(ee*_*X-Q*y*K)/(ee*_-Q*y);else for(q=K,f=y.length-1;-1!==f;--f)y[f]<0&&_[f]>0&&(q=F(q,(ee*_[f]*X-Q*y[f]*K)/(ee*_[f]-Q*y[f])));if(q<=X||q>=K)break;Z=s(q,j=W._at(q,N-1)),H(Y=G(U(y,0),U(0,Z)))?(K=q,_=Z,b=Y,ee=1,-1===J?Q*=.5:Q=1,J=-1):(X=q,y=Z,Q=1,1===J?ee*=.5:ee=1,J=1)}return g=W._at(.5*(t+q),N-1),W.f[N]=i(q,j),W.x[N]=q,W.y[N]=j,W.ymid[N-1]=g,W.events=b,W.iterations=D,W}}t+=L,r=g,y=_,L=F(.8*L*V(a/v,.25),4*L)}return W.iterations=D,W},numeric.LU=function(e,t){t=t||!1;var n,r,i,a,o,s,l,c,h,u=Math.abs,d=e.length,p=d-1,m=new Array(d);for(t||(e=numeric.clone(e)),i=0;i<d;++i){for(l=i,h=u((s=e[i])[i]),r=i+1;r<d;++r)h<(a=u(e[r][i]))&&(h=a,l=r);for(m[i]=l,l!=i&&(e[i]=e[l],e[l]=s,s=e[i]),o=s[i],n=i+1;n<d;++n)e[n][i]/=o;for(n=i+1;n<d;++n){for(c=e[n],r=i+1;r<p;++r)c[r]-=c[i]*s[r],c[++r]-=c[i]*s[r];r===p&&(c[r]-=c[i]*s[r])}}return{LU:e,P:m}},numeric.LUsolve=function e(t,n){var r,i,a,o,s,l=t.LU,c=l.length,h=numeric.clone(n),u=t.P;for(r=c-1;-1!==r;--r)h[r]=n[r];for(r=0;r<c;++r)for(a=u[r],u[r]!==r&&(s=h[r],h[r]=h[a],h[a]=s),o=l[r],i=0;i<r;++i)h[r]-=h[i]*o[i];for(r=c-1;r>=0;--r){for(o=l[r],i=r+1;i<c;++i)h[r]-=h[i]*o[i];h[r]/=o[r]}return h},numeric.solve=function e(t,n,r){return numeric.LUsolve(numeric.LU(t,r),n)},numeric.echelonize=function e(t){var n,r,i,a,o,s,l,c,h=numeric.dim(t),u=h[0],d=h[1],p=numeric.identity(u),m=Array(u),f=Math.abs,g=numeric.diveq;for(t=numeric.clone(t),n=0;n<u;++n){for(i=0,o=t[n],s=p[n],r=1;r<d;++r)f(o[i])<f(o[r])&&(i=r);for(m[n]=i,g(s,o[i]),g(o,o[i]),r=0;r<u;++r)if(r!==n){for(c=(l=t[r])[i],a=d-1;-1!==a;--a)l[a]-=o[a]*c;for(l=p[r],a=u-1;-1!==a;--a)l[a]-=s[a]*c}}return{I:p,A:t,P:m}},numeric.__solveLP=function e(t,n,r,i,a,o,s){var l,c=numeric.sum,h=numeric.mul,u=numeric.sub,d=numeric.dot,p=numeric.div,m=numeric.add,f=t.length,g=r.length,v=!1,y=1;numeric.transpose(n);var _,b=numeric.transpose,x=Math.sqrt,S=Math.abs,w=Math.min,C=numeric.all,M=numeric.gt,E=Array(f),T=Array(g);numeric.rep([g],1);var I,A,k=numeric.solve,P=u(r,d(n,o)),R=d(t,t);for(I=0;I<a;++I){var N,L;for(N=g-1;-1!==N;--N)T[N]=p(n[N],P[N]);var D=b(T);for(N=f-1;-1!==N;--N)E[N]=c(D[N]);y=.25*S(R/d(t,E));var $=100*x(R/d(E,E));for((!isFinite(y)||y>$)&&(y=$),A=m(t,h(y,E)),_=d(D,T),N=f-1;-1!==N;--N)_[N][N]+=1;L=k(_,p(A,y),!0);var z=p(P,d(n,L)),F=1;for(N=g-1;-1!==N;--N)z[N]<0&&(F=w(F,-.999*z[N]));if(l=u(o,h(L,F)),!C(M(P=u(r,d(n,l)),0)))return{solution:o,message:"",iterations:I};if(o=l,y<i)return{solution:l,message:"",iterations:I};if(s){var O=d(t,A),B=d(n,A);for(v=!0,N=g-1;-1!==N;--N)if(O*B[N]<0){v=!1;break}}else v=!(o[f-1]>=0);if(v)return{solution:l,message:"Unbounded",iterations:I}}return{solution:o,message:"maximum iteration count exceeded",iterations:I}},numeric._solveLP=function e(t,n,r,i,a){var o=t.length,s=r.length,l=numeric.sub,c=numeric.dot,h=numeric.rep([o],0).concat([1]),u=numeric.rep([s,1],-1),d=numeric.blockMatrix([[n,u]]),p=r,m=numeric.rep([o],0).concat(Math.max(0,numeric.sup(numeric.neg(r)))+1),f=numeric.__solveLP(h,d,p,i,a,m,!1),g=numeric.clone(f.solution);if(g.length=o,numeric.inf(l(r,c(n,g)))<0)return{solution:NaN,message:"Infeasible",iterations:f.iterations};var v=numeric.__solveLP(t,n,r,i,a-f.iterations,g,!0);return v.iterations+=f.iterations,v},numeric.solveLP=function e(t,n,r,i,a,o,s){if(void 0===s&&(s=1e3),void 0===o&&(o=numeric.epsilon),void 0===i)return numeric._solveLP(t,n,r,o,s);var l,c=i.length,h=i[0].length,u=n.length,d=numeric.echelonize(i),p=numeric.rep([h],0),m=d.P,f=[];for(l=m.length-1;-1!==l;--l)p[m[l]]=1;for(l=h-1;-1!==l;--l)0===p[l]&&f.push(l);var g=numeric.getRange,v=numeric.linspace(0,c-1),y=numeric.linspace(0,u-1),_=g(i,v,f),b=g(n,y,m),x=g(n,y,f),S=numeric.dot,w=numeric.sub,C=S(b,d.I),M=w(x,S(C,_)),E=w(r,S(C,a)),T=Array(m.length),I=Array(f.length);for(l=m.length-1;-1!==l;--l)T[l]=t[m[l]];for(l=f.length-1;-1!==l;--l)I[l]=t[f[l]];var A=w(I,S(T,S(d.I,_))),k=numeric._solveLP(A,M,E,o,s),P=k.solution;if(P!=P)return k;var R=S(d.I,w(a,S(_,P))),N=Array(t.length);for(l=m.length-1;-1!==l;--l)N[m[l]]=R[l];for(l=f.length-1;-1!==l;--l)N[f[l]]=P[l];return{solution:N,message:k.message,iterations:k.iterations}},numeric.MPStoLP=function e(t){t instanceof String&&t.split("\n");var n,r,i,a,o=0,s=["Initial state","NAME","ROWS","COLUMNS","RHS","BOUNDS","ENDATA"],l=t.length,c=0,h={},u=[],d=0,p={},m=0,f=[],g=[],v=[];function y(e){throw new Error("MPStoLP: "+e+"\nLine "+n+": "+t[n]+"\nCurrent state: "+s[o]+"\n")}for(n=0;n<l;++n){var _=(i=t[n]).match(/\S*/g),b=[];for(r=0;r<_.length;++r)""!==_[r]&&b.push(_[r]);if(0!==b.length){for(r=0;r<s.length&&i.substr(0,s[r].length)!==s[r];++r);if(r<s.length){if(o=r,1===r&&(a=b[1]),6===r)return{name:a,c:f,A:numeric.transpose(g),b:v,rows:h,vars:p}}else switch(o){case 0:case 1:y("Unexpected line");case 2:switch(b[0]){case"N":0===c?c=b[1]:y("Two or more N rows");break;case"L":h[b[1]]=d,u[d]=1,v[d]=0,++d;break;case"G":h[b[1]]=d,u[d]=-1,v[d]=0,++d;break;case"E":h[b[1]]=d,u[d]=0,v[d]=0,++d;break;default:y("Parse error "+numeric.prettyPrint(b))}break;case 3:p.hasOwnProperty(b[0])||(p[b[0]]=m,f[m]=0,g[m]=numeric.rep([d],0),++m);var x=p[b[0]];for(r=1;r<b.length;r+=2)if(b[r]!==c){var S=h[b[r]];g[x][S]=(u[S]<0?-1:1)*parseFloat(b[r+1])}else f[x]=parseFloat(b[r+1]);break;case 4:for(r=1;r<b.length;r+=2)v[h[b[r]]]=(u[h[b[r]]]<0?-1:1)*parseFloat(b[r+1]);break;case 5:break;case 6:y("Internal error")}}}y("Reached end of file without ENDATA")},numeric.seedrandom={pow:Math.pow,random:Math.random},(function(e,t,n,r,i,a,o){function s(e){var t,r=this,i=e.length,a=0,o=r.i=r.j=r.m=0;for(r.S=[],r.c=[],i||(e=[i++]);a<n;)r.S[a]=a++;for(a=0;a<n;a++)o=h(o+(t=r.S[a])+e[a%i]),r.S[a]=r.S[o],r.S[o]=t;r.g=function e(t){var i=r.S,a=h(r.i+1),o=i[a],s=h(r.j+o),l=i[s];i[a]=l,i[s]=o;for(var c=i[h(o+l)];--t;)a=h(a+1),s=h(s+(o=i[a])),i[a]=l=i[s],i[s]=o,c=c*n+i[h(o+l)];return r.i=a,r.j=s,c},r.g(n)}function l(e,t,n,r,i){if(n=[],i=typeof e,t&&"object"==i)for(r in e)if(r.indexOf("S")<5)try{n.push(l(e[r],t-1))}catch(e){}return n.length?n:e+("string"!=i?"\0":"")}function c(e,t,n,r){for(e+="",n=0,r=0;r<e.length;r++)t[h(r)]=h((n^=19*t[h(r)])+e.charCodeAt(r));for(r in e="",t)e+=String.fromCharCode(t[r]);return e}function h(e){return 255&e}t.seedrandom=function r(h,u){var d,p=[];return h=c(l(u?[h,e]:arguments.length?h:[(new Date).getTime(),e,window],3),p),c((d=new s(p)).S,e),t.random=function e(){for(var t=d.g(6),r=o,s=0;t<i;)t=(t+s)*n,r*=n,s=d.g(1);for(;t>=a;)t/=2,r/=2,s>>>=1;return(t+s)/r},h},o=t.pow(n,6),i=t.pow(2,i),a=2*i,c(t.random(),e)})([],numeric.seedrandom,256,0,52),(function(e){function t(e){if("object"!=typeof e)return e;var n,r=[],i=e.length;for(n=0;n<i;n++)r[n+1]=t(e[n]);return r}function n(e){if("object"!=typeof e)return e;var t,r=[],i=e.length;for(t=1;t<i;t++)r[t-1]=n(e[t]);return r}function r(e,t,n,r,i,a,o,s,l,c,h,u,d,p,m,f){var g,v,y,_,b,x,S,w,C,M,E,T,I,A,k,P,R,N,L,D,$,z,F,O,B,V,H;I=Math.min(r,c),y=2*r+I*(I+5)/2+2*c+1,O=1e-60;do{B=1+.1*(O+=O),V=1+.2*O}while(B<=1||V<=1);for(g=1;g<=r;g+=1)m[g]=t[g];for(g=r+1;g<=y;g+=1)m[g]=0;for(g=1;g<=c;g+=1)u[g]=0;if(b=[],0===f[1]){if((function U(e,t,n,r){var i,a,o,s,l,c;for(a=1;a<=n;a+=1){if(r[1]=a,c=0,(o=a-1)<1){if((c=e[a][a]-c)<=0)break;e[a][a]=Math.sqrt(c)}else{for(s=1;s<=o;s+=1){for(l=e[s][a],i=1;i<s;i+=1)l-=e[i][a]*e[i][s];e[s][a]=l/=e[s][s],c+=l*l}if((c=e[a][a]-c)<=0)break;e[a][a]=Math.sqrt(c)}r[1]=0}})(e,0,r,b),0!==b[1])return void(f[1]=2);!(function G(e,t,n,r){var i,a,o,s;for(a=1;a<=n;a+=1){for(s=0,i=1;i<a;i+=1)s+=e[i][a]*r[i];r[a]=(r[a]-s)/e[a][a]}for(o=1;o<=n;o+=1)for(r[a=n+1-o]=r[a]/e[a][a],s=-r[a],i=1;i<a;i+=1)r[i]=r[i]+s*e[i][a]})(e,0,r,t),(function W(e,t,n){var r,i,a,o,s;for(a=1;a<=n;a+=1){for(e[a][a]=1/e[a][a],s=-e[a][a],r=1;r<a;r+=1)e[r][a]=s*e[r][a];if(n<(o=a+1))break;for(i=o;i<=n;i+=1)for(s=e[a][i],e[a][i]=0,r=1;r<=a;r+=1)e[r][i]=e[r][i]+s*e[r][a]}})(e,0,r)}else{for(v=1;v<=r;v+=1)for(i[v]=0,g=1;g<=v;g+=1)i[v]=i[v]+e[g][v]*t[g];for(v=1;v<=r;v+=1)for(t[v]=0,g=v;g<=r;g+=1)t[v]=t[v]+e[v][g]*i[g]}for(a[1]=0,v=1;v<=r;v+=1)for(i[v]=t[v],a[1]=a[1]+m[v]*i[v],m[v]=0,g=v+1;g<=r;g+=1)e[g][v]=0;for(a[1]=-a[1]/2,f[1]=0,A=(M=(C=(E=(w=(S=r)+r)+I)+I+1)+I*(I+1)/2)+c,g=1;g<=c;g+=1){for(P=0,v=1;v<=r;v+=1)P+=o[v][g]*o[v][g];m[A+g]=Math.sqrt(P)}function j(){for(p[1]=p[1]+1,y=M,g=1;g<=c;g+=1){for(y+=1,P=-s[g],v=1;v<=r;v+=1)P+=o[v][g]*i[v];if(Math.abs(P)<O&&(P=0),g>h)m[y]=P;else if(m[y]=-Math.abs(P),P>0){for(v=1;v<=r;v+=1)o[v][g]=-o[v][g];s[g]=-s[g]}}for(g=1;g<=d;g+=1)m[M+u[g]]=0;for(T=0,k=0,g=1;g<=c;g+=1)m[M+g]<k*m[A+g]&&(T=g,k=m[M+g]/m[A+g]);return 0===T?999:0}function q(){for(g=1;g<=r;g+=1){for(P=0,v=1;v<=r;v+=1)P+=e[v][g]*o[v][T];m[g]=P}for(_=S,g=1;g<=r;g+=1)m[_+g]=0;for(v=d+1;v<=r;v+=1)for(g=1;g<=r;g+=1)m[_+g]=m[_+g]+e[g][v]*m[v];for(z=!0,g=d;g>=1;g-=1){for(P=m[g],_=(y=C+g*(g+3)/2)-g,v=g+1;v<=d;v+=1)P-=m[y]*m[w+v],y+=v;if(m[w+g]=P/=m[_],u[g]<h)break;if(P<0)break;z=!1,x=g}if(!z)for(R=m[E+x]/m[w+x],g=1;g<=d&&!(u[g]<h)&&!(m[w+g]<0);g+=1)(k=m[E+g]/m[w+g])<R&&(R=k,x=g);for(P=0,g=S+1;g<=S+r;g+=1)P+=m[g]*m[g];if(Math.abs(P)<=O){if(z)return f[1]=1,999;for(g=1;g<=d;g+=1)m[E+g]=m[E+g]-R*m[w+g];return m[E+d+1]=m[E+d+1]+R,700}for(P=0,g=1;g<=r;g+=1)P+=m[S+g]*o[g][T];for(N=-m[M+T]/P,F=!0,z||R<N&&(N=R,F=!1),g=1;g<=r;g+=1)i[g]=i[g]+N*m[S+g],Math.abs(i[g])<O&&(i[g]=0);for(a[1]=a[1]+N*P*(N/2+m[E+d+1]),g=1;g<=d;g+=1)m[E+g]=m[E+g]-N*m[w+g];if(m[E+d+1]=m[E+d+1]+N,!F){for(P=-s[T],v=1;v<=r;v+=1)P+=i[v]*o[v][T];if(T>h)m[M+T]=P;else if(m[M+T]=-Math.abs(P),P>0){for(v=1;v<=r;v+=1)o[v][T]=-o[v][T];s[T]=-s[T]}return 700}for(u[d+=1]=T,y=C+(d-1)*d/2+1,g=1;g<=d-1;g+=1)m[y]=m[g],y+=1;if(d===r)m[y]=m[r];else{for(g=r;g>=d+1&&0!==m[g]&&(L=Math.max(Math.abs(m[g-1]),Math.abs(m[g])),D=Math.min(Math.abs(m[g-1]),Math.abs(m[g])),k=m[g-1]>=0?Math.abs(L*Math.sqrt(1+D*D/(L*L))):-Math.abs(L*Math.sqrt(1+D*D/(L*L))),D=m[g]/k,1!==(L=m[g-1]/k));g-=1)if(0===L)for(m[g-1]=D*k,v=1;v<=r;v+=1)k=e[v][g-1],e[v][g-1]=e[v][g],e[v][g]=k;else for(m[g-1]=k,$=D/(1+L),v=1;v<=r;v+=1)e[v][g]=$*(e[v][g-1]+(k=L*e[v][g-1]+D*e[v][g]))-e[v][g],e[v][g-1]=k;m[y]=m[d]}return 0}function X(){if(0===m[_=(y=C+x*(x+1)/2+1)+x])return 798;if(L=Math.max(Math.abs(m[_-1]),Math.abs(m[_])),D=Math.min(Math.abs(m[_-1]),Math.abs(m[_])),k=m[_-1]>=0?Math.abs(L*Math.sqrt(1+D*D/(L*L))):-Math.abs(L*Math.sqrt(1+D*D/(L*L))),D=m[_]/k,1===(L=m[_-1]/k))return 798;if(0===L){for(g=x+1;g<=d;g+=1)k=m[_-1],m[_-1]=m[_],m[_]=k,_+=g;for(g=1;g<=r;g+=1)k=e[g][x],e[g][x]=e[g][x+1],e[g][x+1]=k}else{for($=D/(1+L),g=x+1;g<=d;g+=1)m[_]=$*(m[_-1]+(k=L*m[_-1]+D*m[_]))-m[_],m[_-1]=k,_+=g;for(g=1;g<=r;g+=1)e[g][x+1]=$*(e[g][x]+(k=L*e[g][x]+D*e[g][x+1]))-e[g][x+1],e[g][x]=k}return 0}function K(){for(_=y-x,g=1;g<=x;g+=1)m[_]=m[y],y+=1,_+=1;return m[E+x]=m[E+x+1],u[x]=u[x+1],(x+=1)<d?797:0}function Y(){return m[E+d]=m[E+d+1],m[E+d+1]=0,u[d]=0,d-=1,p[2]=p[2]+1,0}for(d=0,p[1]=0,p[2]=0,H=0;;){if(999===(H=j()))return;for(;0!==(H=q());){if(999===H)return;if(700===H)if(x===d)Y();else{for(;X(),797===(H=K()););Y()}}}}e.solveQP=function i(e,a,o,s,l,c){e=t(e),a=t(a),o=t(o);var h,u,d,p,m,f=[],g=[],v=[],y=[],_=[];if(l=l||0,c=c?t(c):[void 0,0],s=s?t(s):[],u=e.length-1,d=o[1].length-1,!s)for(h=1;h<=d;h+=1)s[h]=0;for(h=1;h<=d;h+=1)g[h]=0;for(0,p=Math.min(u,d),h=1;h<=u;h+=1)v[h]=0;for(f[1]=0,h=1;h<=2*u+p*(p+5)/2+2*d+1;h+=1)y[h]=0;for(h=1;h<=2;h+=1)_[h]=0;return r(e,a,0,u,v,f,o,s,0,d,l,g,0,_,y,c),m="",1===c[1]&&(m="constraints are inconsistent, no solution!"),2===c[1]&&(m="matrix D in quadratic function is not positive definite!"),{solution:n(v),value:n(f),unconstrained_solution:n(a),iterations:n(_),iact:n(g),message:m}}})(numeric),numeric.svd=function e(t){var n,r=numeric.epsilon,i=1e-64/r,a=0,o=0,s=0,l=0,c=0,h=numeric.clone(t),u=h.length,d=h[0].length;if(u<d)throw"Need more rows than columns";var p=new Array(d),m=new Array(d);for(o=0;o<d;o++)p[o]=m[o]=0;var f=numeric.rep([d,d],0);function g(e,t){return(e=Math.abs(e))>(t=Math.abs(t))?e*Math.sqrt(1+t*t/e/e):0==t?e:t*Math.sqrt(1+e*e/t/t)}var v=0,y=0,_=0,b=0,x=0,S=0,w=0;for(o=0;o<d;o++){for(p[o]=y,w=0,c=o+1,s=o;s<u;s++)w+=h[s][o]*h[s][o];if(w<=i)y=0;else for(v=h[o][o],y=Math.sqrt(w),v>=0&&(y=-y),_=v*y-w,h[o][o]=v-y,s=c;s<d;s++){for(w=0,l=o;l<u;l++)w+=h[l][o]*h[l][s];for(v=w/_,l=o;l<u;l++)h[l][s]+=v*h[l][o]}for(m[o]=y,w=0,s=c;s<d;s++)w+=h[o][s]*h[o][s];if(w<=i)y=0;else{for(v=h[o][o+1],y=Math.sqrt(w),v>=0&&(y=-y),_=v*y-w,h[o][o+1]=v-y,s=c;s<d;s++)p[s]=h[o][s]/_;for(s=c;s<u;s++){for(w=0,l=c;l<d;l++)w+=h[s][l]*h[o][l];for(l=c;l<d;l++)h[s][l]+=w*p[l]}}(x=Math.abs(m[o])+Math.abs(p[o]))>b&&(b=x)}for(o=d-1;-1!=o;o+=-1){if(0!=y){for(_=y*h[o][o+1],s=c;s<d;s++)f[s][o]=h[o][s]/_;for(s=c;s<d;s++){for(w=0,l=c;l<d;l++)w+=h[o][l]*f[l][s];for(l=c;l<d;l++)f[l][s]+=w*f[l][o]}}for(s=c;s<d;s++)f[o][s]=0,f[s][o]=0;f[o][o]=1,y=p[o],c=o}for(o=d-1;-1!=o;o+=-1){for(y=m[o],s=c=o+1;s<d;s++)h[o][s]=0;if(0!=y){for(_=h[o][o]*y,s=c;s<d;s++){for(w=0,l=c;l<u;l++)w+=h[l][o]*h[l][s];for(v=w/_,l=o;l<u;l++)h[l][s]+=v*h[l][o]}for(s=o;s<u;s++)h[s][o]=h[s][o]/y}else for(s=o;s<u;s++)h[s][o]=0;h[o][o]+=1}for(r*=b,l=d-1;-1!=l;l+=-1)for(var C=0;C<50;C++){var M=!1;for(c=l;-1!=c;c+=-1){if(Math.abs(p[c])<=r){M=!0;break}if(Math.abs(m[c-1])<=r)break}if(!M){a=0,w=1;var E=c-1;for(o=c;o<l+1&&(v=w*p[o],p[o]=a*p[o],!(Math.abs(v)<=r));o++)for(_=g(v,y=m[o]),m[o]=_,a=y/_,w=-v/_,s=0;s<u;s++)h[s][E]=(x=h[s][E])*a+(S=h[s][o])*w,h[s][o]=-x*w+S*a}if(S=m[l],c==l){if(S<0)for(m[l]=-S,s=0;s<d;s++)f[s][l]=-f[s][l];break}if(C>=49)throw"Error: no convergence.";for(b=m[c],y=g(v=(((x=m[l-1])-S)*(x+S)+((y=p[l-1])-(_=p[l]))*(y+_))/(2*_*x),1),v=v<0?((b-S)*(b+S)+_*(x/(v-y)-_))/b:((b-S)*(b+S)+_*(x/(v+y)-_))/b,a=1,w=1,o=c+1;o<l+1;o++){for(x=m[o],_=w*(y=p[o]),y*=a,S=g(v,_),p[o-1]=S,v=b*(a=v/S)+y*(w=_/S),y=-b*w+y*a,_=x*w,x*=a,s=0;s<d;s++)f[s][o-1]=(b=f[s][o-1])*a+(S=f[s][o])*w,f[s][o]=-b*w+S*a;for(S=g(v,_),m[o-1]=S,v=(a=v/S)*y+(w=_/S)*x,b=-w*y+a*x,s=0;s<u;s++)h[s][o-1]=(x=h[s][o-1])*a+(S=h[s][o])*w,h[s][o]=-x*w+S*a}p[c]=0,p[l]=v,m[l]=b}for(o=0;o<m.length;o++)m[o]<r&&(m[o]=0);for(o=0;o<d;o++)for(s=o-1;s>=0;s--)if(m[s]<m[o]){for(a=m[s],m[s]=m[o],m[o]=a,l=0;l<h.length;l++)n=h[l][o],h[l][o]=h[l][s],h[l][s]=n;for(l=0;l<f.length;l++)n=f[l][o],f[l][o]=f[l][s],f[l][s]=n;o=s}return{U:h,S:m,V:f}}})(numeric1_2_6);var dist$1={},umap={},heap$2={},utils$5={},__values$3=commonjsGlobal&&commonjsGlobal.__values||function(e){var t="function"==typeof Symbol&&e[Symbol.iterator],n=0;return t?t.call(e):{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}};function tauRandInt(e,t){return Math.floor(t()*e)}function tauRand(e){return e()}function norm(e){var t,n,r=0;try{for(var i=__values$3(e),a=i.next();!a.done;a=i.next()){r+=Math.pow(a.value,2)}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return Math.sqrt(r)}function empty(e){for(var t=[],n=0;n<e;n++)t.push(void 0);return t}function range$3(e){return empty(e).map((function(e,t){return t}))}function filled(e,t){return empty(e).map((function(){return t}))}function zeros$3(e){return filled(e,0)}function ones$1(e){return filled(e,1)}function linear$2(e,t,n){return empty(n).map((function(r,i){return e+i*((t-e)/(n-1))}))}function sum$4(e){return e.reduce((function(e,t){return e+t}))}function mean$1(e){return sum$4(e)/e.length}function max$3(e){for(var t=0,n=0;n<e.length;n++)t=e[n]>t?e[n]:t;return t}function max2d(e){for(var t=0,n=0;n<e.length;n++)for(var r=0;r<e[n].length;r++)t=e[n][r]>t?e[n][r]:t;return t}function rejectionSample$1(e,t,n){for(var r=zeros$3(e),i=0;i<e;i++)for(var a=!0;a;){for(var o=tauRandInt(t,n),s=!1,l=0;l<i;l++)if(o===r[l]){s=!0;break}s||(a=!1),r[i]=o}return r}function reshape2d(e,t,n){var r=[],i=0;if(e.length!==t*n)throw new Error("Array dimensions must match input length.");for(var a=0;a<t;a++){for(var o=[],s=0;s<n;s++)o.push(e[i]),i+=1;r.push(o)}return r}Object.defineProperty(utils$5,"__esModule",{value:!0}),utils$5.tauRandInt=tauRandInt,utils$5.tauRand=tauRand,utils$5.norm=norm,utils$5.empty=empty,utils$5.range=range$3,utils$5.filled=filled,utils$5.zeros=zeros$3,utils$5.ones=ones$1,utils$5.linear=linear$2,utils$5.sum=sum$4,utils$5.mean=mean$1,utils$5.max=max$3,utils$5.max2d=max2d,utils$5.rejectionSample=rejectionSample$1,utils$5.reshape2d=reshape2d;var __importStar$4=commonjsGlobal&&commonjsGlobal.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t};Object.defineProperty(heap$2,"__esModule",{value:!0});var utils$4=__importStar$4(utils$5);function makeHeap(e,t){var n=function(n){return utils$4.empty(e).map((function(){return utils$4.filled(t,n)}))},r=[];return r.push(n(-1)),r.push(n(1/0)),r.push(n(0)),r}function rejectionSample(e,t,n){for(var r=utils$4.zeros(e),i=0;i<e;i++){for(var a=!0,o=0;a;){o=utils$4.tauRandInt(t,n);for(var s=!1,l=0;l<i;l++)if(o===r[l]){s=!0;break}s||(a=!1)}r[i]=o}return r}function heapPush(e,t,n,r,i){t=Math.floor(t);var a=e[0][t];if(n>=e[1][t][0])return 0;for(var o=0;o<a.length;o++)if(r===a[o])return 0;return uncheckedHeapPush(e,t,n,r,i)}function uncheckedHeapPush(e,t,n,r,i){var a=e[0][t],o=e[1][t],s=e[2][t];if(n>=o[0])return 0;o[0]=n,a[0]=r,s[0]=i;for(var l=0,c=0;;){var h=2*l+1,u=h+1,d=e[0][0].length;if(h>=d)break;if(u>=d){if(!(o[h]>n))break;c=h}else if(o[h]>=o[u]){if(!(n<o[h]))break;c=h}else{if(!(n<o[u]))break;c=u}o[l]=o[c],a[l]=a[c],s[l]=s[c],l=c}return o[l]=n,a[l]=r,s[l]=i,1}function buildCandidates(e,t,n,r,i){for(var a=makeHeap(t,r),o=0;o<t;o++)for(var s=0;s<n;s++)if(!(e[0][o][s]<0)){var l=e[0][o][s],c=e[2][o][s],h=utils$4.tauRand(i);heapPush(a,o,h,l,c),heapPush(a,l,h,o,c),e[2][o][s]=0}return a}function deheapSort(e){for(var t=e[0],n=e[1],r=0;r<t.length;r++)for(var i=t[r],a=n[r],o=0;o<i.length-1;o++){var s=i.length-o-1,l=a.length-o-1,c=i[0];i[0]=i[s],i[s]=c;var h=a[0];a[0]=a[l],a[l]=h,siftDown(a,i,l,0)}return{indices:t,weights:n}}function siftDown(e,t,n,r){for(;2*r+1<n;){var i=2*r+1,a=i+1,o=r;if(e[o]<e[i]&&(o=i),a<n&&e[o]<e[a]&&(o=a),o===r)break;var s=e[r];e[r]=e[o],e[o]=s;var l=t[r];t[r]=t[o],t[o]=l,r=o}}function smallestFlagged(e,t){for(var n=e[0][t],r=e[1][t],i=e[2][t],a=1/0,o=-1,s=0;s>n.length;s++)1===i[s]&&r[s]<a&&(a=r[s],o=s);return o>=0?(i[o]=0,Math.floor(n[o])):-1}heap$2.makeHeap=makeHeap,heap$2.rejectionSample=rejectionSample,heap$2.heapPush=heapPush,heap$2.uncheckedHeapPush=uncheckedHeapPush,heap$2.buildCandidates=buildCandidates,heap$2.deheapSort=deheapSort,heap$2.smallestFlagged=smallestFlagged;var matrix$2={},__read$2=commonjsGlobal&&commonjsGlobal.__read||function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,a=n.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(r=a.next()).done;)o.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=a.return)&&n.call(a)}finally{if(i)throw i.error}}return o},__values$2=commonjsGlobal&&commonjsGlobal.__values||function(e){var t="function"==typeof Symbol&&e[Symbol.iterator],n=0;return t?t.call(e):{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}},__importStar$3=commonjsGlobal&&commonjsGlobal.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t},_a;Object.defineProperty(matrix$2,"__esModule",{value:!0});var utils$3=__importStar$3(utils$5),SparseMatrix=(function(){function e(e,t,n,r){if(this.entries=new Map,this.nRows=0,this.nCols=0,e.length!==t.length||e.length!==n.length)throw new Error("rows, cols and values arrays must all have the same length");this.nRows=r[0],this.nCols=r[1];for(var i=0;i<n.length;i++){var a=e[i],o=t[i];this.checkDims(a,o);var s=this.makeKey(a,o);this.entries.set(s,{value:n[i],row:a,col:o})}}return e.prototype.makeKey=function(e,t){return e+":"+t},e.prototype.checkDims=function(e,t){if(!(e<this.nRows&&t<this.nCols))throw new Error("row and/or col specified outside of matrix dimensions")},e.prototype.set=function(e,t,n){this.checkDims(e,t);var r=this.makeKey(e,t);this.entries.has(r)?this.entries.get(r).value=n:this.entries.set(r,{value:n,row:e,col:t})},e.prototype.get=function(e,t,n){void 0===n&&(n=0),this.checkDims(e,t);var r=this.makeKey(e,t);return this.entries.has(r)?this.entries.get(r).value:n},e.prototype.getAll=function(e){void 0===e&&(e=!0);var t=[];return this.entries.forEach((function(e){t.push(e)})),e&&t.sort((function(e,t){return e.row===t.row?e.col-t.col:e.row-t.row})),t},e.prototype.getDims=function(){return[this.nRows,this.nCols]},e.prototype.getRows=function(){return Array.from(this.entries,(function(e){var t=__read$2(e,2);return t[1].row}))},e.prototype.getCols=function(){return Array.from(this.entries,(function(e){var t=__read$2(e,2);return t[1].col}))},e.prototype.getValues=function(){return Array.from(this.entries,(function(e){var t=__read$2(e,2);return t[1].value}))},e.prototype.forEach=function(e){this.entries.forEach((function(t){return e(t.value,t.row,t.col)}))},e.prototype.map=function(t){var n=[];this.entries.forEach((function(e){n.push(t(e.value,e.row,e.col))}));var r=[this.nRows,this.nCols];return new e(this.getRows(),this.getCols(),n,r)},e.prototype.toArray=function(){var e=this,t=utils$3.empty(this.nRows).map((function(){return utils$3.zeros(e.nCols)}));return this.entries.forEach((function(e){t[e.row][e.col]=e.value})),t},e})();function transpose$3(e){var t=[],n=[],r=[];return e.forEach((function(e,i,a){t.push(i),n.push(a),r.push(e)})),new SparseMatrix(n,t,r,[e.nCols,e.nRows])}function identity$4(e){for(var t=__read$2(e,1)[0],n=new SparseMatrix([],[],[],e),r=0;r<t;r++)n.set(r,r,1);return n}function pairwiseMultiply(e,t){return elementWise(e,t,(function(e,t){return e*t}))}function add$2(e,t){return elementWise(e,t,(function(e,t){return e+t}))}function subtract(e,t){return elementWise(e,t,(function(e,t){return e-t}))}function maximum$2(e,t){return elementWise(e,t,(function(e,t){return e>t?e:t}))}function multiplyScalar(e,t){return e.map((function(e){return e*t}))}function eliminateZeros(e){for(var t=new Set,n=e.getValues(),r=e.getRows(),i=e.getCols(),a=0;a<n.length;a++)0===n[a]&&t.add(a);var o=function(e,n){return!t.has(n)},s=n.filter(o),l=r.filter(o),c=i.filter(o);return new SparseMatrix(l,c,s,e.getDims())}function normalize$1(e,t){var n,r;void 0===t&&(t="l2");var i=normFns[t],a=new Map;e.forEach((function(e,t,n){var r=a.get(t)||[];r.push(n),a.set(t,r)}));var o=new SparseMatrix([],[],[],e.getDims()),s=function(t){for(var n=a.get(t).sort(),r=n.map((function(n){return e.get(t,n)})),s=i(r),l=0;l<s.length;l++)o.set(t,n[l],s[l])};try{for(var l=__values$2(a.keys()),c=l.next();!c.done;c=l.next()){s(c.value)}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=l.return)&&r.call(l)}finally{if(n)throw n.error}}return o}matrix$2.SparseMatrix=SparseMatrix,matrix$2.transpose=transpose$3,matrix$2.identity=identity$4,matrix$2.pairwiseMultiply=pairwiseMultiply,matrix$2.add=add$2,matrix$2.subtract=subtract,matrix$2.maximum=maximum$2,matrix$2.multiplyScalar=multiplyScalar,matrix$2.eliminateZeros=eliminateZeros,matrix$2.normalize=normalize$1;var normFns=(_a={},_a.max=function(e){for(var t=-1/0,n=0;n<e.length;n++)t=e[n]>t?e[n]:t;return e.map((function(e){return e/t}))},_a.l1=function(e){for(var t=0,n=0;n<e.length;n++)t+=e[n];return e.map((function(e){return e/t}))},_a.l2=function(e){for(var t=0,n=0;n<e.length;n++)t+=Math.pow(e[n],2);return e.map((function(e){return Math.sqrt(Math.pow(e,2)/t)}))},_a);function elementWise(e,t,n){for(var r=new Set,i=[],a=[],o=[],s=function(r,s){i.push(r),a.push(s);var l=n(e.get(r,s),t.get(r,s));o.push(l)},l=e.getValues(),c=e.getRows(),h=e.getCols(),u=0;u<l.length;u++){r.add((f=c[u])+":"+(g=h[u])),s(f,g)}var d=t.getValues(),p=t.getRows(),m=t.getCols();for(u=0;u<d.length;u++){var f,g;r.has((f=p[u])+":"+(g=m[u]))||s(f,g)}return new SparseMatrix(i,a,o,[e.nRows,e.nCols])}function getCSR(e){var t=[];e.forEach((function(e,n,r){t.push({value:e,row:n,col:r})})),t.sort((function(e,t){return e.row===t.row?e.col-t.col:e.row-t.row}));for(var n=[],r=[],i=[],a=-1,o=0;o<t.length;o++){var s=t[o],l=s.row,c=s.col,h=s.value;l!==a&&(a=l,i.push(o)),n.push(c),r.push(h)}return{indices:n,values:r,indptr:i}}matrix$2.getCSR=getCSR;var nn_descent={},tree$2={},__read$1=commonjsGlobal&&commonjsGlobal.__read||function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,a=n.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(r=a.next()).done;)o.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=a.return)&&n.call(a)}finally{if(i)throw i.error}}return o},__spread$1=commonjsGlobal&&commonjsGlobal.__spread||function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(__read$1(arguments[t]));return e},__values$1=commonjsGlobal&&commonjsGlobal.__values||function(e){var t="function"==typeof Symbol&&e[Symbol.iterator],n=0;return t?t.call(e):{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}},__importStar$2=commonjsGlobal&&commonjsGlobal.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t};Object.defineProperty(tree$2,"__esModule",{value:!0});var utils$2=__importStar$2(utils$5),FlatTree=function FlatTree(e,t,n,r){this.hyperplanes=e,this.offsets=t,this.children=n,this.indices=r};function makeForest(e,t,n,r){var i=Math.max(10,t);return utils$2.range(n).map((function(t,n){return makeTree(e,i,n,r)})).map((function(e){return flattenTree(e,i)}))}function makeTree(e,t,n,r){return void 0===t&&(t=30),makeEuclideanTree(e,utils$2.range(e.length),t,n,r)}function makeEuclideanTree(e,t,n,r,i){if(void 0===n&&(n=30),t.length>n){var a=euclideanRandomProjectionSplit(e,t,i),o=a.indicesRight,s=a.hyperplane,l=a.offset;return{leftChild:makeEuclideanTree(e,a.indicesLeft,n,r+1,i),rightChild:makeEuclideanTree(e,o,n,r+1,i),isLeaf:!1,hyperplane:s,offset:l}}return{indices:t,isLeaf:!0}}function euclideanRandomProjectionSplit(e,t,n){var r=e[0].length,i=utils$2.tauRandInt(t.length,n),a=utils$2.tauRandInt(t.length,n);a+=i===a?1:0;for(var o=t[i],s=t[a%=t.length],l=0,c=utils$2.zeros(r),h=0;h<c.length;h++)c[h]=e[o][h]-e[s][h],l-=c[h]*(e[o][h]+e[s][h])/2;var u=0,d=0,p=utils$2.zeros(t.length);for(h=0;h<t.length;h++){for(var m=l,f=0;f<r;f++)m+=c[f]*e[t[h]][f];0===m?(p[h]=utils$2.tauRandInt(2,n),0===p[h]?u+=1:d+=1):m>0?(p[h]=0,u+=1):(p[h]=1,d+=1)}var g=utils$2.zeros(u),v=utils$2.zeros(d);u=0,d=0;for(h=0;h<p.length;h++)0===p[h]?(g[u]=t[h],u+=1):(v[d]=t[h],d+=1);return{indicesLeft:g,indicesRight:v,hyperplane:c,offset:l}}function flattenTree(e,t){var n=numNodes(e),r=numLeaves(e),i=utils$2.range(n).map((function(){return utils$2.zeros(e.hyperplane?e.hyperplane.length:0)})),a=utils$2.zeros(n),o=utils$2.range(n).map((function(){return[-1,-1]})),s=utils$2.range(r).map((function(){return utils$2.range(t).map((function(){return-1}))}));return recursiveFlatten(e,i,a,o,s,0,0),new FlatTree(i,a,o,s)}function recursiveFlatten(e,t,n,r,i,a,o){var s;if(e.isLeaf)return r[a][0]=-o,(s=i[o]).splice.apply(s,__spread$1([0,e.indices.length],e.indices)),{nodeNum:a,leafNum:o+=1};t[a]=e.hyperplane,n[a]=e.offset,r[a][0]=a+1;var l=a,c=recursiveFlatten(e.leftChild,t,n,r,i,a+1,o);return o=c.leafNum,r[l][1]=(a=c.nodeNum)+1,{nodeNum:(c=recursiveFlatten(e.rightChild,t,n,r,i,a+1,o)).nodeNum,leafNum:c.leafNum}}function numNodes(e){return e.isLeaf?1:1+numNodes(e.leftChild)+numNodes(e.rightChild)}function numLeaves(e){return e.isLeaf?1:numLeaves(e.leftChild)+numLeaves(e.rightChild)}function makeLeafArray(e){var t,n;if(e.length>0){var r=[];try{for(var i=__values$1(e),a=i.next();!a.done;a=i.next()){r.push.apply(r,__spread$1(a.value.indices))}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return r}return[[-1]]}function selectSide(e,t,n,r){for(var i=t,a=0;a<n.length;a++)i+=e[a]*n[a];return 0===i?utils$2.tauRandInt(2,r):i>0?0:1}function searchFlatTree(e,t,n){for(var r=0;t.children[r][0]>0;){r=0===selectSide(t.hyperplanes[r],t.offsets[r],e,n)?t.children[r][0]:t.children[r][1]}return t.indices[-1*t.children[r][0]]}tree$2.FlatTree=FlatTree,tree$2.makeForest=makeForest,tree$2.makeLeafArray=makeLeafArray,tree$2.searchFlatTree=searchFlatTree;var __values=commonjsGlobal&&commonjsGlobal.__values||function(e){var t="function"==typeof Symbol&&e[Symbol.iterator],n=0;return t?t.call(e):{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}},__importStar$1=commonjsGlobal&&commonjsGlobal.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t};Object.defineProperty(nn_descent,"__esModule",{value:!0});var heap$1=__importStar$1(heap$2),matrix$1=__importStar$1(matrix$2),tree$1=__importStar$1(tree$2),utils$1=__importStar$1(utils$5);function makeNNDescent(e,t){return function n(r,i,a,o,s,l,c,h){void 0===o&&(o=10),void 0===s&&(s=50),void 0===l&&(l=.001),void 0===c&&(c=.5),void 0===h&&(h=!0);for(var u=r.length,d=heap$1.makeHeap(r.length,a),p=0;p<r.length;p++)for(var m=heap$1.rejectionSample(a,r.length,t),f=0;f<m.length;f++){var g=e(r[p],r[m[f]]);heap$1.heapPush(d,p,g,m[f],1),heap$1.heapPush(d,m[f],g,p,1)}if(h)for(var v=0;v<i.length;v++)for(p=0;p<i[v].length&&!(i[v][p]<0);p++)for(f=p+1;f<i[v].length&&!(i[v][f]<0);f++){g=e(r[i[v][p]],r[i[v][f]]);heap$1.heapPush(d,i[v][p],g,i[v][f],1),heap$1.heapPush(d,i[v][f],g,i[v][p],1)}for(v=0;v<o;v++){var y=heap$1.buildCandidates(d,u,a,s,t),_=0;for(p=0;p<u;p++)for(f=0;f<s;f++){var b=Math.floor(y[0][p][f]);if(!(b<0||utils$1.tauRand(t)<c))for(var x=0;x<s;x++){var S=Math.floor(y[0][p][x]);if(!(S<0||!y[2][p][f]&&!y[2][p][x])){g=e(r[b],r[S]);_+=heap$1.heapPush(d,b,g,S,1),_+=heap$1.heapPush(d,S,g,b,1)}}}if(_<=l*a*r.length)break}return heap$1.deheapSort(d)}}function makeInitializations(e){return{initFromRandom:function t(n,r,i,a,o){for(var s=0;s<i.length;s++)for(var l=utils$1.rejectionSample(n,r.length,o),c=0;c<l.length;c++)if(!(l[c]<0)){var h=e(r[l[c]],i[s]);heap$1.heapPush(a,s,h,l[c],1)}},initFromTree:function n(t,r,i,a,o){for(var s=0;s<i.length;s++)for(var l=tree$1.searchFlatTree(i[s],t,o),c=0;c<l.length;c++){if(l[c]<0)return;var h=e(r[l[c]],i[s]);heap$1.heapPush(a,s,h,l[c],1)}}}}function makeInitializedNNSearch(e){return function t(n,r,i,a){for(var o,s,l=matrix$1.getCSR(r),c=l.indices,h=l.indptr,u=0;u<a.length;u++)for(var d=new Set(i[0][u]);;){var p=heap$1.smallestFlagged(i,u);if(-1===p)break;var m=c.slice(h[p],h[p+1]);try{for(var f=__values(m),g=f.next();!g.done;g=f.next()){var v=g.value;if(v!==p&&-1!==v&&!d.has(v)){var y=e(n[v],a[u]);heap$1.uncheckedHeapPush(i,u,y,v,1),d.add(v)}}}catch(e){o={error:e}}finally{try{g&&!g.done&&(s=f.return)&&s.call(f)}finally{if(o)throw o.error}}}return i}}function initializeSearch(e,t,n,r,i,a,o){var s,l,c=heap$1.makeHeap(n.length,r);if(i(r,t,n,c,o),e)try{for(var h=__values(e),u=h.next();!u.done;u=h.next()){a(u.value,t,n,c,o)}}catch(e){s={error:e}}finally{try{u&&!u.done&&(l=h.return)&&l.call(h)}finally{if(s)throw s.error}}return c}nn_descent.makeNNDescent=makeNNDescent,nn_descent.makeInitializations=makeInitializations,nn_descent.makeInitializedNNSearch=makeInitializedNNSearch,nn_descent.initializeSearch=initializeSearch;const toString$1=Object.prototype.toString;function isAnyArray$1(e){return toString$1.call(e).endsWith("Array]")}function errorCalculation(e,t,n){let r=0;const i=n(t);for(let t=0;t<e.x.length;t++)r+=Math.abs(e.y[t]-i(e.x[t]));return r}const toString=Object.prototype.toString;function isAnyArray(e){return toString.call(e).endsWith("Array]")}function max$2(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!isAnyArray(e))throw new TypeError("input must be an array");if(0===e.length)throw new TypeError("input must not be empty");var n=t.fromIndex,r=void 0===n?0:n,i=t.toIndex,a=void 0===i?e.length:i;if(r<0||r>=e.length||!Number.isInteger(r))throw new Error("fromIndex must be a positive integer smaller than length");if(a<=r||a>e.length||!Number.isInteger(a))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var o=e[r],s=r+1;s<a;s++)e[s]>o&&(o=e[s]);return o}function min$2(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!isAnyArray(e))throw new TypeError("input must be an array");if(0===e.length)throw new TypeError("input must not be empty");var n=t.fromIndex,r=void 0===n?0:n,i=t.toIndex,a=void 0===i?e.length:i;if(r<0||r>=e.length||!Number.isInteger(r))throw new Error("fromIndex must be a positive integer smaller than length");if(a<=r||a>e.length||!Number.isInteger(a))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var o=e[r],s=r+1;s<a;s++)e[s]<o&&(o=e[s]);return o}function rescale(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!isAnyArray(e))throw new TypeError("input must be an array");if(0===e.length)throw new TypeError("input must not be empty");if(void 0!==n.output){if(!isAnyArray(n.output))throw new TypeError("output option must be an array if specified");t=n.output}else t=new Array(e.length);var r=min$2(e),i=max$2(e);if(r===i)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var a=n.min,o=void 0===a?n.autoMinMax?r:0:a,s=n.max,l=void 0===s?n.autoMinMax?i:1:s;if(o>=l)throw new RangeError("min option must be smaller than max option");for(var c=(l-o)/(i-r),h=0;h<e.length;h++)t[h]=(e[h]-r)*c+o;return t}const indent=" ".repeat(2),indentData=" ".repeat(4);function inspectMatrix(){return inspectMatrixWithOptions(this)}function inspectMatrixWithOptions(e,t={}){const{maxRows:n=15,maxColumns:r=10,maxNumSize:i=8}=t;return`${e.constructor.name} {\n${indent}[\n${indentData}${inspectData(e,n,r,i)}\n${indent}]\n${indent}rows: ${e.rows}\n${indent}columns: ${e.columns}\n}`}function inspectData(e,t,n,r){const{rows:i,columns:a}=e,o=Math.min(i,t),s=Math.min(a,n),l=[];for(let t=0;t<o;t++){let n=[];for(let i=0;i<s;i++)n.push(formatNumber(e.get(t,i),r));l.push(`${n.join(" ")}`)}return s!==a&&(l[l.length-1]+=` ... ${a-n} more columns`),o!==i&&l.push(`... ${i-t} more rows`),l.join(`\n${indentData}`)}function formatNumber(e,t){const n=String(e);if(n.length<=t)return n.padEnd(t," ");const r=e.toPrecision(t-2);if(r.length<=t)return r;const i=e.toExponential(t-2),a=i.indexOf("e"),o=i.slice(a);return i.slice(0,t-o.length)+o}function installMathOperations(e,t){e.prototype.add=function e(t){return"number"==typeof t?this.addS(t):this.addM(t)},e.prototype.addS=function e(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)+t);return this},e.prototype.addM=function e(n){if(n=t.checkMatrix(n),this.rows!==n.rows||this.columns!==n.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,this.get(e,t)+n.get(e,t));return this},e.add=function e(n,r){return new t(n).add(r)},e.prototype.sub=function e(t){return"number"==typeof t?this.subS(t):this.subM(t)},e.prototype.subS=function e(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)-t);return this},e.prototype.subM=function e(n){if(n=t.checkMatrix(n),this.rows!==n.rows||this.columns!==n.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,this.get(e,t)-n.get(e,t));return this},e.sub=function e(n,r){return new t(n).sub(r)},e.prototype.subtract=e.prototype.sub,e.prototype.subtractS=e.prototype.subS,e.prototype.subtractM=e.prototype.subM,e.subtract=e.sub,e.prototype.mul=function e(t){return"number"==typeof t?this.mulS(t):this.mulM(t)},e.prototype.mulS=function e(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)*t);return this},e.prototype.mulM=function e(n){if(n=t.checkMatrix(n),this.rows!==n.rows||this.columns!==n.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,this.get(e,t)*n.get(e,t));return this},e.mul=function e(n,r){return new t(n).mul(r)},e.prototype.multiply=e.prototype.mul,e.prototype.multiplyS=e.prototype.mulS,e.prototype.multiplyM=e.prototype.mulM,e.multiply=e.mul,e.prototype.div=function e(t){return"number"==typeof t?this.divS(t):this.divM(t)},e.prototype.divS=function e(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)/t);return this},e.prototype.divM=function e(n){if(n=t.checkMatrix(n),this.rows!==n.rows||this.columns!==n.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,this.get(e,t)/n.get(e,t));return this},e.div=function e(n,r){return new t(n).div(r)},e.prototype.divide=e.prototype.div,e.prototype.divideS=e.prototype.divS,e.prototype.divideM=e.prototype.divM,e.divide=e.div,e.prototype.mod=function e(t){return"number"==typeof t?this.modS(t):this.modM(t)},e.prototype.modS=function e(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)%t);return this},e.prototype.modM=function e(n){if(n=t.checkMatrix(n),this.rows!==n.rows||this.columns!==n.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,this.get(e,t)%n.get(e,t));return this},e.mod=function e(n,r){return new t(n).mod(r)},e.prototype.modulus=e.prototype.mod,e.prototype.modulusS=e.prototype.modS,e.prototype.modulusM=e.prototype.modM,e.modulus=e.mod,e.prototype.and=function e(t){return"number"==typeof t?this.andS(t):this.andM(t)},e.prototype.andS=function e(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)&t);return this},e.prototype.andM=function e(n){if(n=t.checkMatrix(n),this.rows!==n.rows||this.columns!==n.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,this.get(e,t)&n.get(e,t));return this},e.and=function e(n,r){return new t(n).and(r)},e.prototype.or=function e(t){return"number"==typeof t?this.orS(t):this.orM(t)},e.prototype.orS=function e(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)|t);return this},e.prototype.orM=function e(n){if(n=t.checkMatrix(n),this.rows!==n.rows||this.columns!==n.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,this.get(e,t)|n.get(e,t));return this},e.or=function e(n,r){return new t(n).or(r)},e.prototype.xor=function e(t){return"number"==typeof t?this.xorS(t):this.xorM(t)},e.prototype.xorS=function e(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)^t);return this},e.prototype.xorM=function e(n){if(n=t.checkMatrix(n),this.rows!==n.rows||this.columns!==n.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,this.get(e,t)^n.get(e,t));return this},e.xor=function e(n,r){return new t(n).xor(r)},e.prototype.leftShift=function e(t){return"number"==typeof t?this.leftShiftS(t):this.leftShiftM(t)},e.prototype.leftShiftS=function e(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)<<t);return this},e.prototype.leftShiftM=function e(n){if(n=t.checkMatrix(n),this.rows!==n.rows||this.columns!==n.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,this.get(e,t)<<n.get(e,t));return this},e.leftShift=function e(n,r){return new t(n).leftShift(r)},e.prototype.signPropagatingRightShift=function e(t){return"number"==typeof t?this.signPropagatingRightShiftS(t):this.signPropagatingRightShiftM(t)},e.prototype.signPropagatingRightShiftS=function e(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)>>t);return this},e.prototype.signPropagatingRightShiftM=function e(n){if(n=t.checkMatrix(n),this.rows!==n.rows||this.columns!==n.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,this.get(e,t)>>n.get(e,t));return this},e.signPropagatingRightShift=function e(n,r){return new t(n).signPropagatingRightShift(r)},e.prototype.rightShift=function e(t){return"number"==typeof t?this.rightShiftS(t):this.rightShiftM(t)},e.prototype.rightShiftS=function e(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)>>>t);return this},e.prototype.rightShiftM=function e(n){if(n=t.checkMatrix(n),this.rows!==n.rows||this.columns!==n.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,this.get(e,t)>>>n.get(e,t));return this},e.rightShift=function e(n,r){return new t(n).rightShift(r)},e.prototype.zeroFillRightShift=e.prototype.rightShift,e.prototype.zeroFillRightShiftS=e.prototype.rightShiftS,e.prototype.zeroFillRightShiftM=e.prototype.rightShiftM,e.zeroFillRightShift=e.rightShift,e.prototype.not=function e(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,~this.get(e,t));return this},e.not=function e(n){return new t(n).not()},e.prototype.abs=function e(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.abs(this.get(e,t)));return this},e.abs=function e(n){return new t(n).abs()},e.prototype.acos=function e(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.acos(this.get(e,t)));return this},e.acos=function e(n){return new t(n).acos()},e.prototype.acosh=function e(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.acosh(this.get(e,t)));return this},e.acosh=function e(n){return new t(n).acosh()},e.prototype.asin=function e(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.asin(this.get(e,t)));return this},e.asin=function e(n){return new t(n).asin()},e.prototype.asinh=function e(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.asinh(this.get(e,t)));return this},e.asinh=function e(n){return new t(n).asinh()},e.prototype.atan=function e(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.atan(this.get(e,t)));return this},e.atan=function e(n){return new t(n).atan()},e.prototype.atanh=function e(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.atanh(this.get(e,t)));return this},e.atanh=function e(n){return new t(n).atanh()},e.prototype.cbrt=function e(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.cbrt(this.get(e,t)));return this},e.cbrt=function e(n){return new t(n).cbrt()},e.prototype.ceil=function e(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.ceil(this.get(e,t)));return this},e.ceil=function e(n){return new t(n).ceil()},e.prototype.clz32=function e(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.clz32(this.get(e,t)));return this},e.clz32=function e(n){return new t(n).clz32()},e.prototype.cos=function e(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.cos(this.get(e,t)));return this},e.cos=function e(n){return new t(n).cos()},e.prototype.cosh=function e(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.cosh(this.get(e,t)));return this},e.cosh=function e(n){return new t(n).cosh()},e.prototype.exp=function e(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.exp(this.get(e,t)));return this},e.exp=function e(n){return new t(n).exp()},e.prototype.expm1=function e(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.expm1(this.get(e,t)));return this},e.expm1=function e(n){return new t(n).expm1()},e.prototype.floor=function e(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.floor(this.get(e,t)));return this},e.floor=function e(n){return new t(n).floor()},e.prototype.fround=function e(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.fround(this.get(e,t)));return this},e.fround=function e(n){return new t(n).fround()},e.prototype.log=function e(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.log(this.get(e,t)));return this},e.log=function e(n){return new t(n).log()},e.prototype.log1p=function e(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.log1p(this.get(e,t)));return this},e.log1p=function e(n){return new t(n).log1p()},e.prototype.log10=function e(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.log10(this.get(e,t)));return this},e.log10=function e(n){return new t(n).log10()},e.prototype.log2=function e(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.log2(this.get(e,t)));return this},e.log2=function e(n){return new t(n).log2()},e.prototype.round=function e(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.round(this.get(e,t)));return this},e.round=function e(n){return new t(n).round()},e.prototype.sign=function e(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.sign(this.get(e,t)));return this},e.sign=function e(n){return new t(n).sign()},e.prototype.sin=function e(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.sin(this.get(e,t)));return this},e.sin=function e(n){return new t(n).sin()},e.prototype.sinh=function e(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.sinh(this.get(e,t)));return this},e.sinh=function e(n){return new t(n).sinh()},e.prototype.sqrt=function e(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.sqrt(this.get(e,t)));return this},e.sqrt=function e(n){return new t(n).sqrt()},e.prototype.tan=function e(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.tan(this.get(e,t)));return this},e.tan=function e(n){return new t(n).tan()},e.prototype.tanh=function e(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.tanh(this.get(e,t)));return this},e.tanh=function e(n){return new t(n).tanh()},e.prototype.trunc=function e(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.trunc(this.get(e,t)));return this},e.trunc=function e(n){return new t(n).trunc()},e.pow=function e(n,r){return new t(n).pow(r)},e.prototype.pow=function e(t){return"number"==typeof t?this.powS(t):this.powM(t)},e.prototype.powS=function e(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,Math.pow(this.get(e,n),t));return this},e.prototype.powM=function e(n){if(n=t.checkMatrix(n),this.rows!==n.rows||this.columns!==n.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)this.set(e,t,Math.pow(this.get(e,t),n.get(e,t)));return this}}function checkRowIndex(e,t,n){if(t<0||t>(n?e.rows:e.rows-1))throw new RangeError("Row index out of range")}function checkColumnIndex(e,t,n){if(t<0||t>(n?e.columns:e.columns-1))throw new RangeError("Column index out of range")}function checkRowVector(e,t){if(t.to1DArray&&(t=t.to1DArray()),t.length!==e.columns)throw new RangeError("vector size must be the same as the number of columns");return t}function checkColumnVector(e,t){if(t.to1DArray&&(t=t.to1DArray()),t.length!==e.rows)throw new RangeError("vector size must be the same as the number of rows");return t}function checkIndices(e,t,n){return{row:checkRowIndices(e,t),column:checkColumnIndices(e,n)}}function checkRowIndices(e,t){if("object"!=typeof t)throw new TypeError("unexpected type for row indices");if(t.some((t=>t<0||t>=e.rows)))throw new RangeError("row indices are out of range");return Array.isArray(t)||(t=Array.from(t)),t}function checkColumnIndices(e,t){if("object"!=typeof t)throw new TypeError("unexpected type for column indices");if(t.some((t=>t<0||t>=e.columns)))throw new RangeError("column indices are out of range");return Array.isArray(t)||(t=Array.from(t)),t}function checkRange(e,t,n,r,i){if(5!==arguments.length)throw new RangeError("expected 4 arguments");if(checkNumber("startRow",t),checkNumber("endRow",n),checkNumber("startColumn",r),checkNumber("endColumn",i),t>n||r>i||t<0||t>=e.rows||n<0||n>=e.rows||r<0||r>=e.columns||i<0||i>=e.columns)throw new RangeError("Submatrix indices are out of range")}function newArray(e,t=0){let n=[];for(let r=0;r<e;r++)n.push(t);return n}function checkNumber(e,t){if("number"!=typeof t)throw new TypeError(`${e} must be a number`)}function checkNonEmpty(e){if(e.isEmpty())throw new Error("Empty matrix has no elements to index")}function sumByRow(e){let t=newArray(e.rows);for(let n=0;n<e.rows;++n)for(let r=0;r<e.columns;++r)t[n]+=e.get(n,r);return t}function sumByColumn(e){let t=newArray(e.columns);for(let n=0;n<e.rows;++n)for(let r=0;r<e.columns;++r)t[r]+=e.get(n,r);return t}function sumAll(e){let t=0;for(let n=0;n<e.rows;n++)for(let r=0;r<e.columns;r++)t+=e.get(n,r);return t}function productByRow(e){let t=newArray(e.rows,1);for(let n=0;n<e.rows;++n)for(let r=0;r<e.columns;++r)t[n]*=e.get(n,r);return t}function productByColumn(e){let t=newArray(e.columns,1);for(let n=0;n<e.rows;++n)for(let r=0;r<e.columns;++r)t[r]*=e.get(n,r);return t}function productAll(e){let t=1;for(let n=0;n<e.rows;n++)for(let r=0;r<e.columns;r++)t*=e.get(n,r);return t}function varianceByRow(e,t,n){const r=e.rows,i=e.columns,a=[];for(let o=0;o<r;o++){let r=0,s=0,l=0;for(let t=0;t<i;t++)l=e.get(o,t)-n[o],r+=l,s+=l*l;a.push(t?(s-r*r/i)/(i-1):(s-r*r/i)/i)}return a}function varianceByColumn(e,t,n){const r=e.rows,i=e.columns,a=[];for(let o=0;o<i;o++){let i=0,s=0,l=0;for(let t=0;t<r;t++)l=e.get(t,o)-n[o],i+=l,s+=l*l;a.push(t?(s-i*i/r)/(r-1):(s-i*i/r)/r)}return a}function varianceAll(e,t,n){const r=e.rows,i=e.columns,a=r*i;let o=0,s=0,l=0;for(let t=0;t<r;t++)for(let r=0;r<i;r++)l=e.get(t,r)-n,o+=l,s+=l*l;return t?(s-o*o/a)/(a-1):(s-o*o/a)/a}function centerByRow(e,t){for(let n=0;n<e.rows;n++)for(let r=0;r<e.columns;r++)e.set(n,r,e.get(n,r)-t[n])}function centerByColumn(e,t){for(let n=0;n<e.rows;n++)for(let r=0;r<e.columns;r++)e.set(n,r,e.get(n,r)-t[r])}function centerAll(e,t){for(let n=0;n<e.rows;n++)for(let r=0;r<e.columns;r++)e.set(n,r,e.get(n,r)-t)}function getScaleByRow(e){const t=[];for(let n=0;n<e.rows;n++){let r=0;for(let t=0;t<e.columns;t++)r+=Math.pow(e.get(n,t),2)/(e.columns-1);t.push(Math.sqrt(r))}return t}function scaleByRow(e,t){for(let n=0;n<e.rows;n++)for(let r=0;r<e.columns;r++)e.set(n,r,e.get(n,r)/t[n])}function getScaleByColumn(e){const t=[];for(let n=0;n<e.columns;n++){let r=0;for(let t=0;t<e.rows;t++)r+=Math.pow(e.get(t,n),2)/(e.rows-1);t.push(Math.sqrt(r))}return t}function scaleByColumn(e,t){for(let n=0;n<e.rows;n++)for(let r=0;r<e.columns;r++)e.set(n,r,e.get(n,r)/t[r])}function getScaleAll(e){const t=e.size-1;let n=0;for(let r=0;r<e.columns;r++)for(let i=0;i<e.rows;i++)n+=Math.pow(e.get(i,r),2)/t;return Math.sqrt(n)}function scaleAll(e,t){for(let n=0;n<e.rows;n++)for(let r=0;r<e.columns;r++)e.set(n,r,e.get(n,r)/t)}class AbstractMatrix{static from1DArray(e,t,n){if(e*t!==n.length)throw new RangeError("data length does not match given dimensions");let r=new Matrix(e,t);for(let i=0;i<e;i++)for(let e=0;e<t;e++)r.set(i,e,n[i*t+e]);return r}static rowVector(e){let t=new Matrix(1,e.length);for(let n=0;n<e.length;n++)t.set(0,n,e[n]);return t}static columnVector(e){let t=new Matrix(e.length,1);for(let n=0;n<e.length;n++)t.set(n,0,e[n]);return t}static zeros(e,t){return new Matrix(e,t)}static ones(e,t){return new Matrix(e,t).fill(1)}static rand(e,t,n={}){if("object"!=typeof n)throw new TypeError("options must be an object");const{random:r=Math.random}=n;let i=new Matrix(e,t);for(let n=0;n<e;n++)for(let e=0;e<t;e++)i.set(n,e,r());return i}static randInt(e,t,n={}){if("object"!=typeof n)throw new TypeError("options must be an object");const{min:r=0,max:i=1e3,random:a=Math.random}=n;if(!Number.isInteger(r))throw new TypeError("min must be an integer");if(!Number.isInteger(i))throw new TypeError("max must be an integer");if(r>=i)throw new RangeError("min must be smaller than max");let o=i-r,s=new Matrix(e,t);for(let n=0;n<e;n++)for(let e=0;e<t;e++){let t=r+Math.round(a()*o);s.set(n,e,t)}return s}static eye(e,t,n){void 0===t&&(t=e),void 0===n&&(n=1);let r=Math.min(e,t),i=this.zeros(e,t);for(let e=0;e<r;e++)i.set(e,e,n);return i}static diag(e,t,n){let r=e.length;void 0===t&&(t=r),void 0===n&&(n=t);let i=Math.min(r,t,n),a=this.zeros(t,n);for(let t=0;t<i;t++)a.set(t,t,e[t]);return a}static min(e,t){e=this.checkMatrix(e),t=this.checkMatrix(t);let n=e.rows,r=e.columns,i=new Matrix(n,r);for(let a=0;a<n;a++)for(let n=0;n<r;n++)i.set(a,n,Math.min(e.get(a,n),t.get(a,n)));return i}static max(e,t){e=this.checkMatrix(e),t=this.checkMatrix(t);let n=e.rows,r=e.columns,i=new this(n,r);for(let a=0;a<n;a++)for(let n=0;n<r;n++)i.set(a,n,Math.max(e.get(a,n),t.get(a,n)));return i}static checkMatrix(e){return AbstractMatrix.isMatrix(e)?e:new Matrix(e)}static isMatrix(e){return null!=e&&"Matrix"===e.klass}get size(){return this.rows*this.columns}apply(e){if("function"!=typeof e)throw new TypeError("callback must be a function");for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)e.call(this,t,n);return this}to1DArray(){let e=[];for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)e.push(this.get(t,n));return e}to2DArray(){let e=[];for(let t=0;t<this.rows;t++){e.push([]);for(let n=0;n<this.columns;n++)e[t].push(this.get(t,n))}return e}toJSON(){return this.to2DArray()}isRowVector(){return 1===this.rows}isColumnVector(){return 1===this.columns}isVector(){return 1===this.rows||1===this.columns}isSquare(){return this.rows===this.columns}isEmpty(){return 0===this.rows||0===this.columns}isSymmetric(){if(this.isSquare()){for(let e=0;e<this.rows;e++)for(let t=0;t<=e;t++)if(this.get(e,t)!==this.get(t,e))return!1;return!0}return!1}isEchelonForm(){let e=0,t=0,n=-1,r=!0,i=!1;for(;e<this.rows&&r;){for(t=0,i=!1;t<this.columns&&!1===i;)0===this.get(e,t)?t++:1===this.get(e,t)&&t>n?(i=!0,n=t):(r=!1,i=!0);e++}return r}isReducedEchelonForm(){let e=0,t=0,n=-1,r=!0,i=!1;for(;e<this.rows&&r;){for(t=0,i=!1;t<this.columns&&!1===i;)0===this.get(e,t)?t++:1===this.get(e,t)&&t>n?(i=!0,n=t):(r=!1,i=!0);for(let n=t+1;n<this.rows;n++)0!==this.get(e,n)&&(r=!1);e++}return r}echelonForm(){let e=this.clone(),t=0,n=0;for(;t<e.rows&&n<e.columns;){let r=t;for(let i=t;i<e.rows;i++)e.get(i,n)>e.get(r,n)&&(r=i);if(0===e.get(r,n))n++;else{e.swapRows(t,r);let i=e.get(t,n);for(let r=n;r<e.columns;r++)e.set(t,r,e.get(t,r)/i);for(let r=t+1;r<e.rows;r++){let i=e.get(r,n)/e.get(t,n);e.set(r,n,0);for(let a=n+1;a<e.columns;a++)e.set(r,a,e.get(r,a)-e.get(t,a)*i)}t++,n++}}return e}reducedEchelonForm(){let e=this.echelonForm(),t=e.columns,n=e.rows,r=n-1;for(;r>=0;)if(0===e.maxRow(r))r--;else{let i=0,a=!1;for(;i<n&&!1===a;)1===e.get(r,i)?a=!0:i++;for(let n=0;n<r;n++){let a=e.get(n,i);for(let o=i;o<t;o++){let t=e.get(n,o)-a*e.get(r,o);e.set(n,o,t)}}r--}return e}set(){throw new Error("set method is unimplemented")}get(){throw new Error("get method is unimplemented")}repeat(e={}){if("object"!=typeof e)throw new TypeError("options must be an object");const{rows:t=1,columns:n=1}=e;if(!Number.isInteger(t)||t<=0)throw new TypeError("rows must be a positive integer");if(!Number.isInteger(n)||n<=0)throw new TypeError("columns must be a positive integer");let r=new Matrix(this.rows*t,this.columns*n);for(let e=0;e<t;e++)for(let t=0;t<n;t++)r.setSubMatrix(this,this.rows*e,this.columns*t);return r}fill(e){for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,e);return this}neg(){return this.mulS(-1)}getRow(e){checkRowIndex(this,e);let t=[];for(let n=0;n<this.columns;n++)t.push(this.get(e,n));return t}getRowVector(e){return Matrix.rowVector(this.getRow(e))}setRow(e,t){checkRowIndex(this,e),t=checkRowVector(this,t);for(let n=0;n<this.columns;n++)this.set(e,n,t[n]);return this}swapRows(e,t){checkRowIndex(this,e),checkRowIndex(this,t);for(let n=0;n<this.columns;n++){let r=this.get(e,n);this.set(e,n,this.get(t,n)),this.set(t,n,r)}return this}getColumn(e){checkColumnIndex(this,e);let t=[];for(let n=0;n<this.rows;n++)t.push(this.get(n,e));return t}getColumnVector(e){return Matrix.columnVector(this.getColumn(e))}setColumn(e,t){checkColumnIndex(this,e),t=checkColumnVector(this,t);for(let n=0;n<this.rows;n++)this.set(n,e,t[n]);return this}swapColumns(e,t){checkColumnIndex(this,e),checkColumnIndex(this,t);for(let n=0;n<this.rows;n++){let r=this.get(n,e);this.set(n,e,this.get(n,t)),this.set(n,t,r)}return this}addRowVector(e){e=checkRowVector(this,e);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)+e[n]);return this}subRowVector(e){e=checkRowVector(this,e);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)-e[n]);return this}mulRowVector(e){e=checkRowVector(this,e);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)*e[n]);return this}divRowVector(e){e=checkRowVector(this,e);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)/e[n]);return this}addColumnVector(e){e=checkColumnVector(this,e);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)+e[t]);return this}subColumnVector(e){e=checkColumnVector(this,e);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)-e[t]);return this}mulColumnVector(e){e=checkColumnVector(this,e);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)*e[t]);return this}divColumnVector(e){e=checkColumnVector(this,e);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)/e[t]);return this}mulRow(e,t){checkRowIndex(this,e);for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)*t);return this}mulColumn(e,t){checkColumnIndex(this,e);for(let n=0;n<this.rows;n++)this.set(n,e,this.get(n,e)*t);return this}max(){if(this.isEmpty())return NaN;let e=this.get(0,0);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.get(t,n)>e&&(e=this.get(t,n));return e}maxIndex(){checkNonEmpty(this);let e=this.get(0,0),t=[0,0];for(let n=0;n<this.rows;n++)for(let r=0;r<this.columns;r++)this.get(n,r)>e&&(e=this.get(n,r),t[0]=n,t[1]=r);return t}min(){if(this.isEmpty())return NaN;let e=this.get(0,0);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)this.get(t,n)<e&&(e=this.get(t,n));return e}minIndex(){checkNonEmpty(this);let e=this.get(0,0),t=[0,0];for(let n=0;n<this.rows;n++)for(let r=0;r<this.columns;r++)this.get(n,r)<e&&(e=this.get(n,r),t[0]=n,t[1]=r);return t}maxRow(e){if(checkRowIndex(this,e),this.isEmpty())return NaN;let t=this.get(e,0);for(let n=1;n<this.columns;n++)this.get(e,n)>t&&(t=this.get(e,n));return t}maxRowIndex(e){checkRowIndex(this,e),checkNonEmpty(this);let t=this.get(e,0),n=[e,0];for(let r=1;r<this.columns;r++)this.get(e,r)>t&&(t=this.get(e,r),n[1]=r);return n}minRow(e){if(checkRowIndex(this,e),this.isEmpty())return NaN;let t=this.get(e,0);for(let n=1;n<this.columns;n++)this.get(e,n)<t&&(t=this.get(e,n));return t}minRowIndex(e){checkRowIndex(this,e),checkNonEmpty(this);let t=this.get(e,0),n=[e,0];for(let r=1;r<this.columns;r++)this.get(e,r)<t&&(t=this.get(e,r),n[1]=r);return n}maxColumn(e){if(checkColumnIndex(this,e),this.isEmpty())return NaN;let t=this.get(0,e);for(let n=1;n<this.rows;n++)this.get(n,e)>t&&(t=this.get(n,e));return t}maxColumnIndex(e){checkColumnIndex(this,e),checkNonEmpty(this);let t=this.get(0,e),n=[0,e];for(let r=1;r<this.rows;r++)this.get(r,e)>t&&(t=this.get(r,e),n[0]=r);return n}minColumn(e){if(checkColumnIndex(this,e),this.isEmpty())return NaN;let t=this.get(0,e);for(let n=1;n<this.rows;n++)this.get(n,e)<t&&(t=this.get(n,e));return t}minColumnIndex(e){checkColumnIndex(this,e),checkNonEmpty(this);let t=this.get(0,e),n=[0,e];for(let r=1;r<this.rows;r++)this.get(r,e)<t&&(t=this.get(r,e),n[0]=r);return n}diag(){let e=Math.min(this.rows,this.columns),t=[];for(let n=0;n<e;n++)t.push(this.get(n,n));return t}norm(e="frobenius"){let t=0;if("max"===e)return this.max();if("frobenius"===e){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)t+=this.get(e,n)*this.get(e,n);return Math.sqrt(t)}throw new RangeError(`unknown norm type: ${e}`)}cumulativeSum(){let e=0;for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)e+=this.get(t,n),this.set(t,n,e);return this}dot(e){AbstractMatrix.isMatrix(e)&&(e=e.to1DArray());let t=this.to1DArray();if(t.length!==e.length)throw new RangeError("vectors do not have the same size");let n=0;for(let r=0;r<t.length;r++)n+=t[r]*e[r];return n}mmul(e){e=Matrix.checkMatrix(e);let t=this.rows,n=this.columns,r=e.columns,i=new Matrix(t,r),a=new Float64Array(n);for(let o=0;o<r;o++){for(let t=0;t<n;t++)a[t]=e.get(t,o);for(let e=0;e<t;e++){let t=0;for(let r=0;r<n;r++)t+=this.get(e,r)*a[r];i.set(e,o,t)}}return i}strassen2x2(e){e=Matrix.checkMatrix(e);let t=new Matrix(2,2);const n=this.get(0,0),r=e.get(0,0),i=this.get(0,1),a=e.get(0,1),o=this.get(1,0),s=e.get(1,0),l=this.get(1,1),c=e.get(1,1),h=(n+l)*(r+c),u=(o+l)*r,d=n*(a-c),p=l*(s-r),m=(n+i)*c,f=d+m,g=u+p,v=h-u+d+(o-n)*(r+a);return t.set(0,0,h+p-m+(i-l)*(s+c)),t.set(0,1,f),t.set(1,0,g),t.set(1,1,v),t}strassen3x3(e){e=Matrix.checkMatrix(e);let t=new Matrix(3,3);const n=this.get(0,0),r=this.get(0,1),i=this.get(0,2),a=this.get(1,0),o=this.get(1,1),s=this.get(1,2),l=this.get(2,0),c=this.get(2,1),h=this.get(2,2),u=e.get(0,0),d=e.get(0,1),p=e.get(0,2),m=e.get(1,0),f=e.get(1,1),g=e.get(1,2),v=e.get(2,0),y=e.get(2,1),_=e.get(2,2),b=(n-a)*(-d+f),x=(-n+a+o)*(u-d+f),S=(a+o)*(-u+d),w=n*u,C=(-n+l+c)*(u-p+g),M=(-n+l)*(p-g),E=(l+c)*(-u+p),T=(-i+c+h)*(f+v-y),I=(i-h)*(f-y),A=i*v,k=(c+h)*(-v+y),P=(-i+o+s)*(g+v-_),R=(i-s)*(g-_),N=(o+s)*(-v+_),L=(n+r+i-a-o-c-h)*f+x+S+w+T+A+k,D=w+C+E+(n+r+i-o-s-l-c)*g+A+P+N,$=b+o*(-u+d+m-f-g-v+_)+x+w+A+P+R,z=b+x+S+w+s*y,F=A+P+R+N+a*p,O=w+C+M+c*(-u+p+m-f-g-v+y)+T+I+A,B=T+I+A+k+l*d,V=w+C+M+E+h*_;return t.set(0,0,w+A+r*m),t.set(0,1,L),t.set(0,2,D),t.set(1,0,$),t.set(1,1,z),t.set(1,2,F),t.set(2,0,O),t.set(2,1,B),t.set(2,2,V),t}mmulStrassen(e){e=Matrix.checkMatrix(e);let t=this.clone(),n=t.rows,r=t.columns,i=e.rows,a=e.columns;function o(e,t,n){if(e.rows===t&&e.columns===n)return e;{let r=AbstractMatrix.zeros(t,n);return r=r.setSubMatrix(e,0,0),r}}r!==i&&console.warn(`Multiplying ${n} x ${r} and ${i} x ${a} matrix: dimensions do not match.`);let s=Math.max(n,i),l=Math.max(r,a);return t=o(t,s,l),(function e(t,n,r,i){if(r<=512||i<=512)return t.mmul(n);r%2==1&&i%2==1?(t=o(t,r+1,i+1),n=o(n,r+1,i+1)):r%2==1?(t=o(t,r+1,i),n=o(n,r+1,i)):i%2==1&&(t=o(t,r,i+1),n=o(n,r,i+1));let a=parseInt(t.rows/2,10),s=parseInt(t.columns/2,10),l=t.subMatrix(0,a-1,0,s-1),c=n.subMatrix(0,a-1,0,s-1),h=t.subMatrix(0,a-1,s,t.columns-1),u=n.subMatrix(0,a-1,s,n.columns-1),d=t.subMatrix(a,t.rows-1,0,s-1),p=n.subMatrix(a,n.rows-1,0,s-1),m=t.subMatrix(a,t.rows-1,s,t.columns-1),f=n.subMatrix(a,n.rows-1,s,n.columns-1),g=e(AbstractMatrix.add(l,m),AbstractMatrix.add(c,f),a,s),v=e(AbstractMatrix.add(d,m),c,a,s),y=e(l,AbstractMatrix.sub(u,f),a,s),_=e(m,AbstractMatrix.sub(p,c),a,s),b=e(AbstractMatrix.add(l,h),f,a,s),x=e(AbstractMatrix.sub(d,l),AbstractMatrix.add(c,u),a,s),S=e(AbstractMatrix.sub(h,m),AbstractMatrix.add(p,f),a,s),w=AbstractMatrix.add(g,_);w.sub(b),w.add(S);let C=AbstractMatrix.add(y,b),M=AbstractMatrix.add(v,_),E=AbstractMatrix.sub(g,v);E.add(y),E.add(x);let T=AbstractMatrix.zeros(2*w.rows,2*w.columns);return T=T.setSubMatrix(w,0,0),T=T.setSubMatrix(C,w.rows,0),T=T.setSubMatrix(M,0,w.columns),T=T.setSubMatrix(E,w.rows,w.columns),T.subMatrix(0,r-1,0,i-1)})(t,e=o(e,s,l),s,l)}scaleRows(e={}){if("object"!=typeof e)throw new TypeError("options must be an object");const{min:t=0,max:n=1}=e;if(!Number.isFinite(t))throw new TypeError("min must be a number");if(!Number.isFinite(n))throw new TypeError("max must be a number");if(t>=n)throw new RangeError("min must be smaller than max");let r=new Matrix(this.rows,this.columns);for(let e=0;e<this.rows;e++){const i=this.getRow(e);i.length>0&&rescale(i,{min:t,max:n,output:i}),r.setRow(e,i)}return r}scaleColumns(e={}){if("object"!=typeof e)throw new TypeError("options must be an object");const{min:t=0,max:n=1}=e;if(!Number.isFinite(t))throw new TypeError("min must be a number");if(!Number.isFinite(n))throw new TypeError("max must be a number");if(t>=n)throw new RangeError("min must be smaller than max");let r=new Matrix(this.rows,this.columns);for(let e=0;e<this.columns;e++){const i=this.getColumn(e);i.length&&rescale(i,{min:t,max:n,output:i}),r.setColumn(e,i)}return r}flipRows(){const e=Math.ceil(this.columns/2);for(let t=0;t<this.rows;t++)for(let n=0;n<e;n++){let e=this.get(t,n),r=this.get(t,this.columns-1-n);this.set(t,n,r),this.set(t,this.columns-1-n,e)}return this}flipColumns(){const e=Math.ceil(this.rows/2);for(let t=0;t<this.columns;t++)for(let n=0;n<e;n++){let e=this.get(n,t),r=this.get(this.rows-1-n,t);this.set(n,t,r),this.set(this.rows-1-n,t,e)}return this}kroneckerProduct(e){e=Matrix.checkMatrix(e);let t=this.rows,n=this.columns,r=e.rows,i=e.columns,a=new Matrix(t*r,n*i);for(let o=0;o<t;o++)for(let t=0;t<n;t++)for(let n=0;n<r;n++)for(let s=0;s<i;s++)a.set(r*o+n,i*t+s,this.get(o,t)*e.get(n,s));return a}kroneckerSum(e){if(e=Matrix.checkMatrix(e),!this.isSquare()||!e.isSquare())throw new Error("Kronecker Sum needs two Square Matrices");let t=this.rows,n=e.rows,r=this.kroneckerProduct(Matrix.eye(n,n)),i=Matrix.eye(t,t).kroneckerProduct(e);return r.add(i)}transpose(){let e=new Matrix(this.columns,this.rows);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)e.set(n,t,this.get(t,n));return e}sortRows(e=compareNumbers){for(let t=0;t<this.rows;t++)this.setRow(t,this.getRow(t).sort(e));return this}sortColumns(e=compareNumbers){for(let t=0;t<this.columns;t++)this.setColumn(t,this.getColumn(t).sort(e));return this}subMatrix(e,t,n,r){checkRange(this,e,t,n,r);let i=new Matrix(t-e+1,r-n+1);for(let a=e;a<=t;a++)for(let t=n;t<=r;t++)i.set(a-e,t-n,this.get(a,t));return i}subMatrixRow(e,t,n){if(void 0===t&&(t=0),void 0===n&&(n=this.columns-1),t>n||t<0||t>=this.columns||n<0||n>=this.columns)throw new RangeError("Argument out of range");let r=new Matrix(e.length,n-t+1);for(let i=0;i<e.length;i++)for(let a=t;a<=n;a++){if(e[i]<0||e[i]>=this.rows)throw new RangeError(`Row index out of range: ${e[i]}`);r.set(i,a-t,this.get(e[i],a))}return r}subMatrixColumn(e,t,n){if(void 0===t&&(t=0),void 0===n&&(n=this.rows-1),t>n||t<0||t>=this.rows||n<0||n>=this.rows)throw new RangeError("Argument out of range");let r=new Matrix(n-t+1,e.length);for(let i=0;i<e.length;i++)for(let a=t;a<=n;a++){if(e[i]<0||e[i]>=this.columns)throw new RangeError(`Column index out of range: ${e[i]}`);r.set(a-t,i,this.get(a,e[i]))}return r}setSubMatrix(e,t,n){if((e=Matrix.checkMatrix(e)).isEmpty())return this;checkRange(this,t,t+e.rows-1,n,n+e.columns-1);for(let r=0;r<e.rows;r++)for(let i=0;i<e.columns;i++)this.set(t+r,n+i,e.get(r,i));return this}selection(e,t){let n=checkIndices(this,e,t),r=new Matrix(e.length,t.length);for(let e=0;e<n.row.length;e++){let t=n.row[e];for(let i=0;i<n.column.length;i++){r.set(e,i,this.get(t,n.column[i]))}}return r}trace(){let e=Math.min(this.rows,this.columns),t=0;for(let n=0;n<e;n++)t+=this.get(n,n);return t}clone(){let e=new Matrix(this.rows,this.columns);for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)e.set(t,n,this.get(t,n));return e}sum(e){switch(e){case"row":return sumByRow(this);case"column":return sumByColumn(this);case void 0:return sumAll(this);default:throw new Error(`invalid option: ${e}`)}}product(e){switch(e){case"row":return productByRow(this);case"column":return productByColumn(this);case void 0:return productAll(this);default:throw new Error(`invalid option: ${e}`)}}mean(e){const t=this.sum(e);switch(e){case"row":for(let e=0;e<this.rows;e++)t[e]/=this.columns;return t;case"column":for(let e=0;e<this.columns;e++)t[e]/=this.rows;return t;case void 0:return t/this.size;default:throw new Error(`invalid option: ${e}`)}}variance(e,t={}){if("object"==typeof e&&(t=e,e=void 0),"object"!=typeof t)throw new TypeError("options must be an object");const{unbiased:n=!0,mean:r=this.mean(e)}=t;if("boolean"!=typeof n)throw new TypeError("unbiased must be a boolean");switch(e){case"row":if(!Array.isArray(r))throw new TypeError("mean must be an array");return varianceByRow(this,n,r);case"column":if(!Array.isArray(r))throw new TypeError("mean must be an array");return varianceByColumn(this,n,r);case void 0:if("number"!=typeof r)throw new TypeError("mean must be a number");return varianceAll(this,n,r);default:throw new Error(`invalid option: ${e}`)}}standardDeviation(e,t){"object"==typeof e&&(t=e,e=void 0);const n=this.variance(e,t);if(void 0===e)return Math.sqrt(n);for(let e=0;e<n.length;e++)n[e]=Math.sqrt(n[e]);return n}center(e,t={}){if("object"==typeof e&&(t=e,e=void 0),"object"!=typeof t)throw new TypeError("options must be an object");const{center:n=this.mean(e)}=t;switch(e){case"row":if(!Array.isArray(n))throw new TypeError("center must be an array");return centerByRow(this,n),this;case"column":if(!Array.isArray(n))throw new TypeError("center must be an array");return centerByColumn(this,n),this;case void 0:if("number"!=typeof n)throw new TypeError("center must be a number");return centerAll(this,n),this;default:throw new Error(`invalid option: ${e}`)}}scale(e,t={}){if("object"==typeof e&&(t=e,e=void 0),"object"!=typeof t)throw new TypeError("options must be an object");let n=t.scale;switch(e){case"row":if(void 0===n)n=getScaleByRow(this);else if(!Array.isArray(n))throw new TypeError("scale must be an array");return scaleByRow(this,n),this;case"column":if(void 0===n)n=getScaleByColumn(this);else if(!Array.isArray(n))throw new TypeError("scale must be an array");return scaleByColumn(this,n),this;case void 0:if(void 0===n)n=getScaleAll(this);else if("number"!=typeof n)throw new TypeError("scale must be a number");return scaleAll(this,n),this;default:throw new Error(`invalid option: ${e}`)}}toString(e){return inspectMatrixWithOptions(this,e)}}function compareNumbers(e,t){return e-t}AbstractMatrix.prototype.klass="Matrix","undefined"!=typeof Symbol&&(AbstractMatrix.prototype[Symbol.for("nodejs.util.inspect.custom")]=inspectMatrix),AbstractMatrix.random=AbstractMatrix.rand,AbstractMatrix.randomInt=AbstractMatrix.randInt,AbstractMatrix.diagonal=AbstractMatrix.diag,AbstractMatrix.prototype.diagonal=AbstractMatrix.prototype.diag,AbstractMatrix.identity=AbstractMatrix.eye,AbstractMatrix.prototype.negate=AbstractMatrix.prototype.neg,AbstractMatrix.prototype.tensorProduct=AbstractMatrix.prototype.kroneckerProduct;class Matrix extends AbstractMatrix{constructor(e,t){if(super(),Matrix.isMatrix(e))return e.clone();if(Number.isInteger(e)&&e>=0){if(this.data=[],!(Number.isInteger(t)&&t>=0))throw new TypeError("nColumns must be a positive integer");for(let n=0;n<e;n++)this.data.push(new Float64Array(t))}else{if(!Array.isArray(e))throw new TypeError("First argument must be a positive number or an array");{const n=e;if("number"!=typeof(t=(e=n.length)?n[0].length:0))throw new TypeError("Data must be a 2D array with at least one element");this.data=[];for(let r=0;r<e;r++){if(n[r].length!==t)throw new RangeError("Inconsistent array dimensions");this.data.push(Float64Array.from(n[r]))}}}this.rows=e,this.columns=t}set(e,t,n){return this.data[e][t]=n,this}get(e,t){return this.data[e][t]}removeRow(e){return checkRowIndex(this,e),this.data.splice(e,1),this.rows-=1,this}addRow(e,t){return void 0===t&&(t=e,e=this.rows),checkRowIndex(this,e,!0),t=Float64Array.from(checkRowVector(this,t)),this.data.splice(e,0,t),this.rows+=1,this}removeColumn(e){checkColumnIndex(this,e);for(let t=0;t<this.rows;t++){const n=new Float64Array(this.columns-1);for(let r=0;r<e;r++)n[r]=this.data[t][r];for(let r=e+1;r<this.columns;r++)n[r-1]=this.data[t][r];this.data[t]=n}return this.columns-=1,this}addColumn(e,t){void 0===t&&(t=e,e=this.columns),checkColumnIndex(this,e,!0),t=checkColumnVector(this,t);for(let n=0;n<this.rows;n++){const r=new Float64Array(this.columns+1);let i=0;for(;i<e;i++)r[i]=this.data[n][i];for(r[i++]=t[n];i<this.columns+1;i++)r[i]=this.data[n][i-1];this.data[n]=r}return this.columns+=1,this}}installMathOperations(AbstractMatrix,Matrix);class WrapperMatrix2D extends AbstractMatrix{constructor(e){super(),this.data=e,this.rows=e.length,this.columns=e[0].length}set(e,t,n){return this.data[e][t]=n,this}get(e,t){return this.data[e][t]}}class LuDecomposition{constructor(e){let t,n,r,i,a,o,s,l,c,h=(e=WrapperMatrix2D.checkMatrix(e)).clone(),u=h.rows,d=h.columns,p=new Float64Array(u),m=1;for(t=0;t<u;t++)p[t]=t;for(l=new Float64Array(u),n=0;n<d;n++){for(t=0;t<u;t++)l[t]=h.get(t,n);for(t=0;t<u;t++){for(c=Math.min(t,n),a=0,r=0;r<c;r++)a+=h.get(t,r)*l[r];l[t]-=a,h.set(t,n,l[t])}for(i=n,t=n+1;t<u;t++)Math.abs(l[t])>Math.abs(l[i])&&(i=t);if(i!==n){for(r=0;r<d;r++)o=h.get(i,r),h.set(i,r,h.get(n,r)),h.set(n,r,o);s=p[i],p[i]=p[n],p[n]=s,m=-m}if(n<u&&0!==h.get(n,n))for(t=n+1;t<u;t++)h.set(t,n,h.get(t,n)/h.get(n,n))}this.LU=h,this.pivotVector=p,this.pivotSign=m}isSingular(){let e=this.LU,t=e.columns;for(let n=0;n<t;n++)if(0===e.get(n,n))return!0;return!1}solve(e){e=Matrix.checkMatrix(e);let t=this.LU;if(t.rows!==e.rows)throw new Error("Invalid matrix dimensions");if(this.isSingular())throw new Error("LU matrix is singular");let n,r,i,a=e.columns,o=e.subMatrixRow(this.pivotVector,0,a-1),s=t.columns;for(i=0;i<s;i++)for(n=i+1;n<s;n++)for(r=0;r<a;r++)o.set(n,r,o.get(n,r)-o.get(i,r)*t.get(n,i));for(i=s-1;i>=0;i--){for(r=0;r<a;r++)o.set(i,r,o.get(i,r)/t.get(i,i));for(n=0;n<i;n++)for(r=0;r<a;r++)o.set(n,r,o.get(n,r)-o.get(i,r)*t.get(n,i))}return o}get determinant(){let e=this.LU;if(!e.isSquare())throw new Error("Matrix must be square");let t=this.pivotSign,n=e.columns;for(let r=0;r<n;r++)t*=e.get(r,r);return t}get lowerTriangularMatrix(){let e=this.LU,t=e.rows,n=e.columns,r=new Matrix(t,n);for(let i=0;i<t;i++)for(let t=0;t<n;t++)r.set(i,t,i>t?e.get(i,t):i===t?1:0);return r}get upperTriangularMatrix(){let e=this.LU,t=e.rows,n=e.columns,r=new Matrix(t,n);for(let i=0;i<t;i++)for(let t=0;t<n;t++)r.set(i,t,i<=t?e.get(i,t):0);return r}get pivotPermutationVector(){return Array.from(this.pivotVector)}}function hypotenuse(e,t){let n=0;return Math.abs(e)>Math.abs(t)?(n=t/e,Math.abs(e)*Math.sqrt(1+n*n)):0!==t?(n=e/t,Math.abs(t)*Math.sqrt(1+n*n)):0}class QrDecomposition{constructor(e){let t,n,r,i,a=(e=WrapperMatrix2D.checkMatrix(e)).clone(),o=e.rows,s=e.columns,l=new Float64Array(s);for(r=0;r<s;r++){let e=0;for(t=r;t<o;t++)e=hypotenuse(e,a.get(t,r));if(0!==e){for(a.get(r,r)<0&&(e=-e),t=r;t<o;t++)a.set(t,r,a.get(t,r)/e);for(a.set(r,r,a.get(r,r)+1),n=r+1;n<s;n++){for(i=0,t=r;t<o;t++)i+=a.get(t,r)*a.get(t,n);for(i=-i/a.get(r,r),t=r;t<o;t++)a.set(t,n,a.get(t,n)+i*a.get(t,r))}}l[r]=-e}this.QR=a,this.Rdiag=l}solve(e){e=Matrix.checkMatrix(e);let t=this.QR,n=t.rows;if(e.rows!==n)throw new Error("Matrix row dimensions must agree");if(!this.isFullRank())throw new Error("Matrix is rank deficient");let r,i,a,o,s=e.columns,l=e.clone(),c=t.columns;for(a=0;a<c;a++)for(i=0;i<s;i++){for(o=0,r=a;r<n;r++)o+=t.get(r,a)*l.get(r,i);for(o=-o/t.get(a,a),r=a;r<n;r++)l.set(r,i,l.get(r,i)+o*t.get(r,a))}for(a=c-1;a>=0;a--){for(i=0;i<s;i++)l.set(a,i,l.get(a,i)/this.Rdiag[a]);for(r=0;r<a;r++)for(i=0;i<s;i++)l.set(r,i,l.get(r,i)-l.get(a,i)*t.get(r,a))}return l.subMatrix(0,c-1,0,s-1)}isFullRank(){let e=this.QR.columns;for(let t=0;t<e;t++)if(0===this.Rdiag[t])return!1;return!0}get upperTriangularMatrix(){let e,t,n=this.QR,r=n.columns,i=new Matrix(r,r);for(e=0;e<r;e++)for(t=0;t<r;t++)i.set(e,t,e<t?n.get(e,t):e===t?this.Rdiag[e]:0);return i}get orthogonalMatrix(){let e,t,n,r,i=this.QR,a=i.rows,o=i.columns,s=new Matrix(a,o);for(n=o-1;n>=0;n--){for(e=0;e<a;e++)s.set(e,n,0);for(s.set(n,n,1),t=n;t<o;t++)if(0!==i.get(n,n)){for(r=0,e=n;e<a;e++)r+=i.get(e,n)*s.get(e,t);for(r=-r/i.get(n,n),e=n;e<a;e++)s.set(e,t,s.get(e,t)+r*i.get(e,n))}}return s}}class SingularValueDecomposition{constructor(e,t={}){if((e=WrapperMatrix2D.checkMatrix(e)).isEmpty())throw new Error("Matrix must be non-empty");let n=e.rows,r=e.columns;const{computeLeftSingularVectors:i=!0,computeRightSingularVectors:a=!0,autoTranspose:o=!1}=t;let s,l=Boolean(i),c=Boolean(a),h=!1;if(n<r)if(o){s=e.transpose(),n=s.rows,r=s.columns,h=!0;let t=l;l=c,c=t}else s=e.clone(),console.warn("Computing SVD on a matrix with more columns than rows. Consider enabling autoTranspose");else s=e.clone();let u=Math.min(n,r),d=Math.min(n+1,r),p=new Float64Array(d),m=new Matrix(n,u),f=new Matrix(r,r),g=new Float64Array(r),v=new Float64Array(n),y=new Float64Array(d);for(let e=0;e<d;e++)y[e]=e;let _=Math.min(n-1,r),b=Math.max(0,Math.min(r-2,n)),x=Math.max(_,b);for(let e=0;e<x;e++){if(e<_){p[e]=0;for(let t=e;t<n;t++)p[e]=hypotenuse(p[e],s.get(t,e));if(0!==p[e]){s.get(e,e)<0&&(p[e]=-p[e]);for(let t=e;t<n;t++)s.set(t,e,s.get(t,e)/p[e]);s.set(e,e,s.get(e,e)+1)}p[e]=-p[e]}for(let t=e+1;t<r;t++){if(e<_&&0!==p[e]){let r=0;for(let i=e;i<n;i++)r+=s.get(i,e)*s.get(i,t);r=-r/s.get(e,e);for(let i=e;i<n;i++)s.set(i,t,s.get(i,t)+r*s.get(i,e))}g[t]=s.get(e,t)}if(l&&e<_)for(let t=e;t<n;t++)m.set(t,e,s.get(t,e));if(e<b){g[e]=0;for(let t=e+1;t<r;t++)g[e]=hypotenuse(g[e],g[t]);if(0!==g[e]){g[e+1]<0&&(g[e]=0-g[e]);for(let t=e+1;t<r;t++)g[t]/=g[e];g[e+1]+=1}if(g[e]=-g[e],e+1<n&&0!==g[e]){for(let t=e+1;t<n;t++)v[t]=0;for(let t=e+1;t<n;t++)for(let n=e+1;n<r;n++)v[t]+=g[n]*s.get(t,n);for(let t=e+1;t<r;t++){let r=-g[t]/g[e+1];for(let i=e+1;i<n;i++)s.set(i,t,s.get(i,t)+r*v[i])}}if(c)for(let t=e+1;t<r;t++)f.set(t,e,g[t])}}let S=Math.min(r,n+1);if(_<r&&(p[_]=s.get(_,_)),n<S&&(p[S-1]=0),b+1<S&&(g[b]=s.get(b,S-1)),g[S-1]=0,l){for(let e=_;e<u;e++){for(let t=0;t<n;t++)m.set(t,e,0);m.set(e,e,1)}for(let e=_-1;e>=0;e--)if(0!==p[e]){for(let t=e+1;t<u;t++){let r=0;for(let i=e;i<n;i++)r+=m.get(i,e)*m.get(i,t);r=-r/m.get(e,e);for(let i=e;i<n;i++)m.set(i,t,m.get(i,t)+r*m.get(i,e))}for(let t=e;t<n;t++)m.set(t,e,-m.get(t,e));m.set(e,e,1+m.get(e,e));for(let t=0;t<e-1;t++)m.set(t,e,0)}else{for(let t=0;t<n;t++)m.set(t,e,0);m.set(e,e,1)}}if(c)for(let e=r-1;e>=0;e--){if(e<b&&0!==g[e])for(let t=e+1;t<r;t++){let n=0;for(let i=e+1;i<r;i++)n+=f.get(i,e)*f.get(i,t);n=-n/f.get(e+1,e);for(let i=e+1;i<r;i++)f.set(i,t,f.get(i,t)+n*f.get(i,e))}for(let t=0;t<r;t++)f.set(t,e,0);f.set(e,e,1)}let w=S-1,C=Number.EPSILON;for(;S>0;){let e,t;for(e=S-2;e>=-1&&-1!==e;e--){const t=Number.MIN_VALUE+C*Math.abs(p[e]+Math.abs(p[e+1]));if(Math.abs(g[e])<=t||Number.isNaN(g[e])){g[e]=0;break}}if(e===S-2)t=4;else{let n;for(n=S-1;n>=e&&n!==e;n--){let t=(n!==S?Math.abs(g[n]):0)+(n!==e+1?Math.abs(g[n-1]):0);if(Math.abs(p[n])<=C*t){p[n]=0;break}}n===e?t=3:n===S-1?t=1:(t=2,e=n)}switch(e++,t){case 1:{let t=g[S-2];g[S-2]=0;for(let n=S-2;n>=e;n--){let i=hypotenuse(p[n],t),a=p[n]/i,o=t/i;if(p[n]=i,n!==e&&(t=-o*g[n-1],g[n-1]=a*g[n-1]),c)for(let e=0;e<r;e++)i=a*f.get(e,n)+o*f.get(e,S-1),f.set(e,S-1,-o*f.get(e,n)+a*f.get(e,S-1)),f.set(e,n,i)}break}case 2:{let t=g[e-1];g[e-1]=0;for(let r=e;r<S;r++){let i=hypotenuse(p[r],t),a=p[r]/i,o=t/i;if(p[r]=i,t=-o*g[r],g[r]=a*g[r],l)for(let t=0;t<n;t++)i=a*m.get(t,r)+o*m.get(t,e-1),m.set(t,e-1,-o*m.get(t,r)+a*m.get(t,e-1)),m.set(t,r,i)}break}case 3:{const t=Math.max(Math.abs(p[S-1]),Math.abs(p[S-2]),Math.abs(g[S-2]),Math.abs(p[e]),Math.abs(g[e])),i=p[S-1]/t,a=p[S-2]/t,o=g[S-2]/t,s=p[e]/t,h=g[e]/t,u=((a+i)*(a-i)+o*o)/2,d=i*o*(i*o);let v=0;0===u&&0===d||(v=u<0?0-Math.sqrt(u*u+d):Math.sqrt(u*u+d),v=d/(u+v));let y=(s+i)*(s-i)+v,_=s*h;for(let t=e;t<S-1;t++){let i=hypotenuse(y,_);0===i&&(i=Number.MIN_VALUE);let a=y/i,o=_/i;if(t!==e&&(g[t-1]=i),y=a*p[t]+o*g[t],g[t]=a*g[t]-o*p[t],_=o*p[t+1],p[t+1]=a*p[t+1],c)for(let e=0;e<r;e++)i=a*f.get(e,t)+o*f.get(e,t+1),f.set(e,t+1,-o*f.get(e,t)+a*f.get(e,t+1)),f.set(e,t,i);if(i=hypotenuse(y,_),0===i&&(i=Number.MIN_VALUE),a=y/i,o=_/i,p[t]=i,y=a*g[t]+o*p[t+1],p[t+1]=-o*g[t]+a*p[t+1],_=o*g[t+1],g[t+1]=a*g[t+1],l&&t<n-1)for(let e=0;e<n;e++)i=a*m.get(e,t)+o*m.get(e,t+1),m.set(e,t+1,-o*m.get(e,t)+a*m.get(e,t+1)),m.set(e,t,i)}g[S-2]=y;break}case 4:if(p[e]<=0&&(p[e]=p[e]<0?-p[e]:0,c))for(let t=0;t<=w;t++)f.set(t,e,-f.get(t,e));for(;e<w&&!(p[e]>=p[e+1]);){let t=p[e];if(p[e]=p[e+1],p[e+1]=t,c&&e<r-1)for(let n=0;n<r;n++)t=f.get(n,e+1),f.set(n,e+1,f.get(n,e)),f.set(n,e,t);if(l&&e<n-1)for(let r=0;r<n;r++)t=m.get(r,e+1),m.set(r,e+1,m.get(r,e)),m.set(r,e,t);e++}S--}}if(h){let e=f;f=m,m=e}this.m=n,this.n=r,this.s=p,this.U=m,this.V=f}solve(e){let t=e,n=this.threshold,r=this.s.length,i=Matrix.zeros(r,r);for(let e=0;e<r;e++)Math.abs(this.s[e])<=n?i.set(e,e,0):i.set(e,e,1/this.s[e]);let a=this.U,o=this.rightSingularVectors,s=o.mmul(i),l=o.rows,c=a.rows,h=Matrix.zeros(l,c);for(let e=0;e<l;e++)for(let t=0;t<c;t++){let n=0;for(let i=0;i<r;i++)n+=s.get(e,i)*a.get(t,i);h.set(e,t,n)}return h.mmul(t)}solveForDiagonal(e){return this.solve(Matrix.diag(e))}inverse(){let e=this.V,t=this.threshold,n=e.rows,r=e.columns,i=new Matrix(n,this.s.length);for(let a=0;a<n;a++)for(let n=0;n<r;n++)Math.abs(this.s[n])>t&&i.set(a,n,e.get(a,n)/this.s[n]);let a=this.U,o=a.rows,s=a.columns,l=new Matrix(n,o);for(let e=0;e<n;e++)for(let t=0;t<o;t++){let n=0;for(let r=0;r<s;r++)n+=i.get(e,r)*a.get(t,r);l.set(e,t,n)}return l}get condition(){return this.s[0]/this.s[Math.min(this.m,this.n)-1]}get norm2(){return this.s[0]}get rank(){let e=Math.max(this.m,this.n)*this.s[0]*Number.EPSILON,t=0,n=this.s;for(let r=0,i=n.length;r<i;r++)n[r]>e&&t++;return t}get diagonal(){return Array.from(this.s)}get threshold(){return Number.EPSILON/2*Math.max(this.m,this.n)*this.s[0]}get leftSingularVectors(){return this.U}get rightSingularVectors(){return this.V}get diagonalMatrix(){return Matrix.diag(this.s)}}function inverse(e,t=!1){return e=WrapperMatrix2D.checkMatrix(e),t?new SingularValueDecomposition(e).inverse():solve(e,Matrix.eye(e.rows))}function solve(e,t,n=!1){return e=WrapperMatrix2D.checkMatrix(e),t=WrapperMatrix2D.checkMatrix(t),n?new SingularValueDecomposition(e).solve(t):e.isSquare()?new LuDecomposition(e).solve(t):new QrDecomposition(e).solve(t)}function gradientFunction(e,t,n,r,i){const a=n.length,o=e.x.length;let s=new Array(a);for(let l=0;l<a;l++){s[l]=new Array(o);let a=n.slice();a[l]+=r;let c=i(a);for(let n=0;n<o;n++)s[l][n]=t[n]-c(e.x[n])}return new Matrix(s)}function matrixFunction(e,t){const n=e.x.length;let r=new Array(n);for(let i=0;i<n;i++)r[i]=[e.y[i]-t[i]];return new Matrix(r)}function step$3(e,t,n,r,i){let a=Matrix.eye(t.length,t.length,n*r*r);const o=i(t);let s=new Float64Array(e.x.length);for(let t=0;t<e.x.length;t++)s[t]=o(e.x[t]);let l=gradientFunction(e,s,t,r,i),c=matrixFunction(e,s),h=inverse(a.add(l.mmul(l.transpose())));return(t=(t=new Matrix([t])).sub(h.mmul(l).mmul(c).mul(r).transpose())).to1DArray()}function levenbergMarquardt(e,t,n={}){let{maxIterations:r=100,gradientDifference:i=.1,damping:a=0,errorTolerance:o=.01,minValues:s,maxValues:l,initialValues:c}=n;if(a<=0)throw new Error("The damping option must be a positive number");if(!e.x||!e.y)throw new Error("The data parameter must have x and y elements");if(!isAnyArray$1(e.x)||e.x.length<2||!isAnyArray$1(e.y)||e.y.length<2)throw new Error("The data parameter elements must be an array with more than 2 points");if(e.x.length!==e.y.length)throw new Error("The data parameter elements must have the same size");let h=c||new Array(t.length).fill(1),u=h.length;if(l=l||new Array(u).fill(Number.MAX_SAFE_INTEGER),s=s||new Array(u).fill(Number.MIN_SAFE_INTEGER),l.length!==s.length)throw new Error("minValues and maxValues must be the same size");if(!isAnyArray$1(h))throw new Error("initialValues must be an array");let d,p=errorCalculation(e,h,t),m=p<=o;for(d=0;d<r&&!m;d++){h=step$3(e,h,a,i,t);for(let e=0;e<u;e++)h[e]=Math.min(Math.max(s[e],h[e]),l[e]);if(p=errorCalculation(e,h,t),isNaN(p))break;m=p<=o}return{parameterValues:h,parameterError:p,iterations:d}}var src=Object.freeze({__proto__:null,default:levenbergMarquardt}),require$$5=getAugmentedNamespace(src),__awaiter=commonjsGlobal&&commonjsGlobal.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,a){function o(e){try{l(r.next(e))}catch(e){a(e)}}function s(e){try{l(r.throw(e))}catch(e){a(e)}}function l(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(o,s)}l((r=r.apply(e,t||[])).next())}))},__generator=commonjsGlobal&&commonjsGlobal.__generator||function(e,t){var n,r,i,a,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(a){return function(s){return(function l(a){if(n)throw new TypeError("Generator is already executing.");for(;o;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,r=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){o.label=a[1];break}if(6===a[0]&&o.label<i[1]){o.label=i[1],i=a;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(a);break}i[2]&&o.ops.pop(),o.trys.pop();continue}a=t.call(e,o)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}})([a,s])}}},__read=commonjsGlobal&&commonjsGlobal.__read||function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,a=n.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(r=a.next()).done;)o.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=a.return)&&n.call(a)}finally{if(i)throw i.error}}return o},__spread=commonjsGlobal&&commonjsGlobal.__spread||function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(__read(arguments[t]));return e},__importStar=commonjsGlobal&&commonjsGlobal.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t},__importDefault=commonjsGlobal&&commonjsGlobal.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(umap,"__esModule",{value:!0});var heap=__importStar(heap$2),matrix=__importStar(matrix$2),nnDescent=__importStar(nn_descent),tree=__importStar(tree$2),utils=__importStar(utils$5),ml_levenberg_marquardt_1=__importDefault(require$$5),SMOOTH_K_TOLERANCE=1e-5,MIN_K_DIST_SCALE=.001,UMAP$1=(function(){function e(e){void 0===e&&(e={});var t=this;this.learningRate=1,this.localConnectivity=1,this.minDist=.1,this.nComponents=2,this.nEpochs=0,this.nNeighbors=15,this.negativeSampleRate=5,this.random=Math.random,this.repulsionStrength=1,this.setOpMixRatio=1,this.spread=1,this.transformQueueSize=4,this.targetMetric="categorical",this.targetWeight=.5,this.targetNNeighbors=this.nNeighbors,this.distanceFn=euclidean,this.isInitialized=!1,this.rpForest=[],this.embedding=[],this.optimizationState=new OptimizationState;var n=function(n){void 0!==e[n]&&(t[n]=e[n])};n("distanceFn"),n("learningRate"),n("localConnectivity"),n("minDist"),n("nComponents"),n("nEpochs"),n("nNeighbors"),n("negativeSampleRate"),n("random"),n("repulsionStrength"),n("setOpMixRatio"),n("spread"),n("transformQueueSize")}return e.prototype.fit=function(e){return this.initializeFit(e),this.optimizeLayout(),this.embedding},e.prototype.fitAsync=function(e,t){return void 0===t&&(t=function(){return!0}),__awaiter(this,void 0,void 0,(function(){return __generator(this,(function(n){switch(n.label){case 0:return this.initializeFit(e),[4,this.optimizeLayoutAsync(t)];case 1:return n.sent(),[2,this.embedding]}}))}))},e.prototype.setSupervisedProjection=function(e,t){void 0===t&&(t={}),this.Y=e,this.targetMetric=t.targetMetric||this.targetMetric,this.targetWeight=t.targetWeight||this.targetWeight,this.targetNNeighbors=t.targetNNeighbors||this.targetNNeighbors},e.prototype.setPrecomputedKNN=function(e,t){this.knnIndices=e,this.knnDistances=t},e.prototype.initializeFit=function(e){if(e.length<=this.nNeighbors)throw new Error("Not enough data points ("+e.length+") to create nNeighbors: "+this.nNeighbors+".  Add more data points or adjust the configuration.");if(this.X===e&&this.isInitialized)return this.getNEpochs();if(this.X=e,!this.knnIndices&&!this.knnDistances){var t=this.nearestNeighbors(e);this.knnIndices=t.knnIndices,this.knnDistances=t.knnDistances}this.graph=this.fuzzySimplicialSet(e,this.nNeighbors,this.setOpMixRatio),this.makeSearchFns(),this.searchGraph=this.makeSearchGraph(e),this.processGraphForSupervisedProjection();var n=this.initializeSimplicialSetEmbedding(),r=n.tail,i=n.epochsPerSample;return this.optimizationState.head=n.head,this.optimizationState.tail=r,this.optimizationState.epochsPerSample=i,this.initializeOptimization(),this.prepareForOptimizationLoop(),this.isInitialized=!0,this.getNEpochs()},e.prototype.makeSearchFns=function(){var e=nnDescent.makeInitializations(this.distanceFn),t=e.initFromRandom;this.initFromTree=e.initFromTree,this.initFromRandom=t,this.search=nnDescent.makeInitializedNNSearch(this.distanceFn)},e.prototype.makeSearchGraph=function(e){for(var t=this.knnIndices,n=this.knnDistances,r=new matrix.SparseMatrix([],[],[],[e.length,e.length]),i=0;i<t.length;i++)for(var a=t[i],o=n[i],s=0;s<a.length;s++){var l=o[s];l>0&&r.set(i,a[s],l)}var c=matrix.transpose(r);return matrix.maximum(r,c)},e.prototype.transform=function(e){var t=this,n=this.X;if(void 0===n||0===n.length)throw new Error("No data has been fit.");var r=Math.floor(this.nNeighbors*this.transformQueueSize);r=Math.min(n.length,r);var i=nnDescent.initializeSearch(this.rpForest,n,e,r,this.initFromRandom,this.initFromTree,this.random),a=this.search(n,this.searchGraph,i,e),o=heap.deheapSort(a),s=o.indices,l=o.weights;s=s.map((function(e){return e.slice(0,t.nNeighbors)})),l=l.map((function(e){return e.slice(0,t.nNeighbors)}));var c=Math.max(0,this.localConnectivity-1),h=this.smoothKNNDistance(l,this.nNeighbors,c),u=this.computeMembershipStrengths(s,l,h.sigmas,h.rhos),d=new matrix.SparseMatrix(u.rows,u.cols,u.vals,[e.length,n.length]),p=matrix.normalize(d,"l1"),m=matrix.getCSR(p),f=e.length,g=initTransform(utils.reshape2d(m.indices,f,this.nNeighbors),utils.reshape2d(m.values,f,this.nNeighbors),this.embedding),v=this.nEpochs?this.nEpochs/3:d.nRows<=1e4?100:30,y=d.getValues().reduce((function(e,t){return t>e?t:e}),0);d=d.map((function(e){return e<y/v?0:e})),d=matrix.eliminateZeros(d);var _=this.makeEpochsPerSample(d.getValues(),v),b=d.getRows(),x=d.getCols();return this.assignOptimizationStateParameters({headEmbedding:g,tailEmbedding:this.embedding,head:b,tail:x,currentEpoch:0,nEpochs:v,nVertices:d.getDims()[1],epochsPerSample:_}),this.prepareForOptimizationLoop(),this.optimizeLayout()},e.prototype.processGraphForSupervisedProjection=function(){var e=this.Y;if(e){if(e.length!==this.X.length)throw new Error("Length of X and y must be equal");if("categorical"===this.targetMetric)this.graph=this.categoricalSimplicialSetIntersection(this.graph,e,this.targetWeight<1?1/(1-this.targetWeight)*2.5:1e12)}},e.prototype.step=function(){var e=this.optimizationState.currentEpoch;return e<this.getNEpochs()&&this.optimizeLayoutStep(e),this.optimizationState.currentEpoch},e.prototype.getEmbedding=function(){return this.embedding},e.prototype.nearestNeighbors=function(e){var t,n=this.nNeighbors,r=nnDescent.makeNNDescent(this.distanceFn,this.random),i=5+Math.floor(.5===(t=Math.pow(e.length,.5)/20)?0:Math.round(t)),a=Math.max(5,Math.floor(Math.round((function(e){return Math.log(e)/Math.log(2)})(e.length))));this.rpForest=tree.makeForest(e,n,i,this.random);var o=r(e,tree.makeLeafArray(this.rpForest),n,a);return{knnIndices:o.indices,knnDistances:o.weights}},e.prototype.fuzzySimplicialSet=function(e,t,n){void 0===n&&(n=1);var r=this,i=r.knnIndices,a=void 0===i?[]:i,o=r.knnDistances,s=void 0===o?[]:o,l=this.smoothKNNDistance(s,t,r.localConnectivity),c=this.computeMembershipStrengths(a,s,l.sigmas,l.rhos),h=new matrix.SparseMatrix(c.rows,c.cols,c.vals,[e.length,e.length]),u=matrix.transpose(h),d=matrix.pairwiseMultiply(h,u),p=matrix.subtract(matrix.add(h,u),d),m=matrix.multiplyScalar(p,n),f=matrix.multiplyScalar(d,1-n);return matrix.add(m,f)},e.prototype.categoricalSimplicialSetIntersection=function(e,t,n,r){void 0===r&&(r=1);var i=fastIntersection(e,t,r,n);return resetLocalConnectivity(i=matrix.eliminateZeros(i))},e.prototype.smoothKNNDistance=function(e,t,n,r,i){void 0===n&&(n=1),void 0===r&&(r=64),void 0===i&&(i=1);for(var a=Math.log(t)/Math.log(2)*i,o=utils.zeros(e.length),s=utils.zeros(e.length),l=0;l<e.length;l++){var c=0,h=1/0,u=1,d=e[l],p=d.filter((function(e){return e>0}));if(p.length>=n){var m=Math.floor(n),f=n-m;m>0?(o[l]=p[m-1],f>SMOOTH_K_TOLERANCE&&(o[l]+=f*(p[m]-p[m-1]))):o[l]=f*p[0]}else p.length>0&&(o[l]=utils.max(p));for(var g=0;g<r;g++){for(var v=0,y=1;y<e[l].length;y++){var _=e[l][y]-o[l];v+=_>0?Math.exp(-_/u):1}if(Math.abs(v-a)<SMOOTH_K_TOLERANCE)break;v>a?u=(c+(h=u))/2:(c=u,h===1/0?u*=2:u=(c+h)/2)}if(s[l]=u,o[l]>0){var b=utils.mean(d);s[l]<MIN_K_DIST_SCALE*b&&(s[l]=MIN_K_DIST_SCALE*b)}else{var x=utils.mean(e.map(utils.mean));s[l]<MIN_K_DIST_SCALE*x&&(s[l]=MIN_K_DIST_SCALE*x)}}return{sigmas:s,rhos:o}},e.prototype.computeMembershipStrengths=function(e,t,n,r){for(var i=e.length,a=e[0].length,o=utils.zeros(i*a),s=utils.zeros(i*a),l=utils.zeros(i*a),c=0;c<i;c++)for(var h=0;h<a;h++){var u=0;-1!==e[c][h]&&(u=e[c][h]===c?0:t[c][h]-r[c]<=0?1:Math.exp(-(t[c][h]-r[c])/n[c]),o[c*a+h]=c,s[c*a+h]=e[c][h],l[c*a+h]=u)}return{rows:o,cols:s,vals:l}},e.prototype.initializeSimplicialSetEmbedding=function(){for(var e=this,t=this.getNEpochs(),n=this.nComponents,r=this.graph.getValues(),i=0,a=0;a<r.length;a++){i<r[a]&&(i=r[a])}var o=this.graph.map((function(e){return e<i/t?0:e}));this.embedding=utils.zeros(o.nRows).map((function(){return utils.zeros(n).map((function(){return 20*utils.tauRand(e.random)-10}))}));var s=[],l=[],c=[],h=o.getAll();for(a=0;a<h.length;a++){var u=h[a];u.value&&(s.push(u.value),c.push(u.row),l.push(u.col))}return{head:l,tail:c,epochsPerSample:this.makeEpochsPerSample(s,t)}},e.prototype.makeEpochsPerSample=function(e,t){var n=utils.filled(e.length,-1),r=utils.max(e),i=e.map((function(e){return e/r*t}));return i.forEach((function(e,r){e>0&&(n[r]=t/i[r])})),n},e.prototype.assignOptimizationStateParameters=function(e){Object.assign(this.optimizationState,e)},e.prototype.prepareForOptimizationLoop=function(){var e=this,t=e.repulsionStrength,n=e.learningRate,r=e.negativeSampleRate,i=this.optimizationState,a=i.epochsPerSample,o=i.headEmbedding,s=o[0].length,l=o.length===i.tailEmbedding.length,c=a.map((function(e){return e/r})),h=__spread(c),u=__spread(a);this.assignOptimizationStateParameters({epochOfNextSample:u,epochOfNextNegativeSample:h,epochsPerNegativeSample:c,moveOther:l,initialAlpha:n,alpha:n,gamma:t,dim:s})},e.prototype.initializeOptimization=function(){var e=this.embedding,t=this.embedding,n=this.optimizationState,r=n.head,i=n.tail,a=n.epochsPerSample,o=this.getNEpochs(),s=this.graph.nCols,l=findABParams(this.spread,this.minDist);this.assignOptimizationStateParameters({headEmbedding:e,tailEmbedding:t,head:r,tail:i,epochsPerSample:a,a:l.a,b:l.b,nEpochs:o,nVertices:s})},e.prototype.optimizeLayoutStep=function(e){for(var t=this.optimizationState,n=t.head,r=t.tail,i=t.headEmbedding,a=t.tailEmbedding,o=t.epochsPerSample,s=t.epochOfNextSample,l=t.epochOfNextNegativeSample,c=t.epochsPerNegativeSample,h=t.moveOther,u=t.initialAlpha,d=t.alpha,p=t.gamma,m=t.a,f=t.b,g=t.dim,v=t.nEpochs,y=t.nVertices,_=0;_<o.length;_++)if(!(s[_]>e)){var b=n[_],x=i[b],S=a[r[_]],w=rDist(x,S),C=0;w>0&&(C=-2*m*f*Math.pow(w,f-1),C/=m*Math.pow(w,f)+1);for(var M=0;M<g;M++){var E=clip$1(C*(x[M]-S[M]),4);x[M]+=E*d,h&&(S[M]+=-E*d)}s[_]+=o[_];for(var T=Math.floor((e-l[_])/c[_]),I=0;I<T;I++){var A=utils.tauRandInt(y,this.random),k=a[A],P=rDist(x,k),R=0;if(P>0)R=2*p*f,R/=(.001+P)*(m*Math.pow(P,f)+1);else if(b===A)continue;for(M=0;M<g;M++){E=4;R>0&&(E=clip$1(R*(x[M]-k[M]),4)),x[M]+=E*d}}l[_]+=T*c[_]}return t.alpha=u*(1-e/v),t.currentEpoch+=1,i},e.prototype.optimizeLayoutAsync=function(e){var t=this;return void 0===e&&(e=function(){return!0}),new Promise((function(n,r){var i=function(){return __awaiter(t,void 0,void 0,(function(){var t,a,o,s,l;return __generator(this,(function(c){try{if(a=(t=this.optimizationState).nEpochs,this.embedding=this.optimizeLayoutStep(t.currentEpoch),s=!1===e(o=this.optimizationState.currentEpoch),l=o===a,s||l)return[2,n(l)];setTimeout((function(){return i()}),0)}catch(e){r(e)}return[2]}))}))};setTimeout((function(){return i()}),0)}))},e.prototype.optimizeLayout=function(e){void 0===e&&(e=function(){return!0});for(var t=!1,n=[];!t;){var r=this.optimizationState,i=r.nEpochs;n=this.optimizeLayoutStep(r.currentEpoch);var a=this.optimizationState.currentEpoch,o=!1===e(a);t=a===i||o}return n},e.prototype.getNEpochs=function(){if(this.nEpochs>0)return this.nEpochs;var e=this.graph.nRows;return e<=2500?500:e<=5e3?400:e<=7500?300:200},e})();function euclidean(e,t){for(var n=0,r=0;r<e.length;r++)n+=Math.pow(e[r]-t[r],2);return Math.sqrt(n)}function cosine(e,t){for(var n=0,r=0,i=0,a=0;a<e.length;a++)n+=e[a]*t[a],r+=Math.pow(e[a],2),i+=Math.pow(t[a],2);return 0===r&&0===i?0:0===r||0===i?1:1-n/Math.sqrt(r*i)}umap.UMAP=UMAP$1,umap.euclidean=euclidean,umap.cosine=cosine;var OptimizationState=function OptimizationState(){this.currentEpoch=0,this.headEmbedding=[],this.tailEmbedding=[],this.head=[],this.tail=[],this.epochsPerSample=[],this.epochOfNextSample=[],this.epochOfNextNegativeSample=[],this.epochsPerNegativeSample=[],this.moveOther=!0,this.initialAlpha=1,this.alpha=1,this.gamma=1,this.a=1.5769434603113077,this.b=.8950608779109733,this.dim=2,this.nEpochs=500,this.nVertices=0};function clip$1(e,t){return e>t?t:e<-t?-t:e}function rDist(e,t){for(var n=0,r=0;r<e.length;r++)n+=Math.pow(e[r]-t[r],2);return n}function findABParams(e,t){var n=utils.linear(0,3*e,300).map((function(e){return e<t?1:e})),r=utils.zeros(n.length).map((function(r,i){return n[i]>=t?Math.exp(-(n[i]-t)/e):r})),i=ml_levenberg_marquardt_1.default({x:n,y:r},(function(e){var t=__read(e,2),n=t[0],r=t[1];return function(e){return 1/(1+n*Math.pow(e,2*r))}}),{damping:1.5,initialValues:[.5,.5],gradientDifference:.1,maxIterations:100,errorTolerance:.01}).parameterValues,a=__read(i,2);return{a:a[0],b:a[1]}}function fastIntersection(e,t,n,r){return void 0===n&&(n=1),void 0===r&&(r=5),e.map((function(e,i,a){return-1===t[i]||-1===t[a]?e*Math.exp(-n):t[i]!==t[a]?e*Math.exp(-r):e}))}function resetLocalConnectivity(e){e=matrix.normalize(e,"max");var t=matrix.transpose(e),n=matrix.pairwiseMultiply(t,e);return e=matrix.add(e,matrix.subtract(t,n)),matrix.eliminateZeros(e)}function initTransform(e,t,n){for(var r=utils.zeros(e.length).map((function(e){return utils.zeros(n[0].length)})),i=0;i<e.length;i++)for(var a=0;a<e[0].length;a++)for(var o=0;o<n[0].length;o++){r[i][o]+=t[i][a]*n[e[i][a]][o]}return r}umap.findABParams=findABParams,umap.fastIntersection=fastIntersection,umap.resetLocalConnectivity=resetLocalConnectivity,umap.initTransform=initTransform,Object.defineProperty(dist$1,"__esModule",{value:!0});var umap_1=umap,UMAP=dist$1.UMAP=umap_1.UMAP;class SPTree{constructor(e){if(e.length<1)throw new Error("There should be at least 1 data point");this.dim=e[0].length,this.masks=new Array(Math.pow(2,this.dim));for(let e=0;e<this.masks.length;++e)this.masks[e]=1<<e;let t=new Array(this.dim);fillArray(t,Number.POSITIVE_INFINITY);let n=new Array(this.dim);fillArray(n,Number.NEGATIVE_INFINITY);for(let r=0;r<e.length;++r)for(let i=0;i<this.dim;++i)t[i]=Math.min(t[i],e[r][i]),n[i]=Math.max(n[i],e[r][i]);let r=new Array(this.dim),i=0;for(let e=0;e<this.dim;++e){let a=n[e]-t[e];r[e]=t[e]+a/2,i=Math.max(i,a/2)}this.root={box:{center:r,halfDim:i},point:e[0]};for(let t=1;t<e.length;++t)this.insert(this.root,e[t])}visit(e,t=!1){this.visitNode(this.root,e,t)}visitNode(e,t,n){let r;if(n)r=t(e);else{let n=new Array(this.dim),i=new Array(this.dim);for(let t=0;t<this.dim;++t)n[t]=e.box.center[t]-e.box.halfDim,i[t]=e.box.center[t]+e.box.halfDim;r=t(e,n,i)}if(e.children&&!r)for(let r=0;r<e.children.length;++r){let i=e.children[r];i&&this.visitNode(i,t,n)}}insert(e,t){null==e.children&&(e.children=new Array(this.masks.length));let n=0;for(let r=0;r<this.dim;++r)t[r]>e.box.center[r]&&(n|=this.masks[r]);null==e.children[n]?this.makeChild(e,n,t):this.insert(e.children[n],t)}makeChild(e,t,n){let r=e.box.center,i=e.box.halfDim/2,a=new Array(this.dim);for(let e=0;e<this.dim;++e)a[e]=t&1<<e?r[e]+i:r[e]-i;e.children[t]={box:{center:a,halfDim:i},point:n}}}function fillArray(e,t){for(let n=0;n<e.length;++n)e[n]=t}const THETA=.8,MIN_POSSIBLE_PROB=1e-9;let return_v=!1,v_val=0;function dist2_2D(e,t){let n=e[0]-t[0],r=e[1]-t[1];return n*n+r*r}function dist2_3D(e,t){let n=e[0]-t[0],r=e[1]-t[1],i=e[2]-t[2];return n*n+r*r+i*i}function gaussRandom(e){if(return_v)return return_v=!1,v_val;let t=2*e()-1,n=2*e()-1,r=t*t+n*n;if(0===r||r>1)return gaussRandom(e);let i=Math.sqrt(-2*Math.log(r)/r);return v_val=n*i,return_v=!0,t*i}function randn(e,t,n){return t+gaussRandom(e)*n}function zeros$2(e){return new Float64Array(e)}function randnMatrix(e,t,n){let r=e*t,i=zeros$2(r);for(let e=0;e<r;++e)i[e]=randn(n,0,1e-4);return i}function arrayofs(e,t,n){let r=[];for(let i=0;i<e;++i)r.push(3===t?[n,n,n]:[n,n]);return r}function nearest2P(e,t,n){let r=e.length,i=Math.log(t),a=zeros$2(r*r),o=new Array(e[0].length);for(let t=0;t<r;++t){let s=e[t],l=-1/0,c=1/0,h=1,u=50,d=0;for(;;){let e=0;for(let n=0;n<s.length;++n){let r=s[n],i=t===r.index?0:Math.exp(-r.dist*h);i=Math.max(i,MIN_POSSIBLE_PROB),o[n]=i,e+=i}let r=0;for(let t=0;t<o.length;++t){o[t]/=e;let n=o[t];n>1e-7&&(r-=n*Math.log(n))}if(r>i?(l=h,c===1/0?h*=2:h=(h+c)/2):(c=h,l===-1/0?h/=2:h=(h+l)/2),d++,d>=u||Math.abs(r-i)<n)break}for(let e=0;e<o.length;++e){a[t*r+s[e].index]=o[e]}}let s=2*r;for(let e=0;e<r;++e)for(let t=e+1;t<r;++t){let n=e*r+t,i=t*r+e,o=(a[n]+a[i])/s;a[n]=o,a[i]=o}return a}function sign$3(e){return e>0?1:e<0?-1:0}function computeForce_2d(e,t,n,r){e[0]+=t*(n[0]-r[0]),e[1]+=t*(n[1]-r[1])}function computeForce_3d(e,t,n,r){e[0]+=t*(n[0]-r[0]),e[1]+=t*(n[1]-r[1]),e[2]+=t*(n[2]-r[2])}class TSNE{constructor(e){if(this.iter=0,this.perplexity=(e=e||{dim:2}).perplexity||30,this.epsilon=e.epsilon||10,this.rng=e.rng||Math.random,this.dim=e.dim,2===e.dim)this.dist2=dist2_2D,this.computeForce=computeForce_2d;else{if(3!==e.dim)throw new Error("Only 2D and 3D is supported");this.dist2=dist2_3D,this.computeForce=computeForce_3d}}initDataDist(e){let t=e.length;this.nearest=e,this.P=nearest2P(e,this.perplexity,1e-4),this.N=t,this.initSolution()}initSolution(){this.Y=randnMatrix(this.N,this.dim,this.rng),this.gains=arrayofs(this.N,this.dim,1),this.ystep=arrayofs(this.N,this.dim,0),this.iter=0}getDim(){return this.dim}getSolution(){return this.Y}perturb(){let e=this.N,t=0,n=3===this.dim?[0,0,0]:[0,0];for(let n=0;n<e;++n){let e=0;for(let t=0;t<this.dim;++t)e+=Math.pow(this.Y[n*this.dim+t],2);e>t&&(t=e)}let r=Math.pow(t,.5);for(let i=0;i<e;++i){let e=new Array(this.dim);for(;;){let n=0;for(let t=0;t<this.dim;++t)e[t]=.1*r*(Math.random()-.5),n+=Math.pow(this.Y[i*this.dim+t]+e[t],2);if(n<t)break}for(let t=0;t<this.dim;++t)this.Y[i*this.dim+t]+=e[t],n[t]+=this.Y[i*this.dim+t]}for(let t=0;t<e;++t)for(let r=0;r<this.dim;++r)this.Y[t*this.dim+r]-=n[r]/e}step(){this.iter+=1;let e=this.N,t=this.costGrad(this.Y),n=3===this.dim?[0,0,0]:[0,0];for(let r=0;r<e;++r)for(let e=0;e<this.dim;++e){let i=this.ystep[r][e],a=this.gains[r][e],o=sign$3(t[r][e])===sign$3(i)?.8*a:a+.2;o<.01&&(o=.01),this.gains[r][e]=o;let s=(this.iter<250?.5:.8)*i-this.epsilon*o*t[r][e];this.ystep[r][e]=s;let l=r*this.dim+e;this.Y[l]+=s,n[e]+=this.Y[l]}for(let t=0;t<e;++t)for(let r=0;r<this.dim;++r)this.Y[t*this.dim+r]-=n[r]/e}setSupervision(e,t){if(null!=e){this.labels=e,this.labelCounts={},Array.from(new Set(e)).forEach((e=>this.labelCounts[e]=0)),e.forEach((e=>this.labelCounts[e]+=1))}null!=t&&(this.unlabeledClass=t)}setSuperviseFactor(e){null!=e&&(this.superviseFactor=e)}costGrad(e){let t=this.N,n=this.P,r=this.iter<100?4:1,i=this.superviseFactor/100,a=this.unlabeledClass,o=this.labels,s=this.labelCounts,l=null!=i&&i>0&&null!=o&&null!=s,c=l&&null!=a&&""!==a?s[a]:0,h=new Array(t);for(let n=0;n<t;++n){let t=n*this.dim,r=new Array(this.dim);for(let n=0;n<this.dim;++n)r[n]=e[t+n];h[n]=r}let u=new SPTree(h),d=e=>{let t=1;if(null==e.children)return e.numCells=t,e.yCell=e.point,{numCells:t,yCell:e.yCell};let n=e.point.slice();for(let r=0;r<e.children.length;++r){let i=e.children[r];if(null==i)continue;let a=d(i);t+=a.numCells;for(let e=0;e<this.dim;++e)n[e]+=a.yCell[e]}return e.numCells=t,e.yCell=n.map((e=>e/t)),{numCells:t,yCell:n}};d(u.root),u.visit(((e,t,n)=>(e.rCell=n[0]-t[0],!1)));let p=[],m=0,f=0,g=new Array(t);for(let e=0;e<t;++e){let r=h[e];if(l)var v=s[o[e]],y=t-v-c;let d=3===this.dim?[0,0,0]:[0,0],p=this.nearest[e];for(let s=0;s<p.length;++s){let c=p[s].index,u=n[e*t+c];l&&(o[e]===a||o[c]===a?u*=1/t:o[e]!==o[c]?u*=Math.max(1/t-i/y,1e-7):o[e]===o[c]&&(u*=Math.min(1/t+i/v,1-1e-7)),f+=u);let m=h[c],g=this.dist2(r,m);this.computeForce(d,u/(1+g),r,m)}let _=3===this.dim?[0,0,0]:[0,0];u.visit((e=>{let t=this.dist2(r,e.yCell);if(null==e.children||t>0&&e.rCell/Math.sqrt(t)<THETA){let n=1/(1+t),i=e.numCells*n;return m+=i,i*=n,this.computeForce(_,i,r,e.yCell),!0}let n=1/(1+this.dist2(r,e.point));return m+=n,n*=n,this.computeForce(_,n,r,e.point),!1}),!0),g[e]=[d,_]}let _=4*r;l&&(_/=f);const b=4/m;for(let e=0;e<t;++e){let[t,n]=g[e],r=new Array(this.dim);for(let e=0;e<this.dim;++e)r[e]=_*t[e]-b*n[e];p.push(r)}return p}}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */const EPSILON_FLOAT32$1=1e-7,EPSILON_FLOAT16$1=1e-4;class DataStorage{constructor(e,t){this.backend=e,this.dataMover=t,this.data=new WeakMap,this.dataIdsCount=0}get(e){return this.data.has(e)||this.dataMover.moveData(this.backend,e),this.data.get(e)}set(e,t){this.dataIdsCount++,this.data.set(e,t)}has(e){return this.data.has(e)}delete(e){return this.dataIdsCount--,this.data.delete(e)}numDataIds(){return this.dataIdsCount}}class KernelBackend{refCount(e){return notYetImplemented("refCount")}incRef(e){return notYetImplemented("incRef")}timerAvailable(){return!0}time(e){return notYetImplemented("time")}read(e){return notYetImplemented("read")}readSync(e){return notYetImplemented("readSync")}numDataIds(){return notYetImplemented("numDataIds")}disposeData(e,t){return notYetImplemented("disposeData")}write(e,t,n){return notYetImplemented("write")}move(e,t,n,r,i){return notYetImplemented("move")}memory(){return notYetImplemented("memory")}floatPrecision(){return notYetImplemented("floatPrecision")}epsilon(){return 32===this.floatPrecision()?EPSILON_FLOAT32$1:EPSILON_FLOAT16$1}dispose(){return notYetImplemented("dispose")}}function notYetImplemented(e){throw new Error(`'${e}' not yet implemented or not found in the registry. This kernel may not be supported by the tfjs backend you have chosen`)}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function clamp$1(e,t,n){return Math.max(e,Math.min(t,n))}function nearestLargerEven(e){return e%2==0?e:e+1}function sum$3(e){let t=0;for(let n=0;n<e.length;n++)t+=e[n];return t}function assert$1(e,t){if(!e)throw new Error("string"==typeof t?t:t())}function assertShapesMatch(e,t,n=""){assert$1(arraysEqual$1(e,t),(()=>n+` Shapes ${e} and ${t} must match`))}function flatten$1(e,t=[],n=!1){if(null==t&&(t=[]),Array.isArray(e)||isTypedArray(e)&&!n)for(let r=0;r<e.length;++r)flatten$1(e[r],t,n);else t.push(e);return t}function sizeFromShape(e){if(0===e.length)return 1;let t=e[0];for(let n=1;n<e.length;n++)t*=e[n];return t}function arraysEqual$1(e,t){if(e===t)return!0;if(null==e||null==t)return!1;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function isInt(e){return e%1==0}function sizeToSquarishShape(e){const t=Math.ceil(Math.sqrt(e));return[t,Math.ceil(e/t)]}function rightPad(e,t){return t<=e.length?e:e+" ".repeat(t-e.length)}function repeatedTry(e,t=(e=>0),n){return new Promise(((r,i)=>{let a=0;const o=()=>{if(e())return void r();a++;const s=t(a);null!=n&&a>=n?i():setTimeout(o,s)};o()}))}function inferFromImplicitShape(e,t){let n=1,r=-1;for(let t=0;t<e.length;++t)if(e[t]>=0)n*=e[t];else if(-1===e[t]){if(-1!==r)throw Error(`Shapes can only have 1 implicit size. Found -1 at dim ${r} and dim ${t}`);r=t}else if(e[t]<0)throw Error(`Shapes can not be < 0. Found ${e[t]} at dim ${t}`);if(-1===r){if(t>0&&t!==n)throw Error(`Size(${t}) must match the product of shape ${e}`);return e}if(0===n)throw Error(`Cannot infer the missing size in [${e}] when there are 0 elements`);if(t%n!=0)throw Error(`The implicit shape can't be a fractional number. Got ${t} / ${n}`);const i=e.slice();return i[r]=t/n,i}function parseAxisParam(e,t){const n=t.length;return assert$1((e=null==e?t.map(((e,t)=>t)):[].concat(e)).every((e=>e>=-n&&e<n)),(()=>`All values in axis param must be in range [-${n}, ${n}) but got axis ${e}`)),assert$1(e.every((e=>isInt(e))),(()=>`All values in axis param must be integers but got axis ${e}`)),e.map((e=>e<0?n+e:e))}function squeezeShape(e,t){const n=[],r=[],i=null!=t&&Array.isArray(t)&&0===t.length,a=null==t||i?null:parseAxisParam(t,e).sort();let o=0;for(let t=0;t<e.length;++t){if(null!=a){if(a[o]===t&&1!==e[t])throw new Error(`Can't squeeze axis ${t} since its dim '${e[t]}' is not 1`);(null==a[o]||a[o]>t)&&1===e[t]&&(n.push(e[t]),r.push(t)),a[o]<=t&&o++}1!==e[t]&&(n.push(e[t]),r.push(t))}return{newShape:n,keptDims:r}}function getTypedArrayFromDType(e,t){let n=null;if(null==e||"float32"===e)n=new Float32Array(t);else if("int32"===e)n=new Int32Array(t);else{if("bool"!==e)throw new Error(`Unknown data type ${e}`);n=new Uint8Array(t)}return n}function getArrayFromDType(e,t){let n=null;if(null==e||"float32"===e)n=new Float32Array(t);else if("int32"===e)n=new Int32Array(t);else if("bool"===e)n=new Uint8Array(t);else{if("string"!==e)throw new Error(`Unknown data type ${e}`);n=new Array(t)}return n}function checkConversionForErrors(e,t){for(let n=0;n<e.length;n++){const r=e[n];if(isNaN(r)||!isFinite(r))throw Error(`A tensor of type ${t} being uploaded contains ${r}.`)}}function isValidDtype(e){return"bool"===e||"complex64"===e||"float32"===e||"int32"===e||"string"===e}function hasEncodingLoss(e,t){return"complex64"!==t&&(("float32"!==t||"complex64"===e)&&(("int32"!==t||"float32"===e||"complex64"===e)&&("bool"!==t||"bool"!==e)))}function isTypedArray(e){return e instanceof Float32Array||e instanceof Int32Array||e instanceof Uint8Array}function bytesPerElement(e){if("float32"===e||"int32"===e)return 4;if("complex64"===e)return 8;if("bool"===e)return 1;throw new Error(`Unknown dtype ${e}`)}function bytesFromStringArray(e){if(null==e)return 0;let t=0;return e.forEach((e=>t+=e.length)),t}function isString(e){return"string"==typeof e||e instanceof String}function isBoolean(e){return"boolean"==typeof e}function isNumber(e){return"number"==typeof e}function inferDtype(e){return Array.isArray(e)?inferDtype(e[0]):e instanceof Float32Array?"float32":e instanceof Int32Array||e instanceof Uint8Array?"int32":isNumber(e)?"float32":isString(e)?"string":isBoolean(e)?"bool":"float32"}function isFunction(e){return!!(e&&e.constructor&&e.call&&e.apply)}function nearestDivisor(e,t){for(let n=t;n<e;++n)if(e%n==0)return n;return e}function computeStrides(e){const t=e.length;if(t<2)return[];const n=new Array(t-1);n[t-2]=e[t-1];for(let r=t-3;r>=0;--r)n[r]=n[r+1]*e[r+1];return n}function createNestedArray(e,t,n,r=!1){const i=new Array;if(1===t.length){const a=t[0]*(r?2:1);for(let t=0;t<a;t++)i[t]=n[e+t]}else{const a=t[0],o=t.slice(1),s=o.reduce(((e,t)=>e*t))*(r?2:1);for(let t=0;t<a;t++)i[t]=createNestedArray(e+t*s,o,n,r)}return i}function toNestedArray(e,t,n=!1){if(0===e.length)return t[0];const r=e.reduce(((e,t)=>e*t))*(n?2:1);if(0===r)return[];if(r!==t.length)throw new Error(`[${e}] does not match the input size ${t.length}${n?" for a complex tensor":""}.`);return createNestedArray(0,e,t,n)}function makeOnesTypedArray(e,t){const n=makeZerosTypedArray(e,t);for(let e=0;e<n.length;e++)n[e]=1;return n}function makeZerosTypedArray(e,t){if(null==t||"float32"===t||"complex64"===t)return new Float32Array(e);if("int32"===t)return new Int32Array(e);if("bool"===t)return new Uint8Array(e);throw new Error(`Unknown data type ${t}`)}function makeZerosNestedTypedArray(e,t){const n=e.reduce(((e,t)=>e*t),1);if(null==t||"float32"===t)return toNestedArray(e,new Float32Array(n));if("int32"===t)return toNestedArray(e,new Int32Array(n));if("bool"===t)return toNestedArray(e,new Uint8Array(n));throw new Error(`Unknown data type ${t}`)}function assertNonNegativeIntegerDimensions(e){e.forEach((t=>{assert$1(Number.isInteger(t)&&t>=0,(()=>`Tensor must have a shape comprised of positive integers but got shape [${e}].`))}))}function locToIndex(e,t,n){if(0===t)return 0;if(1===t)return e[0];let r=e[e.length-1];for(let t=0;t<e.length-1;++t)r+=n[t]*e[t];return r}function indexToLoc(e,t,n){if(0===t)return[];if(1===t)return[e];const r=new Array(t);for(let t=0;t<r.length-1;++t)r[t]=Math.floor(e/n[t]),e-=r[t]*n[t];return r[r.length-1]=e,r}function isPromise(e){return e&&e.then&&"function"==typeof e.then}
/**
     * @license
     * Copyright 2017 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */const TENSORFLOWJS_FLAGS_PREFIX="tfjsflags";class Environment{constructor(e){this.global=e,this.flags={},this.flagRegistry={},this.urlFlags={},this.getQueryParams=getQueryParams,this.populateURLFlags()}setPlatform(e,t){null!=this.platform&&console.warn(`Platform ${this.platformName} has already been set. Overwriting the platform with ${t}.`),this.platformName=e,this.platform=t}registerFlag(e,t,n){if(this.flagRegistry[e]={evaluationFn:t,setHook:n},null!=this.urlFlags[e]){const t=this.urlFlags[e];console.warn(`Setting feature override from URL ${e}: ${t}.`),this.set(e,t)}}async getAsync(e){return e in this.flags||(this.flags[e]=await this.evaluateFlag(e)),this.flags[e]}get(e){if(e in this.flags)return this.flags[e];const t=this.evaluateFlag(e);if(isPromise(t))throw new Error(`Flag ${e} cannot be synchronously evaluated. Please use getAsync() instead.`);return this.flags[e]=t,this.flags[e]}getNumber(e){return this.get(e)}getBool(e){return this.get(e)}getFlags(){return this.flags}get features(){return this.flags}set(e,t){if(null==this.flagRegistry[e])throw new Error(`Cannot set flag ${e} as it has not been registered.`);this.flags[e]=t,null!=this.flagRegistry[e].setHook&&this.flagRegistry[e].setHook(t)}evaluateFlag(e){if(null==this.flagRegistry[e])throw new Error(`Cannot evaluate flag '${e}': no evaluation function found.`);return this.flagRegistry[e].evaluationFn()}setFlags(e){this.flags=Object.assign({},e)}reset(){this.flags={},this.urlFlags={},this.populateURLFlags()}populateURLFlags(){if(void 0===this.global||void 0===this.global.location||void 0===this.global.location.search)return;const e=this.getQueryParams(this.global.location.search);if(TENSORFLOWJS_FLAGS_PREFIX in e){e[TENSORFLOWJS_FLAGS_PREFIX].split(",").forEach((e=>{const[t,n]=e.split(":");this.urlFlags[t]=parseValue(t,n)}))}}}function getQueryParams(e){const t={};return e.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g,((e,...n)=>(decodeParam(t,n[0],n[1]),n.join("=")))),t}function decodeParam(e,t,n){e[decodeURIComponent(t)]=decodeURIComponent(n||"")}function parseValue(e,t){if("true"===(t=t.toLowerCase())||"false"===t)return"true"===t;if(""+ +t===t)return+t;throw new Error(`Could not parse value flag value ${t} for flag ${e}.`)}function env(){return ENV$2}let ENV$2=null,globalNameSpace;function setEnvironmentGlobal(e){ENV$2=e}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function getGlobalNamespace(){if(null==globalNameSpace){let e;if("undefined"!=typeof window)e=window;else if("undefined"!=typeof global)e=global;else if("undefined"!=typeof process)e=process;else{if("undefined"==typeof self)throw new Error("Could not find a global object");e=self}globalNameSpace=e}return globalNameSpace}function getGlobalMap(){const e=getGlobalNamespace();return null==e._tfGlobals&&(e._tfGlobals=new Map),e._tfGlobals}function getGlobal(e,t){const n=getGlobalMap();if(n.has(e))return n.get(e);{const r=t();return n.set(e,r),n.get(e)}}const Abs="Abs",Acos="Acos",Acosh="Acosh",Add="Add",AddN="AddN",All="All",Any="Any",ArgMax="ArgMax",ArgMin="ArgMin",Asin="Asin",Asinh="Asinh",Atan="Atan",Atanh="Atanh",Atan2="Atan2",AvgPool="AvgPool",AvgPoolGrad="AvgPoolGrad",AvgPool3D="AvgPool3D",AvgPool3DGrad="AvgPool3DGrad",BatchMatMul="BatchMatMul",BatchToSpaceND="BatchToSpaceND",Bincount="Bincount",Cast="Cast",Ceil="Ceil",ClipByValue="ClipByValue",Complex="Complex",ComplexAbs="ComplexAbs",Concat="Concat",Conv2D="Conv2D",Conv2DBackpropFilter="Conv2DBackpropFilter",Conv2DBackpropInput="Conv2DBackpropInput",Conv3D="Conv3D",Conv3DBackpropFilterV2="Conv3DBackpropFilterV2",Conv3DBackpropInputV2="Conv3DBackpropInputV2",Cos="Cos",Cosh="Cosh",Cumsum="Cumsum",CropAndResize="CropAndResize",DenseBincount="DenseBincount",DepthToSpace="DepthToSpace",DepthwiseConv2dNative="DepthwiseConv2dNative",DepthwiseConv2dNativeBackpropFilter="DepthwiseConv2dNativeBackpropFilter",DepthwiseConv2dNativeBackpropInput="DepthwiseConv2dNativeBackpropInput",Diag="Diag",Dilation2D="Dilation2D",Dilation2DBackpropInput="Dilation2DBackpropInput",Dilation2DBackpropFilter="Dilation2DBackpropFilter",RealDiv="RealDiv",Einsum="Einsum",Elu="Elu",EluGrad="EluGrad",Erf="Erf",Equal="Equal",Exp="Exp",ExpandDims="ExpandDims",Expm1="Expm1",FFT="FFT",Fill="Fill",FlipLeftRight="FlipLeftRight",Floor="Floor",FloorDiv="FloorDiv",FusedBatchNorm="FusedBatchNorm",GatherV2="GatherV2",GatherNd="GatherNd",Greater="Greater",GreaterEqual="GreaterEqual",Identity="Identity",IFFT="IFFT",Imag="Imag",IsFinite="IsFinite",IsInf="IsInf",IsNan="IsNan",LeakyRelu="LeakyRelu",Less="Less",LessEqual="LessEqual",LinSpace="LinSpace",Log="Log",Log1p="Log1p",LogicalAnd="LogicalAnd",LogicalNot="LogicalNot",LogicalOr="LogicalOr",LRN="LRN",LRNGrad="LRNGrad",Max="Max",Maximum="Maximum",MaxPool="MaxPool",MaxPoolGrad="MaxPoolGrad",MaxPool3D="MaxPool3D",MaxPool3DGrad="MaxPool3DGrad",MaxPoolWithArgmax="MaxPoolWithArgmax",Mean="Mean",Min="Min",Minimum="Minimum",MirrorPad="MirrorPad",Mod="Mod",Multinomial="Multinomial",Multiply="Multiply",Neg="Neg",NotEqual="NotEqual",NonMaxSuppressionV3="NonMaxSuppressionV3",NonMaxSuppressionV4="NonMaxSuppressionV4",NonMaxSuppressionV5="NonMaxSuppressionV5",OnesLike="OnesLike",OneHot="OneHot",Pack="Pack",PadV2="PadV2",Pow="Pow",Prelu="Prelu",Prod="Prod",Range="Range",Real="Real",Reciprocal="Reciprocal",Relu="Relu",Reshape="Reshape",ResizeNearestNeighbor="ResizeNearestNeighbor",ResizeNearestNeighborGrad="ResizeNearestNeighborGrad",ResizeBilinear="ResizeBilinear",ResizeBilinearGrad="ResizeBilinearGrad",Relu6="Relu6",Reverse="Reverse",Round="Round",Rsqrt="Rsqrt",ScatterNd="ScatterNd",Select="Select",Selu="Selu",Slice="Slice",Sin="Sin",Sinh="Sinh",Sign="Sign",Sigmoid="Sigmoid",Softplus="Softplus",Sqrt="Sqrt",Sum="Sum",SpaceToBatchND="SpaceToBatchND",SplitV="SplitV",Softmax="Softmax",SquaredDifference="SquaredDifference",Square="Square",Sub="Sub",SparseToDense="SparseToDense",StridedSlice="StridedSlice",Tan="Tan",Tanh="Tanh",Tile="Tile",TopK="TopK",Transform="Transform",Transpose="Transpose",Unique="Unique",Unpack="Unpack",UnsortedSegmentSum="UnsortedSegmentSum",ZerosLike="ZerosLike",Step="Step",FromPixels="FromPixels",RotateWithOffset="RotateWithOffset",_FusedMatMul="_FusedMatMul",FusedConv2D="FusedConv2D",FusedDepthwiseConv2D="FusedDepthwiseConv2D",kernelRegistry=getGlobal("kernelRegistry",(()=>new Map)),gradRegistry=getGlobal("gradRegistry",(()=>new Map));function getKernel(e,t){const n=makeKey(e,t);return kernelRegistry.get(n)}function getGradient(e){return gradRegistry.get(e)}function getKernelsForBackend(e){const t=kernelRegistry.entries(),n=[];for(;;){const{done:r,value:i}=t.next();if(r)break;const[a,o]=i,[s]=a.split("_");s===e&&n.push(o)}return n}function registerKernel(e){const{kernelName:t,backendName:n}=e,r=makeKey(t,n);kernelRegistry.has(r)&&console.warn(`The kernel '${t}' for backend '${n}' is already registered`),kernelRegistry.set(r,e)}function makeKey(e,t){return`${t}_${e}`}
/**
     * @license
     * Copyright 2017 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function createScalarValue(e,t){return"string"===t?encodeString(e):toTypedArray$1([e],t)}function noConversionNeeded(e,t){return e instanceof Float32Array&&"float32"===t||e instanceof Int32Array&&"int32"===t||e instanceof Uint8Array&&"bool"===t}function toTypedArray$1(e,t){if("string"===t)throw new Error("Cannot convert a string[] to a TypedArray");if(Array.isArray(e)&&(e=flatten$1(e)),env().getBool("DEBUG")&&checkConversionForErrors(e,t),noConversionNeeded(e,t))return e;if(null==t||"float32"===t||"complex64"===t)return new Float32Array(e);if("int32"===t)return new Int32Array(e);if("bool"===t){const t=new Uint8Array(e.length);for(let n=0;n<t.length;++n)0!==Math.round(e[n])&&(t[n]=1);return t}throw new Error(`Unknown data type ${t}`)}function now(){return env().platform.now()}function encodeString(e,t="utf-8"){return t=t||"utf-8",env().platform.encode(e,t)}function decodeString(e,t="utf-8"){return t=t||"utf-8",env().platform.decode(e,t)}
/**
     * @license
     * Copyright 2018 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */class Profiler{constructor(e,t){this.backendTimer=e,this.logger=t,null==t&&(this.logger=new Logger)}profileKernel(e,t,n){let r;const i=()=>{r=n()};let a;const o=now();if(this.backendTimer.timerAvailable())a=this.backendTimer.time(i);else{i();for(const e of r)e.dataSync();a=Promise.resolve({kernelMs:now()-o})}if(env().getBool("CHECK_COMPUTATION_FOR_ERRORS"))for(let t=0;t<r.length;t++){const n=r[t];n.data().then((t=>{checkComputationForErrors(t,n.dtype,e)}))}return{kernelName:e,outputs:r,inputs:t,timeMs:a.then((e=>e.kernelMs)),extraInfo:a.then((e=>null!=e.getExtraProfileInfo?e.getExtraProfileInfo():""))}}logKernelProfile(e){const{kernelName:t,outputs:n,timeMs:r,inputs:i,extraInfo:a}=e;n.forEach((e=>{Promise.all([e.data(),r,a]).then((n=>{this.logger.logKernelProfile(t,e,n[0],n[1],i,n[2])}))}))}}function checkComputationForErrors(e,t,n){if("float32"!==t)return!1;for(let t=0;t<e.length;t++){const r=e[t];if(isNaN(r)||!isFinite(r))return console.warn(`Found ${r} in the result of '${n}'`),!0}return!1}class Logger{logKernelProfile(e,t,n,r,i,a){const o="number"==typeof r?rightPad(`${r}ms`,9):r.error,s=rightPad(e,25),l=t.rank,c=t.size,h=rightPad(t.shape.toString(),14);let u="";for(const e in i){const n=i[e];if(null!=n){const r=n.shape||t.shape,i=r.length;u+=`${e}: ${i}D ${i>0?r:""} `}}console.log(`%c${s}\t%c${o}\t%c${l}D ${h}\t%c${c}\t%c${u}\t%c${a}`,"font-weight:bold","color:red","color:blue","color: orange","color: green","color: steelblue")}}
/**
     * @license
     * Copyright 2017 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function getFilteredNodesXToY(e,t,n){const r={},i={};for(let e=0;e<t.length;e++)r[t[e].id]=!0;for(let n=0;n<e.length;n++){const a=e[n],o=a.inputs;for(const e in o){const n=o[e];let s=!1;for(let e=0;e<t.length;e++)if(r[n.id]){a.outputs.forEach((e=>r[e.id]=!0)),s=!0,i[a.id]=!0;break}if(s)break}}const a={};a[n.id]=!0;const o={};for(let t=e.length-1;t>=0;t--){const n=e[t],r=n.inputs;for(let e=0;e<n.outputs.length;e++)if(a[n.outputs[e].id]){for(const e in r)a[r[e].id]=!0,o[n.id]=!0;break}}const s=[];for(let t=0;t<e.length;t++){const n=e[t];if(i[n.id]&&o[n.id]){const e={};for(const t in n.inputs){const i=n.inputs[t];r[i.id]&&(e[t]=i)}const t=Object.assign({},n);t.inputs=e,t.outputs=n.outputs,s.push(t)}}return s}function backpropagateGradients(e,t,n,r){for(let i=t.length-1;i>=0;i--){const a=t[i],o=[];if(a.outputs.forEach((t=>{const n=e[t.id];o.push(null!=n?n:null)})),null==a.gradient)throw new Error(`Cannot compute gradient: gradient function not found for ${a.kernelName}.`);const s=a.gradient(o);for(const t in a.inputs){if(!(t in s))throw new Error(`Cannot backprop through input ${t}. Available gradients found: ${Object.keys(s)}.`);const i=n((()=>s[t]()));if("float32"!==i.dtype)throw new Error(`Error in gradient for op ${a.kernelName}. The gradient of input ${t} must have 'float32' dtype, but has '${i.dtype}'`);const o=a.inputs[t];if(!arraysEqual$1(i.shape,o.shape))throw new Error(`Error in gradient for op ${a.kernelName}. The gradient of input '${t}' has shape '${i.shape}', which does not match the shape of the input '${o.shape}'`);if(null==e[o.id])e[o.id]=i;else{const t=e[o.id];e[o.id]=r(t,i),t.dispose()}}}}
/**
     * @license
     * Copyright 2018 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */const FORMAT_LIMIT_NUM_VALS=20,FORMAT_NUM_FIRST_LAST_VALS=3,FORMAT_NUM_SIG_DIGITS=7;function tensorToString(e,t,n,r){const i=computeStrides(t),a=computeMaxSizePerColumn(e,t,n,i),o=t.length,s=subTensorToString(e,t,n,i,a),l=["Tensor"];return r&&(l.push(`  dtype: ${n}`),l.push(`  rank: ${o}`),l.push(`  shape: [${t}]`),l.push("  values:")),l.push(s.map((e=>"    "+e)).join("\n")),l.join("\n")}function computeMaxSizePerColumn(e,t,n,r){const i=sizeFromShape(t),a=r[r.length-1],o=new Array(a).fill(0),s=t.length,l="complex64"===n?createComplexTuples(e):e;if(s>1)for(let e=0;e<i/a;e++){const t=e*a;for(let e=0;e<a;e++)o[e]=Math.max(o[e],valToString(l[t+e],0,n).length)}return o}function valToString(e,t,n){let r;return r=Array.isArray(e)?`${parseFloat(e[0].toFixed(FORMAT_NUM_SIG_DIGITS))} + ${parseFloat(e[1].toFixed(FORMAT_NUM_SIG_DIGITS))}j`:isString(e)?`'${e}'`:"bool"===n?boolNumToString(e):parseFloat(e.toFixed(FORMAT_NUM_SIG_DIGITS)).toString(),rightPad(r,t)}function boolNumToString(e){return 0===e?"false":"true"}function subTensorToString(e,t,n,r,i,a=!0){const o="complex64"===n?2:1,s=t[0],l=t.length;if(0===l){if("complex64"===n){return[valToString(createComplexTuples(e)[0],0,n)]}return"bool"===n?[boolNumToString(e[0])]:[e[0].toString()]}if(1===l){if(s>FORMAT_LIMIT_NUM_VALS){let t=Array.from(e.slice(0,FORMAT_NUM_FIRST_LAST_VALS*o)),r=Array.from(e.slice((s-FORMAT_NUM_FIRST_LAST_VALS)*o,s*o));return"complex64"===n&&(t=createComplexTuples(t),r=createComplexTuples(r)),["["+t.map(((e,t)=>valToString(e,i[t],n))).join(", ")+", ..., "+r.map(((e,t)=>valToString(e,i[s-FORMAT_NUM_FIRST_LAST_VALS+t],n))).join(", ")+"]"]}return["["+("complex64"===n?createComplexTuples(e):Array.from(e)).map(((e,t)=>valToString(e,i[t],n))).join(", ")+"]"]}const c=t.slice(1),h=r.slice(1),u=r[0]*o,d=[];if(s>FORMAT_LIMIT_NUM_VALS){for(let t=0;t<FORMAT_NUM_FIRST_LAST_VALS;t++){const r=t*u;d.push(...subTensorToString(e.slice(r,r+u),c,n,h,i,!1))}d.push("...");for(let t=s-FORMAT_NUM_FIRST_LAST_VALS;t<s;t++){const r=t*u;d.push(...subTensorToString(e.slice(r,r+u),c,n,h,i,t===s-1))}}else for(let t=0;t<s;t++){const r=t*u;d.push(...subTensorToString(e.slice(r,r+u),c,n,h,i,t===s-1))}const p=2===l?",":"";d[0]="["+d[0]+p;for(let e=1;e<d.length-1;e++)d[e]=" "+d[e]+p;let m=",\n";for(let e=2;e<l;e++)m+="\n";return d[d.length-1]=" "+d[d.length-1]+"]"+(a?"":m),d}function createComplexTuples(e){const t=[];for(let n=0;n<e.length;n+=2)t.push([e[n],e[n+1]]);return t}
/**
     * @license
     * Copyright 2017 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */class TensorBuffer{constructor(e,t,n){if(this.dtype=t,this.shape=e.slice(),this.size=sizeFromShape(e),null!=n){const e=n.length;assert$1(e===this.size,(()=>`Length of values '${e}' does not match the size inferred by the shape '${this.size}'.`))}if("complex64"===t)throw new Error("complex64 dtype TensorBuffers are not supported. Please create a TensorBuffer for the real and imaginary parts separately and call tf.complex(real, imag).");this.values=n||getArrayFromDType(t,this.size),this.strides=computeStrides(e)}set(e,...t){0===t.length&&(t=[0]),assert$1(t.length===this.rank,(()=>`The number of provided coordinates (${t.length}) must match the rank (${this.rank})`));const n=this.locToIndex(t);this.values[n]=e}get(...e){0===e.length&&(e=[0]);let t=0;for(const n of e){if(n<0||n>=this.shape[t]){throw new Error(`Requested out of range element at ${e}.   Buffer shape=${this.shape}`)}t++}let n=e[e.length-1];for(let t=0;t<e.length-1;++t)n+=this.strides[t]*e[t];return this.values[n]}locToIndex(e){if(0===this.rank)return 0;if(1===this.rank)return e[0];let t=e[e.length-1];for(let n=0;n<e.length-1;++n)t+=this.strides[n]*e[n];return t}indexToLoc(e){if(0===this.rank)return[];if(1===this.rank)return[e];const t=new Array(this.shape.length);for(let n=0;n<t.length-1;++n)t[n]=Math.floor(e/this.strides[n]),e-=t[n]*this.strides[n];return t[t.length-1]=e,t}get rank(){return this.shape.length}toTensor(){return trackerFn().makeTensor(this.values,this.shape,this.dtype)}}let trackerFn=null,opHandler$1=null;function setTensorTracker(e){trackerFn=e}function setOpHandler(e){opHandler$1=e}class Tensor{constructor(e,t,n,r){this.kept=!1,this.isDisposedInternal=!1,this.shape=e.slice(),this.dtype=t||"float32",this.size=sizeFromShape(e),this.strides=computeStrides(e),this.dataId=n,this.id=r,this.rankType=this.rank<5?this.rank.toString():"higher"}get rank(){return this.shape.length}async buffer(){const e=await this.data();return opHandler$1.buffer(this.shape,this.dtype,e)}bufferSync(){return opHandler$1.buffer(this.shape,this.dtype,this.dataSync())}async array(){const e=await this.data();return toNestedArray(this.shape,e,"complex64"===this.dtype)}arraySync(){return toNestedArray(this.shape,this.dataSync(),"complex64"===this.dtype)}async data(){this.throwIfDisposed();const e=trackerFn().read(this.dataId);if("string"===this.dtype){const t=await e;try{return t.map((e=>decodeString(e)))}catch(e){throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().")}}return e}dataSync(){this.throwIfDisposed();const e=trackerFn().readSync(this.dataId);if("string"===this.dtype)try{return e.map((e=>decodeString(e)))}catch(e){throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().")}return e}async bytes(){this.throwIfDisposed();const e=await trackerFn().read(this.dataId);return"string"===this.dtype?e:new Uint8Array(e.buffer)}dispose(){this.isDisposed||(trackerFn().disposeTensor(this),this.isDisposedInternal=!0)}get isDisposed(){return this.isDisposedInternal}throwIfDisposed(){if(this.isDisposed)throw new Error("Tensor is disposed.")}print(e=!1){return opHandler$1.print(this,e)}clone(){return this.throwIfDisposed(),opHandler$1.clone(this)}toString(e=!1){return tensorToString(this.dataSync(),this.shape,this.dtype,e)}cast(e){return this.throwIfDisposed(),opHandler$1.cast(this,e)}variable(e=!0,t,n){return this.throwIfDisposed(),trackerFn().makeVariable(this,e,t,n)}}function getGlobalTensorClass(){return getGlobal("Tensor",(()=>Tensor))}Object.defineProperty(Tensor,Symbol.hasInstance,{value:e=>!!e&&null!=e.data&&null!=e.dataSync&&null!=e.throwIfDisposed}),getGlobalTensorClass();class Variable extends Tensor{constructor(e,t,n,r){super(e.shape,e.dtype,e.dataId,r),this.trainable=t,this.name=n}assign(e){if(e.dtype!==this.dtype)throw new Error(`dtype of the new value (${e.dtype}) and previous value (${this.dtype}) must match`);if(!arraysEqual$1(e.shape,this.shape))throw new Error(`shape of the new value (${e.shape}) and previous value (${this.shape}) must match`);trackerFn().disposeTensor(this),this.dataId=e.dataId,trackerFn().incRef(this,null)}dispose(){trackerFn().disposeVariable(this),this.isDisposedInternal=!0}}
/**
     * @license
     * Copyright 2017 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
var Rank,UpcastInt32AndMap,UpcastBoolAndMap,UpcastFloat32AndMap,UpcastComplex64AndMap;Object.defineProperty(Variable,Symbol.hasInstance,{value:e=>e instanceof Tensor&&null!=e.assign&&e.assign instanceof Function}),(function(e){e.R0="R0",e.R1="R1",e.R2="R2",e.R3="R3",e.R4="R4",e.R5="R5",e.R6="R6"})(Rank||(Rank={})),(function(e){e.float32="float32",e.int32="int32",e.bool="int32",e.complex64="complex64"})(UpcastInt32AndMap||(UpcastInt32AndMap={})),(function(e){e.float32="float32",e.int32="int32",e.bool="bool",e.complex64="complex64"})(UpcastBoolAndMap||(UpcastBoolAndMap={})),(function(e){e.float32="float32",e.int32="float32",e.bool="float32",e.complex64="complex64"})(UpcastFloat32AndMap||(UpcastFloat32AndMap={})),(function(e){e.float32="complex64",e.int32="complex64",e.bool="complex64",e.complex64="complex64"})(UpcastComplex64AndMap||(UpcastComplex64AndMap={}));const upcastTypeMap={float32:UpcastFloat32AndMap,int32:UpcastInt32AndMap,bool:UpcastBoolAndMap,complex64:UpcastComplex64AndMap};function upcastType(e,t){if("string"===e||"string"===t){if("string"===e&&"string"===t)return"string";throw new Error(`Can not upcast ${e} with ${t}`)}return upcastTypeMap[e][t]}function sumOutType(e){return upcastType(e,"int32")}
/**
     * @license
     * Copyright 2018 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function makeTypesMatch(e,t){if(e.dtype===t.dtype)return[e,t];const n=upcastType(e.dtype,t.dtype);return[e.cast(n),t.cast(n)]}function getTensorsInContainer(e){const t=[];return walkTensorContainer(e,t,new Set),t}function walkTensorContainer(e,t,n){if(null==e)return;if(e instanceof Tensor)return void t.push(e);if(!isIterable(e))return;const r=e;for(const e in r){const i=r[e];n.has(i)||(n.add(i),walkTensorContainer(i,t,n))}}function isIterable(e){return Array.isArray(e)||"object"==typeof e}
/**
     * @license
     * Copyright 2018 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function isRegisteredKernelInvocation(e){return null!=e.kernelName}class EngineState{constructor(){this.registeredVariables={},this.nextTapeNodeId=0,this.numBytes=0,this.numTensors=0,this.numStringTensors=0,this.numDataBuffers=0,this.gradientDepth=0,this.kernelDepth=0,this.scopeStack=[],this.numDataMovesStack=[],this.nextScopeId=0,this.tensorInfo=new WeakMap,this.profiling=!1,this.activeProfile={newBytes:0,newTensors:0,peakBytes:0,kernels:[],result:null,get kernelNames(){return Array.from(new Set(this.kernels.map((e=>e.name))))}}}dispose(){for(const e in this.registeredVariables)this.registeredVariables[e].dispose()}}class Engine{constructor(e){this.ENV=e,this.registry={},this.registryFactory={},this.pendingBackendInitId=0,this.state=new EngineState}async ready(){if(null!=this.pendingBackendInit)return this.pendingBackendInit.then((()=>{}));if(null!=this.backendInstance)return;const e=this.getSortedBackends();for(let t=0;t<e.length;t++){const n=e[t];if(await this.initializeBackend(n).success)return void await this.setBackend(n)}throw new Error("Could not initialize any backends, all backend initializations failed.")}get backend(){if(null!=this.pendingBackendInit)throw new Error(`Backend '${this.backendName}' has not yet been initialized. Make sure to await tf.ready() or await tf.setBackend() before calling other methods`);if(null==this.backendInstance){const{name:e,asyncInit:t}=this.initializeBackendsAndReturnBest();if(t)throw new Error(`The highest priority backend '${e}' has not yet been initialized. Make sure to await tf.ready() or await tf.setBackend() before calling other methods`);this.setBackend(e)}return this.backendInstance}backendNames(){return Object.keys(this.registryFactory)}findBackend(e){if(!(e in this.registry)){if(!(e in this.registryFactory))return null;{const{asyncInit:t}=this.initializeBackend(e);if(t)return null}}return this.registry[e]}findBackendFactory(e){return e in this.registryFactory?this.registryFactory[e].factory:null}registerBackend(e,t,n=1){return e in this.registryFactory?(console.warn(`${e} backend was already registered. Reusing existing backend factory.`),!1):(this.registryFactory[e]={factory:t,priority:n},!0)}async setBackend(e){if(null==this.registryFactory[e])throw new Error(`Backend name '${e}' not found in registry`);if(this.backendName=e,null==this.registry[e]){this.backendInstance=null;const{success:t,asyncInit:n}=this.initializeBackend(e);if(!(n?await t:t))return!1}return this.backendInstance=this.registry[e],this.setupRegisteredKernels(),this.profiler=new Profiler(this.backendInstance),!0}setupRegisteredKernels(){getKernelsForBackend(this.backendName).forEach((e=>{null!=e.setupFunc&&e.setupFunc(this.backendInstance)}))}disposeRegisteredKernels(e){getKernelsForBackend(e).forEach((t=>{null!=t.disposeFunc&&t.disposeFunc(this.registry[e])}))}initializeBackend(e){const t=this.registryFactory[e];if(null==t)throw new Error(`Cannot initialize backend ${e}, no registration found.`);try{const n=t.factory();if(!n||n instanceof KernelBackend||"function"!=typeof n.then)return this.registry[e]=n,{success:!0,asyncInit:!1};{const t=++this.pendingBackendInitId,r=n.then((n=>!(t<this.pendingBackendInitId)&&(this.registry[e]=n,this.pendingBackendInit=null,!0))).catch((n=>(t<this.pendingBackendInitId||(this.pendingBackendInit=null,console.warn(`Initialization of backend ${e} failed`),console.warn(n.stack||n.message)),!1)));return this.pendingBackendInit=r,{success:r,asyncInit:!0}}}catch(t){return console.warn(`Initialization of backend ${e} failed`),console.warn(t.stack||t.message),{success:!1,asyncInit:!1}}}removeBackend(e){if(!(e in this.registryFactory))throw new Error(`${e} backend not found in registry`);this.backendName===e&&null!=this.pendingBackendInit&&this.pendingBackendInitId++,e in this.registry&&(this.disposeRegisteredKernels(e),this.registry[e].dispose(),delete this.registry[e]),delete this.registryFactory[e],this.backendName===e&&(this.pendingBackendInit=null,this.backendName=null,this.backendInstance=null)}getSortedBackends(){if(0===Object.keys(this.registryFactory).length)throw new Error("No backend found in registry.");return Object.keys(this.registryFactory).sort(((e,t)=>this.registryFactory[t].priority-this.registryFactory[e].priority))}initializeBackendsAndReturnBest(){const e=this.getSortedBackends();for(let t=0;t<e.length;t++){const n=e[t],{success:r,asyncInit:i}=this.initializeBackend(n);if(i||r)return{name:n,asyncInit:i}}throw new Error("Could not initialize any backends, all backend initializations failed.")}moveData(e,t){const n=this.state.tensorInfo.get(t),r=n.backend,i=this.readSync(t),a=r.refCount(t);r.disposeData(t,!0),n.backend=e,e.move(t,i,n.shape,n.dtype,a),this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack[this.state.numDataMovesStack.length-1]++}tidy(e,t){let n,r=null;if(null==t){if("function"!=typeof e)throw new Error("Please provide a function to tidy()");t=e}else{if("string"!=typeof e&&!(e instanceof String))throw new Error("When calling with two arguments, the first argument to tidy() must be a string");if("function"!=typeof t)throw new Error("When calling with two arguments, the 2nd argument to tidy() must be a function");r=e}return this.scopedRun((()=>this.startScope(r)),(()=>this.endScope(n)),(()=>(n=t(),n instanceof Promise&&console.error("Cannot return a Promise inside of tidy."),n)))}scopedRun(e,t,n){e();try{const e=n();return t(),e}catch(e){throw t(),e}}nextTensorId(){return Engine.nextTensorId++}nextVariableId(){return Engine.nextVariableId++}clone(e){const t=ENGINE.runKernel(Identity,{x:e});return this.addTapeNode(this.state.activeScope.name,{x:e},[t],(e=>({x:()=>ENGINE.runKernel(Cast,{x:e},{dtype:"float32"})})),[],{}),t}runKernel(e,t,n){if(!(null!=getKernel(e,this.backendName)))throw new Error(`Kernel '${e}' not registered for backend '${this.backendName}'`);return this.runKernelFunc({kernelName:e,inputs:t,attrs:n})}shouldCheckForMemLeaks(){return this.ENV.getBool("IS_TEST")}checkKernelForMemLeak(e,t,n){const r=this.backend.numDataIds();let i=0;n.forEach((e=>{i+="complex64"===e.dtype?3:1}));const a=r-t-i-this.state.numDataMovesStack[this.state.numDataMovesStack.length-1];if(a>0)throw new Error(`Backend '${this.backendName}' has an internal memory leak (${a} data ids) after running '${e}'`)}runKernelFunc(e){let t,n=[];const r=this.isTapeOn(),i=this.state.numBytes,a=this.state.numTensors;let o,s;this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack.push(0);const l=isRegisteredKernelInvocation(e)?e.kernelName:null!=this.state.activeScope?this.state.activeScope.name:"";if(isRegisteredKernelInvocation(e)){const{kernelName:t,inputs:i,attrs:a}=e,l=getKernel(t,this.backendName);assert$1(null!=l,(()=>`Cannot find registered kernel '${t}' for backend '${this.backendName}'`)),o=()=>{const e=this.backend.numDataIds();s=l.kernelFunc({inputs:i,attrs:a,backend:this.backend});const o=Array.isArray(s)?s:[s];this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(t,e,o);const c=o.map((e=>{if(null!=e.rank)return e;const{dataId:t,shape:n,dtype:r}=e;return this.makeTensorFromDataId(t,n,r)}));if(r){const e=this.getTensorsForGradient(t,i,c);n=this.saveTensorsForBackwardMode(e)}return c}}else{const{forwardFunc:t}=e,i=e=>{r&&(n=e.map((e=>this.keep(this.clone(e)))))};o=()=>{const e=this.backend.numDataIds();s=this.tidy((()=>t(this.backend,i)));const n=Array.isArray(s)?s:[s];return this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(l,e,n),n}}const{inputs:c,attrs:h}=e,u=isRegisteredKernelInvocation(e)?null:e.backwardsFunc;let d;return this.scopedRun((()=>this.state.kernelDepth++),(()=>this.state.kernelDepth--),(()=>{this.ENV.getBool("DEBUG")||this.state.profiling?(d=this.profiler.profileKernel(l,c,(()=>o())),this.ENV.getBool("DEBUG")&&this.profiler.logKernelProfile(d),t=d.outputs):t=o()})),r&&this.addTapeNode(l,c,t,u,n,h),this.state.profiling&&this.state.activeProfile.kernels.push({name:l,bytesAdded:this.state.numBytes-i,totalBytesSnapshot:this.state.numBytes,tensorsAdded:this.state.numTensors-a,totalTensorsSnapshot:this.state.numTensors,inputShapes:Object.keys(c).map((e=>null!=c[e]?c[e].shape:null)),outputShapes:t.map((e=>e.shape)),kernelTimeMs:d.timeMs,extraInfo:d.extraInfo}),Array.isArray(s)?t:t[0]}saveTensorsForBackwardMode(e){return e.map((e=>this.keep(this.clone(e))))}getTensorsForGradient(e,t,n){const r=getGradient(e);if(null!=r){const e=r.inputsToSave||[],i=r.outputsToSave||[];let a;r.saveAllInputs?(assert$1(Array.isArray(t),(()=>"saveAllInputs is true, expected inputs to be an array.")),a=Object.keys(t).map((e=>t[e]))):a=e.map((e=>t[e]));const o=n.filter(((e,t)=>i[t]));return a.concat(o)}return[]}makeTensor(e,t,n,r){if(null==e)throw new Error("Values passed to engine.makeTensor() are null");r=r||this.backend;let i=e;"string"===(n=n||"float32")&&isString(e[0])&&(i=e.map((e=>encodeString(e))));const a=r.write(i,t,n),o=new Tensor(t,n,a,this.nextTensorId());if(this.trackTensor(o,r),"string"===n){const e=this.state.tensorInfo.get(a),t=bytesFromStringArray(i);this.state.numBytes+=t-e.bytes,e.bytes=t}return o}makeTensorFromDataId(e,t,n,r){const i=new Tensor(t,n=n||"float32",e,this.nextTensorId());return this.trackTensor(i,r),i}makeVariable(e,t=!0,n,r){n=n||this.nextVariableId().toString(),null!=r&&r!==e.dtype&&(e=e.cast(r));const i=new Variable(e,t,n,this.nextTensorId());if(null!=this.state.registeredVariables[i.name])throw new Error(`Variable with name ${i.name} was already registered`);return this.state.registeredVariables[i.name]=i,this.incRef(i,this.backend),i}trackTensor(e,t){this.state.numTensors++,"string"===e.dtype&&this.state.numStringTensors++;let n=0;"complex64"!==e.dtype&&"string"!==e.dtype&&(n=e.size*bytesPerElement(e.dtype)),this.state.numBytes+=n,this.state.tensorInfo.has(e.dataId)||(this.state.numDataBuffers++,this.state.tensorInfo.set(e.dataId,{backend:t||this.backend,dtype:e.dtype,shape:e.shape,bytes:n})),e instanceof Variable||this.track(e)}incRef(e,t){this.trackTensor(e,t),this.backend.incRef(e.dataId)}removeDataId(e,t){this.state.tensorInfo.has(e)&&this.state.tensorInfo.get(e).backend===t&&(this.state.tensorInfo.delete(e),this.state.numDataBuffers--)}disposeTensor(e){if(!this.state.tensorInfo.has(e.dataId))return;const t=this.state.tensorInfo.get(e.dataId);if(this.state.numTensors--,"string"===e.dtype&&(this.state.numStringTensors--,this.state.numBytes-=t.bytes),"complex64"!==e.dtype&&"string"!==e.dtype){const t=e.size*bytesPerElement(e.dtype);this.state.numBytes-=t}t.backend.disposeData(e.dataId)&&this.removeDataId(e.dataId,t.backend)}disposeVariables(){for(const e in this.state.registeredVariables){this.disposeVariable(this.state.registeredVariables[e])}}disposeVariable(e){this.disposeTensor(e),null!=this.state.registeredVariables[e.name]&&delete this.state.registeredVariables[e.name]}memory(){const e=this.backend.memory();return e.numTensors=this.state.numTensors,e.numDataBuffers=this.state.numDataBuffers,e.numBytes=this.state.numBytes,this.state.numStringTensors>0&&(e.unreliable=!0,null==e.reasons&&(e.reasons=[]),e.reasons.push("Memory usage by string tensors is approximate (2 bytes per character)")),e}async profile(e){this.state.profiling=!0;const t=this.state.numBytes,n=this.state.numTensors;this.state.activeProfile.kernels=[],this.state.activeProfile.result=await e(),this.state.profiling=!1,this.state.activeProfile.peakBytes=Math.max(...this.state.activeProfile.kernels.map((e=>e.totalBytesSnapshot))),this.state.activeProfile.newBytes=this.state.numBytes-t,this.state.activeProfile.newTensors=this.state.numTensors-n;for(const e of this.state.activeProfile.kernels)e.kernelTimeMs=await e.kernelTimeMs,e.extraInfo=await e.extraInfo;return this.state.activeProfile}isTapeOn(){return this.state.gradientDepth>0&&0===this.state.kernelDepth}addTapeNode(e,t,n,r,i,a){const o={id:this.state.nextTapeNodeId++,kernelName:e,inputs:t,outputs:n,saved:i},s=getGradient(e);null!=s&&(r=s.gradFunc),null!=r&&(o.gradient=e=>(e=e.map(((e,t)=>{if(null==e){const e=n[t],r=makeZerosTypedArray(e.size,e.dtype);return this.makeTensor(r,e.shape,e.dtype)}return e})),r(e.length>1?e:e[0],i,a))),this.state.activeTape.push(o)}keep(e){return e.kept=!0,e}startTape(){0===this.state.gradientDepth&&(this.state.activeTape=[]),this.state.gradientDepth++}endTape(){this.state.gradientDepth--}startScope(e){const t={track:[],name:"unnamed scope",id:this.state.nextScopeId++};e&&(t.name=e),this.state.scopeStack.push(t),this.state.activeScope=t}endScope(e){const t=getTensorsInContainer(e),n=new Set(t.map((e=>e.id)));for(let e=0;e<this.state.activeScope.track.length;e++){const t=this.state.activeScope.track[e];t.kept||n.has(t.id)||t.dispose()}const r=this.state.scopeStack.pop();this.state.activeScope=0===this.state.scopeStack.length?null:this.state.scopeStack[this.state.scopeStack.length-1],t.forEach((e=>{e.kept||e.scopeId!==r.id||this.track(e)}))}gradients(e,t,n,r=!1){if(assert$1(t.length>0,(()=>"gradients() received an empty list of xs.")),null!=n&&"float32"!==n.dtype)throw new Error(`dy must have 'float32' dtype, but has '${n.dtype}'`);const i=this.scopedRun((()=>this.startTape()),(()=>this.endTape()),(()=>this.tidy("forward",e)));assert$1(i instanceof Tensor,(()=>"The result y returned by f() must be a tensor."));const a=getFilteredNodesXToY(this.state.activeTape,t,i);if(!r&&0===a.length&&t.length>0)throw new Error("Cannot compute gradient of y=f(x) with respect to x. Make sure that the f you passed encloses all operations that lead from x to y.");return this.tidy("backward",(()=>{const e={};e[i.id]=null==n?ones(i.shape):n,backpropagateGradients(e,a,(e=>this.tidy(e)),add$1);const r=t.map((t=>e[t.id]));return 0===this.state.gradientDepth&&(this.state.activeTape.forEach((e=>{for(const t of e.saved)t.dispose()})),this.state.activeTape=null),{value:i,grads:r}}))}customGrad(e){return assert$1(isFunction(e),(()=>"The f passed in customGrad(f) must be a function.")),(...t)=>{let n;assert$1(t.every((e=>e instanceof Tensor)),(()=>"The args passed in customGrad(f)(x1, x2,...) must all be tensors"));const r={};t.forEach(((e,t)=>{r[t]=e}));return this.runKernelFunc({forwardFunc:(r,i)=>(n=e(...t,i),assert$1(n.value instanceof Tensor,(()=>"The function f passed in customGrad(f) must return an object where `obj.value` is a tensor")),assert$1(isFunction(n.gradFunc),(()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function.")),n.value),backwardsFunc:(e,r)=>{const i=n.gradFunc(e,r),a=Array.isArray(i)?i:[i];assert$1(a.length===t.length,(()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns the same number of tensors as inputs passed to f(...).")),assert$1(a.every((e=>e instanceof Tensor)),(()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns a list of only tensors."));const o={};return a.forEach(((e,t)=>{o[t]=()=>e})),o},inputs:r})}}readSync(e){return this.state.tensorInfo.get(e).backend.readSync(e)}read(e){return this.state.tensorInfo.get(e).backend.read(e)}async time(e){const t=now(),n=await this.backend.time(e);return n.wallMs=now()-t,n}track(e){return null!=this.state.activeScope&&(e.scopeId=this.state.activeScope.id,this.state.activeScope.track.push(e)),e}get registeredVariables(){return this.state.registeredVariables}reset(){this.pendingBackendInitId++,this.state.dispose(),this.ENV.reset(),this.state=new EngineState;for(const e in this.registry)this.disposeRegisteredKernels(e),this.registry[e].dispose(),delete this.registry[e];this.backendName=null,this.backendInstance=null,this.pendingBackendInit=null}}function ones(e){const t=makeOnesTypedArray(sizeFromShape(e),"float32");return ENGINE.makeTensor(t,e,"float32")}function getOrMakeEngine(){const e=getGlobalNamespace();if(null==e._tfengine){const t=new Environment(e);e._tfengine=new Engine(t)}return setEnvironmentGlobal(e._tfengine.ENV),setTensorTracker((()=>e._tfengine)),e._tfengine}Engine.nextTensorId=0,Engine.nextVariableId=0;const ENGINE=getOrMakeEngine();function add$1(e,t){return ENGINE.runKernel(Add,{a:e,b:t})}
/**
     * @license
     * Copyright 2017 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function _isNavigatorDefined(){return"undefined"!=typeof navigator&&null!=navigator}function isMobile(e){if(e||_isNavigatorDefined()){if(e||(e=navigator),"ReactNative"===e.product)return!0;const t=e.userAgent||e.vendor||window.opera;return/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(t)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(t.substr(0,4))}return!1}function isBrowser(){return"undefined"!=typeof window&&null!=window.document||"undefined"!=typeof WorkerGlobalScope}
/**
     * @license
     * Copyright 2019 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */const ENV$1=env();
/**
     * @license
     * Copyright 2018 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
function inferShape(e,t){let n=e;if(isTypedArray(e))return"string"===t?[]:[e.length];if(!Array.isArray(e))return[];const r=[];for(;Array.isArray(n)||isTypedArray(n)&&"string"!==t;)r.push(n.length),n=n[0];return Array.isArray(e)&&env().getBool("TENSORLIKE_CHECK_SHAPE_CONSISTENCY")&&deepAssertShapeConsistency(e,r,[]),r}function deepAssertShapeConsistency(e,t,n){if(n=n||[],!Array.isArray(e)&&!isTypedArray(e))return void assert$1(0===t.length,(()=>`Element arr[${n.join("][")}] is a primitive, but should be an array/TypedArray of ${t[0]} elements`));assert$1(t.length>0,(()=>`Element arr[${n.join("][")}] should be a primitive, but is an array of ${e.length} elements`)),assert$1(e.length===t[0],(()=>`Element arr[${n.join("][")}] should have ${t[0]} elements, but has ${e.length} elements`));const r=t.slice(1);for(let t=0;t<e.length;++t)deepAssertShapeConsistency(e[t],r,n.concat(t))}function assertDtype(e,t,n,r){if("string_or_numeric"!==e){if(null==e)throw new Error("Expected dtype cannot be null.");if("numeric"!==e&&e!==t||"numeric"===e&&"string"===t)throw new Error(`Argument '${n}' passed to '${r}' must be ${e} tensor, but got ${t} tensor`)}}function convertToTensor(e,t,n,r="numeric"){if(e instanceof Tensor)return assertDtype(r,e.dtype,t,n),e;let i=inferDtype(e);if("string"!==i&&["bool","int32","float32"].indexOf(r)>=0&&(i=r),assertDtype(r,i,t,n),null==e||!isTypedArray(e)&&!Array.isArray(e)&&"number"!=typeof e&&"boolean"!=typeof e&&"string"!=typeof e){throw new Error(`Argument '${t}' passed to '${n}' must be a Tensor or TensorLike, but got '${null==e?"null":e.constructor.name}'`)}const a=inferShape(e,i);isTypedArray(e)||Array.isArray(e)||(e=[e]);const o="string"!==i?toTypedArray$1(e,i):flatten$1(e,[],!0);return ENGINE.makeTensor(o,a,i)}
/**
     * @license
     * Copyright 2018 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */ENV$1.registerFlag("DEBUG",(()=>!1),(e=>{e&&console.warn("Debugging mode is ON. The output of every math call will be downloaded to CPU and checked for NaNs. This significantly impacts performance.")})),ENV$1.registerFlag("IS_BROWSER",(()=>isBrowser())),ENV$1.registerFlag("IS_NODE",(()=>"undefined"!=typeof process&&void 0!==process.versions&&void 0!==process.versions.node)),ENV$1.registerFlag("IS_CHROME",(()=>"undefined"!=typeof navigator&&null!=navigator&&null!=navigator.userAgent&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor))),ENV$1.registerFlag("PROD",(()=>!1)),ENV$1.registerFlag("TENSORLIKE_CHECK_SHAPE_CONSISTENCY",(()=>ENV$1.getBool("DEBUG"))),ENV$1.registerFlag("DEPRECATION_WARNINGS_ENABLED",(()=>!0)),ENV$1.registerFlag("IS_TEST",(()=>!1)),ENV$1.registerFlag("CHECK_COMPUTATION_FOR_ERRORS",(()=>!0)),ENV$1.registerFlag("WRAP_TO_IMAGEBITMAP",(()=>!1));const OP_SCOPE_SUFFIX="__op";function op(e){const t=Object.keys(e);if(1!==t.length)throw new Error(`Please provide an object with a single key (operation name) mapping to a function. Got an object with ${t.length} keys.`);let n=t[0];const r=e[n];n.endsWith("_")&&(n=n.substring(0,n.length-1)),n+=OP_SCOPE_SUFFIX;const i=(...e)=>{ENGINE.startScope(n);try{const t=r(...e);return isPromise(t)&&console.error("Cannot return a Promise inside of tidy."),ENGINE.endScope(t),t}catch(e){throw ENGINE.endScope(null),e}};return Object.defineProperty(i,"name",{value:n,configurable:!0}),i}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function complex_(e,t){const n=convertToTensor(e,"real","complex"),r=convertToTensor(t,"imag","complex");assertShapesMatch(n.shape,r.shape,`real and imag shapes, ${n.shape} and ${r.shape}, must match in call to tf.complex().`);return ENGINE.runKernel(Complex,{real:n,imag:r})}const complex$2=op({complex_:complex_});
/**
     * @license
     * Copyright 2018 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function makeTensor(e,t,n,r){if(null==r&&(r=inferDtype(e)),"complex64"===r)throw new Error("Cannot construct a complex64 tensor directly. Please use tf.complex(real, imag).");if(!isTypedArray(e)&&!Array.isArray(e)&&"number"!=typeof e&&"boolean"!=typeof e&&"string"!=typeof e)throw new Error("values passed to tensor(values) must be a number/boolean/string or an array of numbers/booleans/strings, or a TypedArray");if(null!=t){assertNonNegativeIntegerDimensions(t);const e=sizeFromShape(t),r=sizeFromShape(n);assert$1(e===r,(()=>`Based on the provided shape, [${t}], the tensor should have ${e} values but has ${r}`));for(let e=0;e<n.length;++e){const r=n[e],i=e!==n.length-1||r!==sizeFromShape(t.slice(e));assert$1(n[e]===t[e]||!i,(()=>`Error creating a new Tensor. Inferred shape (${n}) does not match the provided shape (${t}). `))}}return isTypedArray(e)||Array.isArray(e)||(e=[e]),t=t||n,e="string"!==r?toTypedArray$1(e,r):flatten$1(e,[],!0),ENGINE.makeTensor(e,t,r)}
/**
     * @license
     * Copyright 2018 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function tensor(e,t,n){return makeTensor(e,t,inferShape(e,n),n)}
/**
     * @license
     * Copyright 2018 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */const useNodeBuffer="undefined"!=typeof Buffer&&("undefined"==typeof Blob||"undefined"==typeof atob||"undefined"==typeof btoa);function stringByteLength(e){return useNodeBuffer?Buffer.byteLength(e):new Blob([e]).size}function arrayBufferToBase64String(e){if(useNodeBuffer)return Buffer.from(e).toString("base64");const t=new Uint8Array(e);let n="";for(let e=0,r=t.length;e<r;e++)n+=String.fromCharCode(t[e]);return btoa(n)}function base64StringToArrayBuffer(e){if(useNodeBuffer){const t=Buffer.from(e,"base64");return t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength)}const t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;++e)n.set([t.charCodeAt(e)],e);return n.buffer}function getModelArtifactsInfoForJSON(e){if(e.modelTopology instanceof ArrayBuffer)throw new Error("Expected JSON model topology, received ArrayBuffer.");return{dateSaved:new Date,modelTopologyType:"JSON",modelTopologyBytes:null==e.modelTopology?0:stringByteLength(JSON.stringify(e.modelTopology)),weightSpecsBytes:null==e.weightSpecs?0:stringByteLength(JSON.stringify(e.weightSpecs)),weightDataBytes:null==e.weightData?0:e.weightData.byteLength}}
/**
     * @license
     * Copyright 2018 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */class IORouterRegistry{constructor(){this.saveRouters=[],this.loadRouters=[]}static getInstance(){return null==IORouterRegistry.instance&&(IORouterRegistry.instance=new IORouterRegistry),IORouterRegistry.instance}static registerSaveRouter(e){IORouterRegistry.getInstance().saveRouters.push(e)}static registerLoadRouter(e){IORouterRegistry.getInstance().loadRouters.push(e)}static getSaveHandlers(e){return IORouterRegistry.getHandlers(e,"save")}static getLoadHandlers(e,t){return IORouterRegistry.getHandlers(e,"load",t)}static getHandlers(e,t,n){const r=[];return("load"===t?IORouterRegistry.getInstance().loadRouters:IORouterRegistry.getInstance().saveRouters).forEach((t=>{const i=t(e,n);null!==i&&r.push(i)})),r}}
/**
     * @license
     * Copyright 2018 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */const DATABASE_NAME="tensorflowjs",DATABASE_VERSION=1,MODEL_STORE_NAME="models_store",INFO_STORE_NAME="model_info_store";function getIndexedDBFactory(){if(!env().getBool("IS_BROWSER"))throw new Error("Failed to obtain IndexedDB factory because the current environmentis not a web browser.");const e="undefined"==typeof window?self:window,t=e.indexedDB||e.mozIndexedDB||e.webkitIndexedDB||e.msIndexedDB||e.shimIndexedDB;if(null==t)throw new Error("The current browser does not appear to support IndexedDB.");return t}function setUpDatabase(e){const t=e.result;t.createObjectStore(MODEL_STORE_NAME,{keyPath:"modelPath"}),t.createObjectStore(INFO_STORE_NAME,{keyPath:"modelPath"})}class BrowserIndexedDB{constructor(e){if(this.indexedDB=getIndexedDBFactory(),null==e||!e)throw new Error("For IndexedDB, modelPath must not be null, undefined or empty.");this.modelPath=e}async save(e){if(e.modelTopology instanceof ArrayBuffer)throw new Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet.");return this.databaseAction(this.modelPath,e)}async load(){return this.databaseAction(this.modelPath)}databaseAction(e,t){return new Promise(((e,n)=>{const r=this.indexedDB.open(DATABASE_NAME,DATABASE_VERSION);r.onupgradeneeded=()=>setUpDatabase(r),r.onsuccess=()=>{const i=r.result;if(null==t){const t=i.transaction(MODEL_STORE_NAME,"readonly"),r=t.objectStore(MODEL_STORE_NAME).get(this.modelPath);r.onsuccess=()=>{if(null==r.result)return i.close(),n(new Error(`Cannot find model with path '${this.modelPath}' in IndexedDB.`));e(r.result.modelArtifacts)},r.onerror=e=>(i.close(),n(r.error)),t.oncomplete=()=>i.close()}else{const r=getModelArtifactsInfoForJSON(t),a=i.transaction(INFO_STORE_NAME,"readwrite");let o=a.objectStore(INFO_STORE_NAME);const s=o.put({modelPath:this.modelPath,modelArtifactsInfo:r});let l;s.onsuccess=()=>{l=i.transaction(MODEL_STORE_NAME,"readwrite");const s=l.objectStore(MODEL_STORE_NAME).put({modelPath:this.modelPath,modelArtifacts:t,modelArtifactsInfo:r});s.onsuccess=()=>e({modelArtifactsInfo:r}),s.onerror=e=>{o=a.objectStore(INFO_STORE_NAME);const t=o.delete(this.modelPath);t.onsuccess=()=>(i.close(),n(s.error)),t.onerror=e=>(i.close(),n(s.error))}},s.onerror=e=>(i.close(),n(s.error)),a.oncomplete=()=>{null==l?i.close():l.oncomplete=()=>i.close()}}},r.onerror=e=>n(r.error)}))}}BrowserIndexedDB.URL_SCHEME="indexeddb://";const indexedDBRouter=e=>env().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(BrowserIndexedDB.URL_SCHEME)?browserIndexedDB(e.slice(BrowserIndexedDB.URL_SCHEME.length)):null;function browserIndexedDB(e){return new BrowserIndexedDB(e)}function maybeStripScheme$1(e){return e.startsWith(BrowserIndexedDB.URL_SCHEME)?e.slice(BrowserIndexedDB.URL_SCHEME.length):e}IORouterRegistry.registerSaveRouter(indexedDBRouter),IORouterRegistry.registerLoadRouter(indexedDBRouter);class BrowserIndexedDBManager{constructor(){this.indexedDB=getIndexedDBFactory()}async listModels(){return new Promise(((e,t)=>{const n=this.indexedDB.open(DATABASE_NAME,DATABASE_VERSION);n.onupgradeneeded=()=>setUpDatabase(n),n.onsuccess=()=>{const r=n.result,i=r.transaction(INFO_STORE_NAME,"readonly"),a=i.objectStore(INFO_STORE_NAME).getAll();a.onsuccess=()=>{const t={};for(const e of a.result)t[e.modelPath]=e.modelArtifactsInfo;e(t)},a.onerror=e=>(r.close(),t(a.error)),i.oncomplete=()=>r.close()},n.onerror=e=>t(n.error)}))}async removeModel(e){return e=maybeStripScheme$1(e),new Promise(((t,n)=>{const r=this.indexedDB.open(DATABASE_NAME,DATABASE_VERSION);r.onupgradeneeded=()=>setUpDatabase(r),r.onsuccess=()=>{const i=r.result,a=i.transaction(INFO_STORE_NAME,"readwrite"),o=a.objectStore(INFO_STORE_NAME),s=o.get(e);let l;s.onsuccess=()=>{if(null==s.result)return i.close(),n(new Error(`Cannot find model with path '${e}' in IndexedDB.`));{const r=o.delete(e),a=()=>{l=i.transaction(MODEL_STORE_NAME,"readwrite");const r=l.objectStore(MODEL_STORE_NAME).delete(e);r.onsuccess=()=>t(s.result.modelArtifactsInfo),r.onerror=e=>n(s.error)};r.onsuccess=a,r.onerror=e=>(a(),i.close(),n(s.error))}},s.onerror=e=>(i.close(),n(s.error)),a.oncomplete=()=>{null==l?i.close():l.oncomplete=()=>i.close()}},r.onerror=e=>n(r.error)}))}}
/**
     * @license
     * Copyright 2018 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */const PATH_SEPARATOR="/",PATH_PREFIX="tensorflowjs_models",INFO_SUFFIX="info",MODEL_TOPOLOGY_SUFFIX="model_topology",WEIGHT_SPECS_SUFFIX="weight_specs",WEIGHT_DATA_SUFFIX="weight_data",MODEL_METADATA_SUFFIX="model_metadata";function getModelKeys(e){return{info:[PATH_PREFIX,e,INFO_SUFFIX].join(PATH_SEPARATOR),topology:[PATH_PREFIX,e,MODEL_TOPOLOGY_SUFFIX].join(PATH_SEPARATOR),weightSpecs:[PATH_PREFIX,e,WEIGHT_SPECS_SUFFIX].join(PATH_SEPARATOR),weightData:[PATH_PREFIX,e,WEIGHT_DATA_SUFFIX].join(PATH_SEPARATOR),modelMetadata:[PATH_PREFIX,e,MODEL_METADATA_SUFFIX].join(PATH_SEPARATOR)}}function getModelPathFromKey(e){const t=e.split(PATH_SEPARATOR);if(t.length<3)throw new Error(`Invalid key format: ${e}`);return t.slice(1,t.length-1).join(PATH_SEPARATOR)}function maybeStripScheme(e){return e.startsWith(BrowserLocalStorage.URL_SCHEME)?e.slice(BrowserLocalStorage.URL_SCHEME.length):e}class BrowserLocalStorage{constructor(e){if(!env().getBool("IS_BROWSER")||"undefined"==typeof window||void 0===window.localStorage)throw new Error("The current environment does not support local storage.");if(this.LS=window.localStorage,null==e||!e)throw new Error("For local storage, modelPath must not be null, undefined or empty.");this.modelPath=e,this.keys=getModelKeys(this.modelPath)}async save(e){if(e.modelTopology instanceof ArrayBuffer)throw new Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet.");{const t=JSON.stringify(e.modelTopology),n=JSON.stringify(e.weightSpecs),r=getModelArtifactsInfoForJSON(e);try{this.LS.setItem(this.keys.info,JSON.stringify(r)),this.LS.setItem(this.keys.topology,t),this.LS.setItem(this.keys.weightSpecs,n),this.LS.setItem(this.keys.weightData,arrayBufferToBase64String(e.weightData));const i={format:e.format,generatedBy:e.generatedBy,convertedBy:e.convertedBy};return null!=e.signature&&(i.signature=e.signature),null!=e.userDefinedMetadata&&(i.userDefinedMetadata=e.userDefinedMetadata),null!=e.modelInitializer&&(i.modelInitializer=e.modelInitializer),this.LS.setItem(this.keys.modelMetadata,JSON.stringify(i)),{modelArtifactsInfo:r}}catch(e){throw this.LS.removeItem(this.keys.info),this.LS.removeItem(this.keys.topology),this.LS.removeItem(this.keys.weightSpecs),this.LS.removeItem(this.keys.weightData),this.LS.removeItem(this.keys.modelMetadata),new Error(`Failed to save model '${this.modelPath}' to local storage: size quota being exceeded is a possible cause of this failure: modelTopologyBytes=${r.modelTopologyBytes}, weightSpecsBytes=${r.weightSpecsBytes}, weightDataBytes=${r.weightDataBytes}.`)}}}async load(){const e=JSON.parse(this.LS.getItem(this.keys.info));if(null==e)throw new Error(`In local storage, there is no model with name '${this.modelPath}'`);if("JSON"!==e.modelTopologyType)throw new Error("BrowserLocalStorage does not support loading non-JSON model topology yet.");const t={},n=JSON.parse(this.LS.getItem(this.keys.topology));if(null==n)throw new Error(`In local storage, the topology of model '${this.modelPath}' is missing.`);t.modelTopology=n;const r=JSON.parse(this.LS.getItem(this.keys.weightSpecs));if(null==r)throw new Error(`In local storage, the weight specs of model '${this.modelPath}' are missing.`);t.weightSpecs=r;const i=this.LS.getItem(this.keys.modelMetadata);if(null!=i){const e=JSON.parse(i);t.format=e.format,t.generatedBy=e.generatedBy,t.convertedBy=e.convertedBy,null!=e.signature&&(t.signature=e.signature),null!=e.userDefinedMetadata&&(t.userDefinedMetadata=e.userDefinedMetadata),null!=e.modelInitializer&&(t.modelInitializer=e.modelInitializer)}const a=this.LS.getItem(this.keys.weightData);if(null==a)throw new Error(`In local storage, the binary weight values of model '${this.modelPath}' are missing.`);return t.weightData=base64StringToArrayBuffer(a),t}}BrowserLocalStorage.URL_SCHEME="localstorage://";const localStorageRouter=e=>env().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(BrowserLocalStorage.URL_SCHEME)?browserLocalStorage(e.slice(BrowserLocalStorage.URL_SCHEME.length)):null;function browserLocalStorage(e){return new BrowserLocalStorage(e)}IORouterRegistry.registerSaveRouter(localStorageRouter),IORouterRegistry.registerLoadRouter(localStorageRouter);class BrowserLocalStorageManager{constructor(){assert$1(env().getBool("IS_BROWSER"),(()=>"Current environment is not a web browser")),assert$1("undefined"==typeof window||void 0!==window.localStorage,(()=>"Current browser does not appear to support localStorage")),this.LS=window.localStorage}async listModels(){const e={},t=PATH_PREFIX+PATH_SEPARATOR,n=PATH_SEPARATOR+INFO_SUFFIX;for(let r=0;r<this.LS.length;++r){const i=this.LS.key(r);if(i.startsWith(t)&&i.endsWith(n)){e[getModelPathFromKey(i)]=JSON.parse(this.LS.getItem(i))}}return e}async removeModel(e){const t=getModelKeys(e=maybeStripScheme(e));if(null==this.LS.getItem(t.info))throw new Error(`Cannot find model at path '${e}'`);const n=JSON.parse(this.LS.getItem(t.info));return this.LS.removeItem(t.info),this.LS.removeItem(t.topology),this.LS.removeItem(t.weightSpecs),this.LS.removeItem(t.weightData),n}}
/**
     * @license
     * Copyright 2018 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */const URL_SCHEME_SUFFIX="://";class ModelStoreManagerRegistry{constructor(){this.managers={}}static getInstance(){return null==ModelStoreManagerRegistry.instance&&(ModelStoreManagerRegistry.instance=new ModelStoreManagerRegistry),ModelStoreManagerRegistry.instance}static registerManager(e,t){assert$1(null!=e,(()=>"scheme must not be undefined or null.")),e.endsWith(URL_SCHEME_SUFFIX)&&(e=e.slice(0,e.indexOf(URL_SCHEME_SUFFIX))),assert$1(e.length>0,(()=>"scheme must not be an empty string."));const n=ModelStoreManagerRegistry.getInstance();assert$1(null==n.managers[e],(()=>`A model store manager is already registered for scheme '${e}'.`)),n.managers[e]=t}static getManager(e){const t=this.getInstance().managers[e];if(null==t)throw new Error(`Cannot find model manager for scheme '${e}'`);return t}static getSchemes(){return Object.keys(this.getInstance().managers)}}
/**
     * @license
     * Copyright 2019 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */class PlatformBrowser{fetch(e,t){return fetch(e,t)}now(){return performance.now()}encode(e,t){if("utf-8"!==t&&"utf8"!==t)throw new Error(`Browser's encoder only supports utf-8, but got ${t}`);return null==this.textEncoder&&(this.textEncoder=new TextEncoder),this.textEncoder.encode(e)}decode(e,t){return new TextDecoder(t).decode(e)}}if(env().get("IS_BROWSER")){env().setPlatform("browser",new PlatformBrowser);try{ModelStoreManagerRegistry.registerManager(BrowserLocalStorage.URL_SCHEME,new BrowserLocalStorageManager)}catch(e){}try{ModelStoreManagerRegistry.registerManager(BrowserIndexedDB.URL_SCHEME,new BrowserIndexedDBManager)}catch(e){}}
/**
     * @license
     * Copyright 2019 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */const getNodeFetch={importFetch:()=>require("node-fetch")};let systemFetch;class PlatformNode{constructor(){this.util=require("util"),this.textEncoder=new this.util.TextEncoder}fetch(e,t){return null!=env().global.fetch?env().global.fetch(e,t):(null==systemFetch&&(systemFetch=getNodeFetch.importFetch()),systemFetch(e,t))}now(){const e=process.hrtime();return 1e3*e[0]+e[1]/1e6}encode(e,t){if("utf-8"!==t&&"utf8"!==t)throw new Error(`Node built-in encoder only supports utf-8, but got ${t}`);return this.textEncoder.encode(e)}decode(e,t){return 0===e.length?"":new this.util.TextDecoder(t).decode(e)}}
/**
     * @license
     * Copyright 2020 Google Inc. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
function buffer(e,t="float32",n){return t=t||"float32",assertNonNegativeIntegerDimensions(e),new TensorBuffer(e,t,n)}
/**
     * @license
     * Copyright 2020 Google Inc. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function cast_(e,t){const n=convertToTensor(e,"x","cast");if(!isValidDtype(t))throw new Error(`Failed to cast to unknown dtype ${t}`);if("string"===t&&"string"!==n.dtype||"string"!==t&&"string"===n.dtype)throw new Error("Only strings can be casted to strings");return ENGINE.runKernel(Cast,{x:n},{dtype:t})}env().get("IS_NODE")&&env().setPlatform("node",new PlatformNode);const cast$2=op({cast_:cast_});
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function clone_(e){const t=convertToTensor(e,"x","clone","string_or_numeric");return ENGINE.runKernel(Identity,{x:t})}const clone=op({clone_:clone_});
/**
     * @license
     * Copyright 2020 Google Inc. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function print(e,t=!1){console.log(e.toString(t))}
/**
     * @license
     * Copyright 2020 Google Inc. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */getOrMakeEngine();const opHandler={buffer:buffer,cast:cast$2,clone:clone,print:print};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
function matMul_(e,t,n=!1,r=!1){let i=convertToTensor(e,"a","matMul"),a=convertToTensor(t,"b","matMul");[i,a]=makeTypesMatch(i,a);return ENGINE.runKernel(BatchMatMul,{a:i,b:a},{transposeA:n,transposeB:r})}setOpHandler(opHandler);const matMul=op({matMul_:matMul_});
/**
     * @license
     * Copyright 2018 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function transpose_(e,t){const n=convertToTensor(e,"x","transpose");if(null==t&&(t=n.shape.map(((e,t)=>t)).reverse()),assert$1(n.rank===t.length,(()=>`Error in transpose: rank of input ${n.rank} must match length of perm ${t}.`)),t.forEach((e=>{assert$1(e>=0&&e<n.rank,(()=>"All entries in 'perm' must be between 0 and "+(n.rank-1)+` but got ${t}`))})),n.rank<=1)return n.clone();return ENGINE.runKernel(Transpose,{x:n},{perm:t})}const transpose$2=op({transpose_:transpose_});function prepareAndValidate(e,t){const n=e.shape.length,r=t.shape.length;if(n<1)throw new Error(`tf.gatherND() expects the input to be rank 1 or higher, but the rank was ${n}.`);if(r<1)throw new Error(`tf.gatherND() expects the indices to be rank 1 or higher, but the rank was ${r}.`);if("int32"!==t.dtype)throw new Error(`tf.gatherND() expects the indices to be int32 type, but the dtype was ${t.dtype}.`);if(t.shape[r-1]>n)throw new Error(`index innermost dimension length must be <= tensor rank; saw: ${t.shape[r-1]} vs. ${n}`);if(0===sizeFromShape(e.shape))throw new Error(`Requested more than 0 entries, but input is empty. Input shape: ${e.shape}.`);const i=t.shape,a=i[i.length-1];let o=1;for(let e=0;e<i.length-1;++e)o*=i[e];const s=e.shape,l=i.slice();l.pop();let c=1;for(let e=a;e<n;++e)c*=s[e],l.push(s[e]);const h=[...computeStrides(e.shape).map((e=>e/c)),1].slice(0,a);return[l,o,c,h]}function validateUpdateShape(e,t,n){const r=t.rank>1?t.shape[t.rank-1]:1,i=t.rank>1?t.rank-1:1,a=`Must have updates.shape = indices.shape[:batchDim] + shape[sliceDim:], got updates.shape: ${n.shape}, indices.shape: ${t.shape}, shape: ${e}, sliceDim: ${r}, and batchDim: ${i}.`;if(n.rank<i)throw new Error(a+` update.rank < ${i}. `);if(e.length<r+(n.rank-i))throw new Error(a+` Output shape length < ${r+(n.rank-i)}`);if(n.rank!==i+e.length-r)throw new Error(a+" update.rank != "+(i+e.length-r));for(let e=0;e<i;++e)if(n.shape[e]!==t.shape[e])throw new Error(a+` updates.shape[${e}] (${n.shape[e]}) != indices.shape[${e}] (${t.shape[e]}).`);for(let t=0;t<n.rank-i;++t)if(n.shape[t+i]!==e[t+r])throw new Error(a+` updates.shape[${t+i}] (${n.shape[t+i]}) != shape[${t+i}] (${e[t+i]})`)}function validateInput(e,t,n){if(t.rank<1)throw new Error(`tf.scatterND() expects the indices to be rank 1 or higher, but the rank was ${t.rank}.`);if(e.rank<1)throw new Error(`tf.scatterND() expects the updates to be rank 1 or higher, but the rank was ${e.rank}.`);if("int32"!==t.dtype)throw new Error(`The dtype of 'indices' should be int32, but got dtype: ${t.dtype}`);if(n.length<1)throw new Error(`Output rank must be greater or equal to 1, but got shape: ${n}`);if(0===n.length){if(0===t.size)throw new Error(`Indices specified for empty output. indices shape: ${t.shape}`);if(0===e.size)throw new Error(`Updates specified for empty output. updates shape: ${e.shape}`)}validateUpdateShape(n,t,e)}function calculateShapes(e,t,n){const r=t.shape.length,i=r>1?t.shape[r-1]:1,a=n.length;let o=1;for(let e=i;e<a;++e)o*=n[e];const s=i<1?1:i;return{sliceRank:i,numUpdates:sizeFromShape(t.shape)/s,sliceSize:o,strides:[...computeStrides(n.slice(0,i)),1],outputSize:sizeFromShape(n)}}
/**
     * @license
     * Copyright 2017 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function assertParamsValid(e,t,n){const r=e.shape.length;assert$1(r===t.length,(()=>`Error in slice${r}D: Length of begin ${t} must match the rank of the array (${r}).`)),assert$1(r===n.length,(()=>`Error in slice${r}D: Length of size ${n} must match the rank of the array (${r}).`));for(let i=0;i<r;++i)assert$1(t[i]+n[i]<=e.shape[i],(()=>`Error in slice${r}D: begin[${i}] + size[${i}] (${t[i]+n[i]}) would overflow input.shape[${i}] (${e.shape[i]})`))}function maskToAxes(e){const t=[];let n=0;for(;e>0;)1&e&&t.push(n),e/=2,n++;return t}function computeOutShape$2(e,t,n){const r=[];for(let i=0;i<e.length;i++)r[i]=Math.ceil((t[i]-e[i])/n[i]);return r}function stridesWithElidedDims(e,t,n,r){const i=[...e];for(let e=i.length;e<r.length;e++)i.push(1);for(let e=0;e<n;e++)0===e?i[t]=1:(i.splice(t,0,1),i.pop());return i}function unnormalizeAxis(e,t,n){return n<=e?n:n-(t-1)}function getElidedAxes(e,t){const n=[];for(let r=0;r<e;r++)n.push(t+r);return n}function getNormalizedAxes(e,t,n,r,i,a,o,s,l){const c=e.length;let h=new Array(c),u=new Array(c),d=new Array(c);if(t.length&&n>0){const l=t[0],c=n+1;h=startIndicesWithElidedDims(o,l,c,r,e),u=stopIndicesWithElidedDims(s,l,c,i,e),d=stridesWithElidedDims(a,l,c,e)}else for(let t=0;t<c;t++)h[t]=startForAxis(o,r,a,e,t,l),u[t]=stopForAxis(s,i,a,e,t,l),d[t]=stridesForAxis(a,t,l);return{begin:h,end:u,strides:d}}function startIndicesWithElidedDims(e,t,n,r,i){const a=[...i],o=getElidedAxes(n,t);for(let i=0;i<a.length;i++)if(o.indexOf(i)>-1)a[i]=0;else{const o=unnormalizeAxis(t,n,i);let s=r[o];e&1<<o&&(s=0),a[i]=s}return a}function stopIndicesWithElidedDims(e,t,n,r,i){const a=[...i],o=getElidedAxes(n,t);for(let i=0;i<a.length;i++)if(o.indexOf(i)>-1)a[i]=Number.MAX_SAFE_INTEGER;else{const o=unnormalizeAxis(t,n,i);let s=r[o];e&1<<o&&(s=Number.MAX_SAFE_INTEGER),a[i]=s}for(let e=0;e<a.length;e++){const t=i[e];a[e]<0&&(a[e]+=t),a[e]=clamp$1(0,a[e],i[e])}return a}function stridesForAxis(e,t,n){let r=e[t];return(n&1<<t||null==r)&&(r=1),r}function startForAxis(e,t,n,r,i,a){let o=t[i];(e&1<<i||a&1<<i||null==o)&&(o=(n[i]||1)>0?Number.MIN_SAFE_INTEGER:Number.MAX_SAFE_INTEGER);const s=r[i];return o<0&&(o+=s),o=clamp$1(0,o,s-1),o}function stopForAxis(e,t,n,r,i,a){let o=t[i];const s=n[i]||1;(e&1<<i||a&1<<i||null==o)&&(o=s>0?Number.MAX_SAFE_INTEGER:Number.MIN_SAFE_INTEGER);const l=r[i];return o<0&&(o+=l),o=s>0?clamp$1(0,o,l):clamp$1(-1,o,l-1),o}function isSliceContinous(e,t,n){let r=n.length;for(let e=0;e<n.length;e++)if(n[e]>1){r=e;break}for(let i=r+1;i<n.length;i++)if(t[i]>0||n[i]!==e[i])return!1;return!0}function computeFlatOffset(e,t){let n=e.length>0?e[e.length-1]:1;for(let r=0;r<e.length-1;r++)n+=e[r]*t[r];return n}function parseSliceParams(e,t,n){let r;const i=e.shape.length;let a;return r="number"==typeof t?[t,...new Array(i-1).fill(0)]:t.length<i?t.concat(new Array(i-t.length).fill(0)):t.slice(),r.forEach((e=>{assert$1(-1!==e,(()=>"slice() does not support negative begin indexing."))})),a=null==n?new Array(i).fill(-1):"number"==typeof n?[n,...new Array(i-1).fill(-1)]:n.length<i?n.concat(new Array(i-n.length).fill(-1)):n,a=a.map(((t,n)=>t>=0?t:(assert$1(-1===t,(()=>`Negative size values should be exactly -1 but got ${t} for the slice() size at index ${n}.`)),e.shape[n]-r[n]))),[r,a]}function sliceInfo(e,t,n,r,i,a,o,s,l){let c=t.slice(),h=n.slice(),u=r;null==r&&(u=new Array(c.length));const d=maskToAxes(o);if(d.length>1)throw new Error("Multiple ellipses in slice is not allowed.");if(0!==o&&0!==s)throw new Error("Using both ellipsisMask and newAxisMask is not yet supported.");if(0!==o&&0!==l)throw new Error("Using both ellipsisMask and shrinkAxisMask is not yet supported.");const p=e.length-c.length,m=maskToAxes(s),f=e.slice();m.forEach((e=>{c[e]=0,h[e]=1,f.splice(e,0,1)}));const{begin:g,end:v,strides:y}=getNormalizedAxes(f,d,p,c,h,u,i,a,o);c=g,h=v,u=y;const _=maskToAxes(l);_.forEach((e=>{h[e]=c[e]+1,u[e]=1}));const b=computeOutShape$2(c,h,u),x=b.filter(((e,t)=>-1===_.indexOf(t)));return{nonStrided:u.every((e=>1===e)),$begin:c,$end:h,$strides:u,size:b,newShape:f,outShape:x}}var slice_util=Object.freeze({__proto__:null,assertParamsValid:assertParamsValid,maskToAxes:maskToAxes,computeOutShape:computeOutShape$2,stridesWithElidedDims:stridesWithElidedDims,getNormalizedAxes:getNormalizedAxes,startIndicesWithElidedDims:startIndicesWithElidedDims,stopIndicesWithElidedDims:stopIndicesWithElidedDims,stridesForAxis:stridesForAxis,startForAxis:startForAxis,stopForAxis:stopForAxis,isSliceContinous:isSliceContinous,computeFlatOffset:computeFlatOffset,parseSliceParams:parseSliceParams,sliceInfo:sliceInfo});
/**
     * @license
     * Copyright 2018 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function engine(){return ENGINE}function tidy(e,t){return ENGINE.tidy(e,t)}function ready(){return ENGINE.ready()}function getBackend(){return ENGINE.backendName}function registerBackend(e,t,n=1){return ENGINE.registerBackend(e,t,n)}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function mul_(e,t){let n=convertToTensor(e,"a","mul"),r=convertToTensor(t,"b","mul");[n,r]=makeTypesMatch(n,r);return ENGINE.runKernel(Multiply,{a:n,b:r})}const mul=op({mul_:mul_});
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function computeDilation2DInfo(e,t,n,r,i="NHWC",a){return computeConv2DInfo(e,[...t,e[3]],n,a,r,null,null,convertConv2DDataFormat(i))}function computePool2DInfo(e,t,n,r,i,a,o="channelsLast"){const[s,l]=parseTupleParam(t);let c;if("channelsLast"===o)c=[s,l,e[3],e[3]];else{if("channelsFirst"!==o)throw new Error(`Unknown dataFormat ${o}`);c=[s,l,e[1],e[1]]}return computeConv2DInfo(e,c,n,r,i,a,!1,o)}function computePool3DInfo(e,t,n,r,i,a,o="NDHWC"){const[s,l,c]=parse3TupleParam(t);let h,u;if("NDHWC"===o)u="channelsLast",h=[s,l,c,e[4],e[4]];else{if("NCDHW"!==o)throw new Error(`Unknown dataFormat ${o}`);u="channelsFirst",h=[s,l,c,e[1],e[1]]}return computeConv3DInfo(e,h,n,r,i,!1,u,a)}function computeConv2DInfo(e,t,n,r,i,a,o=!1,s="channelsLast"){let[l,c,h,u]=[-1,-1,-1,-1];if("channelsLast"===s)[l,c,h,u]=e;else{if("channelsFirst"!==s)throw new Error(`Unknown dataFormat ${s}`);[l,u,c,h]=e}const[d,p,,m]=t,[f,g]=parseTupleParam(n),[v,y]=parseTupleParam(r),_=getEffectiveFilterSize(d,v),b=getEffectiveFilterSize(p,y),{padInfo:x,outHeight:S,outWidth:w}=getPadAndOutInfo(i,c,h,f,g,_,b,a,s),C=o?m*u:m;let M;return"channelsFirst"===s?M=[l,C,S,w]:"channelsLast"===s&&(M=[l,S,w,C]),{batchSize:l,dataFormat:s,inHeight:c,inWidth:h,inChannels:u,outHeight:S,outWidth:w,outChannels:C,padInfo:x,strideHeight:f,strideWidth:g,filterHeight:d,filterWidth:p,effectiveFilterHeight:_,effectiveFilterWidth:b,dilationHeight:v,dilationWidth:y,inShape:e,outShape:M,filterShape:t}}function computeConv3DInfo(e,t,n,r,i,a=!1,o="channelsLast",s){let[l,c,h,u,d]=[-1,-1,-1,-1,-1];if("channelsLast"===o)[l,c,h,u,d]=e;else{if("channelsFirst"!==o)throw new Error(`Unknown dataFormat ${o}`);[l,d,c,h,u]=e}const[p,m,f,,g]=t,[v,y,_]=parse3TupleParam(n),[b,x,S]=parse3TupleParam(r),w=getEffectiveFilterSize(p,b),C=getEffectiveFilterSize(m,x),M=getEffectiveFilterSize(f,S),{padInfo:E,outDepth:T,outHeight:I,outWidth:A}=get3DPadAndOutInfo(i,c,h,u,v,y,_,w,C,M,s),k=a?g*d:g;let P;return"channelsFirst"===o?P=[l,k,T,I,A]:"channelsLast"===o&&(P=[l,T,I,A,k]),{batchSize:l,dataFormat:o,inDepth:c,inHeight:h,inWidth:u,inChannels:d,outDepth:T,outHeight:I,outWidth:A,outChannels:k,padInfo:E,strideDepth:v,strideHeight:y,strideWidth:_,filterDepth:p,filterHeight:m,filterWidth:f,effectiveFilterDepth:w,effectiveFilterHeight:C,effectiveFilterWidth:M,dilationDepth:b,dilationHeight:x,dilationWidth:S,inShape:e,outShape:P,filterShape:t}}function computeOutputShape2D(e,t,n,r,i){null==r&&(r=computeDefaultPad(e,t,n));const a=e[1];return[round$2((e[0]-t+2*r)/n+1,i),round$2((a-t+2*r)/n+1,i)]}function computeOutputShape4D(e,t,n,r,i,a){null==i&&(i=computeDefaultPad(e,t,r));const o=e[1],s=e[2];return[round$2((e[0]-t+2*i)/r+1,a),round$2((o-t+2*i)/r+1,a),round$2((s-t+2*i)/r+1,a),n]}function computeDefaultPad(e,t,n,r=1){const i=getEffectiveFilterSize(t,r);return Math.floor((e[0]*(n-1)-n+i)/2)}function parseTupleParam(e){return"number"==typeof e?[e,e,e]:2===e.length?[e[0],e[1],1]:e}function parse3TupleParam(e){return"number"==typeof e?[e,e,e]:e}function getEffectiveFilterSize(e,t){return t<=1?e:e+(e-1)*(t-1)}function getPadAndOutInfo(e,t,n,r,i,a,o,s,l){let c,h,u;if("number"==typeof e){c={top:e,bottom:e,left:e,right:e,type:0===e?"VALID":"NUMBER"};const i=computeOutputShape2D([t,n],a,r,e,s);h=i[0],u=i[1]}else if("same"===e){h=Math.ceil(t/r),u=Math.ceil(n/i);const e=Math.max(0,(h-1)*r+a-t),s=Math.max(0,(u-1)*i+o-n),l=Math.floor(e/2),d=e-l,p=Math.floor(s/2);c={top:l,bottom:d,left:p,right:s-p,type:"SAME"}}else if("valid"===e)c={top:0,bottom:0,left:0,right:0,type:"VALID"},h=Math.ceil((t-a+1)/r),u=Math.ceil((n-o+1)/i);else{if("object"!=typeof e)throw Error(`Unknown padding parameter: ${e}`);{const d="channelsLast"===l?e[1][0]:e[2][0],p="channelsLast"===l?e[1][1]:e[2][1],m="channelsLast"===l?e[2][0]:e[3][0],f="channelsLast"===l?e[2][1]:e[3][1];c={top:d,bottom:p,left:m,right:f,type:0===d&&0===p&&0===m&&0===f?"VALID":"EXPLICIT"},h=round$2((t-a+d+p)/r+1,s),u=round$2((n-o+m+f)/i+1,s)}}return{padInfo:c,outHeight:h,outWidth:u}}function get3DPadAndOutInfo(e,t,n,r,i,a,o,s,l,c,h){let u,d,p,m;if("number"==typeof e){u={top:e,bottom:e,left:e,right:e,front:e,back:e,type:0===e?"VALID":"NUMBER"};const a=computeOutputShape4D([t,n,r,1],s,1,i,e,h);d=a[0],p=a[1],m=a[2]}else if("same"===e){d=Math.ceil(t/i),p=Math.ceil(n/a),m=Math.ceil(r/o);const e=(d-1)*i+s-t,h=(p-1)*a+l-n,f=(m-1)*o+c-r,g=Math.floor(e/2),v=e-g,y=Math.floor(h/2),_=h-y,b=Math.floor(f/2);u={top:y,bottom:_,left:b,right:f-b,front:g,back:v,type:"SAME"}}else{if("valid"!==e)throw Error(`Unknown padding parameter: ${e}`);u={top:0,bottom:0,left:0,right:0,front:0,back:0,type:"VALID"},d=Math.ceil((t-s+1)/i),p=Math.ceil((n-l+1)/a),m=Math.ceil((r-c+1)/o)}return{padInfo:u,outDepth:d,outHeight:p,outWidth:m}}function round$2(e,t){if(!t)return Math.trunc(e);switch(t){case"round":return Math.round(e);case"ceil":return Math.ceil(e);case"floor":return Math.floor(e);default:throw new Error(`Unknown roundingMode ${t}`)}}function tupleValuesAreOne(e){const[t,n,r]=parseTupleParam(e);return 1===t&&1===n&&1===r}function eitherStridesOrDilationsAreOne(e,t){return tupleValuesAreOne(e)||tupleValuesAreOne(t)}function convertConv2DDataFormat(e){if("NHWC"===e)return"channelsLast";if("NCHW"===e)return"channelsFirst";throw new Error(`Unknown dataFormat ${e}`)}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function reshape_(e,t){const n=convertToTensor(e,"x","reshape","string_or_numeric");return ENGINE.runKernel(Reshape,{x:n},{shape:t})}const reshape$2=op({reshape_:reshape_});
/**
     * @license
     * Copyright 2017 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function getBroadcastDims$1(e,t){const n=e.length,r=[];for(let i=0;i<n;i++){const a=n-1-i,o=e[a]||1;(t[t.length-1-i]||1)>1&&1===o&&r.unshift(a)}return r}function getReductionAxes(e,t){const n=[];for(let r=0;r<t.length;r++){const i=e[e.length-r-1],a=t.length-r-1,o=t[a];(null==i||1===i&&o>1)&&n.unshift(a)}return n}function assertAndGetBroadcastShape(e,t){const n=[],r=Math.max(e.length,t.length);for(let i=0;i<r;i++){let r=e[e.length-i-1];null==r&&(r=1);let a=t[t.length-i-1];if(null==a&&(a=1),1===r)n.unshift(a);else if(1===a)n.unshift(r);else{if(r!==a){throw Error(`Operands could not be broadcast together with shapes ${e} and ${t}.`)}n.unshift(r)}}return n}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function elu_(e){const t=convertToTensor(e,"x","elu");return ENGINE.runKernel(Elu,{x:t})}const elu$2=op({elu_:elu_});
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function leakyRelu_(e,t=.2){const n=convertToTensor(e,"x","leakyRelu");return ENGINE.runKernel(LeakyRelu,{x:n},{alpha:t})}const leakyRelu$2=op({leakyRelu_:leakyRelu_});
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function sub_(e,t){let n=convertToTensor(e,"a","sub"),r=convertToTensor(t,"b","sub");[n,r]=makeTypesMatch(n,r);return ENGINE.runKernel(Sub,{a:n,b:r})}const sub$3=op({sub_:sub_});
/**
     * @license
     * Copyright 2018 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function sum_(e,t=null,n=!1){let r=convertToTensor(e,"x","sum");"bool"===r.dtype&&(r=cast$2(r,"int32"));return ENGINE.runKernel(Sum,{x:r},{axis:t,keepDims:n})}const sum$2=op({sum_:sum_});
/**
     * @license
     * Copyright 2017 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function axesAreInnerMostDims(e,t){for(let n=0;n<e.length;++n)if(e[e.length-n-1]!==t-1-n)return!1;return!0}function combineLocations(e,t,n){const r=e.length+t.length,i=[];let a=0,o=0;for(let s=0;s<r;s++)-1===n.indexOf(s)?i.push(e[a++]):i.push(t[o++]);return i}function computeOutAndReduceShapes(e,t){const n=[],r=e.length;for(let i=0;i<r;i++)-1===t.indexOf(i)&&n.push(e[i]);return[n,t.map((t=>e[t]))]}function expandShapeToKeepDim(e,t){return combineLocations(e,t.map((e=>1)),t)}function assertAxesAreInnerMostDims(e,t,n){assert$1(axesAreInnerMostDims(t,n),(()=>`${e} supports only inner-most axes for now. Got axes ${t} and rank-${n} input.`))}function getAxesPermutation(e,t){if(axesAreInnerMostDims(e,t))return null;const n=[];for(let r=0;r<t;++r)-1===e.indexOf(r)&&n.push(r);return e.forEach((e=>n.push(e))),n}function getUndoAxesPermutation(e){return e.map(((e,t)=>[t,e])).sort(((e,t)=>e[1]-t[1])).map((e=>e[0]))}function getInnerMostAxes(e,t){const n=[];for(let r=t-e;r<t;++r)n.push(r);return n}
/**
     * @license
     * Copyright 2018 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function zeros$1(e,t="float32"){if("complex64"===t){const t=zeros$1(e,"float32"),n=zeros$1(e,"float32");return complex$2(t,n)}const n=makeZerosTypedArray(sizeFromShape(e),t);return ENGINE.makeTensor(n,e,t)}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function pad_(e,t,n=0){const r=convertToTensor(e,"x","pad");if(0===r.rank)throw new Error("pad(scalar) is not defined. Pass non-scalar to pad");return ENGINE.runKernel(PadV2,{x:r},{paddings:t,constantValue:n})}const pad=op({pad_:pad_});
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function prelu_(e,t){const n=convertToTensor(e,"x","prelu"),r=convertToTensor(t,"alpha","prelu");return ENGINE.runKernel(Prelu,{x:n,alpha:r})}const prelu$2=op({prelu_:prelu_});var alea$1={exports:{}},module;module=alea$1,(function(e,t,n){function r(e){var t=this,n=(function r(){var e=4022871197;return function(t){t=t.toString();for(var n=0;n<t.length;n++){var r=.02519603282416938*(e+=t.charCodeAt(n));r-=e=r>>>0,e=(r*=e)>>>0,e+=4294967296*(r-=e)}return 2.3283064365386963e-10*(e>>>0)}})();t.next=function(){var e=2091639*t.s0+2.3283064365386963e-10*t.c;return t.s0=t.s1,t.s1=t.s2,t.s2=e-(t.c=0|e)},t.c=1,t.s0=n(" "),t.s1=n(" "),t.s2=n(" "),t.s0-=n(e),t.s0<0&&(t.s0+=1),t.s1-=n(e),t.s1<0&&(t.s1+=1),t.s2-=n(e),t.s2<0&&(t.s2+=1),n=null}function i(e,t){return t.c=e.c,t.s0=e.s0,t.s1=e.s1,t.s2=e.s2,t}function a(e,t){var n=new r(e),a=t&&t.state,o=n.next;return o.int32=function(){return 4294967296*n.next()|0},o.double=function(){return o()+11102230246251565e-32*(2097152*o()|0)},o.quick=o,a&&("object"==typeof a&&i(a,n),o.state=function(){return i(n,{})}),o}t&&t.exports?t.exports=a:n&&n.amd?n((function(){return a})):this.alea=a})(0,module,!1);var xor128$1={exports:{}};!(function(e){!(function(e,t,n){function r(e){var t=this,n="";t.x=0,t.y=0,t.z=0,t.w=0,t.next=function(){var e=t.x^t.x<<11;return t.x=t.y,t.y=t.z,t.z=t.w,t.w^=t.w>>>19^e^e>>>8},e===(0|e)?t.x=e:n+=e;for(var r=0;r<n.length+64;r++)t.x^=0|n.charCodeAt(r),t.next()}function i(e,t){return t.x=e.x,t.y=e.y,t.z=e.z,t.w=e.w,t}function a(e,t){var n=new r(e),a=t&&t.state,o=function(){return(n.next()>>>0)/4294967296};return o.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},o.int32=n.next,o.quick=o,a&&("object"==typeof a&&i(a,n),o.state=function(){return i(n,{})}),o}t&&t.exports?t.exports=a:n&&n.amd?n((function(){return a})):this.xor128=a})(0,e,!1)})(xor128$1);var xorwow$1={exports:{}};!(function(e){!(function(e,t,n){function r(e){var t=this,n="";t.next=function(){var e=t.x^t.x>>>2;return t.x=t.y,t.y=t.z,t.z=t.w,t.w=t.v,(t.d=t.d+362437|0)+(t.v=t.v^t.v<<4^e^e<<1)|0},t.x=0,t.y=0,t.z=0,t.w=0,t.v=0,e===(0|e)?t.x=e:n+=e;for(var r=0;r<n.length+64;r++)t.x^=0|n.charCodeAt(r),r==n.length&&(t.d=t.x<<10^t.x>>>4),t.next()}function i(e,t){return t.x=e.x,t.y=e.y,t.z=e.z,t.w=e.w,t.v=e.v,t.d=e.d,t}function a(e,t){var n=new r(e),a=t&&t.state,o=function(){return(n.next()>>>0)/4294967296};return o.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},o.int32=n.next,o.quick=o,a&&("object"==typeof a&&i(a,n),o.state=function(){return i(n,{})}),o}t&&t.exports?t.exports=a:n&&n.amd?n((function(){return a})):this.xorwow=a})(0,e,!1)})(xorwow$1);var xorshift7$1={exports:{}};!(function(e){!(function(e,t,n){function r(e){var t=this;t.next=function(){var e,n,r=t.x,i=t.i;return e=r[i],n=(e^=e>>>7)^e<<24,n^=(e=r[i+1&7])^e>>>10,n^=(e=r[i+3&7])^e>>>3,n^=(e=r[i+4&7])^e<<7,e=r[i+7&7],r[i]=n^=(e^=e<<13)^e<<9,t.i=i+1&7,n},(function n(e,t){var n,r=[];if(t===(0|t))r[0]=t;else for(t=""+t,n=0;n<t.length;++n)r[7&n]=r[7&n]<<15^t.charCodeAt(n)+r[n+1&7]<<13;for(;r.length<8;)r.push(0);for(n=0;n<8&&0===r[n];++n);for(8==n&&(r[7]=-1),e.x=r,e.i=0,n=256;n>0;--n)e.next()})(t,e)}function i(e,t){return t.x=e.x.slice(),t.i=e.i,t}function a(e,t){null==e&&(e=+new Date);var n=new r(e),a=t&&t.state,o=function(){return(n.next()>>>0)/4294967296};return o.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},o.int32=n.next,o.quick=o,a&&(a.x&&i(a,n),o.state=function(){return i(n,{})}),o}t&&t.exports?t.exports=a:n&&n.amd?n((function(){return a})):this.xorshift7=a})(0,e,!1)})(xorshift7$1);var xor4096$1={exports:{}};!(function(e){!(function(e,t,n){function r(e){var t=this;t.next=function(){var e,n,r=t.w,i=t.X,a=t.i;return t.w=r=r+1640531527|0,n=i[a+34&127],e=i[a=a+1&127],n^=n<<13,e^=e<<17,n=i[a]=(n^=n>>>15)^(e^=e>>>12),t.i=a,n+(r^r>>>16)|0},(function n(e,t){var n,r,i,a,o,s=[],l=128;for(t===(0|t)?(r=t,t=null):(t+="\0",r=0,l=Math.max(l,t.length)),i=0,a=-32;a<l;++a)t&&(r^=t.charCodeAt((a+32)%t.length)),0===a&&(o=r),r^=r<<10,r^=r>>>15,r^=r<<4,r^=r>>>13,a>=0&&(i=0==(n=s[127&a]^=r+(o=o+1640531527|0))?i+1:0);for(i>=128&&(s[127&(t&&t.length||0)]=-1),i=127,a=512;a>0;--a)r=s[i+34&127],n=s[i=i+1&127],r^=r<<13,n^=n<<17,s[i]=(r^=r>>>15)^(n^=n>>>12);e.w=o,e.X=s,e.i=i})(t,e)}function i(e,t){return t.i=e.i,t.w=e.w,t.X=e.X.slice(),t}function a(e,t){null==e&&(e=+new Date);var n=new r(e),a=t&&t.state,o=function(){return(n.next()>>>0)/4294967296};return o.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},o.int32=n.next,o.quick=o,a&&(a.X&&i(a,n),o.state=function(){return i(n,{})}),o}t&&t.exports?t.exports=a:n&&n.amd?n((function(){return a})):this.xor4096=a})(0,e,!1)})(xor4096$1);var tychei$1={exports:{}};!(function(e){!(function(e,t,n){function r(e){var t=this,n="";t.next=function(){var e=t.b,n=t.c,r=t.d,i=t.a;return e=e<<25^e>>>7^n,n=n-r|0,r=r<<24^r>>>8^i,i=i-e|0,t.b=e=e<<20^e>>>12^n,t.c=n=n-r|0,t.d=r<<16^n>>>16^i,t.a=i-e|0},t.a=0,t.b=0,t.c=-1640531527,t.d=1367130551,e===Math.floor(e)?(t.a=e/4294967296|0,t.b=0|e):n+=e;for(var r=0;r<n.length+20;r++)t.b^=0|n.charCodeAt(r),t.next()}function i(e,t){return t.a=e.a,t.b=e.b,t.c=e.c,t.d=e.d,t}function a(e,t){var n=new r(e),a=t&&t.state,o=function(){return(n.next()>>>0)/4294967296};return o.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},o.int32=n.next,o.quick=o,a&&("object"==typeof a&&i(a,n),o.state=function(){return i(n,{})}),o}t&&t.exports?t.exports=a:n&&n.amd?n((function(){return a})):this.tychei=a})(0,e,!1)})(tychei$1);var seedrandom$1={exports:{}},_nodeResolve_empty={},_nodeResolve_empty$1=Object.freeze({__proto__:null,default:_nodeResolve_empty}),require$$0=getAugmentedNamespace(_nodeResolve_empty$1);!(function(e){!(function(t,n){var r,i=this,a=256,o=n.pow(a,6),s=n.pow(2,52),l=2*s,c=255;function h(e,c,h){var g=[],v=m(p((c=1==c?{entropy:!0}:c||{}).entropy?[e,f(t)]:null==e?(function y(){try{var e;return r&&(e=r.randomBytes)?e=e(a):(e=new Uint8Array(a),(i.crypto||i.msCrypto).getRandomValues(e)),f(e)}catch(e){var n=i.navigator,o=n&&n.plugins;return[+new Date,i,o,i.screen,f(t)]}})():e,3),g),_=new u(g),b=function(){for(var e=_.g(6),t=o,n=0;e<s;)e=(e+n)*a,t*=a,n=_.g(1);for(;e>=l;)e/=2,t/=2,n>>>=1;return(e+n)/t};return b.int32=function(){return 0|_.g(4)},b.quick=function(){return _.g(4)/4294967296},b.double=b,m(f(_.S),t),(c.pass||h||function(e,t,r,i){return i&&(i.S&&d(i,_),e.state=function(){return d(_,{})}),r?(n.random=e,t):e})(b,v,"global"in c?c.global:this==n,c.state)}function u(e){var t,n=e.length,r=this,i=0,o=r.i=r.j=0,s=r.S=[];for(n||(e=[n++]);i<a;)s[i]=i++;for(i=0;i<a;i++)s[i]=s[o=c&o+e[i%n]+(t=s[i])],s[o]=t;(r.g=function(e){for(var t,n=0,i=r.i,o=r.j,s=r.S;e--;)t=s[i=c&i+1],n=n*a+s[c&(s[i]=s[o=c&o+t])+(s[o]=t)];return r.i=i,r.j=o,n})(a)}function d(e,t){return t.i=e.i,t.j=e.j,t.S=e.S.slice(),t}function p(e,t){var n,r=[],i=typeof e;if(t&&"object"==i)for(n in e)try{r.push(p(e[n],t-1))}catch(e){}return r.length?r:"string"==i?e:e+"\0"}function m(e,t){for(var n,r=e+"",i=0;i<r.length;)t[c&i]=c&(n^=19*t[c&i])+r.charCodeAt(i++);return f(t)}function f(e){return String.fromCharCode.apply(0,e)}if(n.seedrandom=h,m(n.random(),t),e.exports){e.exports=h;try{r=require$$0}catch(e){}}})([],Math)})(seedrandom$1);var alea=alea$1.exports,xor128=xor128$1.exports,xorwow=xorwow$1.exports,xorshift7=xorshift7$1.exports,xor4096=xor4096$1.exports,tychei=tychei$1.exports,sr=seedrandom$1.exports;sr.alea=alea,sr.xor128=xor128,sr.xorwow=xorwow,sr.xorshift7=xorshift7,sr.xor4096=xor4096,sr.tychei=tychei;var seedrandom=sr;
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function relu_(e){const t=convertToTensor(e,"x","relu");return ENGINE.runKernel(Relu,{x:t})}const relu$2=op({relu_:relu_});
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function relu6_(e){const t=convertToTensor(e,"x","relu6");return ENGINE.runKernel(Relu6,{x:t})}const relu6$2=op({relu6_:relu6_});
/**
     * @license
     * Copyright 2018 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function scalar(e,t){if((isTypedArray(e)&&"string"!==t||Array.isArray(e))&&"complex64"!==t)throw new Error("Error creating a new Scalar: value must be a primitive (number|boolean|string)");if("string"===t&&isTypedArray(e)&&!(e instanceof Uint8Array))throw new Error("When making a scalar from encoded string, the value must be `Uint8Array`.");return makeTensor(e,[],[],t)}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function split_(e,t,n=0){const r=convertToTensor(e,"x","split");return ENGINE.runKernel(SplitV,{x:r},{numOrSizeSplits:t,axis:n})}const split=op({split_:split_});
/**
     * @license
     * Copyright 2018 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function step_(e,t=0){const n=convertToTensor(e,"x","step");return ENGINE.runKernel(Step,{x:n},{alpha:t})}const step$2=op({step_:step_});
/**
     * @license
     * Copyright 2018 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function whereImpl$2(e,t){const n=[];for(let e=0;e<t.length;e++)t[e]&&n.push(e);const r=buffer(e,"int32"),i=buffer([n.length,e.length],"int32");for(let t=0;t<n.length;t++){const a=r.indexToLoc(n[t]);i.values.set(a,t*e.length)}return i.toTensor()}
/**
     * @license
     * Copyright 2019 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function getFusedDyActivation(e,t,n){if(null==n||"linear"===n)return e;if("relu"===n)return mul(e,step$2(t));throw new Error(`Cannot compute gradient for fused activation ${n}.`)}function getFusedBiasGradient(e,t){let n=t;const r=getReductionAxes(e.shape,t.shape);return r.length>0&&(n=sum$2(n,r)),reshape$2(n,e.shape)}function applyActivation$1(e,t,n,r){if("linear"===t)return e;if("relu"===t)return relu$2(e);if("elu"===t)return elu$2(e);if("relu6"===t)return relu6$2(e);if("prelu"===t)return prelu$2(e,n);if("leakyrelu"===t)return leakyRelu$2(e,r);throw new Error(`Unknown fused activation ${t}.`)}const shouldFuse=(e,t)=>!(e>0)||"linear"===t;
/**
     * @license
     * Copyright 2019 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function binaryInsert(e,t,n){const r=binarySearch(e,t,n);e.splice(r<0?-(r+1):r,0,t)}function binarySearch(e,t,n){return binarySearch_(e,t,n||defaultComparator)}function defaultComparator(e,t){return e>t?1:e<t?-1:0}function binarySearch_(e,t,n){let r=0,i=e.length,a=0,o=!1;for(;r<i;){a=r+(i-r>>>1);const s=n(t,e[a]);s>0?r=a+1:(i=a,o=!s)}return o?r:-r-1}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function nonMaxSuppressionV3Impl$2(e,t,n,r,i){return nonMaxSuppressionImpl_(e,t,n,r,i,0)}function nonMaxSuppressionV4Impl$2(e,t,n,r,i,a){return nonMaxSuppressionImpl_(e,t,n,r,i,0,!1,a,!0)}function nonMaxSuppressionV5Impl$2(e,t,n,r,i,a){return nonMaxSuppressionImpl_(e,t,n,r,i,a,!0)}function nonMaxSuppressionImpl_(e,t,n,r,i,a,o=!1,s=!1,l=!1){const c=[];for(let e=0;e<t.length;e++)t[e]>i&&c.push({score:t[e],boxIndex:e,suppressBeginIndex:0});c.sort(ascendingComparator$1);const h=a>0?-.5/a:0,u=[],d=[];for(;u.length<n&&c.length>0;){const t=c.pop(),{score:n,boxIndex:a,suppressBeginIndex:o}=t;if(n<i)break;let s=!1;for(let n=u.length-1;n>=o;--n){const o=intersectionOverUnion(e,a,u[n]);if(o>=r){s=!0;break}if(t.score=t.score*suppressWeight(r,h,o),t.score<=i)break}t.suppressBeginIndex=u.length,s||(t.score===n?(u.push(a),d.push(t.score)):t.score>i&&binaryInsert(c,t,ascendingComparator$1))}const p=u.length,m=n-p;s&&m>0&&(u.push(...new Array(m).fill(0)),d.push(...new Array(m).fill(0)));const f={selectedIndices:u};return o&&(f.selectedScores=d),l&&(f.validOutputs=p),f}function intersectionOverUnion(e,t,n){const r=e.subarray(4*t,4*t+4),i=e.subarray(4*n,4*n+4),a=Math.min(r[0],r[2]),o=Math.min(r[1],r[3]),s=Math.max(r[0],r[2]),l=Math.max(r[1],r[3]),c=Math.min(i[0],i[2]),h=Math.min(i[1],i[3]),u=Math.max(i[0],i[2]),d=Math.max(i[1],i[3]),p=(s-a)*(l-o),m=(u-c)*(d-h);if(p<=0||m<=0)return 0;const f=Math.max(a,c),g=Math.max(o,h),v=Math.min(s,u),y=Math.min(l,d),_=Math.max(v-f,0)*Math.max(y-g,0);return _/(p+m-_)}function suppressWeight(e,t,n){const r=Math.exp(t*n*n);return n<=e?r:0}function ascendingComparator$1(e,t){return e.score-t.score||e.score===t.score&&t.boxIndex-e.boxIndex}
/**
     * @license
     * Copyright 2017 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function assertParamsConsistent(e,t){const n=e[0].length;e.forEach(((e,t)=>{assert$1(e.length===n,(()=>`Error in concat${n}D: rank of tensors[${t}] must be the same as the rank of the rest (${n})`))})),assert$1(t>=0&&t<n,(()=>`Error in concat${n}D: axis must be between 0 and ${n-1}.`));const r=e[0];e.forEach(((e,i)=>{for(let a=0;a<n;a++)assert$1(a===t||e[a]===r[a],(()=>`Error in concat${n}D: Shape of tensors[${i}] (${e}) does not match the shape of the rest (${r}) along the non-concatenated axis ${i}.`))}))}function computeOutShape$1(e,t){const n=e[0].slice();for(let r=1;r<e.length;r++)n[t]+=e[r][t];return n}
/**
     * @license
     * Copyright 2017 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */const PARALLELIZE_THRESHOLD=30;function computeOptimalWindowSize(e){return e<=PARALLELIZE_THRESHOLD?e:nearestDivisor(e,Math.floor(Math.sqrt(e)))}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function getImageCenter(e,t,n){return[n*("number"==typeof e?e:e[0]),t*("number"==typeof e?e:e[1])]}
/**
     * @license
     * Copyright 2018 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function getReshaped(e,t,n,r=!0){let i=[];if(r)i=i.concat(t.slice(0)),i.push(e[0]/n),i=i.concat(e.slice(1));else{i=i.concat(e[0]);const n=t.length;for(let r=0;r<n;++r)i=i.concat([e[r+1]/t[r],t[r]]);i=i.concat(e.slice(n+1))}return i}function getPermuted(e,t,n=!0){const r=[];if(n){r.push(t);for(let n=t+1;n<e;++n)n<=2*t?(r.push(n),r.push(n-(t+1))):r.push(n)}else{const n=[],i=[];for(let r=1;r<e;++r)r>=2*t+1||r%2==1?i.push(r):n.push(r);r.push(...n),r.push(0),r.push(...i)}return r}function getReshapedPermuted(e,t,n,r=!0){const i=[];i.push(r?e[0]/n:e[0]*n);for(let n=1;n<e.length;++n)i.push(n<=t.length?r?t[n-1]*e[n]:e[n]/t[n-1]:e[n]);return i}function getSliceBeginCoords(e,t){const n=[0];for(let r=0;r<t;++r)n.push(e[r][0]);return n}function getSliceSize(e,t,n){const r=e.slice(0,1);for(let i=0;i<n;++i)r.push(e[i+1]-t[i][0]-t[i][1]);return r}
/**
     * @license
     * Copyright 2018 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */const SELU_SCALEALPHA=1.7580993408473768,SELU_SCALE=1.0507009873554805,ERF_P=.3275911,ERF_A1=.254829592,ERF_A2=-.284496736,ERF_A3=1.421413741,ERF_A4=-1.453152027,ERF_A5=1.061405429;
/**
     * @license
     * Copyright 2018 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
function warn(...e){env().getBool("IS_TEST")||console.warn(...e)}function log$2(...e){env().getBool("IS_TEST")||console.log(...e)}
/**
     * @license
     * Copyright 2018 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function mergeRealAndImagArrays(e,t){if(e.length!==t.length)throw new Error(`Cannot merge real and imag arrays of different lengths. real:${e.length}, imag: ${t.length}.`);const n=new Float32Array(2*e.length);for(let r=0;r<n.length;r+=2)n[r]=e[r/2],n[r+1]=t[r/2];return n}function splitRealAndImagArrays(e){const t=new Float32Array(e.length/2),n=new Float32Array(e.length/2);for(let r=0;r<e.length;r+=2)t[r/2]=e[r],n[r/2]=e[r+1];return{real:t,imag:n}}function complexWithEvenIndex(e){const t=Math.ceil(e.length/4),n=new Float32Array(t),r=new Float32Array(t);for(let t=0;t<e.length;t+=4)n[Math.floor(t/4)]=e[t],r[Math.floor(t/4)]=e[t+1];return{real:n,imag:r}}function complexWithOddIndex(e){const t=Math.floor(e.length/4),n=new Float32Array(t),r=new Float32Array(t);for(let t=2;t<e.length;t+=4)n[Math.floor(t/4)]=e[t],r[Math.floor(t/4)]=e[t+1];return{real:n,imag:r}}function getComplexWithIndex(e,t){return{real:e[2*t],imag:e[2*t+1]}}function assignToTypedArray(e,t,n,r){e[2*r]=t,e[2*r+1]=n}function exponents(e,t){const n=new Float32Array(e/2),r=new Float32Array(e/2);for(let i=0;i<Math.ceil(e/2);i++){const a=(t?2:-2)*Math.PI*(i/e);n[i]=Math.cos(a),r[i]=Math.sin(a)}return{real:n,imag:r}}function exponent$1(e,t,n){const r=(n?2:-2)*Math.PI*(e/t);return{real:Math.cos(r),imag:Math.sin(r)}}
/**
     * @license
     * Copyright 2021 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */const ARROW="->",ARROW_REGEX=/->/g,COMMA=",",ELLIPSIS="...";function decodeEinsumEquation(e,t){const n=((e=e.replace(/\s/g,"")).length-e.replace(ARROW_REGEX,"").length)/ARROW.length;if(n<1)throw new Error("Equations without an arrow are not supported.");if(n>1)throw new Error(`Equation must contain exactly one arrow ("${ARROW}").`);const[r,i]=e.split(ARROW);assert$1(-1===r.indexOf(ELLIPSIS),(()=>`The ellipsis notation ("${ELLIPSIS}") is not supported yet.`));const a=r.split(COMMA),o=a.length;if(t!==o)throw new Error(`Expected ${o} input tensors, received ${t}`);if(o>2)throw new Error("Support for more than 2 input tensors is not implemented yet.");const s=[];for(let e=0;e<i.length;++e){const t=i[e];if(!a.some((e=>-1!==e.indexOf(t))))throw new Error(`Output subscripts contain the label ${t} not present in the input subscripts.`);-1===s.indexOf(t)&&s.push(t)}for(let e=0;e<r.length;++e){const t=r[e];-1===s.indexOf(t)&&t!==COMMA&&s.push(t)}const l=new Array(a.length);for(let e=0;e<o;++e){if(new Set(a[e].split("")).size!==a[e].length)throw new Error(`Found duplicate axes in input component ${a[e]}. Support for duplicate axes in input is not implemented yet.`);l[e]=[];for(let t=0;t<a[e].length;++t)l[e].push(s.indexOf(a[e][t]))}const c=s.length,h=[];for(let e=i.length;e<c;++e)h.push(e);return{allDims:s,summedDims:h,idDims:l}}function getEinsumPermutation(e,t){let n=new Array(e);n.fill(-1);for(let e=0;e<t.length;++e)n[t[e]]=e;const r=[];for(let t=0;t<e;++t)-1===n[t]&&r.push(t);return n=n.filter((e=>-1!==e)),{permutationIndices:n,expandDims:r}}function checkEinsumDimSizes(e,t,n){const r=new Array(e);for(let e=0;e<n.length;++e){const i=n[e].shape;for(let n=0;n<t[e].length;++n)void 0===r[t[e][n]]?r[t[e][n]]=i[n]:assert$1(r[t[e][n]]===i[n],(()=>`Expected dimension ${r[t[e][n]]} at axis ${n} of input shaped ${JSON.stringify(i)}, but got dimension ${i[n]}`))}}function getEinsumComputePath(e,t){const n=e,r=[];let i=0;0===e.length&&n.push(-1),i=e.length+1;for(let e=0;e<i;++e)r.push([]);const a=[];for(let e=0;e<n.length;++e){const i=findTermsWithDim(t,n[e]);for(const t of i)-1===a.indexOf(t)&&(r[e].push(t),a.push(t))}return{path:n,steps:r}}function isIdentityPermutation(e){return e.every(((e,t)=>e===t))}function findTermsWithDim(e,t){const n=[];for(let r=0;r<e.length;++r)0!==e[r].length&&-1===e[r].indexOf(t)&&-1!==t||n.push(r);return n}function prepareSplitSize(e,t,n=0){let r=[];if("number"==typeof t)assert$1(e.shape[n]%t==0,(()=>"Number of splits must evenly divide the axis.")),r=new Array(t).fill(e.shape[n]/t);else{assert$1(t.reduce(((e,t)=>(-1===t&&(e+=1),e)),0)<=1,(()=>"There should be only one negative value in split array."));const i=t.indexOf(-1);if(-1!==i){const r=t.reduce(((e,t)=>t>0?e+t:e));t[i]=e.shape[n]-r}assert$1(e.shape[n]===t.reduce(((e,t)=>e+t)),(()=>"The sum of sizes must match the size of the axis dimension.")),r=t}return r}
/**
     * @license
     * Copyright 2018 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function segOpComputeOptimalWindowSize(e,t){let n,r=!1;for(e<=PARALLELIZE_THRESHOLD?(n=e,r=!0):n=nearestDivisor(e,Math.floor(Math.sqrt(e)));!r;)n>t||n===e?r=!0:n=nearestDivisor(e,n+1);return n}function computeOutShape(e,t,n){const r=[],i=e.length;for(let a=0;a<i;a++)r.push(a!==t?e[a]:n);return r}function collectGatherOpShapeInfo(e,t,n,r){const i=t.shape.length,a=e.shape.length;if(0!==r&&(r<-i||r>i))throw new Error(`Expect batchDims in the range of [-${i}, ${i}], but got ${r}`);if(r<0&&(r+=i),r>a)throw new Error(`batchDims (${r}) must be less than rank(x) (\n    ${a}).`);if(n<r)throw new Error(`batchDims (${r}) must be less than or equal to axis (${n}).`);for(let n=0;n<r;++n)if(e.shape[n]!==t.shape[n])throw new Error(`x.shape[${n}]: ${e.shape[n]} should be equal to indices.shape[${n}]: ${t.shape[n]}.`);const o=e.shape[n],s=[];let l=1,c=1,h=1;for(let t=0;t<r;++t)s.push(e.shape[t]),l*=e.shape[t];for(let t=r;t<n;t++)s.push(e.shape[t]),c*=e.shape[t];for(let e=r;e<i;e++)s.push(t.shape[e]);for(let t=n+1;t<a;t++)s.push(e.shape[t]),h*=e.shape[t];return{batchSize:l,sliceSize:h,outerSize:c,dimSize:o,outputShape:s}}var segment_util=Object.freeze({__proto__:null,segOpComputeOptimalWindowSize:segOpComputeOptimalWindowSize,computeOutShape:computeOutShape,collectGatherOpShapeInfo:collectGatherOpShapeInfo});
/**
     * @license
     * Copyright 2018 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function fromUint8ToStringArray(e){try{return e.map((e=>decodeString(e)))}catch(e){throw new Error(`Failed to decode encoded string bytes into utf-8, error: ${e}`)}}function fromStringArrayToUint8(e){return e.map((e=>encodeString(e)))}var backend_util=Object.freeze({__proto__:null,slice_util:slice_util,segment_util:segment_util,fromUint8ToStringArray:fromUint8ToStringArray,fromStringArrayToUint8:fromStringArrayToUint8,upcastType:upcastType,axesAreInnerMostDims:axesAreInnerMostDims,combineLocations:combineLocations,computeOutAndReduceShapes:computeOutAndReduceShapes,expandShapeToKeepDim:expandShapeToKeepDim,assertAxesAreInnerMostDims:assertAxesAreInnerMostDims,getAxesPermutation:getAxesPermutation,getUndoAxesPermutation:getUndoAxesPermutation,getInnerMostAxes:getInnerMostAxes,getBroadcastDims:getBroadcastDims$1,getReductionAxes:getReductionAxes,assertAndGetBroadcastShape:assertAndGetBroadcastShape,assertParamsConsistent:assertParamsConsistent,computeOutShape:computeOutShape$1,computeDilation2DInfo:computeDilation2DInfo,computePool2DInfo:computePool2DInfo,computePool3DInfo:computePool3DInfo,computeConv2DInfo:computeConv2DInfo,computeConv3DInfo:computeConv3DInfo,computeDefaultPad:computeDefaultPad,tupleValuesAreOne:tupleValuesAreOne,eitherStridesOrDilationsAreOne:eitherStridesOrDilationsAreOne,convertConv2DDataFormat:convertConv2DDataFormat,getFusedDyActivation:getFusedDyActivation,getFusedBiasGradient:getFusedBiasGradient,applyActivation:applyActivation$1,shouldFuse:shouldFuse,PARALLELIZE_THRESHOLD:PARALLELIZE_THRESHOLD,computeOptimalWindowSize:computeOptimalWindowSize,getImageCenter:getImageCenter,getReshaped:getReshaped,getPermuted:getPermuted,getReshapedPermuted:getReshapedPermuted,getSliceBeginCoords:getSliceBeginCoords,getSliceSize:getSliceSize,prepareAndValidate:prepareAndValidate,validateUpdateShape:validateUpdateShape,validateInput:validateInput,calculateShapes:calculateShapes,SELU_SCALEALPHA:SELU_SCALEALPHA,SELU_SCALE:SELU_SCALE,ERF_P:ERF_P,ERF_A1:ERF_A1,ERF_A2:ERF_A2,ERF_A3:ERF_A3,ERF_A4:ERF_A4,ERF_A5:ERF_A5,warn:warn,log:log$2,mergeRealAndImagArrays:mergeRealAndImagArrays,splitRealAndImagArrays:splitRealAndImagArrays,complexWithEvenIndex:complexWithEvenIndex,complexWithOddIndex:complexWithOddIndex,getComplexWithIndex:getComplexWithIndex,assignToTypedArray:assignToTypedArray,exponents:exponents,exponent:exponent$1,decodeEinsumEquation:decodeEinsumEquation,getEinsumPermutation:getEinsumPermutation,checkEinsumDimSizes:checkEinsumDimSizes,getEinsumComputePath:getEinsumComputePath,isIdentityPermutation:isIdentityPermutation,prepareSplitSize:prepareSplitSize});
/**
     * @license
     * Copyright 2019 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function assertNotComplex$1(e,t){Array.isArray(e)||(e=[e]),e.forEach((e=>{null!=e&&assert$1("complex64"!==e.dtype,(()=>`${t} does not support complex64 tensors in the CPU backend.`))}))}
/**
     * @license
     * Copyright 2021 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */const whereImpl$1=whereImpl$2;class MathBackendCPU extends KernelBackend{constructor(){super(),this.blockSize=48,this.firstUse=!0,this.data=new DataStorage(this,engine())}nextDataId(){return MathBackendCPU.nextDataId++}write(e,t,n){this.firstUse&&(this.firstUse=!1,env().get("IS_NODE")&&warn("\n============================\nHi there 👋. Looks like you are running TensorFlow.js in Node.js. To speed things up dramatically, install our node backend, which binds to TensorFlow C++, by running npm i @tensorflow/tfjs-node, or npm i @tensorflow/tfjs-node-gpu if you have CUDA. Then call require('@tensorflow/tfjs-node'); (-gpu suffix for CUDA) at the start of your program. Visit https://github.com/tensorflow/tfjs-node for more details.\n============================"));const r={id:this.nextDataId()};return this.data.set(r,{values:e,dtype:n,refCount:1}),r}makeTensorInfo(e,t,n){let r;if("string"===t&&null!=n&&n.length>0&&isString(n[0])){const i=n.map((e=>encodeString(e)));r=this.write(i,e,t)}else r=this.write(n,e,t);return{dataId:r,shape:e,dtype:t}}refCount(e){if(this.data.has(e)){return this.data.get(e).refCount}return 0}incRef(e){this.data.get(e).refCount++}decRef(e){if(this.data.has(e)){this.data.get(e).refCount--}}move(e,t,n,r,i){this.data.set(e,{values:t,dtype:r,refCount:i})}numDataIds(){return this.data.numDataIds()}async read(e){return this.readSync(e)}readSync(e){const{dtype:t,complexTensorInfos:n}=this.data.get(e);if("complex64"===t){return mergeRealAndImagArrays(this.readSync(n.real.dataId),this.readSync(n.imag.dataId))}return this.data.get(e).values}bufferSync(e){const t=this.readSync(e.dataId);let n=t;if("string"===e.dtype)try{n=t.map((e=>decodeString(e)))}catch(e){throw new Error("Failed to decode encoded string bytes into utf-8")}return buffer(e.shape,e.dtype,n)}makeOutput(e,t,n){const r=this.write(e,t,n);return engine().makeTensorFromDataId(r,t,n,this)}disposeData(e,t=!1){if(this.data.has(e)){if(this.data.get(e).refCount--,!t&&this.data.get(e).refCount>0)return!1;const{complexTensorInfos:n}=this.data.get(e);null!=n&&(this.disposeData(n.real.dataId,!0),this.disposeData(n.imag.dataId,!0)),this.data.delete(e)}return!0}disposeIntermediateTensorInfo(e){this.disposeData(e.dataId)}async time(e){const t=now();e();return{kernelMs:now()-t}}memory(){return{unreliable:!0,reasons:["The reported memory is an upper bound. Due to automatic garbage collection, the true allocated memory may be less."]}}where(e){assertNotComplex$1([e],"where");const t=this.readSync(e.dataId);return whereImpl$1(e.shape,t)}dispose(){}floatPrecision(){return 32}epsilon(){return super.epsilon()}}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the License);
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an AS IS BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
function simpleAbsImpl(e){const t=new Float32Array(e.length);for(let n=0;n<e.length;++n)t[n]=Math.abs(e[n]);return t}MathBackendCPU.nextDataId=0;const abs$1=e=>{const{x:t}=e.inputs,n=e.backend;assertNotComplex$1(t,"abs");let r=new Float32Array(sizeFromShape(t.shape));return r=simpleAbsImpl(n.data.get(t.dataId).values),n.makeOutput(r,t.shape,"float32")},absConfig$1={kernelName:Abs,backendName:"cpu",kernelFunc:abs$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
function createSimpleBinaryKernelImpl(e){return(t,n,r,i,a)=>{const o=assertAndGetBroadcastShape(t,n),s=o.length,l=computeStrides(o),c=getTypedArrayFromDType(a,sizeFromShape(o)),h=t.length,u=n.length,d=computeStrides(t),p=computeStrides(n),m=getBroadcastDims$1(t,o),f=getBroadcastDims$1(n,o);if(m.length+f.length===0)for(let t=0;t<c.length;++t)c[t]=e(r[t%r.length],i[t%i.length]);else for(let t=0;t<c.length;++t){const n=indexToLoc(t,s,l),a=n.slice(-h);m.forEach((e=>a[e]=0));const o=locToIndex(a,h,d),g=n.slice(-u);f.forEach((e=>g[e]=0));const v=locToIndex(g,u,p);c[t]=e(r[o],i[v])}return[c,o]}}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function complex$1(e){const{inputs:t,backend:n}=e,{real:r,imag:i}=t,a=n.data.get(r.dataId).values,o=n.data.get(i.dataId).values,s=n.makeTensorInfo(r.shape,"complex64");return n.data.get(s.dataId).complexTensorInfos={real:n.makeTensorInfo(r.shape,"float32",a),imag:n.makeTensorInfo(i.shape,"float32",o)},s}const complexConfig$1={kernelName:Complex,backendName:"cpu",kernelFunc:complex$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function zeros(e,t,n="float32"){if("complex64"===n){return complex$1({inputs:{real:zeros(e,t,"float32"),imag:zeros(e,t,"float32")},backend:e})}const r=makeZerosTypedArray(sizeFromShape(t),n);return e.makeTensorInfo(t,n,r)}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function identity$3(e){const{inputs:t,backend:n}=e,{x:r}=t;return n.incRef(r.dataId),{dataId:r.dataId,shape:r.shape,dtype:r.dtype}}const identityConfig$1={kernelName:Identity,backendName:"cpu",kernelFunc:identity$3};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function real$1(e){const{inputs:t,backend:n}=e,{input:r}=t,i=n.data.get(r.dataId).complexTensorInfos.real,a=n.data.get(i.dataId).values;return n.makeTensorInfo(i.shape,i.dtype,a)}const realConfig$1={kernelName:Real,backendName:"cpu",kernelFunc:real$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function cast$1(e){const{inputs:t,backend:n,attrs:r}=e,{x:i}=t,{dtype:a}=r;if("complex64"===a){if("complex64"===i.dtype)return identity$3({inputs:{x:i},backend:n});const e=zeros(n,i.shape,i.dtype),t=cast$1({inputs:{x:i},backend:n,attrs:{dtype:"float32"}}),r=complex$1({inputs:{real:t,imag:e},backend:n});return n.disposeIntermediateTensorInfo(e),n.disposeIntermediateTensorInfo(t),r}if("complex64"===i.dtype){const e=real$1({inputs:{input:i},backend:n}),t=cast$1({inputs:{x:e},backend:n,attrs:{dtype:a}});return n.disposeIntermediateTensorInfo(e),t}if(!hasEncodingLoss(i.dtype,a)){const e=identity$3({inputs:{x:i},backend:n});return{dataId:e.dataId,shape:e.shape,dtype:a}}if("int32"===a){const e=n.data.get(i.dataId).values,t=Int32Array.from(e);return n.makeTensorInfo(i.shape,"int32",t)}if("bool"===a){const e=n.data.get(i.dataId).values,t=toTypedArray$1([0],i.dtype),[r,a]=createSimpleBinaryKernelImpl(((e,t)=>e!==t?1:0))(i.shape,[],e,t,"bool");return n.makeTensorInfo(a,"bool",r)}throw new Error(`Error in Cast: failed to cast ${i.dtype} to ${a}`)}const castConfig$1={kernelName:Cast,backendName:"cpu",kernelFunc:cast$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function binaryKernelFunc$1(e,t,n,r){return null==n?({inputs:n,backend:i})=>{const{a:a,b:o}=n,s=i;assertNotComplex$1([a,o],e);const l=s.data.get(a.dataId).values,c=s.data.get(o.dataId).values,h=r||a.dtype,[u,d]=t(a.shape,o.shape,l,c,h);return s.makeTensorInfo(d,h,u)}:({inputs:e,backend:i})=>{const{a:a,b:o}=e,s=i;if("complex64"===a.dtype||"complex64"===o.dtype){const e=cast$1({inputs:{x:a},backend:s,attrs:{dtype:"complex64"}}),t=s.data.get(e.dataId),r=t.complexTensorInfos.imag,i=s.data.get(t.complexTensorInfos.real.dataId).values,l=s.data.get(r.dataId).values,c=cast$1({inputs:{x:o},backend:s,attrs:{dtype:"complex64"}}),h=s.data.get(c.dataId),u=h.complexTensorInfos.imag,d=s.data.get(h.complexTensorInfos.real.dataId).values,p=s.data.get(u.dataId).values,[m,f,g]=n(a.shape,o.shape,i,l,d,p),v=s.makeTensorInfo(g,"float32",m),y=s.makeTensorInfo(g,"float32",f),_=complex$1({inputs:{real:v,imag:y},backend:s});return s.disposeIntermediateTensorInfo(e),s.disposeIntermediateTensorInfo(c),s.disposeIntermediateTensorInfo(v),s.disposeIntermediateTensorInfo(y),_}{const e=s.data.get(a.dataId).values,n=s.data.get(o.dataId).values,i=r||a.dtype,[l,c]=t(a.shape,o.shape,e,n,i);return s.makeTensorInfo(c,i,l)}}}function createComplexBinaryKernelImpl(e){return(t,n,r,i,a,o)=>{const s=assertAndGetBroadcastShape(t,n),l=sizeFromShape(s),c=s.length,h=computeStrides(s),u=getTypedArrayFromDType("float32",l),d=getTypedArrayFromDType("float32",l),p=getBroadcastDims$1(t,s),m=getBroadcastDims$1(n,s),f=mergeRealAndImagArrays(r,i),g=mergeRealAndImagArrays(a,o),v=t.length,y=computeStrides(t),_=n.length,b=computeStrides(n);if(p.length+m.length===0)for(let t=0;t<u.length;t++){const n=t%f.length,r=t%g.length,i=e(f[2*n],f[2*n+1],g[2*r],g[2*r+1]);u[t]=i.real,d[t]=i.imag}else for(let t=0;t<u.length;t++){const n=indexToLoc(t,c,h),r=n.slice(-v);p.forEach((e=>r[e]=0));const i=locToIndex(r,v,y),a=n.slice(-_);m.forEach((e=>a[e]=0));const o=locToIndex(a,_,b),s=e(f[2*i],f[2*i+1],g[2*o],g[2*o+1]);u[t]=s.real,d[t]=s.imag}return[u,d,s]}}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */const addImpl=createSimpleBinaryKernelImpl(((e,t)=>e+t)),addComplexImpl=createComplexBinaryKernelImpl(((e,t,n,r)=>({real:e+n,imag:t+r}))),add=binaryKernelFunc$1(Add,addImpl,addComplexImpl),addConfig$1={kernelName:Add,backendName:"cpu",kernelFunc:add};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
function bincountImpl(e,t,n,r,i){const a=sizeFromShape(r),o=makeZerosTypedArray(i,n);for(let n=0;n<e.length;n++){const r=e[n];if(r<0)throw new Error("Input x must be non-negative!");r>=i||(o[r]+=a>0?t[n]:1)}return o}function bincountReduceImpl(e,t,n,r=!1){const i=e.shape[0],a=e.shape[1],o=buffer([i,n],t.dtype);for(let s=0;s<i;s++)for(let i=0;i<a;i++){const a=e.get(s,i);if(a<0)throw new Error("Input x must be non-negative!");a>=n||o.set(r?1:t.size>0?o.get(s,a)+t.get(s,i):o.get(s,a)+1,s,a)}return o}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function createSimpleUnaryImpl(e){return(t,n,r)=>{const i=getTypedArrayFromDType(n,t.length);for(let n=0;n<t.length;++n)i[n]=e(t[n],r);return i}}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function unaryKernelFunc$1(e,t,n){return({inputs:r,attrs:i,backend:a})=>{const{x:o}=r;if(assertNotComplex$1(o,e),"string"===o.dtype||"string"===n)throw new Error("unaryKernelFunc does not support string input/output");const s=a,l=s.data.get(o.dataId).values,c=sizeFromShape(o.shape),h=n||o.dtype,u=getArrayFromDType(h,c);for(let e=0;e<c;++e)u[e]=t(l[e],i);return s.makeTensorInfo(o.shape,h,u)}}function unaryKernelFuncFromImpl(e,t,n){return({inputs:r,attrs:i,backend:a})=>{const{x:o}=r;if(assertNotComplex$1(o,e),"string"===o.dtype||"string"===n)throw new Error("unaryKernelFunc does not support string input/output");const s=a,l=s.data.get(o.dataId).values,c=n||o.dtype,h=t(l,c,i);return s.makeTensorInfo(o.shape,c,h)}}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the License);
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an AS IS BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */const ceilImpl=createSimpleUnaryImpl((e=>Math.ceil(e))),ceil$1=unaryKernelFuncFromImpl(Ceil,ceilImpl),ceilConfig$1={kernelName:Ceil,backendName:"cpu",kernelFunc:ceil$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
function concatImpl$1(e,t,n,r){const i=getArrayFromDType(n,sizeFromShape(t));if(r&&"string"!==n){let t=0;e.forEach((e=>{const n=sizeFromShape(e.shape);i.set(e.vals,t),t+=n}))}else{let r=0;e.forEach((e=>{const a="string"===n?fromUint8ToStringArray(e.vals):e.vals;let o=0;for(let n=0;n<e.shape[0];++n){const s=n*t[1]+r;for(let t=0;t<e.shape[1];++t)i[s+t]=a[o++]}r+=e.shape[1]}))}return i}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the License);
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an AS IS BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */const expImpl=createSimpleUnaryImpl((e=>Math.exp(e))),exp$1=unaryKernelFuncFromImpl(Exp,expImpl),expConfig$1={kernelName:Exp,backendName:"cpu",kernelFunc:exp$1},expm1Impl=createSimpleUnaryImpl((e=>Math.expm1(e))),expm1$1=unaryKernelFuncFromImpl(Expm1,expm1Impl),expm1Config$1={kernelName:Expm1,backendName:"cpu",kernelFunc:expm1$1},floorImpl=createSimpleUnaryImpl((e=>Math.floor(e))),floor$1=unaryKernelFuncFromImpl(Floor,floorImpl),floorConfig$1={kernelName:Floor,backendName:"cpu",kernelFunc:floor$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
function gatherV2Impl(e,t,n){const r=buffer(n,e.dtype);for(let n=0;n<r.size;++n){const i=r.indexToLoc(n).slice(),a=t.locToIndex([i[0],i[2]]);i[2]=t.values[a];const o=e.locToIndex(i);r.values[n]=e.values[o]}return r}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */const greaterImpl=createSimpleBinaryKernelImpl(((e,t)=>e>t?1:0)),greater$1=binaryKernelFunc$1(Greater,greaterImpl,null,"bool"),greaterConfig$1={kernelName:Greater,backendName:"cpu",kernelFunc:greater$1},lessImpl=createSimpleBinaryKernelImpl(((e,t)=>e<t?1:0)),less$1=binaryKernelFunc$1(Less,lessImpl,null,"bool"),lessConfig$1={kernelName:Less,backendName:"cpu",kernelFunc:less$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
function linSpaceImpl(e,t,n){const r=(t-e)/(n-1),i=makeZerosTypedArray(n,"float32");i[0]=e;for(let e=1;e<i.length;e++)i[e]=i[e-1]+r;return i}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the License);
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an AS IS BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */const logImpl=createSimpleUnaryImpl((e=>Math.log(e))),log$1=unaryKernelFuncFromImpl(Log,logImpl),logConfig$1={kernelName:Log,backendName:"cpu",kernelFunc:log$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
function maxImpl$1(e,t,n,r){const i=getTypedArrayFromDType(r,sizeFromShape(n));for(let n=0;n<i.length;++n){const r=n*t;let a=e[r];for(let n=0;n<t;++n){const t=e[r+n];t>a&&(a=t)}i[n]=a}return i}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */const maximumImpl=createSimpleBinaryKernelImpl(((e,t)=>Math.max(e,t))),maximum$1=binaryKernelFunc$1(Maximum,maximumImpl),maximumConfig$1={kernelName:Maximum,backendName:"cpu",kernelFunc:maximum$1},minimumImpl=createSimpleBinaryKernelImpl(((e,t)=>Math.min(e,t))),minimum$1=binaryKernelFunc$1(Minimum,minimumImpl),minimumConfig$1={kernelName:Minimum,backendName:"cpu",kernelFunc:minimum$1},multiplyImpl=createSimpleBinaryKernelImpl(((e,t)=>e*t)),multiplyComplexImpl=createComplexBinaryKernelImpl(((e,t,n,r)=>({real:e*n-t*r,imag:e*r+t*n}))),multiply$1=binaryKernelFunc$1(Multiply,multiplyImpl,multiplyComplexImpl),multiplyConfig$1={kernelName:Multiply,backendName:"cpu",kernelFunc:multiply$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
function negImpl(e,t,n){const r=createScalarValue(-1,n);return multiplyImpl([],t,r,e,n)}function neg$1(e){const{inputs:t,backend:n}=e,{x:r}=t;assertNotComplex$1(r,"neg");const i=n.data.get(r.dataId).values,[a,o]=negImpl(i,r.shape,r.dtype);return n.makeTensorInfo(o,r.dtype,a)}const negConfig$1={kernelName:Neg,backendName:"cpu",kernelFunc:neg$1},notEqualImpl=createSimpleBinaryKernelImpl(((e,t)=>e!==t?1:0)),notEqual$1=binaryKernelFunc$1(NotEqual,notEqualImpl,null,"bool"),notEqualConfig$1={kernelName:NotEqual,backendName:"cpu",kernelFunc:notEqual$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
function transposeImpl$1(e,t,n,r,i){const a=t.length,o=sizeFromShape(t),s=computeStrides(t),l=computeStrides(i),c=getTypedArrayFromDType(n,sizeFromShape(i));for(let t=0;t<o;++t){const n=indexToLoc(t,a,s),i=new Array(n.length);for(let e=0;e<i.length;e++)i[e]=n[r[e]];c[locToIndex(i,a,l)]=e[t]}return c}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function transpose$1(e){const{inputs:t,attrs:n,backend:r}=e,{x:i}=t,{perm:a}=n;assertNotComplex$1(i,"transpose");const o=new Array(i.shape.length);for(let e=0;e<o.length;e++)o[e]=i.shape[a[e]];const s=transposeImpl$1(r.data.get(i.dataId).values,i.shape,i.dtype,a,o);return{dataId:r.write(s,o,i.dtype),shape:o,dtype:i.dtype}}const transposeConfig$1={kernelName:Transpose,backendName:"cpu",kernelFunc:transpose$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function prodImpl(e,t,n,r){const[i,a]=computeOutAndReduceShapes(e,r),o=upcastType(t,"int32"),s=makeZerosTypedArray(sizeFromShape(i),o),l=sizeFromShape(a);for(let e=0;e<s.length;++e){const t=e*l;let r=1;for(let e=0;e<l;++e)r*=n[t+e];s[e]=r}return{outVals:s,outShape:i,outDtype:o}}function prod$1(e){const{inputs:t,backend:n,attrs:r}=e,{x:i}=t,{axis:a,keepDims:o}=r;assertNotComplex$1(i,"prod");const s=i.shape.length,l=parseAxisParam(a,i.shape),c=getAxesPermutation(l,s);let h=l,u=i;const d=[];null!=c&&(u=transpose$1({inputs:{x:i},backend:n,attrs:{perm:c}}),d.push(u),h=getInnerMostAxes(h.length,s));const p=n.data.get(u.dataId).values,{outVals:m,outShape:f,outDtype:g}=prodImpl(u.shape,u.dtype,p,h);let v=f;return o&&(v=expandShapeToKeepDim(f,l)),d.forEach((e=>n.disposeIntermediateTensorInfo(e))),n.makeTensorInfo(v,g,m)}const prodConfig$1={kernelName:Prod,backendName:"cpu",kernelFunc:prod$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function rangeImpl(e,t,n,r){if(e===t||e<t&&n<0||t<e&&n>1)return makeZerosTypedArray(0,r);const i=makeZerosTypedArray(Math.abs(Math.ceil((t-e)/n)),r);t<e&&1===n&&(n=-1),i[0]=e;for(let e=1;e<i.length;e++)i[e]=i[e-1]+n;return i}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the License);
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an AS IS BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */const rsqrtImpl=createSimpleUnaryImpl((e=>1/Math.sqrt(e))),rsqrt$1=unaryKernelFuncFromImpl(Rsqrt,rsqrtImpl),rsqrtConfig$1={kernelName:Rsqrt,backendName:"cpu",kernelFunc:rsqrt$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
function sliceImpl(e,t,n,r,i){const a=isSliceContinous(r,t,n),o=sizeFromShape(n),s=computeStrides(r);if(a){const n=computeFlatOffset(t,s);return"string"===i?e.slice(n,n+o):e.subarray(n,n+o)}const l=buffer(r,i,"string"===i?fromUint8ToStringArray(e):e),c=buffer(n,i);for(let e=0;e<c.size;++e){const n=c.indexToLoc(e),r=n.map(((e,n)=>e+t[n]));c.set(l.get(...r),...n)}return"string"===i?fromStringArrayToUint8(c.values):c.values}function slice$2(e){const{inputs:t,backend:n,attrs:r}=e,{x:i}=t,{begin:a,size:o}=r;assertNotComplex$1(i,"slice");const[s,l]=parseSliceParams(i,a,o);assertParamsValid(i,s,l);const c=sliceImpl(n.data.get(i.dataId).values,s,l,i.shape,i.dtype);return n.makeTensorInfo(l,i.dtype,c)}const sliceConfig$1={kernelName:Slice,backendName:"cpu",kernelFunc:slice$2},squaredDifferenceImpl=createSimpleBinaryKernelImpl(((e,t)=>{const n=e-t;return n*n})),squaredDifference$1=binaryKernelFunc$1(SquaredDifference,squaredDifferenceImpl),squaredDifferenceConfig$1={kernelName:SquaredDifference,backendName:"cpu",kernelFunc:squaredDifference$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
function stridedSliceImpl(e,t,n,r){const i=buffer(e,t.dtype);for(let e=0;e<i.size;e++){const a=i.indexToLoc(e),o=new Array(a.length);for(let e=0;e<o.length;e++)o[e]=a[e]*n[e]+r[e];i.set(t.get(...o),...a)}return i}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */const subImpl=createSimpleBinaryKernelImpl(((e,t)=>e-t)),subComplexImpl=createComplexBinaryKernelImpl(((e,t,n,r)=>({real:e-n,imag:t-r}))),sub$2=binaryKernelFunc$1(Sub,subImpl,subComplexImpl),subConfig$1={kernelName:Sub,backendName:"cpu",kernelFunc:sub$2};
/**
     * @license
     * Copyright 2019 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
function tileImpl(e,t){const n=new Array(e.rank);for(let r=0;r<n.length;r++)n[r]=e.shape[r]*t[r];const r=buffer(n,e.dtype);for(let t=0;t<r.values.length;++t){const n=r.indexToLoc(t),i=new Array(e.rank);for(let t=0;t<i.length;t++)i[t]=n[t]%e.shape[t];const a=e.locToIndex(i);r.values[t]=e.values[a]}return r}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function topKImpl(e,t,n,r,i){const a=t[t.length-1],[o,s]=[e.length/a,a],l=getTypedArrayFromDType(n,o*r),c=getTypedArrayFromDType("int32",o*r);for(let t=0;t<o;t++){const n=t*s,i=e.subarray(n,n+s),a=[];for(let e=0;e<i.length;e++)a.push({value:i[e],index:e});a.sort(((e,t)=>t.value-e.value));const o=t*r,h=l.subarray(o,o+r),u=c.subarray(o,o+r);for(let e=0;e<r;e++)h[e]=a[e].value,u[e]=a[e].index}const h=t.slice();return h[h.length-1]=r,[buffer(h,n,l),buffer(h,"int32",c)]}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function uniqueImpl(e,t,n,r){const i=parseAxisParam(t,n)[0],a=[1,n[0],1];for(let e=0;e<i;e++)a[0]*=n[e];a[1]=n[i];for(let e=i+1;e<n.length;e++)a[2]*=n[e];const o={},s=new Int32Array(n[i]),l=new TensorBuffer(a,r,e),c=[],h=1===a[0]&&1===a[2];for(let t=0;t<n[i];t++){let n;if(h)n=e[t].toString();else{const e=[];for(let n=0;n<a[0];n++)for(let r=0;r<a[2];r++)e.push(l.get(n,t,r));n=e.join(",")}if(void 0!==o[n])s[t]=o[n];else{const e=Object.keys(o).length;o[n]=e,s[t]=e,c.push(t)}}const u=a.slice();u[1]=Object.keys(o).length;const d=new TensorBuffer(u,r);c.forEach(((e,t)=>{for(let n=0;n<a[0];n++)for(let r=0;r<a[2];r++)d.set(l.get(n,e,r),n,t,r)}));const p=n.slice();return p[i]=u[1],{outputValues:d.values,outputShape:p,indices:s}}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */var shared=Object.freeze({__proto__:null,simpleAbsImpl:simpleAbsImpl,addImpl:addImpl,bincountImpl:bincountImpl,bincountReduceImpl:bincountReduceImpl,ceilImpl:ceilImpl,concatImpl:concatImpl$1,expImpl:expImpl,expm1Impl:expm1Impl,floorImpl:floorImpl,gatherV2Impl:gatherV2Impl,greaterImpl:greaterImpl,lessImpl:lessImpl,linSpaceImpl:linSpaceImpl,logImpl:logImpl,maxImpl:maxImpl$1,maximumImpl:maximumImpl,minimumImpl:minimumImpl,multiplyImpl:multiplyImpl,negImpl:negImpl,notEqualImpl:notEqualImpl,prodImpl:prodImpl,rangeImpl:rangeImpl,rsqrtImpl:rsqrtImpl,sliceImpl:sliceImpl,squaredDifferenceImpl:squaredDifferenceImpl,stridedSliceImpl:stridedSliceImpl,subImpl:subImpl,tileImpl:tileImpl,topKImpl:topKImpl,transposeImpl:transposeImpl$1,uniqueImpl:uniqueImpl});
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */registerBackend("cpu",(()=>new MathBackendCPU),1);
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the License);
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an AS IS BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
const elu$1=unaryKernelFunc$1(Elu,(e=>e>=0?e:Math.exp(e)-1)),eluConfig$1={kernelName:Elu,backendName:"cpu",kernelFunc:elu$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
function leakyRelu$1(e){const{inputs:t,backend:n,attrs:r}=e,{x:i}=t,{alpha:a}=r;assertNotComplex$1([i],"leakyRelu");const o=sizeFromShape(i.shape),s=n.data.get(i.dataId).values,l=getTypedArrayFromDType("float32",o);for(let e=0;e<s.length;e++)l[e]=s[e]<0?a*s[e]:s[e];return n.makeTensorInfo(i.shape,"float32",l)}const leakyReluConfig$1={kernelName:LeakyRelu,backendName:"cpu",kernelFunc:leakyRelu$1},preluImpl=createSimpleBinaryKernelImpl(((e,t)=>e<0?t*e:e));
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the License);
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an AS IS BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function prelu$1(e){const{inputs:t,backend:n}=e,{x:r,alpha:i}=t;assertNotComplex$1([r,i],"prelu");const a=n.data.get(r.dataId).values,o=n.data.get(i.dataId).values,[s,l]=preluImpl(r.shape,i.shape,a,o,r.dtype);return n.makeTensorInfo(l,r.dtype,s)}const preluConfig$1={kernelName:Prelu,backendName:"cpu",kernelFunc:prelu$1},relu$1=unaryKernelFunc$1(Relu,(e=>Math.max(0,e))),reluConfig$1={kernelName:Relu,backendName:"cpu",kernelFunc:relu$1},relu6$1=unaryKernelFunc$1(Relu6,(e=>Math.min(Math.max(0,e),6))),relu6Config$1={kernelName:Relu6,backendName:"cpu",kernelFunc:relu6$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the License);
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an AS IS BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
function applyActivation(e,t,n,r,i){if("linear"===n)return identity$3({inputs:{x:t},backend:e});if("relu"===n)return relu$1({inputs:{x:t},backend:e});if("elu"===n)return elu$1({inputs:{x:t},backend:e});if("relu6"===n)return relu6$1({inputs:{x:t},backend:e});if("prelu"===n)return prelu$1({inputs:{x:t,alpha:r},backend:e});if("leakyrelu"===n)return leakyRelu$1({inputs:{x:t},backend:e,attrs:{alpha:i}});throw new Error(`Activation ${n} has not been implemented for the CPU backend.`)}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function reshape$1(e){const{inputs:t,backend:n,attrs:r}=e,{x:i}=t,{shape:a}=r,o=sizeFromShape(i.shape),s=inferFromImplicitShape(a,o),l=sizeFromShape(s);assert$1(o===l,(()=>`The new shape (${s}) has ${l} elements and the old shape (${i.shape}) has ${o} elements. The new shape and old shape must have the same number of elements.`)),n.incRef(i.dataId);const c=n.data.get(i.dataId);if(null!=c.complexTensorInfos){const e=c.complexTensorInfos.imag;c.complexTensorInfos.real.shape=s,e.shape=s}return{dataId:i.dataId,shape:s,dtype:i.dtype}}const reshapeConfig$1={kernelName:Reshape,backendName:"cpu",kernelFunc:reshape$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the License);
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an AS IS BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function batchMatMul$1(e){const{inputs:t,backend:n,attrs:r}=e,{a:i,b:a}=t,{transposeA:o,transposeB:s}=r;assertNotComplex$1([i,a],"matMul");const l=i.shape.length,c=a.shape.length,h=o?i.shape[l-2]:i.shape[l-1],u=s?a.shape[c-1]:a.shape[c-2],d=o?i.shape[l-1]:i.shape[l-2],p=s?a.shape[c-2]:a.shape[c-1],m=i.shape.slice(0,-2),f=a.shape.slice(0,-2),g=sizeFromShape(m),v=sizeFromShape(f);assert$1(l>=2&&c>=2&&(g===v||1===g||1===v),(()=>`Error in matMul: the input batch dimensions must either be the same or at least one input batch dimension must be 1. Got input batch dimensions of (${m}) and (${f}).`));const y=(g>v?i.shape.slice(0,-2):a.shape.slice(0,-2)).concat([d,p]);assert$1(h===u,(()=>`Error in matMul: inner shapes (${h}) and (${u}) of Tensors with shapes ${i.shape} and ${a.shape} and transposeA=${o} and transposeB=${s} must match.`));const _=s?[v,p,u]:[v,u,p],b=reshape$1({inputs:{x:i},backend:n,attrs:{shape:o?[g,h,d]:[g,d,h]}}),x=reshape$1({inputs:{x:a},backend:n,attrs:{shape:_}}),S=o?b.shape[1]:b.shape[2],w=o?b.shape[2]:b.shape[1],C=s?x.shape[1]:x.shape[2],M=Math.max(g,v),E=n.data.get(b.dataId).values,T=n.data.get(x.dataId).values,I=computeStrides(b.shape),A=computeStrides(x.shape),[k,P,R]=o?[I[0],1,I[1]]:[I[0],I[1],1],[N,L,D]=s?[1,A[1],A[0]]:[A[1],1,A[0]],$=w*C,z=buffer([M,w,C],b.dtype),F=z.values,O=n.blockSize;for(let e=0;e<M;e++)for(let t=0;t<w;t+=O)for(let n=0;n<C;n+=O)for(let r=0;r<S;r+=O){const i=Math.min(t+O,w),a=Math.min(n+O,C),o=Math.min(r+O,S);for(let s=t;s<i;s++)for(let t=n;t<a;t++){let n=0;for(let i=r;i<o;i++){const r=Math.min(e,g-1)*k,a=Math.min(e,v-1)*D;n+=E[r+s*P+i*R]*T[i*N+t*L+a]}F[e*$+(s*C+t)]+=n}}return n.disposeIntermediateTensorInfo(b),n.disposeIntermediateTensorInfo(x),n.makeTensorInfo(y,z.dtype,z.values)}const batchMatMulConfig$1={kernelName:BatchMatMul,backendName:"cpu",kernelFunc:batchMatMul$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the License);
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an AS IS BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function _fusedMatMul$1(e){const{inputs:t,backend:n,attrs:r}=e,{a:i,b:a,bias:o,preluActivationWeights:s}=t,{transposeA:l,transposeB:c,activation:h,leakyreluAlpha:u}=r;let d,p,m;const f=[];d=batchMatMul$1({inputs:{a:i,b:a},attrs:{transposeA:l,transposeB:c},backend:n}),o&&(p=add({inputs:{a:d,b:o},backend:n}),f.push(d),d=p),h&&(m=applyActivation(n,d,h,s,u),f.push(d),d=m);for(const e of f)n.disposeIntermediateTensorInfo(e);return d}const _fusedMatMulConfig$1={kernelName:_FusedMatMul,backendName:"cpu",kernelFunc:_fusedMatMul$1},acos$1=unaryKernelFunc$1(Acos,(e=>Math.acos(e))),acosConfig$1={kernelName:Acos,backendName:"cpu",kernelFunc:acos$1},acosh$1=unaryKernelFunc$1(Acosh,(e=>Math.acosh(e))),acoshConfig$1={kernelName:Acosh,backendName:"cpu",kernelFunc:acosh$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the License);
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an AS IS BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
function addN$1(e){const{inputs:t,backend:n}=e,r=t;assertNotComplex$1(t,"addN");const i=r.map((e=>n.data.get(e.dataId).values)),a=buffer(r[0].shape,r[0].dtype),o=a.values;for(let e=0;e<r.length;e++){const t=i[e];for(let e=0;e<o.length;e++)o[e]+=t[e]}return n.makeTensorInfo(a.shape,a.dtype,a.values)}const addNConfig$1={kernelName:AddN,backendName:"cpu",kernelFunc:addN$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function all$1(e){const{inputs:t,backend:n,attrs:r}=e,{x:i}=t,{axis:a,keepDims:o}=r;assertNotComplex$1(i,"all");const s=parseAxisParam(a,i.shape);let l=s;const c=getAxesPermutation(l,i.shape.length);let h=i;null!=c&&(h=transpose$1({inputs:{x:i},backend:n,attrs:{perm:c}}),l=getInnerMostAxes(l.length,i.shape.length)),assertAxesAreInnerMostDims("all",l,h.shape.length);const[u,d]=computeOutAndReduceShapes(h.shape,l),p=sizeFromShape(d),m=makeZerosTypedArray(sizeFromShape(u),h.dtype),f=n.data.get(h.dataId).values;for(let e=0;e<m.length;++e){const t=e*p;let n=f[t];for(let e=0;e<p;++e){const r=f[t+e];n=n&&r}m[e]=n}null!=c&&n.disposeIntermediateTensorInfo(h);const g=n.makeTensorInfo(u,h.dtype,m);if(o){const e=reshape$1({inputs:{x:g},backend:n,attrs:{shape:expandShapeToKeepDim(u,s)}});return n.disposeIntermediateTensorInfo(g),e}return g}const allConfig$1={kernelName:All,backendName:"cpu",kernelFunc:all$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function any$1(e){const{inputs:t,backend:n,attrs:r}=e,{x:i}=t,{axis:a,keepDims:o}=r;assertNotComplex$1(i,"any");const s=parseAxisParam(a,i.shape);let l=s;const c=getAxesPermutation(l,i.shape.length);let h=i;null!=c&&(h=transpose$1({inputs:{x:i},backend:n,attrs:{perm:c}}),l=getInnerMostAxes(l.length,i.shape.length)),assertAxesAreInnerMostDims("any",l,h.shape.length);const[u,d]=computeOutAndReduceShapes(h.shape,l),p=sizeFromShape(d),m=makeZerosTypedArray(sizeFromShape(u),h.dtype),f=n.data.get(h.dataId).values;for(let e=0;e<m.length;++e){const t=e*p;let n=f[t];for(let e=0;e<p;++e){const r=f[t+e];n=n||r}m[e]=n}null!=c&&n.disposeIntermediateTensorInfo(h);const g=n.makeTensorInfo(u,h.dtype,m);if(o){const e=reshape$1({inputs:{x:g},backend:n,attrs:{shape:expandShapeToKeepDim(u,s)}});return n.disposeIntermediateTensorInfo(g),e}return g}const anyConfig$1={kernelName:Any,backendName:"cpu",kernelFunc:any$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function argMax$1(e){const{inputs:t,backend:n,attrs:r}=e,{x:i}=t,{axis:a}=r;assertNotComplex$1(i,"argMax");let o=parseAxisParam(a,i.shape);const s=getAxesPermutation(o,i.shape.length);let l=i;const c=[];null!=s&&(l=transpose$1({inputs:{x:i},backend:n,attrs:{perm:s}}),c.push(l),o=getInnerMostAxes(o.length,l.shape.length)),o=[o[0]],assertAxesAreInnerMostDims("argMax",o,l.shape.length);const[h,u]=computeOutAndReduceShapes(l.shape,o),d=makeZerosTypedArray(sizeFromShape(h),"int32"),p=sizeFromShape(u),m=n.data.get(l.dataId).values;for(let e=0;e<d.length;++e){const t=e*p;let n=m[t],r=0;for(let e=0;e<p;++e){const i=m[t+e];i>n&&(n=i,r=e)}d[e]=r}return c.forEach((e=>n.disposeIntermediateTensorInfo(e))),n.makeTensorInfo(h,"int32",d)}const argMaxConfig$1={kernelName:ArgMax,backendName:"cpu",kernelFunc:argMax$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function argMin$1(e){const{inputs:t,backend:n,attrs:r}=e,{x:i}=t,{axis:a}=r;assertNotComplex$1(i,"argMin");let o=parseAxisParam(a,i.shape);const s=getAxesPermutation(o,i.shape.length);let l=i;const c=[];null!=s&&(l=transpose$1({inputs:{x:i},backend:n,attrs:{perm:s}}),c.push(l),o=getInnerMostAxes(o.length,l.shape.length)),o=[o[0]],assertAxesAreInnerMostDims("argMin",o,l.shape.length);const[h,u]=computeOutAndReduceShapes(l.shape,o),d=makeZerosTypedArray(sizeFromShape(h),"int32"),p=sizeFromShape(u),m=n.data.get(l.dataId).values;for(let e=0;e<d.length;++e){const t=e*p;let n=m[t],r=0;for(let e=0;e<p;++e){const i=m[t+e];i<n&&(n=i,r=e)}d[e]=r}return c.forEach((e=>n.disposeIntermediateTensorInfo(e))),n.makeTensorInfo(h,"int32",d)}const argMinConfig$1={kernelName:ArgMin,backendName:"cpu",kernelFunc:argMin$1},asin$1=unaryKernelFunc$1(Asin,(e=>Math.asin(e))),asinConfig$1={kernelName:Asin,backendName:"cpu",kernelFunc:asin$1},asinh$1=unaryKernelFunc$1(Asinh,(e=>Math.asinh(e))),asinhConfig$1={kernelName:Asinh,backendName:"cpu",kernelFunc:asinh$1},atan$1=unaryKernelFunc$1(Atan,(e=>Math.atan(e))),atanConfig$1={kernelName:Atan,backendName:"cpu",kernelFunc:atan$1},atan2Impl=createSimpleBinaryKernelImpl(((e,t)=>Math.atan2(e,t))),atan2$1=binaryKernelFunc$1(Atan2,atan2Impl),atan2Config$1={kernelName:Atan2,backendName:"cpu",kernelFunc:atan2$1},atanh$1=unaryKernelFunc$1(Atanh,(e=>Math.atanh(e))),atanhConfig$1={kernelName:Atanh,backendName:"cpu",kernelFunc:atanh$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the License);
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an AS IS BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
function pool(e,t,n,r,i,a){const o=i.strideHeight,s=i.strideWidth,l=i.dilationHeight,c=i.dilationWidth,h=i.effectiveFilterHeight,u=i.effectiveFilterWidth,d=i.padInfo.top,p=i.padInfo.left,m="max"===a?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,f=buffer(i.outShape,n),g=f.values,v=i.outShape[1]*i.outShape[2]*i.outShape[3],y=i.outShape[2]*i.outShape[3],_=i.outShape[3];for(let t=0;t<i.batchSize;++t){const n=t*v,f=t*r[0];for(let t=0;t<i.inChannels;++t)for(let v=0;v<i.outHeight;++v){const b=v*o-d,x=Math.max(0,b),S=Math.min(i.inHeight,h+b),w=n+v*y;for(let n=0;n<i.outWidth;++n){const o=n*s-p,h=Math.max(0,o),d=Math.min(i.inWidth,u+o);let v=m,y=0,b=0;for(let n=x;n<S;n+=l){const i=f+n*r[1];for(let n=h;n<d;n+=c){const o=e[i+n*r[2]+t];"max"===a&&o>v?v=o:"avg"===a&&(y+=o,b++)}if(isNaN(v))break}g[w+n*_+t]="avg"===a?y/b:v}}}return f}function maxPoolPositions(e,t,n,r,i=!1,a=!1){const o=buffer(r.outShape,"int32"),s=r.strideHeight,l=r.strideWidth,c=r.dilationHeight,h=r.dilationWidth,u=r.effectiveFilterHeight,d=r.effectiveFilterWidth,p=r.padInfo.top,m=r.padInfo.left,f=buffer(t,n,e);for(let e=0;e<r.batchSize;++e)for(let t=0;t<r.inChannels;++t)for(let n=0;n<r.outHeight;++n){const g=n*s-p;let v=g;for(;v<0;)v+=c;const y=Math.min(r.inHeight,u+g);for(let s=0;s<r.outWidth;++s){const u=s*l-m;let p=u;for(;p<0;)p+=h;const _=Math.min(r.inWidth,d+u);let b=Number.NEGATIVE_INFINITY,x=-1;for(let n=v;n<y;n+=c){const o=n-g;for(let s=p;s<_;s+=h){const l=s-u,c=f.get(e,n,s,t);c>b&&(b=c,x=i?a?((e*r.inHeight+n)*r.inWidth+s)*r.inChannels+t:(n*r.inWidth+s)*r.inChannels+t:o*d+l)}}o.set(x,e,n,s,t)}}return o}function pool3d(e,t,n,r,i,a){const o=i.strideDepth,s=i.strideHeight,l=i.strideWidth,c=i.dilationDepth,h=i.dilationHeight,u=i.dilationWidth,d=i.effectiveFilterDepth,p=i.effectiveFilterHeight,m=i.effectiveFilterWidth,f=i.padInfo.front,g=i.padInfo.top,v=i.padInfo.left,y="max"===a?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,_=buffer(i.outShape,n),b=_.values,x=i.outShape[1]*i.outShape[2]*i.outShape[3]*i.outShape[4],S=i.outShape[2]*i.outShape[3]*i.outShape[4],w=i.outShape[3]*i.outShape[4],C=i.outShape[4];for(let t=0;t<i.batchSize;++t){const n=t*x,_=t*r[0];for(let t=0;t<i.inChannels;++t)for(let x=0;x<i.outDepth;++x){const M=x*o-f;let E=M;for(;E<0;)E+=c;const T=Math.min(i.inDepth,d+M),I=n+x*S;for(let n=0;n<i.outHeight;++n){const o=n*s-g;let d=o;for(;d<0;)d+=h;const f=Math.min(i.inHeight,p+o),x=I+n*w;for(let n=0;n<i.outWidth;++n){const o=n*l-v;let s=o;for(;s<0;)s+=u;const p=Math.min(i.inWidth,m+o),g=x+n*C;let S=y,w=0,M=0;for(let n=E;n<T;n+=c){const i=_+n*r[1];for(let n=d;n<f;n+=h){const o=i+n*r[2];for(let n=s;n<p;n+=u){const i=e[o+n*r[3]+t];if("max"===a&&i>S?S=i:"avg"===a&&(w+=i,M++),isNaN(S))break}if(isNaN(S))break}if(isNaN(S))break}b[g+t]="avg"===a?w/M:S}}}}return _}function maxPool3dPositions(e,t){const n=buffer(t.outShape,"int32"),r=t.strideDepth,i=t.strideHeight,a=t.strideWidth,o=t.dilationDepth,s=t.dilationHeight,l=t.dilationWidth,c=t.effectiveFilterDepth,h=t.effectiveFilterHeight,u=t.effectiveFilterWidth,d=t.padInfo.front,p=t.padInfo.top,m=t.padInfo.left;for(let f=0;f<t.batchSize;++f)for(let g=0;g<t.inChannels;++g)for(let v=0;v<t.outDepth;++v){const y=v*r-d;let _=y;for(;_<0;)_+=o;const b=Math.min(t.inDepth,c+y);for(let r=0;r<t.outHeight;++r){const c=r*i-p;let d=c;for(;d<0;)d+=s;const x=Math.min(t.inHeight,h+c);for(let i=0;i<t.outWidth;++i){const p=i*a-m;let S=p;for(;S<0;)S+=l;const w=Math.min(t.inWidth,u+p);let C=Number.NEGATIVE_INFINITY,M=-1;for(let t=_;t<b;t+=o){const n=t-y;for(let r=d;r<x;r+=s){const i=r-c;for(let a=S;a<w;a+=l){const o=a-p,s=e.get(f,t,r,a,g);s>=C&&(C=s,M=n*h*u+i*h+o)}}}n.set(M,f,v,r,i,g)}}}return n}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function avgPool$1(e){const{inputs:t,backend:n,attrs:r}=e,{x:i}=t;assertNotComplex$1(i,"avgPool");const{filterSize:a,strides:o,pad:s,dimRoundingMode:l}=r;assert$1(eitherStridesOrDilationsAreOne(o,1),(()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${o} and dilations '1'`));const c=computePool2DInfo(i.shape,a,o,1,s,l);let h;if(1===c.filterWidth&&1===c.filterHeight&&arraysEqual$1(c.inShape,c.outShape))h=identity$3({inputs:{x:i},backend:n});else{const e=n.data.get(i.dataId).values,t=computeStrides(i.shape),r=pool(e,i.shape,i.dtype,t,c,"avg");h=n.makeTensorInfo(c.outShape,i.dtype,r.values)}return h}const avgPoolConfig$1={kernelName:AvgPool,backendName:"cpu",kernelFunc:avgPool$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function avgPool3D$1(e){const{inputs:t,backend:n,attrs:r}=e,{x:i}=t,{filterSize:a,strides:o,pad:s,dimRoundingMode:l,dataFormat:c}=r;assertNotComplex$1(i,"avgPool3d");const h=computePool3DInfo(i.shape,a,o,1,s,l,c),u=pool3d(n.data.get(i.dataId).values,i.shape,i.dtype,computeStrides(i.shape),h,"avg");return n.makeTensorInfo(u.shape,"float32",u.values)}const avgPool3DConfig$1={kernelName:AvgPool3D,backendName:"cpu",kernelFunc:avgPool3D$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function avgPool3DGrad$1(e){const{inputs:t,backend:n,attrs:r}=e,{dy:i,input:a}=t,{filterSize:o,strides:s,pad:l,dimRoundingMode:c}=r;assertNotComplex$1([i,a],"avgPool3DGrad");const h=computePool3DInfo(a.shape,o,s,1,l,c),u=h.strideDepth,d=h.strideHeight,p=h.strideWidth,m=h.filterDepth,f=h.filterHeight,g=h.filterWidth,v=h.dilationDepth,y=h.dilationHeight,_=h.dilationWidth,b=h.effectiveFilterDepth,x=h.effectiveFilterHeight,S=h.effectiveFilterWidth,w=b-1-h.padInfo.front,C=S-1-h.padInfo.left,M=x-1-h.padInfo.top,E=buffer(a.shape,"float32"),T=1/(m*f*g),I=n.bufferSync(i);for(let e=0;e<h.batchSize;++e)for(let t=0;t<h.inChannels;++t)for(let n=0;n<h.inDepth;++n)for(let r=0;r<h.inHeight;++r)for(let i=0;i<h.inWidth;++i){const a=n-w,o=r-M,s=i-C;let l=0;for(let n=0;n<b;n+=v){const r=(a+n)/u;if(!(r<0||r>=h.outDepth||Math.floor(r)!==r))for(let n=0;n<x;n+=y){const i=(o+n)/d;if(!(i<0||i>=h.outHeight||Math.floor(i)!==i))for(let n=0;n<S;n+=_){const a=(s+n)/p;if(a<0||a>=h.outWidth||Math.floor(a)!==a)continue;l+=I.get(e,r,i,a,t)}}}E.set(l*T,e,n,r,i,t)}return n.makeTensorInfo(E.shape,E.dtype,E.values)}const avgPool3DGradConfig={kernelName:AvgPool3DGrad,backendName:"cpu",kernelFunc:avgPool3DGrad$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function avgPoolGrad$1(e){const{inputs:t,backend:n,attrs:r}=e,{dy:i,input:a}=t,o=a;assertNotComplex$1([i,a],"avgPoolGrad");const{filterSize:s,strides:l,pad:c}=r,h=computePool2DInfo(o.shape,s,l,1,c),u=h.strideHeight,d=h.strideWidth,p=h.filterHeight,m=h.filterWidth,f=h.dilationHeight,g=h.dilationWidth,v=h.effectiveFilterHeight,y=h.effectiveFilterWidth,_=y-1-h.padInfo.left,b=v-1-h.padInfo.top,x=buffer(o.shape,"float32"),S=1/(p*m),w=n.data.get(i.dataId).values,C=buffer(i.shape,"float32",w);for(let e=0;e<h.batchSize;++e)for(let t=0;t<h.inChannels;++t)for(let n=0;n<h.inHeight;++n)for(let r=0;r<h.inWidth;++r){const i=n-b,a=r-_;let o=0;for(let n=0;n<v;n+=f){const r=(i+n)/u;if(!(r<0||r>=h.outHeight||Math.floor(r)!==r))for(let n=0;n<y;n+=g){const i=(a+n)/d;if(i<0||i>=h.outWidth||Math.floor(i)!==i)continue;o+=C.get(e,r,i,t)}}x.set(o*S,e,n,r,t)}return n.makeTensorInfo(x.shape,x.dtype,x.values)}const avgPoolGradConfig$1={kernelName:AvgPoolGrad,backendName:"cpu",kernelFunc:avgPoolGrad$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function batchNorm$1(e){const{inputs:t,backend:n,attrs:r}=e,{x:i,scale:a,offset:o,mean:s,variance:l}=t;assert$1(s.shape.length===l.shape.length,(()=>"Batch normalization gradient requires mean and variance to have equal ranks.")),assert$1(null==o||s.shape.length===o.shape.length,(()=>"Batch normalization gradient requires mean and offset to have equal ranks.")),assert$1(null==a||s.shape.length===a.shape.length,(()=>"Batch normalization gradient requires mean and scale to have equal ranks.")),assertNotComplex$1([i,s,l,a,o],"batchNorm");let{varianceEpsilon:c}=r;null==c&&(c=.001);const h=n.data.get(i.dataId).values,u=n.data.get(s.dataId).values,d=n.data.get(l.dataId).values,p=a?n.data.get(a.dataId).values:new Float32Array([1]),m=o?n.data.get(o.dataId).values:new Float32Array([0]),f=new Float32Array(h.length),g=m.length,v=p.length,y=d.length,_=u.length;let b=0,x=0,S=0,w=0;for(let e=0;e<h.length;++e)f[e]=m[b++]+(h[e]-u[x++])*p[S++]/Math.sqrt(d[w++]+c),b>=g&&(b=0),x>=_&&(x=0),S>=v&&(S=0),w>=y&&(w=0);return n.makeTensorInfo(i.shape,i.dtype,f)}const batchNormConfig$1={kernelName:FusedBatchNorm,backendName:"cpu",kernelFunc:batchNorm$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function batchToSpaceND$1(e){const{inputs:t,backend:n,attrs:r}=e,{x:i}=t,{blockShape:a,crops:o}=r;assertNotComplex$1([i],"batchToSpaceND");const s=a.reduce(((e,t)=>e*t)),l=getReshaped(i.shape,a,s),c=getPermuted(l.length,a.length),h=getReshapedPermuted(i.shape,a,s),u=getSliceBeginCoords(o,a.length),d=getSliceSize(h,o,a.length),p=reshape$1({inputs:{x:i},backend:n,attrs:{shape:l}}),m=transpose$1({inputs:{x:p},backend:n,attrs:{perm:c}}),f=reshape$1({inputs:{x:m},backend:n,attrs:{shape:h}}),g=slice$2({inputs:{x:f},backend:n,attrs:{begin:u,size:d}});return n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(m),n.disposeIntermediateTensorInfo(f),g}const batchToSpaceNDConfig$1={kernelName:BatchToSpaceND,backendName:"cpu",kernelFunc:batchToSpaceND$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function bincount$1(e){const{inputs:t,backend:n,attrs:r}=e,{x:i,weights:a}=t,{size:o}=r,s=bincountImpl(n.data.get(i.dataId).values,n.data.get(a.dataId).values,a.dtype,a.shape,o);return n.makeTensorInfo([o],a.dtype,s)}const bincountConfig$1={kernelName:Bincount,backendName:"cpu",kernelFunc:bincount$1},clip=unaryKernelFunc$1(ClipByValue,((e,t)=>e>t.clipValueMax?t.clipValueMax:e<t.clipValueMin?t.clipValueMin:e)),clipConfig={kernelName:ClipByValue,backendName:"cpu",kernelFunc:clip},complexAbs$1=e=>{const{x:t}=e.inputs,n=e.backend,r=new Float32Array(sizeFromShape(t.shape)),i=n.data.get(t.dataId),a=i.complexTensorInfos.imag,o=n.data.get(i.complexTensorInfos.real.dataId).values,s=n.data.get(a.dataId).values;for(let e=0;e<o.length;e++){r[e]=Math.hypot(o[e],s[e])}return n.makeOutput(r,t.shape,"float32")},complexAbsConfig$1={kernelName:ComplexAbs,backendName:"cpu",kernelFunc:complexAbs$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the License);
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an AS IS BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
function imag$1(e){const{inputs:t,backend:n}=e,{input:r}=t,i=n.data.get(r.dataId).complexTensorInfos.imag,a=n.data.get(i.dataId).values;return n.makeTensorInfo(i.shape,i.dtype,a)}const imagConfig$1={kernelName:Imag,backendName:"cpu",kernelFunc:imag$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function concat$1(e){const{inputs:t,backend:n,attrs:r}=e,{axis:i}=r,a=parseAxisParam(i,t[0].shape)[0];let o=computeOutShape$1(t.map((e=>e.shape)),a);if(0===sizeFromShape(o))return n.makeTensorInfo(o,t[0].dtype,[]);const s=t.filter((e=>sizeFromShape(e.shape)>0));if(1===s.length)return identity$3({inputs:{x:s[0]},backend:n});if(assertParamsConsistent(s.map((e=>e.shape)),a),"complex64"===s[0].dtype){const e=s.map((e=>real$1({inputs:{input:e},backend:n}))),t=s.map((e=>imag$1({inputs:{input:e},backend:n}))),r=concat$1({inputs:e,backend:n,attrs:{axis:a}}),i=concat$1({inputs:t,backend:n,attrs:{axis:a}}),o=complex$1({inputs:{real:r,imag:i},backend:n});return e.forEach((e=>n.disposeIntermediateTensorInfo(e))),t.forEach((e=>n.disposeIntermediateTensorInfo(e))),n.disposeIntermediateTensorInfo(r),n.disposeIntermediateTensorInfo(i),o}const l=s.map((e=>{const t=sizeFromShape(e.shape.slice(a));return reshape$1({inputs:{x:e},backend:n,attrs:{shape:[-1,t]}})})),c=l.map((e=>({vals:n.data.get(e.dataId).values,shape:e.shape})));o=computeOutShape$1(l.map((e=>e.shape)),1);const h=concatImpl$1(c,o,t[0].dtype,1===l[0].shape[0]),u=computeOutShape$1(s.map((e=>e.shape)),a),d=n.makeTensorInfo(u,t[0].dtype,h);return l.forEach((e=>n.disposeIntermediateTensorInfo(e))),d}const concatConfig$1={kernelName:Concat,backendName:"cpu",kernelFunc:concat$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function conv2D(e){const{inputs:t,backend:n,attrs:r}=e,{x:i,filter:a}=t,{strides:o,pad:s,dataFormat:l,dilations:c,dimRoundingMode:h}=r;assertNotComplex$1([i,a],"conv2d");const u=convertConv2DDataFormat(l),d=computeConv2DInfo(i.shape,a.shape,o,c,s,h,!1,u),p=d.filterHeight,m=d.filterWidth,f=d.dilationHeight,g=d.dilationWidth,v=d.padInfo.left,y=d.padInfo.top,_="channelsLast"===d.dataFormat,b=new TensorBuffer(d.outShape,i.dtype),x=computeStrides(i.shape),S=computeStrides(a.shape),w=x[0],C=_?x[1]:x[2],M=_?x[2]:1,E=_?1:x[1],T=b.strides[0],I=_?b.strides[1]:b.strides[2],A=_?b.strides[2]:1,k=_?1:b.strides[1],P=n.data.get(i.dataId).values,R=n.data.get(a.dataId).values,N=b.values;for(let e=0;e<d.batchSize;++e){const t=e*w,n=e*T;for(let e=0;e<d.outHeight;++e){const r=n+e*I,i=e*d.strideHeight-y;for(let e=0;e<p;++e){const n=i+e*f;if(n<0||n>=d.inHeight)continue;const a=e*S[0],o=t+n*C;for(let e=0;e<d.outWidth;++e){const t=r+e*A,n=e*d.strideWidth-v;for(let e=0;e<m;++e){const r=n+e*g;if(r<0||r>=d.inWidth)continue;const i=o+r*M;let s=a+e*S[1];for(let e=0;e<d.inChannels;++e){const n=P[i+e*E];for(let e=0;e<d.outChannels;++e)N[t+e*k]+=n*R[s+e];s+=d.outChannels}}}}}}return n.makeTensorInfo(b.shape,b.dtype,N)}const conv2DConfig$1={kernelName:Conv2D,backendName:"cpu",kernelFunc:conv2D};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function conv2DBackpropFilter$1(e){const{inputs:t,backend:n,attrs:r}=e,{x:i,dy:a}=t,{strides:o,pad:s,dataFormat:l,dimRoundingMode:c,filterShape:h}=r;assertNotComplex$1([i,a],"conv2dBackpropFilter");const u=convertConv2DDataFormat(l),d=computeConv2DInfo(i.shape,h,o,1,s,c,!1,u),{strideHeight:p,strideWidth:m,filterHeight:f,filterWidth:g}=d,v="channelsLast"===d.dataFormat,y=new TensorBuffer(d.filterShape,"float32"),_=d.padInfo.left,b=d.padInfo.top,x=n.data.get(i.dataId).values,S=n.data.get(a.dataId).values,w=new TensorBuffer(i.shape,i.dtype,x),C=new TensorBuffer(a.shape,a.dtype,S);for(let e=0;e<f;++e){const t=Math.max(0,Math.ceil((b-e)/p)),n=Math.min(d.outHeight,(d.inHeight+b-e)/p);for(let r=0;r<g;++r){const i=Math.max(0,Math.ceil((_-r)/m)),a=Math.min(d.outWidth,(d.inWidth+_-r)/m);for(let o=0;o<d.inChannels;++o)for(let s=0;s<d.outChannels;++s){let l=0;for(let c=0;c<d.batchSize;++c)for(let h=t;h<n;++h){const t=e+h*p-b;for(let e=i;e<a;++e){const n=r+e*m-_;l+=v?w.get(c,t,n,o)*C.get(c,h,e,s):w.get(c,o,t,n)*C.get(c,s,h,e)}}y.set(l,e,r,o,s)}}}return n.makeTensorInfo(y.shape,y.dtype,y.values)}const conv2DBackpropFilterConfig$1={kernelName:Conv2DBackpropFilter,backendName:"cpu",kernelFunc:conv2DBackpropFilter$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function conv2DBackpropInput$1(e){const{inputs:t,backend:n,attrs:r}=e,{dy:i,filter:a}=t,{inputShape:o,strides:s,pad:l,dataFormat:c,dimRoundingMode:h}=r;assertNotComplex$1([i,a],"conv2dBackpropInput");const u=computeStrides(a.shape),d=computeStrides(i.shape);let p=convertConv2DDataFormat(c);const m=computeConv2DInfo(o,a.shape,s,1,l,h,!1,p),f=new TensorBuffer(m.inShape,"float32"),g=f.values,v=n.data.get(i.dataId).values,y=n.data.get(a.dataId).values,[_,b,x]=u,{batchSize:S,filterHeight:w,filterWidth:C,inChannels:M,inHeight:E,inWidth:T,outChannels:I,outHeight:A,outWidth:k,strideHeight:P,strideWidth:R}=m;p=m.dataFormat;const N=w-1-m.padInfo.top,L=C-1-m.padInfo.left,D="channelsLast"===p,$=f.strides[0],z=D?f.strides[1]:f.strides[2],F=D?f.strides[2]:1,O=D?1:f.strides[1],B=d[0],V=D?d[1]:d[2],H=D?d[2]:1,U=D?1:d[1];for(let e=0;e<S;++e)for(let t=0;t<M;++t)for(let n=0;n<E;++n){const r=n-N,i=Math.max(0,Math.ceil(r/P)),a=Math.min(A,(w+r)/P);for(let o=0;o<T;++o){const s=o-L,l=Math.max(0,Math.ceil(s/R)),c=Math.min(k,(C+s)/R);let h=0;for(let n=i;n<a;++n){const i=n*P-r;for(let r=l;r<c;++r){const a=B*e+V*n+H*r,o=_*(w-1-i)+b*(C-1-(r*R-s))+x*t;for(let e=0;e<I;++e){h+=v[a+U*e]*y[o+e]}}}g[$*e+z*n+F*o+O*t]=h}}return n.makeTensorInfo(f.shape,f.dtype,f.values)}const conv2DBackpropInputConfig$1={kernelName:Conv2DBackpropInput,backendName:"cpu",kernelFunc:conv2DBackpropInput$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function conv3D$1(e){const{inputs:t,backend:n,attrs:r}=e,{x:i,filter:a}=t,{strides:o,pad:s,dilations:l}=r;assertNotComplex$1([i,a],"conv3d");const c=computeConv3DInfo(i.shape,a.shape,o,l,s),{filterDepth:h,filterHeight:u,filterWidth:d,dilationDepth:p,dilationHeight:m,dilationWidth:f,padInfo:g}=c,v=g.front,y=g.left,_=g.top,b=new TensorBuffer(c.outShape,i.dtype),x=n.data.get(i.dataId).values,S=n.data.get(a.dataId).values,w=b.values,C=computeStrides(i.shape),M=computeStrides(a.shape);for(let e=0;e<c.batchSize;++e){const t=e*C[0],n=e*b.strides[0];for(let e=0;e<c.outDepth;++e){const r=n+e*b.strides[1],i=e*c.strideDepth-v;for(let e=0;e<h;++e){const n=i+e*p;if(n<0||n>=c.inDepth)continue;const a=e*M[0],o=t+n*C[1];for(let e=0;e<c.outHeight;++e){const t=r+e*b.strides[2],n=e*c.strideHeight-_;for(let e=0;e<u;++e){const r=n+e*m;if(r<0||r>=c.inHeight)continue;const i=a+e*M[1],s=o+r*C[2];for(let e=0;e<c.outWidth;++e){const n=t+e*c.outChannels,r=e*c.strideWidth-y;for(let e=0;e<d;++e){const t=r+e*f;if(t<0||t>=c.inWidth)continue;const a=s+t*c.inChannels;let o=i+e*M[2];for(let e=0;e<c.inChannels;++e){const t=x[a+e];for(let e=0;e<c.outChannels;++e)w[n+e]+=t*S[o+e];o+=c.outChannels}}}}}}}}return n.makeTensorInfo(b.shape,b.dtype,b.values)}const conv3DConfig$1={kernelName:Conv3D,backendName:"cpu",kernelFunc:conv3D$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function conv3DBackpropFilterV2$1(e){const{inputs:t,backend:n,attrs:r}=e,{x:i,dy:a}=t,{strides:o,pad:s,filterShape:l}=r;assertNotComplex$1([i,a],"conv3dBackpropFilterV2");const c=computeStrides(i.shape),h=computeStrides(a.shape),u=computeConv3DInfo(i.shape,l,o,1,s),d=u.strideDepth,p=u.strideHeight,m=u.strideWidth,f=u.filterDepth,g=u.filterHeight,v=u.filterWidth,y=new TensorBuffer(u.filterShape,"float32"),_=y.values,[b,x,S,w]=y.strides,C=n.data.get(a.dataId).values,[M,E,T,I]=h,A=n.data.get(i.dataId).values,[k,P,R,N]=c,L=u.padInfo.front,D=u.padInfo.left,$=u.padInfo.top;for(let e=0;e<f;++e){const t=Math.max(0,Math.ceil((L-e)/d)),n=Math.min(u.outDepth,(u.inDepth+L-e)/d),r=e*b;for(let i=0;i<g;++i){const a=Math.max(0,Math.ceil(($-i)/p)),o=Math.min(u.outHeight,(u.inHeight+$-i)/p),s=i*x+r;for(let r=0;r<v;++r){const l=Math.max(0,Math.ceil((D-r)/m)),c=Math.min(u.outWidth,(u.inWidth+D-r)/m),h=r*S+s;for(let s=0;s<u.inChannels;++s){const f=s*w+h;for(let h=0;h<u.outChannels;++h){let g=0;for(let f=0;f<u.batchSize;++f){const u=f*k,v=f*M;for(let f=t;f<n;++f){const t=(e+f*d-L)*P+u,n=f*E+v;for(let e=a;e<o;++e){const a=(i+e*p-$)*R+t,o=e*T+n;for(let e=l;e<c;++e){g+=A[(r+e*m-D)*N+a+s]*C[e*I+o+h]}}}}_[f+h]=g}}}}}return n.makeTensorInfo(y.shape,y.dtype,y.values)}const conv3DBackpropFilterV2Config$1={kernelName:Conv3DBackpropFilterV2,backendName:"cpu",kernelFunc:conv3DBackpropFilterV2$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function conv3DBackpropInputV2(e){const{inputs:t,backend:n,attrs:r}=e,{dy:i,filter:a}=t,{pad:o,strides:s,inputShape:l}=r;assertNotComplex$1([i],"conv3dBackpropInputV2");const c=computeStrides(i.shape),h=computeStrides(a.shape),u=computeConv3DInfo(l,a.shape,s,1,o),d=new TensorBuffer(u.inShape,"float32"),p=d.values,[m,f,g,v]=d.strides,y=n.data.get(i.dataId).values,[_,b,x,S]=c,w=n.data.get(a.dataId).values,[C,M,E,T]=h,{batchSize:I,filterDepth:A,filterHeight:k,filterWidth:P,inChannels:R,inDepth:N,inHeight:L,inWidth:D,outChannels:$,outDepth:z,outHeight:F,outWidth:O,strideDepth:B,strideHeight:V,strideWidth:H}=u,U=A-1-u.padInfo.front,G=k-1-u.padInfo.top,W=P-1-u.padInfo.left;for(let e=0;e<I;++e)for(let t=0;t<R;++t)for(let n=0;n<N;++n){const r=n-U,i=Math.max(0,Math.ceil(r/B)),a=Math.min(z,(A+r)/B);for(let o=0;o<L;++o){const s=o-G,l=Math.max(0,Math.ceil(s/V)),c=Math.min(F,(k+s)/V);for(let h=0;h<D;++h){const u=h-W,d=Math.max(0,Math.ceil(u/H)),I=Math.min(O,(P+u)/H);let R=0;for(let n=i;n<a;++n){const i=n*B-r;for(let r=l;r<c;++r){const a=r*V-s;for(let o=d;o<I;++o){const s=_*e+b*n+x*r+S*o,l=C*(A-1-i)+M*(k-1-a)+E*(P-1-(o*H-u))+T*t;for(let e=0;e<$;++e){R+=y[s+e]*w[l+e]}}}}p[m*e+f*n+g*o+v*h+t]=R}}}return n.makeTensorInfo(d.shape,d.dtype,d.values)}const conv3DBackpropInputV2Config={kernelName:Conv3DBackpropInputV2,backendName:"cpu",kernelFunc:conv3DBackpropInputV2},cos$1=unaryKernelFunc$1(Cos,(e=>Math.cos(e))),cosConfig$1={kernelName:Cos,backendName:"cpu",kernelFunc:cos$1},cosh$1=unaryKernelFunc$1(Cosh,(e=>Math.cosh(e))),coshConfig$1={kernelName:Cosh,backendName:"cpu",kernelFunc:cosh$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
function cropAndResize$1(e){const{inputs:t,backend:n,attrs:r}=e,{image:i,boxes:a,boxInd:o}=t,{cropSize:s,method:l,extrapolationValue:c}=r,[h,u,d,p]=i.shape,m=a.shape[0],[f,g]=s,v=buffer([m,f,g,p],"float32"),y=n.data.get(a.dataId).values,_=n.data.get(o.dataId).values,b=n.data.get(i.dataId).values,x=computeStrides(i.shape),S=computeStrides(v.shape);for(let e=0;e<m;e++){const t=4*e,n=y[t],r=y[t+1],i=y[t+2],a=y[t+3],o=_[e];if(o>=h)continue;const s=f>1?(i-n)*(u-1)/(f-1):0,m=g>1?(a-r)*(d-1)/(g-1):0;for(let t=0;t<f;t++){const h=f>1?n*(u-1)+t*s:.5*(n+i)*(u-1);if(h<0||h>u-1)for(let n=0;n<g;n++)for(let r=0;r<p;r++){v.values[r+n*S[2]+t*S[1]+e*S[0]]=c}else if("bilinear"===l){const n=Math.floor(h),i=Math.ceil(h),s=h-n;for(let l=0;l<g;l++){const h=g>1?r*(d-1)+l*m:.5*(r+a)*(d-1);if(h<0||h>d-1){for(let n=0;n<p;n++){v.values[n+l*S[2]+t*S[1]+e*S[0]]=c}continue}const u=Math.floor(h),f=Math.ceil(h),y=h-u;for(let r=0;r<p;r++){let a=r+u*x[2]+n*x[1]+o*x[0];const c=b[a];a=r+f*x[2]+n*x[1]+o*x[0];const h=b[a];a=r+u*x[2]+i*x[1]+o*x[0];const d=b[a];a=r+f*x[2]+i*x[1]+o*x[0];const p=b[a],m=c+(h-c)*y;a=r+l*S[2]+t*S[1]+e*S[0],v.values[a]=m+(d+(p-d)*y-m)*s}}}else for(let n=0;n<g;++n){const i=g>1?r*(d-1)+n*m:.5*(r+a)*(d-1);if(i<0||i>d-1){for(let r=0;r<p;r++){v.values[r+n*S[2]+t*S[1]+e*S[0]]=c}continue}const s=Math.round(i),l=Math.round(h);for(let r=0;r<p;r++){v.values[r+n*S[2]+t*S[1]+e*S[0]]=b[r+s*x[2]+l*x[1]+o*x[0]]}}}}return n.makeTensorInfo(v.shape,v.dtype,v.values)}const cropAndResizeConfig$1={kernelName:CropAndResize,backendName:"cpu",kernelFunc:cropAndResize$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function cumsum$1(e){const{inputs:t,backend:n,attrs:r}=e,{x:i}=t,{axis:a,exclusive:o,reverse:s}=r;assertNotComplex$1(i,"cumsum");const l=getAxesPermutation([a],i.shape.length);let c=i;null!=l&&(c=transpose$1({inputs:{x:i},backend:n,attrs:{perm:l}}));const h=getInnerMostAxes(1,i.shape.length)[0];if(h!==c.shape.length-1)throw new Error(`backend.cumsum in CPU expects an inner-most axis=${c.shape.length-1} but got axis=${h}`);const u=upcastType(c.dtype,"int32"),d=makeZerosTypedArray(sizeFromShape(c.shape),u),p=n.data.get(c.dataId).values,m=c.shape[c.shape.length-1],f=s?(e,t)=>e+m-t-1:(e,t)=>e+t;for(let e=0;e<p.length;e+=m)for(let t=0;t<m;t++){const n=f(e,t);if(0===t)d[n]=o?0:p[n];else{const r=f(e,t-1);d[n]=o?p[r]+d[r]:p[n]+d[r]}}const g=n.makeTensorInfo(c.shape,u,d);if(null!=l){const e=transpose$1({inputs:{x:g},backend:n,attrs:{perm:getUndoAxesPermutation(l)}});return n.disposeIntermediateTensorInfo(g),n.disposeIntermediateTensorInfo(c),e}return g}const cumsumConfig$1={kernelName:Cumsum,backendName:"cpu",kernelFunc:cumsum$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function denseBincount$1(e){const{inputs:t,backend:n,attrs:r}=e,{x:i,weights:a}=t,{size:o,binaryOutput:s}=r;if(1===i.shape.length){const e=bincountImpl(n.data.get(i.dataId).values,n.data.get(a.dataId).values,a.dtype,a.shape,o);return n.makeTensorInfo([o],a.dtype,e)}if(2===i.shape.length){const e=bincountReduceImpl(n.bufferSync(i),n.bufferSync(a),o,s);return n.makeTensorInfo(e.shape,a.dtype,e.values)}throw new Error(`Error in denseBincount: input must be at most rank 2, but got rank${i.shape.length}.`)}const denseBincountConfig$1={kernelName:DenseBincount,backendName:"cpu",kernelFunc:denseBincount$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function depthToSpace$1(e){const{inputs:t,backend:n,attrs:r}=e,{x:i}=t,{blockSize:a,dataFormat:o}=r;assert$1("NHWC"===o,(()=>`Only NHWC dataFormat supported on CPU for depthToSpace. Got ${o}`)),assert$1(a>1,(()=>`blockSize should be > 1 for depthToSpace, but was: ${a}`));const s=i.shape[0],l=i.shape[1],c=i.shape[2],h=i.shape[3],u=l*a,d=c*a,p=h/(a*a),m=n.data.get(i.dataId).values,f=new Float32Array(s*u*d*p);let g=0;for(let e=0;e<s;++e)for(let t=0;t<u;++t){const n=Math.floor(t/a),r=t%a;for(let t=0;t<d;++t){const i=Math.floor(t/a),o=(r*a+t%a)*p;for(let t=0;t<p;++t){f[g++]=m[t+o+h*(i+c*(n+l*e))]}}}return n.makeTensorInfo([s,u,d,p],i.dtype,f)}const depthToSpaceConfig$1={kernelName:DepthToSpace,backendName:"cpu",kernelFunc:depthToSpace$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function depthwiseConv2dNative$1(e){const{inputs:t,backend:n,attrs:r}=e,{x:i,filter:a}=t,{strides:o,pad:s,dilations:l,dimRoundingMode:c}=r;assertNotComplex$1([i,a],"depthwiseConv2DNative");const h=computeStrides(i.shape),u=computeStrides(a.shape);let d=l;null==d&&(d=[1,1]),assert$1(eitherStridesOrDilationsAreOne(o,d),(()=>`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${o} and dilations '${d}'`));const p=computeConv2DInfo(i.shape,a.shape,o,d,s,c,!0),{filterHeight:m,filterWidth:f,dilationHeight:g,dilationWidth:v,padInfo:y}=p,_=y.left,b=y.top,x=p.outChannels/p.inChannels,S=new TensorBuffer(p.outShape,i.dtype),w=n.data.get(i.dataId).values,C=n.data.get(a.dataId).values,M=S.values;for(let e=0;e<p.batchSize;++e){const t=e*h[0],n=e*S.strides[0];for(let e=0;e<p.outHeight;++e){const r=n+e*S.strides[1],i=e*p.strideHeight-_;for(let e=0;e<m;++e){const n=i+e*g;if(n<0||n>=p.inHeight)continue;const a=e*u[0],o=t+n*h[1];for(let e=0;e<p.outWidth;++e){const t=r+e*S.strides[2],n=e*p.strideWidth-b;for(let e=0;e<f;++e){const r=n+e*v;if(r<0||r>=p.inWidth)continue;const i=o+r*p.inChannels;let s=t,l=a+e*u[1];for(let e=0;e<p.inChannels;++e){const t=w[i+e];for(let e=0;e<x;++e)M[s+e]+=t*C[l+e];s+=x,l+=x}}}}}}return n.makeTensorInfo(S.shape,S.dtype,S.values)}const depthwiseConv2dNativeConfig$1={kernelName:DepthwiseConv2dNative,backendName:"cpu",kernelFunc:depthwiseConv2dNative$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function depthwiseConv2dNativeBackpropFilter$1(e){const{inputs:t,backend:n,attrs:r}=e,{x:i,dy:a}=t,{strides:o,dilations:s,pad:l,dimRoundingMode:c,filterShape:h}=r;assertNotComplex$1([i,a],"depthwiseConv2dNativeBackpropFilter");const u=computeConv2DInfo(i.shape,h,o,s,l,c,!0),{strideHeight:d,strideWidth:p,filterHeight:m,filterWidth:f}=u,g=new TensorBuffer(u.filterShape,"float32"),v=u.padInfo.left,y=u.padInfo.top,_=u.outChannels/u.inChannels,b=n.data.get(i.dataId).values,x=new TensorBuffer(i.shape,i.dtype,b),S=n.data.get(a.dataId).values,w=new TensorBuffer(a.shape,a.dtype,S);for(let e=0;e<m;++e){const t=Math.max(0,Math.ceil((y-e)/d)),n=Math.min(u.outHeight,(u.inHeight+y-e)/d);for(let r=0;r<f;++r){const i=Math.max(0,Math.ceil((v-r)/p)),a=Math.min(u.outWidth,(u.inWidth+v-r)/p);for(let o=0;o<u.outChannels;++o){const s=Math.trunc(o/_),l=o%_;let c=0;for(let l=0;l<u.batchSize;++l)for(let h=t;h<n;++h){const t=e+h*d-y;for(let e=i;e<a;++e){c+=x.get(l,t,r+e*p-v,s)*w.get(l,h,e,o)}}g.set(c,e,r,s,l)}}}return n.makeTensorInfo(g.shape,g.dtype,g.values)}const depthwiseConv2dNativeBackpropFilterConfig$1={kernelName:DepthwiseConv2dNativeBackpropFilter,backendName:"cpu",kernelFunc:depthwiseConv2dNativeBackpropFilter$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function depthwiseConv2dNativeBackpropInput$1(e){const{inputs:t,backend:n,attrs:r}=e,{dy:i,filter:a}=t,{strides:o,dilations:s,pad:l,dimRoundingMode:c,inputShape:h}=r;assertNotComplex$1([i,a],"depthwiseConv2DNativeBackpropInput");const u=computeStrides(i.shape),d=computeStrides(a.shape),p=computeConv2DInfo(h,a.shape,o,s,l,c,!0),m=new TensorBuffer(p.inShape,"float32"),f=m.values,[g,v,y]=m.strides,_=n.data.get(i.dataId).values,[b,x,S]=u,w=n.data.get(a.dataId).values,[C,M,E]=d,{batchSize:T,filterHeight:I,filterWidth:A,inChannels:k,inHeight:P,inWidth:R,outChannels:N,outHeight:L,outWidth:D,strideHeight:$,strideWidth:z}=p,F=I-1-p.padInfo.top,O=A-1-p.padInfo.left,B=N/k;for(let e=0;e<T;++e)for(let t=0;t<k;++t)for(let n=0;n<P;++n){const r=n-F,i=Math.max(0,Math.ceil(r/$)),a=Math.min(L,(I+r)/$);for(let o=0;o<R;++o){const s=o-O,l=Math.max(0,Math.ceil(s/z)),c=Math.min(D,(A+s)/z);let h=0;for(let n=i;n<a;++n){const i=n*$-r;for(let r=l;r<c;++r){const a=b*e+x*n+S*r,o=C*(I-1-i)+M*(A-1-(r*z-s))+E*t;for(let e=0;e<B;++e){h+=_[a+(t*B+e)]*w[o+e]}}}f[g*e+v*n+y*o+t]=h}}return n.makeTensorInfo(m.shape,m.dtype,m.values)}const depthwiseConv2dNativeBackpropInputConfig$1={kernelName:DepthwiseConv2dNativeBackpropInput,backendName:"cpu",kernelFunc:depthwiseConv2dNativeBackpropInput$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function diag$1(e){const{inputs:t,backend:n}=e,{x:r}=t,i=sizeFromShape(r.shape),a=n.data.get(r.dataId).values,o=buffer([i,i],r.dtype),s=o.values;for(let e=0;e<a.length;e++)s[e*i+e]=a[e];const l=[...r.shape,...r.shape];return n.makeTensorInfo(l,o.dtype,o.values)}const diagConfig$1={kernelName:Diag,backendName:"cpu",kernelFunc:diag$1},dilation2dConfig={kernelName:Dilation2D,backendName:"cpu",kernelFunc:({inputs:e,backend:t,attrs:n})=>{const{x:r,filter:i}=e,{strides:a,pad:o,dilations:s}=n,l=t,c=l.data.get(r.dataId).values,h=r.shape.length,u=l.data.get(i.dataId).values,d=i.shape.length,{batchSize:p,inHeight:m,inWidth:f,inChannels:g,outHeight:v,outWidth:y,padInfo:_,strideHeight:b,strideWidth:x,filterHeight:S,filterWidth:w,dilationHeight:C,dilationWidth:M,outShape:E}=computeDilation2DInfo(r.shape,i.shape,a,o,"NHWC",s),T=sizeFromShape(E),I=E.length,A=getArrayFromDType(r.dtype,T);for(let e=0;e<p;++e)for(let t=0;t<v;++t){const n=t*b-_.top;for(let a=0;a<y;++a){const o=a*x-_.left;for(let s=0;s<g;++s){let l=Number.MIN_SAFE_INTEGER;for(let t=0;t<S;++t){const a=n+t*C;if(a>=0&&a<m)for(let n=0;n<w;++n){const p=o+n*M;if(p>=0&&p<f){const o=locToIndex([e,a,p,s],h,computeStrides(r.shape)),m=locToIndex([t,n,s],d,computeStrides(i.shape)),f=c[o]+u[m];f>l&&(l=f)}}}A[locToIndex([e,t,a,s],I,computeStrides(E))]=l}}}return{dataId:l.write(toTypedArray$1(A,r.dtype),E,r.dtype),shape:E,dtype:r.dtype}}},dilation2dBackpropFilterConfig={kernelName:Dilation2DBackpropFilter,backendName:"cpu",kernelFunc:({inputs:e,backend:t,attrs:n})=>{const{x:r,filter:i,dy:a}=e,{strides:o,pad:s,dilations:l}=n,c=t,h=toNestedArray(r.shape,c.data.get(r.dataId).values),u=toNestedArray(i.shape,c.data.get(i.dataId).values),{batchSize:d,inHeight:p,inWidth:m,inChannels:f,outHeight:g,outWidth:v,padInfo:y,strideHeight:_,strideWidth:b,filterHeight:x,filterWidth:S,dilationHeight:w,dilationWidth:C,outShape:M}=computeDilation2DInfo(r.shape,i.shape,o,s,"NHWC",l);assert$1(a.rank===M.length,(()=>`Error in ${Dilation2DBackpropFilter}, dy must have the same rank as output ${M.length}, but got ${a.rank}`));const E=toNestedArray(M,c.data.get(a.dataId).values),T=makeZerosNestedTypedArray(i.shape,i.dtype);for(let e=0;e<d;++e)for(let t=0;t<g;++t){const n=t*_-y.top;for(let r=0;r<v;++r){const i=r*b-y.left;for(let a=0;a<f;++a){let o=Number.MIN_SAFE_INTEGER,s=0,l=0;for(let t=0;t<x;++t){const r=n+t*w;if(r>=0&&r<p)for(let n=0;n<S;++n){const c=i+n*C;if(c>=0&&c<m){const i=h[e][r][c][a]+u[t][n][a];i>o&&(o=i,s=t,l=n)}}}T[s][l][a]+=E[e][t][r][a]}}}return{dataId:c.write(toTypedArray$1(T,r.dtype),i.shape,i.dtype),shape:i.shape,dtype:i.dtype}}},dilation2dBackpropInputConfig={kernelName:Dilation2DBackpropInput,backendName:"cpu",kernelFunc:({inputs:e,backend:t,attrs:n})=>{const{x:r,filter:i,dy:a}=e,{strides:o,pad:s,dilations:l}=n,c=t,h=toNestedArray(r.shape,c.data.get(r.dataId).values),u=toNestedArray(i.shape,c.data.get(i.dataId).values),{batchSize:d,inHeight:p,inWidth:m,inChannels:f,outHeight:g,outWidth:v,padInfo:y,strideHeight:_,strideWidth:b,filterHeight:x,filterWidth:S,dilationHeight:w,dilationWidth:C,outShape:M}=computeDilation2DInfo(r.shape,i.shape,o,s,"NHWC",l);assert$1(a.rank===M.length,(()=>`Error in ${Dilation2DBackpropInput}, dy must have the same rank as output ${M.length}, but got ${a.rank}`));const E=toNestedArray(M,c.data.get(a.dataId).values),T=makeZerosNestedTypedArray(r.shape,r.dtype);for(let e=0;e<d;++e)for(let t=0;t<g;++t){const n=t*_-y.top;for(let r=0;r<v;++r){const i=r*b-y.left;for(let a=0;a<f;++a){let o=Number.MIN_SAFE_INTEGER,s=n<0?0:n,l=i<0?0:i;for(let t=0;t<x;++t){const r=n+t*w;if(r>=0&&r<p)for(let n=0;n<S;++n){const c=i+n*C;if(c>=0&&c<m){const i=h[e][r][c][a]+u[t][n][a];i>o&&(o=i,s=r,l=c)}}}T[e][s][l][a]+=E[e][t][r][a]}}}return{dataId:c.write(toTypedArray$1(T,r.dtype),r.shape,r.dtype),shape:r.shape,dtype:r.dtype}}};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
function sum$1(e){const{inputs:t,backend:n,attrs:r}=e,{x:i}=t,{axis:a,keepDims:o}=r;let s;assertNotComplex$1(i,"sum"),s="bool"===i.dtype?cast$1({inputs:{x:i},backend:n,attrs:{dtype:"int32"}}):identity$3({inputs:{x:i},backend:n});const l=s.shape.length,c=parseAxisParam(a,s.shape),h=getAxesPermutation(c,l);let u=c,d=s;null!=h&&(d=transpose$1({inputs:{x:s},backend:n,attrs:{perm:h}}),u=getInnerMostAxes(u.length,l)),assertAxesAreInnerMostDims("sum",u,d.shape.length);const[p,m]=computeOutAndReduceShapes(d.shape,u);let f=zeros(n,p,upcastType(d.dtype,"int32"));const g=sizeFromShape(m),v=n.data.get(f.dataId).values,y=n.data.get(d.dataId).values;for(let e=0;e<v.length;++e){const t=e*g;let n=0;for(let e=0;e<g;++e)n+=y[t+e];v[e]=n}if(o){const e=f;f=reshape$1({inputs:{x:f},backend:n,attrs:{shape:expandShapeToKeepDim(f.shape,c)}}),n.disposeIntermediateTensorInfo(e)}return n.disposeIntermediateTensorInfo(s),null!=h&&n.disposeIntermediateTensorInfo(d),f}const sumConfig$1={kernelName:Sum,backendName:"cpu",kernelFunc:sum$1};
/**
     * @license
     * Copyright 2021 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function einsum$1(e){const{inputs:t,backend:n,attrs:r}=e,{equation:i}=r,a=t,{allDims:o,summedDims:s,idDims:l}=decodeEinsumEquation(i,a.length);checkEinsumDimSizes(o.length,l,a);const{path:c,steps:h}=getEinsumComputePath(s,l),u=h.length;let d=null,p=o.length;const m=[];for(let e=0;e<u;++e){for(const t of h[e]){const{permutationIndices:e,expandDims:r}=getEinsumPermutation(p,l[t]);let i;isIdentityPermutation(e)?i=a[t]:(i=transpose$1({inputs:{x:a[t]},backend:n,attrs:{perm:e}}),m.push(i));const o=i.shape.slice();for(let e=0;e<r.length;++e)o.splice(r[e],0,1);arraysEqual$1(i.shape,o)||(i=reshape$1({inputs:{x:i},backend:n,attrs:{shape:o}}),m.push(i)),null===d?d=i:(d=multiply$1({inputs:{a:i,b:d},backend:n}),m.push(d))}e<u-1&&(c[e]>=0&&(d=sum$1({inputs:{x:d},backend:n,attrs:{axis:c[e]-(o.length-p),keepDims:!1}}),m.push(d)),p--)}for(const e of m)e!==d&&n.disposeIntermediateTensorInfo(e);return d}const einsumConfig$1={kernelName:Einsum,backendName:"cpu",kernelFunc:einsum$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function eluGrad$1(e){const{inputs:t,backend:n}=e,{dy:r,y:i}=t;assertNotComplex$1([r,i],"eluGrad");const a=new Float32Array(sizeFromShape(i.shape)),o=n.data.get(i.dataId).values,s=n.data.get(r.dataId).values;for(let e=0;e<o.length;++e){const t=o[e];a[e]=t>=1?s[e]:s[e]*(t+1)}return n.makeTensorInfo(i.shape,"float32",a)}const eluGradConfig$1={kernelName:EluGrad,backendName:"cpu",kernelFunc:eluGrad$1},equalImpl=createSimpleBinaryKernelImpl(((e,t)=>e===t?1:0)),equal$1=binaryKernelFunc$1(Equal,equalImpl,null,"bool"),equalConfig$1={kernelName:Equal,backendName:"cpu",kernelFunc:equal$1},p=ERF_P,a1=ERF_A1,a2=ERF_A2,a3=ERF_A3,a4=ERF_A4,a5=ERF_A5,erf$1=unaryKernelFunc$1(Erf,(e=>{const t=Math.sign(e),n=Math.abs(e),r=1/(1+p*n);return t*(1-((((a5*r+a4)*r+a3)*r+a2)*r+a1)*r*Math.exp(-n*n))})),erfConfig$1={kernelName:Erf,backendName:"cpu",kernelFunc:erf$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
function expandDims$1(e){const{inputs:t,backend:n,attrs:r}=e,{input:i}=t,{dim:a}=r,o=i.shape.length,s=i.shape.slice();let l=a;return a<0&&(assert$1(-(o+1)<=a,(()=>`Axis must be in the interval [${-(o+1)}, ${o}]`)),l=o+a+1),s.splice(l,0,1),reshape$1({inputs:{x:i},backend:n,attrs:{shape:s}})}const expandDimsConfig$1={kernelName:ExpandDims,backendName:"cpu",kernelFunc:expandDims$1},realDivImpl=createSimpleBinaryKernelImpl(((e,t)=>e/t)),div=binaryKernelFunc$1(RealDiv,realDivImpl),realDivConfig$1={kernelName:RealDiv,backendName:"cpu",kernelFunc:div};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
function fftBatch(e,t,n){const r=e.shape,i=r[0],a=r[1],o=n.data.get(e.dataId),s=o.complexTensorInfos.real,l=o.complexTensorInfos.imag,c=[i,a],h=sizeFromShape(c),u=getTypedArrayFromDType("float32",h),d=getTypedArrayFromDType("float32",h);for(let e=0;e<i;e++){const r=slice$2({inputs:{x:s},backend:n,attrs:{begin:[e,0],size:[1,a]}}),i=slice$2({inputs:{x:l},backend:n,attrs:{begin:[e,0],size:[1,a]}}),o=complex$1({inputs:{real:r,imag:i},backend:n}),{real:c,imag:h}=fftImpl$1(o,t,n),p=mergeRealAndImagArrays(c,h);for(let t=0;t<a;t++){const n=getComplexWithIndex(p,t);u[e*a+t]=n.real,d[e*a+t]=n.imag}n.disposeIntermediateTensorInfo(r),n.disposeIntermediateTensorInfo(i),n.disposeIntermediateTensorInfo(o)}const p=n.makeTensorInfo(c,"float32",u),m=n.makeTensorInfo(c,"float32",d),f=complex$1({inputs:{real:p,imag:m},backend:n});return n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(m),f}function fftImpl$1(e,t,n){const r=sizeFromShape(e.shape),i=n.data.get(e.dataId),a=n.data.get(i.complexTensorInfos.real.dataId).values,o=n.data.get(i.complexTensorInfos.imag.dataId).values;if(isExponentOf2(r)){const i=fftRadix2(a,o,r,t,n),s=[e.shape[0],e.shape[1]];if(t){const e=n.makeTensorInfo(s,"float32",i.real),t=n.makeTensorInfo(s,"float32",i.imag),a=n.makeTensorInfo([],"float32",createScalarValue(r,"float32")),o=identity$3({inputs:{x:a},backend:n}),l=realDivConfig$1.kernelFunc({inputs:{a:e,b:a},backend:n}),c=realDivConfig$1.kernelFunc({inputs:{a:t,b:o},backend:n}),h=n.data.get(l.dataId).values,u=n.data.get(c.dataId).values;return n.disposeIntermediateTensorInfo(e),n.disposeIntermediateTensorInfo(t),n.disposeIntermediateTensorInfo(a),n.disposeIntermediateTensorInfo(o),n.disposeIntermediateTensorInfo(l),n.disposeIntermediateTensorInfo(c),{real:h,imag:u}}return i}return splitRealAndImagArrays(fourierTransformByMatmul(mergeRealAndImagArrays(a,o),r,t))}function isExponentOf2(e){return 0==(e&e-1)}function fftRadix2(e,t,n,r,i){if(1===n)return{real:e,imag:t};const a=mergeRealAndImagArrays(e,t),o=n/2,s=complexWithEvenIndex(a),l=s.real,c=s.imag,h=[l.length],u=i.makeTensorInfo(h,"float32",l),d=i.makeTensorInfo(h,"float32",c),p=complex$1({inputs:{real:u,imag:d},backend:i}),m=complexWithOddIndex(a),f=m.real,g=m.imag,v=[f.length],y=i.makeTensorInfo(v,"float32",f),_=i.makeTensorInfo(v,"float32",g),b=complex$1({inputs:{real:y,imag:_},backend:i}),x=fftRadix2(l,c,o,r,i),S=x.real,w=x.imag,C=[S.length],M=i.makeTensorInfo(C,"float32",S),E=i.makeTensorInfo(C,"float32",w),T=complex$1({inputs:{real:M,imag:E},backend:i}),I=fftRadix2(f,g,o,r,i),A=I.real,k=I.imag,P=[A.length],R=i.makeTensorInfo(P,"float32",A),N=i.makeTensorInfo(P,"float32",k),L=complex$1({inputs:{real:R,imag:N},backend:i}),D=exponents(n,r),$=[D.real.length],z=i.makeTensorInfo($,"float32",D.real),F=i.makeTensorInfo($,"float32",D.imag),O=complex$1({inputs:{real:z,imag:F},backend:i}),B=multiply$1({inputs:{a:O,b:L},backend:i}),V=add({inputs:{a:T,b:B},backend:i}),H=sub$2({inputs:{a:T,b:B},backend:i}),U=real$1({inputs:{input:V},backend:i}),G=real$1({inputs:{input:H},backend:i}),W=imag$1({inputs:{input:V},backend:i}),j=imag$1({inputs:{input:H},backend:i}),q=concat$1({inputs:[U,G],backend:i,attrs:{axis:0}}),X=concat$1({inputs:[W,j],backend:i,attrs:{axis:0}}),K=i.data.get(q.dataId).values,Y=i.data.get(X.dataId).values;return i.disposeIntermediateTensorInfo(u),i.disposeIntermediateTensorInfo(d),i.disposeIntermediateTensorInfo(p),i.disposeIntermediateTensorInfo(y),i.disposeIntermediateTensorInfo(_),i.disposeIntermediateTensorInfo(b),i.disposeIntermediateTensorInfo(M),i.disposeIntermediateTensorInfo(E),i.disposeIntermediateTensorInfo(T),i.disposeIntermediateTensorInfo(R),i.disposeIntermediateTensorInfo(N),i.disposeIntermediateTensorInfo(L),i.disposeIntermediateTensorInfo(z),i.disposeIntermediateTensorInfo(F),i.disposeIntermediateTensorInfo(O),i.disposeIntermediateTensorInfo(B),i.disposeIntermediateTensorInfo(V),i.disposeIntermediateTensorInfo(H),i.disposeIntermediateTensorInfo(U),i.disposeIntermediateTensorInfo(W),i.disposeIntermediateTensorInfo(G),i.disposeIntermediateTensorInfo(j),i.disposeIntermediateTensorInfo(q),i.disposeIntermediateTensorInfo(X),{real:K,imag:Y}}function fourierTransformByMatmul(e,t,n){const r=new Float32Array(2*t);for(let i=0;i<t;i++){let a=0,o=0;for(let r=0;r<t;r++){const s=exponent$1(i*r,t,n),l=getComplexWithIndex(e,r);a+=l.real*s.real-l.imag*s.imag,o+=l.real*s.imag+l.imag*s.real}n&&(a/=t,o/=t),assignToTypedArray(r,a,o,i)}return r}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function fft$1(e){const{inputs:t,backend:n}=e,{input:r}=t,i=sizeFromShape(r.shape),a=r.shape[r.shape.length-1],o=reshape$1({inputs:{x:r},backend:n,attrs:{shape:[i/a,a]}}),s=fftBatch(o,!1,n),l=reshape$1({inputs:{x:s},backend:n,attrs:{shape:r.shape}});return n.disposeIntermediateTensorInfo(o),n.disposeIntermediateTensorInfo(s),l}const fftConfig$1={kernelName:FFT,backendName:"cpu",kernelFunc:fft$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function fill$1(e){const{backend:t,attrs:n}=e,{shape:r,value:i,dtype:a}=n,o=a||inferDtype(i),s=getArrayFromDType(o,sizeFromShape(r));return fillValues(s,i,o),t.makeTensorInfo(r,o,s)}const fillConfig$1={kernelName:Fill,backendName:"cpu",kernelFunc:fill$1};function fillValues(e,t,n){e.fill(t)}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */const flipLeftRightConfig$1={kernelName:FlipLeftRight,backendName:"cpu",kernelFunc:({inputs:e,backend:t})=>{const{image:n}=e,r=t,i=getTypedArrayFromDType(n.dtype,sizeFromShape(n.shape)),[a,o,s,l]=n.shape,c=r.data.get(n.dataId).values;for(let e=0;e<a;e++){const t=e*s*o*l;for(let e=0;e<o;e++){const n=e*(s*l);for(let r=0;r<s;r++){const o=r*l;for(let h=0;h<l;h++){const u=Math.round(s-[a,e,r,h][2]),d=t+n+o+h;let p=c[d];if(u>=0&&u<s){p=c[t+n+u*l+h]}i[d]=p}}}}return{dataId:r.write(i,n.shape,n.dtype),shape:n.shape,dtype:n.dtype}}},floorDivImpl=createSimpleBinaryKernelImpl(((e,t)=>Math.floor(e/t))),floorDiv$1=binaryKernelFunc$1(FloorDiv,floorDivImpl,null,"int32"),floorDivConfig$1={kernelName:FloorDiv,backendName:"cpu",kernelFunc:floorDiv$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
function fusedConv2D(e){const{inputs:t,backend:n,attrs:r}=e,{x:i,filter:a,bias:o,preluActivationWeights:s}=t,{strides:l,pad:c,dataFormat:h,dilations:u,dimRoundingMode:d,activation:p,leakyreluAlpha:m}=r;let f=conv2D({inputs:{x:i,filter:a},backend:n,attrs:{strides:l,pad:c,dataFormat:h,dilations:u,dimRoundingMode:d}});if(o){const e=f;f=add({inputs:{a:f,b:o},backend:n}),n.disposeIntermediateTensorInfo(e)}if(p){const e=f;f=applyActivation(n,f,p,s,m),n.disposeIntermediateTensorInfo(e)}return f}const fusedConv2DConfig$1={kernelName:FusedConv2D,backendName:"cpu",kernelFunc:fusedConv2D};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function fusedDepthwiseConv2D$1(e){const{inputs:t,backend:n,attrs:r}=e,{x:i,filter:a,bias:o,preluActivationWeights:s}=t,{strides:l,pad:c,dataFormat:h,dilations:u,dimRoundingMode:d,activation:p,leakyreluAlpha:m}=r;let f=depthwiseConv2dNative$1({inputs:{x:i,filter:a},backend:n,attrs:{strides:l,pad:c,dataFormat:h,dilations:u,dimRoundingMode:d}});if(o){const e=f;f=add({inputs:{a:f,b:o},backend:n}),n.disposeIntermediateTensorInfo(e)}if(p){const e=f;f=applyActivation(n,f,p,s,m),n.disposeIntermediateTensorInfo(e)}return f}const fusedDepthwiseConv2DConfig$1={kernelName:FusedDepthwiseConv2D,backendName:"cpu",kernelFunc:fusedDepthwiseConv2D$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function gatherNd$1(e){const{inputs:t,backend:n}=e,{params:r,indices:i}=t,a=sizeFromShape(r.shape),o=i.shape,s=o[o.length-1],[l,c,h,u]=prepareAndValidate(r,i);if(0===c)return n.makeTensorInfo(l,r.dtype,[]);const d=buffer([c,h],r.dtype),p=n.data.get(i.dataId).values,m=n.data.get(r.dataId).values;for(let e=0;e<c;e++){const t=[];let n=0;for(let r=0;r<s;r++){const i=p[e*s+r];n+=i*u[r],t.push(i)}if(n<0||n>=a/h)throw new Error(`Invalid indices: ${t} does not index into ${r.shape}`);for(let t=0;t<h;t++)d.values[e*h+t]=m[n*h+t]}return n.makeTensorInfo(l,d.dtype,d.values)}const gatherNdConfig$1={kernelName:GatherNd,backendName:"cpu",kernelFunc:gatherNd$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function gatherV2$1(e){const{inputs:t,backend:n,attrs:r}=e,{x:i,indices:a}=t,{axis:o,batchDims:s}=r;assertNotComplex$1([i,a],"gatherV2");let l=s;null==s&&(l=0);const c=sizeFromShape(a.shape),h=collectGatherOpShapeInfo(i,a,parseAxisParam(o,i.shape)[0],l),u=reshape$1({inputs:{x:i},backend:n,attrs:{shape:[h.batchSize,h.outerSize,h.dimSize,h.sliceSize]}}),d=reshape$1({inputs:{x:a},backend:n,attrs:{shape:[h.batchSize,c/h.batchSize]}}),p=[h.batchSize,h.outerSize,c/h.batchSize,h.sliceSize],m=n.bufferSync(d),f=gatherV2Impl(n.bufferSync(u),m,p);return n.disposeIntermediateTensorInfo(u),n.disposeIntermediateTensorInfo(d),n.makeTensorInfo(h.outputShape,f.dtype,f.values)}const gatherV2Config$1={kernelName:GatherV2,backendName:"cpu",kernelFunc:gatherV2$1},greaterEqualImpl=createSimpleBinaryKernelImpl(((e,t)=>e>=t?1:0)),greaterEqual$1=binaryKernelFunc$1(GreaterEqual,greaterEqualImpl,null,"bool"),greaterEqualConfig$1={kernelName:GreaterEqual,backendName:"cpu",kernelFunc:greaterEqual$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
function ifft$1(e){const{inputs:t,backend:n}=e,{input:r}=t,i=sizeFromShape(r.shape),a=r.shape[r.shape.length-1],o=reshape$1({inputs:{x:r},backend:n,attrs:{shape:[i/a,a]}}),s=fftBatch(o,!0,n),l=reshape$1({inputs:{x:s},backend:n,attrs:{shape:r.shape}});return n.disposeIntermediateTensorInfo(o),n.disposeIntermediateTensorInfo(s),l}const ifftConfig$1={kernelName:IFFT,backendName:"cpu",kernelFunc:ifft$1},isFinite$2=unaryKernelFunc$1(IsFinite,(e=>Number.isFinite(e)?1:0),"bool"),isFiniteConfig$1={kernelName:IsFinite,backendName:"cpu",kernelFunc:isFinite$2},isInf$1=unaryKernelFunc$1(IsInf,(e=>Math.abs(e)===1/0?1:0),"bool"),isInfConfig$1={kernelName:IsInf,backendName:"cpu",kernelFunc:isInf$1},isNaN$2=unaryKernelFunc$1(IsNan,(e=>Number.isNaN(e)?1:0),"bool"),isNaNConfig$1={kernelName:IsNan,backendName:"cpu",kernelFunc:isNaN$2},lessEqualImpl=createSimpleBinaryKernelImpl(((e,t)=>e<=t?1:0)),lessEqual$1=binaryKernelFunc$1(LessEqual,lessEqualImpl,null,"bool"),lessEqualConfig$1={kernelName:LessEqual,backendName:"cpu",kernelFunc:lessEqual$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the License);
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an AS IS BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
function linSpace$1(e){const{backend:t,attrs:n}=e,{start:r,stop:i,num:a}=n,o=linSpaceImpl(r,i,a);return t.makeTensorInfo([o.length],"float32",o)}const linSpaceConfig$1={kernelName:LinSpace,backendName:"cpu",kernelFunc:linSpace$1},log1p$1=unaryKernelFunc$1(Log1p,(e=>Math.log1p(e))),log1pConfig$1={kernelName:Log1p,backendName:"cpu",kernelFunc:log1p$1},logicalAndImpl=createSimpleBinaryKernelImpl(((e,t)=>e&&t)),logicalAnd$1=binaryKernelFunc$1(LogicalAnd,logicalAndImpl,null,"bool"),logicalAndConfig$1={kernelName:LogicalAnd,backendName:"cpu",kernelFunc:logicalAnd$1},logicalNot$1=unaryKernelFunc$1(LogicalNot,(e=>e?0:1),"bool"),logicalNotConfig$1={kernelName:LogicalNot,backendName:"cpu",kernelFunc:logicalNot$1},logicalOrImpl=createSimpleBinaryKernelImpl(((e,t)=>e||t)),logicalOr$1=binaryKernelFunc$1(LogicalOr,logicalOrImpl,null,"bool"),logicalOrConfig$1={kernelName:LogicalOr,backendName:"cpu",kernelFunc:logicalOr$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the License);
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an AS IS BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
function lRN(e){const{inputs:t,backend:n,attrs:r}=e,{x:i}=t,{depthRadius:a,bias:o,alpha:s,beta:l}=r;assertNotComplex$1(i,"LRN");const c=i.shape[3],h=c-1,u=n.data.get(i.dataId).values,d=sizeFromShape(i.shape),p=new Float32Array(d);function m(e){const t=e%c;let n=e-t+Math.max(0,t-a);const r=e-t+Math.min(t+a,h);let i=0;for(;n<=r;n++){const e=u[n];i+=e*e}return i}for(let e=0;e<d;e++){const t=m(e),n=u[e]*Math.pow(o+s*t,-l);p[e]=n}return n.makeTensorInfo(i.shape,i.dtype,p)}const lRNConfig={kernelName:LRN,backendName:"cpu",kernelFunc:lRN};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function lRNGrad(e){const{inputs:t,backend:n,attrs:r}=e,{x:i,y:a,dy:o}=t,{depthRadius:s,bias:l,alpha:c,beta:h}=r;assertNotComplex$1(o,"LRNGrad");const u=sizeFromShape(o.shape),d=o.shape[3],p=n.data.get(o.dataId).values,m=n.data.get(i.dataId).values,f=n.data.get(a.dataId).values,g=new Float32Array(u),v=u;for(let e=0;e<v;e++){const t=e%d,n=e-t+Math.max(0,t-s),r=e-t+Math.min(d,t+s+1);let i=0;for(let e=n;e<r;e++)i+=Math.pow(m[e],2);i=c*i+l;for(let t=n;t<r;t++){let n=-2*c*h*m[t]*f[e]/i;e===t&&(n+=Math.pow(i,-h)),n*=p[e],g[t]+=n}}return n.makeTensorInfo(o.shape,i.dtype,g)}const lRNGradConfig={kernelName:LRNGrad,backendName:"cpu",kernelFunc:lRNGrad};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function max$1(e){const{inputs:t,backend:n,attrs:r}=e,{x:i}=t,{reductionIndices:a,keepDims:o}=r,s=n;let l=i.shape;const c=l.length,h=parseAxisParam(a,l);let u=h;const d=getAxesPermutation(u,c);let p=s.data.get(i.dataId).values;if(null!=d){const e=new Array(c);for(let t=0;t<e.length;t++)e[t]=l[d[t]];p=transposeImpl$1(p,l,i.dtype,d,e),u=getInnerMostAxes(u.length,c),l=e}assertNotComplex$1(i,"max"),assertAxesAreInnerMostDims("max",u,c);const[m,f]=computeOutAndReduceShapes(l,u),g=maxImpl$1(p,sizeFromShape(f),m,i.dtype),v=s.write(g,m,i.dtype);let y=m;if(o){y=expandShapeToKeepDim(m,h)}return{dataId:v,shape:y,dtype:i.dtype}}const maxConfig$1={kernelName:Max,backendName:"cpu",kernelFunc:max$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function maxPool$1(e){const{inputs:t,backend:n,attrs:r}=e,{x:i}=t;assertNotComplex$1(i,"maxPool");const{filterSize:a,strides:o,pad:s,dimRoundingMode:l}=r;assert$1(eitherStridesOrDilationsAreOne(o,1),(()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${o} and dilations '1'`));const c=computePool2DInfo(i.shape,a,o,1,s,l);let h;if(1===c.filterWidth&&1===c.filterHeight&&arraysEqual$1(c.inShape,c.outShape))h=identity$3({inputs:{x:i},backend:n});else{const e=n.data.get(i.dataId).values,t=computeStrides(i.shape),r=pool(e,i.shape,i.dtype,t,c,"max");h=n.makeTensorInfo(c.outShape,i.dtype,r.values)}return h}const maxPoolConfig$1={kernelName:MaxPool,backendName:"cpu",kernelFunc:maxPool$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function maxPool3D(e){const{inputs:t,backend:n,attrs:r}=e,{x:i}=t,{filterSize:a,strides:o,pad:s,dimRoundingMode:l,dataFormat:c}=r;assertNotComplex$1(i,"maxPool3d");const h=computePool3DInfo(i.shape,a,o,1,s,l,c),u=pool3d(n.data.get(i.dataId).values,i.shape,i.dtype,computeStrides(i.shape),h,"max");return n.makeTensorInfo(u.shape,"float32",u.values)}const maxPool3DConfig$1={kernelName:MaxPool3D,backendName:"cpu",kernelFunc:maxPool3D};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function maxPool3DGrad$1(e){const{inputs:t,backend:n,attrs:r}=e,{dy:i,input:a}=t,{filterSize:o,strides:s,pad:l,dimRoundingMode:c}=r;assertNotComplex$1([i,a],"maxPool3DGrad");const h=computePool3DInfo(a.shape,o,s,1,l,c),u=maxPool3dPositions(n.bufferSync(a),h),d=h.strideDepth,p=h.strideHeight,m=h.strideWidth,f=h.dilationDepth,g=h.dilationHeight,v=h.dilationWidth,y=h.effectiveFilterDepth,_=h.effectiveFilterHeight,b=h.effectiveFilterWidth,x=y-1-h.padInfo.front,S=b-1-h.padInfo.left,w=_-1-h.padInfo.top,C=buffer(a.shape,"float32"),M=n.bufferSync(i);for(let e=0;e<h.batchSize;++e)for(let t=0;t<h.inChannels;++t)for(let n=0;n<h.inDepth;++n)for(let r=0;r<h.inHeight;++r)for(let i=0;i<h.inWidth;++i){const a=n-x,o=r-w,s=i-S;let l=0;for(let n=0;n<y;n+=f){const r=(a+n)/d;if(!(r<0||r>=h.outDepth||Math.floor(r)!==r))for(let i=0;i<_;i+=g){const a=(o+i)/p;if(!(a<0||a>=h.outHeight||Math.floor(a)!==a))for(let o=0;o<b;o+=v){const c=(s+o)/m;if(c<0||c>=h.outWidth||Math.floor(c)!==c)continue;const d=y*_*b-1-u.get(e,r,a,c,t)===n*_*b+i*b+o?1:0;if(0===d)continue;l+=M.get(e,r,a,c,t)*d}}}C.set(l,e,n,r,i,t)}return n.makeTensorInfo(C.shape,C.dtype,C.values)}const maxPool3DGradConfig={kernelName:MaxPool3DGrad,backendName:"cpu",kernelFunc:maxPool3DGrad$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function maxPoolGrad$1(e){const{inputs:t,backend:n,attrs:r}=e,{dy:i,input:a,output:o}=t,s=a;assertNotComplex$1([a,o],"maxPoolGrad");const{filterSize:l,strides:c,pad:h,dimRoundingMode:u}=r,d=computePool2DInfo(s.shape,l,c,1,h,u),p=n.data.get(s.dataId).values,m=buffer(d.outShape,s.dtype,maxPoolPositions(p,s.shape,s.dtype,d).values),f=d.strideHeight,g=d.strideWidth,v=d.dilationHeight,y=d.dilationWidth,_=d.effectiveFilterHeight,b=d.effectiveFilterWidth,x=b-1-d.padInfo.left,S=_-1-d.padInfo.top,w=buffer(s.shape,"float32"),C=n.data.get(i.dataId).values,M=buffer(i.shape,"float32",C);for(let e=0;e<d.batchSize;++e)for(let t=0;t<d.inChannels;++t)for(let n=0;n<d.inHeight;++n)for(let r=0;r<d.inWidth;++r){const i=n-S,a=r-x;let o=0;for(let n=0;n<_;n+=v){const r=(i+n)/f;if(!(r<0||r>=d.outHeight||Math.floor(r)!==r))for(let i=0;i<b;i+=y){const s=(a+i)/g;if(s<0||s>=d.outWidth||Math.floor(s)!==s)continue;const l=_*b-1-m.get(e,r,s,t)===n*b+i?1:0;if(0===l)continue;o+=M.get(e,r,s,t)*l}}w.set(o,e,n,r,t)}return n.makeTensorInfo(w.shape,w.dtype,w.values)}const maxPoolGradConfig$1={kernelName:MaxPoolGrad,backendName:"cpu",kernelFunc:maxPoolGrad$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function maxPoolWithArgmaxImpl$1(e,t,n,r,i){const a=pool(e,t,n,computeStrides(t),i,"max"),o=maxPoolPositions(e,t,n,i,!0,r);return[a.values,o.values]}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */const maxPoolWithArgmaxConfig$1={kernelName:MaxPoolWithArgmax,backendName:"cpu",kernelFunc:({inputs:e,attrs:t,backend:n})=>{const{x:r}=e,{filterSize:i,strides:a,pad:o,includeBatchInIndex:s}=t,l=n;assertNotComplex$1(r,"MaxPoolWithArgmax");const c=l.data.get(r.dataId).values,h=computePool2DInfo(r.shape,i,a,[1,1],o),[u,d]=maxPoolWithArgmaxImpl$1(c,r.shape,r.dtype,s,h),p=l.write(u,h.outShape,r.dtype),m=l.write(d,h.outShape,r.dtype);return[{dataId:p,shape:h.outShape,dtype:r.dtype},{dataId:m,shape:h.outShape,dtype:"int32"}]}};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function mean(e){const{inputs:t,backend:n,attrs:r}=e,{x:i}=t,{axis:a,keepDims:o}=r,s=parseAxisParam(a,i.shape),l=sizeFromShape(computeOutAndReduceShapes(i.shape,s)[1]),c=[],h=n.makeTensorInfo([],"float32",new Float32Array([l]));c.push(h);const u=cast$1({inputs:{x:i},backend:n,attrs:{dtype:"float32"}});c.push(u);const d=div({inputs:{a:u,b:h},backend:n});c.push(d);const p=sum$1({inputs:{x:d},backend:n,attrs:{axis:a,keepDims:o}});return c.forEach((e=>n.disposeIntermediateTensorInfo(e))),p}const meanConfig$1={kernelName:Mean,backendName:"cpu",kernelFunc:mean};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function min$1(e){const{inputs:t,backend:n,attrs:r}=e,{x:i}=t,{axis:a,keepDims:o}=r;assertNotComplex$1(i,"min");const s=parseAxisParam(a,i.shape);let l=s;const c=getAxesPermutation(l,i.shape.length);let h=i;null!=c&&(h=transpose$1({inputs:{x:i},backend:n,attrs:{perm:c}}),l=getInnerMostAxes(l.length,i.shape.length)),assertAxesAreInnerMostDims("min",l,h.shape.length);const[u,d]=computeOutAndReduceShapes(h.shape,l),p=sizeFromShape(d),m=makeZerosTypedArray(sizeFromShape(u),h.dtype),f=n.data.get(h.dataId).values;for(let e=0;e<m.length;++e){const t=e*p;let n=f[t];for(let e=0;e<p;++e){const r=f[t+e];r<n&&(n=r)}m[e]=n}null!=c&&n.disposeIntermediateTensorInfo(h);const g=n.makeTensorInfo(u,h.dtype,m);if(o){const e=reshape$1({inputs:{x:g},backend:n,attrs:{shape:expandShapeToKeepDim(u,s)}});return n.disposeIntermediateTensorInfo(g),e}return g}const minConfig$1={kernelName:Min,backendName:"cpu",kernelFunc:min$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function mirrorPad(e){const{inputs:t,backend:n,attrs:r}=e,{x:i}=t,{paddings:a,mode:o}=r;assertNotComplex$1(i,"mirrorPad");const s=a.map(((e,t)=>e[0]+i.shape[t]+e[1])),l=a.map((e=>e[0])),c=a.map(((e,t)=>e[0]+i.shape[t])),h="reflect"===o?0:1,u=n.data.get(i.dataId).values,d=i.shape.length,p=computeStrides(i.shape),m=sizeFromShape(s),f=s.length,g=computeStrides(s),v=getTypedArrayFromDType(i.dtype,m);for(let e=0;e<m;e++){let t=indexToLoc(e,f,g);for(let e=0;e<f;e++)t[e]<l[e]?t[e]=2*l[e]-t[e]-h:t[e]>=c[e]&&(t[e]=2*(c[e]-1)-t[e]+h);t=t.map(((e,t)=>e-l[t]));const n=locToIndex(t,d,p);v[e]=u[n]}return{dataId:n.write(v,s,i.dtype),shape:s,dtype:i.dtype}}const mirrorPadConfig$1={kernelName:MirrorPad,backendName:"cpu",kernelFunc:mirrorPad},modImpl=createSimpleBinaryKernelImpl(((e,t)=>{const n=e%t;return e<0&&t<0||e>=0&&t>=0?n:(n+t)%t})),mod$1=binaryKernelFunc$1(Mod,modImpl),modConfig$1={kernelName:Mod,backendName:"cpu",kernelFunc:mod$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
function softmax$1(e){const{inputs:t,backend:n,attrs:r}=e,{logits:i}=t,{dim:a}=r,o=i.shape.length;let s=a;if(-1===s&&(s=o-1),s!==o-1)throw Error(`Softmax along a non-last dimension is not yet supported. Logits was rank ${o} and dim was ${s}`);const l=parseAxisParam([s],i.shape),c=max$1({inputs:{x:i},backend:n,attrs:{reductionIndices:l,keepDims:!1}}),h=expandShapeToKeepDim(c.shape,l),u=reshape$1({inputs:{x:c},backend:n,attrs:{shape:h}}),d=sub$2({inputs:{a:i,b:u},backend:n}),p=exp$1({inputs:{x:d},backend:n}),m=sum$1({inputs:{x:p},backend:n,attrs:{axis:l,keepDims:!1}}),f=reshape$1({inputs:{x:m},backend:n,attrs:{shape:h}}),g=div({inputs:{a:p,b:f},backend:n});return n.disposeIntermediateTensorInfo(c),n.disposeIntermediateTensorInfo(u),n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(m),n.disposeIntermediateTensorInfo(f),g}const softmaxConfig$1={kernelName:Softmax,backendName:"cpu",kernelFunc:softmax$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function multinomial$1(e){const{inputs:t,backend:n,attrs:r}=e,{logits:i}=t,{numSamples:a,seed:o,normalized:s}=r;assertNotComplex$1(i,"multinomial");const l=s?i:softmax$1({inputs:{logits:i},backend:n,attrs:{dim:-1}}),c=l.shape[0],h=l.shape[1],u=n.data.get(l.dataId).values,d=[c,a],p=makeZerosTypedArray(sizeFromShape(d),"int32");for(let e=0;e<c;++e){const t=e*h,n=new Float32Array(h-1);n[0]=u[t];for(let e=1;e<n.length;++e)n[e]=n[e-1]+u[t+e];const r=seedrandom.alea(o.toString()),i=e*a;for(let e=0;e<a;++e){const t=r();p[i+e]=n.length;for(let r=0;r<n.length;r++)if(t<n[r]){p[i+e]=r;break}}}return s||n.disposeIntermediateTensorInfo(l),n.makeTensorInfo(d,"int32",p)}const multinomialConfig$1={kernelName:Multinomial,backendName:"cpu",kernelFunc:multinomial$1},nonMaxSuppressionV3Impl$1=nonMaxSuppressionV3Impl$2;
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function nonMaxSuppressionV3$1(e){const{inputs:t,backend:n,attrs:r}=e,{boxes:i,scores:a}=t,{maxOutputSize:o,iouThreshold:s,scoreThreshold:l}=r;assertNotComplex$1(i,"NonMaxSuppression");const c=n.data.get(i.dataId).values,h=n.data.get(a.dataId).values,{selectedIndices:u}=nonMaxSuppressionV3Impl$1(c,h,o,s,l);return n.makeTensorInfo([u.length],"int32",new Int32Array(u))}const nonMaxSuppressionV3Config$1={kernelName:NonMaxSuppressionV3,backendName:"cpu",kernelFunc:nonMaxSuppressionV3$1},nonMaxSuppressionV4Impl$1=nonMaxSuppressionV4Impl$2;
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function nonMaxSuppressionV4$1(e){const{inputs:t,backend:n,attrs:r}=e,{boxes:i,scores:a}=t,{maxOutputSize:o,iouThreshold:s,scoreThreshold:l,padToMaxOutputSize:c}=r;assertNotComplex$1(i,"NonMaxSuppressionPadded");const h=n.data.get(i.dataId).values,u=n.data.get(a.dataId).values,{selectedIndices:d,validOutputs:p}=nonMaxSuppressionV4Impl$1(h,u,o,s,l,c);return[n.makeTensorInfo([d.length],"int32",new Int32Array(d)),n.makeTensorInfo([],"int32",new Int32Array([p]))]}const nonMaxSuppressionV4Config$1={kernelName:NonMaxSuppressionV4,backendName:"cpu",kernelFunc:nonMaxSuppressionV4$1},nonMaxSuppressionV5Impl$1=nonMaxSuppressionV5Impl$2;
/**
     * @license
     * Copyright 2019 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function nonMaxSuppressionV5$1(e){const{inputs:t,backend:n,attrs:r}=e,{boxes:i,scores:a}=t,{maxOutputSize:o,iouThreshold:s,scoreThreshold:l,softNmsSigma:c}=r;assertNotComplex$1(i,"NonMaxSuppressionWithScore");const h=n.data.get(i.dataId).values,u=n.data.get(a.dataId).values,d=o,p=s,m=l,f=c,{selectedIndices:g,selectedScores:v}=nonMaxSuppressionV5Impl$1(h,u,d,p,m,f);return[n.makeTensorInfo([g.length],"int32",new Int32Array(g)),n.makeTensorInfo([v.length],"float32",new Float32Array(v))]}const nonMaxSuppressionV5Config$1={kernelName:NonMaxSuppressionV5,backendName:"cpu",kernelFunc:nonMaxSuppressionV5$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function oneHot$1(e){const{inputs:t,backend:n,attrs:r}=e,{indices:i}=t,{depth:a,onValue:o,offValue:s}=r;assertNotComplex$1(i,"oneHot");const l=sizeFromShape(i.shape),c=new Float32Array(l*a);c.fill(s);const h=n.data.get(i.dataId).values;for(let e=0;e<l;++e)h[e]>=0&&h[e]<a&&(c[e*a+h[e]]=o);return n.makeTensorInfo([...i.shape,a],"int32",c)}const oneHotConfig$1={kernelName:OneHot,backendName:"cpu",kernelFunc:oneHot$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function zerosLike$1(e){const{inputs:t,backend:n}=e,{x:r}=t;if("string"===r.dtype)throw new Error("zerosLike is not supported for string tensors");if("complex64"===r.dtype){const e=real$1({inputs:{input:r},backend:n}),t=zerosLike$1({inputs:{x:e},backend:n}),i=imag$1({inputs:{input:r},backend:n}),a=zerosLike$1({inputs:{x:i},backend:n}),o=complex$1({inputs:{real:t,imag:a},backend:n});return n.disposeIntermediateTensorInfo(e),n.disposeIntermediateTensorInfo(t),n.disposeIntermediateTensorInfo(i),n.disposeIntermediateTensorInfo(a),o}return fill$1({backend:n,attrs:{shape:r.shape,value:0,dtype:r.dtype}})}const zerosLikeConfig$1={kernelName:ZerosLike,backendName:"cpu",kernelFunc:zerosLike$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function onesLike$1(e){const{inputs:t,backend:n}=e,{x:r}=t;if("string"===r.dtype)throw new Error("onesLike is not supported for string tensors");if("complex64"===r.dtype){const e=real$1({inputs:{input:r},backend:n}),t=onesLike$1({inputs:{x:e},backend:n}),i=imag$1({inputs:{input:r},backend:n}),a=zerosLike$1({inputs:{x:i},backend:n}),o=complex$1({inputs:{real:t,imag:a},backend:n});return n.disposeIntermediateTensorInfo(e),n.disposeIntermediateTensorInfo(t),n.disposeIntermediateTensorInfo(i),n.disposeIntermediateTensorInfo(a),o}return fill$1({backend:n,attrs:{shape:r.shape,value:1,dtype:r.dtype}})}const onesLikeConfig$1={kernelName:OnesLike,backendName:"cpu",kernelFunc:onesLike$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function pack$1(e){const{inputs:t,backend:n,attrs:r}=e,{axis:i}=r;if(1===t.length)return expandDims$1({inputs:{input:t[0]},backend:n,attrs:{dim:i}});const a=t[0].shape,o=t[0].dtype;t.forEach((e=>{assertShapesMatch(a,e.shape,"All tensors passed to stack must have matching shapes"),assert$1(o===e.dtype,(()=>"All tensors passed to stack must have matching dtypes"))}));const s=[],l=concat$1({inputs:t.map((e=>{const t=expandDims$1({inputs:{input:e},backend:n,attrs:{dim:i}});return s.push(t),t})),backend:n,attrs:{axis:i}});return s.forEach((e=>n.disposeIntermediateTensorInfo(e))),l}const packConfig$1={kernelName:Pack,backendName:"cpu",kernelFunc:pack$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function padV2$1(e){const{inputs:t,backend:n,attrs:r}=e,{x:i}=t,{paddings:a,constantValue:o}=r;assertNotComplex$1(i,"pad");const s=a.map(((e,t)=>e[0]+i.shape[t]+e[1])),l=a.map((e=>e[0])),c=n.data.get(i.dataId).values,h=sizeFromShape(i.shape),u=i.shape.length,d=computeStrides(i.shape),p=sizeFromShape(s),m=s.length,f=computeStrides(s),g=getTypedArrayFromDType(i.dtype,p);0!==o&&g.fill(o);for(let e=0;e<h;e++){g[locToIndex(indexToLoc(e,u,d).map(((e,t)=>e+l[t])),m,f)]=c[e]}return{dataId:n.write(g,s,i.dtype),shape:s,dtype:i.dtype}}const padV2Config$1={kernelName:PadV2,backendName:"cpu",kernelFunc:padV2$1},powImpl=createSimpleBinaryKernelImpl(((e,t)=>Math.pow(e,t))),pow$2=binaryKernelFunc$1(Pow,powImpl),powConfig$1={kernelName:Pow,backendName:"cpu",kernelFunc:pow$2};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
function range$2(e){const{backend:t,attrs:n}=e,{start:r,stop:i,dtype:a,step:o}=n,s=rangeImpl(r,i,o,a);return t.makeTensorInfo([s.length],a,s)}const rangeConfig$1={kernelName:Range,backendName:"cpu",kernelFunc:range$2},reciprocal$1=unaryKernelFunc$1(Reciprocal,(e=>1/e)),reciprocalConfig$1={kernelName:Reciprocal,backendName:"cpu",kernelFunc:reciprocal$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the License);
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an AS IS BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
function resizeBilinear$1(e){const{inputs:t,backend:n,attrs:r}=e,{images:i}=t,{alignCorners:a,halfPixelCenters:o,size:s}=r;assertNotComplex$1(i,"resizeBilinear");const l=computeStrides(i.shape),[c,h]=s,[u,d,p,m]=i.shape,f=n.data.get(i.dataId).values,g=new Float32Array(sizeFromShape([u,c,h,m])),v=[a&&c>1?d-1:d,a&&h>1?p-1:p],y=[a&&c>1?c-1:c,a&&h>1?h-1:h];let _=0;const b=v[0]/y[0],x=v[1]/y[1];for(let e=0;e<u;e++)for(let t=0;t<c;t++){let n;n=o?b*(t+.5)-.5:b*t;const r=Math.max(0,Math.floor(n)),i=n-r,a=Math.min(d-1,Math.ceil(n)),s=e*l[0]+r*l[1],c=e*l[0]+a*l[1];for(let e=0;e<h;e++){let t;t=o?x*(e+.5)-.5:x*e;const n=Math.max(0,Math.floor(t)),r=t-n,a=Math.min(p-1,Math.ceil(t)),h=s+n*l[2],u=c+n*l[2],d=s+a*l[2],v=c+a*l[2];for(let e=0;e<m;e++){const t=f[h+e],n=f[u+e],a=t+(f[d+e]-t)*r;g[_++]=a+(n+(f[v+e]-n)*r-a)*i}}}return n.makeTensorInfo([u,c,h,m],"float32",g)}const resizeBilinearConfig$1={kernelName:ResizeBilinear,backendName:"cpu",kernelFunc:resizeBilinear$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function resizeBilinearGrad$1(e){const{inputs:t,backend:n,attrs:r}=e,{images:i,dy:a}=t,{alignCorners:o}=r;assertNotComplex$1([a,i],"resizeBilinearGrad");const s=computeStrides(i.shape),[l,c,h,u]=i.shape,[,d,p]=a.shape,m=new Float32Array(l*c*h*u),f=[o&&d>1?c-1:c,o&&p>1?h-1:h],g=[o&&d>1?d-1:d,o&&p>1?p-1:p],v=f[0]/g[0],y=f[1]/g[1],_=n.data.get(a.dataId).values;let b=0;for(let e=0;e<l;e++){const t=e*s[0];for(let e=0;e<d;e++){const n=e*v,r=Math.floor(n),i=Math.min(Math.ceil(n),c-1),a=t+r*s[1],o=t+i*s[1],l=n-r,d=1-l;for(let e=0;e<p;e++){const t=e*y,n=Math.floor(t),r=Math.min(Math.ceil(t),h-1),i=t-n,c=1-i,p=a+n*s[2],f=a+r*s[2],g=o+n*s[2],v=o+r*s[2],x=d*c,S=d*i,w=l*c,C=l*i;for(let e=0;e<u;e++){const t=_[b++];m[p+e]+=t*x,m[f+e]+=t*S,m[g+e]+=t*w,m[v+e]+=t*C}}}}return n.makeTensorInfo([l,h,c,u],"float32",m)}const resizeBilinearGradConfig$1={kernelName:ResizeBilinearGrad,backendName:"cpu",kernelFunc:resizeBilinearGrad$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function resizeNearestNeighbor$1(e){const{inputs:t,backend:n,attrs:r}=e,{images:i}=t,{alignCorners:a,halfPixelCenters:o,size:s}=r;assertNotComplex$1(i,"resizeNearestNeighbor");const l=computeStrides(i.shape),[c,h]=s,[u,d,p,m]=i.shape,f=n.data.get(i.dataId).values,g=new Float32Array(u*c*h*m),v=[a&&c>1?d-1:d,a&&h>1?p-1:p],y=[a&&c>1?c-1:c,a&&h>1?h-1:h],_=v[0]/y[0],b=v[1]/y[1];let x=0;for(let e=0;e<u;e++){const t=e*l[0];for(let e=0;e<c;e++){const n=o?_*(e+.5):_*e;let r=Math.min(d-1,a?Math.round(n):Math.floor(n));o&&(r=Math.max(0,r));const i=t+r*l[1];for(let e=0;e<h;e++){const t=o?b*(e+.5):b*e;let n=Math.min(p-1,a?Math.round(t):Math.floor(t));o&&(n=Math.max(0,n));const r=i+n*l[2];for(let e=0;e<m;e++){g[x++]=f[r+e]}}}}return n.makeTensorInfo([u,c,h,m],i.dtype,g)}const resizeNearestNeighborConfig$1={kernelName:ResizeNearestNeighbor,backendName:"cpu",kernelFunc:resizeNearestNeighbor$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function resizeNearestNeighborGrad$1(e){const{inputs:t,backend:n,attrs:r}=e,{images:i,dy:a}=t,{alignCorners:o}=r;assertNotComplex$1([a,i],"resizeNearestNeighborGrad");const s=computeStrides(i.shape),l=computeStrides(a.shape),[c,h,u,d]=i.shape,[,p,m]=a.shape,f=new Float32Array(c*h*u*d),g=n.data.get(a.dataId).values,v=[o&&p>1?h-1:h,o&&m>1?u-1:u],y=[o&&p>1?p-1:p,o&&m>1?m-1:m],_=v[0]/y[0],b=v[1]/y[1],x=1/_,S=1/b,w=2*Math.ceil(x)+2,C=2*Math.ceil(S)+2;for(let e=0;e<c;e++){const t=e*s[0];for(let e=0;e<h;e++){const n=t+e*s[1],r=Math.floor(e*x),i=Math.floor(r-w/2);for(let r=0;r<u;r++){const a=n+r*s[2],c=Math.floor(r*S),v=Math.floor(c-C/2);for(let n=0;n<d;n++){let s=0;for(let a=0;a<w;a++){const c=a+i;if(c<0||c>=p)continue;const d=t+c*l[1],f=c*_;if(e===Math.min(h-1,o?Math.round(f):Math.floor(f)))for(let e=0;e<C;e++){const t=e+v;if(t<0||t>=m)continue;const i=d+t*l[2],a=t*b;r===Math.min(u-1,o?Math.round(a):Math.floor(a))&&(s+=g[i+n])}}f[a+n]=s}}}}return n.makeTensorInfo(i.shape,i.dtype,f)}const resizeNearestNeighborGradConfig$1={kernelName:ResizeNearestNeighborGrad,backendName:"cpu",kernelFunc:resizeNearestNeighborGrad$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function reverse$1(e){const{inputs:t,backend:n,attrs:r}=e,{x:i}=t,{dims:a}=r;assertNotComplex$1(i,"reverse");const o=i.shape.length,s=parseAxisParam(a,i.shape);if(0===o)return identity$3({inputs:{x:i},backend:n});const l=new TensorBuffer(i.shape,i.dtype),c=n.bufferSync(i);for(let e=0;e<l.size;e++){const t=l.indexToLoc(e),n=t.slice();s.forEach((e=>n[e]=i.shape[e]-1-n[e])),l.set(c.get(...n),...t)}return n.makeTensorInfo(l.shape,l.dtype,l.values)}const reverseConfig$1={kernelName:Reverse,backendName:"cpu",kernelFunc:reverse$1},rotateWithOffsetConfig$1={kernelName:RotateWithOffset,backendName:"cpu",kernelFunc:({inputs:e,attrs:t,backend:n})=>{const{image:r}=e,{radians:i,fillValue:a,center:o}=t,s=n,l=getTypedArrayFromDType(r.dtype,sizeFromShape(r.shape)),[c,h,u,d]=r.shape,[p,m]=getImageCenter(o,h,u),f=Math.sin(i),g=Math.cos(i),v=s.data.get(r.dataId).values;for(let e=0;e<c;e++){const t=e*u*h*d;for(let e=0;e<h;e++){const n=e*(u*d);for(let r=0;r<u;r++){const i=r*d;for(let o=0;o<d;o++){const s=[c,e,r,o],y=s[2],_=s[1];let b=(y-p)*g-(_-m)*f,x=(y-p)*f+(_-m)*g;b=Math.round(b+p),x=Math.round(x+m);let S=a;if("number"!=typeof a&&(S=3===o?255:a[o]),b>=0&&b<u&&x>=0&&x<h){S=v[t+x*(u*d)+b*d+o]}l[t+n+i+o]=S}}}}return{dataId:s.write(l,r.shape,r.dtype),shape:r.shape,dtype:r.dtype}}},round$1=unaryKernelFunc$1(Round,(e=>{const t=Math.floor(e);return e-t<.5?Math.floor(e):e-t>.5?Math.ceil(e):t%2==0?t:t+1})),roundConfig$1={kernelName:Round,backendName:"cpu",kernelFunc:round$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
function scatterImpl(e,t,n,r,i,a,o,s,l,c){const h=[r/i,i],u=e.values,d=t.values;if(0===r)return buffer(n,t.dtype);const p=buffer(h,t.dtype);p.values.fill(l);for(let e=0;e<a;e++){const a=[];let l=0;for(let t=0;t<o;t++){const n=u[e*o+t];a.push(n),l+=n*s[t]}if(l<0||l>=r/i)throw new Error(`Invalid indices: ${a} does not index into ${n}`);for(let n=0;n<i;n++)c?p.values[l*i+n]+=d[e*i+n]:p.values[l*i+n]=0===t.rank?d[0]:d[e*i+n]}return p}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function scatterNd$1(e){const{inputs:t,backend:n,attrs:r}=e,{indices:i,updates:a}=t,{shape:o}=r,{sliceRank:s,numUpdates:l,sliceSize:c,strides:h,outputSize:u}=calculateShapes(a,i,o),d=scatterImpl(n.bufferSync(i),n.bufferSync(a),o,u,c,l,s,h,0,!0);return n.makeTensorInfo(o,d.dtype,d.values)}const scatterNdConfig$1={kernelName:ScatterNd,backendName:"cpu",kernelFunc:scatterNd$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function select$1(e){const{inputs:t,backend:n}=e,{condition:r,t:i,e:a}=t;assertNotComplex$1([r,i,a],"select");const o=r.shape.length,s=n.data.get(r.dataId).values,l=n.data.get(i.dataId).values,c=n.data.get(a.dataId).values,h=upcastType(i.dtype,a.dtype),u=makeZerosTypedArray(sizeFromShape(i.shape),h);let d=0;const p=0===o||o>1||1===i.shape.length?1:sizeFromShape(i.shape.slice(1));for(let e=0;e<s.length;e++)for(let t=0;t<p;t++)u[d++]=1===s[e]?l[e]:c[e];return n.makeTensorInfo(i.shape,h,u)}const selectConfig$1={kernelName:Select,backendName:"cpu",kernelFunc:select$1},scaleAlpha=SELU_SCALEALPHA,scale=SELU_SCALE,selu$1=unaryKernelFunc$1(Selu,(e=>e>=0?scale*e:scaleAlpha*(Math.exp(e)-1))),seluConfig$1={kernelName:Selu,backendName:"cpu",kernelFunc:selu$1},sigmoid$1=unaryKernelFunc$1(Sigmoid,(e=>1/(1+Math.exp(-e)))),sigmoidConfig$1={kernelName:Sigmoid,backendName:"cpu",kernelFunc:sigmoid$1},sign$2=unaryKernelFunc$1(Sign,(e=>e<0?-1:e>0?1:0)),signConfig$1={kernelName:Sign,backendName:"cpu",kernelFunc:sign$2},sin$1=unaryKernelFunc$1(Sin,(e=>Math.sin(e))),sinConfig$1={kernelName:Sin,backendName:"cpu",kernelFunc:sin$1},sinh$1=unaryKernelFunc$1(Sinh,(e=>Math.sinh(e))),sinhConfig$1={kernelName:Sinh,backendName:"cpu",kernelFunc:sinh$1},epsilon=1.1920928955078125e-7,threshold=Math.log(epsilon)+2,softplus$1=unaryKernelFunc$1(Softplus,(e=>{const t=e>-threshold,n=e<threshold,r=Math.exp(e);let i;return i=n?r:t?e:Math.log(1+r),i})),softplusConfig$1={kernelName:Softplus,backendName:"cpu",kernelFunc:softplus$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the License);
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an AS IS BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
function spaceToBatchND$1(e){const{inputs:t,backend:n,attrs:r}=e,{x:i}=t,{blockShape:a,paddings:o}=r;assertNotComplex$1([i],"spaceToBatchND");const s=sizeFromShape(a),l=[[0,0]];l.push(...o);for(let e=1+a.length;e<i.shape.length;++e)l.push([0,0]);const c=padV2Config$1.kernelFunc({inputs:{x:i},backend:n,attrs:{paddings:l,constantValue:0}}),h=getReshaped(c.shape,a,s,!1),u=getPermuted(h.length,a.length,!1),d=getReshapedPermuted(c.shape,a,s,!1),p=reshape$1({inputs:{x:c},backend:n,attrs:{shape:h}}),m=transpose$1({inputs:{x:p},backend:n,attrs:{perm:u}}),f=reshape$1({inputs:{x:m},backend:n,attrs:{shape:d}});return n.disposeIntermediateTensorInfo(c),n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(m),f}const spaceToBatchNDConfig$1={kernelName:SpaceToBatchND,backendName:"cpu",kernelFunc:spaceToBatchND$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function sparseToDense$1(e){const{inputs:t,backend:n,attrs:r}=e,{sparseIndices:i,sparseValues:a,defaultValue:o}=t,{outputShape:s}=r,{sliceRank:l,numUpdates:c,sliceSize:h,strides:u,outputSize:d}=calculateShapes(a,i,s),p=scatterImpl(n.bufferSync(i),n.bufferSync(a),s,d,h,c,l,u,n.data.get(o.dataId).values[0],!1);return n.makeTensorInfo(s,p.dtype,p.values)}const sparseToDenseConfig$1={kernelName:SparseToDense,backendName:"cpu",kernelFunc:sparseToDense$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function splitV$1(e){const{inputs:t,backend:n,attrs:r}=e,{x:i}=t,{numOrSizeSplits:a,axis:o}=r,s=parseAxisParam(o,i.shape)[0],l=prepareSplitSize(i,a,s),c=new Array(i.shape.length).fill(0),h=i.shape.slice();return l.map((e=>{const t=[...h];t[s]=e;const r=slice$2({inputs:{x:i},backend:n,attrs:{begin:c,size:t}});return c[s]+=e,r}))}const splitVConfig$1={kernelName:SplitV,backendName:"cpu",kernelFunc:splitV$1},sqrt$1=unaryKernelFunc$1(Sqrt,(e=>Math.sqrt(e))),sqrtConfig$1={kernelName:Sqrt,backendName:"cpu",kernelFunc:sqrt$1},squareConfig$1={kernelName:Square,backendName:"cpu",kernelFunc:({inputs:e,backend:t})=>{const{x:n}=e,r=t;assertNotComplex$1(n,"square");const i=r.data.get(n.dataId).values,a=new Float32Array(i.length);for(let e=0;e<i.length;++e){const t=i[e];a[e]=t*t}return{dataId:r.write(a,n.shape,n.dtype),shape:n.shape,dtype:n.dtype}}},step$1=unaryKernelFunc$1(Step,((e,t)=>{const n=t;return isNaN(e)?NaN:e>0?1:n.alpha})),stepConfig$1={kernelName:Step,backendName:"cpu",kernelFunc:step$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the License);
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an AS IS BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
function stridedSlice$1(e){const{inputs:t,backend:n,attrs:r}=e,{x:i}=t,{begin:a,end:o,strides:s,beginMask:l,endMask:c,ellipsisMask:h,newAxisMask:u,shrinkAxisMask:d}=r;assertNotComplex$1(i,"stridedSlice");const{nonStrided:p,$begin:m,$strides:f,size:g,newShape:v,outShape:y}=sliceInfo(i.shape,a,o,s,l,c,h,u,d),_=reshape$1({inputs:{x:i},backend:n,attrs:{shape:v}});let b;if(p){const e=slice$2({inputs:{x:_},backend:n,attrs:{begin:m,size:g}});b=reshape$1({inputs:{x:e},backend:n,attrs:{shape:y}}),n.disposeIntermediateTensorInfo(e)}else if(y.some((e=>0===e)))b=n.makeTensorInfo(y,i.dtype,[]);else{const e=stridedSliceImpl(y,n.bufferSync(_),f,m);b=n.makeTensorInfo(e.shape,e.dtype,e.values)}const x=reshape$1({inputs:{x:b},backend:n,attrs:{shape:y}});return n.disposeIntermediateTensorInfo(_),n.disposeIntermediateTensorInfo(b),x}const stridedSliceConfig$1={kernelName:StridedSlice,backendName:"cpu",kernelFunc:stridedSlice$1},tan$1=unaryKernelFunc$1(Tan,(e=>Math.tan(e))),tanConfig$1={kernelName:Tan,backendName:"cpu",kernelFunc:tan$1},tanh$1=unaryKernelFunc$1(Tanh,(e=>Math.tanh(e))),tanhConfig$1={kernelName:Tanh,backendName:"cpu",kernelFunc:tanh$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the License);
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an AS IS BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
function tile$1(e){const{inputs:t,backend:n,attrs:r}=e,{x:i}=t,{reps:a}=r;assertNotComplex$1(i,"tile");const o=tileImpl(n.bufferSync(i),a);return n.makeTensorInfo(o.shape,o.dtype,o.values)}const tileConfig$1={kernelName:Tile,backendName:"cpu",kernelFunc:tile$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function topK$1(e){const{inputs:t,backend:n,attrs:r}=e,{x:i}=t,{k:a}=r;assertNotComplex$1(i,"topk");const o=n.data.get(i.dataId).values,[s,l]=topKImpl(o,i.shape,i.dtype,a);return[n.makeTensorInfo(s.shape,s.dtype,s.values),n.makeTensorInfo(l.shape,l.dtype,l.values)]}const topKConfig$1={kernelName:TopK,backendName:"cpu",kernelFunc:topK$1};
/**
     * @license
     * Copyright 2021 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function transform$1(e){const{inputs:t,attrs:n,backend:r}=e,{image:i,transforms:a}=t,{interpolation:o,fillMode:s,fillValue:l,outputShape:c}=n,[h,u,d,p]=i.shape,[m,f]=null!=c?c:[u,d],g=[h,m,f,p],v=computeStrides(i.shape),y=v[0],_=v[1],b=v[2],x=getTypedArrayFromDType(i.dtype,sizeFromShape(g));x.fill(l);const S=r.data.get(i.dataId).values,w=r.data.get(a.dataId).values;for(let e=0;e<h;++e){const t=1===a.shape[0]?w:w.subarray(8*e,8*e+8);for(let n=0;n<m;++n)for(let r=0;r<f;++r)for(let i=0;i<p;++i){let a;const c=t[6]*r+t[7]*n+1;if(0===c)continue;const h=(t[3]*r+t[4]*n+t[5])/c,p=mapCoord((t[0]*r+t[1]*n+t[2])/c,d,s),m=mapCoord(h,u,s);switch(o){case"nearest":a=nearestInterpolation(S,u,d,y,_,b,e,m,p,i,l);break;case"bilinear":a=bilinearInterpolation(S,u,d,y,_,b,e,m,p,i,l);break;default:throw new Error(`Error in Transform: Expect 'nearest' or 'bilinear', but got ${o}`)}x[e*y+n*_+r*b+i]=a}return r.makeTensorInfo(g,i.dtype,x)}return{dataId:r.write(x,g,i.dtype),shape:i.shape,dtype:i.dtype}}const transformConfig$1={kernelName:Transform,backendName:"cpu",kernelFunc:transform$1};function mapCoord(e,t,n){switch(n){case"reflect":return mapCoordReflect(e,t);case"wrap":return mapCoordWrap(e,t);case"nearest":return mapCoordNearest(e,t);case"constant":default:return mapCoordConstant(e)}}function mapCoordReflect(e,t){let n=e;if(n<0)if(t<=1)n=0;else{const e=2*t;n<e&&(n=e*Math.trunc(-n/e)+n),n=n<-t?n+e:-n-1}else if(n>t-1)if(t<=1)n=0;else{const e=2*t;n-=e*Math.trunc(n/e),n>=t&&(n=e-n-1)}return clamp$1(0,n,t-1)}function mapCoordWrap(e,t){let n=e;if(n<0)if(t<=1)n=0;else{n+=t*(Math.trunc(-n/(t-1))+1)}else if(n>t-1)if(t<=1)n=0;else{n-=t*Math.trunc(n/(t-1))}return clamp$1(0,n,t-1)}function mapCoordConstant(e,t){return e}function mapCoordNearest(e,t){return clamp$1(0,e,t-1)}function readWithFillValue(e,t,n,r,i,a,o,s,l,c,h){return 0<=s&&s<t&&0<=l&&l<n?e[o*r+s*i+l*a+c]:h}function nearestInterpolation(e,t,n,r,i,a,o,s,l,c,h){return readWithFillValue(e,t,n,r,i,a,o,Math.round(s),Math.round(l),c,h)}function bilinearInterpolation(e,t,n,r,i,a,o,s,l,c,h){const u=Math.floor(s),d=Math.floor(l),p=u+1,m=d+1;return(p-s)*((m-l)*readWithFillValue(e,t,n,r,i,a,o,u,d,c,h)+(l-d)*readWithFillValue(e,t,n,r,i,a,o,u,m,c,h))+(s-u)*((m-l)*readWithFillValue(e,t,n,r,i,a,o,p,d,c,h)+(l-d)*readWithFillValue(e,t,n,r,i,a,o,p,m,c,h))}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the License);
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an AS IS BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function unique$1(e){const{inputs:t,attrs:n,backend:r}=e,{axis:i}=n,{x:a}=t;assertNotComplex$1(a,"unique");const o=r.data.get(a.dataId).values,{outputValues:s,outputShape:l,indices:c}=uniqueImpl(o,i,a.shape,a.dtype);return[r.makeTensorInfo(l,a.dtype,s),r.makeTensorInfo([c.length],"int32",c)]}const uniqueConfig$1={kernelName:Unique,backendName:"cpu",kernelFunc:unique$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function unpack$1(e){const{inputs:t,backend:n,attrs:r}=e,{value:i}=t;let{axis:a}=r;a<0&&(a+=i.shape.length);const o=i.shape.length,s=i.shape[a],l=new Array(o-1);let c=0;for(let e=0;e<o;e++)e!==a&&(l[c++]=i.shape[e]);const h=new Array(o).fill(0),u=i.shape.slice();u[a]=1;const d=new Array(s);for(let e=0;e<d.length;e++){h[a]=e;const t=slice$2({inputs:{x:i},backend:n,attrs:{begin:h,size:u}});d[e]=reshape$1({inputs:{x:t},backend:n,attrs:{shape:l}}),n.disposeIntermediateTensorInfo(t)}return d}const unpackConfig$1={kernelName:Unpack,backendName:"cpu",kernelFunc:unpack$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function unsortedSegmentSum$1(e){const{inputs:t,backend:n,attrs:r}=e,{x:i,segmentIds:a}=t,{numSegments:o}=r;assertNotComplex$1(i,"unsortedSegmentSum");const s=[],l=[],c=i.shape.length-a.shape.length;let h=a;for(let e=0;e<c;++e){const t=expandDims$1({inputs:{input:h},backend:n,attrs:{dim:e+1}});h=t,l.push(t)}for(let e=0;e<o;++e){const t=createScalarValue(e,"int32"),r=n.makeTensorInfo([],"int32",t),a=equal$1({inputs:{a:r,b:h},backend:n}),o=cast$1({inputs:{x:a},backend:n,attrs:{dtype:"float32"}}),c=multiply$1({inputs:{a:o,b:i},backend:n}),u=sum$1({inputs:{x:c},backend:n,attrs:{axis:0,keepDims:!1}});s.push(u),l.push(r),l.push(a),l.push(o),l.push(c),l.push(u)}const u=pack$1({inputs:s,backend:n,attrs:{axis:0}});return l.forEach((e=>n.disposeIntermediateTensorInfo(e))),u}const unsortedSegmentSumConfig$1={kernelName:UnsortedSegmentSum,backendName:"cpu",kernelFunc:unsortedSegmentSum$1},kernelConfigs$1=[_fusedMatMulConfig$1,absConfig$1,acosConfig$1,acoshConfig$1,addConfig$1,addNConfig$1,allConfig$1,anyConfig$1,argMaxConfig$1,argMinConfig$1,asinConfig$1,asinhConfig$1,atanConfig$1,atan2Config$1,atanhConfig$1,avgPoolConfig$1,avgPool3DConfig$1,avgPool3DGradConfig,avgPoolGradConfig$1,batchMatMulConfig$1,batchNormConfig$1,batchToSpaceNDConfig$1,bincountConfig$1,castConfig$1,ceilConfig$1,clipConfig,complexConfig$1,complexAbsConfig$1,concatConfig$1,conv2DBackpropFilterConfig$1,conv2DBackpropInputConfig$1,conv2DConfig$1,conv3DBackpropFilterV2Config$1,conv3DBackpropInputV2Config,conv3DConfig$1,cosConfig$1,coshConfig$1,cropAndResizeConfig$1,cumsumConfig$1,denseBincountConfig$1,depthToSpaceConfig$1,depthwiseConv2dNativeConfig$1,depthwiseConv2dNativeBackpropFilterConfig$1,depthwiseConv2dNativeBackpropInputConfig$1,diagConfig$1,dilation2dConfig,dilation2dBackpropInputConfig,dilation2dBackpropFilterConfig,realDivConfig$1,einsumConfig$1,eluConfig$1,eluGradConfig$1,equalConfig$1,erfConfig$1,expConfig$1,expandDimsConfig$1,expm1Config$1,fftConfig$1,fillConfig$1,flipLeftRightConfig$1,floorConfig$1,floorDivConfig$1,fusedConv2DConfig$1,fusedDepthwiseConv2DConfig$1,gatherNdConfig$1,gatherV2Config$1,greaterConfig$1,greaterEqualConfig$1,identityConfig$1,ifftConfig$1,imagConfig$1,isFiniteConfig$1,isInfConfig$1,isNaNConfig$1,leakyReluConfig$1,lessConfig$1,lessEqualConfig$1,linSpaceConfig$1,logConfig$1,log1pConfig$1,logicalAndConfig$1,logicalNotConfig$1,logicalOrConfig$1,lRNConfig,lRNGradConfig,maximumConfig$1,maxPoolConfig$1,maxPool3DConfig$1,maxPool3DGradConfig,maxPoolGradConfig$1,maxPoolWithArgmaxConfig$1,maxConfig$1,meanConfig$1,minConfig$1,minimumConfig$1,mirrorPadConfig$1,modConfig$1,multinomialConfig$1,multiplyConfig$1,negConfig$1,nonMaxSuppressionV3Config$1,nonMaxSuppressionV4Config$1,nonMaxSuppressionV5Config$1,notEqualConfig$1,oneHotConfig$1,onesLikeConfig$1,packConfig$1,padV2Config$1,powConfig$1,preluConfig$1,prodConfig$1,rangeConfig$1,realConfig$1,reciprocalConfig$1,reluConfig$1,relu6Config$1,reshapeConfig$1,resizeBilinearConfig$1,resizeBilinearGradConfig$1,resizeNearestNeighborConfig$1,resizeNearestNeighborGradConfig$1,reverseConfig$1,rotateWithOffsetConfig$1,roundConfig$1,rsqrtConfig$1,scatterNdConfig$1,selectConfig$1,seluConfig$1,sigmoidConfig$1,signConfig$1,sinConfig$1,sinhConfig$1,sliceConfig$1,softmaxConfig$1,softplusConfig$1,spaceToBatchNDConfig$1,sparseToDenseConfig$1,splitVConfig$1,sqrtConfig$1,squareConfig$1,squaredDifferenceConfig$1,stepConfig$1,stridedSliceConfig$1,subConfig$1,sumConfig$1,tanConfig$1,tanhConfig$1,tileConfig$1,topKConfig$1,transposeConfig$1,transformConfig$1,uniqueConfig$1,unpackConfig$1,unsortedSegmentSumConfig$1,zerosLikeConfig$1];
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */for(const e of kernelConfigs$1)registerKernel(e);
/**
     * @license
     * Copyright 2018 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */const contexts={},WEBGL_ATTRIBUTES={alpha:!1,antialias:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,depth:!1,stencil:!1,failIfMajorPerformanceCaveat:!0};function setWebGLContext(e,t){contexts[e]=t}function getWebGLContext(e){if(!(e in contexts)){const t=getWebGLRenderingContext(e);if(null===t)return console.log("Could not get context for WebGL version",e),null;contexts[e]=t}const t=contexts[e];return t.isContextLost()?(delete contexts[e],getWebGLContext(e)):(t.disable(t.DEPTH_TEST),t.disable(t.STENCIL_TEST),t.disable(t.BLEND),t.disable(t.DITHER),t.disable(t.POLYGON_OFFSET_FILL),t.disable(t.SAMPLE_COVERAGE),t.enable(t.SCISSOR_TEST),t.enable(t.CULL_FACE),t.cullFace(t.BACK),contexts[e])}function createCanvas(e){if("undefined"!=typeof OffscreenCanvas&&2===e)return new OffscreenCanvas(300,150);if("undefined"!=typeof document)return document.createElement("canvas");throw new Error("Cannot create a canvas in this context")}function getWebGLRenderingContext(e){if(1!==e&&2!==e)throw new Error("Cannot get WebGL rendering context, WebGL is disabled.");const t=createCanvas(e);return t.addEventListener("webglcontextlost",(t=>{t.preventDefault(),delete contexts[e]}),!1),1===e?t.getContext("webgl",WEBGL_ATTRIBUTES)||t.getContext("experimental-webgl",WEBGL_ATTRIBUTES):t.getContext("webgl2",WEBGL_ATTRIBUTES)}
/**
     * @license
     * Copyright 2017 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */var PackingScheme,TextureUsage,PhysicalTextureType;function getUnpackedMatrixTextureShapeWidthHeight(e,t){return[t,e]}function getUnpackedArraySizeFromMatrixSize(e,t){return e*t}function getDenseTexShape(e){const t=sizeFromShape(e);return sizeToSquarishShape(Math.ceil(t/4))}function getPackedMatrixTextureShapeWidthHeight(e,t){return[Math.max(1,Math.ceil(t/2)),Math.max(1,Math.ceil(e/2))]}function getPackedRGBAArraySizeFromMatrixShape(e,t){const[n,r]=getPackedMatrixTextureShapeWidthHeight(e,t);return n*r*4}function getTextureConfig(e,t){const n=e;let r,i,a,o,s,l,c,h,u,d;return 2===env().getNumber("WEBGL_VERSION")?(r=n.R32F,i=n.R16F,a=n.RGBA16F,o=n.RGBA32F,s=n.RED,c=4,h=1,u=n.HALF_FLOAT,d=n.FLOAT):(r=e.RGBA,i=e.RGBA,a=e.RGBA,o=n.RGBA,s=e.RGBA,c=4,h=4,u=null!=t?t.HALF_FLOAT_OES:null,d=e.FLOAT),l=e.RGBA,{internalFormatFloat:r,internalFormatHalfFloat:i,internalFormatPackedHalfFloat:a,internalFormatPackedFloat:o,textureFormatFloat:s,downloadTextureFormat:l,downloadUnpackNumChannels:c,defaultNumChannels:h,textureTypeHalfFloat:u,textureTypeFloat:d}}
/**
     * @license
     * Copyright 2017 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function callAndCheck(e,t){const n=t();return env().getBool("DEBUG")&&checkWebGLError(e),n}function checkWebGLError(e){const t=e.getError();if(t!==e.NO_ERROR)throw new Error("WebGL Error: "+getWebGLErrorMessage(e,t))}!(function(e){e[e.DENSE=0]="DENSE",e[e.SHARED_BATCH=1]="SHARED_BATCH"})(PackingScheme||(PackingScheme={})),(function(e){e[e.RENDER=0]="RENDER",e[e.UPLOAD=1]="UPLOAD",e[e.PIXELS=2]="PIXELS",e[e.DOWNLOAD=3]="DOWNLOAD"})(TextureUsage||(TextureUsage={})),(function(e){e[e.UNPACKED_FLOAT16=0]="UNPACKED_FLOAT16",e[e.UNPACKED_FLOAT32=1]="UNPACKED_FLOAT32",e[e.PACKED_4X1_UNSIGNED_BYTE=2]="PACKED_4X1_UNSIGNED_BYTE",e[e.PACKED_2X2_FLOAT32=3]="PACKED_2X2_FLOAT32",e[e.PACKED_2X2_FLOAT16=4]="PACKED_2X2_FLOAT16"})(PhysicalTextureType||(PhysicalTextureType={}));const MIN_FLOAT16=5.96e-8,MAX_FLOAT16=65504;function canBeRepresented(e){return!!(env().getBool("WEBGL_RENDER_FLOAT32_ENABLED")||0===e||MIN_FLOAT16<Math.abs(e)&&Math.abs(e)<MAX_FLOAT16)}function getWebGLErrorMessage(e,t){switch(t){case e.NO_ERROR:return"NO_ERROR";case e.INVALID_ENUM:return"INVALID_ENUM";case e.INVALID_VALUE:return"INVALID_VALUE";case e.INVALID_OPERATION:return"INVALID_OPERATION";case e.INVALID_FRAMEBUFFER_OPERATION:return"INVALID_FRAMEBUFFER_OPERATION";case e.OUT_OF_MEMORY:return"OUT_OF_MEMORY";case e.CONTEXT_LOST_WEBGL:return"CONTEXT_LOST_WEBGL";default:return`Unknown error code ${t}`}}function getExtensionOrThrow(e,t){return throwIfNull(e,(()=>e.getExtension(t)),'Extension "'+t+'" not supported on this browser.')}function createVertexShader$2(e,t){const n=throwIfNull(e,(()=>e.createShader(e.VERTEX_SHADER)),"Unable to create vertex WebGLShader.");if(callAndCheck(e,(()=>e.shaderSource(n,t))),callAndCheck(e,(()=>e.compileShader(n))),!1===e.getShaderParameter(n,e.COMPILE_STATUS))throw console.log(e.getShaderInfoLog(n)),new Error("Failed to compile vertex shader.");return n}function createFragmentShader$1(e,t){const n=throwIfNull(e,(()=>e.createShader(e.FRAGMENT_SHADER)),"Unable to create fragment WebGLShader.");if(callAndCheck(e,(()=>e.shaderSource(n,t))),callAndCheck(e,(()=>e.compileShader(n))),!1===e.getShaderParameter(n,e.COMPILE_STATUS))throw logShaderSourceAndInfoLog(t,e.getShaderInfoLog(n)),new Error("Failed to compile fragment shader.");return n}const lineNumberRegex=/ERROR: [0-9]+:([0-9]+):/g;function logShaderSourceAndInfoLog(e,t){const n=lineNumberRegex.exec(t);if(null==n)return console.log(`Couldn't parse line number in error: ${t}`),void console.log(e);const r=+n[1],i=e.split("\n"),a=i.length.toString().length+2,o=i.map(((e,t)=>rightPad((t+1).toString(),a)+e));let s=0;for(let e=0;e<o.length;e++)s=Math.max(o[e].length,s);const l=o.slice(0,r-1),c=o.slice(r-1,r),h=o.slice(r);console.log(l.join("\n")),console.log(t.split("\n")[0]),console.log(`%c ${rightPad(c[0],s)}`,"border:1px solid red; background-color:#e3d2d2; color:#a61717"),console.log(h.join("\n"))}function createProgram(e){return throwIfNull(e,(()=>e.createProgram()),"Unable to create WebGLProgram.")}function linkProgram(e,t){if(callAndCheck(e,(()=>e.linkProgram(t))),!1===e.getProgramParameter(t,e.LINK_STATUS))throw console.log(e.getProgramInfoLog(t)),new Error("Failed to link vertex and fragment shaders.")}function validateProgram(e,t){if(callAndCheck(e,(()=>e.validateProgram(t))),!1===e.getProgramParameter(t,e.VALIDATE_STATUS))throw console.log(e.getProgramInfoLog(t)),new Error("Shader program validation failed.")}function createStaticVertexBuffer(e,t){const n=throwIfNull(e,(()=>e.createBuffer()),"Unable to create WebGLBuffer");return callAndCheck(e,(()=>e.bindBuffer(e.ARRAY_BUFFER,n))),callAndCheck(e,(()=>e.bufferData(e.ARRAY_BUFFER,t,e.STATIC_DRAW))),n}function createStaticIndexBuffer(e,t){const n=throwIfNull(e,(()=>e.createBuffer()),"Unable to create WebGLBuffer");return callAndCheck(e,(()=>e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,n))),callAndCheck(e,(()=>e.bufferData(e.ELEMENT_ARRAY_BUFFER,t,e.STATIC_DRAW))),n}function createTexture$1(e){return throwIfNull(e,(()=>e.createTexture()),"Unable to create WebGLTexture.")}function validateTextureSize(e,t){const n=env().getNumber("WEBGL_MAX_TEXTURE_SIZE");if(e<=0||t<=0){throw new Error("Requested texture size "+`[${e}x${t}]`+" is invalid.")}if(e>n||t>n){throw new Error("Requested texture size "+`[${e}x${t}]`+" greater than WebGL maximum on this browser / GPU "+`[${n}x${n}]`+".")}}function createFramebuffer(e){return throwIfNull(e,(()=>e.createFramebuffer()),"Unable to create WebGLFramebuffer.")}function bindVertexBufferToProgramAttribute(e,t,n,r,i,a,o){const s=e.getAttribLocation(t,n);return-1!==s&&(callAndCheck(e,(()=>e.bindBuffer(e.ARRAY_BUFFER,r))),callAndCheck(e,(()=>e.vertexAttribPointer(s,i,e.FLOAT,!1,a,o))),callAndCheck(e,(()=>e.enableVertexAttribArray(s))),!0)}function bindTextureUnit(e,t,n){validateTextureUnit(e,n),callAndCheck(e,(()=>e.activeTexture(e.TEXTURE0+n))),callAndCheck(e,(()=>e.bindTexture(e.TEXTURE_2D,t)))}function getProgramUniformLocationOrThrow(e,t,n){return throwIfNull(e,(()=>e.getUniformLocation(t,n)),'uniform "'+n+'" not present in program.')}function getProgramUniformLocation(e,t,n){return e.getUniformLocation(t,n)}function bindTextureToProgramUniformSampler(e,t,n,r){callAndCheck(e,(()=>bindTextureUnit(e,t,r))),callAndCheck(e,(()=>e.uniform1i(n,r)))}function bindColorTextureToFramebuffer(e,t,n){callAndCheck(e,(()=>e.bindFramebuffer(e.FRAMEBUFFER,n))),callAndCheck(e,(()=>e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t,0)))}function unbindColorTextureFromFramebuffer(e,t){callAndCheck(e,(()=>e.bindFramebuffer(e.FRAMEBUFFER,t))),callAndCheck(e,(()=>e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,null,0)))}function validateFramebuffer(e){const t=e.checkFramebufferStatus(e.FRAMEBUFFER);if(t!==e.FRAMEBUFFER_COMPLETE)throw new Error("Error binding framebuffer: "+getFramebufferErrorMessage(e,t))}function getFramebufferErrorMessage(e,t){switch(t){case e.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:return"FRAMEBUFFER_INCOMPLETE_ATTACHMENT";case e.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:return"FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT";case e.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:return"FRAMEBUFFER_INCOMPLETE_DIMENSIONS";case e.FRAMEBUFFER_UNSUPPORTED:return"FRAMEBUFFER_UNSUPPORTED";default:return`unknown error ${t}`}}function throwIfNull(e,t,n){const r=callAndCheck(e,(()=>t()));if(null==r)throw new Error(n);return r}function validateTextureUnit(e,t){const n=e.MAX_COMBINED_TEXTURE_IMAGE_UNITS-1,r=t+e.TEXTURE0;if(r<e.TEXTURE0||r>n){throw new Error(`textureUnit must be in ${`[gl.TEXTURE0, gl.TEXTURE${n}]`}.`)}}function getBatchDim(e,t=2){return sizeFromShape(e.slice(0,e.length-t))}function getRowsCols(e){if(0===e.length)throw Error("Cannot get rows and columns of an empty shape array.");return[e.length>1?e[e.length-2]:1,e[e.length-1]]}function getShapeAs3D(e){let t=[1,1,1];return 0===e.length||1===e.length&&1===e[0]||(t=[getBatchDim(e),...getRowsCols(e)]),t}function getTextureShapeFromLogicalShape(e,t=!1){let n=env().getNumber("WEBGL_MAX_TEXTURE_SIZE");if(t&&(n*=2,1===(e=e.map(((t,n)=>n>=e.length-2?nearestLargerEven(e[n]):e[n]))).length&&(e=[2,e[0]])),2!==e.length){const t=squeezeShape(e);e=t.newShape}let r=sizeFromShape(e);if(e.length<=1&&r<=n)return[1,r];if(2===e.length&&e[0]<=n&&e[1]<=n)return e;if(3===e.length&&e[0]*e[1]<=n&&e[2]<=n)return[e[0]*e[1],e[2]];if(3===e.length&&e[0]<=n&&e[1]*e[2]<=n)return[e[0],e[1]*e[2]];if(4===e.length&&e[0]*e[1]*e[2]<=n&&e[3]<=n)return[e[0]*e[1]*e[2],e[3]];if(4===e.length&&e[0]<=n&&e[1]*e[2]*e[3]<=n)return[e[0],e[1]*e[2]*e[3]];if(t){const t=getBatchDim(e);let n=2,i=2;return e.length&&([n,i]=getRowsCols(e)),r=t*(n/2)*(i/2),sizeToSquarishShape(r).map((e=>2*e))}return sizeToSquarishShape(r)}function isEven(e){return e%2==0}function isReshapeFree(e,t){if(arraysEqual$1(e=e.slice(-2),t=t.slice(-2)))return!0;if(!e.length||!t.length)return!0;if(0===e[0]||0===e[1]||0===t[0]||0===t[1])return!0;if(e.length!==t.length){const n=e.slice(-1)[0],r=t.slice(-1)[0];if(n===r)return!0;if(isEven(n)&&isEven(r)&&(1===e[0]||1===t[0]))return!0}return e[1]===t[1]&&isEven(e[0])&&isEven(t[0])}let MAX_TEXTURE_SIZE,MAX_TEXTURES_IN_SHADER;function getWebGLMaxTextureSize(e){if(null==MAX_TEXTURE_SIZE){const t=getWebGLContext(e);MAX_TEXTURE_SIZE=t.getParameter(t.MAX_TEXTURE_SIZE)}return MAX_TEXTURE_SIZE}function getMaxTexturesInShader(e){if(null==MAX_TEXTURES_IN_SHADER){const t=getWebGLContext(e);MAX_TEXTURES_IN_SHADER=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS)}return Math.min(16,MAX_TEXTURES_IN_SHADER)}function getWebGLDisjointQueryTimerVersion(e){if(0===e)return 0;let t;const n=getWebGLContext(e);return t=hasExtension(n,"EXT_disjoint_timer_query_webgl2")&&2===e?2:hasExtension(n,"EXT_disjoint_timer_query")?1:0,t}function hasExtension(e,t){return null!=e.getExtension(t)}function isWebGLVersionEnabled(e){try{if(null!=getWebGLContext(e))return!0}catch(e){return console.log("Error when getting WebGL context: ",e),!1}return!1}function isCapableOfRenderingToFloatTexture(e){if(0===e)return!1;const t=getWebGLContext(e);if(1===e){if(!hasExtension(t,"OES_texture_float"))return!1}else if(!hasExtension(t,"EXT_color_buffer_float"))return!1;return createFloatTextureAndBindToFramebuffer(t)}function isDownloadFloatTextureEnabled(e){if(0===e)return!1;const t=getWebGLContext(e);if(1!==e){if(hasExtension(t,"EXT_color_buffer_float"))return createFloatTextureAndBindToFramebuffer(t);const e="EXT_color_buffer_half_float";if(hasExtension(t,e)){const n=t.getExtension(e);return createHalfFloatTextureAndBindToFramebuffer(t,n)}return!1}if(!hasExtension(t,"OES_texture_float"))return!1;if(!hasExtension(t,"WEBGL_color_buffer_float"))return!1;return createFloatTextureAndBindToFramebuffer(t)}function createFloatTextureAndBindToFramebuffer(e){const t=getTextureConfig(e),n=e.createTexture();e.bindTexture(e.TEXTURE_2D,n);e.texImage2D(e.TEXTURE_2D,0,t.internalFormatFloat,1,1,0,t.textureFormatFloat,t.textureTypeFloat,null);const r=e.createFramebuffer();e.bindFramebuffer(e.FRAMEBUFFER,r),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,n,0);const i=e.checkFramebufferStatus(e.FRAMEBUFFER)===e.FRAMEBUFFER_COMPLETE;return e.bindTexture(e.TEXTURE_2D,null),e.bindFramebuffer(e.FRAMEBUFFER,null),e.deleteTexture(n),e.deleteFramebuffer(r),i}function createHalfFloatTextureAndBindToFramebuffer(e,t){const n=getTextureConfig(e,t),r=e.createTexture();e.bindTexture(e.TEXTURE_2D,r);e.texImage2D(e.TEXTURE_2D,0,n.internalFormatHalfFloat,1,1,0,n.textureFormatFloat,n.textureTypeHalfFloat,null);const i=e.createFramebuffer();e.bindFramebuffer(e.FRAMEBUFFER,i),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,r,0);const a=e.checkFramebufferStatus(e.FRAMEBUFFER)===e.FRAMEBUFFER_COMPLETE;return e.bindTexture(e.TEXTURE_2D,null),e.bindFramebuffer(e.FRAMEBUFFER,null),e.deleteTexture(r),e.deleteFramebuffer(i),a}function isWebGLFenceEnabled(e){if(2!==e)return!1;return null!=getWebGLContext(e).fenceSync}function assertNotComplex(e,t){Array.isArray(e)||(e=[e]),e.forEach((e=>{null!=e&&assert$1("complex64"!==e.dtype,(()=>`${t} does not support complex64 tensors in the WebGL backend.`))}))}
/**
     * @license
     * Copyright 2019 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */const ENV=env();
/**
     * @license
     * Copyright 2018 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
function getGlslDifferences(){let e,t,n,r,i,a,o,s,l,c;return 2===env().getNumber("WEBGL_VERSION")?(e="#version 300 es",t="in",n="out",r="in",i="texture",a="outputColor",o="out vec4 outputColor;",s="\n      bool isnan_custom(float val) {\n        return (val > 0.0 || val < 0.0) ? false : val != 0.0;\n      }\n\n      bvec4 isnan_custom(vec4 val) {\n        return bvec4(isnan_custom(val.x),\n          isnan_custom(val.y), isnan_custom(val.z), isnan_custom(val.w));\n      }\n\n      #define isnan(value) isnan_custom(value)\n    ",l="",c="\n      #define round(value) newRound(value)\n      int newRound(float value) {\n        return int(floor(value + 0.5));\n      }\n\n      ivec4 newRound(vec4 value) {\n        return ivec4(floor(value + vec4(0.5)));\n      }\n    "):(e="",t="attribute",n="varying",r="varying",i="texture2D",a="gl_FragColor",o="",s="\n      #define isnan(value) isnan_custom(value)\n      bool isnan_custom(float val) {\n        return (val > 0. || val < 1. || val == 0.) ? false : true;\n      }\n      bvec4 isnan_custom(vec4 val) {\n        return bvec4(isnan(val.x), isnan(val.y), isnan(val.z), isnan(val.w));\n      }\n    ",l="\n      uniform float INFINITY;\n\n      bool isinf(float val) {\n        return abs(val) == INFINITY;\n      }\n      bvec4 isinf(vec4 val) {\n        return equal(abs(val), vec4(INFINITY));\n      }\n    ",c="\n      int round(float value) {\n        return int(floor(value + 0.5));\n      }\n\n      ivec4 round(vec4 value) {\n        return ivec4(floor(value + vec4(0.5)));\n      }\n    "),{version:e,attribute:t,varyingVs:n,varyingFs:r,texture2D:i,output:a,defineOutput:o,defineSpecialNaN:s,defineSpecialInf:l,defineRound:c}}
/**
     * @license
     * Copyright 2018 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function getLogicalCoordinatesFromFlatIndex(e,t,n="index"){const r=computeStrides(t);return r.map(((t,i)=>`${`int ${e[i]} = ${n} / ${t}`}; ${i===r.length-1?`int ${e[i+1]} = ${n} - ${e[i]} * ${t}`:`index -= ${e[i]} * ${t}`};`)).join("")}function getFlatIndexFrom3D(e){const t=computeStrides(e).map((e=>e.toString()));return`\n  int getFlatIndex(ivec3 coords) {\n    return coords.x * ${t[0]} + coords.y * ${t[1]} + coords.z;\n  }\n`}ENV.registerFlag("HAS_WEBGL",(()=>ENV.getNumber("WEBGL_VERSION")>0)),ENV.registerFlag("WEBGL_VERSION",(()=>isWebGLVersionEnabled(2)?2:isWebGLVersionEnabled(1)?1:0)),ENV.registerFlag("WEBGL_CHECK_NUMERICAL_PROBLEMS",(()=>!1)),ENV.registerFlag("WEBGL_BUFFER_SUPPORTED",(()=>2===ENV.get("WEBGL_VERSION"))),ENV.registerFlag("WEBGL_CPU_FORWARD",(()=>!0)),ENV.registerFlag("WEBGL_FORCE_F16_TEXTURES",(()=>!1)),ENV.registerFlag("WEBGL_PACK",(()=>ENV.getBool("HAS_WEBGL"))),ENV.registerFlag("WEBGL_PACK_NORMALIZATION",(()=>ENV.getBool("WEBGL_PACK"))),ENV.registerFlag("WEBGL_PACK_CLIP",(()=>ENV.getBool("WEBGL_PACK"))),ENV.registerFlag("WEBGL_PACK_DEPTHWISECONV",(()=>!0)),ENV.registerFlag("WEBGL_PACK_BINARY_OPERATIONS",(()=>ENV.getBool("WEBGL_PACK"))),ENV.registerFlag("WEBGL_PACK_UNARY_OPERATIONS",(()=>ENV.getBool("WEBGL_PACK"))),ENV.registerFlag("WEBGL_PACK_ARRAY_OPERATIONS",(()=>ENV.getBool("WEBGL_PACK"))),ENV.registerFlag("WEBGL_PACK_IMAGE_OPERATIONS",(()=>ENV.getBool("WEBGL_PACK"))),ENV.registerFlag("WEBGL_PACK_REDUCE",(()=>ENV.getBool("WEBGL_PACK"))),ENV.registerFlag("WEBGL_LAZILY_UNPACK",(()=>ENV.getBool("WEBGL_PACK"))),ENV.registerFlag("WEBGL_CONV_IM2COL",(()=>ENV.getBool("WEBGL_PACK"))),ENV.registerFlag("WEBGL_MAX_TEXTURE_SIZE",(()=>getWebGLMaxTextureSize(ENV.getNumber("WEBGL_VERSION")))),ENV.registerFlag("WEBGL_MAX_TEXTURES_IN_SHADER",(()=>getMaxTexturesInShader(ENV.getNumber("WEBGL_VERSION")))),ENV.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION",(()=>{const e=ENV.getNumber("WEBGL_VERSION");return 0===e?0:getWebGLDisjointQueryTimerVersion(e)})),ENV.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE",(()=>ENV.getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0&&!isMobile())),ENV.registerFlag("WEBGL_RENDER_FLOAT32_CAPABLE",(()=>isCapableOfRenderingToFloatTexture(ENV.getNumber("WEBGL_VERSION")))),ENV.registerFlag("WEBGL_RENDER_FLOAT32_ENABLED",(()=>!ENV.getBool("WEBGL_FORCE_F16_TEXTURES")&&ENV.getBool("WEBGL_RENDER_FLOAT32_CAPABLE"))),ENV.registerFlag("WEBGL_DOWNLOAD_FLOAT_ENABLED",(()=>isDownloadFloatTextureEnabled(ENV.getNumber("WEBGL_VERSION")))),ENV.registerFlag("WEBGL_FENCE_API_ENABLED",(()=>isWebGLFenceEnabled(ENV.getNumber("WEBGL_VERSION")))),ENV.registerFlag("WEBGL_SIZE_UPLOAD_UNIFORM",(()=>ENV.getBool("WEBGL_RENDER_FLOAT32_ENABLED")?4:0)),ENV.registerFlag("WEBGL_DELETE_TEXTURE_THRESHOLD",(()=>-1),(e=>{if(e<0&&-1!==e)throw new Error(`WEBGL_DELETE_TEXTURE_THRESHOLD must be -1 (indicating never delete) or at least 0, but got ${e}.`)})),ENV.registerFlag("WEBGL_FLUSH_THRESHOLD",(()=>isMobile()&&ENV.getBool("IS_CHROME")?1:-1),(e=>{if(e<0&&-1!==e)throw new Error(`WEBGL_FLUSH_THRESHOLD must be -1 (indicating never manual flush) or at least 0, but got ${e}.`)}));const ENCODE_FLOAT_SNIPPET="\n  const float FLOAT_MAX = 1.70141184e38;\n  const float FLOAT_MIN = 1.17549435e-38;\n\n  lowp vec4 encode_float(highp float v) {\n    if (isnan(v)) {\n      return vec4(255, 255, 255, 255);\n    }\n\n    highp float av = abs(v);\n\n    if(av < FLOAT_MIN) {\n      return vec4(0.0, 0.0, 0.0, 0.0);\n    } else if(v > FLOAT_MAX) {\n      return vec4(0.0, 0.0, 128.0, 127.0) / 255.0;\n    } else if(v < -FLOAT_MAX) {\n      return vec4(0.0, 0.0,  128.0, 255.0) / 255.0;\n    }\n\n    highp vec4 c = vec4(0,0,0,0);\n\n    highp float e = floor(log2(av));\n    highp float m = exp2(fract(log2(av))) - 1.0;\n\n    c[2] = floor(128.0 * m);\n    m -= c[2] / 128.0;\n    c[1] = floor(32768.0 * m);\n    m -= c[1] / 32768.0;\n    c[0] = floor(8388608.0 * m);\n\n    highp float ebias = e + 127.0;\n    c[3] = floor(ebias / 2.0);\n    ebias -= c[3] * 2.0;\n    c[2] += floor(ebias) * 128.0;\n\n    c[3] += 128.0 * step(0.0, -v);\n\n    return c / 255.0;\n  }\n";
/**
     * @license
     * Copyright 2019 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */class DecodeMatrixProgram{constructor(e){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.outPackingScheme=PackingScheme.DENSE;const t=getDenseTexShape(e),n=getGlslDifferences();this.outputShape=e,this.userCode=`\n      ivec3 outCoordsFromFlatIndex(int index) {\n        ${getLogicalCoordinatesFromFlatIndex(["r","c","d"],e)}\n        return ivec3(r, c, d);\n      }\n\n      void main() {\n        ivec2 resTexRC = ivec2(resultUV.yx *\n          vec2(${t[0]}, ${t[1]}));\n        int index = 4 * (resTexRC.x * ${t[1]} + resTexRC.y);\n\n        vec4 result = vec4(0.);\n\n        for (int i=0; i<4; i++) {\n          int flatIndex = index + i;\n          ivec3 rc = outCoordsFromFlatIndex(flatIndex);\n          result[i] = getA(rc.x, rc.y, rc.z);\n        }\n\n        ${n.output} = result;\n      }\n    `}}
/**
     * @license
     * Copyright 2019 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */class DecodeMatrixPackedProgram{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outPackingScheme=PackingScheme.DENSE;const t=getDenseTexShape(e),n=getGlslDifferences();this.outputShape=e,this.userCode=`\n      ivec3 outCoordsFromFlatIndex(int index) {\n        ${getLogicalCoordinatesFromFlatIndex(["r","c","d"],e)}\n        return ivec3(r, c, d);\n      }\n\n      void main() {\n        ivec2 resTexRC = ivec2(resultUV.yx *\n          vec2(${t[0]}, ${t[1]}));\n        int index = 4 * (resTexRC.x * ${t[1]} + resTexRC.y);\n\n        vec4 result = vec4(0.);\n\n        for (int i=0; i<4; i++) {\n          int flatIndex = index + i;\n          ivec3 rc = outCoordsFromFlatIndex(flatIndex);\n          result[i] = getChannel(getA(rc.x, rc.y, rc.z), vec2(rc.y, rc.z));\n        }\n\n        ${n.output} = result;\n      }\n    `}}
/**
     * @license
     * Copyright 2018 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */class EncodeFloatProgram{constructor(e){this.variableNames=["A"],this.outTexUsage=TextureUsage.DOWNLOAD;const t=getGlslDifferences();this.outputShape=e,this.userCode=`\n      ${ENCODE_FLOAT_SNIPPET}\n\n      void main() {\n        float x = getAAtOutCoords();\n        ${t.output} = encode_float(x);\n      }\n    `}}
/**
     * @license
     * Copyright 2018 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */class EncodeFloatPackedProgram{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outTexUsage=TextureUsage.DOWNLOAD;const t=getGlslDifferences();this.outputShape=e,this.userCode=`\n      ${ENCODE_FLOAT_SNIPPET}\n\n      void main() {\n        ivec3 coords = getOutputCoords();\n        float x = getChannel(getAAtOutCoords(), vec2(coords.y, coords.z));\n        ${t.output} = encode_float(x);\n      }\n    `}}
/**
     * @license
     * Copyright 2018 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */class EncodeMatrixProgram{constructor(e,t,n=!1){this.variableNames=["A"];const r=getGlslDifferences(),[i,a]=t;this.outputShape=e;let o="result";n&&(o="floor(result * 255. + 0.5)"),this.userCode=`\n      ${getFlatIndexFrom3D(e)}\n\n      void main() {\n        ivec3 coords = getOutputCoords();\n\n        int flatIndex = getFlatIndex(coords);\n        int offset = imod(flatIndex, 4);\n\n        flatIndex = idiv(flatIndex, 4, 1.);\n\n        int r = flatIndex / ${a};\n        int c = imod(flatIndex, ${a});\n        vec2 uv = (vec2(c, r) + halfCR) / vec2(${a}.0, ${i}.0);\n        vec4 values = ${r.texture2D}(A, uv);\n\n        float result;\n\n        if(offset == 0) {\n          result = values[0];\n        } else if(offset == 1) {\n          result = values[1];\n        } else if(offset == 2) {\n          result = values[2];\n        } else {\n          result = values[3];\n        }\n\n        ${r.output} = vec4(${o}, 0., 0., 0.);\n      }\n    `}}
/**
     * @license
     * Copyright 2018 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */class EncodeMatrixPackedProgram{constructor(e,t,n=!1){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0;const r=getGlslDifferences(),[i,a]=t;this.outputShape=e;let o="",s="result";n&&(s="floor(result * 255. + 0.5)");for(let t=0;t<=1;t++)for(let n=0;n<=1;n++){const s=2*t+n;o+=`\n          localCoords = coords;\n          if(localCoords[2] + ${n} < ${e[2]}) {\n            localCoords[2] += ${n};\n            if(localCoords[1] + ${t} < ${e[1]}) {\n              localCoords[1] += ${t};\n\n              flatIndex = getFlatIndex(localCoords);\n              offset = imod(flatIndex, 4);\n\n              flatIndex = idiv(flatIndex, 4, 1.);\n\n              r = flatIndex / ${a};\n              c = imod(flatIndex, ${a});\n              uv = (vec2(c, r) + halfCR) / vec2(${a}.0, ${i}.0);\n              values = ${r.texture2D}(A, uv);\n\n              if(offset == 0) {\n                result[${s}] = values[0];\n              } else if(offset == 1) {\n                result[${s}] = values[1];\n              } else if(offset == 2) {\n                result[${s}] = values[2];\n              } else {\n                result[${s}] = values[3];\n              }\n            }\n          }\n        `}this.userCode=`\n      ${getFlatIndexFrom3D(e)}\n\n      void main() {\n        ivec3 coords = getOutputCoords();\n\n        vec4 result = vec4(0.);\n        int flatIndex, r, c, offset;\n        ivec3 localCoords;\n        vec2 uv;\n        vec4 values;\n\n        ${o}\n\n        ${r.output} = ${s};\n      }\n    `}}
/**
     * @license
     * Copyright 2017 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function createVertexShader$1(e){const t=getGlslDifferences();return createVertexShader$2(e,`${t.version}\n    precision highp float;\n    ${t.attribute} vec3 clipSpacePos;\n    ${t.attribute} vec2 uv;\n    ${t.varyingVs} vec2 resultUV;\n\n    void main() {\n      gl_Position = vec4(clipSpacePos, 1);\n      resultUV = uv;\n    }`)}function createVertexBuffer(e){return createStaticVertexBuffer(e,new Float32Array([-1,1,0,0,1,-1,-1,0,0,0,1,1,0,1,1,1,-1,0,1,0]))}function createIndexBuffer(e){return createStaticIndexBuffer(e,new Uint16Array([0,1,2,2,1,3]))}function createAndConfigureTexture(e,t,n,r,i,a){validateTextureSize(t,n);const o=createTexture$1(e),s=e.TEXTURE_2D;return callAndCheck(e,(()=>e.bindTexture(s,o))),callAndCheck(e,(()=>e.texParameteri(s,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE))),callAndCheck(e,(()=>e.texParameteri(s,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE))),callAndCheck(e,(()=>e.texParameteri(s,e.TEXTURE_MIN_FILTER,e.NEAREST))),callAndCheck(e,(()=>e.texParameteri(s,e.TEXTURE_MAG_FILTER,e.NEAREST))),callAndCheck(e,(()=>e.texImage2D(s,0,r,t,n,0,i,a,null))),callAndCheck(e,(()=>e.bindTexture(e.TEXTURE_2D,null))),o}function getInternalFormatForFloat32MatrixTexture(e){return e.internalFormatFloat}function createFloat32MatrixTexture(e,t,n,r){const[i,a]=getUnpackedMatrixTextureShapeWidthHeight(t,n);return createAndConfigureTexture(e,i,a,getInternalFormatForFloat32MatrixTexture(r),r.textureFormatFloat,e.FLOAT)}function getInternalFormatForFloat16MatrixTexture(e){return e.internalFormatHalfFloat}function createFloat16MatrixTexture(e,t,n,r){const[i,a]=getUnpackedMatrixTextureShapeWidthHeight(t,n);return createAndConfigureTexture(e,i,a,getInternalFormatForFloat16MatrixTexture(r),r.textureFormatFloat,r.textureTypeHalfFloat)}function getInternalFormatForUnsignedBytesMatrixTexture(e){return e.downloadTextureFormat}function createUnsignedBytesMatrixTexture(e,t,n,r){const[i,a]=getUnpackedMatrixTextureShapeWidthHeight(t,n);return createAndConfigureTexture(e,i,a,getInternalFormatForUnsignedBytesMatrixTexture(r),e.RGBA,e.UNSIGNED_BYTE)}function getInternalFormatForPackedMatrixTexture(e){return e.internalFormatPackedFloat}function createPackedMatrixTexture(e,t,n,r){const[i,a]=getPackedMatrixTextureShapeWidthHeight(t,n);return createAndConfigureTexture(e,i,a,getInternalFormatForPackedMatrixTexture(r),e.RGBA,e.FLOAT)}function getInternalFormatForFloat16PackedMatrixTexture(e){return e.internalFormatPackedHalfFloat}function createFloat16PackedMatrixTexture(e,t,n,r){const[i,a]=getPackedMatrixTextureShapeWidthHeight(t,n);return createAndConfigureTexture(e,i,a,getInternalFormatForFloat16PackedMatrixTexture(r),e.RGBA,r.textureTypeHalfFloat)}function bindVertexProgramAttributeStreams(e,t,n){callAndCheck(e,(()=>e.bindBuffer(e.ARRAY_BUFFER,n)));return bindVertexBufferToProgramAttribute(e,t,"clipSpacePos",n,3,20,0)&&bindVertexBufferToProgramAttribute(e,t,"uv",n,2,20,12)}function uploadDenseMatrixToTexture(e,t,n,r,i,a){let o,s,l;callAndCheck(e,(()=>e.bindTexture(e.TEXTURE_2D,t))),i instanceof Uint8Array?(o=new Uint8Array(n*r*4),s=e.UNSIGNED_BYTE,l=e.RGBA):(o=new Float32Array(n*r*4),s=e.FLOAT,l=a.internalFormatPackedFloat),o.set(i),callAndCheck(e,(()=>e.texImage2D(e.TEXTURE_2D,0,l,n,r,0,e.RGBA,s,o))),callAndCheck(e,(()=>e.bindTexture(e.TEXTURE_2D,null)))}function uploadPixelDataToTexture(e,t,n){callAndCheck(e,(()=>e.bindTexture(e.TEXTURE_2D,t))),n.data instanceof Uint8Array?callAndCheck(e,(()=>e.texImage2D(e.TEXTURE_2D,0,e.RGBA,n.width,n.height,0,e.RGBA,e.UNSIGNED_BYTE,n.data))):callAndCheck(e,(()=>e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,n))),callAndCheck(e,(()=>e.bindTexture(e.TEXTURE_2D,null)))}function createBufferFromOutputTexture(e,t,n,r){const i=e.createBuffer();callAndCheck(e,(()=>e.bindBuffer(e.PIXEL_PACK_BUFFER,i)));const a=16*t*n;return callAndCheck(e,(()=>e.bufferData(e.PIXEL_PACK_BUFFER,a,e.STREAM_READ))),callAndCheck(e,(()=>e.readPixels(0,0,n,t,e.RGBA,e.FLOAT,0))),callAndCheck(e,(()=>e.bindBuffer(e.PIXEL_PACK_BUFFER,null))),i}function downloadFloat32MatrixFromBuffer(e,t,n){const r=e,i=new Float32Array(n);return r.bindBuffer(r.PIXEL_PACK_BUFFER,t),r.getBufferSubData(r.PIXEL_PACK_BUFFER,0,i),r.bindBuffer(r.PIXEL_PACK_BUFFER,null),i}function downloadByteEncodedFloatMatrixFromOutputTexture(e,t,n,r){const[i,a]=getUnpackedMatrixTextureShapeWidthHeight(t,n),o=new Uint8Array(getUnpackedArraySizeFromMatrixSize(t*n,4));return callAndCheck(e,(()=>e.readPixels(0,0,i,a,r.downloadTextureFormat,e.UNSIGNED_BYTE,o))),new Float32Array(o.buffer)}function downloadPackedMatrixFromBuffer(e,t,n,r,i,a,o,s){const l=e,c=new Float32Array(getPackedRGBAArraySizeFromMatrixShape(a,o));return l.bindBuffer(l.PIXEL_PACK_BUFFER,t),l.getBufferSubData(l.PIXEL_PACK_BUFFER,0,c),l.bindBuffer(l.PIXEL_PACK_BUFFER,null),c}function downloadMatrixFromPackedOutputTexture(e,t,n){const r=new Float32Array(t*n*4);return callAndCheck(e,(()=>e.readPixels(0,0,n,t,e.RGBA,e.FLOAT,r))),r}
/**
     * @license
     * Copyright 2017 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */class GPGPUContext{constructor(e){this.outputTexture=null,this.program=null,this.disposed=!1,this.vertexAttrsAreBound=!1,this.itemsToPoll=[];const t=env().getNumber("WEBGL_VERSION");null!=e?(this.gl=e,setWebGLContext(t,e)):this.gl=getWebGLContext(t);let n="WEBGL_color_buffer_float";const r="EXT_color_buffer_half_float";if(1===env().getNumber("WEBGL_VERSION")){const e="OES_texture_half_float";if(this.textureFloatExtension=getExtensionOrThrow(this.gl,"OES_texture_float"),hasExtension(this.gl,e))this.textureHalfFloatExtension=getExtensionOrThrow(this.gl,e);else if(env().get("WEBGL_FORCE_F16_TEXTURES"))throw new Error("GL context does not support half float textures, yet the environment flag WEBGL_FORCE_F16_TEXTURES is set to true.");if(this.colorBufferFloatExtension=this.gl.getExtension(n),hasExtension(this.gl,r))this.colorBufferHalfFloatExtension=getExtensionOrThrow(this.gl,r);else if(env().get("WEBGL_FORCE_F16_TEXTURES"))throw new Error("GL context does not support color renderable half floats, yet the environment flag WEBGL_FORCE_F16_TEXTURES is set to true.")}else if(n="EXT_color_buffer_float",hasExtension(this.gl,n))this.colorBufferFloatExtension=this.gl.getExtension(n);else{if(!hasExtension(this.gl,r))throw new Error("GL context does not support color renderable floats");this.colorBufferHalfFloatExtension=this.gl.getExtension(r)}this.vertexBuffer=createVertexBuffer(this.gl),this.indexBuffer=createIndexBuffer(this.gl),this.framebuffer=createFramebuffer(this.gl),this.textureConfig=getTextureConfig(this.gl,this.textureHalfFloatExtension)}get debug(){return env().getBool("DEBUG")}dispose(){if(this.disposed)return;null!=this.program&&console.warn("Disposing a GPGPUContext that still has a bound WebGLProgram. This is probably a resource leak, delete the program with GPGPUContext.deleteProgram before disposing."),null!=this.outputTexture&&console.warn("Disposing a GPGPUContext that still has a bound output matrix texture.  This is probably a resource leak, delete the output matrix texture with GPGPUContext.deleteMatrixTexture before disposing.");const e=this.gl;callAndCheck(e,(()=>e.finish())),callAndCheck(e,(()=>e.bindFramebuffer(e.FRAMEBUFFER,null))),callAndCheck(e,(()=>e.deleteFramebuffer(this.framebuffer))),callAndCheck(e,(()=>e.bindBuffer(e.ARRAY_BUFFER,null))),callAndCheck(e,(()=>e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,null))),callAndCheck(e,(()=>e.deleteBuffer(this.indexBuffer))),this.disposed=!0}createFloat32MatrixTexture(e,t){return this.throwIfDisposed(),createFloat32MatrixTexture(this.gl,e,t,this.textureConfig)}createFloat16MatrixTexture(e,t){return this.throwIfDisposed(),createFloat16MatrixTexture(this.gl,e,t,this.textureConfig)}createUnsignedBytesMatrixTexture(e,t){return this.throwIfDisposed(),createUnsignedBytesMatrixTexture(this.gl,e,t,this.textureConfig)}uploadPixelDataToTexture(e,t){this.throwIfDisposed(),uploadPixelDataToTexture(this.gl,e,t)}uploadDenseMatrixToTexture(e,t,n,r){this.throwIfDisposed(),uploadDenseMatrixToTexture(this.gl,e,t,n,r,this.textureConfig)}createFloat16PackedMatrixTexture(e,t){return this.throwIfDisposed(),createFloat16PackedMatrixTexture(this.gl,e,t,this.textureConfig)}createPackedMatrixTexture(e,t){return this.throwIfDisposed(),createPackedMatrixTexture(this.gl,e,t,this.textureConfig)}deleteMatrixTexture(e){this.throwIfDisposed(),this.outputTexture===e&&(unbindColorTextureFromFramebuffer(this.gl,this.framebuffer),this.outputTexture=null),callAndCheck(this.gl,(()=>this.gl.deleteTexture(e)))}downloadByteEncodedFloatMatrixFromOutputTexture(e,t,n){return this.downloadMatrixDriver(e,(()=>downloadByteEncodedFloatMatrixFromOutputTexture(this.gl,t,n,this.textureConfig)))}downloadPackedMatrixFromBuffer(e,t,n,r,i,a){return downloadPackedMatrixFromBuffer(this.gl,e,t,n,r,i,a,this.textureConfig)}downloadFloat32MatrixFromBuffer(e,t){return downloadFloat32MatrixFromBuffer(this.gl,e,t)}createBufferFromTexture(e,t,n){this.bindTextureToFrameBuffer(e);const r=createBufferFromOutputTexture(this.gl,t,n,this.textureConfig);return this.unbindTextureToFrameBuffer(),r}createAndWaitForFence(){const e=this.createFence(this.gl);return this.pollFence(e)}createFence(e){let t,n;if(env().getBool("WEBGL_FENCE_API_ENABLED")){const r=e,i=r.fenceSync(r.SYNC_GPU_COMMANDS_COMPLETE,0);e.flush(),n=()=>{const e=r.clientWaitSync(i,0,0);return e===r.ALREADY_SIGNALED||e===r.CONDITION_SATISFIED},t=i}else env().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0?(t=this.beginQuery(),this.endQuery(),n=()=>this.isQueryAvailable(t,env().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))):n=()=>!0;return{query:t,isFencePassed:n}}downloadMatrixFromPackedTexture(e,t,n){return this.downloadMatrixDriver(e,(()=>downloadMatrixFromPackedOutputTexture(this.gl,t,n)))}createProgram(e){this.throwIfDisposed();const t=this.gl,n=createFragmentShader$1(t,e),r=createVertexShader$1(t),i=createProgram(t);return callAndCheck(t,(()=>t.attachShader(i,r))),callAndCheck(t,(()=>t.attachShader(i,n))),linkProgram(t,i),this.debug&&validateProgram(t,i),this.vertexAttrsAreBound||(this.setProgram(i),this.vertexAttrsAreBound=bindVertexProgramAttributeStreams(t,this.program,this.vertexBuffer)),i}deleteProgram(e){this.throwIfDisposed(),e===this.program&&(this.program=null),null!=e&&callAndCheck(this.gl,(()=>this.gl.deleteProgram(e)))}setProgram(e){this.throwIfDisposed(),this.program=e,null!=this.program&&this.debug&&validateProgram(this.gl,this.program),callAndCheck(this.gl,(()=>this.gl.useProgram(e)))}getUniformLocation(e,t,n=!0){return this.throwIfDisposed(),n?getProgramUniformLocationOrThrow(this.gl,e,t):getProgramUniformLocation(this.gl,e,t)}getAttributeLocation(e,t){return this.throwIfDisposed(),callAndCheck(this.gl,(()=>this.gl.getAttribLocation(e,t)))}getUniformLocationNoThrow(e,t){return this.throwIfDisposed(),this.gl.getUniformLocation(e,t)}setInputMatrixTexture(e,t,n){this.throwIfDisposed(),this.throwIfNoProgram(),bindTextureToProgramUniformSampler(this.gl,e,t,n)}setOutputMatrixTexture(e,t,n){this.setOutputMatrixTextureDriver(e,n,t)}setOutputPackedMatrixTexture(e,t,n){this.throwIfDisposed();const[r,i]=getPackedMatrixTextureShapeWidthHeight(t,n);this.setOutputMatrixTextureDriver(e,r,i)}setOutputMatrixWriteRegion(e,t,n,r){this.setOutputMatrixWriteRegionDriver(n,e,r,t)}setOutputPackedMatrixWriteRegion(e,t,n,r){throw new Error("setOutputPackedMatrixWriteRegion not implemented.")}debugValidate(){null!=this.program&&validateProgram(this.gl,this.program),validateFramebuffer(this.gl)}executeProgram(){this.throwIfDisposed(),this.throwIfNoProgram();const e=this.gl;this.debug&&this.debugValidate(),callAndCheck(e,(()=>e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0)))}blockUntilAllProgramsCompleted(){this.throwIfDisposed(),callAndCheck(this.gl,(()=>this.gl.finish()))}getQueryTimerExtension(){return null==this.disjointQueryTimerExtension&&(this.disjointQueryTimerExtension=getExtensionOrThrow(this.gl,2===env().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")?"EXT_disjoint_timer_query_webgl2":"EXT_disjoint_timer_query")),this.disjointQueryTimerExtension}getQueryTimerExtensionWebGL2(){return this.getQueryTimerExtension()}getQueryTimerExtensionWebGL1(){return this.getQueryTimerExtension()}beginQuery(){if(2===env().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")){const e=this.gl,t=this.getQueryTimerExtensionWebGL2(),n=e.createQuery();return e.beginQuery(t.TIME_ELAPSED_EXT,n),n}const e=this.getQueryTimerExtensionWebGL1(),t=e.createQueryEXT();return e.beginQueryEXT(e.TIME_ELAPSED_EXT,t),t}endQuery(){if(2===env().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")){const e=this.gl,t=this.getQueryTimerExtensionWebGL2();return void e.endQuery(t.TIME_ELAPSED_EXT)}const e=this.getQueryTimerExtensionWebGL1();e.endQueryEXT(e.TIME_ELAPSED_EXT)}async waitForQueryAndGetTime(e){return await repeatedTry((()=>this.disposed||this.isQueryAvailable(e,env().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")))),this.getQueryTime(e,env().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))}getQueryTime(e,t){if(0===t)return null;if(2===t){const t=this.gl;return t.getQueryParameter(e,t.QUERY_RESULT)/1e6}{const t=this.getQueryTimerExtensionWebGL1();return t.getQueryObjectEXT(e,t.QUERY_RESULT_EXT)/1e6}}isQueryAvailable(e,t){if(0===t)return!0;if(2===t){const t=this.gl,n=this.getQueryTimerExtensionWebGL2(),r=t.getQueryParameter(e,t.QUERY_RESULT_AVAILABLE);return null==this.disjoint&&(this.disjoint=this.gl.getParameter(n.GPU_DISJOINT_EXT)),r&&!this.disjoint}{const t=this.getQueryTimerExtensionWebGL1(),n=t.getQueryObjectEXT(e,t.QUERY_RESULT_AVAILABLE_EXT);return null==this.disjoint&&(this.disjoint=this.gl.getParameter(t.GPU_DISJOINT_EXT)),n&&!this.disjoint}}pollFence(e){return new Promise((t=>{this.addItemToPoll((()=>e.isFencePassed()),(()=>t()))}))}pollItems(){const e=linearSearchLastTrue(this.itemsToPoll.map((e=>e.isDoneFn)));for(let t=0;t<=e;++t){const{resolveFn:e}=this.itemsToPoll[t];e()}this.itemsToPoll=this.itemsToPoll.slice(e+1)}addItemToPoll(e,t){this.itemsToPoll.push({isDoneFn:e,resolveFn:t}),this.itemsToPoll.length>1||repeatedTry((()=>(this.pollItems(),0===this.itemsToPoll.length)))}bindTextureToFrameBuffer(e){this.throwIfDisposed(),bindColorTextureToFramebuffer(this.gl,e,this.framebuffer),this.debug&&validateFramebuffer(this.gl)}unbindTextureToFrameBuffer(){null!=this.outputTexture?(bindColorTextureToFramebuffer(this.gl,this.outputTexture,this.framebuffer),this.debug&&validateFramebuffer(this.gl)):unbindColorTextureFromFramebuffer(this.gl,this.framebuffer)}downloadMatrixDriver(e,t){this.bindTextureToFrameBuffer(e);const n=t();return this.unbindTextureToFrameBuffer(),n}setOutputMatrixTextureDriver(e,t,n){this.throwIfDisposed();const r=this.gl;bindColorTextureToFramebuffer(r,e,this.framebuffer),this.debug&&validateFramebuffer(r),this.outputTexture=e,callAndCheck(r,(()=>r.viewport(0,0,t,n))),callAndCheck(r,(()=>r.scissor(0,0,t,n)))}setOutputMatrixWriteRegionDriver(e,t,n,r){this.throwIfDisposed(),callAndCheck(this.gl,(()=>this.gl.scissor(e,t,n,r)))}throwIfDisposed(){if(this.disposed)throw new Error("Attempted to use disposed GPGPUContext.")}throwIfNoProgram(){if(null==this.program)throw new Error("No GPU program is currently set.")}}function linearSearchLastTrue(e){let t=0;for(;t<e.length;++t){if(!e[t]())break}return t-1}
/**
     * @license
     * Copyright 2017 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */const{getBroadcastDims:getBroadcastDims}=backend_util;function makeShader(e,t,n,r){const i=[];e.forEach((e=>{const t=sizeFromShape(e.shapeInfo.logicalShape);e.shapeInfo.isUniform?i.push(`uniform float ${e.name}${t>1?`[${t}]`:""};`):(i.push(`uniform sampler2D ${e.name};`),i.push(`uniform int offset${e.name};`))}));const a=i.join("\n"),o=e.map((e=>getInputSamplingSnippet(e,t,r))).join("\n"),s=t.texShape,l=getGlslDifferences(),c=getFloatTextureSampleSnippet(l);let h,u,d=getShaderPrefix(l);t.isPacked?(h=getPackedOutputSamplingSnippet(t.logicalShape,s),u=getFloatTextureSetRGBASnippet(l)):(h=getOutputSamplingSnippet(t.logicalShape,s),u=getFloatTextureSetRSnippet(l)),r&&(d+=SHADER_PACKED_PREFIX);return[d,c,u,a,h,o,n].join("\n")}function getSamplerFromInInfo(e){const t=e.shapeInfo.logicalShape;switch(t.length){case 0:return getSamplerScalar(e);case 1:return getSampler1D(e);case 2:return getSampler2D(e);case 3:return getSampler3D(e);case 4:return getSampler4D(e);case 5:return getSampler5D(e);case 6:return getSampler6D(e);default:throw new Error(`${t.length}-D input sampling is not yet supported`)}}function getPackedSamplerFromInInfo(e){switch(e.shapeInfo.logicalShape.length){case 0:return getPackedSamplerScalar(e);case 1:return getPackedSampler1D(e);case 2:return getPackedSampler2D(e);case 3:return getPackedSampler3D(e);default:return getPackedSamplerND(e)}}function getInputSamplingSnippet(e,t,n=!1){let r="";r+=n?getPackedSamplerFromInInfo(e):getSamplerFromInInfo(e);return e.shapeInfo.logicalShape.length<=t.logicalShape.length&&(r+=n?getPackedSamplerAtOutputCoords(e,t):getSamplerAtOutputCoords(e,t)),r}function getPackedOutputSamplingSnippet(e,t){switch(e.length){case 0:return getOutputScalarCoords();case 1:return getOutputPacked1DCoords(e,t);case 2:return getOutputPacked2DCoords(e,t);case 3:return getOutputPacked3DCoords(e,t);default:return getOutputPackedNDCoords(e,t)}}function getOutputSamplingSnippet(e,t){switch(e.length){case 0:return getOutputScalarCoords();case 1:return getOutput1DCoords(e,t);case 2:return getOutput2DCoords(e,t);case 3:return getOutput3DCoords(e,t);case 4:return getOutput4DCoords(e,t);case 5:return getOutput5DCoords(e,t);case 6:return getOutput6DCoords(e,t);default:throw new Error(`${e.length}-D output sampling is not yet supported`)}}function getFloatTextureSampleSnippet(e){return`\n    float sampleTexture(sampler2D textureSampler, vec2 uv) {\n      return ${e.texture2D}(textureSampler, uv).r;\n    }\n  `}function getFloatTextureSetRSnippet(e){return`\n    void setOutput(float val) {\n      ${e.output} = vec4(val, 0, 0, 0);\n    }\n  `}function getFloatTextureSetRGBASnippet(e){return`\n    void setOutput(vec4 val) {\n      ${e.output} = val;\n    }\n  `}function getShaderPrefix(e){return`${e.version}\n    precision highp float;\n    precision highp int;\n    precision highp sampler2D;\n    ${e.varyingFs} vec2 resultUV;\n    ${e.defineOutput}\n    const vec2 halfCR = vec2(0.5, 0.5);\n\n    struct ivec5\n    {\n      int x;\n      int y;\n      int z;\n      int w;\n      int u;\n    };\n\n    struct ivec6\n    {\n      int x;\n      int y;\n      int z;\n      int w;\n      int u;\n      int v;\n    };\n\n    uniform float NAN;\n    ${e.defineSpecialNaN}\n    ${e.defineSpecialInf}\n    ${e.defineRound}\n\n    int imod(int x, int y) {\n      return x - y * (x / y);\n    }\n\n    int idiv(int a, int b, float sign) {\n      int res = a / b;\n      int mod = imod(a, b);\n      if (sign < 0. && mod != 0) {\n        res -= 1;\n      }\n      return res;\n    }\n\n    //Based on the work of Dave Hoskins\n    //https://www.shadertoy.com/view/4djSRW\n    #define HASHSCALE1 443.8975\n    float random(float seed){\n      vec2 p = resultUV * seed;\n      vec3 p3  = fract(vec3(p.xyx) * HASHSCALE1);\n      p3 += dot(p3, p3.yzx + 19.19);\n      return fract((p3.x + p3.y) * p3.z);\n    }\n\n    ${SAMPLE_1D_SNIPPET}\n    ${SAMPLE_2D_SNIPPET}\n    ${SAMPLE_3D_SNIPPET}\n  `}const SAMPLE_1D_SNIPPET="\nvec2 uvFromFlat(int texNumR, int texNumC, int index) {\n  int texR = index / texNumC;\n  int texC = index - texR * texNumC;\n  return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n}\nvec2 packedUVfrom1D(int texNumR, int texNumC, int index) {\n  int texelIndex = index / 2;\n  int texR = texelIndex / texNumC;\n  int texC = texelIndex - texR * texNumC;\n  return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n}\n",SAMPLE_2D_SNIPPET="\nvec2 packedUVfrom2D(int texelsInLogicalRow, int texNumR,\n  int texNumC, int row, int col) {\n  int texelIndex = (row / 2) * texelsInLogicalRow + (col / 2);\n  int texR = texelIndex / texNumC;\n  int texC = texelIndex - texR * texNumC;\n  return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n}\n",SAMPLE_3D_SNIPPET="\nvec2 packedUVfrom3D(int texNumR, int texNumC,\n    int texelsInBatch, int texelsInLogicalRow, int b,\n    int row, int col) {\n  int index = b * texelsInBatch + (row / 2) * texelsInLogicalRow + (col / 2);\n  int texR = index / texNumC;\n  int texC = index - texR * texNumC;\n  return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n}\n",SHADER_PACKED_PREFIX="\n  float getChannel(vec4 frag, vec2 innerDims) {\n    vec2 modCoord = mod(innerDims, 2.);\n    return modCoord.x == 0. ?\n      (modCoord.y == 0. ? frag.r : frag.g) :\n      (modCoord.y == 0. ? frag.b : frag.a);\n  }\n  float getChannel(vec4 frag, int dim) {\n    float modCoord = mod(float(dim), 2.);\n    return modCoord == 0. ? frag.r : frag.g;\n  }\n";function getOutputScalarCoords(){return"\n    int getOutputCoords() {\n      return 0;\n    }\n  "}function getOutputPacked1DCoords(e,t){const n=[Math.ceil(t[0]/2),Math.ceil(t[1]/2)];return 1===n[0]?`\n      int getOutputCoords() {\n        return 2 * int(resultUV.x * ${n[1]}.0);\n      }\n    `:1===n[1]?`\n      int getOutputCoords() {\n        return 2 * int(resultUV.y * ${n[0]}.0);\n      }\n    `:`\n    int getOutputCoords() {\n      ivec2 resTexRC = ivec2(resultUV.yx *\n                             vec2(${n[0]}, ${n[1]}));\n      return 2 * (resTexRC.x * ${n[1]} + resTexRC.y);\n    }\n  `}function getOutput1DCoords(e,t){return 1===t[0]?`\n      int getOutputCoords() {\n        return int(resultUV.x * ${t[1]}.0);\n      }\n    `:1===t[1]?`\n      int getOutputCoords() {\n        return int(resultUV.y * ${t[0]}.0);\n      }\n    `:`\n    int getOutputCoords() {\n      ivec2 resTexRC = ivec2(resultUV.yx *\n                             vec2(${t[0]}, ${t[1]}));\n      return resTexRC.x * ${t[1]} + resTexRC.y;\n    }\n  `}function getOutputPacked3DCoords(e,t){const n=[Math.ceil(t[0]/2),Math.ceil(t[1]/2)],r=Math.ceil(e[2]/2),i=r*Math.ceil(e[1]/2);return`\n    ivec3 getOutputCoords() {\n      ivec2 resTexRC = ivec2(resultUV.yx *\n                             vec2(${n[0]}, ${n[1]}));\n      int index = resTexRC.x * ${n[1]} + resTexRC.y;\n\n      int b = index / ${i};\n      index -= b * ${i};\n\n      int r = 2 * (index / ${r});\n      int c = imod(index, ${r}) * 2;\n\n      return ivec3(b, r, c);\n    }\n  `}function getOutput3DCoords(e,t){const n=getLogicalCoordinatesFromFlatIndex(["r","c","d"],e);return`\n    ivec3 getOutputCoords() {\n      ivec2 resTexRC = ivec2(resultUV.yx *\n                             vec2(${t[0]}, ${t[1]}));\n      int index = resTexRC.x * ${t[1]} + resTexRC.y;\n      ${n}\n      return ivec3(r, c, d);\n    }\n  `}function getOutputPackedNDCoords(e,t){const n=[Math.ceil(t[0]/2),Math.ceil(t[1]/2)],r=Math.ceil(e[e.length-1]/2),i=r*Math.ceil(e[e.length-2]/2);let a=i,o="",s="b, r, c";for(let t=2;t<e.length-1;t++)a*=e[e.length-t-1],o=`\n      int b${t} = index / ${a};\n      index -= b${t} * ${a};\n    `+o,s=`b${t}, `+s;return`\n    ivec${e.length} getOutputCoords() {\n      ivec2 resTexRC = ivec2(resultUV.yx *\n                             vec2(${n[0]}, ${n[1]}));\n      int index = resTexRC.x * ${n[1]} + resTexRC.y;\n\n      ${o}\n\n      int b = index / ${i};\n      index -= b * ${i};\n\n      int r = 2 * (index / ${r});\n      int c = imod(index, ${r}) * 2;\n\n      return ivec${e.length}(${s});\n    }\n  `}function getOutput4DCoords(e,t){const n=getLogicalCoordinatesFromFlatIndex(["r","c","d","d2"],e);return`\n    ivec4 getOutputCoords() {\n      ivec2 resTexRC = ivec2(resultUV.yx *\n        vec2(${t[0]}, ${t[1]}));\n      int index = resTexRC.x * ${t[1]} + resTexRC.y;\n      ${n}\n      return ivec4(r, c, d, d2);\n    }\n  `}function getOutput5DCoords(e,t){const n=getLogicalCoordinatesFromFlatIndex(["r","c","d","d2","d3"],e);return`\n    ivec5 getOutputCoords() {\n      ivec2 resTexRC = ivec2(resultUV.yx * vec2(${t[0]},\n                             ${t[1]}));\n\n      int index = resTexRC.x * ${t[1]} + resTexRC.y;\n\n      ${n}\n\n      ivec5 outShape = ivec5(r, c, d, d2, d3);\n      return outShape;\n    }\n  `}function getOutput6DCoords(e,t){const n=getLogicalCoordinatesFromFlatIndex(["r","c","d","d2","d3","d4"],e);return`\n    ivec6 getOutputCoords() {\n      ivec2 resTexRC = ivec2(resultUV.yx *\n        vec2(${t[0]}, ${t[1]}));\n      int index = resTexRC.x * ${t[1]} + resTexRC.y;\n\n      ${n}\n\n      ivec6 result = ivec6(r, c, d, d2, d3, d4);\n      return result;\n    }\n  `}function getOutputPacked2DCoords(e,t){const n=[Math.ceil(t[0]/2),Math.ceil(t[1]/2)];if(arraysEqual$1(e,t))return`\n      ivec2 getOutputCoords() {\n        return 2 * ivec2(resultUV.yx * vec2(${n[0]}, ${n[1]}));\n      }\n    `;const r=Math.ceil(e[1]/2);return`\n    ivec2 getOutputCoords() {\n      ivec2 resTexRC = ivec2(resultUV.yx *\n                             vec2(${n[0]}, ${n[1]}));\n\n      int index = resTexRC.x * ${n[1]} + resTexRC.y;\n      int r = 2 * (index / ${r});\n      int c = imod(index, ${r}) * 2;\n\n      return ivec2(r, c);\n    }\n  `}function getOutput2DCoords(e,t){return arraysEqual$1(e,t)?`\n      ivec2 getOutputCoords() {\n        return ivec2(resultUV.yx * vec2(${t[0]}, ${t[1]}));\n      }\n    `:1===e[1]?`\n      ivec2 getOutputCoords() {\n        ivec2 resTexRC = ivec2(resultUV.yx *\n                               vec2(${t[0]}, ${t[1]}));\n        int index = resTexRC.x * ${t[1]} + resTexRC.y;\n        return ivec2(index, 0);\n      }\n    `:1===e[0]?`\n      ivec2 getOutputCoords() {\n        ivec2 resTexRC = ivec2(resultUV.yx *\n                               vec2(${t[0]}, ${t[1]}));\n        int index = resTexRC.x * ${t[1]} + resTexRC.y;\n        return ivec2(0, index);\n      }\n    `:`\n    ivec2 getOutputCoords() {\n      ivec2 resTexRC = ivec2(resultUV.yx *\n                             vec2(${t[0]}, ${t[1]}));\n      int index = resTexRC.x * ${t[1]} + resTexRC.y;\n      int r = index / ${e[1]};\n      int c = index - r * ${e[1]};\n      return ivec2(r, c);\n    }\n  `}function getFlatOffsetUniformName(e){return`offset${e}`}function getPackedSamplerScalar(e){const t=e.name;return`\n    vec4 ${"get"+t.charAt(0).toUpperCase()+t.slice(1)}() {\n      return ${getGlslDifferences().texture2D}(${t}, halfCR);\n    }\n  `}function getSamplerScalar(e){const t=e.name,n="get"+t.charAt(0).toUpperCase()+t.slice(1);if(e.shapeInfo.isUniform)return`float ${n}() {return ${t};}`;const[r,i]=e.shapeInfo.texShape;if(1===r&&1===i)return`\n      float ${n}() {\n        return sampleTexture(${t}, halfCR);\n      }\n    `;const[a,o]=e.shapeInfo.texShape;return`\n    float ${n}() {\n      vec2 uv = uvFromFlat(${a}, ${o}, ${getFlatOffsetUniformName(t)});\n      return sampleTexture(${t}, uv);\n    }\n  `}function getPackedSampler1D(e){const t=e.name,n="get"+t.charAt(0).toUpperCase()+t.slice(1),r=e.shapeInfo.texShape,i=[Math.ceil(r[0]/2),Math.ceil(r[1]/2)],a=getGlslDifferences();return`\n    vec4 ${n}(int index) {\n      vec2 uv = packedUVfrom1D(\n        ${i[0]}, ${i[1]}, index);\n      return ${a.texture2D}(${t}, uv);\n    }\n  `}function getSampler1D(e){const t=e.name,n="get"+t.charAt(0).toUpperCase()+t.slice(1);if(e.shapeInfo.isUniform)return`\n      float ${n}(int index) {\n        ${getUniformSampler(e)}\n      }\n    `;const r=e.shapeInfo.texShape,i=r[0],a=r[1];if(1===a&&1===i)return`\n      float ${n}(int index) {\n        return sampleTexture(${t}, halfCR);\n      }\n    `;const o=getFlatOffsetUniformName(t);return 1===a?`\n      float ${n}(int index) {\n        vec2 uv = vec2(0.5, (float(index + ${o}) + 0.5) / ${i}.0);\n        return sampleTexture(${t}, uv);\n      }\n    `:1===i?`\n      float ${n}(int index) {\n        vec2 uv = vec2((float(index + ${o}) + 0.5) / ${a}.0, 0.5);\n        return sampleTexture(${t}, uv);\n      }\n    `:`\n    float ${n}(int index) {\n      vec2 uv = uvFromFlat(${i}, ${a}, index + ${o});\n      return sampleTexture(${t}, uv);\n    }\n  `}function getPackedSampler2D(e){const t=e.shapeInfo.logicalShape,n=e.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),i=e.shapeInfo.texShape,a=i[0],o=i[1],s=getGlslDifferences();if(null!=i&&arraysEqual$1(t,i))return`\n      vec4 ${r}(int row, int col) {\n        vec2 uv = (vec2(col, row) + halfCR) / vec2(${o}.0, ${a}.0);\n\n        return ${s.texture2D}(${n}, uv);\n      }\n    `;const l=[Math.ceil(i[0]/2),Math.ceil(i[1]/2)];return`\n    vec4 ${r}(int row, int col) {\n      vec2 uv = packedUVfrom2D(${Math.ceil(t[1]/2)}, ${l[0]}, ${l[1]}, row, col);\n      return ${s.texture2D}(${n}, uv);\n    }\n  `}function getSampler2D(e){const t=e.shapeInfo.logicalShape,n=e.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),i=e.shapeInfo.texShape;if(null!=i&&arraysEqual$1(t,i)){return`\n    float ${r}(int row, int col) {\n      vec2 uv = (vec2(col, row) + halfCR) / vec2(${i[1]}.0, ${i[0]}.0);\n      return sampleTexture(${n}, uv);\n    }\n  `}const{newShape:a,keptDims:o}=squeezeShape(t);if(a.length<t.length){const t=["row","col"];return`\n      ${getSamplerFromInInfo(squeezeInputInfo(e,a))}\n      float ${r}(int row, int col) {\n        return ${r}(${getSqueezedParams(t,o)});\n      }\n    `}if(e.shapeInfo.isUniform)return`\n      float ${r}(int row, int col) {\n        int index = round(dot(vec2(row, col), vec2(${t[1]}, 1)));\n        ${getUniformSampler(e)}\n      }\n    `;const s=i[0],l=i[1],c=getFlatOffsetUniformName(n);return 1===l?`\n    float ${r}(int row, int col) {\n      float index = dot(vec3(row, col, ${c}), vec3(${t[1]}, 1, 1));\n      vec2 uv = vec2(0.5, (index + 0.5) / ${s}.0);\n      return sampleTexture(${n}, uv);\n    }\n  `:1===s?`\n    float ${r}(int row, int col) {\n      float index = dot(vec3(row, col, ${c}), vec3(${t[1]}, 1, 1));\n      vec2 uv = vec2((index + 0.5) / ${l}.0, 0.5);\n      return sampleTexture(${n}, uv);\n    }\n  `:`\n  float ${r}(int row, int col) {\n    // Explicitly use integer operations as dot() only works on floats.\n    int index = row * ${t[1]} + col + ${c};\n    vec2 uv = uvFromFlat(${s}, ${l}, index);\n    return sampleTexture(${n}, uv);\n  }\n`}function getPackedSampler3D(e){const t=e.shapeInfo.logicalShape,n=e.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),i=e.shapeInfo.texShape,a=[Math.ceil(i[0]/2),Math.ceil(i[1]/2)];if(1===t[0]){const n=[1,2],i=["b","row","col"];return`\n        ${getPackedSamplerFromInInfo(squeezeInputInfo(e,t.slice(1)))}\n        vec4 ${r}(int b, int row, int col) {\n          return ${r}(${getSqueezedParams(i,n)});\n        }\n      `}const o=a[0],s=a[1],l=Math.ceil(t[2]/2);return`\n    vec4 ${r}(int b, int row, int col) {\n      vec2 uv = packedUVfrom3D(\n        ${o}, ${s}, ${l*Math.ceil(t[1]/2)}, ${l}, b, row, col);\n      return ${getGlslDifferences().texture2D}(${n}, uv);\n    }\n  `}function getSampler3D(e){const t=e.shapeInfo.logicalShape,n=e.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),i=t[1]*t[2],a=t[2],{newShape:o,keptDims:s}=squeezeShape(t);if(o.length<t.length){const t=["row","col","depth"];return`\n        ${getSamplerFromInInfo(squeezeInputInfo(e,o))}\n        float ${r}(int row, int col, int depth) {\n          return ${r}(${getSqueezedParams(t,s)});\n        }\n      `}if(e.shapeInfo.isUniform)return`\n      float ${r}(int row, int col, int depth) {\n        int index = round(dot(vec3(row, col, depth),\n                          vec3(${i}, ${a}, 1)));\n        ${getUniformSampler(e)}\n      }\n    `;const l=e.shapeInfo.texShape,c=l[0],h=l[1],u=e.shapeInfo.flatOffset;if(h===i&&null==u)return`\n        float ${r}(int row, int col, int depth) {\n          float texR = float(row);\n          float texC = dot(vec2(col, depth), vec2(${a}, 1));\n          vec2 uv = (vec2(texC, texR) + halfCR) /\n                     vec2(${h}.0, ${c}.0);\n          return sampleTexture(${n}, uv);\n        }\n      `;if(h===a&&null==u)return`\n    float ${r}(int row, int col, int depth) {\n      float texR = dot(vec2(row, col), vec2(${t[1]}, 1));\n      float texC = float(depth);\n      vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${h}.0, ${c}.0);\n      return sampleTexture(${n}, uv);\n    }\n  `;return`\n      float ${r}(int row, int col, int depth) {\n        // Explicitly use integer operations as dot() only works on floats.\n        int index = row * ${i} + col * ${a} + depth + ${getFlatOffsetUniformName(n)};\n        vec2 uv = uvFromFlat(${c}, ${h}, index);\n        return sampleTexture(${n}, uv);\n      }\n  `}function getPackedSamplerND(e){const t=e.shapeInfo.logicalShape,n=t.length,r=e.name,i="get"+r.charAt(0).toUpperCase()+r.slice(1),a=e.shapeInfo.texShape,o=[Math.ceil(a[0]/2),Math.ceil(a[1]/2)],s=o[0],l=o[1],c=Math.ceil(t[n-1]/2);let h=c*Math.ceil(t[n-2]/2),u="int b, int row, int col",d=`b * ${h} + (row / 2) * ${c} + (col / 2)`;for(let e=2;e<n-1;e++)u=`int b${e}, `+u,h*=t[n-e-1],d=`b${e} * ${h} + `+d;return`\n    vec4 ${i}(${u}) {\n      int index = ${d};\n      int texR = index / ${l};\n      int texC = index - texR * ${l};\n      vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${l}, ${s});\n      return ${getGlslDifferences().texture2D}(${r}, uv);\n    }\n  `}function getSampler4D(e){const t=e.shapeInfo.logicalShape,n=e.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),i=t[3],a=t[2]*i,o=t[1]*a,{newShape:s,keptDims:l}=squeezeShape(t);if(s.length<t.length){const t=["row","col","depth","depth2"];return`\n      ${getSamplerFromInInfo(squeezeInputInfo(e,s))}\n      float ${r}(int row, int col, int depth, int depth2) {\n        return ${r}(${getSqueezedParams(t,l)});\n      }\n    `}if(e.shapeInfo.isUniform)return`\n      float ${r}(int row, int col, int depth, int depth2) {\n        int index = round(dot(vec4(row, col, depth, depth2),\n                          vec4(${o}, ${a}, ${i}, 1)));\n        ${getUniformSampler(e)}\n      }\n    `;const c=e.shapeInfo.flatOffset,h=e.shapeInfo.texShape,u=h[0],d=h[1];if(d===o&&null==c)return`\n      float ${r}(int row, int col, int depth, int depth2) {\n        float texR = float(row);\n        float texC =\n            dot(vec3(col, depth, depth2),\n                vec3(${a}, ${i}, 1));\n        vec2 uv = (vec2(texC, texR) + halfCR) /\n                   vec2(${d}.0, ${u}.0);\n        return sampleTexture(${n}, uv);\n      }\n    `;if(d===i&&null==c)return`\n      float ${r}(int row, int col, int depth, int depth2) {\n        float texR = dot(vec3(row, col, depth),\n                         vec3(${t[1]*t[2]}, ${t[2]}, 1));\n        float texC = float(depth2);\n        vec2 uv = (vec2(texC, texR) + halfCR) /\n                  vec2(${d}.0, ${u}.0);\n        return sampleTexture(${n}, uv);\n      }\n    `;return`\n    float ${r}(int row, int col, int depth, int depth2) {\n      // Explicitly use integer operations as dot() only works on floats.\n      int index = row * ${o} + col * ${a} +\n          depth * ${i} + depth2;\n      vec2 uv = uvFromFlat(${u}, ${d}, index + ${getFlatOffsetUniformName(n)});\n      return sampleTexture(${n}, uv);\n    }\n  `}function getSampler5D(e){const t=e.shapeInfo.logicalShape,n=e.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),i=t[4],a=t[3]*i,o=t[2]*a,s=t[1]*o,{newShape:l,keptDims:c}=squeezeShape(t);if(l.length<t.length){const t=["row","col","depth","depth2","depth3"];return`\n      ${getSamplerFromInInfo(squeezeInputInfo(e,l))}\n      float ${r}(int row, int col, int depth, int depth2, int depth3) {\n        return ${r}(${getSqueezedParams(t,c)});\n      }\n    `}if(e.shapeInfo.isUniform)return`\n      float ${r}(int row, int col, int depth, int depth2, int depth3) {\n        float index = dot(\n          vec4(row, col, depth, depth2),\n          vec4(${s}, ${o}, ${a}, ${i})) +\n          depth3;\n        ${getUniformSampler(e)}\n      }\n    `;const h=e.shapeInfo.flatOffset,u=e.shapeInfo.texShape,d=u[0],p=u[1];if(p===s&&null==h)return`\n      float ${r}(int row, int col, int depth, int depth2, int depth3) {\n        int texR = row;\n        float texC = dot(vec4(col, depth, depth2, depth3),\n                         vec4(${o}, ${a}, ${i}, 1));\n        vec2 uv = (vec2(texC, texR) + halfCR) /\n                   vec2(${p}.0, ${d}.0);\n        return sampleTexture(${n}, uv);\n      }\n    `;if(p===i&&null==h)return`\n      float ${r}(int row, int col, int depth, int depth2, int depth3) {\n        float texR = dot(\n          vec4(row, col, depth, depth2),\n          vec4(${t[1]*t[2]*t[3]},\n               ${t[2]*t[3]}, ${t[3]}, 1));\n        int texC = depth3;\n        vec2 uv = (vec2(texC, texR) + halfCR) /\n                  vec2(${p}.0, ${d}.0);\n        return sampleTexture(${n}, uv);\n      }\n    `;return`\n    float ${r}(int row, int col, int depth, int depth2, int depth3) {\n      // Explicitly use integer operations as dot() only works on floats.\n      int index = row * ${s} + col * ${o} + depth * ${a} +\n          depth2 * ${i} + depth3 + ${getFlatOffsetUniformName(n)};\n      vec2 uv = uvFromFlat(${d}, ${p}, index);\n      return sampleTexture(${n}, uv);\n    }\n  `}function getSampler6D(e){const t=e.shapeInfo.logicalShape,n=e.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),{newShape:i,keptDims:a}=squeezeShape(t);if(i.length<t.length){const t=["row","col","depth","depth2","depth3","depth4"];return`\n      ${getSamplerFromInInfo(squeezeInputInfo(e,i))}\n      float ${r}(int row, int col, int depth,\n                    int depth2, int depth3, int depth4) {\n        return ${r}(${getSqueezedParams(t,a)});\n      }\n    `}const o=t[5],s=t[4]*o,l=t[3]*s,c=t[2]*l,h=t[1]*c;if(e.shapeInfo.isUniform)return`\n      float ${r}(int row, int col, int depth,\n                  int depth2, int depth3, int depth4) {\n        int index = round(dot(\n          vec4(row, col, depth, depth2),\n          vec4(${h}, ${c}, ${l}, ${s})) +\n          dot(\n            vec2(depth3, depth4),\n            vec2(${o}, 1)));\n        ${getUniformSampler(e)}\n      }\n    `;const u=e.shapeInfo.flatOffset,d=e.shapeInfo.texShape,p=d[0],m=d[1];if(m===h&&null==u)return`\n      float ${r}(int row, int col, int depth,\n                    int depth2, int depth3, int depth4) {\n        int texR = row;\n        float texC = dot(vec4(col, depth, depth2, depth3),\n          vec4(${c}, ${l}, ${s}, ${o})) +\n               float(depth4);\n        vec2 uv = (vec2(texC, texR) + halfCR) /\n                   vec2(${m}.0, ${p}.0);\n        return sampleTexture(${n}, uv);\n      }\n    `;if(m===o&&null==u)return`\n      float ${r}(int row, int col, int depth,\n                    int depth2, int depth3, int depth4) {\n        float texR = dot(vec4(row, col, depth, depth2),\n          vec4(${t[1]*t[2]*t[3]*t[4]},\n               ${t[2]*t[3]*t[4]},\n               ${t[3]*t[4]},\n               ${t[4]})) + float(depth3);\n        int texC = depth4;\n        vec2 uv = (vec2(texC, texR) + halfCR) /\n                  vec2(${m}.0, ${p}.0);\n        return sampleTexture(${n}, uv);\n      }\n    `;return`\n    float ${r}(int row, int col, int depth,\n                  int depth2, int depth3, int depth4) {\n      // Explicitly use integer operations as dot() only works on floats.\n      int index = row * ${h} + col * ${c} + depth * ${l} +\n          depth2 * ${s} + depth3 * ${o} + depth4 + ${getFlatOffsetUniformName(n)};\n      vec2 uv = uvFromFlat(${p}, ${m}, index);\n      return sampleTexture(${n}, uv);\n    }\n  `}function getUniformSampler(e){const t=e.name,n=sizeFromShape(e.shapeInfo.logicalShape);return n<2?`return ${t};`:`\n    for (int i = 0; i < ${n}; i++) {\n      if (i == index) {\n        return ${t}[i];\n      }\n    }\n  `}function getPackedSamplerAtOutputCoords(e,t){const n=e.name,r=n.charAt(0).toUpperCase()+n.slice(1),i="get"+r+"AtOutCoords",a=e.shapeInfo.logicalShape.length,o=t.logicalShape.length,s=getBroadcastDims(e.shapeInfo.logicalShape,t.logicalShape),l=getCoordsDataType(o),c=o-a;let h;const u=["x","y","z","w","u","v"];h=0===a?"":o<2&&s.length>=1?"coords = 0;":s.map((e=>`coords.${u[e+c]} = 0;`)).join("\n");let d="";d=o<2&&a>0?"coords":e.shapeInfo.logicalShape.map(((e,t)=>`coords.${u[t+c]}`)).join(", ");let p="return outputValue;";const m=1===sizeFromShape(e.shapeInfo.logicalShape),f=1===sizeFromShape(t.logicalShape);if(1!==a||m||f){if(m&&!f)p=1===o?"\n        return vec4(outputValue.x, outputValue.x, 0., 0.);\n      ":"\n        return vec4(outputValue.x);\n      ";else if(s.length){const e=a-2,t=a-1;s.indexOf(e)>-1&&s.indexOf(t)>-1?p="return vec4(outputValue.x);":s.indexOf(e)>-1?p="return vec4(outputValue.x, outputValue.y, outputValue.x, outputValue.y);":s.indexOf(t)>-1&&(p="return vec4(outputValue.xx, outputValue.zz);")}}else p="\n      return vec4(outputValue.xy, outputValue.xy);\n    ";return`\n    vec4 ${i}() {\n      ${l} coords = getOutputCoords();\n      ${h}\n      vec4 outputValue = get${r}(${d});\n      ${p}\n    }\n  `}function getSamplerAtOutputCoords(e,t){const n=e.name,r=n.charAt(0).toUpperCase()+n.slice(1),i="get"+r+"AtOutCoords",a=e.shapeInfo.logicalShape.length,o=t.logicalShape.length;if(!e.shapeInfo.isUniform&&a===o&&null==e.shapeInfo.flatOffset&&arraysEqual$1(e.shapeInfo.texShape,t.texShape))return`\n      float ${i}() {\n        return sampleTexture(${n}, resultUV);\n      }\n    `;const s=getCoordsDataType(o),l=getBroadcastDims(e.shapeInfo.logicalShape,t.logicalShape),c=o-a;let h;const u=["x","y","z","w","u","v"];h=0===a?"":o<2&&l.length>=1?"coords = 0;":l.map((e=>`coords.${u[e+c]} = 0;`)).join("\n");let d="";return d=o<2&&a>0?"coords":e.shapeInfo.logicalShape.map(((e,t)=>`coords.${u[t+c]}`)).join(", "),`\n    float ${i}() {\n      ${s} coords = getOutputCoords();\n      ${h}\n      return get${r}(${d});\n    }\n  `}function getCoordsDataType(e){if(e<=1)return"int";if(2===e)return"ivec2";if(3===e)return"ivec3";if(4===e)return"ivec4";if(5===e)return"ivec5";if(6===e)return"ivec6";throw Error(`GPU for rank ${e} is not yet supported`)}function squeezeInputInfo(e,t){const n=JSON.parse(JSON.stringify(e));return n.shapeInfo.logicalShape=t,n}function getSqueezedParams(e,t){return t.map((t=>e[t])).join(", ")}
/**
     * @license
     * Copyright 2017 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function compileProgram(e,t,n,r){const i=t.userCode,a=n.map(((e,n)=>{const r={logicalShape:e.shape,texShape:e.isUniform?null:e.texData.texShape,isUniform:e.isUniform,isPacked:!e.isUniform&&e.texData.isPacked,flatOffset:null};return null!=e.texData&&null!=e.texData.slice&&e.texData.slice.flatOffset>0&&(r.flatOffset=e.texData.slice.flatOffset),{name:t.variableNames[n],shapeInfo:r}})),o=a.map((e=>e.shapeInfo)),s={logicalShape:r.shape,texShape:r.texData.texShape,isUniform:!1,isPacked:r.texData.isPacked,flatOffset:null},l=makeShader(a,s,i,t.packedInputs),c=e.createProgram(l);let h=null;const u=e.getUniformLocation(c,"NAN",!1);1===env().getNumber("WEBGL_VERSION")&&(h=e.getUniformLocation(c,"INFINITY",!1));const d={};for(let n=0;n<t.variableNames.length;n++){const r=t.variableNames[n],i=!1;d[r]=e.getUniformLocation(c,r,i),d[`offset${r}`]=e.getUniformLocation(c,`offset${r}`,i)}return{program:t,source:l,webGLProgram:c,uniformLocations:d,inShapeInfos:o,outShapeInfo:s,infLoc:h,nanLoc:u}}function validateBinaryAndProgram(e,t){if(e.length!==t.length)throw Error(`Binary was compiled with ${e.length} inputs, but was executed with ${t.length} inputs`);e.forEach(((e,n)=>{const r=e.logicalShape,i=t[n],a=i.shape;if(!arraysEqual$1(r,a))throw Error(`Binary was compiled with different shapes than the current args. Shapes ${r} and ${a} must match`);if(e.isUniform&&i.isUniform)return;const o=e.texShape,s=i.isUniform?null:i.texData.texShape;if(!arraysEqual$1(o,s))throw Error(`Binary was compiled with different texture shapes than the current args. Shape ${o} and ${s} must match`)}))}function runProgram(e,t,n,r,i){validateBinaryAndProgram(t.inShapeInfos,n),validateBinaryAndProgram([t.outShapeInfo],[r]);const a=r.texData.texture,o=r.texData.texShape;r.texData.isPacked?e.setOutputPackedMatrixTexture(a,o[0],o[1]):e.setOutputMatrixTexture(a,o[0],o[1]),e.setProgram(t.webGLProgram),1===env().getNumber("WEBGL_VERSION")&&null!==t.infLoc&&e.gl.uniform1f(t.infLoc,1/0),null!==t.nanLoc&&e.gl.uniform1f(t.nanLoc,NaN),n.forEach(((n,r)=>{const i=t.program.variableNames[r],a=t.uniformLocations[i],o=t.uniformLocations[`offset${i}`];if(null!=a)if(n.isUniform)if(sizeFromShape(n.shape)<2)e.gl.uniform1f(a,n.uniformValues[0]);else{let t=n.uniformValues;t instanceof Float32Array||(t=new Float32Array(t)),e.gl.uniform1fv(a,t)}else null!=n.texData.slice&&null!=o&&e.gl.uniform1i(o,n.texData.slice.flatOffset),e.setInputMatrixTexture(n.texData.texture,a,r)})),null!=i&&i(e,t.webGLProgram),e.executeProgram()}function makeShaderKey(e,t,n){let r="";t.concat(n).forEach((e=>{r+=`${e.shape}_${e.isUniform?"uniform":e.texData.texShape}_${null!=e.texData&&null!=e.texData.slice&&e.texData.slice.flatOffset>0}`}));let i=e.constructor.name;return i+="_"+r+"_"+e.userCode,i}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */const{addImpl:addImplCPU,bincountImpl:bincountImplCPU,bincountReduceImpl:bincountReduceImplCPU,ceilImpl:ceilImplCPU,concatImpl:concatImplCPU,expImpl:expImplCPU,expm1Impl:expm1ImplCPU,floorImpl:floorImplCPU,gatherV2Impl:gatherV2ImplCPU,greaterImpl:greaterImplCPU,lessImpl:lessImplCPU,linSpaceImpl:linSpaceImplCPU,logImpl:logImplCPU,maxImpl:maxImplCPU,maximumImpl:maximumImplCPU,minimumImpl:minimumImplCPU,multiplyImpl:multiplyImplCPU,negImpl:negImplCPU,prodImpl:prodImplCPU,rangeImpl:rangeImplCPU,rsqrtImpl:rsqrtImplCPU,simpleAbsImpl:simpleAbsImplCPU,sliceImpl:sliceImplCPU,stridedSliceImpl:stridedSliceImplCPU,subImpl:subImplCPU,tileImpl:tileImplCPU,topKImpl:topKImplCPU,transposeImpl:transposeImplCPU,uniqueImpl:uniqueImplCPU}=shared;
/**
     * @license
     * Copyright 2018 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function getVecChannels(e,t){return["x","y","z","w","u","v"].slice(0,t).map((t=>`${e}.${t}`))}function getChannels(e,t){return 1===t?[e]:getVecChannels(e,t)}function getSourceCoords$2(e,t){if(1===e)return"rc";let n="";for(let r=0;r<e;r++)n+=t[r],r<e-1&&(n+=",");return n}
/**
     * @license
     * Copyright 2018 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */class PackProgram{constructor(e){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.outputShape=e;const t=e.length;if(0===t)this.userCode="\n        void main() {\n          setOutput(vec4(getA(), 0., 0., 0.));\n        }\n      ";else{const n=getChannels("rc",t),r=getCoordsDataType(t),i=getOutOfBoundsCondition(t,e,n),a=getSetup(t,e[e.length-1],e[e.length-2],n),o=getOutput(e,n);this.userCode=`\n        void main() {\n          ${r} rc = getOutputCoords();\n\n          if(${i}) {\n            setOutput(vec4(0));\n          } else {\n            ${a}\n\n            setOutput(vec4(${o}));\n          }\n        }\n      `}}}function getSourceCoordsArr(e,t){const n=[];for(let r=0;r<=1;r++)for(let i=0;i<=1;i++){let a=`${0===r?"r":"rp1"}, ${0===i?"c":"cp1"}`;for(let n=2;n<e;n++)a=`${t[t.length-1-n]},`+a;n.push(a)}return n}function getOutOfBoundsCondition(e,t,n){if(1===e)return`rc > ${t[0]}`;let r="";for(let i=e-2;i<e;i++)r+=`${n[i]} >= ${t[i]}`,i<e-1&&(r+="||");return r}function getSetup(e,t,n,r){if(1===e)return"";const i=r.slice(-2);return`\n    int r = ${i[0]};\n    int c = ${i[1]};\n    int rp1 = r + 1;\n    int cp1 = c + 1;\n\n    bool cEdge = cp1 >= ${t};\n    bool rEdge = rp1 >= ${n};\n  `}function getOutput(e,t){const n=e.length,r=getSourceCoordsArr(n,t);return 1===n?`getA(rc),\n            rc + 1 >= ${e[0]} ? 0. : getA(rc + 1),\n            0, 0`:`getA(${r[0]}),\n          cEdge ? 0. : getA(${r[1]}),\n          rEdge ? 0. : getA(${r[2]}),\n          rEdge || cEdge ? 0. : getA(${r[3]})`}
/**
     * @license
     * Copyright 2018 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */class ReshapePackedProgram{constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e;let n="";for(let e=0;e<4;e++){let t="thisRC = rc;";e%2==1&&(t+="thisRC.z += 1;"),e>1&&(t+="thisRC.y += 1;"),n+=`\n        ${t}\n        ${e>0?"if(thisRC.y < rows && thisRC.z < cols){":""}\n          int flatIndex = getFlatIndex(thisRC);\n\n          ivec3 inputRC = inputCoordsFromReshapedOutCoords(flatIndex);\n          vec2 inputRCInnerDims = vec2(float(inputRC.y),float(inputRC.z));\n\n          result[${e}] =\n            getChannel(getA(inputRC.x, inputRC.y, inputRC.z), inputRCInnerDims);\n        ${e>0?"}":""}\n      `}this.userCode=`\n      ${getReshapedInputCoords(t)}\n      ${getFlatIndexFrom3D(e)}\n\n      void main() {\n        ivec3 rc = getOutputCoords();\n\n        vec4 result = vec4(0.);\n\n        ivec3 thisRC;\n        int rows = ${e[1]};\n        int cols = ${e[2]};\n\n        ${n}\n\n        setOutput(result);\n      }\n    `}}function getReshapedInputCoords(e){return`\n    ivec3 inputCoordsFromReshapedOutCoords(int index) {\n      ${getLogicalCoordinatesFromFlatIndex(["r","c","d"],e)}\n      return ivec3(r, c, d);\n    }\n  `}
/**
     * @license
     * Copyright 2017 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */class TextureManager{constructor(e){this.gpgpu=e,this.numUsedTextures=0,this.numFreeTextures=0,this._numBytesAllocated=0,this._numBytesFree=0,this.freeTextures={},this.logEnabled=!1,this.usedTextures={}}acquireTexture(e,t,n){const r=getPhysicalFromLogicalTextureType(t,n),i=getKeyFromTextureShape(e,r,n);i in this.freeTextures||(this.freeTextures[i]=[]),i in this.usedTextures||(this.usedTextures[i]=[]);const a=computeBytes(e,r,this.gpgpu.gl,this.gpgpu.textureConfig,n);if(this.freeTextures[i].length>0){this.numFreeTextures--,this.numUsedTextures++,this._numBytesFree-=a,this.log();const e=this.freeTextures[i].shift();return this.usedTextures[i].push(e),e}let o;return r===PhysicalTextureType.PACKED_2X2_FLOAT32?o=this.gpgpu.createPackedMatrixTexture(e[0],e[1]):r===PhysicalTextureType.PACKED_2X2_FLOAT16?o=this.gpgpu.createFloat16PackedMatrixTexture(e[0],e[1]):r===PhysicalTextureType.UNPACKED_FLOAT32?o=this.gpgpu.createFloat32MatrixTexture(e[0],e[1]):r===PhysicalTextureType.UNPACKED_FLOAT16?o=this.gpgpu.createFloat16MatrixTexture(e[0],e[1]):r===PhysicalTextureType.PACKED_4X1_UNSIGNED_BYTE&&(o=this.gpgpu.createUnsignedBytesMatrixTexture(e[0],e[1])),this.usedTextures[i].push(o),this.numUsedTextures++,this._numBytesAllocated+=a,this.log(),o}releaseTexture(e,t,n,r){if(null==this.freeTextures)return;const i=getPhysicalFromLogicalTextureType(n,r),a=getKeyFromTextureShape(t,i,r);a in this.freeTextures||(this.freeTextures[a]=[]);const o=computeBytes(t,i,this.gpgpu.gl,this.gpgpu.textureConfig,r),s=env().get("WEBGL_DELETE_TEXTURE_THRESHOLD");-1!==s&&this._numBytesAllocated>s?(this.gpgpu.deleteMatrixTexture(e),this._numBytesAllocated-=o):(this.freeTextures[a].push(e),this.numFreeTextures++,this._numBytesFree+=o),this.numUsedTextures--;const l=this.usedTextures[a],c=l.indexOf(e);if(c<0)throw new Error("Cannot release a texture that was never provided by this texture manager");l.splice(c,1),this.log()}log(){if(!this.logEnabled)return;console.log("Free/Used",`${this.numFreeTextures} / ${this.numUsedTextures}`,`(${this.numFreeTextures+this.numUsedTextures})`);const e=this._numBytesFree/this._numBytesAllocated;console.log(`Bytes allocated: ${this._numBytesAllocated}`),console.log(`Bytes unused: ${this._numBytesFree} (${Math.round(100*e)}%)`)}get numBytesAllocated(){return this._numBytesAllocated}get numBytesFree(){return this._numBytesFree}getNumUsedTextures(){return this.numUsedTextures}getNumFreeTextures(){return this.numFreeTextures}dispose(){if(null!=this.freeTextures){for(const e in this.freeTextures)this.freeTextures[e].forEach((e=>{this.gpgpu.deleteMatrixTexture(e)}));for(const e in this.usedTextures)this.usedTextures[e].forEach((e=>{this.gpgpu.deleteMatrixTexture(e)}));this.freeTextures=null,this.usedTextures=null,this.numUsedTextures=0,this.numFreeTextures=0,this._numBytesAllocated=0,this._numBytesFree=0}}}function numBytesForInternalFormat(e,t){if(t===e.R32F)return 4;if(t===e.R16F)return 2;if(t===e.RGBA32F)return 16;if(t===e.RGBA)return 16;if(t===e.RGBA16F)return 8;throw new Error(`Unknown internal format ${t}`)}function computeBytes(e,t,n,r,i){const a=internalFormatForPhysicalTexType(t,r);let o;if(i){const[t,n]=getPackedMatrixTextureShapeWidthHeight(e[0],e[1]);o=t*n}else{const[t,n]=getUnpackedMatrixTextureShapeWidthHeight(e[0],e[1]);o=t*n}return o*numBytesForInternalFormat(n,a)}function internalFormatForPhysicalTexType(e,t){switch(e){case PhysicalTextureType.PACKED_2X2_FLOAT32:return getInternalFormatForPackedMatrixTexture(t);case PhysicalTextureType.PACKED_2X2_FLOAT16:return getInternalFormatForFloat16PackedMatrixTexture(t);case PhysicalTextureType.UNPACKED_FLOAT32:return getInternalFormatForFloat32MatrixTexture(t);case PhysicalTextureType.UNPACKED_FLOAT16:return getInternalFormatForFloat16MatrixTexture(t);case PhysicalTextureType.PACKED_4X1_UNSIGNED_BYTE:return getInternalFormatForUnsignedBytesMatrixTexture(t);default:throw new Error(`Unknown physical texture type ${e}`)}}function getPhysicalTextureForRendering(e){return env().getBool("WEBGL_RENDER_FLOAT32_ENABLED")?e?PhysicalTextureType.PACKED_2X2_FLOAT32:PhysicalTextureType.UNPACKED_FLOAT32:e?PhysicalTextureType.PACKED_2X2_FLOAT16:PhysicalTextureType.UNPACKED_FLOAT16}function getPhysicalFromLogicalTextureType(e,t){if(e===TextureUsage.UPLOAD)return PhysicalTextureType.PACKED_2X2_FLOAT32;if(e===TextureUsage.RENDER||null==e)return getPhysicalTextureForRendering(t);if(e===TextureUsage.DOWNLOAD||e===TextureUsage.PIXELS)return PhysicalTextureType.PACKED_4X1_UNSIGNED_BYTE;throw new Error(`Unknown logical texture type ${e}`)}function getKeyFromTextureShape(e,t,n){return`${e[0]}_${e[1]}_${t}_${n}`}
/**
     * @license
     * Copyright 2017 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */class UnaryOpProgram{constructor(e,t){this.variableNames=["A"],this.outputShape=e,this.userCode=`\n      float unaryOperation(float x) {\n        ${t}\n      }\n\n      void main() {\n        float x = getAAtOutCoords();\n        float y = unaryOperation(x);\n\n        setOutput(y);\n      }\n    `}}const CHECK_NAN_SNIPPET$2="if (isnan(x)) return x;",LINEAR$1="return x;",ABS$1="return abs(x);",ELU$2="return (x >= 0.0) ? x : (exp(x) - 1.0);",RELU$2=CHECK_NAN_SNIPPET$2+"\n  return (x < 0.0) ? 0.0 : x;\n",RELU6$2=CHECK_NAN_SNIPPET$2+"\n  return (x < 0.0) ? 0.0 : min(6.0, x);\n",CLONE="return x;",LINEAR="return x;",ELU$1="\n  vec4 result;\n\n  result.r = (x.r >= 0.0) ? x.r : (exp(x.r) - 1.0);\n  result.g = (x.g >= 0.0) ? x.g : (exp(x.g) - 1.0);\n  result.b = (x.b >= 0.0) ? x.b : (exp(x.b) - 1.0);\n  result.a = (x.a >= 0.0) ? x.a : (exp(x.a) - 1.0);\n\n  return result;\n",RELU$1="\n  vec4 result = x * vec4(greaterThanEqual(x, vec4(0.0)));\n  bvec4 isNaN = isnan(x);\n\n  result.r = isNaN.r ? x.r : result.r;\n  result.g = isNaN.g ? x.g : result.g;\n  result.b = isNaN.b ? x.b : result.b;\n  result.a = isNaN.a ? x.a : result.a;\n\n  return result;\n",RELU6$1="\n  vec4 result = min(x, vec4(6.)) * vec4(greaterThanEqual(x, vec4(0.0)));\n  bvec4 isNaN = isnan(x);\n\n  result.r = isNaN.r ? x.r : result.r;\n  result.g = isNaN.g ? x.g : result.g;\n  result.b = isNaN.b ? x.b : result.b;\n  result.a = isNaN.a ? x.a : result.a;\n\n  return result;\n";class UnaryOpPackedProgram{constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.userCode=`\n      vec4 unaryOperation(vec4 x) {\n        ${t}\n      }\n\n      void main() {\n        vec4 x = getAAtOutCoords();\n        vec4 y = unaryOperation(x);\n\n        setOutput(y);\n      }\n    `}}
/**
     * @license
     * Copyright 2018 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */class UnpackProgram{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outputShape=e;const t=e.length,n=getChannels("rc",t),r=getCoordsDataType(t),i=getSourceCoords$2(t,n),a=n.slice(-2),o=t<=1?"rc":`vec2(${a.join(",")})`;this.userCode=`\n      void main() {\n        ${r} rc = getOutputCoords();\n        vec4 packedInput = getA(${i});\n\n        setOutput(getChannel(packedInput, ${o}));\n      }\n    `}}
/**
     * @license
     * Copyright 2017 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */const whereImpl=whereImpl$2,EPSILON_FLOAT32=1e-7,EPSILON_FLOAT16=1e-4,binaryCaches={};function getBinaryCache(e){return e in binaryCaches||(binaryCaches[e]={}),binaryCaches[e]}const CPU_HANDOFF_SIZE_THRESHOLD=128,BEFORE_PAGING_CONSTANT=600;function numMBBeforeWarning(){return null==env().global.screen?1024:env().global.screen.height*env().global.screen.width*window.devicePixelRatio*BEFORE_PAGING_CONSTANT/1024/1024}class MathBackendWebGL extends KernelBackend{constructor(e){if(super(),this.pendingRead=new WeakMap,this.pendingDisposal=new WeakSet,this.dataRefCount=new WeakMap,this.numBytesInGPU=0,this.uploadWaitMs=0,this.downloadWaitMs=0,this.lastGlFlushTime=0,this.warnedAboutMemory=!1,this.pendingDeletes=0,this.disposed=!1,!env().getBool("HAS_WEBGL"))throw new Error("WebGL is not supported on this device");if(null==e){const e=getWebGLContext(env().getNumber("WEBGL_VERSION"));this.binaryCache=getBinaryCache(env().getNumber("WEBGL_VERSION")),this.gpgpu=new GPGPUContext(e),this.canvas=e.canvas,this.gpgpuCreatedLocally=!0}else this.gpgpu=e,this.binaryCache={},this.gpgpuCreatedLocally=!1,this.canvas=e.gl.canvas;this.textureManager=new TextureManager(this.gpgpu),this.numMBBeforeWarning=numMBBeforeWarning(),this.texData=new DataStorage(this,engine())}nextDataId(){return MathBackendWebGL.nextDataId++}numDataIds(){return this.texData.numDataIds()+(this.cpuBackend?this.cpuBackend.numDataIds():0)-this.pendingDeletes}write(e,t,n){if((env().getBool("WEBGL_CHECK_NUMERICAL_PROBLEMS")||env().getBool("DEBUG"))&&this.checkNumericalProblems(e),"complex64"===n&&null!=e)throw new Error("Cannot write to a complex64 dtype. Please use tf.complex(real, imag).");const r={id:this.nextDataId()};return this.texData.set(r,{shape:t,dtype:n,values:e,usage:TextureUsage.UPLOAD,refCount:1}),r}refCount(e){if(this.texData.has(e)){return this.texData.get(e).refCount}return 0}incRef(e){this.texData.get(e).refCount++}decRef(e){if(this.texData.has(e)){this.texData.get(e).refCount--}}move(e,t,n,r,i){if(env().getBool("DEBUG")&&this.checkNumericalProblems(t),"complex64"===r)throw new Error("Cannot write to a complex64 dtype. Please use tf.complex(real, imag).");this.texData.set(e,{shape:n,dtype:r,values:t,usage:TextureUsage.UPLOAD,refCount:i})}disposeIntermediateTensorInfo(e){this.disposeData(e.dataId)}readSync(e){const t=this.texData.get(e),{values:n,dtype:r,complexTensorInfos:i,slice:a,shape:o,isPacked:s}=t;if(null!=a){let t;t=s?new UnaryOpPackedProgram(o,CLONE):new UnaryOpProgram(o,CLONE);const n=this.runWebGLProgram(t,[{dataId:e,shape:o,dtype:r}],r),i=this.readSync(n.dataId);return this.disposeIntermediateTensorInfo(n),i}if(null!=n)return this.convertAndCacheOnCPU(e);if("string"===r)return n;const l=null!=this.activeTimers;let c,h;if(l&&(c=now()),"complex64"===r){h=mergeRealAndImagArrays(this.readSync(i.real.dataId),this.readSync(i.imag.dataId))}else h=this.getValuesFromTexture(e);return l&&(this.downloadWaitMs+=now()-c),this.convertAndCacheOnCPU(e,h)}async read(e){if(this.pendingRead.has(e)){const t=this.pendingRead.get(e);return new Promise((e=>t.push(e)))}const t=this.texData.get(e),{values:n,shape:r,slice:i,dtype:a,complexTensorInfos:o,isPacked:s}=t;if(null!=i){let t;t=s?new UnaryOpPackedProgram(r,CLONE):new UnaryOpProgram(r,CLONE);const n=this.runWebGLProgram(t,[{dataId:e,shape:r,dtype:a}],a),i=this.read(n.dataId);return this.disposeIntermediateTensorInfo(n),i}if(null!=n)return this.convertAndCacheOnCPU(e);if(!env().getBool("WEBGL_DOWNLOAD_FLOAT_ENABLED")&&2===env().getNumber("WEBGL_VERSION"))throw new Error("tensor.data() with WEBGL_DOWNLOAD_FLOAT_ENABLED=false and WEBGL_VERSION=2 not yet supported.");let l,c,h=null;if("complex64"!==a&&env().get("WEBGL_BUFFER_SUPPORTED")){l=this.decode(e);const t=this.texData.get(l.dataId);h=this.gpgpu.createBufferFromTexture(t.texture,...getDenseTexShape(r))}if(this.pendingRead.set(e,[]),"complex64"!==a&&await this.gpgpu.createAndWaitForFence(),"complex64"===a){const e=await Promise.all([this.read(o.real.dataId),this.read(o.imag.dataId)]);c=mergeRealAndImagArrays(e[0],e[1])}else if(null==h)c=this.getValuesFromTexture(e);else{const e=sizeFromShape(r);c=this.gpgpu.downloadFloat32MatrixFromBuffer(h,e)}null!=l&&this.disposeIntermediateTensorInfo(l);const u=this.convertAndCacheOnCPU(e,c),d=this.pendingRead.get(e);return this.pendingRead.delete(e),d.forEach((e=>e(u))),this.pendingDisposal.has(e)&&(this.pendingDisposal.delete(e),this.disposeData(e)&&engine().removeDataId(e,this),this.pendingDeletes--),u}bufferSync(e){const t=this.readSync(e.dataId);let n=t;if("string"===e.dtype)try{n=t.map((e=>decodeString(e)))}catch(e){throw new Error("Failed to decode encoded string bytes into utf-8")}return buffer(e.shape,e.dtype,n)}checkNumericalProblems(e){if(null!=e)for(let t=0;t<e.length;t++){const n=e[t];if(!canBeRepresented(n)){if(env().getBool("WEBGL_RENDER_FLOAT32_CAPABLE"))throw Error(`The value ${n} cannot be represented with your current settings. Consider enabling float32 rendering: 'tf.env().set('WEBGL_RENDER_FLOAT32_ENABLED', true);'`);throw Error(`The value ${n} cannot be represented on this device.`)}}}getValuesFromTexture(e){const{shape:t,dtype:n,isPacked:r}=this.texData.get(e),i=sizeFromShape(t);if(env().getBool("WEBGL_DOWNLOAD_FLOAT_ENABLED")){const n=this.decode(e),r=this.texData.get(n.dataId),a=this.gpgpu.downloadMatrixFromPackedTexture(r.texture,...getDenseTexShape(t)).subarray(0,i);return this.disposeIntermediateTensorInfo(n),a}const a=env().getBool("WEBGL_PACK")&&!0===r,o=a?getShapeAs3D(t):t,s=a?new EncodeFloatPackedProgram(o):new EncodeFloatProgram(o),l=this.runWebGLProgram(s,[{shape:o,dtype:n,dataId:e}],"float32"),c=this.texData.get(l.dataId),h=this.gpgpu.downloadByteEncodedFloatMatrixFromOutputTexture(c.texture,c.texShape[0],c.texShape[1]).subarray(0,i);return this.disposeIntermediateTensorInfo(l),h}timerAvailable(){return env().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0}async time(e){const t=this.activeTimers,n=[];let r=!1;null==this.programTimersStack?(this.programTimersStack=n,r=!0):this.activeTimers.push(n),this.activeTimers=n,e();const i=flatten$1(this.activeTimers.map((e=>e.query))).filter((e=>null!=e)),a=flatten$1(this.activeTimers.map((e=>e.name))).filter((e=>null!=e));this.activeTimers=t,r&&(this.programTimersStack=null);const o={uploadWaitMs:this.uploadWaitMs,downloadWaitMs:this.downloadWaitMs,kernelMs:null,wallMs:null};if(env().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0){const e=await Promise.all(i);o.kernelMs=sum$3(e),o.getExtraProfileInfo=()=>e.map(((e,t)=>({name:a[t],ms:e}))).map((e=>`${e.name}: ${e.ms}`)).join(", ")}else o.kernelMs={error:"WebGL query timers are not supported in this environment."};return this.uploadWaitMs=0,this.downloadWaitMs=0,o}memory(){return{unreliable:!1,numBytesInGPU:this.numBytesInGPU,numBytesInGPUAllocated:this.textureManager.numBytesAllocated,numBytesInGPUFree:this.textureManager.numBytesFree}}startTimer(){return env().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0?this.gpgpu.beginQuery():{startMs:now(),endMs:null}}endTimer(e){return env().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0?(this.gpgpu.endQuery(),e):(e.endMs=now(),e)}async getQueryTime(e){if(env().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0)return this.gpgpu.waitForQueryAndGetTime(e);return e.endMs-e.startMs}disposeData(e,t=!1){if(this.pendingDisposal.has(e))return!1;if(!this.texData.has(e))return!0;if(t?this.texData.get(e).refCount=0:this.texData.get(e).refCount--,!t&&this.texData.get(e).refCount>0)return!1;if(this.pendingRead.has(e))return this.pendingDisposal.add(e),this.pendingDeletes++,!1;this.releaseGPUData(e);const{complexTensorInfos:n}=this.texData.get(e);return null!=n&&(this.disposeData(n.real.dataId,t),this.disposeData(n.imag.dataId,t)),this.texData.delete(e),!0}releaseGPUData(e){const{texture:t,dtype:n,texShape:r,usage:i,isPacked:a,slice:o}=this.texData.get(e),s=o&&o.origDataId||e,l=this.dataRefCount.get(s);l>1?this.dataRefCount.set(s,l-1):(this.dataRefCount.delete(s),null!=t&&(this.numBytesInGPU-=this.computeBytes(r,n),this.textureManager.releaseTexture(t,r,i,a)));const c=this.texData.get(e);c.texture=null,c.texShape=null,c.isPacked=!1,c.slice=null}getTexture(e){return this.uploadToGPU(e),this.texData.get(e).texture}getDataInfo(e){return this.texData.get(e)}shouldExecuteOnCPU(e,t=CPU_HANDOFF_SIZE_THRESHOLD){return env().getBool("WEBGL_CPU_FORWARD")&&e.every((e=>null==this.texData.get(e.dataId).texture&&sizeFromShape(e.shape)<t))}getGPGPUContext(){return this.gpgpu}where(e){warn("tf.where() in webgl locks the UI thread. Call tf.whereAsync() instead");const t=e.dataSync();return whereImpl(e.shape,t)}packedUnaryOp(e,t,n){const r=new UnaryOpPackedProgram(e.shape,t),i=this.compileAndRun(r,[e],n);return engine().makeTensorFromDataId(i.dataId,i.shape,i.dtype)}abs(e){if(this.shouldExecuteOnCPU([e])&&"complex64"!==e.dtype){const t=simpleAbsImplCPU(this.texData.get(e.dataId).values);return this.makeOutput(e.shape,e.dtype,t)}if(env().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(e,ABS$1,e.dtype);const t=new UnaryOpProgram(e.shape,ABS$1),n=this.compileAndRun(t,[e]);return engine().makeTensorFromDataId(n.dataId,n.shape,n.dtype)}makeTensorInfo(e,t,n){let r;if("string"===t&&null!=n&&n.length>0&&isString(n[0])){const i=n.map((e=>encodeString(e)));r=this.write(i,e,t)}else r=this.write(n,e,t);return this.texData.get(r).usage=null,{dataId:r,shape:e,dtype:t}}makeOutput(e,t,n){const{dataId:r}=this.makeTensorInfo(e,t,n);return engine().makeTensorFromDataId(r,e,t,this)}unpackTensor(e){const t=new UnpackProgram(e.shape);return this.runWebGLProgram(t,[e],e.dtype)}packTensor(e){const t=new PackProgram(e.shape);return this.runWebGLProgram(t,[e],e.dtype,null,!0)}packedReshape(e,t){const n=[getBatchDim(e.shape),...getRowsCols(e.shape)],r={dtype:e.dtype,shape:n,dataId:e.dataId},i=[getBatchDim(t),...getRowsCols(t)],a=new ReshapePackedProgram(i,n),o=this.runWebGLProgram(a,[r],e.dtype,null,!0);return{dataId:o.dataId,shape:t,dtype:o.dtype}}decode(e){const t=this.texData.get(e),{isPacked:n,shape:r,dtype:i}=t,a=getShapeAs3D(r);let o;o=n?new DecodeMatrixPackedProgram(a):new DecodeMatrixProgram(a);return{dtype:i,shape:r,dataId:this.runWebGLProgram(o,[{shape:a,dtype:i,dataId:e}],i,null,!0).dataId}}runWebGLProgram(e,t,n,r,i=!1){const a=this.makeTensorInfo(e.outputShape,n),o=this.texData.get(a.dataId);if(e.packedOutput&&(o.isPacked=!0),e.outPackingScheme===PackingScheme.DENSE){const t=getDenseTexShape(e.outputShape);o.texShape=t.map((e=>2*e))}if(null!=e.outTexUsage&&(o.usage=e.outTexUsage),0===sizeFromShape(a.shape))return o.values=getTypedArrayFromDType(a.dtype,0),a;const s=[],l=t.map((t=>{if("complex64"===t.dtype)throw new Error("GPGPUProgram does not support complex64 input. For complex64 dtypes, please separate the program into real and imaginary parts.");let n=this.texData.get(t.dataId);if(null==n.texture){if(!e.packedInputs&&sizeFromShape(t.shape)<=env().getNumber("WEBGL_SIZE_UPLOAD_UNIFORM"))return{shape:t.shape,texData:null,isUniform:!0,uniformValues:n.values};e.packedInputs&&(n.isPacked=!0,n.shape=t.shape)}else if(!!n.isPacked!=!!e.packedInputs)t=n.isPacked?this.unpackTensor(t):this.packTensor(t),s.push(t),n=this.texData.get(t.dataId);else if(n.isPacked&&!isReshapeFree(n.shape,t.shape)){const e=t,r=t.shape;t.shape=n.shape,t=this.packedReshape(t,r),s.push(t),n=this.texData.get(t.dataId),e.shape=r}return this.uploadToGPU(t.dataId),{shape:t.shape,texData:n,isUniform:!1}}));this.uploadToGPU(a.dataId);const c={shape:a.shape,texData:o,isUniform:!1},h=makeShaderKey(e,l,c),u=this.getAndSaveBinary(h,(()=>compileProgram(this.gpgpu,e,l,c))),d=null!=this.activeTimers;let p;d&&(p=this.startTimer()),runProgram(this.gpgpu,u,l,c,r),s.forEach((e=>this.disposeIntermediateTensorInfo(e))),d&&(p=this.endTimer(p),this.activeTimers.push({name:e.constructor.name,query:this.getQueryTime(p)}));const m=env().get("WEBGL_FLUSH_THRESHOLD");if(m>0){const e=now();e-this.lastGlFlushTime>m&&(this.gpgpu.gl.flush(),this.lastGlFlushTime=e)}if(!env().getBool("WEBGL_LAZILY_UNPACK")&&o.isPacked&&!1===i){const e=this.unpackTensor(a);return this.disposeIntermediateTensorInfo(a),e}return a}compileAndRun(e,t,n,r,i=!1){return this.runWebGLProgram(e,t,n=n||t[0].dtype,r,i)}getAndSaveBinary(e,t){return e in this.binaryCache||(this.binaryCache[e]=t()),this.binaryCache[e]}getTextureManager(){return this.textureManager}dispose(){if(!this.disposed){if(!env().getBool("IS_TEST")){Object.keys(this.binaryCache).forEach((e=>{this.gpgpu.deleteProgram(this.binaryCache[e].webGLProgram),delete this.binaryCache[e]}))}this.textureManager.dispose(),null!=this.canvas&&"undefined"!=typeof HTMLCanvasElement&&this.canvas instanceof HTMLCanvasElement?this.canvas.remove():this.canvas=null,this.gpgpuCreatedLocally&&(this.gpgpu.program=null,this.gpgpu.dispose()),this.disposed=!0}}floatPrecision(){return null==this.floatPrecisionValue&&(this.floatPrecisionValue=tidy((()=>{if(!env().get("WEBGL_RENDER_FLOAT32_ENABLED")){const e=env().getBool("DEBUG");env().set("DEBUG",!1);const t=this.abs(scalar(1e-8)).dataSync()[0];if(env().set("DEBUG",e),t>0)return 32}return 16}))),this.floatPrecisionValue}epsilon(){return 32===this.floatPrecision()?EPSILON_FLOAT32:EPSILON_FLOAT16}uploadToGPU(e){const t=this.texData.get(e),{shape:n,dtype:r,values:i,texture:a,usage:o,isPacked:s}=t;if(null!=a)return;const l=null!=this.activeTimers;let c;l&&(c=now());let h=t.texShape;if(null==h&&(h=getTextureShapeFromLogicalShape(n,s),t.texShape=h),null!=i){const e=getShapeAs3D(n);let a,o=h[1],u=h[0];const d=i instanceof Uint8Array;s?([o,u]=getPackedMatrixTextureShapeWidthHeight(h[0],h[1]),a=new EncodeMatrixPackedProgram(e,[u,o],d)):a=new EncodeMatrixProgram(e,[u,o],d);const p=this.makeTensorInfo([u,o],r);this.texData.get(p.dataId).usage=d?TextureUsage.PIXELS:TextureUsage.UPLOAD,this.gpgpu.uploadDenseMatrixToTexture(this.getTexture(p.dataId),o,u,i);const m=this.runWebGLProgram(a,[p],r,null,!0),f=this.texData.get(m.dataId);t.texture=f.texture,t.texShape=f.texShape,t.isPacked=f.isPacked,t.usage=f.usage,this.disposeIntermediateTensorInfo(p),this.texData.delete(m.dataId),t.values=null,l&&(this.uploadWaitMs+=now()-c)}else{const e=this.acquireTexture(h,o,r,s);t.texture=e}}convertAndCacheOnCPU(e,t){const n=this.texData.get(e),{dtype:r}=n;return this.releaseGPUData(e),null!=t&&(n.values=float32ToTypedArray(t,r)),n.values}acquireTexture(e,t,n,r){if(this.numBytesInGPU+=this.computeBytes(e,n),!this.warnedAboutMemory&&this.numBytesInGPU>1024*this.numMBBeforeWarning*1024){const e=(this.numBytesInGPU/1024/1024).toFixed(2);this.warnedAboutMemory=!0,console.warn(`High memory usage in GPU: ${e} MB, most likely due to a memory leak`)}return this.textureManager.acquireTexture(e,t,r)}computeBytes(e,t){return e[0]*e[1]*bytesPerElement(t)}}function float32ToTypedArray(e,t){if("float32"===t||"complex64"===t)return e;if("int32"===t||"bool"===t){const n="int32"===t?new Int32Array(e.length):new Uint8Array(e.length);for(let t=0;t<n.length;++t)n[t]=Math.round(e[t]);return n}throw new Error(`Unknown dtype ${t}`)}
/**
     * @license
     * Copyright 2020 Google Inc. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */MathBackendWebGL.nextDataId=0,isBrowser()&&registerBackend("webgl",(()=>new MathBackendWebGL),2)
/**
     * @license
     * Copyright 2017 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */;const CHECK_NAN_SNIPPET$1="\n  if (isnan(a)) return a;\n  if (isnan(b)) return b;\n";class BinaryOpProgram{constructor(e,t,n){this.variableNames=["A","B"],this.outputShape=assertAndGetBroadcastShape(t,n),this.userCode=`\n      float binaryOperation(float a, float b) {\n        ${e}\n      }\n\n      void main() {\n        float a = getAAtOutCoords();\n        float b = getBAtOutCoords();\n        setOutput(binaryOperation(a, b));\n      }\n    `}}
/**
     * @license
     * Copyright 2018 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */const CHECK_NAN_SNIPPET="\n  result.r = isNaN.r > 0. ? NAN : result.r;\n  result.g = isNaN.g > 0. ? NAN : result.g;\n  result.b = isNaN.b > 0. ? NAN : result.b;\n  result.a = isNaN.a > 0. ? NAN : result.a;\n";class BinaryOpPackedProgram{constructor(e,t,n,r=!1){this.variableNames=["A","B"],this.supportsBroadcasting=!0,this.packedInputs=!0,this.packedOutput=!0,this.outputShape=assertAndGetBroadcastShape(t,n);const i=this.outputShape.length;let a="";if(r)if(0===i||1===sizeFromShape(this.outputShape))a="\n          result.y = 0.;\n          result.z = 0.;\n          result.w = 0.;\n        ";else{if(a=`\n          ${getCoordsDataType(i)} coords = getOutputCoords();\n        `,1===i)a+=`\n            result.y = (coords + 1) >= ${this.outputShape[0]} ? 0. : result.y;\n            result.z = 0.;\n            result.w = 0.;\n          `;else{const e=getChannels("coords",i);a+=`\n            bool nextRowOutOfBounds =\n              (${e[i-2]} + 1) >= ${this.outputShape[i-2]};\n            bool nextColOutOfBounds =\n              (${e[i-1]} + 1) >= ${this.outputShape[i-1]};\n            result.y = nextColOutOfBounds ? 0. : result.y;\n            result.z = nextRowOutOfBounds ? 0. : result.z;\n            result.w = nextColOutOfBounds || nextRowOutOfBounds ? 0. : result.w;\n          `}}this.userCode=`\n      vec4 binaryOperation(vec4 a, vec4 b) {\n        ${e}\n      }\n\n      void main() {\n        vec4 a = getAAtOutCoords();\n        vec4 b = getBAtOutCoords();\n\n        vec4 result = binaryOperation(a, b);\n        ${a}\n\n        setOutput(result);\n      }\n    `}}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function identity$2(e){const{inputs:t,backend:n}=e,{x:r}=t;return n.incRef(r.dataId),{dataId:r.dataId,shape:r.shape,dtype:r.dtype}}const identityConfig={kernelName:Identity,backendName:"webgl",kernelFunc:identity$2};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function complex(e){const{inputs:t,backend:n}=e,{real:r,imag:i}=t,a=n.makeTensorInfo(r.shape,"complex64"),o=n.texData.get(a.dataId),s=identity$2({inputs:{x:r},backend:n}),l=identity$2({inputs:{x:i},backend:n});return o.complexTensorInfos={real:s,imag:l},a}const complexConfig={kernelName:Complex,backendName:"webgl",kernelFunc:complex},LEAKYRELU="return (a < 0.) ? b * a : a;",LEAKYRELU_PACKED="\n  vec4 aLessThanZero = vec4(lessThan(a, vec4(0.)));\n  return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a);\n";
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function leakyRelu(e){const{inputs:t,backend:n,attrs:r}=e,{x:i}=t,{alpha:a}=r,o=n.makeTensorInfo([],"float32",createScalarValue(a,"float32")),s=env().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new BinaryOpPackedProgram(LEAKYRELU_PACKED,i.shape,o.shape):new BinaryOpProgram(LEAKYRELU,i.shape,o.shape),l=n.runWebGLProgram(s,[i,o],i.dtype);return n.disposeIntermediateTensorInfo(o),l}const leakyReluConfig={kernelName:LeakyRelu,backendName:"webgl",kernelFunc:leakyRelu},PRELU="return (a < 0.) ? b * a : a;",PRELU_PACKED="\n  vec4 aLessThanZero = vec4(lessThan(a, vec4(0.)));\n  return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a);\n";
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function prelu(e){const{inputs:t,backend:n}=e,{x:r,alpha:i}=t,a=env().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new BinaryOpPackedProgram(PRELU_PACKED,r.shape,i.shape):new BinaryOpProgram(PRELU,r.shape,i.shape);return n.runWebGLProgram(a,[r,i],r.dtype)}const preluConfig={kernelName:Prelu,backendName:"webgl",kernelFunc:prelu},CHECK_NAN_SNIPPET_UNARY="if (isnan(x)) return x;",CHECK_NAN_SNIPPET_BINARY="\n  if (isnan(a)) return a;\n  if (isnan(b)) return b;\n",CHECK_NAN_SNIPPET_BINARY_PACKED="\n  result.r = isNaN.r > 0. ? NAN : result.r;\n  result.g = isNaN.g > 0. ? NAN : result.g;\n  result.b = isNaN.b > 0. ? NAN : result.b;\n  result.a = isNaN.a > 0. ? NAN : result.a;\n";
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function unaryKernelFunc({opSnippet:e,packedOpSnippet:t,cpuKernelImpl:n,dtype:r}){return({inputs:i,backend:a})=>{const{x:o}=i,s=a,l=r||o.dtype;if(s.shouldExecuteOnCPU([o])&&null!=n){const e=s.texData.get(o.dataId),t=n(e.values,l);return s.makeTensorInfo(o.shape,l,t)}let c;return c=env().getBool("WEBGL_PACK_UNARY_OPERATIONS")&&null!=t?new UnaryOpPackedProgram(o.shape,t):new UnaryOpProgram(o.shape,e),s.runWebGLProgram(c,[o],l)}}function binaryKernelFunc({opSnippet:e,packedOpSnippet:t,checkOutOfBounds:n=!1,supportsComplex:r=!1,cpuKernelImpl:i,dtype:a}){return({inputs:o,backend:s})=>{const{a:l,b:c}=o,h=s;if(r&&"complex64"===l.dtype){const t=h.texData.get(l.dataId),n=h.texData.get(c.dataId),[r,i]=[[t.complexTensorInfos.real,n.complexTensorInfos.real],[t.complexTensorInfos.imag,n.complexTensorInfos.imag]].map((t=>{const[n,r]=t,i={dataId:n.dataId,dtype:n.dtype,shape:l.shape},a={dataId:r.dataId,dtype:r.dtype,shape:c.shape},o=new BinaryOpProgram(e,l.shape,c.shape);return h.runWebGLProgram(o,[i,a],upcastType(n.dtype,r.dtype))})),a=complex({inputs:{real:r,imag:i},backend:h});return h.disposeIntermediateTensorInfo(r),h.disposeIntermediateTensorInfo(i),a}const u=a||upcastType(l.dtype,c.dtype);if(h.shouldExecuteOnCPU([l,c])&&null!=i){const e=h.texData.get(l.dataId),t=h.texData.get(c.dataId),[n,r]=i(l.shape,c.shape,e.values,t.values,u),a=h.makeTensorInfo(r,u);return h.texData.get(a.dataId).values=n,a}let d;return d=env().getBool("WEBGL_PACK_BINARY_OPERATIONS")&&null!=t?new BinaryOpPackedProgram(t,l.shape,c.shape,n):new BinaryOpProgram(e,l.shape,c.shape),h.runWebGLProgram(d,[l,c],u)}}function mapActivationToShaderProgram(e,t=!1){if("linear"===e)return t?LINEAR:LINEAR$1;if("relu"===e)return t?RELU$1:RELU$2;if("elu"===e)return t?ELU$1:ELU$2;if("relu6"===e)return t?RELU6$1:RELU6$2;if("prelu"===e)return t?PRELU_PACKED:PRELU;if("leakyrelu"===e)return t?LEAKYRELU_PACKED:LEAKYRELU;throw new Error(`Activation ${e} has not been implemented for the WebGL backend.`)}
/**
     * @license
     * Copyright 2018 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */class MatMulPackedProgram{constructor(e,t,n,r=!1,i=!1,a=!1,o=null,s=!1,l=!1){this.variableNames=["matrixA","matrixB"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=n;const c=Math.ceil((r?e[1]:e[2])/2),h=r?"i * 2, rc.y":"rc.y, i * 2",u=i?"rc.z, i * 2":"i * 2, rc.z",d=r?["a.xxyy","a.zzww"]:["a.xxzz","a.yyww"],p=i?["b.xzxz","b.ywyw"]:["b.xyxy","b.zwzw"];let m="",f="";o&&(m=s?`vec4 activation(vec4 a) {\n          vec4 b = getPreluActivationWeightsAtOutCoords();\n          ${o}\n        }`:l?`vec4 activation(vec4 a) {\n          vec4 b = getLeakyreluAlphaAtOutCoords();\n          ${o}\n        }`:`vec4 activation(vec4 x) {\n          ${o}\n        }`,f="result = activation(result);");const g=a?"result += getBiasAtOutCoords();":"";a&&this.variableNames.push("bias"),s&&this.variableNames.push("preluActivationWeights"),l&&this.variableNames.push("leakyreluAlpha");let v="rc.x",y="rc.x";e[0]<t[0]?v=`int(min(float(rc.x), ${e[0]-1}.))`:t[0]<e[0]&&(y=`int(min(float(rc.x), ${t[0]-1}.))`),this.userCode=`\n      ${m}\n\n      const float sharedDimension = ${c}.0;\n\n      vec4 dot2x2ARowBCol(ivec3 rc) {\n        vec4 result = vec4(0);\n        for (int i = 0; i < ${c}; i++) {\n          int batchA = ${v};\n          int batchB = ${y};\n          vec4 a = getMatrixA(batchA, ${h});\n          vec4 b = getMatrixB(batchB, ${u});\n\n          // These swizzled products need to be separately added.\n          // See: https://github.com/tensorflow/tfjs/issues/1735\n          result += (${d[0]} * ${p[0]});\n          result += (${d[1]} * ${p[1]});\n        }\n        return result;\n      }\n\n      void main() {\n        ivec3 rc = getOutputCoords();\n        vec4 result = dot2x2ARowBCol(rc);\n\n        ${g}\n\n        ${f}\n\n        setOutput(result);\n      }\n    `}}
/**
     * @license
     * Copyright 2018 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */const COMPLEX_MULTIPLY={REAL:"return areal * breal - aimag * bimag;",IMAG:"return areal * bimag + aimag * breal;"};class BinaryOpComplexProgram{constructor(e,t,n){this.variableNames=["AReal","AImag","BReal","BImag"],this.outputShape=assertAndGetBroadcastShape(t,n),this.userCode=`\n      float binaryOpComplex(\n          float areal, float aimag, float breal, float bimag) {\n        ${e}\n      }\n\n      void main() {\n        float areal = getARealAtOutCoords();\n        float aimag = getAImagAtOutCoords();\n        float breal = getBRealAtOutCoords();\n        float bimag = getBImagAtOutCoords();\n        setOutput(binaryOpComplex(areal, aimag, breal, bimag));\n      }\n    `}}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */const MUL="return a * b;";function multiply(e){const{inputs:t,backend:n}=e,{a:r,b:i}=t,a=upcastType(r.dtype,i.dtype);if("complex64"===r.dtype){const e=n.texData.get(r.dataId),t=n.texData.get(i.dataId),a=new BinaryOpComplexProgram(COMPLEX_MULTIPLY.REAL,r.shape,i.shape),o=new BinaryOpComplexProgram(COMPLEX_MULTIPLY.IMAG,r.shape,i.shape),s=[{dataId:e.complexTensorInfos.real.dataId,dtype:e.complexTensorInfos.real.dtype,shape:r.shape},{dataId:e.complexTensorInfos.imag.dataId,dtype:e.complexTensorInfos.imag.dtype,shape:r.shape},{dataId:t.complexTensorInfos.real.dataId,dtype:t.complexTensorInfos.real.dtype,shape:i.shape},{dataId:t.complexTensorInfos.imag.dataId,dtype:t.complexTensorInfos.imag.dtype,shape:i.shape}],l=n.runWebGLProgram(a,s,"float32"),c=n.runWebGLProgram(o,s,"float32"),h=complex({inputs:{real:l,imag:c},backend:n});return n.disposeIntermediateTensorInfo(l),n.disposeIntermediateTensorInfo(c),h}if(n.shouldExecuteOnCPU([r,i])){const e=n.texData.get(r.dataId),t=n.texData.get(i.dataId),[o,s]=multiplyImplCPU(r.shape,i.shape,e.values,t.values,a),l=n.makeTensorInfo(s,a);return n.texData.get(l.dataId).values=o,l}let o;return o=env().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new BinaryOpPackedProgram(MUL,r.shape,i.shape):new BinaryOpProgram(MUL,r.shape,i.shape),n.runWebGLProgram(o,[r,i],a)}const multiplyConfig={kernelName:Multiply,backendName:"webgl",kernelFunc:multiply};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function packedReshape(e,t,n){const r=[getBatchDim(e.shape),...getRowsCols(e.shape)],i={dtype:e.dtype,shape:r,dataId:e.dataId},a=[getBatchDim(t),...getRowsCols(t)],o=new ReshapePackedProgram(a,r),s=n.runWebGLProgram(o,[i],e.dtype,null,!0);return{dataId:s.dataId,shape:t,dtype:s.dtype}}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function reshape(e){const{inputs:t,backend:n,attrs:r}=e,{x:i}=t,{shape:a}=r,o=n,s=sizeFromShape(i.shape),l=inferFromImplicitShape(a,s),c=sizeFromShape(l);assert$1(s===c,(()=>`The new shape (${l}) has ${c} elements and the old shape (${i.shape}) has ${s} elements. The new shape and old shape must have the same number of elements.`));const h=o.texData.get(i.dataId);return!h.isPacked||isReshapeFree(i.shape,l)||null!==h.texture&&isReshapeFree(h.shape,l)?(o.incRef(i.dataId),{dataId:i.dataId,shape:l,dtype:i.dtype}):packedReshape(i,l,o)}const reshapeConfig={kernelName:Reshape,backendName:"webgl",kernelFunc:reshape};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */class MeanProgram{constructor(e,t){this.variableNames=["x"];const{windowSize:n,batchSize:r,inSize:i,outSize:a}=e;this.outputShape=[r,a];const o=4*Math.floor(n/4),s=n%4;let l="sumValue += dot(values, ones);";if(null!=t){const e=1/t;l=`sumValue += dot(values * ${isInt(e)?e.toPrecision(2):e}, ones);`}let c="";i%n>0&&(c=`\n        if (inIdx < 0 || inIdx >= ${i}) {\n          return 0.0;\n        }\n      `),this.userCode=`\n      const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);\n\n      float getValue(int batch, int inIdx) {\n        ${c}\n        return getX(batch, inIdx);\n      }\n\n      void main() {\n        ivec2 coords = getOutputCoords();\n        int batch = coords[0];\n        int outIdx = coords[1];\n        int inOffset = outIdx * ${n};\n\n        float sumValue = 0.0;\n\n        for (int i = 0; i < ${o}; i += 4) {\n          int inIdx = inOffset + i;\n          vec4 values = vec4(\n            getValue(batch, inIdx),\n            getValue(batch, inIdx + 1),\n            getValue(batch, inIdx + 2),\n            getValue(batch, inIdx + 3)\n          );\n\n          ${l}\n        }\n\n        int inIdx = inOffset + ${o};\n        if (${1===s}) {\n          vec4 values = vec4(getValue(batch, inIdx), 0.0, 0.0, 0.0);\n\n          ${l}\n        } else if (${2===s}) {\n          vec4 values = vec4(\n            getValue(batch, inIdx),\n            getValue(batch, inIdx + 1), 0.0, 0.0);\n\n          ${l}\n        } else if (${3===s}) {\n          vec4 values = vec4(\n            getValue(batch, inIdx),\n            getValue(batch, inIdx + 1),\n            getValue(batch, inIdx + 2), 0.0);\n\n          ${l}\n        }\n        setOutput(sumValue);\n      }\n    `}}
/**
     * @license
     * Copyright 2017 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */class ReduceProgram{constructor(e,t){this.variableNames=["x"];const{windowSize:n,batchSize:r,inSize:i,outSize:a}=e;this.outputShape=[r,a];let o="0.0",s="";"prod"===t?o="1.0":"min"===t?(o="1.0 / 1e-20",s="min"):"max"===t&&(o="-1.0 / 1e-20",s="max");let l=`${t}(${t}(${t}(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])`;"sum"===t?l="sumValue":"prod"===t?l="prodValue":"all"===t?l="allValue":"any"===t&&(l="anyValue");const c=4*Math.floor(n/4),h=n%4;let u=`\n      if (${"sum"===t}) {\n        sumValue += dot(values, ones);\n      } else if (${"prod"===t}) {\n        vec2 tmp = vec2(values[0], values[1]) * vec2(values[2], values[3]);\n        prodValue *= tmp[0] * tmp[1];\n      } else {\n        minMaxValue = ${s}(values, minMaxValue);\n      }\n    `,d="vec4";"all"===t?(o="1.0",u="\n        bool reducedAllValue = all(values);\n        float floatedReducedAllValue = float(reducedAllValue);\n        allValue = float(allValue >= 1.0 && floatedReducedAllValue >= 1.0);\n      ",d="bvec4"):"any"===t&&(o="0.0",u="\n        bool reducedAnyValue = any(values);\n        float floatedReducedAnyValue = float(reducedAnyValue);\n        anyValue = float(anyValue >= 1.0 || floatedReducedAnyValue >= 1.0);\n      ",d="bvec4");let p="";i%n>0&&(p=`\n        if (inIdx < 0 || inIdx >= ${i}) {\n          return initializationValue;\n        }\n      `),this.userCode=`\n      const float initializationValue = ${o};\n      const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);\n\n      float getValue(int batch, int inIdx) {\n        ${p}\n        return getX(batch, inIdx);\n      }\n\n      void main() {\n        ivec2 coords = getOutputCoords();\n        int batch = coords[0];\n        int outIdx = coords[1];\n        int inOffset = outIdx * ${n};\n\n        vec4 minMaxValue = vec4(${o});\n        float prodValue = 1.0;\n        float sumValue = 0.0;\n        float allValue = 1.0;\n        float anyValue = 0.0;\n\n        for (int i = 0; i < ${c}; i += 4) {\n          int inIdx = inOffset + i;\n          ${d} values = ${d}(\n            getValue(batch, inIdx),\n            getValue(batch, inIdx + 1),\n            getValue(batch, inIdx + 2),\n            getValue(batch, inIdx + 3)\n          );\n\n          ${u}\n        }\n\n        int inIdx = inOffset + ${c};\n        if (${1===h}) {\n          ${d} values = ${d}(\n            getValue(batch, inIdx),\n            initializationValue,\n            initializationValue,\n            initializationValue\n          );\n\n          ${u}\n        } else if (${2===h}) {\n          ${d} values = ${d}(\n            getValue(batch, inIdx),\n            getValue(batch, inIdx + 1),\n            initializationValue,\n            initializationValue\n          );\n\n          ${u}\n        } else if (${3===h}) {\n          ${d} values = ${d}(\n            getValue(batch, inIdx),\n            getValue(batch, inIdx + 1),\n            getValue(batch, inIdx + 2),\n            initializationValue\n          );\n\n          ${u}\n        }\n        setOutput(${l});\n      }\n    `}}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function getReductionStages(e){const t=[];for(;0===t.length||1!==t[t.length-1].outSize;){const n=t.length?t[t.length-1].outSize:e[1],r=computeOptimalWindowSize(n);t.push({inSize:n,windowSize:r,outSize:Math.ceil(n/r)})}return t}function reduce(e,t,n,r){const i=getReductionStages(e.shape);let a=e;for(let o=0;o<i.length;o++){const{inSize:s,windowSize:l,outSize:c}=i[o];let h,u;h="mean"===n?0===o?new MeanProgram({windowSize:l,inSize:s,batchSize:e.shape[0],outSize:c},s):new MeanProgram({windowSize:l,inSize:s,batchSize:e.shape[0],outSize:c}):new ReduceProgram({windowSize:l,inSize:s,batchSize:e.shape[0],outSize:c},n),u=a,a=r.runWebGLProgram(h,[a],t),u.dataId!==e.dataId&&r.disposeIntermediateTensorInfo(u)}return a}
/**
     * @license
     * Copyright 2017 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */class TransposeProgram{constructor(e,t){this.variableNames=["A"];const n=new Array(e.length);for(let r=0;r<n.length;r++)n[r]=e[t[r]];this.outputShape=n,this.rank=n.length;const r=getCoordsDataType(this.rank),i=getSwitchedCoords(t);this.userCode=`\n    void main() {\n      ${r} resRC = getOutputCoords();\n      setOutput(getA(${i}));\n    }\n    `}}function getSwitchedCoords(e){const t=e.length;if(t>6)throw Error(`Transpose for rank ${t} is not yet supported`);const n=["resRC.x","resRC.y","resRC.z","resRC.w","resRC.u","resRC.v"],r=new Array(t);for(let t=0;t<e.length;t++)r[e[t]]=n[t];return r.join()}
/**
     * @license
     * Copyright 2019 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */class TransposePackedProgram{constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0;const n=new Array(e.length);for(let r=0;r<n.length;r++)n[r]=e[t[r]];if(this.outputShape=n,this.rank=n.length,this.rank>6)throw Error(`Packed transpose for rank ${this.rank} is not yet supported.`);const r=getCoordsDataType(this.rank),i=getVecChannels("rc",this.rank),a=new Array(this.rank);for(let e=0;e<t.length;e++)a[t[e]]=i[e];const o=`vec2(${a.slice(-2).join()})`,s=`++${i[this.rank-1]} < ${n[this.rank-1]}`,l=`getChannel(getA(${a.join()}), ${o})`;this.userCode=`\n    void main() {\n      ${r} rc = getOutputCoords();\n      vec4 result = vec4(0.);\n      result[0] = ${l};\n      if(${s}) {\n        result[1] = ${l};\n      }\n      --${i[this.rank-1]};\n      if(++${i[this.rank-2]} < ${n[this.rank-2]}) {\n        result[2] = ${l};\n        if(${s}) {\n          result[3] = ${l};\n        }\n      }\n      setOutput(result);\n    }\n    `}}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function transposeImpl(e,t,n){const r=env().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new TransposePackedProgram(e.shape,t):new TransposeProgram(e.shape,t);return n.runWebGLProgram(r,[e],e.dtype)}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function sumImpl(e,t,n,r){const i=e.shape.length,a=parseAxisParam(t,e.shape);let o=a;const s=getAxesPermutation(o,i),l=null!=s;let c=e;l&&(c=transposeImpl(e,s,r),o=getInnerMostAxes(o.length,i)),assertAxesAreInnerMostDims("sum",o,i);const[h,u]=computeOutAndReduceShapes(c.shape,o);let d=h;n&&(d=expandShapeToKeepDim(h,a));const p=sizeFromShape(u),m=reshape({inputs:{x:c},attrs:{shape:[sizeFromShape(e.shape)/p,p]},backend:r}),f=reduce(m,sumOutType(e.dtype),"sum",r),g=reshape({inputs:{x:f},attrs:{shape:d},backend:r});return r.disposeIntermediateTensorInfo(m),r.disposeIntermediateTensorInfo(f),l&&r.disposeIntermediateTensorInfo(c),g}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function sum(e){const{inputs:t,backend:n,attrs:r}=e,{x:i}=t,{axis:a,keepDims:o}=r;return sumImpl(i,a,o,n)}const sumConfig={kernelName:Sum,backendName:"webgl",kernelFunc:sum};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function transpose(e){const{inputs:t,backend:n,attrs:r}=e,{x:i}=t,{perm:a}=r,o=n,s=new Array(i.shape.length);for(let e=0;e<s.length;e++)s[e]=i.shape[a[e]];let l;if(o.shouldExecuteOnCPU([i])){const e=o.texData.get(i.dataId),t=transposeImplCPU(e.values,i.shape,i.dtype,a,s);l=o.makeTensorInfo(s,i.dtype);o.texData.get(l.dataId).values=t}else l=transposeImpl(i,a,o);return l}const transposeConfig={kernelName:Transpose,backendName:"webgl",kernelFunc:transpose},MATMUL_SHARED_DIM_THRESHOLD=1e3;
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function batchMatMulImpl({a:e,b:t,transposeA:n,transposeB:r,backend:i,bias:a=null,preluActivationWeights:o=null,leakyreluAlpha:s=0,activation:l=null}){const c=e.shape.length,h=t.shape.length,u=n?e.shape[c-2]:e.shape[c-1],d=r?t.shape[h-1]:t.shape[h-2],p=n?e.shape[c-1]:e.shape[c-2],m=r?t.shape[h-2]:t.shape[h-1],f=e.shape.slice(0,-2),g=t.shape.slice(0,-2),v=sizeFromShape(f),y=sizeFromShape(g);assert$1(c>=2&&h>=2&&(v===y||1===v||1===y),(()=>`Error in matMul: the input batch dimensions must either be the same or at least one input batch dimension must be 1. Got input batch dimensions of (${f}) and (${g}).`));const _=(v>y?e.shape.slice(0,-2):t.shape.slice(0,-2)).concat([p,m]);assert$1(u===d,(()=>`Error in matMul: inner shapes (${u}) and (${d}) of Tensors with shapes ${e.shape} and ${t.shape} and transposeA=${n} and transposeB=${r} must match.`));const b=n?[v,u,p]:[v,p,u],x=r?[y,m,d]:[y,d,m],S=reshape({inputs:{x:e},backend:i,attrs:{shape:b}}),w=reshape({inputs:{x:t},backend:i,attrs:{shape:x}}),C=[S,w],M=Math.max(v,y),E=n?S.shape[1]:S.shape[2],T=null!=a,I=null!=o,A="leakyrelu"===l,k=null!=l?mapActivationToShaderProgram(l,!0):null;let P;if((1===p||1===m)&&E>MATMUL_SHARED_DIM_THRESHOLD&&!1===(T||I||A||null!=k)){let e=S,t=w;n&&(e=transpose({inputs:{x:S},backend:i,attrs:{perm:[0,2,1]}}),C.push(e)),r&&(t=transpose({inputs:{x:w},backend:i,attrs:{perm:[0,2,1]}}),C.push(t));const a=1===m;let o=e;1!==m&&(o=reshape({inputs:{x:e},backend:i,attrs:{shape:[M,E,1]}}),C.push(o));const s=1===m?2:1;let l=t;a&&(l=reshape({inputs:{x:t},backend:i,attrs:{shape:[M,1,E]}}),C.push(l));const c=multiply({inputs:{a:o,b:l},backend:i});P=sum({inputs:{x:c},backend:i,attrs:{axis:s,keepDims:!0}}),C.push(c)}else{const l=upcastType(e.dtype,t.dtype),c=new MatMulPackedProgram(b,x,[M,p,m],n,r,T,k,I,A),h=[S,w];if(null!=a&&h.push(a),I&&h.push(o),A){const e=i.makeTensorInfo([],"float32",createScalarValue(s,"float32"));h.push(e),C.push(e)}P=i.runWebGLProgram(c,h,l)}const R=reshape({inputs:{x:P},backend:i,attrs:{shape:_}});C.push(P);for(const e of C)i.disposeIntermediateTensorInfo(e);return R}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the License);
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an AS IS BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function _fusedMatMul(e){const{inputs:t,backend:n,attrs:r}=e,{a:i,b:a,bias:o,preluActivationWeights:s}=t,{transposeA:l,transposeB:c,activation:h,leakyreluAlpha:u}=r;return batchMatMulImpl({a:i,b:a,transposeA:l,transposeB:c,backend:n,bias:o,preluActivationWeights:s,leakyreluAlpha:u,activation:h})}const _fusedMatMulConfig={kernelName:_FusedMatMul,backendName:"webgl",kernelFunc:_fusedMatMul},ABS="return abs(x);";
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function abs(e){const{inputs:t,backend:n}=e,{x:r}=t;if(n.shouldExecuteOnCPU([r])&&"complex64"!==r.dtype){const e=n.texData.get(r.dataId),t=simpleAbsImplCPU(e.values);return n.makeTensorInfo(r.shape,r.dtype,t)}let i;return i=env().getBool("WEBGL_PACK_UNARY_OPERATIONS")?new UnaryOpPackedProgram(r.shape,ABS):new UnaryOpProgram(r.shape,ABS),n.runWebGLProgram(i,[r],r.dtype)}const absConfig={kernelName:Abs,backendName:"webgl",kernelFunc:abs},ACOS=CHECK_NAN_SNIPPET$2+"\n  if (abs(x) > 1.) {\n    return NAN;\n  }\n  return acos(x);\n",acos=unaryKernelFunc({opSnippet:ACOS}),acosConfig={kernelName:Acos,backendName:"webgl",kernelFunc:acos},ACOSH=CHECK_NAN_SNIPPET$2+"\n  if (x < 1.0) return NAN;\nreturn log(x + sqrt(x * x - 1.0));",acosh=unaryKernelFunc({opSnippet:ACOSH}),acoshConfig={kernelName:Acosh,backendName:"webgl",kernelFunc:acosh},ADD="return a + b;",addKernelFunc=binaryKernelFunc({opSnippet:ADD,packedOpSnippet:ADD,supportsComplex:!0,cpuKernelImpl:addImplCPU}),addConfig={kernelName:Add,backendName:"webgl",kernelFunc:addKernelFunc};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
/**
     * @license
     * Copyright 2019 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
class AddNProgram{constructor(e,t){this.outputShape=[],this.outputShape=e,this.variableNames=t.map(((e,t)=>`T${t}`));const n=[];this.variableNames.forEach((e=>{n.push(`float v${e} = get${e}AtOutCoords();`)}));const r=this.variableNames.map((e=>`v${e}`)).join(" + ");this.userCode=`\n      void main() {\n        ${n.join("\n        ")}\n\n        float result = ${r};\n        setOutput(result);\n      }\n    `}}
/**
     * @license
     * Copyright 2019 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */class AddNPackedProgram{constructor(e,t){this.outputShape=[],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.variableNames=t.map(((e,t)=>`T${t}`));const n=[];this.variableNames.forEach((e=>{n.push(`vec4 v${e} = get${e}AtOutCoords();`)}));const r=this.variableNames.map((e=>`v${e}`)).join(" + ");this.userCode=`\n      void main() {\n        ${n.join("\n        ")}\n\n        vec4 result = ${r};\n        setOutput(result);\n      }\n    `}}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function addN(e){const{inputs:t,backend:n}=e,r=t;if(1===r.length)return identity$2({inputs:{x:r[0]},backend:n});if(r.length>env().get("WEBGL_MAX_TEXTURES_IN_SHADER")){const e=Math.floor(r.length/2),t=addN({inputs:r.slice(0,e),backend:n}),i=addN({inputs:r.slice(e),backend:n});return addN({inputs:[t,i],backend:n})}const i=r.map((e=>e.dtype)).reduce(((e,t)=>upcastType(e,t))),a=r.map((e=>e.shape)),o=env().getBool("WEBGL_PACK")?new AddNPackedProgram(r[0].shape,a):new AddNProgram(r[0].shape,a);return n.runWebGLProgram(o,r,i)}const addNConfig={kernelName:AddN,backendName:"webgl",kernelFunc:addN};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function all(e){const{inputs:t,backend:n,attrs:r}=e,{x:i}=t,{axis:a,keepDims:o}=r,s=i.shape.length,l=parseAxisParam(a,i.shape);let c=l;const h=getAxesPermutation(c,s);let u=i;null!=h&&(u=transpose({inputs:{x:i},backend:n,attrs:{perm:h}}),c=getInnerMostAxes(c.length,s)),assertAxesAreInnerMostDims("all",c,s);const[d,p]=computeOutAndReduceShapes(u.shape,c),m=reshape({inputs:{x:u},backend:n,attrs:{shape:[-1,sizeFromShape(p)]}}),f=reduce(m,m.dtype,"all",n);let g;if(o){g=reshape({inputs:{x:f},backend:n,attrs:{shape:expandShapeToKeepDim(d,l)}})}else g=reshape({inputs:{x:f},backend:n,attrs:{shape:d}});return n.disposeIntermediateTensorInfo(m),n.disposeIntermediateTensorInfo(f),null!=h&&n.disposeIntermediateTensorInfo(u),g}const allConfig={kernelName:All,backendName:"webgl",kernelFunc:all};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function any(e){const{inputs:t,backend:n,attrs:r}=e,{x:i}=t,{axis:a,keepDims:o}=r,s=i.shape.length,l=parseAxisParam(a,i.shape);let c=l;const h=getAxesPermutation(c,s);let u=i;null!=h&&(u=transpose({inputs:{x:i},backend:n,attrs:{perm:h}}),c=getInnerMostAxes(c.length,s)),assertAxesAreInnerMostDims("any",c,s);const[d,p]=computeOutAndReduceShapes(u.shape,c),m=reshape({inputs:{x:u},backend:n,attrs:{shape:[-1,sizeFromShape(p)]}}),f=reduce(m,m.dtype,"any",n);let g;if(o){g=reshape({inputs:{x:f},backend:n,attrs:{shape:expandShapeToKeepDim(d,l)}})}else g=reshape({inputs:{x:f},backend:n,attrs:{shape:d}});return n.disposeIntermediateTensorInfo(m),n.disposeIntermediateTensorInfo(f),null!=h&&n.disposeIntermediateTensorInfo(u),g}const anyConfig={kernelName:Any,backendName:"webgl",kernelFunc:any};
/**
     * @license
     * Copyright 2017 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */class ArgMinMaxProgram{constructor(e,t,n){this.variableNames=["A"];const{windowSize:r,batchSize:i,outSize:a}=e;n||this.variableNames.push("bestIndicesA"),this.outputShape=[i,a];this.userCode=`\n      void main() {\n        ivec2 coords = getOutputCoords();\n        int batch = coords[0];\n        int outIdx = coords[1];\n        int inOffset = outIdx * ${r};\n\n        int bestIndex = inOffset;\n        float bestValue = getA(batch, bestIndex);\n\n        for (int i = 0; i < ${r}; i++) {\n          int inIdx = ${n?"inOffset + i;":"round(getBestIndicesA(batch, inOffset + i));"};\n          float candidate = getA(batch, inIdx);\n          if (candidate ${"max"===t?">":"<"} bestValue) {\n            bestValue = candidate;\n            bestIndex = inIdx;\n          }\n        }\n        setOutput(float(bestIndex));\n      }\n    `}}
/**
     * @license
     * Copyright 2019 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */class ArgMinMaxPackedProgram{constructor(e,t,n,r){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,assert$1(e.length>2,(()=>`Packed arg${n.charAt(0).toUpperCase()+n.slice(1)} supports only inputs with rank above 2.`));const i=Math.ceil(e[e.length-1]/t);this.outputShape=e.slice(0,-1),i>1&&this.outputShape.push(i),r||this.variableNames.push("bestIndicesA");const a=this.outputShape,o=a.length,s=getCoordsDataType(o),l=getChannels("coords",o);let c,h;if(1===i){h=o+1;const e=getCoordsDataType(h);c=`\n        ${e} sourceLocR = ${e}(${l.join()}, 0);\n        ++${l[o-1]};\n        ${e} sourceLocG = ${e}(${l.join()}, 0);\n        ++${l[o-2]};\n        ${e} sourceLocA = ${e}(${l.join()}, 0);\n        --${l[o-1]};\n        ${e} sourceLocB = ${e}(${l.join()}, 0);\n        --${l[o-2]};`}else h=o,c=`\n        ${s} sourceLocR = coords;\n        ++${l[o-1]};\n        ${s} sourceLocG = coords;\n        ++${l[o-2]};\n        ${s} sourceLocA = coords;\n        --${l[o-1]};\n        ${s} sourceLocB = coords;\n        --${l[o-2]};`;const u=["x","y","z","w","u","v"].slice(0,h),d="."+u[h-1],p=u.map((e=>"int "+e)),m=getChannels("sourceLocR",h-1).concat("inIdx.r"),f=getChannels("sourceLocG",h-1).concat("inIdx.g"),g=getChannels("sourceLocB",h-1).concat("inIdx.b"),v=getChannels("sourceLocA",h-1).concat("inIdx.a"),y="max"===n?"greaterThan":"lessThan",_=r?"":`\n          inIdx = round(vec4(getBestIndicesAChannel(${m.join()}),\n                             getBestIndicesAChannel(${f.join()}),\n                             getBestIndicesAChannel(${g.join()}),\n                             getBestIndicesAChannel(${v.join()})));`,b=`vec4(\n            getAChannel(${m.join()}),\n            hasNextCol ? getAChannel(${f.join()}) : 0.,\n            hasNextRow ? getAChannel(${g.join()}) : 0.,\n            hasNextRow && hasNextCol ? getAChannel(${v.join()}) : 0.)`,x=r?"":`\n      float getBestIndicesAChannel(${p.join()}) {\n        return getChannel(getBestIndicesA(${u.join()}),\n                                          vec2(${u.slice(-2).join()}));\n      }`;this.userCode=`\n      float getAChannel(${p.join()}) {\n        return getChannel(getA(${u.join()}),\n                               vec2(${u.slice(-2).join()}));\n      }\n      ${x}\n      void main() {\n        ${s} coords = getOutputCoords();\n        bool hasNextCol = ${l[o-1]} < ${a[o-1]-1};\n        bool hasNextRow = ${l[o-2]} < ${a[o-2]-1};\n        ${c}\n        ivec4 srcIdx = ivec4(sourceLocR${d}, sourceLocG${d},\n          sourceLocB${d}, sourceLocA${d}) * ${t};\n        ivec4 inIdx = srcIdx;\n        vec4 bestIndex = vec4(inIdx);\n        vec4 bestValue = ${b};\n\n        for (int i = 0; i < ${t}; i++) {\n          inIdx = srcIdx;\n          ${_}\n          vec4 candidate = ${b};\n          bvec4 nan = isnan(candidate);\n          bvec4 replace = bvec4(\n            vec4(${y}(candidate, bestValue)) * (vec4(1.0) - vec4(nan)));\n\n          bestValue = vec4(replace.x  ? candidate.x : bestValue.x,\n                           replace.y  ? candidate.y : bestValue.y,\n                           replace.z  ? candidate.z : bestValue.z,\n                           replace.w  ? candidate.w : bestValue.w);\n          bestIndex = mix(bestIndex, vec4(inIdx), vec4(replace));\n          srcIdx++;\n        }\n        setOutput(bestIndex);\n      }\n    `}}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function argReduce(e,t,n,r=null){let i=t.shape[0],a=t.shape[1];null!=r&&(i=r.shape[0],a=r.shape[1]);const o=computeOptimalWindowSize(a),s={windowSize:o,inSize:a,batchSize:i,outSize:Math.ceil(a/o)},l=new ArgMinMaxProgram(s,n,null==r),c=[t];null!=r&&c.push(r);const h=e.runWebGLProgram(l,c,"int32");if(1===h.shape[1])return h;const u=argReduce(e,t,n,h);return e.disposeIntermediateTensorInfo(h),u}function argReducePacked(e,t,n,r=null){const i=null!=r?r.shape:t.shape,a=computeOptimalWindowSize(i[i.length-1]),o=new ArgMinMaxPackedProgram(i,a,n,null==r),s=e.runWebGLProgram(o,null==r?[t]:[t,r],"int32");if(s.shape.length===t.shape.length){const r=argReducePacked(e,t,n,s);return e.disposeIntermediateTensorInfo(s),r}return s}function argMinMaxReduce(e,t,n,r){const i=[n];if(assertAxesAreInnerMostDims("arg"+r.charAt(0).toUpperCase()+r.slice(1),i,t.shape.length),!env().getBool("WEBGL_PACK_REDUCE")||t.shape.length<=2){const n=[],[a,o]=computeOutAndReduceShapes(t.shape,i),s=sizeFromShape(o),l=reshape({inputs:{x:t},backend:e,attrs:{shape:[-1,s]}});n.push(l);const c=argReduce(e,l,r);n.push(c);const h=reshape({inputs:{x:c},backend:e,attrs:{shape:a}});return n.forEach((t=>e.disposeIntermediateTensorInfo(t))),h}return argReducePacked(e,t,r)}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function argMax(e){const{inputs:t,backend:n,attrs:r}=e,{x:i}=t,{axis:a}=r;let o=parseAxisParam(a,i.shape);const s=getAxesPermutation(o,i.shape.length);let l=i;const c=[];null!=s&&(l=transpose({inputs:{x:i},backend:n,attrs:{perm:s}}),c.push(l),o=getInnerMostAxes(o.length,l.shape.length)),assertAxesAreInnerMostDims("argMax",[o[0]],l.shape.length);const h=argMinMaxReduce(n,l,o[0],"max");return c.forEach((e=>n.disposeIntermediateTensorInfo(e))),h}const argMaxConfig={kernelName:ArgMax,backendName:"webgl",kernelFunc:argMax};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function argMin(e){const{inputs:t,backend:n,attrs:r}=e,{x:i}=t,{axis:a}=r;let o=parseAxisParam(a,i.shape);const s=getAxesPermutation(o,i.shape.length);let l=i;const c=[];null!=s&&(l=transpose({inputs:{x:i},backend:n,attrs:{perm:s}}),c.push(l),o=getInnerMostAxes(o.length,l.shape.length)),assertAxesAreInnerMostDims("argMin",[o[0]],l.shape.length);const h=argMinMaxReduce(n,l,o[0],"min");return c.forEach((e=>n.disposeIntermediateTensorInfo(e))),h}const argMinConfig={kernelName:ArgMin,backendName:"webgl",kernelFunc:argMin},ASIN=CHECK_NAN_SNIPPET$2+"\n  if (abs(x) > 1.) {\n    return NAN;\n  }\n  return asin(x);\n",asin=unaryKernelFunc({opSnippet:ASIN}),asinConfig={kernelName:Asin,backendName:"webgl",kernelFunc:asin},ASINH=CHECK_NAN_SNIPPET$2+"return log(x + sqrt(x * x + 1.0));",asinh=unaryKernelFunc({opSnippet:ASINH}),asinhConfig={kernelName:Asinh,backendName:"webgl",kernelFunc:asinh},ATAN=CHECK_NAN_SNIPPET$2+"\n  return atan(x);\n",atan=unaryKernelFunc({opSnippet:ATAN}),atanConfig={kernelName:Atan,backendName:"webgl",kernelFunc:atan},ATAN2=CHECK_NAN_SNIPPET_BINARY+"\n  return atan(a, b);\n",ATAN2_PACKED="\n  vec4 result = atan(a, b);\n  vec4 isNaN = min(vec4(isnan(a)) + vec4(isnan(b)), vec4(1.0));\n  "+CHECK_NAN_SNIPPET_BINARY_PACKED+"\n  return result;\n",atan2=binaryKernelFunc({opSnippet:ATAN2,packedOpSnippet:ATAN2_PACKED}),atan2Config={kernelName:Atan2,backendName:"webgl",kernelFunc:atan2},ATANH=CHECK_NAN_SNIPPET$2+"\n  if ((x < -1.0) || (x > 1.0)) return NAN;\nreturn (log(1.0 + x) - log(1.0 - x)) / 2.0;",atanh=unaryKernelFunc({opSnippet:ATANH}),atanhConfig={kernelName:Atanh,backendName:"webgl",kernelFunc:atanh};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
/**
     * @license
     * Copyright 2017 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
class Pool2DProgram{constructor(e,t,n,r=!1,i=!1){if(this.variableNames=["x"],"avg"===t&&n)throw new Error("Cannot compute positions for average pool.");const a=e.filterWidth,o=e.strideHeight,s=e.strideWidth,l=e.dilationHeight,c=e.dilationWidth,h=e.effectiveFilterHeight,u=e.effectiveFilterWidth,d=e.padInfo.top,p=e.padInfo.left;this.outputShape=e.outShape;const m="avg"===t;let f="0.0";if(m||(f="-1.0 / 1e-20"),n){return void(this.userCode=`\n        const ivec2 strides = ivec2(${o}, ${s});\n        const ivec2 pads = ivec2(${d}, ${p});\n\n        void main() {\n          ivec4 coords = getOutputCoords();\n          int batch = coords[0];\n          int d = coords[3];\n\n          ivec2 xRCCorner = coords.yz * strides - pads;\n          int xRCorner = xRCCorner.x;\n          int xCCorner = xRCCorner.y;\n\n          // max/min x(?, ?, d) to get y(yR, yC, d).\n          // ? = to be determined\n          float minMaxValue = 0.0;\n          float minMaxValueFound = 0.0;\n          int minMaxPosition = 0;\n          float avgValue = 0.0;\n\n          for (int wR = 0; wR < ${h};\n              wR += ${l}) {\n            int xR = xRCorner + wR;\n\n            if (xR < 0 || xR >= ${e.inHeight}) {\n              continue;\n            }\n\n            for (int wC = 0; wC < ${u};\n                wC += ${c}) {\n              int xC = xCCorner + wC;\n\n              if (xC < 0 || xC >= ${e.inWidth}) {\n                continue;\n              }\n\n              float value = getX(batch, xR, xC, d);\n\n              // If a min / max value has already been found, use it. If not,\n              // use the current value.\n              float currMinMaxValue = mix(\n                  value, minMaxValue, minMaxValueFound);\n              if (value ${">="} currMinMaxValue) {\n                minMaxValue = value;\n                minMaxValueFound = 1.0;\n                minMaxPosition = ${r?i?`((batch  * ${e.inHeight} + xR) * ${e.inWidth} + xC) * ${e.inChannels} + d`:`(xR * ${e.inWidth} + xC) * ${e.inChannels} + d`:`wR * ${u} + wC`};\n              }\n            }\n          }\n          setOutput(float(minMaxPosition));\n        }\n      `)}let g=`${t}(${t}(${t}(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])`;"avg"===t&&(g="avgValue / count");const v=4*Math.floor(a/4),y=a%4,_=`\n      if (${m}) {\n        avgValue += dot(values, ones);\n      } else {\n        minMaxValue = max(values, minMaxValue);\n      }\n    `;this.userCode=`\n      const ivec2 strides = ivec2(${o}, ${s});\n      const ivec2 pads = ivec2(${d}, ${p});\n      const float initializationValue = ${f};\n      const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);\n\n      float count = 0.0;\n\n      float getValue(int batch, int xR, int xC, int d) {\n        if (xC < 0 || xC >= ${e.inWidth}) {\n          return initializationValue;\n        }\n        count += 1.0;\n        return getX(batch, xR, xC, d);\n      }\n\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int batch = coords[0];\n        int d = coords[3];\n\n        ivec2 xRCCorner = coords.yz * strides - pads;\n        int xRCorner = xRCCorner.x;\n        int xCCorner = xRCCorner.y;\n\n        // max/min x(?, ?, d) to get y(yR, yC, d).\n        // ? = to be determined\n        vec4 minMaxValue = vec4(${f});\n        float avgValue = 0.0;\n        count = 0.0;\n\n        for (int wR = 0; wR < ${h};\n            wR += ${l}) {\n          int xR = xRCorner + wR;\n\n          if (xR < 0 || xR >= ${e.inHeight}) {\n            continue;\n          }\n\n          for (int wC = 0; wC < ${v}; wC += 4) {\n            int xC = xCCorner + wC * ${c};\n\n            vec4 values = vec4(\n              getValue(batch, xR, xC, d),\n              getValue(batch, xR, xC + ${c}, d),\n              getValue(batch, xR, xC + 2 * ${c}, d),\n              getValue(batch, xR, xC + 3 * ${c}, d)\n            );\n\n            ${_}\n          }\n\n          int xC = xCCorner + ${v};\n          if (${1===y}) {\n            vec4 values = vec4(\n              getValue(batch, xR, xC, d),\n              initializationValue,\n              initializationValue,\n              initializationValue\n            );\n\n            ${_}\n          } else if (${2===y}) {\n            vec4 values = vec4(\n              getValue(batch, xR, xC, d),\n              getValue(batch, xR, xC + ${c}, d),\n              initializationValue,\n              initializationValue\n            );\n\n            ${_}\n          } else if (${3===y}) {\n            vec4 values = vec4(\n              getValue(batch, xR, xC, d),\n              getValue(batch, xR, xC + ${c}, d),\n              getValue(batch, xR, xC + 2 * ${c}, d),\n              initializationValue\n            );\n\n            ${_}\n          }\n        }\n        setOutput(${g});\n      }\n    `}}class Pool3DProgram{constructor(e,t,n,r=!1,i=!1){if(this.variableNames=["x"],"avg"===t&&n)throw new Error("Cannot compute positions for average pool.");const a=e.filterWidth,o=e.strideDepth,s=e.strideHeight,l=e.strideWidth,c=e.dilationDepth,h=e.dilationHeight,u=e.dilationWidth,d=e.effectiveFilterDepth,p=e.effectiveFilterHeight,m=e.effectiveFilterWidth,f=e.padInfo.front,g=e.padInfo.top,v=e.padInfo.left;this.outputShape=e.outShape;const y="avg"===t;let _="0.0";if(y||(_="-1.0 / 1e-20"),n){return void(this.userCode=`\n        const ivec3 strides =\n            ivec3(${o}, ${s}, ${l});\n        const ivec3 pads = ivec3(${f}, ${g}, ${v});\n\n        void main() {\n          ivec5 coords = getOutputCoords();\n          int batch = coords.x;\n          int ch = coords.u;\n\n          ivec3 xCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads;\n          int xDCorner = xCorner.x;\n          int xRCorner = xCorner.y;\n          int xCCorner = xCorner.z;\n\n          // max/min x(?, ?, ?, ch) to get y(yD, yR, yC, ch).\n          // ? = to be determined\n          float minMaxValue = 0.0;\n          float minMaxValueFound = 0.0;\n          int minMaxPosition = 0;\n\n          for (int wD = 0; wD < ${d};\n              wD += ${c}) {\n            int xD = xDCorner + wD;\n\n            if (xD < 0 || xD >= ${e.inDepth}) {\n              continue;\n            }\n\n            for (int wR = 0; wR < ${p};\n                wR += ${h}) {\n              int xR = xRCorner + wR;\n\n              if (xR < 0 || xR >= ${e.inHeight}) {\n                continue;\n              }\n\n              for (int wC = 0; wC < ${m};\n                  wC += ${u}) {\n                int xC = xCCorner + wC;\n\n                if (xC < 0 || xC >= ${e.inWidth}) {\n                  continue;\n                }\n\n                float value = getX(batch, xD, xR, xC, ch);\n\n                // If a min / max value has already been found, use it. If not,\n                // use the current value.\n                float currMinMaxValue = mix(\n                    value, minMaxValue, minMaxValueFound);\n                if (value ${">="} currMinMaxValue) {\n                  minMaxValue = value;\n                  minMaxValueFound = 1.0;\n                  minMaxPosition = ${r?i?`(((batch * ${e.inDepth} + xD) * ${e.inHeight} + xR) * ${e.inWidth} + xC) * ${e.inChannels} + ch`:`((xD * ${e.inHeight} + xR) * ${e.inWidth} + xC) * ${e.inChannels} + ch`:`wD * ${p} * ${m} +\n                      wR * ${m} + wC`};\n                }\n              }\n            }\n          }\n          setOutput(float(minMaxPosition));\n        }\n      `)}let b=`${t}(${t}(${t}(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])`;"avg"===t&&(b="avgValue / count");const x=4*Math.floor(a/4),S=a%4,w=`\n      if (${y}) {\n        avgValue += dot(values, ones);\n      } else {\n        minMaxValue = max(values, minMaxValue);\n      }\n    `;this.userCode=`\n      const ivec3 strides =\n        ivec3(${o}, ${s}, ${l});\n      const ivec3 pads = ivec3(${f}, ${g}, ${v});\n      const float initializationValue = ${_};\n      const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);\n\n      float count = 0.0;\n\n      float getValue(int batch, int xD, int xR, int xC, int ch) {\n        if (xC < 0 || xC >= ${e.inWidth}) {\n          return initializationValue;\n        }\n        count += 1.0;\n        return getX(batch, xD, xR, xC, ch);\n      }\n\n      void main() {\n        ivec5 coords = getOutputCoords();\n        int batch = coords.x;\n        int ch = coords.u;\n\n        ivec3 xCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads;\n        int xDCorner = xCorner.x;\n        int xRCorner = xCorner.y;\n        int xCCorner = xCorner.z;\n\n        // max/min x(?, ?, ?, d) to get y(yD, yR, yC, ch).\n        // ? = to be determined\n        vec4 minMaxValue = vec4(${_});\n        float avgValue = 0.0;\n        count = 0.0;\n\n        for (int wD = 0; wD < ${d};\n            wD += ${c}) {\n          int xD = xDCorner + wD;\n\n          if (xD < 0 || xD >= ${e.inDepth}) {\n            continue;\n          }\n\n          for (int wR = 0; wR < ${p};\n            wR += ${h}) {\n            int xR = xRCorner + wR;\n\n            if (xR < 0 || xR >= ${e.inHeight}) {\n              continue;\n            }\n\n            for (int wC = 0; wC < ${x}; wC += 4) {\n              int xC = xCCorner + wC * ${u};\n\n              vec4 values = vec4(\n                getValue(batch, xD, xR, xC, ch),\n                getValue(batch, xD, xR, xC + ${u}, ch),\n                getValue(batch, xD, xR, xC + 2 * ${u}, ch),\n                getValue(batch, xD, xR, xC + 3 * ${u}, ch)\n              );\n\n              ${w}\n            }\n\n            int xC = xCCorner + ${x};\n            if (${1===S}) {\n              vec4 values = vec4(\n                getValue(batch, xD, xR, xC, ch),\n                initializationValue,\n                initializationValue,\n                initializationValue\n              );\n\n              ${w}\n            } else if (${2===S}) {\n              vec4 values = vec4(\n                getValue(batch, xD, xR, xC, ch),\n                getValue(batch, xD, xR, xC + ${u}, ch),\n                initializationValue,\n                initializationValue\n              );\n\n              ${w}\n            } else if (${3===S}) {\n              vec4 values = vec4(\n                getValue(batch, xD, xR, xC, ch),\n                getValue(batch, xD, xR, xC + ${u}, ch),\n                getValue(batch, xD, xR, xC + 2 * ${u}, ch),\n                initializationValue\n              );\n\n              ${w}\n            }\n          }\n          setOutput(${b});\n        }\n      }\n    `}}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function avgPool(e){const{inputs:t,backend:n,attrs:r}=e,{x:i}=t;assertNotComplex(i,"avgPool");const{filterSize:a,strides:o,pad:s,dimRoundingMode:l}=r;assert$1(eitherStridesOrDilationsAreOne(o,1),(()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${o} and dilations '1'`));const c=computePool2DInfo(i.shape,a,o,1,s,l);if(1===c.filterWidth&&1===c.filterHeight&&arraysEqual$1(c.inShape,c.outShape))return identity$2({inputs:{x:i},backend:n});const h=new Pool2DProgram(c,"avg",!1);return n.runWebGLProgram(h,[i],"float32")}const avgPoolConfig={kernelName:AvgPool,backendName:"webgl",kernelFunc:avgPool};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function avgPool3D(e){const{inputs:t,backend:n,attrs:r}=e,{x:i}=t,{filterSize:a,strides:o,pad:s,dimRoundingMode:l,dataFormat:c}=r,h=computePool3DInfo(i.shape,a,o,[1,1,1],s,l,c),u=new Pool3DProgram(h,"avg",!1);return n.runWebGLProgram(u,[i],"float32")}const avgPool3DConfig={kernelName:AvgPool3D,backendName:"webgl",kernelFunc:avgPool3D};
/**
     * @license
     * Copyright 2017 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */class AvgPool2DBackpropProgram{constructor(e){this.variableNames=["dy"],this.outputShape=e.inShape;const t=e.effectiveFilterHeight,n=e.effectiveFilterWidth;this.userCode=`\n      const ivec2 pads = ivec2(${t-1-e.padInfo.top}, ${n-1-e.padInfo.left});\n      const float avgMultiplier = float(${1/(e.filterHeight*e.filterWidth)});\n\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int b = coords[0];\n        int d = coords[3];\n\n        ivec2 dyRCCorner = coords.yz - pads;\n        int dyRCorner = dyRCCorner.x;\n        int dyCCorner = dyRCCorner.y;\n\n        // Convolve dy(?, ?, d) with pos mask(:, :, d) to get dx(xR, xC, d).\n        // ? = to be determined. : = across all values in that axis.\n        float dotProd = 0.0;\n        for (int wR = 0; wR < ${t};\n            wR += ${e.dilationHeight}) {\n          float dyR = float(dyRCorner + wR) / ${e.strideHeight}.0;\n\n          if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) {\n            continue;\n          }\n          int idyR = int(dyR);\n\n          for (int wC = 0; wC < ${n};\n            wC+= ${e.dilationWidth}) {\n            float dyC = float(dyCCorner + wC) / ${e.strideWidth}.0;\n\n            if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||\n                fract(dyC) > 0.0) {\n              continue;\n            }\n            int idyC = int(dyC);\n\n            float dyValue = getDy(b, idyR, idyC, d);\n\n            dotProd += dyValue * avgMultiplier;\n          }\n        }\n        setOutput(dotProd);\n      }\n    `}}class AvgPool3DBackpropProgram{constructor(e){this.variableNames=["dy"],this.outputShape=e.inShape;const t=e.effectiveFilterDepth,n=e.effectiveFilterHeight,r=e.effectiveFilterWidth;this.userCode=`\n      const ivec3 pads = ivec3(${t-1-e.padInfo.front}, ${n-1-e.padInfo.top}, ${r-1-e.padInfo.left});\n      const float avgMultiplier = float(${1/(e.filterDepth*e.filterHeight*e.filterWidth)});\n\n      void main() {\n        ivec5 coords = getOutputCoords();\n        int batch = coords.x;\n        int ch = coords.u;\n\n        ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads;\n        int dyDCorner = dyCorner.x;\n        int dyRCorner = dyCorner.y;\n        int dyCCorner = dyCorner.z;\n\n        // Convolve dy(?, ?, ?, d) with pos mask(:, :, :, ch) to get\n        // dx(xD, xR, xC, ch).\n        // ? = to be determined. : = across all values in that axis.\n        float dotProd = 0.0;\n\n        for (int wD = 0; wD < ${t};\n            wD += ${e.dilationDepth}) {\n          float dyD = float(dyDCorner + wD) / ${e.strideDepth}.0;\n\n          if (dyD < 0.0 || dyD >= ${e.outDepth}.0 || fract(dyD) > 0.0) {\n            continue;\n          }\n          int idyD = int(dyD);\n\n          for (int wR = 0; wR < ${n};\n              wR += ${e.dilationHeight}) {\n            float dyR = float(dyRCorner + wR) / ${e.strideHeight}.0;\n\n            if (dyR < 0.0 || dyR >= ${e.outHeight}.0 ||\n                fract(dyR) > 0.0) {\n              continue;\n            }\n            int idyR = int(dyR);\n\n            for (int wC = 0; wC < ${r};\n                wC += ${e.dilationWidth}) {\n              float dyC = float(dyCCorner + wC) / ${e.strideWidth}.0;\n\n              if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||\n                  fract(dyC) > 0.0) {\n                continue;\n              }\n              int idyC = int(dyC);\n\n              float dyValue = getDy(batch, idyD, idyR, idyC, ch);\n\n              dotProd += dyValue * avgMultiplier;\n            }\n          }\n        }\n        setOutput(dotProd);\n      }\n    `}}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function avgPool3DGrad(e){const{inputs:t,backend:n,attrs:r}=e,{dy:i,input:a}=t,o=a,{filterSize:s,strides:l,pad:c,dimRoundingMode:h}=r,u=computePool3DInfo(o.shape,s,l,[1,1,1],c,h),d=new AvgPool3DBackpropProgram(u);return n.runWebGLProgram(d,[i],o.dtype)}const avgPoolGrad3DConfig={kernelName:AvgPool3DGrad,backendName:"webgl",kernelFunc:avgPool3DGrad};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function avgPoolGrad(e){const{inputs:t,backend:n,attrs:r}=e,{dy:i,input:a}=t,o=a;assertNotComplex([i,a],"avgPoolGrad");const{filterSize:s,strides:l,pad:c}=r,h=computePool2DInfo(o.shape,s,l,1,c),u=new AvgPool2DBackpropProgram(h);return n.runWebGLProgram(u,[i],o.dtype)}const avgPoolGradConfig={kernelName:AvgPoolGrad,backendName:"webgl",kernelFunc:avgPoolGrad};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function batchMatMul(e){const{inputs:t,backend:n,attrs:r}=e,{a:i,b:a}=t,{transposeA:o,transposeB:s}=r;return batchMatMulImpl({a:i,b:a,transposeA:o,transposeB:s,backend:n})}const batchMatMulConfig={kernelName:BatchMatMul,backendName:"webgl",kernelFunc:batchMatMul};
/**
     * @license
     * Copyright 2017 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */class BatchNormProgram{constructor(e,t,n,r,i,a){this.outputShape=[],this.variableNames=["x","mean","variance"],assertAndGetBroadcastShape(e,t),assertAndGetBroadcastShape(e,n);let o="0.0";null!=r&&(assertAndGetBroadcastShape(e,r),this.variableNames.push("offset"),o="getOffsetAtOutCoords()");let s="1.0";null!=i&&(assertAndGetBroadcastShape(e,i),this.variableNames.push("scale"),s="getScaleAtOutCoords()"),this.outputShape=e,this.userCode=`\n      void main() {\n        float x = getXAtOutCoords();\n        float mean = getMeanAtOutCoords();\n        float variance = getVarianceAtOutCoords();\n        float offset = ${o};\n        float scale = ${s};\n        float inv = scale * inversesqrt(variance + float(${a}));\n        setOutput(dot(vec3(x, -mean, offset), vec3(inv, inv, 1)));\n      }\n    `}}
/**
     * @license
     * Copyright 2018 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */class BatchNormPackedProgram{constructor(e,t,n,r,i,a){this.packedInputs=!0,this.packedOutput=!0,this.variableNames=["x","mean","variance"],assertAndGetBroadcastShape(e,t),assertAndGetBroadcastShape(e,n);let o="vec4(0.0)";null!=r&&(assertAndGetBroadcastShape(e,r),this.variableNames.push("offset"),o="getOffsetAtOutCoords()");let s="vec4(1.0)";null!=i&&(assertAndGetBroadcastShape(e,i),this.variableNames.push("scale"),s="getScaleAtOutCoords()"),this.outputShape=e,this.userCode=`\n      void main() {\n        vec4 offset = ${o};\n        vec4 scale = ${s};\n\n        vec4 x = getXAtOutCoords();\n        vec4 mean = getMeanAtOutCoords();\n        vec4 variance = getVarianceAtOutCoords();\n\n        vec4 inv = scale * inversesqrt(variance + vec4(${a}));\n\n        setOutput((x - mean) * inv + offset);\n      }\n    `}}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */const batchNorm=({inputs:e,backend:t,attrs:n})=>{const{x:r,mean:i,variance:a,offset:o,scale:s}=e;assert$1(i.shape.length===a.shape.length,(()=>"Batch normalization gradient requires mean and variance to have equal ranks.")),assert$1(null==o||i.shape.length===o.shape.length,(()=>"Batch normalization gradient requires mean and offset to have equal ranks.")),assert$1(null==s||i.shape.length===s.shape.length,(()=>"Batch normalization gradient requires mean and scale to have equal ranks."));let{varianceEpsilon:l}=n;null==l&&(l=.001);const c=[r,i,a];let h=null;null!=o&&(h=o.shape,c.push(o));let u=null;null!=s&&(u=s.shape,c.push(s));const d=env().getBool("WEBGL_PACK_NORMALIZATION")?new BatchNormPackedProgram(r.shape,i.shape,a.shape,h,u,l):new BatchNormProgram(r.shape,i.shape,a.shape,h,u,l);return t.runWebGLProgram(d,c,c[0].dtype)},batchNormConfig={kernelName:FusedBatchNorm,backendName:"webgl",kernelFunc:batchNorm};
/**
     * @license
     * Copyright 2017 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
class SliceProgram{constructor(e){this.variableNames=["source"],this.outputShape=e,this.rank=e.length;const t=getCoordsDataType(this.rank),n=`uniform int start[${this.rank}];`,r=getCoords$1(this.rank);let i;i=`\n        ${t} sourceLoc;\n        ${t} coords = getOutputCoords();\n        ${e.map(((e,t)=>`sourceLoc.${coords[t]} = start[${t}] + coords.${coords[t]};`)).join("\n")}\n      `,this.userCode=`\n      ${n}\n      void main() {\n        ${i}\n        setOutput(getSource(${r}));\n      }\n    `}getCustomSetupFunc(e){if(e.length!==this.rank)throw Error(`The rank (${this.rank}) of the program must match the length of start (${e.length})`);return(t,n)=>{null==this.startLoc&&(this.startLoc=t.getUniformLocationNoThrow(n,"start"),null==this.startLoc)||t.gl.uniform1iv(this.startLoc,e)}}}const coords=["x","y","z","w","u","v"];function getCoords$1(e){if(1===e)return"sourceLoc";if(e<=6)return coords.slice(0,e).map((e=>"sourceLoc."+e)).join(",");throw Error(`Slicing for rank ${e} is not yet supported`)}
/**
     * @license
     * Copyright 2019 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */class SlicePackedProgram{constructor(e){this.variableNames=["source"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.rank=e.length;const t=getCoordsDataType(this.rank),n=getChannels("coords",this.rank),r=getChannels("sourceLoc",this.rank),i=1===this.rank?"sourceLoc":`vec2(${r.slice(-2).join()})`,a=`getChannel(getSource(${r.join()}), ${i})`,o=`\n      result.x = ${a};\n      if (++${n[this.rank-1]} < ${e[this.rank-1]}) {\n        ++${r[this.rank-1]};\n        result.y = ${a};\n        --${r[this.rank-1]};\n      }\n    `,s=1===this.rank?"":`\n      --${n[this.rank-1]};\n      if (++${n[this.rank-2]} < ${e[this.rank-2]}) {\n        ++${r[this.rank-2]};\n        result.z = ${a};\n        if (++${n[this.rank-1]} < ${e[this.rank-1]}) {\n          ++${r[this.rank-1]};\n          result.w = ${a};\n        }\n      }\n    `,l=this.rank<=4?`sourceLoc = coords +\n            ${t}(${e.map(((e,t)=>`start[${t}]`)).join()});`:e.map(((e,t)=>`${r[t]} = ${n[t]} + start[${t}];`)).join("\n");this.userCode=`\n      uniform int start[${this.rank}];\n      void main() {\n        ${t} coords = getOutputCoords();\n        ${t} sourceLoc;\n        ${l}\n        vec4 result = vec4(0.);\n        ${o}\n        ${s}\n        setOutput(result);\n      }\n    `}getCustomSetupFunc(e){if(e.length!==this.rank)throw Error(`The rank (${this.rank}) of the program must match the length of start (${e.length})`);return(t,n)=>{null==this.startLoc&&(this.startLoc=t.getUniformLocationNoThrow(n,"start"),null==this.startLoc)||t.gl.uniform1iv(this.startLoc,e)}}}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function shallowSlice(e,t,n,r){const i=r.texData.get(e.dataId),a=r.makeTensorInfo(n,e.dtype),o=r.texData.get(a.dataId);Object.assign(o,i),o.refCount=1,o.shape=n,o.dtype=e.dtype;let s=computeFlatOffset(t,computeStrides(e.shape));i.slice&&(s+=i.slice.flatOffset),o.slice={flatOffset:s,origDataId:i.slice&&i.slice.origDataId||e.dataId};const l=r.dataRefCount.get(o.slice.origDataId)||1;return r.dataRefCount.set(o.slice.origDataId,l+1),a}function slice$1(e){const{inputs:t,backend:n,attrs:r}=e,{x:i}=t,{begin:a,size:o}=r,[s,l]=parseSliceParams(i,a,o);if(assertParamsValid(i,s,l),0===sizeFromShape(l))return n.makeTensorInfo(l,i.dtype,[]);if(n.shouldExecuteOnCPU([i])||"string"===i.dtype){const e=n.texData.get(i.dataId),t=sliceImplCPU(e.values,s,l,i.shape,i.dtype);return n.makeTensorInfo(l,i.dtype,t)}const{isPacked:c}=n.texData.get(i.dataId),h=isSliceContinous(i.shape,s,l);if(c||!h){const e=env().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new SlicePackedProgram(l):new SliceProgram(l),t=e.getCustomSetupFunc(s);return n.runWebGLProgram(e,[i],i.dtype,t)}return n.uploadToGPU(i.dataId),shallowSlice(i,s,l,n)}const sliceConfig={kernelName:Slice,backendName:"webgl",kernelFunc:slice$1},batchToSpaceND=e=>{const{inputs:t,backend:n,attrs:r}=e,{x:i}=t,{blockShape:a,crops:o}=r;assert$1(i.shape.length<=4,(()=>"batchToSpaceND for rank > 4 with a WebGL backend not implemented yet"));const s=a.reduce(((e,t)=>e*t)),l=getReshaped(i.shape,a,s),c=getPermuted(l.length,a.length),h=getReshapedPermuted(i.shape,a,s),u=getSliceBeginCoords(o,a.length),d=getSliceSize(h,o,a.length),p=[],m=reshape({inputs:{x:i},backend:n,attrs:{shape:l}}),f=transpose({inputs:{x:m},backend:n,attrs:{perm:c}}),g=reshape({inputs:{x:f},backend:n,attrs:{shape:h}}),v=slice$1({inputs:{x:g},backend:n,attrs:{begin:u,size:d}});return p.push(m),p.push(f),p.push(g),p.forEach((e=>n.disposeIntermediateTensorInfo(e))),v},batchToSpaceNDConfig={kernelName:BatchToSpaceND,backendName:"webgl",kernelFunc:batchToSpaceND};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
function bincount(e){const{inputs:t,backend:n,attrs:r}=e,{x:i,weights:a}=t,{size:o}=r,s=n.readSync(i.dataId),l=n.readSync(a.dataId),c=bincountImplCPU(s,l,a.dtype,a.shape,o);return n.makeTensorInfo([o],a.dtype,c)}const bincountConfig={kernelName:Bincount,backendName:"webgl",kernelFunc:bincount},NOT_EQUAL="return float(a != b);",notEqual=binaryKernelFunc({opSnippet:NOT_EQUAL,dtype:"bool"}),notEqualConfig={kernelName:NotEqual,backendName:"webgl",kernelFunc:notEqual};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
function real(e){const{inputs:t,backend:n}=e,{input:r}=t;return identity$2({inputs:{x:n.texData.get(r.dataId).complexTensorInfos.real},backend:n})}const realConfig={kernelName:Real,backendName:"webgl",kernelFunc:real},TO_INT="return float(int(x));";
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function int(e,t){const n=new UnaryOpProgram(e.shape,TO_INT),r=t.runWebGLProgram(n,[e],"int32");return{dataId:r.dataId,shape:r.shape,dtype:r.dtype}}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function cast(e){const{inputs:t,backend:n,attrs:r}=e,{x:i}=t,{dtype:a}=r;if("complex64"===a){if("complex64"===i.dtype)return identity$2({inputs:{x:i},backend:n});const e=zeros$1(i.shape),t=cast({inputs:{x:i},backend:n,attrs:{dtype:"float32"}}),r=complex({inputs:{real:t,imag:e},backend:n});return e.dispose(),n.disposeIntermediateTensorInfo(t),r}if("complex64"===i.dtype){const e=real({inputs:{input:i},backend:n}),t=cast({inputs:{x:e},backend:n,attrs:{dtype:a}});return n.disposeIntermediateTensorInfo(e),t}if(!hasEncodingLoss(i.dtype,a)){const e=identity$2({inputs:{x:i},backend:n});return{dataId:e.dataId,shape:e.shape,dtype:a}}if("int32"===a)return int(i,n);if("bool"===a){const e=n.makeTensorInfo([],"bool",getTypedArrayFromDType("bool",1)),t=notEqual({inputs:{a:i,b:e},backend:n});return n.disposeIntermediateTensorInfo(e),t}throw new Error(`Error in Cast: failed to cast ${i.dtype} to ${a}`)}const castConfig={kernelName:Cast,backendName:"webgl",kernelFunc:cast},CEIL="return ceil(x);",ceil=unaryKernelFunc({opSnippet:CEIL,packedOpSnippet:CEIL,cpuKernelImpl:ceilImplCPU}),ceilConfig={kernelName:Ceil,backendName:"webgl",kernelFunc:ceil};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
/**
     * @license
     * Copyright 2017 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
class ClipProgram{constructor(e){this.variableNames=["A"],this.outputShape=e,this.userCode="\n      uniform float minVal;\n      uniform float maxVal;\n\n      void main() {\n        float value = getAAtOutCoords();\n        if (isnan(value)) {\n          setOutput(value);\n          return;\n        }\n\n        setOutput(clamp(value, minVal, maxVal));\n      }\n    "}getCustomSetupFunc(e,t){return(n,r)=>{null==this.minLoc&&(this.minLoc=n.getUniformLocationNoThrow(r,"minVal"),this.maxLoc=n.getUniformLocationNoThrow(r,"maxVal")),n.gl.uniform1f(this.minLoc,e),n.gl.uniform1f(this.maxLoc,t)}}}
/**
     * @license
     * Copyright 2018 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */class ClipPackedProgram{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.userCode="\n      uniform float minVal;\n      uniform float maxVal;\n\n      void main() {\n        vec4 value = getAAtOutCoords();\n\n        if (any(isnan(value))) {\n          setOutput(value);\n          return;\n        }\n\n        setOutput(clamp(value, vec4(minVal), vec4(maxVal)));\n      }\n    "}getCustomSetupFunc(e,t){return(n,r)=>{null==this.minLoc&&(this.minLoc=n.getUniformLocationNoThrow(r,"minVal"),this.maxLoc=n.getUniformLocationNoThrow(r,"maxVal")),n.gl.uniform1f(this.minLoc,e),n.gl.uniform1f(this.maxLoc,t)}}}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function clipByValue(e){const{inputs:t,backend:n,attrs:r}=e,{x:i}=t,{clipValueMin:a,clipValueMax:o}=r;let s;s=env().getBool("WEBGL_PACK_CLIP")?new ClipPackedProgram(i.shape):new ClipProgram(i.shape);const l=s.getCustomSetupFunc(a,o);return n.runWebGLProgram(s,[i],i.dtype,l)}const clipByValueConfig={kernelName:ClipByValue,backendName:"webgl",kernelFunc:clipByValue};
/**
     * @license
     * Copyright 2018 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */class ComplexAbsProgram{constructor(e){this.variableNames=["real","imag"],this.outputShape=e,this.userCode="\n      void main() {\n        float re = abs(getRealAtOutCoords());\n        float im = abs(getImagAtOutCoords());\n        float mx = max(re, im);\n\n        // sadly the length function in glsl is not underflow-safe\n        // (at least not on Intel GPUs). So the safe solution is\n        // to ensure underflow-safety in all cases.\n        setOutput(\n          mx == 0.0 ? 0.0 : mx * length(vec2(1, min(re, im)/mx))\n        );\n      }\n    "}}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function makeComplexComponentTensorInfo(e,t){return{dataId:t.dataId,dtype:t.dtype,shape:e.shape}}function complexAbs(e){const{inputs:t,backend:n}=e,{x:r}=t,i=n.texData.get(r.dataId),a=new ComplexAbsProgram(r.shape),o=[makeComplexComponentTensorInfo(r,i.complexTensorInfos.real),makeComplexComponentTensorInfo(r,i.complexTensorInfos.imag)];return n.runWebGLProgram(a,o,o[0].dtype)}const complexAbsConfig={kernelName:ComplexAbs,backendName:"webgl",kernelFunc:complexAbs};
/**
     * @license
     * Copyright 2017 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */class ConcatProgram{constructor(e){this.outputShape=[],this.outputShape=computeOutShape$1(e,1),this.variableNames=e.map(((e,t)=>`T${t}`));const t=new Array(e.length-1);t[0]=e[0][1];for(let n=1;n<t.length;n++)t[n]=t[n-1]+e[n][1];const n=[`if (yC < ${t[0]}) setOutput(getT0(yR, yC));`];for(let e=1;e<t.length;e++){n.push(`else if (yC < ${t[e]}) setOutput(getT${e}(yR, yC-${t[e-1]}));`)}n.push(`else setOutput(getT${t.length}(yR, yC-${t[t.length-1]}));`),this.userCode=`\n      void main() {\n        ivec2 coords = getOutputCoords();\n        int yR = coords.x;\n        int yC = coords.y;\n\n        ${n.join("\n        ")}\n      }\n    `}}
/**
     * @license
     * Copyright 2019 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */class ConcatPackedProgram{constructor(e,t){this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[],this.outputShape=computeOutShape$1(e,t);const n=this.outputShape,r=n.length,i=getCoordsDataType(r),a=getChannels("coords",r),o=["x","y","z","w","u","v"].slice(0,r);this.variableNames=e.map(((e,t)=>`T${t}`));const s=new Array(e.length-1);s[0]=e[0][t];for(let n=1;n<s.length;n++)s[n]=s[n-1]+e[n][t];const l=o[t],c=o.slice(-2),h=o.join();let u=`if (${l} < ${s[0]}) {\n        return getChannel(\n            getT0(${h}), vec2(${c.join()}));\n        }`;for(let e=1;e<s.length;e++){const t=s[e-1];u+=`\n        if (${l} < ${s[e]}  && ${l} >= ${s[e-1]}) {\n          return getChannel(\n            getT${e}(${shiftedChannels(o,l,t)}),\n            vec2(${shiftedChannels(c,l,t)}));\n        }`}const d=s[s.length-1];u+=`\n        return getChannel(\n          getT${s.length}(${shiftedChannels(o,l,d)}),\n          vec2(${shiftedChannels(c,l,d)}));`,this.userCode=`\n      float getValue(${o.map((e=>"int "+e))}) {\n        ${u}\n      }\n\n      void main() {\n        ${i} coords = getOutputCoords();\n        vec4 result = vec4(getValue(${a}), 0., 0., 0.);\n\n        ${a[r-1]} = ${a[r-1]} + 1;\n        if (${a[r-1]} < ${n[r-1]}) {\n          result.g = getValue(${a});\n        }\n\n        ${a[r-2]} = ${a[r-2]} + 1;\n        if (${a[r-2]} < ${n[r-2]}) {\n          result.a = getValue(${a});\n        }\n\n        ${a[r-1]} = ${a[r-1]} - 1;\n        if (${a[r-2]} < ${n[r-2]} &&\n            ${a[r-1]} < ${n[r-1]}) {\n          result.b = getValue(${a});\n        }\n        setOutput(result);\n      }\n    `}}function shiftedChannels(e,t,n){const r=e.indexOf(t);return e.map(((e,t)=>t===r?`${e} - ${n}`:e)).join()}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function imag(e){const{inputs:t,backend:n}=e,{input:r}=t;return identity$2({inputs:{x:n.texData.get(r.dataId).complexTensorInfos.imag},backend:n})}const imagConfig={kernelName:Imag,backendName:"webgl",kernelFunc:imag};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function concatImpl(e,t,n){const r=e[0].dtype;if("complex64"===r){const r=e.map((e=>real({inputs:{input:e},backend:n}))),i=e.map((e=>imag({inputs:{input:e},backend:n}))),a=concatImpl(r,t,n),o=concatImpl(i,t,n),s=complex({inputs:{real:a,imag:o},backend:n});return r.forEach((e=>n.disposeIntermediateTensorInfo(e))),i.forEach((e=>n.disposeIntermediateTensorInfo(e))),n.disposeIntermediateTensorInfo(a),n.disposeIntermediateTensorInfo(o),s}if("string"===r){const{tensors2D:i,outShape:a}=computeTensors2D(e,t,n),o=i.map((e=>({vals:n.readSync(e.dataId),shape:e.shape}))),s=concatImplCPU(o,a,r,1===i[0].shape[0]),l=computeOutShape$1(e.map((e=>e.shape)),t),c=n.makeTensorInfo(l,r,s);return i.forEach((e=>n.disposeIntermediateTensorInfo(e))),c}if(e.length>env().getNumber("WEBGL_MAX_TEXTURES_IN_SHADER")){const r=Math.floor(e.length/2),i=concatImpl(e.slice(0,r),t,n),a=concatImpl(e.slice(r),t,n),o=concatImpl([i,a],t,n);return n.disposeIntermediateTensorInfo(i),n.disposeIntermediateTensorInfo(a),o}if(env().getBool("WEBGL_PACK_ARRAY_OPERATIONS")&&e[0].shape.length>1){const i=new ConcatPackedProgram(e.map((e=>e.shape)),t);return n.runWebGLProgram(i,e,r)}const{tensors2D:i,outShape:a}=computeTensors2D(e,t,n),o=new ConcatProgram(i.map((e=>e.shape))),s=n.runWebGLProgram(o,i,r);i.forEach((e=>n.disposeIntermediateTensorInfo(e)));const l=reshape({inputs:{x:s},attrs:{shape:a},backend:n});return n.disposeIntermediateTensorInfo(s),l}function computeTensors2D(e,t,n){const r=computeOutShape$1(e.map((e=>e.shape)),t);return{tensors2D:e.map((e=>reshape({inputs:{x:e},attrs:{shape:[-1,sizeFromShape(e.shape.slice(t))]},backend:n}))),outShape:r}}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function concat(e){const{inputs:t,backend:n,attrs:r}=e,{axis:i}=r,a=parseAxisParam(i,t[0].shape)[0],o=computeOutShape$1(t.map((e=>e.shape)),a);if(0===sizeFromShape(o))return n.makeTensorInfo(o,t[0].dtype,[]);const s=t.filter((e=>sizeFromShape(e.shape)>0));if(1===s.length)return identity$2({inputs:{x:s[0]},backend:n});return assertParamsConsistent(s.map((e=>e.shape)),a),concatImpl(s,a,n)}const concatConfig={kernelName:Concat,backendName:"webgl",kernelFunc:concat};
/**
     * @license
     * Copyright 2017 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */class Conv2DProgram{constructor(e,t=!1,n=null,r=!1,i=!1){this.variableNames=["x","W"],this.outputShape=e.outShape;const a=e.padInfo.top,o=e.padInfo.left,s=e.strideHeight,l=e.strideWidth,c=e.dilationHeight,h=e.dilationWidth,u=e.filterHeight,d=e.filterWidth,p=4*Math.floor(e.inChannels/4),m=e.inChannels%4,f="channelsLast"===e.dataFormat,g=f?1:2,v=f?2:3,y=f?3:1;let _="",b="";n&&(_=r?`float activation(float a) {\n          float b = getPreluActivationWeightsAtOutCoords();\n          ${n}\n        }`:i?`float activation(float a) {\n          float b = getLeakyreluAlphaAtOutCoords();\n          ${n}\n        }`:`\n          float activation(float x) {\n            ${n}\n          }\n        `,b="result = activation(result);");const x=t?"result += getBiasAtOutCoords();":"";t&&this.variableNames.push("bias"),r&&this.variableNames.push("preluActivationWeights"),i&&this.variableNames.push("leakyreluAlpha"),this.userCode=`\n      ${_}\n\n      const ivec2 strides = ivec2(${s}, ${l});\n      const ivec2 pads = ivec2(${a}, ${o});\n\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int batch = coords[0];\n        int d2 = coords[${y}];\n\n        ivec2 xRCCorner =\n            ivec2(coords[${g}], coords[${v}]) * strides - pads;\n        int xRCorner = xRCCorner.x;\n        int xCCorner = xRCCorner.y;\n\n        // Convolve x(?, ?, d1) with w(:, :, d1, d2) to get y(yR, yC, d2).\n        // ? = to be determined. : = across all values in that axis.\n        float dotProd = 0.0;\n        for (int wR = 0; wR < ${u}; wR++) {\n          int xR = xRCorner + wR * ${c};\n\n          if (xR < 0 || xR >= ${e.inHeight}) {\n            continue;\n          }\n\n          for (int wC = 0; wC < ${d}; wC++) {\n            int xC = xCCorner + wC * ${h};\n\n            if (xC < 0 || xC >= ${e.inWidth}) {\n              continue;\n            }\n\n            for (int d1 = 0; d1 < ${p}; d1 += 4) {\n              vec4 wValues = vec4(\n                getW(wR, wC, d1, d2),\n                getW(wR, wC, d1 + 1, d2),\n                getW(wR, wC, d1 + 2, d2),\n                getW(wR, wC, d1 + 3, d2)\n              );\n\n              if (${f}) {\n                vec4 xValues = vec4(\n                  getX(batch, xR, xC, d1),\n                  getX(batch, xR, xC, d1 + 1),\n                  getX(batch, xR, xC, d1 + 2),\n                  getX(batch, xR, xC, d1 + 3)\n                );\n                dotProd += dot(xValues, wValues);\n              } else {\n                vec4 xValues = vec4(\n                  getX(batch, d1, xR, xC),\n                  getX(batch, d1 + 1, xR, xC),\n                  getX(batch, d1 + 2, xR, xC),\n                  getX(batch, d1 + 3, xR, xC)\n                );\n                dotProd += dot(xValues, wValues);\n              }\n            }\n\n            if (${1===m}) {\n\n              if (${f}) {\n                dotProd +=\n                    getX(batch, xR, xC, ${p}) *\n                    getW(wR, wC, ${p}, d2);\n              } else {\n                dotProd +=\n                    getX(batch, ${p}, xR, xC) *\n                    getW(wR, wC, ${p}, d2);\n              }\n\n            } else if (${2===m}) {\n              vec2 wValues = vec2(\n                getW(wR, wC, ${p}, d2),\n                getW(wR, wC, ${p} + 1, d2)\n              );\n\n              if (${f}) {\n                vec2 xValues = vec2(\n                  getX(batch, xR, xC, ${p}),\n                  getX(batch, xR, xC, ${p} + 1)\n                );\n                dotProd += dot(xValues, wValues);\n              } else {\n                vec2 xValues = vec2(\n                  getX(batch, ${p}, xR, xC),\n                  getX(batch, ${p} + 1, xR, xC)\n                );\n                dotProd += dot(xValues, wValues);\n              }\n\n            } else if (${3===m}) {\n              vec3 wValues = vec3(\n                getW(wR, wC, ${p}, d2),\n                getW(wR, wC, ${p} + 1, d2),\n                getW(wR, wC, ${p} + 2, d2)\n              );\n\n              if (${f}) {\n                vec3 xValues = vec3(\n                  getX(batch, xR, xC, ${p}),\n                  getX(batch, xR, xC, ${p} + 1),\n                  getX(batch, xR, xC, ${p} + 2)\n                );\n                dotProd += dot(xValues, wValues);\n              } else {\n                vec3 xValues = vec3(\n                  getX(batch, ${p}, xR, xC),\n                  getX(batch, ${p} + 1, xR, xC),\n                  getX(batch, ${p} + 2, xR, xC)\n                );\n                dotProd += dot(xValues, wValues);\n              }\n\n            }\n          }\n        }\n\n        float result = dotProd;\n        ${x}\n        ${b}\n        setOutput(result);\n      }\n    `}}class Conv3DProgram{constructor(e){this.variableNames=["x","W"],this.outputShape=e.outShape;const t=e.padInfo.front,n=e.padInfo.top,r=e.padInfo.left,i=e.strideDepth,a=e.strideHeight,o=e.strideWidth,s=e.dilationDepth,l=e.dilationHeight,c=e.dilationWidth,h=e.filterDepth,u=e.filterHeight,d=e.filterWidth,p=4*Math.floor(e.inChannels/4),m=e.inChannels%4;this.userCode=`\n      const ivec3 strides = ivec3(${i}, ${a}, ${o});\n      const ivec3 pads = ivec3(${t}, ${n}, ${r});\n\n      void main() {\n        ivec5 coords = getOutputCoords();\n        int batch = coords.x;\n        int d2 = coords.u;\n\n        ivec3 xFRCCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads;\n        int xFCorner = xFRCCorner.x;\n        int xRCorner = xFRCCorner.y;\n        int xCCorner = xFRCCorner.z;\n\n        // Convolve x(?, ?, ?, d1) with w(:, :, :, d1, d2) to get\n        // y(yF, yR, yC, d2). ? = to be determined. : = across all\n        // values in that axis.\n        float dotProd = 0.0;\n        for (int wF = 0; wF < ${h}; wF++) {\n          int xF = xFCorner + wF * ${s};\n\n          if (xF < 0 || xF >= ${e.inDepth}) {\n            continue;\n          }\n\n          for (int wR = 0; wR < ${u}; wR++) {\n            int xR = xRCorner + wR * ${l};\n\n            if (xR < 0 || xR >= ${e.inHeight}) {\n              continue;\n            }\n\n            for (int wC = 0; wC < ${d}; wC++) {\n              int xC = xCCorner + wC * ${c};\n\n              if (xC < 0 || xC >= ${e.inWidth}) {\n                continue;\n              }\n\n              for (int d1 = 0; d1 < ${p}; d1 += 4) {\n                vec4 xValues = vec4(\n                  getX(batch, xF, xR, xC, d1),\n                  getX(batch, xF, xR, xC, d1 + 1),\n                  getX(batch, xF, xR, xC, d1 + 2),\n                  getX(batch, xF, xR, xC, d1 + 3)\n                );\n                vec4 wValues = vec4(\n                  getW(wF, wR, wC, d1, d2),\n                  getW(wF, wR, wC, d1 + 1, d2),\n                  getW(wF, wR, wC, d1 + 2, d2),\n                  getW(wF, wR, wC, d1 + 3, d2)\n                );\n\n                dotProd += dot(xValues, wValues);\n              }\n\n              if (${1===m}) {\n                dotProd +=\n                  getX(batch, xF, xR, xC, ${p}) *\n                  getW(wF, wR, wC, ${p}, d2);\n              } else if (${2===m}) {\n                vec2 xValues = vec2(\n                  getX(batch, xF, xR, xC, ${p}),\n                  getX(batch, xF, xR, xC, ${p} + 1)\n                );\n                vec2 wValues = vec2(\n                  getW(wF, wR, wC, ${p}, d2),\n                  getW(wF, wR, wC, ${p} + 1, d2)\n                );\n                dotProd += dot(xValues, wValues);\n              } else if (${3===m}) {\n                vec3 xValues = vec3(\n                  getX(batch, xF, xR, xC, ${p}),\n                  getX(batch, xF, xR, xC, ${p} + 1),\n                  getX(batch, xF, xR, xC, ${p} + 2)\n                );\n                vec3 wValues = vec3(\n                  getW(wF, wR, wC, ${p}, d2),\n                  getW(wF, wR, wC, ${p} + 1, d2),\n                  getW(wF, wR, wC, ${p} + 2, d2)\n                );\n                dotProd += dot(xValues, wValues);\n              }\n            }\n          }\n        }\n        setOutput(dotProd);\n      }\n    `}}
/**
     * @license
     * Copyright 2019 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */class Im2ColPackedProgram{constructor(e,t,n){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e;const{filterWidth:r,inChannels:i,strideWidth:a,strideHeight:o,padInfo:s,outWidth:l,dilationWidth:c,dilationHeight:h,dataFormat:u}=n,{left:d,top:p}=s,m=i*r,f=getGlslDifferences(),g="channelsLast"===u,v=g?0:1,y=g?1:2;let _="";for(let n=0;n<=1;n++)for(let r=0;r<=1;r++)_+=`\n          blockIndex = rc.y + ${r};\n          pos = rc.x + ${n};\n\n          if(blockIndex < ${e[1]} && pos < ${e[0]}) {\n            offsetY = int(blockIndex / (${l})) * ${o} - ${p};\n            d0 = offsetY + ${h} * (pos / ${m});\n\n            if(d0 < ${t[v]} && d0 >= 0) {\n\n              offsetX = int(mod(float(blockIndex), ${l}.) * ${a}. - ${d}.);\n              d1 = offsetX + ${c} * (int(mod(float(pos), ${m}.) / ${i}.));\n\n              if(d1 < ${t[y]} && d1 >= 0) {\n\n                ch = int(mod(float(pos), ${i}.));\n\n                if (${g}) {\n                  innerDims = vec2(d1, ch);\n                  result[${2*n+r}] = getChannel(\n                    getA(d0, int(innerDims.x),\n                    int(innerDims.y)), innerDims);\n                } else {\n                  innerDims = vec2(d0, d1);\n                  result[${2*n+r}] = getChannel(\n                    getA(ch, int(innerDims.x),\n                    int(innerDims.y)), innerDims);\n                }\n              }\n            }\n          }\n        `;this.userCode=`\n      void main() {\n        ivec2 rc = getOutputCoords();\n\n        vec4 result = vec4(0);\n\n        int blockIndex, pos, offsetY, d0, offsetX, d1, ch;\n        vec2 innerDims;\n\n        ${_}\n\n        ${f.output} = result;\n      }\n    `}}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function conv2dByMatMul({x:e,filter:t,convInfo:n,backend:r,bias:i=null,preluActivationWeights:a=null,leakyreluAlpha:o=0,activation:s=null}){const l=e.shape,c=r.texData.get(e.dataId),h="channelsLast"===n.dataFormat;let u;const d=[],p=l[2]%2!=0&&!!c.isPacked;if(!((1===l[0]*l[1]*l[2]||1===n.outChannels)&&n.inChannels>MATMUL_SHARED_DIM_THRESHOLD)&&env().getBool("WEBGL_LAZILY_UNPACK")&&env().getBool("WEBGL_PACK_BINARY_OPERATIONS")&&p){const p={dataId:e.dataId,shape:[1,h?l[0]*l[1]*(l[2]+1):l[0]*l[2]*(l[3]+1),n.inChannels],dtype:e.dtype},m=c.shape;c.shape=c.shape.slice(),c.shape[c.shape.length-2]++,assert$1(isReshapeFree(c.shape,p.shape),(()=>`packed reshape ${c.shape} to ${p.shape} isn't free`));const f=reshape({inputs:{x:t},backend:r,attrs:{shape:[1,n.inChannels,n.outChannels]}});d.push(f);const g=batchMatMulImpl({a:p,b:f,backend:r,transposeA:false,transposeB:false,bias:i,activation:s,preluActivationWeights:a,leakyreluAlpha:o}),v=r.texData.get(g.dataId);assert$1(v.isPacked,(()=>"batchMatMul result is expected to be packed")),c.shape=m,v.shape=n.outShape,u=identity$2({inputs:{x:g},backend:r}),u.shape=n.outShape,d.push(g)}else{const c=reshape({inputs:{x:e},backend:r,attrs:{shape:[1,h?l[0]*l[1]*l[2]:l[0]*l[2]*l[3],n.inChannels]}}),p=reshape({inputs:{x:t},backend:r,attrs:{shape:[1,n.inChannels,n.outChannels]}}),m=batchMatMulImpl({a:c,b:p,transposeA:false,transposeB:false,backend:r,bias:i,activation:s,preluActivationWeights:a,leakyreluAlpha:o});u=reshape({inputs:{x:m},backend:r,attrs:{shape:n.outShape}}),d.push(c),d.push(p),d.push(m)}for(const e of d)r.disposeIntermediateTensorInfo(e);return u}function conv2dWithIm2Row({x:e,filter:t,convInfo:n,backend:r,bias:i=null,preluActivationWeights:a=null,leakyreluAlpha:o=0,activation:s=null}){const{filterWidth:l,filterHeight:c,inChannels:h,outWidth:u,outHeight:d,dataFormat:p}=n,m="channelsLast"===p,f=l*c*h,g=d*u,v=[f,g],y=[],_=reshape({inputs:{x:e},backend:r,attrs:{shape:e.shape.slice(1)}}),b=reshape({inputs:{x:t},backend:r,attrs:{shape:[1,f,sizeFromShape(t.shape)/f]}});y.push(_),y.push(b);const x=new Im2ColPackedProgram(v,_.shape,n),S=r.runWebGLProgram(x,[_],"float32"),w=reshape({inputs:{x:S},backend:r,attrs:{shape:[1,v[0],v[1]]}});y.push(S),y.push(w);const C=null!=i,M=null!=a,E="leakyrelu"===s,T=s?mapActivationToShaderProgram(s,!0):null,I=new MatMulPackedProgram(w.shape,b.shape,[1,g,n.outChannels],!0,!1,C,T,M,E),A=[w,b];if(i&&A.push(i),M&&A.push(a),E){const e=r.makeTensorInfo([],"float32",createScalarValue(o,"float32"));A.push(e),y.push(e)}const k=r.runWebGLProgram(I,A,"float32"),P=reshape({inputs:{x:k},backend:r,attrs:{shape:m?[1,d,u,n.outChannels]:[1,n.outChannels,d,u]}});y.push(k);for(const e of y)r.disposeIntermediateTensorInfo(e);return P}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function conv2d(e){const{inputs:t,backend:n,attrs:r}=e,{x:i,filter:a}=t,{strides:o,pad:s,dataFormat:l,dilations:c,dimRoundingMode:h}=r,u=convertConv2DDataFormat(l),d=computeConv2DInfo(i.shape,a.shape,o,c,s,h,!1,u);let p;if(1!==d.filterHeight||1!==d.filterWidth||1!==d.dilationHeight||1!==d.dilationWidth||1!==d.strideHeight||1!==d.strideWidth||"SAME"!==d.padInfo.type&&"VALID"!==d.padInfo.type)if(env().getBool("WEBGL_CONV_IM2COL")&&1===i.shape[0])p=conv2dWithIm2Row({x:i,filter:a,convInfo:d,backend:n});else{const e=new Conv2DProgram(d);p=n.runWebGLProgram(e,[i,a],"float32")}else p=conv2dByMatMul({x:i,filter:a,convInfo:d,backend:n});const m=reshape({inputs:{x:p},backend:n,attrs:{shape:d.outShape}});return n.disposeIntermediateTensorInfo(p),m}const conv2DConfig={kernelName:Conv2D,backendName:"webgl",kernelFunc:conv2d};
/**
     * @license
     * Copyright 2017 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */class Conv2DDerFilterProgram{constructor(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape;this.userCode=`\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int wR = coords.x;\n        int wC = coords.y;\n        int d1 = coords.z;\n        int d2 = coords.w;\n\n        // Convolve x(?, ?, d1) with dy(:, :, d2) to get dw(wR, wC, d1, d2).\n        // ? = to be determined. : = across all values in that axis.\n        float dotProd = 0.0;\n\n        for (int b = 0; b < ${e.batchSize}; b++) {\n          for (int yR = 0; yR < ${e.outHeight}; yR++) {\n            int xR = wR + yR * ${e.strideHeight} - ${e.padInfo.top};\n\n            if (xR < 0 || xR >= ${e.inHeight}) {\n              continue;\n            }\n\n            for (int yC = 0; yC < ${e.outWidth}; yC++) {\n              int xC = wC + yC * ${e.strideWidth} - ${e.padInfo.left};\n\n              if (xC < 0 || xC >= ${e.inWidth}) {\n                continue;\n              }\n\n              if (${"channelsLast"===e.dataFormat}) {\n                float dyValue = getDy(b, yR, yC, d2);\n                float xValue = getX(b, xR, xC, d1);\n                dotProd += (xValue * dyValue);\n              } else {\n                float dyValue = getDy(b, d2, yR, yC);\n                float xValue = getX(b, d1, xR, xC);\n                dotProd += (xValue * dyValue);\n              }\n\n            }\n          }\n        }\n        setOutput(dotProd);\n      }\n    `}}class Conv2DDerInputProgram{constructor(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;const t=e.filterHeight,n=e.filterWidth,r="channelsLast"===e.dataFormat;this.userCode=`\n      const ivec2 pads = ivec2(${t-1-e.padInfo.top}, ${n-1-e.padInfo.left});\n\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int batch = coords[0];\n        int d1 = coords[${r?3:1}];\n\n        ivec2 dyCorner = ivec2(coords[${r?1:2}], coords[${r?2:3}]) - pads;\n        int dyRCorner = dyCorner.x;\n        int dyCCorner = dyCorner.y;\n\n        // Convolve dy(?, ?, d2) with w(:, :, d1, d2) to compute dx(xR, xC, d1).\n        // ? = to be determined. : = across all values in that axis.\n        float dotProd = 0.0;\n        for (int wR = 0; wR < ${t}; wR++) {\n          float dyR = float(dyRCorner + wR) / ${e.strideHeight}.0;\n\n          if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) {\n            continue;\n          }\n          int idyR = int(dyR);\n\n          int wRPerm = ${t} - 1 - wR;\n\n          for (int wC = 0; wC < ${n}; wC++) {\n            float dyC = float(dyCCorner + wC) / ${e.strideWidth}.0;\n\n            if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||\n                fract(dyC) > 0.0) {\n              continue;\n            }\n            int idyC = int(dyC);\n\n            int wCPerm = ${n} - 1 - wC;\n\n            for (int d2 = 0; d2 < ${e.outChannels}; d2++) {\n\n              if (${r}) {\n                float xValue = getDy(batch, idyR, idyC, d2);\n                float wValue = getW(wRPerm, wCPerm, d1, d2);\n                dotProd += xValue * wValue;\n              } else {\n                float xValue = getDy(batch, d2, idyR, idyC);\n                float wValue = getW(wRPerm, wCPerm, d1, d2);\n                dotProd += xValue * wValue;\n              }\n\n            }\n          }\n        }\n        setOutput(dotProd);\n      }\n    `}}class Conv3DDerFilterProgram{constructor(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape;this.userCode=`\n      void main() {\n        ivec5 coords = getOutputCoords();\n        int wF = coords.x;\n        int wR = coords.y;\n        int wC = coords.z;\n        int d1 = coords.w;\n        int d2 = coords.u;\n\n        float dotProd = 0.0;\n\n        for (int b = 0; b < ${e.batchSize}; b++) {\n          for (int yF = 0; yF < ${e.outDepth}; yF++) {\n            int xF = wF + yF * ${e.strideDepth} - ${e.padInfo.front};\n\n            if (xF < 0 || xF >= ${e.inDepth}) {\n              continue;\n            }\n\n            for (int yR = 0; yR < ${e.outHeight}; yR++) {\n              int xR = wR + yR * ${e.strideHeight} - ${e.padInfo.top};\n\n              if (xR < 0 || xR >= ${e.inHeight}) {\n                continue;\n              }\n\n              for (int yC = 0; yC < ${e.outWidth}; yC++) {\n                int xC = wC + yC * ${e.strideWidth} - ${e.padInfo.left};\n\n                if (xC < 0 || xC >= ${e.inWidth}) {\n                  continue;\n                }\n\n                float dyValue = getDy(b, yF, yR, yC, d2);\n                float xValue = getX(b, xF, xR, xC, d1);\n                dotProd += (xValue * dyValue);\n              }\n            }\n          }\n        }\n        setOutput(dotProd);\n      }\n    `}}class Conv3DDerInputProgram{constructor(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;const t=e.filterDepth,n=e.filterHeight,r=e.filterWidth;this.userCode=`\n      const ivec3 pads = ivec3(${t-1-e.padInfo.front}, ${n-1-e.padInfo.top}, ${r-1-e.padInfo.left});\n\n      void main() {\n        ivec5 coords = getOutputCoords();\n        int batch = coords.x;\n        int d1 = coords.u;\n\n\n        ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads;\n        int dyFCorner = dyCorner.x;\n        int dyRCorner = dyCorner.y;\n        int dyCCorner = dyCorner.z;\n\n        float dotProd = 0.0;\n        for (int wF = 0; wF < ${t}; wF++) {\n          float dyF = float(dyFCorner + wF) / ${e.strideDepth}.0;\n\n          if (dyF < 0.0 || dyF >= ${e.outDepth}.0 || fract(dyF) > 0.0) {\n            continue;\n          }\n          int idyF = int(dyF);\n\n          int wFPerm = ${t} - 1 - wF;\n\n          for (int wR = 0; wR < ${n}; wR++) {\n            float dyR = float(dyRCorner + wR) / ${e.strideHeight}.0;\n\n            if (dyR < 0.0 || dyR >= ${e.outHeight}.0 ||\n              fract(dyR) > 0.0) {\n              continue;\n            }\n            int idyR = int(dyR);\n\n            int wRPerm = ${n} - 1 - wR;\n\n            for (int wC = 0; wC < ${r}; wC++) {\n              float dyC = float(dyCCorner + wC) / ${e.strideWidth}.0;\n\n              if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||\n                  fract(dyC) > 0.0) {\n                continue;\n              }\n              int idyC = int(dyC);\n\n              int wCPerm = ${r} - 1 - wC;\n\n              for (int d2 = 0; d2 < ${e.outChannels}; d2++) {\n                float xValue = getDy(batch, idyF, idyR, idyC, d2);\n                float wValue = getW(wFPerm, wRPerm, wCPerm, d1, d2);\n                dotProd += xValue * wValue;\n              }\n            }\n          }\n        }\n        setOutput(dotProd);\n      }\n    `}}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function conv2DBackpropFilter(e){const{inputs:t,backend:n,attrs:r}=e,{x:i,dy:a}=t,{strides:o,pad:s,dataFormat:l,dimRoundingMode:c,filterShape:h}=r,u=convertConv2DDataFormat(l),d=computeConv2DInfo(i.shape,h,o,1,s,c,!1,u),p=new Conv2DDerFilterProgram(d);return n.runWebGLProgram(p,[i,a],"float32")}const conv2DBackpropFilterConfig={kernelName:Conv2DBackpropFilter,backendName:"webgl",kernelFunc:conv2DBackpropFilter};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function conv2DBackpropInput(e){const{inputs:t,backend:n,attrs:r}=e,{dy:i,filter:a}=t,{inputShape:o,strides:s,pad:l,dataFormat:c,dimRoundingMode:h}=r,u=convertConv2DDataFormat(c),d=computeConv2DInfo(o,a.shape,s,1,l,h,!1,u),p=new Conv2DDerInputProgram(d);return n.runWebGLProgram(p,[i,a],"float32")}const conv2DBackpropInputConfig={kernelName:Conv2DBackpropInput,backendName:"webgl",kernelFunc:conv2DBackpropInput};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function conv3D(e){const{inputs:t,backend:n,attrs:r}=e,{x:i,filter:a}=t,{strides:o,pad:s,dilations:l}=r,c=computeConv3DInfo(i.shape,a.shape,o,l,s),h=new Conv3DProgram(c);return n.runWebGLProgram(h,[i,a],"float32")}const conv3DConfig={kernelName:Conv3D,backendName:"webgl",kernelFunc:conv3D};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function conv3DBackpropFilterV2(e){const{inputs:t,backend:n,attrs:r}=e,{x:i,dy:a}=t,{strides:o,pad:s,filterShape:l}=r,c=computeConv3DInfo(i.shape,l,o,1,s),h=new Conv3DDerFilterProgram(c);return n.runWebGLProgram(h,[i,a],"float32")}const conv3DBackpropFilterV2Config={kernelName:Conv3DBackpropFilterV2,backendName:"webgl",kernelFunc:conv3DBackpropFilterV2};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function conv3DBackpropInput(e){const{inputs:t,backend:n,attrs:r}=e,{dy:i,filter:a}=t,{pad:o,strides:s,inputShape:l}=r,c=computeConv3DInfo(l,a.shape,s,1,o),h=new Conv3DDerInputProgram(c);return n.runWebGLProgram(h,[i,a],"float32")}const conv3DBackpropInputConfig={kernelName:Conv3DBackpropInputV2,backendName:"webgl",kernelFunc:conv3DBackpropInput},COS=CHECK_NAN_SNIPPET_UNARY+"\n  return cos(x);\n",cos=unaryKernelFunc({opSnippet:COS}),cosConfig={kernelName:Cos,backendName:"webgl",kernelFunc:cos},COSH="\n  float e2x = exp(-x);\n  return (e2x + 1.0 / e2x) / 2.0;\n",cosh=unaryKernelFunc({opSnippet:COSH}),coshConfig={kernelName:Cosh,backendName:"webgl",kernelFunc:cosh};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
/**
     * @license
     * Copyright 2017 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
class CropAndResizeProgram{constructor(e,t,n,r,i){this.variableNames=["Image","Boxes","BoxInd"],this.outputShape=[];const[a,o,s,l]=e,[c]=t,[h,u]=n;this.outputShape=[c,h,u,l];const d="bilinear"===r?1:0,[p,m]=[o-1+".0",s-1+".0"],[f,g,v]=h>1?[""+(o-1)/(h-1),"(y2-y1) * height_ratio",`y1*${p} + float(y)*(height_scale)`]:["0.0","0.0",`0.5 * (y1+y2) * ${p}`],[y,_,b]=u>1?[""+(s-1)/(u-1),"(x2-x1) * width_ratio",`x1*${m} + float(x)*(width_scale)`]:["0.0","0.0",`0.5 * (x1+x2) * ${m}`];this.userCode=`\n      const float height_ratio = float(${f});\n      const float width_ratio = float(${y});\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int b = coords[0];\n        int y = coords[1];\n        int x = coords[2];\n        int d = coords[3];\n\n        // get box vals\n        float y1 = getBoxes(b,0);\n        float x1 = getBoxes(b,1);\n        float y2 = getBoxes(b,2);\n        float x2 = getBoxes(b,3);\n\n        // get image in batch index\n        int bInd = round(getBoxInd(b));\n        if(bInd < 0 || bInd >= ${a}) {\n          return;\n        }\n\n        float height_scale = ${g};\n        float width_scale = ${_};\n\n        float in_y = ${v};\n        if( in_y < 0.0 || in_y > ${p} ) {\n          setOutput(float(${i}));\n          return;\n        }\n        float in_x = ${b};\n        if( in_x < 0.0 || in_x > ${m} ) {\n          setOutput(float(${i}));\n          return;\n        }\n\n        vec2 sourceFracIndexCR = vec2(in_x,in_y);\n        if(${d} == 1) {\n          // Compute the four integer indices.\n          ivec2 sourceFloorCR = ivec2(sourceFracIndexCR);\n          ivec2 sourceCeilCR = ivec2(ceil(sourceFracIndexCR));\n\n          float topLeft = getImage(b, sourceFloorCR.y, sourceFloorCR.x, d);\n          float bottomLeft = getImage(b, sourceCeilCR.y, sourceFloorCR.x, d);\n          float topRight = getImage(b, sourceFloorCR.y, sourceCeilCR.x, d);\n          float bottomRight = getImage(b, sourceCeilCR.y, sourceCeilCR.x, d);\n\n          vec2 fracCR = sourceFracIndexCR - vec2(sourceFloorCR);\n\n          float top = topLeft + (topRight - topLeft) * fracCR.x;\n          float bottom = bottomLeft + (bottomRight - bottomLeft) * fracCR.x;\n          float newValue = top + (bottom - top) * fracCR.y;\n          setOutput(newValue);\n        } else {\n          // Compute the coordinators of nearest neighbor point.\n          ivec2 sourceNearestCR = ivec2(floor(\n            sourceFracIndexCR + vec2(0.5,0.5)));\n          float newValue = getImage(b, sourceNearestCR.y, sourceNearestCR.x, d);\n          setOutput(newValue);\n        }\n      }\n    `}}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */const cropAndResize=e=>{const{inputs:t,backend:n,attrs:r}=e,{image:i,boxes:a,boxInd:o}=t,{cropSize:s,method:l,extrapolationValue:c}=r,h=new CropAndResizeProgram(i.shape,a.shape,s,l,c);return n.runWebGLProgram(h,[i,a,o],"float32")},cropAndResizeConfig={kernelName:CropAndResize,backendName:"webgl",kernelFunc:cropAndResize};class CumSumProgram{constructor(e,t,n){this.variableNames=["x"],this.outputShape=e;const r=e.length,i=t?"0.0":`getX(${getCoords(r,"coords")})`,a=e[e.length-1];let o="",s="";t?(o=n?"end != "+(a-1):"end != 0",s=n?"end + 1":"end - 1"):(o=n?`end + pow2 < ${a}`:"end >= pow2",s=n?"end + pow2":"end - pow2"),this.userCode=`\n      uniform float index;\n      void main() {\n        ${getCoordsDataType(r)} coords = getOutputCoords();\n        int end = ${getFinalCoord(r,"coords")};\n        float val = ${i};\n        int pow2 = int(pow(2.0, index));\n        if (${o}) {\n          int idx = ${s};\n          ${getFinalCoord(r,"coords")} = idx;\n          val += getX(${getCoords(r,"coords")});\n        }\n        setOutput(val);\n      }\n    `}getCustomSetupFunc(e){return(t,n)=>{null==this.index&&(this.index=t.getUniformLocation(n,"index")),t.gl.uniform1f(this.index,e)}}}function getCoords(e,t){if(1===e)return`${t}`;if(2===e)return`${t}.x, ${t}.y`;if(3===e)return`${t}.x, ${t}.y, ${t}.z`;if(4===e)return`${t}.x, ${t}.y, ${t}.z, ${t}.w`;throw Error(`Cumulative sum for rank ${e} is not yet supported`)}function getFinalCoord(e,t){if(1===e)return`${t}`;if(2===e)return`${t}.y`;if(3===e)return`${t}.z`;if(4===e)return`${t}.w`;throw Error(`Cumulative sum for rank ${e} is not yet supported`)}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function cumsum(e){const{inputs:t,backend:n,attrs:r}=e,{x:i}=t,{axis:a,exclusive:o,reverse:s}=r,l=i.shape.length,c=getAxesPermutation([a],l);let h=i;null!=c&&(h=transpose({inputs:{x:i},backend:n,attrs:{perm:c}}));const u=getInnerMostAxes(1,l)[0];if(u!==l-1)throw new Error(`WebGL cumsum shader expects an inner-most axis=${i.shape.length-1} but got axis=${a}`);const d=h.shape[u];let p=identity$2({inputs:{x:h},backend:n});for(let e=0;e<=Math.ceil(Math.log2(d))-1;e++){const t=new CumSumProgram(h.shape,!1,s),r=t.getCustomSetupFunc(e),i=p;p=n.runWebGLProgram(t,[p],p.dtype,r),n.disposeIntermediateTensorInfo(i)}if(o){const e=new CumSumProgram(h.shape,o,s),t=p;p=n.runWebGLProgram(e,[p],p.dtype),n.disposeIntermediateTensorInfo(t)}if(null!=c){const e=transpose({inputs:{x:p},backend:n,attrs:{perm:getUndoAxesPermutation(c)}});return n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(h),e}return p}const cumsumConfig={kernelName:Cumsum,backendName:"webgl",kernelFunc:cumsum};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function denseBincount(e){const{inputs:t,backend:n,attrs:r}=e,{x:i,weights:a}=t,{size:o,binaryOutput:s}=r;if(1===i.shape.length){const e=n.readSync(i.dataId),t=n.readSync(a.dataId),r=bincountImplCPU(e,t,a.dtype,a.shape,o);return n.makeTensorInfo([o],a.dtype,r)}if(2===i.shape.length){const e=n.bufferSync(i),t=n.bufferSync(a),r=bincountReduceImplCPU(e,t,o,s);return n.makeTensorInfo(r.shape,a.dtype,r.values)}throw new Error(`Error in denseBincount: input must be at most rank 2, but got rank${i.shape.length}.`)}const denseBincountConfig={kernelName:DenseBincount,backendName:"webgl",kernelFunc:denseBincount};
/**
     * @license
     * Copyright 2018 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */class DepthToSpaceProgram{constructor(e,t,n){this.variableNames=["x"],this.outputShape=[],this.outputShape=e,this.blockSize=t,this.dataFormat=n,this.userCode=`\n    void main() {\n      ivec4 coords = getOutputCoords();\n      int b = coords[0];\n      int h = ${this.getHeightCoordString()};\n      int w = ${this.getWidthCoordString()};\n      int d = ${this.getDepthCoordString()};\n\n      int in_h = h / ${t};\n      int offset_h = imod(h, ${t});\n      int in_w = w / ${t};\n      int offset_w = imod(w, ${t});\n      int offset_d = (offset_h * ${t} + offset_w) *\n        ${this.getOutputDepthSize()};\n      int in_d = d + offset_d;\n\n      float result = ${this.getInputSamplingString()};\n      setOutput(result);\n    }\n  `}getHeightCoordString(){return"NHWC"===this.dataFormat?"coords[1]":"coords[2]"}getWidthCoordString(){return"NHWC"===this.dataFormat?"coords[2]":"coords[3]"}getDepthCoordString(){return"NHWC"===this.dataFormat?"coords[3]":"coords[1]"}getOutputDepthSize(){return"NHWC"===this.dataFormat?this.outputShape[3]:this.outputShape[1]}getInputSamplingString(){return"NHWC"===this.dataFormat?"getX(b, in_h, in_w, in_d)":"getX(b, in_d, in_h, in_w)"}}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function depthToSpace(e){const{inputs:t,backend:n,attrs:r}=e,{x:i}=t,{blockSize:a,dataFormat:o}=r;assert$1(a>1,(()=>`blockSize should be > 1 for depthToSpace, but was: ${a}`));const s=i.shape[0],l=("NHWC"===o?i.shape[1]:i.shape[2])*a,c=("NHWC"===o?i.shape[2]:i.shape[3])*a,h=("NHWC"===o?i.shape[3]:i.shape[1])/(a*a),u=new DepthToSpaceProgram("NHWC"===o?[s,l,c,h]:[s,h,l,c],a,o);return n.runWebGLProgram(u,[i],i.dtype)}const depthToSpaceConfig={kernelName:DepthToSpace,backendName:"webgl",kernelFunc:depthToSpace};
/**
     * @license
     * Copyright 2017 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */class DepthwiseConv2DProgram{constructor(e,t=!1,n=null,r=!1,i=!1){this.variableNames=["x","W"],this.outputShape=e.outShape;const a=e.inHeight,o=e.inWidth,s=e.padInfo.top,l=e.padInfo.left,c=e.strideHeight,h=e.strideWidth,u=e.dilationHeight,d=e.dilationWidth,p=e.filterHeight,m=e.filterWidth,f=e.outChannels/e.inChannels;let g="",v="";n&&(g=r?`float activation(float a) {\n          float b = getPreluActivationWeightsAtOutCoords();\n          ${n}\n        }`:i?`float activation(float a) {\n          float b = getLeakyreluAlphaAtOutCoords();\n          ${n}\n        }`:`\n          float activation(float x) {\n            ${n}\n          }\n        `,v="result = activation(result);");const y=t?"result += getBiasAtOutCoords();":"";t&&this.variableNames.push("bias"),r&&this.variableNames.push("preluActivationWeights"),i&&this.variableNames.push("leakyreluAlpha"),this.userCode=`\n      ${g}\n\n      const ivec2 strides = ivec2(${c}, ${h});\n      const ivec2 pads = ivec2(${s}, ${l});\n\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int batch = coords.x;\n        ivec2 xRCCorner = coords.yz * strides - pads;\n        int d2 = coords.w;\n        int d1 = d2 / ${f};\n        int q = d2 - d1 * ${f};\n\n        int xRCorner = xRCCorner.x;\n        int xCCorner = xRCCorner.y;\n\n        // Convolve x(?, ?, d1) with w(:, :, d1, q) to get y(yR, yC, d2).\n        // ? = to be determined. : = across all values in that axis.\n        float dotProd = 0.0;\n        // TO DO(dsmilkov): Flatten the two for loops and vec4 the operations.\n        for (int wR = 0; wR < ${p}; wR++) {\n          int xR = xRCorner + wR * ${u};\n\n          if (xR < 0 || xR >= ${a}) {\n            continue;\n          }\n\n          for (int wC = 0; wC < ${m}; wC++) {\n            int xC = xCCorner + wC * ${d};\n\n            if (xC < 0 || xC >= ${o}) {\n              continue;\n            }\n\n            float xVal = getX(batch, xR, xC, d1);\n            float wVal = getW(wR, wC, d1, q);\n            dotProd += xVal * wVal;\n          }\n        }\n\n        float result = dotProd;\n        ${y}\n        ${v}\n        setOutput(result);\n      }\n    `}}
/**
     * @license
     * Copyright 2018 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */class DepthwiseConvPacked2DProgram{constructor(e,t=!1,n=null,r=!1,i=!1){this.variableNames=["x","W"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e.outShape;const a=e.outChannels/e.inChannels,o=e.inHeight,s=e.inWidth,l=e.padInfo.top,c=e.padInfo.left,h=e.strideHeight,u=e.strideWidth,d=e.dilationHeight,p=e.dilationWidth,m=e.filterHeight,f=e.filterWidth,g=f;let v="\n      int xR; int xC; int xCOffset;\n      vec4 wTexel; vec4 previous; vec4 final;";for(let e=0;e<f;e++)v+=`\n          vec4 xTexelC${2*e};\n          vec4 xC${e};`;for(let e=0;e<m;e++){for(let e=0;e<f;e++)v+=`\n          xTexelC${2*e} = vec4(0.0);\n          xC${e} = vec4(0.0);`;v+=`\n        xR = xRCorner + ${e*d};\n        if (xR >=0 && xR < ${o}) {\n      `;for(let t=0;t<g/2+1;t++){const n=2*t;if(v+=`\n          xC = xCCorner + ${n*p};\n          `,1===u){if(n<f&&(c%2==1?(v+=`\n                xCOffset = xC + 1;\n                if (xCOffset >= 0 && xCOffset < ${s}) {\n                  xTexelC${n} = getX(batch, xR, xCOffset, d1);\n\n                  // Need to manually clear unused channels in case\n                  // we're reading from recycled texture.\n                  if (xCOffset + 1 >= ${s}) {\n                    xTexelC${n}.zw = vec2(0.0);\n                  }\n                }\n              `,v+=1===p&&n>0?`\n                xC${n} = vec4(xTexelC${n-2}.zw, xTexelC${n}.xy);\n                `:`\n                  xCOffset = xC + 1 - 2;\n\n                  if (xCOffset >= 0 && xCOffset < ${s}) {\n                    previous = getX(batch, xR, xCOffset, d1);\n\n                    // Need to manually clear unused channels in case\n                    // we're reading from recycled texture.\n                    if (xCOffset + 1 >= ${s}) {\n                      previous.zw = vec2(0.0);\n                    }\n\n                    xC${n} = vec4(previous.zw, xTexelC${n}.xy);\n                  } else {\n                    xC${n} = vec4(0.0, 0.0, xTexelC${n}.xy);\n                  }\n                  `):v+=`\n                if (xC >= 0 && xC < ${s}) {\n                  xTexelC${n} = getX(batch, xR, xC, d1);\n                  if (xC + 1 >= ${s}) {\n                    xTexelC${n}.zw = vec2(0.0);\n                  }\n                }\n\n                xC${n} = xTexelC${n};\n                `,n+1<f)){const e=c%2==0?nearestLargerEven(p):p;p%2==0&&c%2==1||p%2!=0&&c%2!=1?(v+=`\n                  xCOffset = xC + ${c%2} + ${e};\n\n                  if (xCOffset >= 0 && xCOffset < ${s}) {\n                    xTexelC${n+2} = getX(batch, xR, xCOffset, d1);\n\n                    // Need to manually clear unused channels in case\n                    // we're reading from recycled texture.\n                    if (xCOffset + 1 >= ${s}) {\n                      xTexelC${n+2}.zw = vec2(0.0);\n                    }\n                  }\n                  `,p>1&&(v+=`\n                    xCOffset -= 2;\n                    if (xCOffset >= 0 && xCOffset < ${s}) {\n                      xTexelC${n} = getX(batch, xR, xCOffset, d1);\n                    }\n                    `),v+=`\n                  xC${n+1} = vec4(xTexelC${n}.zw, xTexelC${n+2}.xy);\n                  `):v+=1===e?`\n                    xC${n+1} = xTexelC${n};\n                    `:`\n                    xCOffset = xC + ${e};\n\n                    if (xCOffset >= 0 && xCOffset < ${s}) {\n                      xTexelC${n+2} = getX(batch, xR, xCOffset, d1);\n                      if (xCOffset + 1 >= ${s}) {\n                        xTexelC${n+2}.zw = vec2(0.0);\n                      }\n                    }\n\n                    xC${n+1} = xTexelC${n+2};\n                    `}}else n<f&&(c%2==1?(v+=`\n                xCOffset = xC + 1 - ${u};\n                if(xCOffset >= 0 && xCOffset < ${s}) {\n                  xTexelC${n} = getX(batch, xR, xCOffset, d1);\n                  // Need to manually clear unused channels in case\n                  // we're reading from recycled texture.\n                  if (xCOffset + 1 >= ${s}) {\n                    xTexelC${n}.zw = vec2(0.0);\n                  }\n                }\n\n                if(xC + 1 >= 0 && xC + 1 < ${s}) {\n                  xTexelC${n+2} = getX(batch, xR, xC + 1, d1);\n                  // Need to manually clear unused channels in case\n                  // we're reading from recycled texture.\n                  if (xC + 2 >= ${s}) {\n                    xTexelC${n+2}.zw = vec2(0.0);\n                  }\n                }\n\n                xC${n} = vec4(xTexelC${n}.zw, xTexelC${n+2}.zw);\n              `,n+1<f&&(v+=`\n                  final = vec4(0.0);\n                  xCOffset = xC + 1 + ${u};\n                  if(xCOffset >= 0 && xCOffset < ${s}) {\n                    final = getX(batch, xR, xCOffset, d1);\n                  }\n                  xC${n+1} = vec4(xTexelC${n+2}.xy, final.xy);\n                `)):(v+=`\n                if(xC >= 0 && xC < ${s}) {\n                  xTexelC${n} = getX(batch, xR, xC, d1);\n                  if (xC + 1 >= ${s}) {\n                    xTexelC${n}.zw = vec2(0.0);\n                  }\n                }\n\n                xCOffset = xC + ${u};\n                if(xCOffset >= 0 && xCOffset < ${s}) {\n                  xTexelC${n+2} = getX(batch, xR, xCOffset, d1);\n                  if (xCOffset + 1 >= ${s}) {\n                    xTexelC${n+2}.zw = vec2(0.);\n                  }\n                }\n\n                xC${n} = vec4(\n                  xTexelC${n}.xy, xTexelC${n+2}.xy);\n              `,n+1<f&&(v+=`\n                  xC${n+1} = vec4(xTexelC${n}.zw, xTexelC${n+2}.zw);\n                `)));n<f&&(v+=`\n            wTexel = getW(${e}, ${n}, d1, q);\n            dotProd += xC${n} * vec4(wTexel.xz, wTexel.xz);\n          `,n+1<f&&(v+=`\n              wTexel = getW(${e}, ${n+1}, d1, q);\n              dotProd += xC${n+1} * vec4(wTexel.xz, wTexel.xz);\n            `))}v+="\n        }\n      "}let y="",_="";n&&(y=r?`vec4 activation(vec4 a) {\n          vec4 b = getPreluActivationWeightsAtOutCoords();\n          ${n}\n        }`:i?`vec4 activation(vec4 a) {\n          vec4 b = getLeakyreluAlphaAtOutCoords();\n          ${n}\n        }`:`vec4 activation(vec4 x) {\n          ${n}\n        }`,_="result = activation(result);");const b=t?"result += getBiasAtOutCoords();":"";t&&this.variableNames.push("bias"),r&&this.variableNames.push("preluActivationWeights"),i&&this.variableNames.push("leakyreluAlpha"),this.userCode=`\n      ${y}\n\n      const ivec2 strides = ivec2(${h}, ${u});\n      const ivec2 pads = ivec2(${l}, ${c});\n\n      void main() {\n\n        ivec4 coords = getOutputCoords();\n        int batch = coords.x;\n        ivec2 xRCCorner = coords.yz * strides - pads;\n        int d2 = coords.w;\n        int d1 = d2 / ${a};\n        int q = d2 - d1 * ${a};\n        int xRCorner = xRCCorner.x;\n        int xCCorner = xRCCorner.y;\n\n        //intialize dotProd with a small epsilon seems to reduce GPU accuracy loss.\n        vec4 dotProd = vec4(0.000000000000001);\n\n        ${v}\n\n        vec4 result = dotProd - vec4(0.000000000000001);\n        ${b}\n        ${_}\n        setOutput(result);\n      }\n    `}}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function depthwiseConv2dNative(e){const{inputs:t,backend:n,attrs:r}=e,{x:i,filter:a}=t,{strides:o,pad:s,dilations:l,dimRoundingMode:c}=r;let h=l;null==h&&(h=[1,1]),assert$1(eitherStridesOrDilationsAreOne(o,h),(()=>`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${o} and dilations '${h}'`));const u=computeConv2DInfo(i.shape,a.shape,o,h,s,c,!0);let d;return d=env().getBool("WEBGL_PACK_DEPTHWISECONV")&&u.strideWidth<=2&&u.outChannels/u.inChannels==1?new DepthwiseConvPacked2DProgram(u):new DepthwiseConv2DProgram(u),n.runWebGLProgram(d,[i,a],"float32")}const depthwiseConv2dNativeConfig={kernelName:DepthwiseConv2dNative,backendName:"webgl",kernelFunc:depthwiseConv2dNative};
/**
     * @license
     * Copyright 2018 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */class DepthwiseConv2DDerFilterProgram{constructor(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape;this.userCode=`\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int wR = coords.x;\n        int wC = coords.y;\n        int d1 = coords.z;\n        int dm = coords.w;\n        int d2 = d1 * ${e.outChannels/e.inChannels} + dm;\n\n        float dotProd = 0.0;\n\n        // TO DO: Vec4 over the batch size\n        for (int b = 0; b < ${e.batchSize}; b++) {\n          for (int yR = 0; yR < ${e.outHeight}; yR++) {\n            int xR = wR + yR * ${e.strideHeight} - ${e.padInfo.top};\n\n            if (xR < 0 || xR >= ${e.inHeight}) {\n              continue;\n            }\n\n            for (int yC = 0; yC < ${e.outWidth}; yC++) {\n              int xC = wC + yC * ${e.strideWidth} - ${e.padInfo.left};\n\n              if (xC < 0 || xC >= ${e.inWidth}) {\n                continue;\n              }\n\n              float dyValue = getDy(b, yR, yC, d2);\n              float xValue = getX(b, xR, xC, d1);\n              dotProd += (xValue * dyValue);\n            }\n          }\n        }\n        setOutput(dotProd);\n      }\n    `}}class DepthwiseConv2DDerInputProgram{constructor(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;const t=e.filterHeight,n=e.filterWidth,r=e.outChannels/e.inChannels;this.userCode=`\n      const ivec2 pads = ivec2(${t-1-e.padInfo.top}, ${n-1-e.padInfo.left});\n\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int batch = coords[0];\n        int d1 = coords[3];\n        ivec2 dyCorner = coords.yz - pads;\n        int dyRCorner = dyCorner.x;\n        int dyCCorner = dyCorner.y;\n\n        float dotProd = 0.0;\n\n        for (int wR = 0; wR < ${t}; wR++) {\n          float dyR = float(dyRCorner + wR) / ${e.strideHeight}.0;\n\n          if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) {\n            continue;\n          }\n          int idyR = int(dyR);\n\n          int wRPerm = ${t} - 1 - wR;\n\n          for (int wC = 0; wC < ${n}; wC++) {\n            float dyC = float(dyCCorner + wC) / ${e.strideWidth}.0;\n\n            if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||\n                fract(dyC) > 0.0) {\n              continue;\n            }\n            int idyC = int(dyC);\n\n            int wCPerm = ${n} - 1 - wC;\n\n            // TO DO: Vec4 over the channelMul\n            for (int dm = 0; dm < ${r}; dm++) {\n              int d2 = d1 * ${r} + dm;\n              float xValue = getDy(batch, idyR, idyC, d2);\n              float wValue = getW(wRPerm, wCPerm, d1, dm);\n              dotProd += xValue * wValue;\n            }\n          }\n        }\n        setOutput(dotProd);\n      }\n    `}}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function depthwiseConv2dNativeBackpropFilter(e){const{inputs:t,backend:n,attrs:r}=e,{x:i,dy:a}=t,{strides:o,dilations:s,pad:l,dimRoundingMode:c,filterShape:h}=r,u=computeConv2DInfo(i.shape,h,o,s,l,c,!0),d=new DepthwiseConv2DDerFilterProgram(u);return n.runWebGLProgram(d,[i,a],"float32")}const depthwiseConv2dNativeBackpropFilterConfig={kernelName:DepthwiseConv2dNativeBackpropFilter,backendName:"webgl",kernelFunc:depthwiseConv2dNativeBackpropFilter};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function depthwiseConv2dNativeBackpropInput(e){const{inputs:t,backend:n,attrs:r}=e,{dy:i,filter:a}=t,{strides:o,dilations:s,pad:l,dimRoundingMode:c,inputShape:h}=r,u=computeConv2DInfo(h,a.shape,o,s,l,c,!0),d=new DepthwiseConv2DDerInputProgram(u);return n.runWebGLProgram(d,[i,a],"float32")}const depthwiseConv2dNativeBackpropInputConfig={kernelName:DepthwiseConv2dNativeBackpropInput,backendName:"webgl",kernelFunc:depthwiseConv2dNativeBackpropInput};
/**
     * @license
     * Copyright 2019 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */class DiagProgram{constructor(e){this.variableNames=["X"],this.outputShape=[e,e],this.userCode="\n      void main() {\n          ivec2 coords = getOutputCoords();\n          float val = coords[0] == coords[1] ? getX(coords[0]) : 0.0;\n          setOutput(val);\n      }\n    "}}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function diag(e){const{inputs:t,backend:n}=e,{x:r}=t,i=[...r.shape,...r.shape],a=sizeFromShape(r.shape),o=reshape({inputs:{x:r},backend:n,attrs:{shape:[a]}}),s=new DiagProgram(a),l=n.runWebGLProgram(s,[o],o.dtype),c=reshape({inputs:{x:l},backend:n,attrs:{shape:i}});return n.disposeIntermediateTensorInfo(o),n.disposeIntermediateTensorInfo(l),c}const diagConfig={kernelName:Diag,backendName:"webgl",kernelFunc:diag};
/**
     * @license
     * Copyright 2017 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */class Dilation2DProgram{constructor(e){this.variableNames=["x","W"],this.outputShape=e.outShape;const{inHeight:t,inWidth:n,padInfo:r,strideHeight:i,strideWidth:a,filterHeight:o,filterWidth:s,dilationHeight:l,dilationWidth:c}=e,{top:h,left:u}=r;this.userCode=`\n      const ivec2 strides = ivec2(${i}, ${a});\n      const ivec2 pads = ivec2(${h}, ${u});\n      const float neg_infinity = -3.4e38;\n\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int batch = coords.x;\n        int d1 = coords.w;\n        ivec2 outTopLeftCorner =\n            coords.yz * strides - pads;\n        int hBeg = outTopLeftCorner.x;\n        int wBeg = outTopLeftCorner.y;\n\n        float curVal = neg_infinity;\n        for (int h = 0; h < ${o}; h++) {\n          int hIn = hBeg + h * ${l};\n\n          if (hIn >= 0 && hIn < ${t}) {\n            for (int w = 0; w < ${s}; w++) {\n              int wIn = wBeg + w * ${c};\n\n              if (wIn >= 0 && wIn < ${n}) {\n                float xVal = getX(batch, hIn, wIn, d1);\n                float wVal = getW(h, w, d1);\n\n                float val = xVal + wVal;\n                if (val > curVal) {\n                  curVal = val;\n                }\n              }\n            }\n          }\n        }\n\n        float result = curVal;\n        setOutput(result);\n      }\n    `}}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function dilation2D(e){const{inputs:t,backend:n,attrs:r}=e,{x:i,filter:a}=t,{strides:o,pad:s,dilations:l}=r,c=computeDilation2DInfo(i.shape,a.shape,o,s,"NHWC",l);let h;const u=new Dilation2DProgram(c);h=n.runWebGLProgram(u,[i,a],"float32");const d=reshape({inputs:{x:h},backend:n,attrs:{shape:c.outShape}});return n.disposeIntermediateTensorInfo(h),d}const dilation2DConfig={kernelName:Dilation2D,backendName:"webgl",kernelFunc:dilation2D};
/**
     * @license
     * Copyright 2021 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function einsum(e){const{inputs:t,backend:n,attrs:r}=e,{equation:i}=r,a=t,{allDims:o,summedDims:s,idDims:l}=decodeEinsumEquation(i,a.length);checkEinsumDimSizes(o.length,l,a);const{path:c,steps:h}=getEinsumComputePath(s,l),u=h.length;let d=null,p=o.length;const m=[];for(let e=0;e<u;++e){for(const t of h[e]){const{permutationIndices:e,expandDims:r}=getEinsumPermutation(p,l[t]);let i;isIdentityPermutation(e)?i=a[t]:(i=transpose({inputs:{x:a[t]},backend:n,attrs:{perm:e}}),m.push(i));const o=i.shape.slice();for(let e=0;e<r.length;++e)o.splice(r[e],0,1);arraysEqual$1(i.shape,o)||(i=reshape({inputs:{x:i},backend:n,attrs:{shape:o}}),m.push(i)),null===d?d=i:(d=multiply({inputs:{a:i,b:d},backend:n}),m.push(d))}e<u-1&&(c[e]>=0&&(d=sum({inputs:{x:d},backend:n,attrs:{axis:c[e]-(o.length-p),keepDims:!1}}),m.push(d)),p--)}for(const e of m)e!==d&&n.disposeIntermediateTensorInfo(e);return d}const einsumConfig={kernelName:Einsum,backendName:"webgl",kernelFunc:einsum},ELU="return (x >= 0.0) ? x : (exp(x) - 1.0);",ELU_PACKED="\n  vec4 result;\n\n  result.r = (x.r >= 0.0) ? x.r : (exp(x.r) - 1.0);\n  result.g = (x.g >= 0.0) ? x.g : (exp(x.g) - 1.0);\n  result.b = (x.b >= 0.0) ? x.b : (exp(x.b) - 1.0);\n  result.a = (x.a >= 0.0) ? x.a : (exp(x.a) - 1.0);\n\n  return result;\n",elu=unaryKernelFunc({opSnippet:ELU,packedOpSnippet:ELU_PACKED}),eluConfig={kernelName:Elu,backendName:"webgl",kernelFunc:elu},ELU_DER="return (b >= 1.0) ? a : a * (b + 1.0);",ELU_DER_PACKED="\n  vec4 bGTEZero = vec4(greaterThanEqual(b, vec4(0.)));\n  return (bGTEZero * a) + ((vec4(1.0) - bGTEZero) * (a * (b + vec4(1.0))));\n",eluGrad=e=>{const{inputs:t,backend:n}=e,{dy:r,y:i}=t,a=env().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new BinaryOpPackedProgram(ELU_DER_PACKED,r.shape,i.shape):new BinaryOpProgram(ELU_DER,r.shape,i.shape);return n.runWebGLProgram(a,[r,i],r.dtype)},eluGradConfig={kernelName:EluGrad,backendName:"webgl",kernelFunc:eluGrad},PACKED_EQUAL="\n  return vec4(equal(a, b));\n",EQUAL="return float(a == b);",equal=binaryKernelFunc({opSnippet:EQUAL,packedOpSnippet:PACKED_EQUAL,dtype:"bool"}),equalConfig={kernelName:Equal,backendName:"webgl",kernelFunc:equal},ERF=`\n  // Error function is calculated approximately with elementary function.\n  // See "Handbook of Mathematical Functions with Formulas,\n  // Graphs, and Mathematical Tables", Abramowitz and Stegun.\n  float p = ${ERF_P};\n  float a1 = ${ERF_A1};\n  float a2 = ${ERF_A2};\n  float a3 = ${ERF_A3};\n  float a4 = ${ERF_A4};\n  float a5 = ${ERF_A5};\n\n  float sign = sign(x);\n  x = abs(x);\n  float t = 1.0 / (1.0 + p * x);\n  return sign * (1.0 - (((((a5*t + a4)*t) + a3)*t + a2)*t + a1)*t*exp(-x*x));\n`,erf=unaryKernelFunc({opSnippet:ERF}),erfConfig={kernelName:Erf,backendName:"webgl",kernelFunc:erf},EXP="return exp(x);",exp=unaryKernelFunc({opSnippet:EXP,packedOpSnippet:EXP,cpuKernelImpl:expImplCPU}),expConfig={kernelName:Exp,backendName:"webgl",kernelFunc:exp};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the License);
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an AS IS BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
function expandDims(e){const{inputs:t,attrs:n,backend:r}=e,{dim:i}=n,{input:a}=t,o=a.shape.length,s=a.shape.slice();let l=i;return i<0&&(assert$1(-(o+1)<=i,(()=>`Axis must be in the interval [${-(o+1)}, ${o}]`)),l=o+i+1),s.splice(l,0,1),reshape({inputs:{x:a},backend:r,attrs:{shape:s}})}const expandDimsConfig={kernelName:ExpandDims,backendName:"webgl",kernelFunc:expandDims},EXPM1="return exp(x) - 1.0;",expm1=unaryKernelFunc({opSnippet:EXPM1,packedOpSnippet:EXPM1,cpuKernelImpl:expm1ImplCPU}),expm1Config={kernelName:Expm1,backendName:"webgl",kernelFunc:expm1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
/**
     * @license
     * Copyright 2018 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
class FFTProgram{constructor(e,t,n){this.variableNames=["real","imag"];const r=t[1];this.outputShape=t;const i=n?`2.0 * ${Math.PI}`:`-2.0 * ${Math.PI}`,a=n?`${r}.0`:"1.0";let o;if("real"===e)o="return real * expR - imag * expI;";else{if("imag"!==e)throw new Error(`FFT component must be either "real" or "imag", got ${e}.`);o="return real * expI + imag * expR;"}this.userCode=`\n      const float exponentMultiplier = ${i};\n\n      float unaryOpComplex(float real, float expR, float imag, float expI) {\n        ${o}\n      }\n\n      float mulMatDFT(int batch, int index) {\n        float indexRatio = float(index) / float(${r});\n        float exponentMultiplierTimesIndexRatio =\n            exponentMultiplier * indexRatio;\n\n        float result = 0.0;\n\n        for (int i = 0; i < ${r}; i++) {\n          // x = (-2|2 * PI / N) * index * i;\n          float x = exponentMultiplierTimesIndexRatio * float(i);\n          float expR = cos(x);\n          float expI = sin(x);\n          float real = getReal(batch, i);\n          float imag = getImag(batch, i);\n\n          result +=\n              unaryOpComplex(real, expR, imag, expI) / ${a};\n        }\n\n        return result;\n      }\n\n      void main() {\n        ivec2 coords = getOutputCoords();\n        setOutput(mulMatDFT(coords[0], coords[1]));\n      }\n    `}}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function fftImpl(e,t,n){const r=n.texData.get(e.dataId),i=sizeFromShape(e.shape),a=e.shape[e.shape.length-1],o=reshape({inputs:{x:e},backend:n,attrs:{shape:[i/a,a]}}),s=o.shape,l=new FFTProgram("real",s,t),c=new FFTProgram("imag",s,t),h=[{dataId:r.complexTensorInfos.real.dataId,dtype:r.complexTensorInfos.real.dtype,shape:s},{dataId:r.complexTensorInfos.imag.dataId,dtype:r.complexTensorInfos.imag.dtype,shape:s}],u=n.runWebGLProgram(l,h,"float32"),d=n.runWebGLProgram(c,h,"float32"),p=complex({inputs:{real:u,imag:d},backend:n});n.disposeIntermediateTensorInfo(u),n.disposeIntermediateTensorInfo(d);const m=reshape({inputs:{x:p},backend:n,attrs:{shape:e.shape}});return n.disposeIntermediateTensorInfo(o),n.disposeIntermediateTensorInfo(p),m}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function fft(e){const{inputs:t,backend:n}=e,{input:r}=t;return fftImpl(r,!1,n)}const fftConfig={kernelName:FFT,backendName:"webgl",kernelFunc:fft};
/**
     * @license
     * Copyright 2019 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */class FillProgram{constructor(e,t){this.outputShape=[],this.variableNames=["x"],this.outputShape=e,this.userCode="\n      uniform float value;\n      void main() {\n        // Input can be obtained from uniform value.\n        setOutput(value);\n      }\n    "}getCustomSetupFunc(e){return(t,n)=>{null==this.valueLoc&&(this.valueLoc=t.getUniformLocationNoThrow(n,"value")),t.gl.uniform1f(this.valueLoc,e)}}}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function fill(e){const{backend:t,attrs:n}=e,{shape:r,value:i}=n;let{dtype:a}=n;if(a=a||inferDtype(i),"string"===a){const e=getArrayFromDType(a,sizeFromShape(r));return e.fill(i),t.makeTensorInfo(r,a,e)}{const e=new FillProgram(r,i),n=e.getCustomSetupFunc(i);return t.runWebGLProgram(e,[],a,n)}}const fillConfig={kernelName:Fill,backendName:"webgl",kernelFunc:fill};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */class FlipLeftRightProgram{constructor(e){this.variableNames=["Image"],this.outputShape=[];const t=e[2];this.outputShape=e,this.userCode=`\n        void main() {\n          ivec4 coords = getOutputCoords();\n          int x = coords[2];\n\n          int coordX = ${t} - x;\n          float outputValue;\n          if(coordX >= 0 && coordX < ${t}) {\n            outputValue = getImage(coords[0], coords[1], coordX, coords[3]);\n          } else {\n            outputValue = getImage(coords[0], coords[1], coords[2], coords[3]);\n          }\n          setOutput(outputValue);\n        }\n    `}}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */const flipLeftRightConfig={kernelName:FlipLeftRight,backendName:"webgl",kernelFunc:({inputs:e,backend:t})=>{const{image:n}=e,r=t,i=new FlipLeftRightProgram(n.shape);return r.runWebGLProgram(i,[n],n.dtype)}},FLOOR="return floor(x);",floor=unaryKernelFunc({opSnippet:FLOOR,packedOpSnippet:FLOOR,cpuKernelImpl:floorImplCPU}),floorConfig={kernelName:Floor,backendName:"webgl",kernelFunc:floor},INT_DIV="\n  float s = sign(a) * sign(b);\n  int ia = round(a);\n  int ib = round(b);\n  if (ib != 0) {\n    // Windows (D3D) wants guaranteed non-zero int division at compile-time.\n    return float(idiv(ia, ib, s));\n  } else {\n    return NAN;\n  }\n",INT_DIV_PACKED="\n  ivec4 ia = round(a);\n  ivec4 ib = round(b);\n  bvec4 cond = notEqual(ib, ivec4(0));\n  ivec4 result = ivec4(0);\n  vec4 s = sign(a) * sign(b);\n\n  // Windows (D3D) wants guaranteed non-zero int division at compile-time.\n  if (cond[0]) {\n    result[0] = idiv(ia[0], ib[0], s[0]);\n  }\n  if (cond[1]) {\n    result[1] = idiv(ia[1], ib[1], s[1]);\n  }\n  if (cond[2]) {\n    result[2] = idiv(ia[2], ib[2], s[2]);\n  }\n  if (cond[3]) {\n    result[3] = idiv(ia[3], ib[3], s[3]);\n  }\n  return vec4(result);\n",floorDiv=binaryKernelFunc({opSnippet:INT_DIV,packedOpSnippet:INT_DIV_PACKED,dtype:"int32"}),floorDivConfig={kernelName:FloorDiv,backendName:"webgl",kernelFunc:floorDiv};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
/**
     * @license
     * Copyright 2018 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
class FromPixelsProgram{constructor(e){this.variableNames=["A"];const t=getGlslDifferences(),[n,r]=e;this.outputShape=e,this.userCode=`\n      void main() {\n        ivec3 coords = getOutputCoords();\n        int texR = coords[0];\n        int texC = coords[1];\n        int depth = coords[2];\n        vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${r}.0, ${n}.0);\n\n        vec4 values = ${t.texture2D}(A, uv);\n        float value;\n        if (depth == 0) {\n          value = values.r;\n        } else if (depth == 1) {\n          value = values.g;\n        } else if (depth == 2) {\n          value = values.b;\n        } else if (depth == 3) {\n          value = values.a;\n        }\n\n        setOutput(floor(value * 255.0 + 0.5));\n      }\n    `}}
/**
     * @license
     * Copyright 2018 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */class FromPixelsPackedProgram{constructor(e){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0;const t=getGlslDifferences(),[n,r]=e;this.outputShape=e,this.userCode=`\n      void main() {\n        ivec3 coords = getOutputCoords();\n        int texR = coords[0];\n        int texC = coords[1];\n        int depth = coords[2];\n\n        vec4 result = vec4(0.);\n\n        for(int row=0; row<=1; row++) {\n          for(int col=0; col<=1; col++) {\n            texC = coords[1] + row;\n            depth = coords[2] + col;\n\n            vec2 uv = (vec2(texC, texR) + halfCR) /\n                       vec2(${r}.0, ${n}.0);\n            vec4 values = ${t.texture2D}(A, uv);\n            float value;\n            if (depth == 0) {\n              value = values.r;\n            } else if (depth == 1) {\n              value = values.g;\n            } else if (depth == 2) {\n              value = values.b;\n            } else if (depth == 3) {\n              value = values.a;\n            }\n\n            result[row * 2 + col] = floor(value * 255.0 + 0.5);\n          }\n        }\n\n        ${t.output} = result;\n      }\n    `}}
/**
     * @license
     * Copyright 2019 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */const fromPixelsConfig={kernelName:FromPixels,backendName:"webgl",kernelFunc:fromPixels};let fromPixels2DContext;function fromPixels(e){const{inputs:t,backend:n,attrs:r}=e;let{pixels:i}=t;const{numChannels:a}=r,o="undefined"!=typeof HTMLVideoElement&&i instanceof HTMLVideoElement,s="undefined"!=typeof HTMLImageElement&&i instanceof HTMLImageElement,[l,c]=o?[i.videoWidth,i.videoHeight]:[i.width,i.height],h=[c,l],u=[c,l,a];(s||o)&&(null==fromPixels2DContext&&(fromPixels2DContext=document.createElement("canvas").getContext("2d")),fromPixels2DContext.canvas.width=l,fromPixels2DContext.canvas.height=c,fromPixels2DContext.drawImage(i,0,0,l,c),i=fromPixels2DContext.canvas);const d=n.makeTensorInfo(h,"int32");n.texData.get(d.dataId).usage=TextureUsage.PIXELS,n.gpgpu.uploadPixelDataToTexture(n.getTexture(d.dataId),i);const p=env().getBool("WEBGL_PACK")?new FromPixelsPackedProgram(u):new FromPixelsProgram(u),m=n.runWebGLProgram(p,[d],"int32");return n.disposeData(d.dataId),m}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function fusedConv2d(e){const{inputs:t,backend:n,attrs:r}=e,{x:i,filter:a,bias:o,preluActivationWeights:s}=t,{strides:l,pad:c,dataFormat:h,dilations:u,dimRoundingMode:d,activation:p,leakyreluAlpha:m}=r,f=convertConv2DDataFormat(h),g=computeConv2DInfo(i.shape,a.shape,l,u,c,d,!1,f);let v;const y=[];if(1!==g.filterHeight||1!==g.filterWidth||1!==g.dilationHeight||1!==g.dilationWidth||1!==g.strideHeight||1!==g.strideWidth||"SAME"!==g.padInfo.type&&"VALID"!==g.padInfo.type)if(env().getBool("WEBGL_CONV_IM2COL")&&1===i.shape[0])v=conv2dWithIm2Row({x:i,filter:a,convInfo:g,backend:n,bias:o,activation:p,preluActivationWeights:s,leakyreluAlpha:m});else{const e=null!=o,t=null!=s,r="leakyrelu"===p,l=p?mapActivationToShaderProgram(p,!1):null,c=new Conv2DProgram(g,e,l,t,r),h=[i,a];if(o&&h.push(o),s&&h.push(s),r){const e=n.makeTensorInfo([],"float32",createScalarValue(m,"float32"));h.push(e),y.push(e)}v=n.runWebGLProgram(c,h,"float32")}else v=conv2dByMatMul({x:i,filter:a,convInfo:g,backend:n,bias:o,activation:p,preluActivationWeights:s,leakyreluAlpha:m});const _=reshape({inputs:{x:v},backend:n,attrs:{shape:g.outShape}});return y.push(v),y.forEach((e=>n.disposeIntermediateTensorInfo(e))),_}const fusedConv2DConfig={kernelName:FusedConv2D,backendName:"webgl",kernelFunc:fusedConv2d};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function fusedDepthwiseConv2D(e){const{inputs:t,backend:n,attrs:r}=e,{x:i,filter:a,bias:o,preluActivationWeights:s}=t,{strides:l,pad:c,dilations:h,dimRoundingMode:u,activation:d,leakyreluAlpha:p}=r,m=[];let f=h;null==f&&(f=[1,1]),assert$1(eitherStridesOrDilationsAreOne(l,f),(()=>`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${l} and dilations '${f}'`));const g=computeConv2DInfo(i.shape,a.shape,l,f,c,u,!0),v=env().getBool("WEBGL_PACK_DEPTHWISECONV")&&g.strideWidth<=2&&g.outChannels/g.inChannels==1,y=d?mapActivationToShaderProgram(d,v):null,_=[i,a],b=null!=o,x=null!=s,S="leakyrelu"===d;if(b&&_.push(o),x&&_.push(s),S){const e=n.makeTensorInfo([],"float32",createScalarValue(p,"float32"));_.push(e),m.push(e)}let w;w=v?new DepthwiseConvPacked2DProgram(g,b,y,x,S):new DepthwiseConv2DProgram(g,b,y,x,S);const C=n.runWebGLProgram(w,_,"float32");return m.forEach((e=>n.disposeIntermediateTensorInfo(e))),C}const fusedDepthwiseConv2DConfig={kernelName:FusedDepthwiseConv2D,backendName:"webgl",kernelFunc:fusedDepthwiseConv2D};class GatherNDProgram{constructor(e,t,n){this.sliceDim=e,this.strides=t,this.variableNames=["x","indices"],this.outputShape=n;const r=getCoordsDataType(t.length),i=getCoordsDataType(n.length);this.userCode=`\n        ${r} strides = ${r}(${this.strides});\n         void main() {\n          ${i} coords = getOutputCoords();\n          int flattenIndex = 0;\n          for (int j = 0; j < ${this.sliceDim}; j++) {\n            int index = round(getIndices(coords[0], j));\n            flattenIndex += index * ${this.sliceDim>1?"strides[j]":"strides"};\n          }\n          setOutput(getX(flattenIndex, coords[1]));\n        }\n      `}}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function gatherNd(e){const{inputs:t,backend:n}=e,{params:r,indices:i}=t,a=i.shape,o=a[a.length-1],[s,l,c,h]=prepareAndValidate(r,i),u=reshape({inputs:{x:i},backend:n,attrs:{shape:[l,o]}}),d=reshape({inputs:{x:r},backend:n,attrs:{shape:[sizeFromShape(r.shape)/c,c]}}),p=new GatherNDProgram(o,h,[l,c]),m=n.runWebGLProgram(p,[d,u],d.dtype),f=reshape({inputs:{x:m},backend:n,attrs:{shape:s}});return n.disposeIntermediateTensorInfo(u),n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(m),f}const gatherNdConfig={kernelName:GatherNd,backendName:"webgl",kernelFunc:gatherNd};
/**
     * @license
     * Copyright 2017 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */class GatherProgram{constructor(e,t){this.variableNames=["A","indices"],this.outputShape=t,this.rank=t.length;const n=getCoordsDataType(this.rank),r=getSourceCoords$1(e);this.userCode=`\n      void main() {\n        ${n} resRC = getOutputCoords();\n        setOutput(getA(${r}));\n      }\n    `}}function getSourceCoords$1(e,t){const n=["resRC.x","resRC.y","resRC.z","resRC.w"],r=[];for(let t=0;t<e.length;t++)r.push(2===t?"int(getIndices(resRC.x, resRC.z))":`${n[t]}`);return r.join()}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function gatherV2(e){const{inputs:t,backend:n,attrs:r}=e,{x:i,indices:a}=t,{axis:o,batchDims:s}=r,l=collectGatherOpShapeInfo(i,a,parseAxisParam(o,i.shape)[0],s),c=sizeFromShape(a.shape),h=[],u=reshape({inputs:{x:i},backend:n,attrs:{shape:[l.batchSize,l.outerSize,l.dimSize,l.sliceSize]}}),d=reshape({inputs:{x:a},backend:n,attrs:{shape:[l.batchSize,c/l.batchSize]}});h.push(u),h.push(d);const p=[l.batchSize,l.outerSize,c/l.batchSize,l.sliceSize];if(n.shouldExecuteOnCPU([i,a])||"string"===i.dtype){const e=n.bufferSync(d),t=n.bufferSync(u),r=gatherV2ImplCPU(t,e,p);return h.forEach((e=>n.disposeIntermediateTensorInfo(e))),n.makeTensorInfo(l.outputShape,r.dtype,r.values)}const m=new GatherProgram(u.shape,p),f=n.runWebGLProgram(m,[u,d],u.dtype);h.push(f);const g=reshape({inputs:{x:f},backend:n,attrs:{shape:l.outputShape}});return h.forEach((e=>n.disposeIntermediateTensorInfo(e))),g}const gatherV2Config={kernelName:GatherV2,backendName:"webgl",kernelFunc:gatherV2},GREATER="return float(a > b);",GREATER_PACKED="\n  return vec4(greaterThan(a, b));\n",greater=binaryKernelFunc({opSnippet:GREATER,packedOpSnippet:GREATER_PACKED,cpuKernelImpl:greaterImplCPU,dtype:"bool"}),greaterConfig={kernelName:Greater,backendName:"webgl",kernelFunc:greater},GREATER_EQUAL="return float(a >= b);",GREATER_EQUAL_PACKED="\n  return vec4(greaterThanEqual(a, b));\n",greaterEqual=binaryKernelFunc({opSnippet:GREATER_EQUAL,packedOpSnippet:GREATER_EQUAL_PACKED,dtype:"bool"}),greaterEqualConfig={kernelName:GreaterEqual,backendName:"webgl",kernelFunc:greaterEqual};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
function ifft(e){const{inputs:t,backend:n}=e,{input:r}=t;return fftImpl(r,!0,n)}const ifftConfig={kernelName:IFFT,backendName:"webgl",kernelFunc:ifft},IS_FINITE="return float(!isnan(x) && !isinf(x));",isFinite$1=unaryKernelFunc({opSnippet:IS_FINITE,dtype:"bool"}),isFiniteConfig={kernelName:IsFinite,backendName:"webgl",kernelFunc:isFinite$1},IS_INF="return float(isinf(x));",isInf=unaryKernelFunc({opSnippet:IS_INF,dtype:"bool"}),isInfConfig={kernelName:IsInf,backendName:"webgl",kernelFunc:isInf},IS_NAN="return float(isnan(x));",isNaN$1=unaryKernelFunc({opSnippet:IS_NAN,dtype:"bool"}),isNaNConfig={kernelName:IsNan,backendName:"webgl",kernelFunc:isNaN$1},LESS="return float(a < b);",LESS_PACKED="\n  return vec4(lessThan(a, b));\n",less=binaryKernelFunc({opSnippet:LESS,packedOpSnippet:LESS_PACKED,cpuKernelImpl:lessImplCPU,dtype:"bool"}),lessConfig={kernelName:Less,backendName:"webgl",kernelFunc:less},LESS_EQUAL="return float(a <= b);",LESS_EQUAL_PACKED="\n  return vec4(lessThanEqual(a, b));\n",lessEqual=binaryKernelFunc({opSnippet:LESS_EQUAL,packedOpSnippet:LESS_EQUAL_PACKED,dtype:"bool"}),lessEqualConfig={kernelName:LessEqual,backendName:"webgl",kernelFunc:lessEqual};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
function linSpace(e){const{backend:t,attrs:n}=e,{start:r,stop:i,num:a}=n,o=linSpaceImplCPU(r,i,a);return t.makeTensorInfo([o.length],"float32",o)}const linSpaceConfig={kernelName:LinSpace,backendName:"webgl",kernelFunc:linSpace},LOG="if (x < 0.0) return NAN;\n  return log(x);",LOG_PACKED="\n  vec4 result = log(x);\n  vec4 isNaN = vec4(lessThan(x, vec4(0.0)));\n  result.r = isNaN.r == 1.0 ? NAN : result.r;\n  result.g = isNaN.g == 1.0 ? NAN : result.g;\n  result.b = isNaN.b == 1.0 ? NAN : result.b;\n  result.a = isNaN.a == 1.0 ? NAN : result.a;\n\n  return result;\n",log=unaryKernelFunc({opSnippet:LOG,packedOpSnippet:LOG_PACKED,cpuKernelImpl:logImplCPU}),logConfig={kernelName:Log,backendName:"webgl",kernelFunc:log},LOG1P="return log(1.0 + x);",log1p=unaryKernelFunc({opSnippet:LOG1P}),log1pConfig={kernelName:Log1p,backendName:"webgl",kernelFunc:log1p},LOGICAL_AND="return float(a >= 1.0 && b >= 1.0);",LOGICAL_AND_PACKED="\n  return vec4(\n    vec4(greaterThanEqual(a, vec4(1.0))) *\n    vec4(greaterThanEqual(b, vec4(1.0))));\n",logicalAnd=binaryKernelFunc({opSnippet:LOGICAL_AND,packedOpSnippet:LOGICAL_AND_PACKED,dtype:"bool"}),logicalAndConfig={kernelName:LogicalAnd,backendName:"webgl",kernelFunc:logicalAnd},LOGICAL_NOT="return float(!(x >= 1.0));",logicalNot=unaryKernelFunc({opSnippet:LOGICAL_NOT}),logicalNotConfig={kernelName:LogicalNot,backendName:"webgl",kernelFunc:logicalNot},LOGICAL_OR="return float(a >= 1.0 || b >= 1.0);",LOGICAL_OR_PACKED="\n  return min(\n    vec4(greaterThanEqual(a, vec4(1.0))) +\n    vec4(greaterThanEqual(b, vec4(1.0))),\n    vec4(1.0));\n",logicalOr=binaryKernelFunc({opSnippet:LOGICAL_OR,packedOpSnippet:LOGICAL_OR_PACKED,dtype:"bool"}),logicalOrConfig={kernelName:LogicalOr,backendName:"webgl",kernelFunc:logicalOr};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
/**
     * @license
     * Copyright 2017 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
class LRNProgram{constructor(e,t,n,r,i){this.variableNames=["x"],this.outputShape=[];const a=t,o=e[3]-1;let s;this.outputShape=e;const l=`float(${n}) + float(${r}) * sum`;s=.5===i?`inversesqrt(${l})`:1===i?`1.0/(${l})`:`exp(log(${l}) * float(-${i}));`,this.userCode=`\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int b = coords[0];\n        int r = coords[1];\n        int c = coords[2];\n        int d = coords[3];\n        float x = getX(b, r, c, d);\n        float sum = 0.0;\n        for (int j = -${a}; j <= ${a}; j++) {\n          int idx = d + j;\n          if (idx >= 0 && idx <=  ${o}) {\n            float z = getX(b, r, c, idx);\n            sum += z * z;\n          }\n        }\n        float val = x * ${s};\n        setOutput(val);\n      }\n    `}}
/**
     * @license
     * Copyright 2019 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */class LRNPackedProgram{constructor(e,t,n,r,i){this.variableNames=["x"],this.outputShape=[],this.packedInputs=!0,this.packedOutput=!0;const a=t,o=e[3]-1;let s;this.outputShape=e;const l=`float(${n}) + float(${r}) * sum`;s=.5===i?`inversesqrt(${l})`:1===i?`1.0/(${l})`:`exp(log(${l}) * float(-${i}));`,this.userCode=`\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int b = coords.x;\n        int r = coords.y;\n        int c = coords.z;\n        int d = coords.w;\n\n        bool hasNextCol = d < ${this.outputShape[3]};\n        bool hasNextRow = c < ${this.outputShape[2]};\n\n        vec4 sum = vec4(0.);\n        vec4 xFragAtOutputCoords = getX(b, r, c, d);\n\n        vec4 xAtOutputCoords = vec4(\n          getChannel(xFragAtOutputCoords, vec2(c, d)),\n          hasNextCol ?\n            getChannel(xFragAtOutputCoords, vec2(c, d + 1)) : 0.0,\n          hasNextRow ?\n            getChannel(xFragAtOutputCoords , vec2(c + 1, d)) : 0.0,\n          (hasNextRow && hasNextCol) ?\n            getChannel(xFragAtOutputCoords, vec2(c + 1, d + 1)) : 0.0\n        );\n\n        int firstChannel = d - ${a};\n        vec2 cache = vec2(0.);\n        if(firstChannel >= 0){\n          vec4 firstChannelFrag = getX(b, r, c, firstChannel);\n          cache.x = getChannel(firstChannelFrag, vec2(c, firstChannel));\n            if(hasNextRow){\n              cache.y = getChannel(firstChannelFrag, vec2(c + 1, firstChannel));\n            }\n        }\n\n        ivec2 depth = ivec2(d, d + 1);\n        for (int j = - ${a}; j <= ${a}; j++) {\n          ivec2 idx = depth + j;\n          bvec2 aboveLowerBound = greaterThanEqual(idx, ivec2(0));\n          bvec2 belowUpperBound = lessThanEqual(idx, ivec2(${o}));\n\n          bool depthInRange = aboveLowerBound.x && belowUpperBound.x;\n          bool depthPlusOneInRange = aboveLowerBound.y && belowUpperBound.y;\n\n          if(depthInRange || depthPlusOneInRange){\n            vec4 z = vec4(0.);\n            vec4 xFragAtCurrentDepth;\n            z.xz = cache.xy;\n            if(depthPlusOneInRange && hasNextCol){\n              xFragAtCurrentDepth = idx.y != d ?\n                getX(b, r, c, idx.y) : xFragAtOutputCoords;\n              z.y = getChannel(xFragAtCurrentDepth, vec2(c, idx.y));\n              if(hasNextRow){\n                z.w = getChannel(xFragAtCurrentDepth, vec2(c + 1, idx.y));\n              }\n            }\n            cache.xy = z.yw;\n            sum += z * z;\n          }\n        }\n        vec4 result = xAtOutputCoords * ${s};\n        setOutput(result);\n      }\n    `}}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */const lrn=e=>{const{inputs:t,backend:n,attrs:r}=e,{x:i}=t,{depthRadius:a,bias:o,alpha:s,beta:l}=r,c=env().getBool("WEBGL_PACK_NORMALIZATION")?new LRNPackedProgram(i.shape,a,o,s,l):new LRNProgram(i.shape,a,o,s,l);return n.runWebGLProgram(c,[i],i.dtype)},LRNConfig={kernelName:LRN,backendName:"webgl",kernelFunc:lrn};
/**
     * @license
     * Copyright 2018 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
class LRNGradProgram{constructor(e,t,n,r,i){this.variableNames=["inputImage","outputImage","dy"],this.outputShape=[],this.outputShape=e,this.depth=e[3],this.depthRadius=t,this.bias=n,this.alpha=r,this.beta=i,this.userCode=`\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int b = coords[0];\n        int r = coords[1];\n        int c = coords[2];\n\n        float result = 0.0;\n        for (int d = 0; d < ${this.depth}; ++d) {\n          int depthBegin = int(max(0.0, float(d - ${t})));\n          int depthEnd = int(min(float(${this.depth}),\n              float(d + ${t} + 1)));\n\n          const int MIN_DEPTH_BEGIN = 0;\n          const int MAX_DEPTH_END = ${this.depth};\n\n          float norm = 0.0;\n          for (int k = MIN_DEPTH_BEGIN; k < MAX_DEPTH_END; ++k) {\n            if (k < depthBegin){\n              continue;\n            }\n            else if (k >= depthBegin && k < depthEnd) {\n              norm += getInputImage(b, r, c, k) * getInputImage(b, r, c, k);\n            }\n            else {\n              break;\n            }\n          }\n\n          norm = float(${r}) * norm + float(${n});\n\n          for(int k = MIN_DEPTH_BEGIN; k < MAX_DEPTH_END; ++k){\n            if (k < depthBegin){\n              continue;\n            }\n            else if (k >= depthBegin && k < depthEnd){\n              float dyi = -2.0 * float(${r})\n                * float(${i})\n                * getInputImage(b ,r ,c, k) * getOutputImage(b, r, c, d)\n                / norm;\n              if (k == d) {\n                dyi += pow(norm, -1.0 * ${i});\n              }\n              if (k == coords[3]) {\n                dyi *= getDy(b, r, c, d);\n                result += dyi;\n              }\n            }\n            else {\n              break;\n            }\n          }\n      }\n      setOutput(result);\n      }\n    `}}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */const lrnGrad=e=>{const{inputs:t,backend:n,attrs:r}=e,{x:i,y:a,dy:o}=t,{depthRadius:s,bias:l,alpha:c,beta:h}=r,u=new LRNGradProgram(i.shape,s,l,c,h);return n.runWebGLProgram(u,[i,a,o],i.dtype)},LRNGradConfig={kernelName:LRNGrad,backendName:"webgl",kernelFunc:lrnGrad};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
function maxImpl(e,t,n,r){const i=sizeFromShape(t),a=reshape({inputs:{x:e},attrs:{shape:[sizeFromShape(e.shape)/i,i]},backend:r}),o=reduce(a,e.dtype,"max",r),s=reshape({inputs:{x:o},attrs:{shape:n},backend:r});return r.disposeIntermediateTensorInfo(a),r.disposeIntermediateTensorInfo(o),s}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function max(e){const{inputs:t,backend:n,attrs:r}=e,{x:i}=t,{reductionIndices:a,keepDims:o}=r,s=i.shape.length,l=parseAxisParam(a,i.shape);let c=l;const h=getAxesPermutation(c,s),u=null!=h,d=n.shouldExecuteOnCPU([i]);let p=i;if(u){if(d){const e=n.texData.get(p.dataId).values,t=new Array(s);for(let e=0;e<t.length;e++)t[e]=i.shape[h[e]];const r=transposeImplCPU(e,i.shape,i.dtype,h,t);p=n.makeTensorInfo(t,i.dtype);n.texData.get(p.dataId).values=r}else p=transposeImpl(i,h,n);c=getInnerMostAxes(c.length,s)}assertAxesAreInnerMostDims("max",c,s);const[m,f]=computeOutAndReduceShapes(p.shape,c);let g,v=m;if(o&&(v=expandShapeToKeepDim(m,l)),d){const e=n.texData.get(p.dataId),t=maxImplCPU(e.values,sizeFromShape(f),v,i.dtype);g=n.makeTensorInfo(v,i.dtype);n.texData.get(g.dataId).values=t}else g=maxImpl(p,f,v,n);return u&&n.disposeIntermediateTensorInfo(p),g}const maxConfig={kernelName:Max,backendName:"webgl",kernelFunc:max},MAXIMUM=CHECK_NAN_SNIPPET$1+"\n  return max(a, b);\n",MAXIMUM_PACKED="\n  vec4 result = vec4(max(a, b));\n  vec4 isNaN = min(vec4(isnan(a)) + vec4(isnan(b)), vec4(1.0));\n  "+CHECK_NAN_SNIPPET+"\n  return result;\n",maximum=binaryKernelFunc({opSnippet:MAXIMUM,packedOpSnippet:MAXIMUM_PACKED,cpuKernelImpl:maximumImplCPU}),maximumConfig={kernelName:Maximum,backendName:"webgl",kernelFunc:maximum};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
function maxPool(e){const{inputs:t,backend:n,attrs:r}=e,{x:i}=t;assertNotComplex(i,"maxPool");const{filterSize:a,strides:o,pad:s,dimRoundingMode:l}=r;assert$1(eitherStridesOrDilationsAreOne(o,1),(()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${o} and dilations '1'`));const c=computePool2DInfo(i.shape,a,o,1,s,l);if(1===c.filterWidth&&1===c.filterHeight&&arraysEqual$1(c.inShape,c.outShape))return identity$2({inputs:{x:i},backend:n});const h=new Pool2DProgram(c,"max",!1);return n.runWebGLProgram(h,[i],i.dtype)}const maxPoolConfig={kernelName:MaxPool,backendName:"webgl",kernelFunc:maxPool};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function maxPool3d(e){const{inputs:t,backend:n,attrs:r}=e,{x:i}=t,{filterSize:a,strides:o,pad:s,dataFormat:l,dimRoundingMode:c}=r,h=computePool3DInfo(i.shape,a,o,[1,1,1],s,c,l),u=new Pool3DProgram(h,"max",!1);return n.runWebGLProgram(u,[i],i.dtype)}const maxPool3DConfig={kernelName:MaxPool3D,backendName:"webgl",kernelFunc:maxPool3d};
/**
     * @license
     * Copyright 2017 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */class MaxPool2DBackpropProgram{constructor(e){this.variableNames=["dy","maxPos"],this.outputShape=e.inShape;const t=e.effectiveFilterHeight,n=e.effectiveFilterWidth;this.userCode=`\n      const ivec2 pads = ivec2(${t-1-e.padInfo.top}, ${n-1-e.padInfo.left});\n\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int b = coords[0];\n        int d = coords[3];\n\n        ivec2 dyRCCorner = coords.yz - pads;\n        int dyRCorner = dyRCCorner.x;\n        int dyCCorner = dyRCCorner.y;\n\n        // Convolve dy(?, ?, d) with pos mask(:, :, d) to get dx(xR, xC, d).\n        // ? = to be determined. : = across all values in that axis.\n        float dotProd = 0.0;\n        for (int wR = 0; wR < ${t};\n          wR += ${e.dilationHeight}) {\n          float dyR = float(dyRCorner + wR) / ${e.strideHeight}.0;\n\n          if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) {\n            continue;\n          }\n          int idyR = int(dyR);\n\n          for (int wC = 0; wC < ${n}; wC++) {\n            float dyC = float(dyCCorner + wC) / ${e.strideWidth}.0;\n\n            if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||\n                fract(dyC) > 0.0) {\n              continue;\n            }\n            int idyC = int(dyC);\n\n            float dyValue = getDy(b, idyR, idyC, d);\n            int maxPosValue = ${t*n-1} - int(getMaxPos(b, idyR, idyC, d));\n\n            // Get the current value, check it against the value from the\n            // position matrix.\n            int curPosValue = wR * ${n} + wC;\n            float mask = float(maxPosValue == curPosValue ? 1.0 : 0.0);\n\n            dotProd += dyValue * mask;\n          }\n        }\n        setOutput(dotProd);\n      }\n    `}}class MaxPool3DBackpropProgram{constructor(e){this.variableNames=["dy","maxPos"],this.outputShape=e.inShape;const t=e.effectiveFilterDepth,n=e.effectiveFilterHeight,r=e.effectiveFilterWidth;this.userCode=`\n      const ivec3 pads = ivec3(${t-1-e.padInfo.front}, ${n-1-e.padInfo.top}, ${r-1-e.padInfo.left});\n\n      void main() {\n        ivec5 coords = getOutputCoords();\n        int batch = coords.x;\n        int ch = coords.u;\n\n        ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads;\n        int dyDCorner = dyCorner.x;\n        int dyRCorner = dyCorner.y;\n        int dyCCorner = dyCorner.z;\n\n        // Convolve dy(?, ?, ?, ch) with pos mask(:, :, :, d) to get\n        // dx(xD, xR, xC, ch).\n        // ? = to be determined. : = across all values in that axis.\n        float dotProd = 0.0;\n\n        for (int wD = 0; wD < ${t};\n           wD += ${e.dilationDepth}) {\n          float dyD = float(dyDCorner + wD) / ${e.strideDepth}.0;\n\n          if (dyD < 0.0 || dyD >= ${e.outDepth}.0 || fract(dyD) > 0.0) {\n            continue;\n          }\n          int idyD = int(dyD);\n\n          for (int wR = 0; wR < ${n};\n              wR += ${e.dilationHeight}) {\n            float dyR = float(dyRCorner + wR) / ${e.strideHeight}.0;\n\n            if (dyR < 0.0 || dyR >= ${e.outHeight}.0 ||\n                fract(dyR) > 0.0) {\n              continue;\n            }\n            int idyR = int(dyR);\n\n            for (int wC = 0; wC < ${r};\n                wC += ${e.dilationWidth}) {\n              float dyC = float(dyCCorner + wC) / ${e.strideWidth}.0;\n\n              if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||\n                  fract(dyC) > 0.0) {\n                continue;\n              }\n              int idyC = int(dyC);\n\n              float dyValue = getDy(batch, idyD, idyR, idyC, ch);\n              int maxPosValue = ${t*n*r-1} -\n                  int(getMaxPos(batch, idyD, idyR, idyC, ch));\n\n              // Get the current value, check it against the value from the\n              // position matrix.\n              int curPosValue =\n                  wD * ${n} * ${r} +\n                  wR * ${r} + wC;\n              float mask = float(maxPosValue == curPosValue ? 1.0 : 0.0);\n\n              dotProd += dyValue * mask;\n            }\n          }\n        }\n        setOutput(dotProd);\n      }\n    `}}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function maxPool3DGrad(e){const{inputs:t,backend:n,attrs:r}=e,{dy:i,input:a}=t,o=a,{filterSize:s,strides:l,pad:c,dimRoundingMode:h}=r,u=computePool3DInfo(o.shape,s,l,[1,1,1],c,h),d=new Pool3DProgram(u,"max",!0),p=n.runWebGLProgram(d,[o],o.dtype),m=new MaxPool3DBackpropProgram(u),f=n.runWebGLProgram(m,[i,p],o.dtype);return n.disposeIntermediateTensorInfo(p),f}const maxPoolGrad3DConfig={kernelName:MaxPool3DGrad,backendName:"webgl",kernelFunc:maxPool3DGrad};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function maxPoolGrad(e){const{inputs:t,backend:n,attrs:r}=e,{dy:i,input:a,output:o}=t,s=a;assertNotComplex([a,o],"maxPoolGrad");const{filterSize:l,strides:c,pad:h,dimRoundingMode:u}=r,d=computePool2DInfo(s.shape,l,c,1,h,u),p=new Pool2DProgram(d,"max",!0),m=n.runWebGLProgram(p,[s],s.dtype),f=new MaxPool2DBackpropProgram(d),g=n.runWebGLProgram(f,[i,m],s.dtype);return n.disposeIntermediateTensorInfo(m),g}const maxPoolGradConfig={kernelName:MaxPoolGrad,backendName:"webgl",kernelFunc:maxPoolGrad};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function maxPoolWithArgmaxImpl(e,t,n,r){let i=new Pool2DProgram(n,"max",!1);const a=r.runWebGLProgram(i,[e],"float32");i=new Pool2DProgram(n,"max",!0,!0,t);return[a,r.runWebGLProgram(i,[e],"float32")]}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */const maxPoolWithArgmaxConfig={kernelName:MaxPoolWithArgmax,backendName:"webgl",kernelFunc:({inputs:e,attrs:t,backend:n})=>{const{x:r}=e,{filterSize:i,strides:a,pad:o,includeBatchInIndex:s}=t,l=n;assert$1(4===r.shape.length,(()=>`Error in maxPool: input must be rank 4 but got rank ${r.shape.length}.`));const c=[1,1];assert$1(eitherStridesOrDilationsAreOne(a,c),(()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${a} and dilations '${c}'`));const h=computePool2DInfo(r.shape,i,a,c,o),[u,d]=maxPoolWithArgmaxImpl(r,s,h,l);return[u,d]}};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function meanImpl(e,t,n,r){const i=sizeFromShape(t),a=reshape({inputs:{x:e},attrs:{shape:[sizeFromShape(e.shape)/i,i]},backend:r}),o=reduce(a,"float32","mean",r),s=reshape({inputs:{x:o},attrs:{shape:n},backend:r});return r.disposeIntermediateTensorInfo(a),r.disposeIntermediateTensorInfo(o),s}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */const meanConfig={kernelName:Mean,backendName:"webgl",kernelFunc:({inputs:e,attrs:t,backend:n})=>{const{x:r}=e,{keepDims:i,axis:a}=t,o=n,s=r.shape.length,l=parseAxisParam(a,r.shape);let c=l;const h=getAxesPermutation(c,s),u=null!=h,d=o.shouldExecuteOnCPU([r]),p=[];let m=r;if(u){if(d){const e=o.texData.get(m.dataId).values,t=new Array(s);for(let e=0;e<t.length;e++)t[e]=r.shape[h[e]];const n=transposeImplCPU(e,r.shape,r.dtype,h,t);m=o.makeTensorInfo(t,r.dtype);o.texData.get(m.dataId).values=n}else m=transposeImpl(r,h,o);p.push(m),c=getInnerMostAxes(c.length,s)}assertAxesAreInnerMostDims("sum",c,s);const[f,g]=computeOutAndReduceShapes(m.shape,c);let v=f;i&&(v=expandShapeToKeepDim(f,l));const y=meanImpl(m,g,v,o);for(const e of p)o.disposeIntermediateTensorInfo(e);return y}};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function min(e){const{inputs:t,backend:n,attrs:r}=e,{x:i}=t,{axis:a,keepDims:o}=r,s=i.shape.length,l=parseAxisParam(a,i.shape);let c=l;const h=getAxesPermutation(c,s);let u=i;null!=h&&(u=transpose({inputs:{x:i},backend:n,attrs:{perm:h}}),c=getInnerMostAxes(c.length,i.shape.length)),assertAxesAreInnerMostDims("min",c,s);const[d,p]=computeOutAndReduceShapes(u.shape,c),m=reshape({inputs:{x:u},backend:n,attrs:{shape:[-1,sizeFromShape(p)]}}),f=reduce(m,m.dtype,"min",n);let g;if(o){g=reshape({inputs:{x:f},backend:n,attrs:{shape:expandShapeToKeepDim(d,l)}})}else g=reshape({inputs:{x:f},backend:n,attrs:{shape:d}});return n.disposeIntermediateTensorInfo(m),n.disposeIntermediateTensorInfo(f),null!=h&&n.disposeIntermediateTensorInfo(u),g}const minConfig={kernelName:Min,backendName:"webgl",kernelFunc:min},MINIMUM=CHECK_NAN_SNIPPET$1+"\n  return min(a, b);\n",MINIMUM_PACKED="\n  vec4 result = vec4(min(a, b));\n  vec4 isNaN = min(vec4(isnan(a)) + vec4(isnan(b)), vec4(1.0));\n  "+CHECK_NAN_SNIPPET+"\n  return result;\n",minimum=binaryKernelFunc({opSnippet:MINIMUM,packedOpSnippet:MINIMUM_PACKED,cpuKernelImpl:minimumImplCPU}),minimumConfig={kernelName:Minimum,backendName:"webgl",kernelFunc:minimum};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
class MirrorPadProgram{constructor(e,t,n){this.variableNames=["x"],this.outputShape=t.map(((t,n)=>t[0]+e[n]+t[1]));const r=e.length,i=getCoordsDataType(r),a=t.map((e=>e[0])).join(","),o=t.map(((t,n)=>t[0]+e[n])).join(","),s=["coords[0]","coords[1]","coords[2]","coords[3]"].slice(0,r),l="reflect"===n?0:1;this.userCode=1!==r?`\n      ${i} start = ${i}(${a});\n      ${i} end = ${i}(${o});\n\n      void main() {\n        ${i} outC = getOutputCoords();\n        for (int i = 0; i < ${r}; i++) {\n          if (outC[i] < start[i]) {\n            outC[i] = start[i] * 2 - outC[i] - ${l};\n          } else if(outC[i] >= end[i]) {\n            outC[i] = (end[i] - 1) * 2 - outC[i] + ${l};\n          }\n        }\n        ${i} coords = outC - start;\n        setOutput(getX(${s}));\n      }\n    `:`\n        int start = ${a};\n        int end = ${o};\n\n        void main() {\n          int outC = getOutputCoords();\n          if (outC < start) {\n            outC = start * 2 - outC - ${l};\n          } else if(outC >= end) {\n            outC = (end - 1) * 2 - outC + ${l};\n          }\n          setOutput(getX(outC - start));\n        }\n      `}}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */class MirrorPadPackedProgram{constructor(e,t,n){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t.map(((t,n)=>t[0]+e[n]+t[1]));const r=e.length,i=getCoordsDataType(r),a=t.map((e=>e[0])).join(","),o=t.map(((t,n)=>t[0]+e[n])).join(","),s=getChannels("rc",r),l=getChannels("source",r),c=`${s[r-1]} < ${this.outputShape[r-1]}`,h=1===r?"source":`vec2(${l.slice(-2).join()})`,u="reflect"===n?0:1;let d="";if(1===r){const e=`\n        ${i} source = rc;\n        if (source < start) {\n          source = start * 2 - source - ${u};\n        } else if (source >= end) {\n          source = (end - 1) * 2 - source + ${u};\n        }\n        source -= start;\n      `;d=`\n        ${i} rc = outputLoc;\n        ${e}\n        result[0] = getChannel(getX(${l.join()}), ${h});\n        ${s[r-1]} += 1;\n        if(${c}) {\n          ${e}\n          result[1] = getChannel(getX(${l.join()}), ${h});\n        }\n      `}else{const e=`\n        ${i} source = rc;\n        ${i} lt = ${i}(lessThan(source, start));\n        ${i} gte = ${i}(greaterThanEqual(source, end));\n        ${i} orig = 1 - (lt + gte);\n        source = orig * source +\n                lt * (start * 2 - source - ${u}) +\n                gte * ((end - 1) * 2 - source + ${u});\n        source -= start;\n      `;d=`\n        ${i} rc = outputLoc;\n        ${e}\n        result[0] = getChannel(getX(${l.join()}), ${h});\n        ${s[r-1]} += 1;\n        if(${c}) {\n          ${e}\n          result[1] = getChannel(getX(${l.join()}), ${h});\n        }\n        rc = outputLoc;\n        ${s[r-2]} += 1;\n        if(${s[r-2]} < ${this.outputShape[r-2]}) {\n          ${e}\n          result[2] = getChannel(getX(${l.join()}), ${h});\n          ${s[r-1]} += 1;\n          if(${c}) {\n            ${e}\n            result[3] = getChannel(getX(${l.join()}), ${h});\n          }\n        }\n      `}this.userCode=`\n      const ${i} start = ${i}(${a});\n      const ${i} end = ${i}(${o});\n\n      void main() {\n        ${i} outputLoc = getOutputCoords();\n        vec4 result = vec4(0.);\n        ${d}\n        setOutput(result);\n      }\n    `}}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */const mirrorPadKernelFunc=({inputs:e,backend:t,attrs:n})=>{const{x:r}=e,{paddings:i,mode:a}=n,o=env().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new MirrorPadPackedProgram(r.shape,i,a):new MirrorPadProgram(r.shape,i,a);return t.runWebGLProgram(o,[r],r.dtype)},mirrorPadConfig={kernelName:MirrorPad,backendName:"webgl",kernelFunc:mirrorPadKernelFunc},MOD="if (b == 0.0) return NAN;\n  return mod(a, b);",MOD_PACKED="\n  vec4 result = mod(a, b);\n  vec4 isNaN = vec4(equal(b, vec4(0.0)));\n  "+CHECK_NAN_SNIPPET+"\n  return result;\n",mod=binaryKernelFunc({opSnippet:MOD,packedOpSnippet:MOD_PACKED}),modConfig={kernelName:Mod,backendName:"webgl",kernelFunc:mod};
/**
     * @license
     * Copyright 2017 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
class MultinomialProgram{constructor(e,t,n){this.variableNames=["probs"],this.outputShape=[e,n],this.userCode=`\n      uniform float seed;\n\n      void main() {\n        ivec2 coords = getOutputCoords();\n        int batch = coords[0];\n\n        float r = random(seed);\n        float cdf = 0.0;\n\n        for (int i = 0; i < ${t-1}; i++) {\n          cdf += getProbs(batch, i);\n\n          if (r < cdf) {\n            setOutput(float(i));\n            return;\n          }\n        }\n\n        // If no other event happened, last event happened.\n        setOutput(float(${t-1}));\n      }\n    `}getCustomSetupFunc(e){return(t,n)=>{null==this.seedLoc&&(this.seedLoc=t.getUniformLocation(n,"seed")),t.gl.uniform1f(this.seedLoc,e)}}}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */const DIV="\nif (a == b) {\n  return 1.0;\n};\nreturn a / b;",DIV_PACKED="\n  // vec4 one = vec4(equal(a, b));\n  // return one + (vec4(1.0) - one) * a / b;\n  vec4 result = a / b;\n  if(a.x == b.x) {\n    result.x = 1.;\n  }\n  if(a.y == b.y) {\n    result.y = 1.;\n  }\n  if(a.z == b.z) {\n    result.z = 1.;\n  }\n  if(a.w == b.w) {\n    result.w = 1.;\n  }\n\n  return result;\n",realDiv=binaryKernelFunc({opSnippet:DIV,packedOpSnippet:DIV_PACKED,checkOutOfBounds:!0}),realDivConfig={kernelName:RealDiv,backendName:"webgl",kernelFunc:realDiv},SUB="return a - b;",sub$1=binaryKernelFunc({opSnippet:SUB,packedOpSnippet:SUB,supportsComplex:!0,cpuKernelImpl:subImplCPU}),subConfig={kernelName:Sub,backendName:"webgl",kernelFunc:sub$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
function softmax(e){const{inputs:t,backend:n,attrs:r}=e,{logits:i}=t,{dim:a}=r,o=parseAxisParam([a],i.shape),s=max({inputs:{x:i},backend:n,attrs:{reductionIndices:o,keepDims:!1}}),l=expandShapeToKeepDim(s.shape,o),c=reshape({inputs:{x:s},backend:n,attrs:{shape:l}}),h=sub$1({inputs:{a:i,b:c},backend:n}),u=exp({inputs:{x:h},backend:n}),d=sum({inputs:{x:u},backend:n,attrs:{axis:o,keepDims:!1}}),p=reshape({inputs:{x:d},backend:n,attrs:{shape:l}}),m=realDiv({inputs:{a:u,b:p},backend:n});return n.disposeIntermediateTensorInfo(s),n.disposeIntermediateTensorInfo(c),n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(u),n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(p),m}const softmaxConfig={kernelName:Softmax,backendName:"webgl",kernelFunc:softmax};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function multinomial(e){const{inputs:t,backend:n,attrs:r}=e,{logits:i}=t,{numSamples:a,seed:o,normalized:s}=r,l=s?i:softmax({inputs:{logits:i},backend:n,attrs:{dim:i.shape.length-1}}),c=new MultinomialProgram(l.shape[0],l.shape[1],a),h=c.getCustomSetupFunc(o),u=n.runWebGLProgram(c,[l],"int32",h);return s||n.disposeIntermediateTensorInfo(l),u}const multinomialConfig={kernelName:Multinomial,backendName:"webgl",kernelFunc:multinomial},NEG="return -x;";
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function neg(e){const{inputs:t,backend:n}=e,{x:r}=t;if(n.shouldExecuteOnCPU([r])){const e=n.texData.get(r.dataId),[t,i]=negImplCPU(e.values,r.shape,r.dtype);return n.makeTensorInfo(i,r.dtype,t)}let i;return i=env().getBool("WEBGL_PACK_UNARY_OPERATIONS")?new UnaryOpPackedProgram(r.shape,NEG):new UnaryOpProgram(r.shape,NEG),n.runWebGLProgram(i,[r],r.dtype)}const negConfig={kernelName:Neg,backendName:"webgl",kernelFunc:neg},nonMaxSuppressionV3Impl=nonMaxSuppressionV3Impl$2;
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function nonMaxSuppressionV3(e){warn("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");const{inputs:t,backend:n,attrs:r}=e,{boxes:i,scores:a}=t,{maxOutputSize:o,iouThreshold:s,scoreThreshold:l}=r,c=n.readSync(i.dataId),h=n.readSync(a.dataId),{selectedIndices:u}=nonMaxSuppressionV3Impl(c,h,o,s,l);return n.makeTensorInfo([u.length],"int32",new Int32Array(u))}const nonMaxSuppressionV3Config={kernelName:NonMaxSuppressionV3,backendName:"webgl",kernelFunc:nonMaxSuppressionV3},nonMaxSuppressionV4Impl=nonMaxSuppressionV4Impl$2;
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function nonMaxSuppressionV4(e){warn("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");const{inputs:t,backend:n,attrs:r}=e,{boxes:i,scores:a}=t,{maxOutputSize:o,iouThreshold:s,scoreThreshold:l,padToMaxOutputSize:c}=r,h=n.readSync(i.dataId),u=n.readSync(a.dataId),{selectedIndices:d,validOutputs:p}=nonMaxSuppressionV4Impl(h,u,o,s,l,c);return[n.makeTensorInfo([d.length],"int32",new Int32Array(d)),n.makeTensorInfo([],"int32",new Int32Array([p]))]}const nonMaxSuppressionV4Config={kernelName:NonMaxSuppressionV4,backendName:"webgl",kernelFunc:nonMaxSuppressionV4},nonMaxSuppressionV5Impl=nonMaxSuppressionV5Impl$2;
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function nonMaxSuppressionV5(e){warn("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");const{inputs:t,backend:n,attrs:r}=e,{boxes:i,scores:a}=t,{maxOutputSize:o,iouThreshold:s,scoreThreshold:l,softNmsSigma:c}=r,h=n.readSync(i.dataId),u=n.readSync(a.dataId),d=o,p=s,m=l,f=c,{selectedIndices:g,selectedScores:v}=nonMaxSuppressionV5Impl(h,u,d,p,m,f);return[n.makeTensorInfo([g.length],"int32",new Int32Array(g)),n.makeTensorInfo([v.length],"float32",new Float32Array(v))]}const nonMaxSuppressionV5Config={kernelName:NonMaxSuppressionV5,backendName:"webgl",kernelFunc:nonMaxSuppressionV5};
/**
     * @license
     * Copyright 2017 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */class OneHotProgram{constructor(e,t,n,r){this.variableNames=["indices"],this.outputShape=[e,t],this.userCode=`\n      void main() {\n        ivec2 coords = getOutputCoords();\n        int index = round(getIndices(coords.x));\n        setOutput(mix(float(${r}), float(${n}),\n                      float(index == coords.y)));\n      }\n    `}}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */const oneHot=e=>{const{inputs:t,backend:n,attrs:r}=e,{indices:i}=t,{depth:a,onValue:o,offValue:s}=r,l=sizeFromShape(i.shape),c=new OneHotProgram(l,a,o,s),h=reshape({inputs:{x:i},backend:n,attrs:{shape:[l]}}),u=n.runWebGLProgram(c,[h],i.dtype);n.disposeIntermediateTensorInfo(h);const d=reshape({inputs:{x:u},backend:n,attrs:{shape:[...i.shape,a]}});return n.disposeIntermediateTensorInfo(u),d},oneHotConfig={kernelName:OneHot,backendName:"webgl",kernelFunc:oneHot};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
function zerosLike(e){const{inputs:t,backend:n}=e,{x:r}=t;if("complex64"===r.dtype){const e=real({inputs:{input:r},backend:n}),t=zerosLike({inputs:{x:e},backend:n}),i=imag({inputs:{input:r},backend:n}),a=zerosLike({inputs:{x:i},backend:n}),o=complex({inputs:{real:t,imag:a},backend:n});return n.disposeIntermediateTensorInfo(e),n.disposeIntermediateTensorInfo(t),n.disposeIntermediateTensorInfo(i),n.disposeIntermediateTensorInfo(a),o}return fill({attrs:{shape:r.shape,dtype:r.dtype,value:"string"===r.dtype?"":0},backend:n})}const zerosLikeConfig={kernelName:ZerosLike,backendName:"webgl",kernelFunc:zerosLike};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function onesLike(e){const{inputs:t,backend:n}=e,{x:r}=t;if("string"===r.dtype)throw new Error("onesLike is not supported under string dtype");if("complex64"===r.dtype){const e=real({inputs:{input:r},backend:n}),t=onesLike({inputs:{x:e},backend:n}),i=imag({inputs:{input:r},backend:n}),a=zerosLike({inputs:{x:i},backend:n}),o=complex({inputs:{real:t,imag:a},backend:n});return n.disposeIntermediateTensorInfo(e),n.disposeIntermediateTensorInfo(t),n.disposeIntermediateTensorInfo(i),n.disposeIntermediateTensorInfo(a),o}return fill({attrs:{shape:r.shape,dtype:r.dtype,value:1},backend:n})}const onesLikeConfig={kernelName:OnesLike,backendName:"webgl",kernelFunc:onesLike};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function pack(e){const{inputs:t,backend:n,attrs:r}=e,{axis:i}=r;if(1===t.length)return expandDims({inputs:{input:t[0]},backend:n,attrs:{dim:i}});const a=t[0].shape,o=t[0].dtype;t.forEach((e=>{assertShapesMatch(a,e.shape,"All tensors passed to stack must have matching shapes"),assert$1(o===e.dtype,(()=>"All tensors passed to stack must have matching dtypes"))}));const s=[],l=concat({inputs:t.map((e=>{const t=expandDims({inputs:{input:e},backend:n,attrs:{dim:i}});return s.push(t),t})),backend:n,attrs:{axis:i}});return s.forEach((e=>n.disposeIntermediateTensorInfo(e))),l}const packConfig={kernelName:Pack,backendName:"webgl",kernelFunc:pack};
/**
     * @license
     * Copyright 2017 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */class PadProgram{constructor(e,t,n){this.variableNames=["x"],this.outputShape=t.map(((t,n)=>t[0]+e[n]+t[1]));const r=e.length,i=getCoordsDataType(r),a=t.map((e=>e[0])).join(","),o=t.map(((t,n)=>t[0]+e[n])).join(","),s=["coords[0]","coords[1]","coords[2]","coords[3]"].slice(0,r);this.userCode=1!==r?`\n      ${i} start = ${i}(${a});\n      ${i} end = ${i}(${o});\n      uniform float value;\n\n      void main() {\n        ${i} outC = getOutputCoords();\n        if (any(lessThan(outC, start)) || any(greaterThanEqual(outC, end))) {\n          setOutput(value);\n        } else {\n          ${i} coords = outC - start;\n          setOutput(getX(${s}));\n        }\n      }\n    `:`\n        int start = ${a};\n        int end = ${o};\n        uniform float value;\n\n        void main() {\n          int outC = getOutputCoords();\n          if (outC < start || outC >= end) {\n            setOutput(value);\n          } else {\n            setOutput(getX(outC - start));\n          }\n        }\n      `}getCustomSetupFunc(e){return(t,n)=>{null==this.valueLoc&&(this.valueLoc=t.getUniformLocationNoThrow(n,"value")),t.gl.uniform1f(this.valueLoc,e)}}}
/**
     * @license
     * Copyright 2019 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */class PadPackedProgram{constructor(e,t,n){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t.map(((t,n)=>t[0]+e[n]+t[1]));const r=e.length,i=getCoordsDataType(r),a=t.map((e=>e[0])).join(","),o=t.map(((t,n)=>t[0]+e[n])).join(","),s=getChannels("rc",r),l=getChannels("source",r),c=`${s[r-1]} < ${this.outputShape[r-1]}`,h=1===r?"source":`vec2(${l.slice(-2).join()})`,u=[`${i} rc = outputLoc;`,`${s[r-1]} += 1;\n       if(${c}) {\n      `,1===r?"":`}\n       rc = outputLoc;\n       ${s[r-2]} += 1;\n       if(${s[r-2]} < ${this.outputShape[r-2]}) {`,1===r?"":`  ${s[r-1]} += 1;\n         if(${c}) {`],d=1===r?"rc < start || rc >= end":"any(lessThan(rc, start)) || any(greaterThanEqual(rc, end))";let p="";for(let e=0,t=1===r?2:4;e<t;e++)p+=`\n        ${u[e]}\n        if (${d}) {\n          result[${e}] = float(value);\n        } else {\n          ${i} source = rc - start;\n          result[${e}] = getChannel(getX(${l.join()}), ${h});\n        }\n      `;p+=1===r?"} ":"}}",this.userCode=`\n      const ${i} start = ${i}(${a});\n      const ${i} end = ${i}(${o});\n      uniform float value;\n\n      void main() {\n        ${i} outputLoc = getOutputCoords();\n        vec4 result = vec4(0.);\n        ${p}\n        setOutput(result);\n      }\n    `}getCustomSetupFunc(e){return(t,n)=>{null==this.valueLoc&&(this.valueLoc=t.getUniformLocationNoThrow(n,"value")),t.gl.uniform1f(this.valueLoc,e)}}}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */const padV2=e=>{const{inputs:t,backend:n,attrs:r}=e,{x:i}=t,{paddings:a,constantValue:o}=r,s=env().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new PadPackedProgram(i.shape,a,o):new PadProgram(i.shape,a,o),l=s.getCustomSetupFunc(o);return n.runWebGLProgram(s,[i],i.dtype,l)},padV2Config={kernelName:PadV2,backendName:"webgl",kernelFunc:padV2},POW="\n  if(a < 0.0 && floor(b) < b){\n    return NAN;\n  }\n  if (b == 0.0) {\n    return 1.0;\n  }\n  return (round(mod(b, 2.0)) != 1) ?\n      pow(abs(a), b) : sign(a) * pow(abs(a), b);\n",POW_PACKED="\n  // isModRound1 has 1 for components with round(mod(b, 2.0)) == 1, 0 otherwise.\n  vec4 isModRound1 = vec4(equal(round(mod(b, 2.0)), ivec4(1)));\n  vec4 multiplier = sign(a) * isModRound1 + (vec4(1.0) - isModRound1);\n  vec4 result = multiplier * pow(abs(a), b);\n\n  // Ensure that a^0 = 1, including 0^0 = 1 as this correspond to TF and JS\n  bvec4 isExpZero = equal(b, vec4(0.0));\n  result.r = isExpZero.r ? 1.0 : result.r;\n  result.g = isExpZero.g ? 1.0 : result.g;\n  result.b = isExpZero.b ? 1.0 : result.b;\n  result.a = isExpZero.a ? 1.0 : result.a;\n\n  vec4 isNaN = vec4(lessThan(a, vec4(0.0))) * vec4(lessThan(floor(b), b));\n  "+CHECK_NAN_SNIPPET+"\n  return result;\n",pow$1=binaryKernelFunc({opSnippet:POW,packedOpSnippet:POW_PACKED}),powConfig={kernelName:Pow,backendName:"webgl",kernelFunc:pow$1};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
function prod(e){const{inputs:t,backend:n,attrs:r}=e,{x:i}=t,{axis:a,keepDims:o}=r,s=i.shape.length,l=[],c=parseAxisParam(a,i.shape);let h=c;const u=getAxesPermutation(h,s);let d,p=i;if(null!=u&&(p=transpose({inputs:{x:i},backend:n,attrs:{perm:u}}),h=getInnerMostAxes(h.length,s),l.push(p)),assertAxesAreInnerMostDims("prod",h,s),n.shouldExecuteOnCPU([p])){const e=n.texData.get(p.dataId).values,{outVals:t,outShape:r,outDtype:i}=prodImplCPU(p.shape,p.dtype,e,h);d=n.makeTensorInfo(r,i,t)}else{const[e,t]=computeOutAndReduceShapes(p.shape,h),r=sizeFromShape(t),a=reshape({inputs:{x:p},backend:n,attrs:{shape:[-1,r]}}),o=reduce(a,sumOutType(i.dtype),"prod",n);d=reshape({inputs:{x:o},backend:n,attrs:{shape:e}}),l.push(a),l.push(o)}if(o){l.push(d);const e=expandShapeToKeepDim(d.shape,c);d=reshape({inputs:{x:d},backend:n,attrs:{shape:e}})}return l.forEach((e=>n.disposeIntermediateTensorInfo(e))),d}const prodConfig={kernelName:Prod,backendName:"webgl",kernelFunc:prod},range$1=e=>{const{backend:t,attrs:n}=e,{start:r,stop:i,step:a,dtype:o}=n,s=rangeImplCPU(r,i,a,o);return t.makeTensorInfo([s.length],o,s)},rangeConfig={kernelName:Range,backendName:"webgl",kernelFunc:range$1},RECIPROCAL="return 1.0 / x;",reciprocal=unaryKernelFunc({opSnippet:RECIPROCAL}),reciprocalConfig={kernelName:Reciprocal,backendName:"webgl",kernelFunc:reciprocal},RELU=CHECK_NAN_SNIPPET$2+"\n  return (x < 0.0) ? 0.0 : x;\n",RELU_PACKED="\n  vec4 result = x * vec4(greaterThanEqual(x, vec4(0.0)));\n  bvec4 isNaN = isnan(x);\n\n  result.r = isNaN.r ? x.r : result.r;\n  result.g = isNaN.g ? x.g : result.g;\n  result.b = isNaN.b ? x.b : result.b;\n  result.a = isNaN.a ? x.a : result.a;\n\n  return result;\n",relu=unaryKernelFunc({opSnippet:RELU,packedOpSnippet:RELU_PACKED}),reluConfig={kernelName:Relu,backendName:"webgl",kernelFunc:relu},RELU6=CHECK_NAN_SNIPPET$2+"\n  return (x < 0.0) ? 0.0 : min(6.0, x);\n",RELU6_PACKED="\n  vec4 result = min(x, vec4(6.)) * vec4(greaterThanEqual(x, vec4(0.0)));\n  bvec4 isNaN = isnan(x);\n\n  result.r = isNaN.r ? x.r : result.r;\n  result.g = isNaN.g ? x.g : result.g;\n  result.b = isNaN.b ? x.b : result.b;\n  result.a = isNaN.a ? x.a : result.a;\n\n  return result;\n",relu6=unaryKernelFunc({opSnippet:RELU6,packedOpSnippet:RELU6_PACKED}),relu6Config={kernelName:Relu6,backendName:"webgl",kernelFunc:relu6};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
/**
     * @license
     * Copyright 2017 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
class ResizeBilinearProgram{constructor(e,t,n,r,i){this.variableNames=["A"],this.outputShape=[];const[a,o,s,l]=e;this.outputShape=[a,t,n,l];const c=[r&&t>1?o-1:o,r&&n>1?s-1:s],h=[r&&t>1?t-1:t,r&&n>1?n-1:n];let u;u=i?"(vec2(yRC) + vec2(0.5)) * effectiveInputOverOutputRatioRC - vec2(0.5)":"vec2(yRC) * effectiveInputOverOutputRatioRC",this.userCode=`\n      const vec2 effectiveInputOverOutputRatioRC = vec2(\n          ${c[0]/h[0]},\n          ${c[1]/h[1]});\n      const vec2 inputShapeRC = vec2(${o}.0, ${s}.0);\n\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int b = coords[0];\n        int d = coords[3];\n        ivec2 yRC = coords.yz;\n\n        // Fractional source index.\n        vec2 sourceFracIndexRC = ${u};\n\n        // Compute the four integer indices.\n        ivec2 sourceFloorRC = ivec2(max(sourceFracIndexRC, vec2(0.0)));\n        ivec2 sourceCeilRC = ivec2(\n          min(inputShapeRC - 1.0, ceil(sourceFracIndexRC)));\n\n        float topLeft = getA(b, sourceFloorRC.x, sourceFloorRC.y, d);\n        float bottomLeft = getA(b, sourceCeilRC.x, sourceFloorRC.y, d);\n        float topRight = getA(b, sourceFloorRC.x, sourceCeilRC.y, d);\n        float bottomRight = getA(b, sourceCeilRC.x, sourceCeilRC.y, d);\n\n        vec2 fracRC = sourceFracIndexRC - vec2(sourceFloorRC);\n\n        float top = topLeft + (topRight - topLeft) * fracRC.y;\n        float bottom = bottomLeft + (bottomRight - bottomLeft) * fracRC.y;\n        float newValue = top + (bottom - top) * fracRC.x;\n\n        setOutput(newValue);\n      }\n    `}}
/**
     * @license
     * Copyright 2019 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */class ResizeBilinearPackedProgram{constructor(e,t,n,r,i){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[];const[a,o,s,l]=e;this.outputShape=[a,t,n,l];const c=[r&&t>1?o-1:o,r&&n>1?s-1:s],h=[r&&t>1?t-1:t,r&&n>1?n-1:n];let u;u=i?"(vec3(yRC) + vec3(0.5)) * effectiveInputOverOutputRatioRC - vec3(0.5)":"vec3(yRC) * effectiveInputOverOutputRatioRC",this.userCode=`\n      const vec3 effectiveInputOverOutputRatioRC = vec3(\n          ${c[0]/h[0]},\n          ${c[1]/h[1]},\n          ${c[1]/h[1]});\n      const vec3 inputShapeRC = vec3(${o}.0, ${s}.0,\n                                     ${s}.0);\n\n      float getAValue(int b, int r, int c, int d) {\n        return getChannel(getA(b, r, c, d), vec2(c, d));\n      }\n\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int b = coords[0];\n        int d = coords[3];\n        // Calculate values for next column in yRC.z.\n        ivec3 yRC = coords.yzz + ivec3(0, 0, 1);\n\n        // Fractional source index.\n        vec3 sourceFracIndexRC = ${u};\n\n        // Compute the four integer indices.\n        ivec3 sourceFloorRC = ivec3(max(sourceFracIndexRC, vec3(0.0)));\n        ivec3 sourceCeilRC = ivec3(\n          min(inputShapeRC - 1.0, ceil(sourceFracIndexRC)));\n\n        // Should we calculate next column and row elements in 2x2 packed cell.\n        bool hasNextCol = d < ${l-1};\n        bool hasNextRow = coords.z < ${n-1};\n\n        // In parallel, construct four corners for all four components in\n        // packed 2x2 cell.\n        vec4 topLeft = vec4(\n          getAValue(b, sourceFloorRC.x, sourceFloorRC.y, d),\n          hasNextCol ? getAValue(b, sourceFloorRC.x, sourceFloorRC.y, d + 1)\n                     : 0.0,\n          hasNextRow ? getAValue(b, sourceFloorRC.x, sourceFloorRC.z, d)\n                     : 0.0,\n          (hasNextRow && hasNextCol) ?\n            getAValue(b, sourceFloorRC.x, sourceFloorRC.z, d + 1) : 0.0);\n\n        vec4 bottomLeft = vec4(\n          getAValue(b, sourceCeilRC.x, sourceFloorRC.y, d),\n          hasNextCol ? getAValue(b, sourceCeilRC.x, sourceFloorRC.y, d + 1)\n                     : 0.0,\n          hasNextRow ? getAValue(b, sourceCeilRC.x, sourceFloorRC.z, d)\n                     : 0.0,\n          (hasNextRow && hasNextCol) ?\n            getAValue(b, sourceCeilRC.x, sourceFloorRC.z, d + 1) : 0.0);\n\n        vec4 topRight = vec4(\n          getAValue(b, sourceFloorRC.x, sourceCeilRC.y, d),\n          hasNextCol ? getAValue(b, sourceFloorRC.x, sourceCeilRC.y, d + 1)\n                     : 0.0,\n          hasNextRow ? getAValue(b, sourceFloorRC.x, sourceCeilRC.z, d)\n                     : 0.0,\n          (hasNextRow && hasNextCol) ?\n            getAValue(b, sourceFloorRC.x, sourceCeilRC.z, d + 1) : 0.0);\n\n        vec4 bottomRight = vec4(\n          getAValue(b, sourceCeilRC.x, sourceCeilRC.y, d),\n          hasNextCol ? getAValue(b, sourceCeilRC.x, sourceCeilRC.y, d + 1)\n                     : 0.0,\n          hasNextRow ? getAValue(b, sourceCeilRC.x, sourceCeilRC.z, d)\n                     : 0.0,\n          (hasNextRow && hasNextCol) ?\n            getAValue(b, sourceCeilRC.x, sourceCeilRC.z, d + 1) : 0.0);\n\n        vec3 fracRC = sourceFracIndexRC - vec3(sourceFloorRC);\n\n        vec4 top = mix(topLeft, topRight, fracRC.yyzz);\n        vec4 bottom = mix(bottomLeft, bottomRight, fracRC.yyzz);\n        vec4 newValue = mix(top, bottom, fracRC.x);\n\n        setOutput(newValue);\n      }\n    `}}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function resizeBilinear(e){const{inputs:t,backend:n,attrs:r}=e,{images:i}=t,{alignCorners:a,halfPixelCenters:o,size:s}=r,[l,c]=s,h=env().getBool("WEBGL_PACK_IMAGE_OPERATIONS")?new ResizeBilinearPackedProgram(i.shape,l,c,a,o):new ResizeBilinearProgram(i.shape,l,c,a,o);return n.runWebGLProgram(h,[i],"float32")}const resizeBilinearConfig={kernelName:ResizeBilinear,backendName:"webgl",kernelFunc:resizeBilinear};
/**
     * @license
     * Copyright 2018 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */class ResizeBilinearBackpropProgram{constructor(e,t,n){this.variableNames=["dy"],this.outputShape=[],this.outputShape=t;const[,r,i]=t,[,a,o]=e,s=[n&&a>1?r-1:r,n&&o>1?i-1:i],l=[n&&a>1?a-1:a,n&&o>1?o-1:o],c=s[0]/l[0],h=s[1]/l[1],u=1/c,d=1/h,p=2*Math.ceil(u)+2,m=2*Math.ceil(d)+2;this.userCode=`\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int b = coords[0];\n        int d = coords[3];\n        int r = coords[1];\n        int c = coords[2];\n\n        float accumulator = 0.0;\n\n        const float heightScale = float(${c});\n        const float widthScale = float(${h});\n\n        const float invHeightScale = float(${u});\n        const float invWidthScale = float(${d});\n\n        const int winHeight = int(${p});\n        const int winWidth = int(${m});\n\n        // Compute bounds for where in dy we will look\n        float startRLerp = floor(float(r) * invHeightScale);\n        int startDyR = int(startRLerp - float(winHeight / 2));\n\n        float startCLerp = floor(float(c) * invWidthScale);\n        int startDyC = int(startCLerp - float(winWidth / 2));\n\n        // Loop over dy\n        for (int dyROffset = 0; dyROffset < winHeight; dyROffset++) {\n          int dyR = dyROffset + startDyR;\n\n          // Guard against the window exceeding the bounds of dy\n          if (dyR < 0 || dyR >= ${a}) {\n            continue;\n          }\n\n          for (int dyCOffset = 0; dyCOffset < winWidth; dyCOffset++) {\n            int dyC = dyCOffset + startDyC;\n\n            // Guard against the window exceeding the bounds of dy\n            if (dyC < 0 || dyC >= ${o}) {\n              continue;\n            }\n\n            float dxR = float(dyR) * heightScale;\n            int topDxRIndex = int(floor(dxR));\n            int bottomDxRIndex = int(min(ceil(dxR), ${r-1}.0));\n            float dxRLerp = dxR - float(topDxRIndex);\n            float inverseDxRLerp = 1.0 - dxRLerp;\n\n            float dxC = float(dyC) * widthScale;\n            int leftDxCIndex = int(floor(dxC));\n            int rightDxCIndex = int(min(ceil(dxC), ${i-1}.0));\n            float dxCLerp = dxC - float(leftDxCIndex);\n            float inverseDxCLerp = 1.0 - dxCLerp;\n\n            if (r == topDxRIndex && c == leftDxCIndex) {\n              // topLeft\n              accumulator +=\n                getDy(b, dyR, dyC, d) * inverseDxRLerp * inverseDxCLerp;\n            }\n\n            if (r == topDxRIndex && c == rightDxCIndex) {\n              // topRight\n              accumulator += getDy(b, dyR, dyC, d) * inverseDxRLerp * dxCLerp;\n            }\n\n            if (r == bottomDxRIndex && c == leftDxCIndex) {\n              // bottomLeft\n              accumulator += getDy(b, dyR, dyC, d) * dxRLerp * inverseDxCLerp;\n            }\n\n            if (r == bottomDxRIndex && c == rightDxCIndex) {\n              // bottomRight\n              accumulator += getDy(b, dyR, dyC, d) * dxRLerp * dxCLerp;\n            }\n          }\n        }\n        // End loop over dy\n\n        setOutput(accumulator);\n      }\n    `}}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function resizeBilinearGrad(e){const{inputs:t,backend:n,attrs:r}=e,{images:i,dy:a}=t,{alignCorners:o}=r,s=new ResizeBilinearBackpropProgram(a.shape,i.shape,o);return n.runWebGLProgram(s,[a],a.dtype)}const resizeBilinearGradConfig={kernelName:ResizeBilinearGrad,backendName:"webgl",kernelFunc:resizeBilinearGrad};
/**
     * @license
     * Copyright 2018 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */class ResizeNearestNeighborProgram{constructor(e,t,n,r,i){this.variableNames=["A"],this.outputShape=[];const[a,o,s,l]=e;this.outputShape=[a,t,n,l];const c=[r&&t>1?o-1:o,r&&n>1?s-1:s],h=[r&&t>1?t-1:t,r&&n>1?n-1:n];let u;u=i?"max((vec2(yRC) + vec2(0.5)) * effectiveInputOverOutputRatioRC, vec2(0.0))":"vec2(yRC) * effectiveInputOverOutputRatioRC",this.userCode=`\n      const vec2 effectiveInputOverOutputRatioRC = vec2(\n          ${c[0]/h[0]},\n          ${c[1]/h[1]});\n      const vec2 inputShapeRC = vec2(${o}.0, ${s}.0);\n\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int b = coords[0];\n        int d = coords[3];\n        ivec2 yRC = coords.yz;\n\n        // Fractional source index.\n        vec2 sourceFracIndexRC = ${u};\n\n        // Compute the coordinators of nearest neighbor point.\n        ivec2 sourceNearestRC = ivec2(\n          min(inputShapeRC - 1.0, floor(sourceFracIndexRC + ${r?"0.5":"0.0"})));\n        float newValue = getA(b, sourceNearestRC.x, sourceNearestRC.y, d);\n\n        setOutput(newValue);\n      }\n    `}}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function resizeNearestNeighbor(e){const{inputs:t,backend:n,attrs:r}=e,{images:i}=t,{alignCorners:a,halfPixelCenters:o,size:s}=r,[l,c]=s,h=new ResizeNearestNeighborProgram(i.shape,l,c,a,o);return n.runWebGLProgram(h,[i],i.dtype)}const resizeNearestNeighborConfig={kernelName:ResizeNearestNeighbor,backendName:"webgl",kernelFunc:resizeNearestNeighbor};
/**
     * @license
     * Copyright 2018 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */class ResizeNearestNeigborBackpropProgram{constructor(e,t,n){this.variableNames=["dy"],this.outputShape=[],this.outputShape=t;const[,r,i]=t,[,a,o]=e,s=[n&&a>1?r-1:r,n&&o>1?i-1:i],l=[n&&a>1?a-1:a,n&&o>1?o-1:o],c=s[0]/l[0],h=s[1]/l[1],u=1/c,d=1/h,p=2*Math.ceil(u)+2,m=2*Math.ceil(d)+2;this.userCode=`\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int b = coords[0];\n        int d = coords[3];\n        int r = coords[1];\n        int c = coords[2];\n\n        float accumulator = 0.0;\n\n        const float heightScale = float(${c});\n        const float widthScale = float(${h});\n\n        const float invHeightScale = float(${u});\n        const float invWidthScale = float(${d});\n\n        const int winHeight = int(${p});\n        const int winWidth = int(${m});\n\n        // Compute bounds for where in dy we will look\n        float startRLerp = floor(float(r) * invHeightScale);\n        int startDyR = int(floor(startRLerp - float(winHeight / 2)));\n\n        float startCLerp = floor(float(c) * invWidthScale);\n        int startDyC = int(floor(startCLerp - float(winWidth / 2)));\n\n        // Loop over dy\n        for (int dyROffset = 0; dyROffset < winHeight; dyROffset++) {\n          int dyR = dyROffset + startDyR;\n\n          // Guard against the window exceeding the bounds of dy\n          if (dyR < 0 || dyR >= ${a}) {\n            continue;\n          }\n\n          for (int dyCOffset = 0; dyCOffset < winWidth; dyCOffset++) {\n            int dyC = dyCOffset + startDyC;\n\n            // Guard against the window exceeding the bounds of dy\n            if (dyC < 0 || dyC >= ${o}) {\n              continue;\n            }\n\n            float sourceFracRow =\n              float(${s[0]}) *\n                (float(dyR) / float(${l[0]}));\n\n            float sourceFracCol =\n                float(${s[1]}) *\n                  (float(dyC) / float(${l[1]}));\n\n            int sourceNearestRow = int(min(\n                float(int(${r}) - 1),\n                ${n} ? float(round(sourceFracRow)) :\n                                  float(floor(sourceFracRow))));\n\n            int sourceNearestCol = int(min(\n                float(int(${i}) - 1),\n                ${n} ? float(round(sourceFracCol)) :\n                                  float(floor(sourceFracCol))));\n\n            if (r == sourceNearestRow && c == sourceNearestCol) {\n              accumulator += getDy(b, dyR, dyC, d);\n            }\n          }\n        }\n        // End loop over dy\n\n        setOutput(accumulator);\n      }\n    `}}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function resizeNearestNeighborGrad(e){const{inputs:t,backend:n,attrs:r}=e,{images:i,dy:a}=t,{alignCorners:o}=r,s=new ResizeNearestNeigborBackpropProgram(a.shape,i.shape,o);return n.runWebGLProgram(s,[a],a.dtype)}const resizeNearestNeighborGradConfig={kernelName:ResizeNearestNeighborGrad,backendName:"webgl",kernelFunc:resizeNearestNeighborGrad};
/**
     * @license
     * Copyright 2017 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */class ReverseProgram{constructor(e,t){this.variableNames=["x"];const n=e.length;if(n>4)throw new Error(`WebGL backend: Reverse of rank-${n} tensor is not yet supported`);if(this.outputShape=e,1===n)return void(this.userCode=`\n        void main() {\n          int coord = getOutputCoords();\n          setOutput(getX(${e[0]} - coord - 1));\n        }\n      `);const r=e.map(((n,r)=>(n=>-1!==t.indexOf(n)&&1!==e[n]?`${e[n]} - coords[${n}] - 1`:`coords[${n}]`)(r))).join(","),i=getCoordsDataType(n);this.userCode=`\n      void main() {\n        ${i} coords = getOutputCoords();\n        setOutput(getX(${r}));\n      }\n    `}}
/**
     * @license
     * Copyright 2019 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */class ReversePackedProgram{constructor(e,t){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0;const n=e.length;if(n>4)throw new Error(`WebGL backend: Reverse of rank-${n} tensor is not yet supported`);this.outputShape=e;const r=getChannels("rc",n),i=`${r[n-1]} + 1 < ${this.outputShape[n-1]}`,a=`${r[n-2]} + 1 < ${this.outputShape[n-2]}`,o=getCoordsDataType(n);function s(n){const r=e.map(((r,i)=>(function a(n,r){return-1!==t.indexOf(n)&&1!==e[n]?`${e[n]} - ${r[n]} - 1`:`${r[n]}`})(i,n)));return`getChannel(getX(${r.join(",")}), vec2(${r.slice(-2).join(",")}))`}this.userCode=1===n?`\n        void main(){\n          int rc = getOutputCoords();\n          vec4 result = vec4(0.);\n          result.r = getChannel(getX(${e[0]} - rc - 1),\n            ${e[0]} - rc - 1);\n          if(${i}){\n              result.g = getChannel(getX(${e[0]} - (rc  + 1) - 1),\n                ${e[0]} - (rc  + 1) - 1);\n          }\n          setOutput(result);\n        }\n      `:`\n        void main() {\n          ${o} rc = getOutputCoords();\n          vec4 result = vec4(0.);\n          result.r = ${(function l(e){return s(e)})(r.slice())};\n          if(${i}){\n            result.g = ${(function c(e){return e[n-1]="("+e[n-1]+" + 1)",s(e)})(r.slice())};\n          }\n          if(${a}) {\n            result.b = ${(function h(e){return e[n-2]="("+e[n-2]+" + 1)",s(e)})(r.slice())};\n            if(${i}) {\n              result.a = ${(function u(e){return e[n-1]="("+e[n-1]+" + 1)",e[n-2]="("+e[n-2]+" + 1)",s(e)})(r.slice())};\n            }\n          }\n          setOutput(result);\n        }\n    `}}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function reverse(e){const{inputs:t,backend:n,attrs:r}=e,{x:i}=t,{dims:a}=r,o=i.shape.length,s=parseAxisParam(a,i.shape);if(0===o)return identity$2({inputs:{x:i},backend:n});const l=env().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new ReversePackedProgram(i.shape,s):new ReverseProgram(i.shape,s);return n.runWebGLProgram(l,[i],i.dtype)}const reverseConfig={kernelName:Reverse,backendName:"webgl",kernelFunc:reverse};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */class RotateProgram{constructor(e,t){this.variableNames=["Image"],this.outputShape=[];const n=e[1],r=e[2];this.outputShape=e;let i="";i="number"==typeof t?`float outputValue = ${t.toFixed(2)};`:`\n        vec3 fill = vec3(${t.join(",")});\n        float outputValue = fill[coords[3]];`,this.userCode=`\n        uniform vec4 params;\n        void main() {\n          ivec4 coords = getOutputCoords();\n          int x = coords[2];\n          int y = coords[1];\n          float coordXFloat = (float(x) - params[0]) * params[3] -\n            (float(y) - params[1]) * params[2];\n          float coordYFloat = (float(x) - params[0]) * params[2] +\n            (float(y) - params[1]) * params[3];\n          int coordX = int(round(coordXFloat + params[0]));\n          int coordY = int(round(coordYFloat + params[1]));\n          ${i}\n          if(coordX >= 0 && coordX < ${r} && coordY >= 0 && coordY < ${n}) {\n            outputValue = getImage(coords[0], coordY, coordX, coords[3]);\n          }\n          setOutput(outputValue);\n        }\n    `}getCustomSetupFunc(e,t,n,r){return(i,a)=>{null==this.paramsLoc&&(this.paramsLoc=i.getUniformLocationNoThrow(a,"params")),i.gl.uniform4f(this.paramsLoc,e,t,n,r)}}}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */const rotateWithOffsetConfig={kernelName:RotateWithOffset,backendName:"webgl",kernelFunc:({inputs:e,attrs:t,backend:n})=>{const{image:r}=e,{radians:i,fillValue:a,center:o}=t,s=n,l=new RotateProgram(r.shape,a),[c,h]=getImageCenter(o,r.shape[1],r.shape[2]),u=l.getCustomSetupFunc(c,h,Math.sin(i),Math.cos(i));return s.runWebGLProgram(l,[r],r.dtype,u)}},ROUND="\n  // OpenGL ES does not support round function.\n  // The algorithm is based on banker's rounding.\n  float base = floor(x);\n  if ((x - base) < 0.5) {\n    return floor(x);\n  } else if ((x - base) > 0.5) {\n    return ceil(x);\n  } else {\n    if (mod(base, 2.0) == 0.0) {\n      return base;\n    } else {\n      return base + 1.0;\n    }\n  }\n",round=unaryKernelFunc({opSnippet:ROUND}),roundConfig={kernelName:Round,backendName:"webgl",kernelFunc:round},RSQRT="return inversesqrt(x);",rsqrt=unaryKernelFunc({opSnippet:RSQRT,cpuKernelImpl:rsqrtImplCPU}),rsqrtConfig={kernelName:Rsqrt,backendName:"webgl",kernelFunc:rsqrt};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
/**
     * @license
     * Copyright 2018 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
class ScatterProgram{constructor(e,t,n,r,i,a,o=!0){this.variableNames=["updates","indices","defaultValue"],this.outputShape=a;const s=getCoordsDataType(i.length),l=getCoordsDataType(a.length);let c="";1===n?c="i":2===n&&(c="i, j");let h="";1===r?h="i":2===r&&(h="i, coords[1]");this.userCode=`\n        ${s} strides = ${s}(${i});\n\n        void main() {\n          ${l} coords = getOutputCoords();\n          float sum = 0.0;\n          bool found = false;\n          for (int i = 0; i < ${e}; i++) {\n            int flattenedIndex = 0;\n            for (int j = 0; j < ${t}; j++) {\n              int index = round(${`getIndices(${c})`});\n              flattenedIndex += index * ${t>1?"strides[j]":"strides"};\n            }\n            if (flattenedIndex == coords[0]) {\n              sum += ${`getUpdates(${h})`};\n              found = true;\n            }\n          }\n          setOutput(mix(getDefaultValue(), sum, float(found)));\n        }\n      `}}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function scatterNd(e){const{inputs:t,backend:n,attrs:r}=e,{indices:i,updates:a}=t,{shape:o}=r,{sliceRank:s,numUpdates:l,sliceSize:c,strides:h,outputSize:u}=calculateShapes(a,i,o),d=[u/c,c];if(0===u)return n.makeTensorInfo(o,i.dtype);const p=reshape({inputs:{x:i},backend:n,attrs:{shape:[l,s]}}),m=reshape({inputs:{x:a},backend:n,attrs:{shape:[l,c]}}),f=n.makeTensorInfo([],"float32",new Float32Array([0])),g=new ScatterProgram(l,s,p.shape.length,m.shape.length,h,d),v=n.runWebGLProgram(g,[m,p,f],m.dtype),y=reshape({inputs:{x:v},backend:n,attrs:{shape:o}});return n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(m),n.disposeIntermediateTensorInfo(v),n.disposeIntermediateTensorInfo(f),y}const scatterNdConfig={kernelName:ScatterNd,backendName:"webgl",kernelFunc:scatterNd};
/**
     * @license
     * Copyright 2017 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */class SelectProgram{constructor(e,t,n){let r,i;if(this.variableNames=["c","a","b"],this.outputShape=t,n>4)throw Error(`Where for rank ${n} is not yet supported`);if(1===n)i="resRC",r="resRC";else{const n=["resRC.x","resRC.y","resRC.z","resRC.w"],a=[],o=[];for(let r=0;r<t.length;r++)o.push(`${n[r]}`),r<e&&a.push(`${n[r]}`);r=a.join(),i=o.join()}const a=getCoordsDataType(n);this.userCode=`\n      void main() {\n        ${a} resRC = getOutputCoords();\n        float cVal = getC(${r});\n        if (cVal >= 1.0) {\n          setOutput(getA(${i}));\n        } else {\n          setOutput(getB(${i}));\n        }\n      }\n    `}}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function select(e){const{inputs:t,backend:n}=e,{condition:r,t:i,e:a}=t,o=new SelectProgram(r.shape.length,i.shape,i.shape.length);return n.runWebGLProgram(o,[r,i,a],upcastType(i.dtype,a.dtype))}const selectConfig={kernelName:Select,backendName:"webgl",kernelFunc:select},SELU=`\n  // Stable and Attracting Fixed Point (0, 1) for Normalized Weights.\n  // see: https://arxiv.org/abs/1706.02515\n  float scaleAlpha = ${SELU_SCALEALPHA};\n  float scale = ${SELU_SCALE};\n  return (x >= 0.0) ? scale * x : scaleAlpha * (exp(x) - 1.0);\n`,selu=unaryKernelFunc({opSnippet:SELU}),seluConfig={kernelName:Selu,backendName:"webgl",kernelFunc:selu},SIGMOID="return 1.0 / (1.0 + exp(-1.0 * x));",sigmoid=unaryKernelFunc({opSnippet:SIGMOID}),sigmoidConfig={kernelName:Sigmoid,backendName:"webgl",kernelFunc:sigmoid},SIGN="\n  if (isnan(x)) { return 0.0; }\n  return sign(x);\n",sign$1=unaryKernelFunc({opSnippet:SIGN}),signConfig={kernelName:Sign,backendName:"webgl",kernelFunc:sign$1},SIN=CHECK_NAN_SNIPPET_UNARY+"\n  return sin(x);\n",sin=unaryKernelFunc({opSnippet:SIN}),sinConfig={kernelName:Sin,backendName:"webgl",kernelFunc:sin},SINH="\n  float e2x = exp(x);\n  return (e2x - 1.0 / e2x) / 2.0;\n",sinh=unaryKernelFunc({opSnippet:SINH}),sinhConfig={kernelName:Sinh,backendName:"webgl",kernelFunc:sinh},SOFTPLUS="\n  float epsilon = 1.1920928955078125e-7;\n  float threshold = log(epsilon) + 2.0;\n\n  bool too_large = x > -threshold;\n  bool too_small = x < threshold;\n\n  float result;\n  float exp_x = exp(x);\n\n  if (too_large){\n    result = x;\n  }\n  else if (too_small){\n    result = exp_x;\n  }\n  else{\n    result = log(exp_x + 1.0);\n  }\n  return result;\n",softplus=unaryKernelFunc({opSnippet:SOFTPLUS}),softplusConfig={kernelName:Softplus,backendName:"webgl",kernelFunc:softplus},spaceToBatchND=e=>{const{inputs:t,backend:n,attrs:r}=e,{x:i}=t,{blockShape:a,paddings:o}=r;assert$1(i.shape.length<=4,(()=>"spaceToBatchND for rank > 4 with a WebGL backend not implemented yet"));const s=a.reduce(((e,t)=>e*t)),l=[[0,0]];l.push(...o);for(let e=1+a.length;e<i.shape.length;++e)l.push([0,0]);const c=[],h=padV2({inputs:{x:i},backend:n,attrs:{paddings:l,constantValue:0}}),u=getReshaped(h.shape,a,s,!1),d=getPermuted(u.length,a.length,!1),p=getReshapedPermuted(h.shape,a,s,!1),m=reshape({inputs:{x:h},backend:n,attrs:{shape:u}}),f=transpose({inputs:{x:m},backend:n,attrs:{perm:d}}),g=reshape({inputs:{x:f},backend:n,attrs:{shape:p}});return c.push(h),c.push(m),c.push(f),c.forEach((e=>n.disposeIntermediateTensorInfo(e))),g},spaceToBatchNDConfig={kernelName:SpaceToBatchND,backendName:"webgl",kernelFunc:spaceToBatchND};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
function sparseToDense(e){const{inputs:t,backend:n,attrs:r}=e,{sparseIndices:i,sparseValues:a,defaultValue:o}=t,{outputShape:s}=r,{sliceRank:l,numUpdates:c,strides:h,outputSize:u}=calculateShapes(a,i,s),d=new ScatterProgram(c,l,i.shape.length,a.shape.length,h,[u,1],!1),p=n.runWebGLProgram(d,[a,i,o],a.dtype),m=reshape({inputs:{x:p},backend:n,attrs:{shape:s}});return n.disposeIntermediateTensorInfo(p),m}const sparseToDenseConfig={kernelName:SparseToDense,backendName:"webgl",kernelFunc:sparseToDense};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function splitV(e){const{inputs:t,backend:n,attrs:r}=e,{x:i}=t,{numOrSizeSplits:a,axis:o}=r,s=parseAxisParam(o,i.shape)[0],l=prepareSplitSize(i,a,s),c=new Array(i.shape.length).fill(0),h=i.shape.slice();return l.map((e=>{const t=[...h];t[s]=e;const r=slice$1({inputs:{x:i},backend:n,attrs:{begin:c,size:t}});return c[s]+=e,r}))}const splitVConfig={kernelName:SplitV,backendName:"webgl",kernelFunc:splitV},SQRT="return sqrt(x);",sqrt=unaryKernelFunc({opSnippet:SQRT}),sqrtConfig={kernelName:Sqrt,backendName:"webgl",kernelFunc:sqrt},SQUARE="return x * x;",square=unaryKernelFunc({opSnippet:SQUARE}),squareConfig={kernelName:Square,backendName:"webgl",kernelFunc:square},SQUARED_DIFFERENCE="return (a - b) * (a - b);",squaredDifference=binaryKernelFunc({opSnippet:SQUARED_DIFFERENCE,packedOpSnippet:SQUARED_DIFFERENCE}),squaredDifferenceConfig={kernelName:SquaredDifference,backendName:"webgl",kernelFunc:squaredDifference};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
function step({inputs:e,attrs:t,backend:n}){const{x:r}=e,i=new UnaryOpProgram(r.shape,CHECK_NAN_SNIPPET$2+`\n    return x > 0.0 ? 1.0 : float(${t.alpha});\n  `);return n.runWebGLProgram(i,[r],r.dtype)}const stepConfig={kernelName:Step,backendName:"webgl",kernelFunc:step};
/**
     * @license
     * Copyright 2017 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */class StridedSliceProgram{constructor(e,t,n){this.variableNames=["x"],this.outputShape=n;const r=n.length,i=getCoordsDataType(n.length),a=getCoordsDataType(n.length);let o="";if(1===r)o="coords * strides + begin";else{let e=0;o=n.map(((t,r)=>(e++,1===n.length?`coords * strides[${r}] + begin[${r}]`:`coords[${e-1}] * strides[${r}] + begin[${r}]`))).join(",")}this.userCode=`\n      ${i} begin = ${i}(${e});\n      ${i} strides = ${i}(${t});\n\n      void main() {\n        ${a} coords = getOutputCoords();\n        setOutput(getX(${o}));\n      }\n    `}}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function stridedSlice(e){const{inputs:t,backend:n,attrs:r}=e,{x:i}=t,{begin:a,end:o,strides:s,beginMask:l,endMask:c,ellipsisMask:h,newAxisMask:u,shrinkAxisMask:d}=r,{nonStrided:p,$begin:m,$strides:f,size:g,newShape:v,outShape:y}=sliceInfo(i.shape,a,o,s,l,c,h,u,d),_=reshape({inputs:{x:i},backend:n,attrs:{shape:v}});let b;if(p){const e=slice$1({inputs:{x:_},backend:n,attrs:{begin:m,size:g}});b=reshape({inputs:{x:e},backend:n,attrs:{shape:y}}),n.disposeIntermediateTensorInfo(e)}else if(y.some((e=>0===e)))b=n.makeTensorInfo(y,i.dtype,[]);else{if(n.shouldExecuteOnCPU([_])){const e=n.texData.get(_.dataId),t=buffer(_.shape,_.dtype,e.values),r=stridedSliceImplCPU(y,t,f,m);b=n.makeTensorInfo(y,_.dtype,r.values)}else{const e=new StridedSliceProgram(m,f,y);b=n.runWebGLProgram(e,[_],_.dtype)}}const x=reshape({inputs:{x:b},backend:n,attrs:{shape:y}});return n.disposeIntermediateTensorInfo(_),n.disposeIntermediateTensorInfo(b),x}const stridedSliceConfig={kernelName:StridedSlice,backendName:"webgl",kernelFunc:stridedSlice},TAN="return tan(x);",tan=unaryKernelFunc({opSnippet:TAN}),tanConfig={kernelName:Tan,backendName:"webgl",kernelFunc:tan},TANH="\n  float e2x = exp(-2.0 * abs(x));\n  return sign(x) * (1.0 - e2x) / (1.0 + e2x);\n",tanh=unaryKernelFunc({opSnippet:TANH}),tanhConfig={kernelName:Tanh,backendName:"webgl",kernelFunc:tanh};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
/**
     * @license
     * Copyright 2017 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */
class TileProgram{constructor(e,t){this.variableNames=["A"];const n=new Array(e.length);for(let r=0;r<n.length;r++)n[r]=e[r]*t[r];this.outputShape=n,this.rank=n.length;const r=getCoordsDataType(this.rank),i=getSourceCoords(e);this.userCode=`\n      void main() {\n        ${r} resRC = getOutputCoords();\n        setOutput(getA(${i}));\n      }\n    `}}function getSourceCoords(e){const t=e.length;if(t>5)throw Error(`Tile for rank ${t} is not yet supported`);if(1===t)return`imod(resRC, ${e[0]})`;const n=["resRC.x","resRC.y","resRC.z","resRC.w","resRC.u"],r=[];for(let t=0;t<e.length;t++)r.push(`imod(${n[t]}, ${e[t]})`);return r.join()}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function tile(e){const{inputs:t,backend:n,attrs:r}=e,{x:i}=t,{reps:a}=r;if("string"===i.dtype){const e=n.readSync(i.dataId).map((e=>decodeString(e))),t=buffer(i.shape,i.dtype,e),r=tileImplCPU(t,a);return n.makeTensorInfo(r.shape,r.dtype,r.values)}const o=new TileProgram(i.shape,a);return n.runWebGLProgram(o,[i],i.dtype)}const tileConfig={kernelName:Tile,backendName:"webgl",kernelFunc:tile};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function topK(e){const{inputs:t,backend:n,attrs:r}=e,{x:i}=t,{k:a,sorted:o}=r,s=n.readSync(i.dataId),[l,c]=topKImplCPU(s,i.shape,i.dtype,a,o);return[n.makeTensorInfo(l.shape,l.dtype,l.values),n.makeTensorInfo(c.shape,c.dtype,c.values)]}const topKConfig={kernelName:TopK,backendName:"webgl",kernelFunc:topK};
/**
     * @license
     * Copyright 2021 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */class TransformProgram{constructor(e,t,n,r,i,a){this.variableNames=["Image","Transforms"],this.outputShape=a;const o="nearest"===n?1:2;let s;switch(r){case"constant":s=1;break;case"reflect":s=2;break;case"wrap":s=3;break;case"nearest":s=4;break;default:s=1}this.userCode=`\n            float mapCoord(float outCoord, float len) {\n              float inCoord = outCoord;\n              if(${s} == 2) {\n                if (inCoord < 0.0) {\n                  if (len <= 1.0) {\n                    inCoord = 0.0;\n                  } else {\n                    float sz2 = 2.0 * len;\n                    if (inCoord < sz2) {\n                      inCoord = sz2 * float(int(float(-inCoord / sz2))) +\n                      inCoord;\n                    }\n                    inCoord = inCoord < -len ? inCoord + sz2 : -inCoord - 1.0;\n                  }\n                } else if (inCoord > len - 1.0) {\n                  if (len <= 1.0) {\n                    inCoord = 0.0;\n                  } else {\n                    float sz2 = 2.0 * len;\n                    inCoord -= sz2 * float(int(float(inCoord / sz2)));\n                    if (inCoord >= len) {\n                      inCoord = sz2 - inCoord - 1.0;\n                    }\n                  }\n                }\n                return clamp(inCoord, 0.0, len - 1.0);\n              } else if (${s} == 3) {\n                if (inCoord < 0.0) {\n                  if (len <= 1.0) {\n                    inCoord = 0.0;\n                  } else {\n                    float sz = len - 1.0;\n                    inCoord += len * (float(int(float(-inCoord / sz))) + 1.0);\n                  }\n                } else if (inCoord > len - 1.0) {\n                  if (len <= 1.0) {\n                    inCoord = 0.0;\n                  } else {\n                    float sz = len - 1.0;\n                    inCoord -= len * float(int(float(inCoord / sz)));\n                  }\n                }\n                return clamp(inCoord, 0.0, len - 1.0);\n              } else if (${s} == 4) {\n                return clamp(outCoord, 0.0, len - 1.0);\n              } else {\n                return outCoord;\n              }\n            }\n\n            float readWithFillValue(int batch, int coordY, int coordX,\n              int channel) {\n              float outputValue;\n              if (0 <= coordY && coordY < ${e} && 0 <= coordX && coordX < ${t}) {\n                  outputValue = getImage(batch, coordY, coordX, channel);\n              } else {\n                outputValue = float(${i});\n              }\n              return outputValue;\n            }\n\n            void main() {\n              ivec4 coords = getOutputCoords();\n              float outputValue;\n              int batch = coords[0];\n              int x = coords[2];\n              int y = coords[1];\n              int channel = coords[3];\n              float xf = float(x);\n              float yf = float(y);\n              float a1 = getTransforms(batch, 0);\n              float a2 = getTransforms(batch, 1);\n              float a3 = getTransforms(batch, 2);\n              float b1 = getTransforms(batch, 3);\n              float b2 = getTransforms(batch, 4);\n              float b3 = getTransforms(batch, 5);\n              float c1 = getTransforms(batch, 6);\n              float c2 = getTransforms(batch, 7);\n              float projection = c1 * xf + c2 * yf + 1.0;\n              if (projection == 0.0) {\n                outputValue = float(${i});\n              } else {\n                float inX = (a1 * xf + a2 * yf + a3) / projection;\n                float inY = (b1 * xf + b2 * yf + b3) / projection;\n                float mapX = mapCoord(inX, float(${t}));\n                float mapY = mapCoord(inY, float(${e}));\n\n                if (${o} == 1) {\n                  int coordY = int(round(mapY));\n                  int coordX = int(round(mapX));\n                  outputValue = readWithFillValue(batch, coordY, coordX,\n                    channel);\n                } else {\n                  float yFloor = floor(mapY);\n                  float xFloor = floor(mapX);\n                  float yCeil = yFloor + 1.0;\n                  float xCeil = xFloor + 1.0;\n                  float valueYFloor = (xCeil - mapX) *\n                  readWithFillValue(batch, int(yFloor), int(xFloor), channel) +\n                  (mapX - xFloor) *\n                  readWithFillValue(batch, int(yFloor), int(xCeil), channel);\n                  float valueYCeil = (xCeil - mapX) *\n                  readWithFillValue(batch, int(yCeil), int(xFloor), channel) +\n                  (mapX - xFloor) *\n                  readWithFillValue(batch, int(yCeil), int(xCeil), channel);\n                  outputValue = (yCeil - mapY) * valueYFloor +\n                  (mapY - yFloor) * valueYCeil;\n                }\n              }\n              setOutput(outputValue);\n            }\n        `}}
/**
     * @license
     * Copyright 2021 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function transform(e){const{inputs:t,backend:n,attrs:r}=e,{image:i,transforms:a}=t,{interpolation:o,fillMode:s,fillValue:l,outputShape:c}=r,[h,u,d,p]=i.shape,[m,f]=null!=c?c:[u,d],g=new TransformProgram(u,d,o,s,l,[h,m,f,p]);return n.runWebGLProgram(g,[i,a],"float32")}const transformConfig={kernelName:Transform,backendName:"webgl",kernelFunc:transform};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the License);
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an AS IS BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function unique(e){const{inputs:t,attrs:n,backend:r}=e,{axis:i}=n,{x:a}=t;assertNotComplex(a,"unique"),console.warn("WARNING: ","UI might be locked temporarily as data is being downloaded");const o=r.readSync(a.dataId),{outputValues:s,outputShape:l,indices:c}=uniqueImplCPU(o,i,a.shape,a.dtype);return[r.makeTensorInfo(l,a.dtype,s),r.makeTensorInfo([c.length],"int32",c)]}const uniqueConfig={kernelName:Unique,backendName:"webgl",kernelFunc:unique};
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function unpack(e){const{inputs:t,backend:n,attrs:r}=e,{value:i}=t;let{axis:a}=r;a<0&&(a+=i.shape.length);const o=i,s=o.shape.length,l=i.shape[a],c=new Array(s-1);let h=0;for(let e=0;e<s;e++)e!==a&&(c[h++]=o.shape[e]);const u=[],d=new Array(s).fill(0),p=o.shape.slice();p[a]=1;const m=new Array(l);for(let e=0;e<m.length;e++){d[a]=e;const t=slice$1({inputs:{x:o},backend:n,attrs:{begin:d,size:p}}),r=reshape({inputs:{x:t},backend:n,attrs:{shape:c}});m[e]=r,u.push(t)}return u.forEach((e=>n.disposeIntermediateTensorInfo(e))),m}const unpackConfig={kernelName:Unpack,backendName:"webgl",kernelFunc:unpack};
/**
     * @license
     * Copyright 2018 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */class SegmentOpProgram{constructor(e,t){this.variableNames=["x","segmentIds"];const n=e.windowSize,r=e.batchSize,i=e.inSize,a=e.numSegments,o=a*Math.ceil(i/n);this.outputShape=[r,o];const s=4*Math.floor(n/4),l=n%4,c="\n        sumValue += dot(values, segFilter);\n    ";let h="";i%n>0&&(h=`\n        if (inIdx < 0 || inIdx >= ${i}) {\n          return initializationValue;\n        }\n      `);let u="";i%n>0&&(u=`\n        if (inIdx < 0 || inIdx >= ${i}) {\n          return -1.0;\n        }\n      `),this.userCode=`\n      const float initializationValue = 0.0;\n\n      float getValue(int batch, int inIdx) {\n        ${h}\n        return getX(batch, inIdx);\n      }\n\n      float getSegmentIdAtIndex(int inIdx) {\n        ${u}\n        return getSegmentIds(inIdx);\n      }\n\n      void main() {\n        ivec2 coords = getOutputCoords();\n        int batch = coords[0];\n        int outIdx = coords[1];\n        int inOffset = int(floor(float(outIdx) / float(\n          ${a})) * float(${n}));\n        int currentSeg = int(mod(float(outIdx), float(${a})));\n\n        float sumValue = 0.0;\n\n        for (int i = 0; i < ${s}; i += 4) {\n          int inIdx = inOffset + i;\n          vec4 values = vec4(\n            getValue(batch, inIdx),\n            getValue(batch, inIdx + 1),\n            getValue(batch, inIdx + 2),\n            getValue(batch, inIdx + 3)\n          );\n\n          vec4 segFilter = vec4(\n            int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,\n            int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0,\n            int(getSegmentIdAtIndex(inIdx + 2)) == currentSeg ? 1 : 0,\n            int(getSegmentIdAtIndex(inIdx + 3)) == currentSeg ? 1 : 0\n          );\n\n          ${c}\n        }\n\n        int inIdx = inOffset + ${s};\n        if (${1===l}) {\n          vec4 values = vec4(\n            getValue(batch, inIdx),\n            initializationValue,\n            initializationValue,\n            initializationValue\n          );\n\n          int inIdxSeg = int(getSegmentIdAtIndex(inIdx));\n\n          vec4 segFilter = vec4(\n            int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,\n            0,\n            0,\n            0\n          );\n\n          ${c}\n        } else if (${2===l}) {\n          vec4 values = vec4(\n            getValue(batch, inIdx),\n            getValue(batch, inIdx + 1),\n            initializationValue,\n            initializationValue\n          );\n\n          vec4 segFilter = vec4(\n            int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,\n            int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0,\n              0,\n              0\n          );\n\n          ${c}\n        } else if (${3===l}) {\n          vec4 values = vec4(\n            getValue(batch, inIdx),\n            getValue(batch, inIdx + 1),\n            getValue(batch, inIdx + 2),\n            initializationValue\n          );\n\n          vec4 segFilter = vec4(\n            int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,\n            int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0,\n            int(getSegmentIdAtIndex(inIdx + 2)) == currentSeg ? 1 : 0,\n            0\n          );\n\n          ${c}\n        }\n        setOutput(sumValue);\n      }\n    `}}
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */function unsortedSegmentSum(e){const{inputs:t,backend:n,attrs:r}=e,{x:i,segmentIds:a}=t,{numSegments:o}=r,s=i.shape.length,l=[];let c=0;const h=getAxesPermutation([c],s);let u=i;null!=h&&(u=transpose({inputs:{x:i},backend:n,attrs:{perm:h}}),l.push(u),c=getInnerMostAxes(1,s)[0]);const d=computeOutShape(u.shape,c,o),p=sizeFromShape([u.shape[c]]),m=reshape({inputs:{x:u},backend:n,attrs:{shape:[-1,p]}});l.push(m);const f=sumOutType(i.dtype),g=(e,t,r,i,a)=>{const o=e.shape[0],s=e.shape[1],c=segOpComputeOptimalWindowSize(s,a),h=new SegmentOpProgram({windowSize:c,inSize:s,batchSize:o,numSegments:a},t),u=n.compileAndRun(h,[e,r],i);if(l.push(u),u.shape[1]===a)return u;const d=range$1({backend:n,attrs:{start:0,stop:a,step:1,dtype:"float32"}}),p=tile({inputs:{x:d},backend:n,attrs:{reps:[s/c]}});l.push(d),l.push(p);return g(u,t,p,i,a)},v=reshape({inputs:{x:g(m,"unsortedSegmentSum",a,f,o)},backend:n,attrs:{shape:d}});let y=v;if(null!=h){l.push(v);const e=getUndoAxesPermutation(h);y=transpose({inputs:{x:y},backend:n,attrs:{perm:e}})}return l.forEach((e=>n.disposeIntermediateTensorInfo(e))),y}const unsortedSegmentSumConfig={kernelName:UnsortedSegmentSum,backendName:"webgl",kernelFunc:unsortedSegmentSum},kernelConfigs=[LRNConfig,LRNGradConfig,_fusedMatMulConfig,absConfig,acosConfig,acoshConfig,addConfig,addNConfig,allConfig,anyConfig,argMaxConfig,argMinConfig,asinConfig,asinhConfig,atan2Config,atanConfig,atanhConfig,avgPool3DConfig,avgPoolConfig,avgPoolGrad3DConfig,avgPoolGradConfig,batchMatMulConfig,batchNormConfig,batchToSpaceNDConfig,bincountConfig,castConfig,ceilConfig,clipByValueConfig,complexAbsConfig,complexConfig,concatConfig,conv2DBackpropFilterConfig,conv2DBackpropInputConfig,conv2DConfig,conv3DBackpropFilterV2Config,conv3DBackpropInputConfig,conv3DConfig,cosConfig,coshConfig,cropAndResizeConfig,cumsumConfig,denseBincountConfig,depthToSpaceConfig,depthwiseConv2dNativeBackpropFilterConfig,depthwiseConv2dNativeBackpropInputConfig,depthwiseConv2dNativeConfig,diagConfig,dilation2DConfig,einsumConfig,eluConfig,eluGradConfig,equalConfig,erfConfig,expConfig,expandDimsConfig,expm1Config,fftConfig,fillConfig,flipLeftRightConfig,floorConfig,floorDivConfig,fromPixelsConfig,fusedConv2DConfig,fusedDepthwiseConv2DConfig,gatherNdConfig,gatherV2Config,greaterConfig,greaterEqualConfig,identityConfig,ifftConfig,imagConfig,isFiniteConfig,isInfConfig,isNaNConfig,leakyReluConfig,lessConfig,lessEqualConfig,linSpaceConfig,log1pConfig,logConfig,logicalAndConfig,logicalNotConfig,logicalOrConfig,maxConfig,maxPool3DConfig,maxPoolConfig,maxPoolGrad3DConfig,maxPoolGradConfig,maxPoolWithArgmaxConfig,maximumConfig,meanConfig,minConfig,minimumConfig,mirrorPadConfig,modConfig,multinomialConfig,multiplyConfig,negConfig,nonMaxSuppressionV3Config,nonMaxSuppressionV4Config,nonMaxSuppressionV5Config,notEqualConfig,oneHotConfig,onesLikeConfig,packConfig,padV2Config,powConfig,preluConfig,prodConfig,rangeConfig,realConfig,realDivConfig,reciprocalConfig,relu6Config,reluConfig,reshapeConfig,resizeBilinearConfig,resizeBilinearGradConfig,resizeNearestNeighborConfig,resizeNearestNeighborGradConfig,reverseConfig,rotateWithOffsetConfig,roundConfig,rsqrtConfig,scatterNdConfig,selectConfig,seluConfig,sigmoidConfig,signConfig,sinConfig,sinhConfig,sliceConfig,softmaxConfig,softplusConfig,spaceToBatchNDConfig,sparseToDenseConfig,splitVConfig,sqrtConfig,squareConfig,squaredDifferenceConfig,stepConfig,stridedSliceConfig,subConfig,sumConfig,tanConfig,tanhConfig,tileConfig,topKConfig,transformConfig,transposeConfig,uniqueConfig,unpackConfig,unsortedSegmentSumConfig,zerosLikeConfig];
/**
     * @license
     * Copyright 2020 Google LLC. All Rights Reserved.
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * =============================================================================
     */for(const e of kernelConfigs)registerKernel(e);class MinHeap{constructor(){this.arr=[]}push(e,t){this.arr.push({key:e,value:t}),this.bubbleUp(this.arr.length-1)}pop(){if(0===this.arr.length)throw new Error("pop() called on empty binary heap");let e=this.arr[0],t=this.arr.length-1;return this.arr[0]=this.arr[t],this.arr.pop(),t>0&&this.bubbleDown(0),e}peek(){return this.arr[0]}popPush(e,t){if(0===this.arr.length)throw new Error("pop() called on empty binary heap");let n=this.arr[0];return this.arr[0]={key:e,value:t},this.arr.length>0&&this.bubbleDown(0),n}size(){return this.arr.length}items(){return this.arr}swap(e,t){let n=this.arr[e];this.arr[e]=this.arr[t],this.arr[t]=n}bubbleDown(e){let t=1+(e<<1),n=t+1,r=e;t<this.arr.length&&this.arr[t].key<this.arr[r].key&&(r=t),n<this.arr.length&&this.arr[n].key<this.arr[r].key&&(r=n),r!==e&&(this.swap(r,e),this.bubbleDown(r))}bubbleUp(e){if(e<=0)return;let t=e-1>>1;this.arr[e].key<this.arr[t].key&&(this.swap(e,t),this.bubbleUp(t))}}class KMin{constructor(e){this.maxHeap=new MinHeap,this.k=e}add(e,t){if(this.maxHeap.size()<this.k)return void this.maxHeap.push(-e,t);e<-this.maxHeap.peek().key&&this.maxHeap.popPush(-e,t)}getMinKItems(){let e=this.maxHeap.items();return e.sort(((e,t)=>t.key-e.key)),e.map((e=>e.value))}getSize(){return this.maxHeap.size()}getLargestKey(){return 0===this.maxHeap.size()?null:-this.maxHeap.peek().key}}const WARNING_DURATION_MS=1e4;let dom=null,msgId=0,numActiveMessages=0;function setDomContainer(e){dom=e}function setModalMessage(e,t=null,n=null,r=!1){if(null==dom)return void console.warn("Can't show modal message before the dom is initialized");null==t&&(t=(msgId++).toString());let i=dom.shadowRoot.querySelector("#notification-dialog");i.querySelector(".close-button").style.display=r?null:"none";let a=i.querySelector(".progress");a.style.display=r?"none":null,a.active=!r||null,i.querySelector("#notification-title").textContent=n;let o=i.querySelector("#notify-msgs");if(r)o.textContent="";else{const e=o.querySelectorAll(".error");for(let t=0;t<e.length;t++)o.removeChild(e[t])}let s=`notify-msg-${t}`,l=i.querySelector("#"+s);return null==l&&(l=document.createElement("div"),l.className="notify-msg "+(r?"error":""),l.id=s,o.insertBefore(l,o.firstChild),r?numActiveMessages=0:numActiveMessages++),null==e?(numActiveMessages--,0===numActiveMessages&&i.close(),l.remove()):(l.innerText=e,i.open()),t}function setErrorMessage(e,t){setModalMessage(e,null,"Error "+(null!=t?t:""),!0)}function setWarningMessage(e){let t=dom.shadowRoot.querySelector("#toast");t.text=e,t.duration=WARNING_DURATION_MS,t.open()}
/**
     * @license
     * Copyright 2010-2022 Three.js Authors
     * SPDX-License-Identifier: MIT
     */const REVISION="137",MOUSE={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},TOUCH={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},CullFaceNone=0,CullFaceBack=1,CullFaceFront=2,PCFShadowMap=1,PCFSoftShadowMap=2,VSMShadowMap=3,FrontSide=0,BackSide=1,DoubleSide=2,FlatShading=1,NoBlending=0,NormalBlending=1,AdditiveBlending=2,SubtractiveBlending=3,MultiplyBlending=4,CustomBlending=5,AddEquation=100,SubtractEquation=101,ReverseSubtractEquation=102,MinEquation=103,MaxEquation=104,ZeroFactor=200,OneFactor=201,SrcColorFactor=202,OneMinusSrcColorFactor=203,SrcAlphaFactor=204,OneMinusSrcAlphaFactor=205,DstAlphaFactor=206,OneMinusDstAlphaFactor=207,DstColorFactor=208,OneMinusDstColorFactor=209,SrcAlphaSaturateFactor=210,NeverDepth=0,AlwaysDepth=1,LessDepth=2,LessEqualDepth=3,EqualDepth=4,GreaterEqualDepth=5,GreaterDepth=6,NotEqualDepth=7,MultiplyOperation=0,MixOperation=1,AddOperation=2,NoToneMapping=0,LinearToneMapping=1,ReinhardToneMapping=2,CineonToneMapping=3,ACESFilmicToneMapping=4,CustomToneMapping=5,UVMapping=300,CubeReflectionMapping=301,CubeRefractionMapping=302,EquirectangularReflectionMapping=303,EquirectangularRefractionMapping=304,CubeUVReflectionMapping=306,CubeUVRefractionMapping=307,RepeatWrapping=1e3,ClampToEdgeWrapping=1001,MirroredRepeatWrapping=1002,NearestFilter=1003,NearestMipmapNearestFilter=1004,NearestMipmapLinearFilter=1005,LinearFilter=1006,LinearMipmapNearestFilter=1007,LinearMipmapLinearFilter=1008,UnsignedByteType=1009,ByteType=1010,ShortType=1011,UnsignedShortType=1012,IntType=1013,UnsignedIntType=1014,FloatType=1015,HalfFloatType=1016,UnsignedShort4444Type=1017,UnsignedShort5551Type=1018,UnsignedInt248Type=1020,AlphaFormat=1021,RGBAFormat=1023,LuminanceFormat=1024,LuminanceAlphaFormat=1025,DepthFormat=1026,DepthStencilFormat=1027,RedFormat=1028,RedIntegerFormat=1029,RGFormat=1030,RGIntegerFormat=1031,RGBAIntegerFormat=1033,RGB_S3TC_DXT1_Format=33776,RGBA_S3TC_DXT1_Format=33777,RGBA_S3TC_DXT3_Format=33778,RGBA_S3TC_DXT5_Format=33779,RGB_PVRTC_4BPPV1_Format=35840,RGB_PVRTC_2BPPV1_Format=35841,RGBA_PVRTC_4BPPV1_Format=35842,RGBA_PVRTC_2BPPV1_Format=35843,RGB_ETC1_Format=36196,RGB_ETC2_Format=37492,RGBA_ETC2_EAC_Format=37496,RGBA_ASTC_4x4_Format=37808,RGBA_ASTC_5x4_Format=37809,RGBA_ASTC_5x5_Format=37810,RGBA_ASTC_6x5_Format=37811,RGBA_ASTC_6x6_Format=37812,RGBA_ASTC_8x5_Format=37813,RGBA_ASTC_8x6_Format=37814,RGBA_ASTC_8x8_Format=37815,RGBA_ASTC_10x5_Format=37816,RGBA_ASTC_10x6_Format=37817,RGBA_ASTC_10x8_Format=37818,RGBA_ASTC_10x10_Format=37819,RGBA_ASTC_12x10_Format=37820,RGBA_ASTC_12x12_Format=37821,RGBA_BPTC_Format=36492,LoopOnce=2200,LoopRepeat=2201,LoopPingPong=2202,InterpolateDiscrete=2300,InterpolateLinear=2301,InterpolateSmooth=2302,ZeroCurvatureEnding=2400,ZeroSlopeEnding=2401,WrapAroundEnding=2402,NormalAnimationBlendMode=2500,AdditiveAnimationBlendMode=2501,TrianglesDrawMode=0,LinearEncoding=3e3,sRGBEncoding=3001,BasicDepthPacking=3200,RGBADepthPacking=3201,TangentSpaceNormalMap=0,ObjectSpaceNormalMap=1,KeepStencilOp=7680,AlwaysStencilFunc=519,StaticDrawUsage=35044,DynamicDrawUsage=35048,GLSL3="300 es",_SRGBAFormat=1035;class EventDispatcher{addEventListener(e,t){void 0===this._listeners&&(this._listeners={});const n=this._listeners;void 0===n[e]&&(n[e]=[]),-1===n[e].indexOf(t)&&n[e].push(t)}hasEventListener(e,t){if(void 0===this._listeners)return!1;const n=this._listeners;return void 0!==n[e]&&-1!==n[e].indexOf(t)}removeEventListener(e,t){if(void 0===this._listeners)return;const n=this._listeners[e];if(void 0!==n){const e=n.indexOf(t);-1!==e&&n.splice(e,1)}}dispatchEvent(e){if(void 0===this._listeners)return;const t=this._listeners[e.type];if(void 0!==t){e.target=this;const n=t.slice(0);for(let t=0,r=n.length;t<r;t++)n[t].call(this,e);e.target=null}}}const _lut=[];for(let e=0;e<256;e++)_lut[e]=(e<16?"0":"")+e.toString(16);const DEG2RAD=Math.PI/180,RAD2DEG=180/Math.PI;function generateUUID(){const e=4294967295*Math.random()|0,t=4294967295*Math.random()|0,n=4294967295*Math.random()|0,r=4294967295*Math.random()|0;return(_lut[255&e]+_lut[e>>8&255]+_lut[e>>16&255]+_lut[e>>24&255]+"-"+_lut[255&t]+_lut[t>>8&255]+"-"+_lut[t>>16&15|64]+_lut[t>>24&255]+"-"+_lut[63&n|128]+_lut[n>>8&255]+"-"+_lut[n>>16&255]+_lut[n>>24&255]+_lut[255&r]+_lut[r>>8&255]+_lut[r>>16&255]+_lut[r>>24&255]).toUpperCase()}function clamp(e,t,n){return Math.max(t,Math.min(n,e))}function euclideanModulo(e,t){return(e%t+t)%t}function lerp(e,t,n){return(1-n)*e+n*t}function isPowerOfTwo(e){return 0==(e&e-1)&&0!==e}function floorPowerOfTwo(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}class Vector2{constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e,t){return void 0!==t?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this)}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e,t){return void 0!==t?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this)}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t,n){return void 0!==n&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),r=Math.sin(t),i=this.x-e.x,a=this.y-e.y;return this.x=i*n-a*r+e.x,this.y=i*r+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}Vector2.prototype.isVector2=!0;class Matrix3{constructor(){this.elements=[1,0,0,0,1,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")}set(e,t,n,r,i,a,o,s,l){const c=this.elements;return c[0]=e,c[1]=r,c[2]=o,c[3]=t,c[4]=i,c[5]=s,c[6]=n,c[7]=a,c[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[3],s=n[6],l=n[1],c=n[4],h=n[7],u=n[2],d=n[5],p=n[8],m=r[0],f=r[3],g=r[6],v=r[1],y=r[4],_=r[7],b=r[2],x=r[5],S=r[8];return i[0]=a*m+o*v+s*b,i[3]=a*f+o*y+s*x,i[6]=a*g+o*_+s*S,i[1]=l*m+c*v+h*b,i[4]=l*f+c*y+h*x,i[7]=l*g+c*_+h*S,i[2]=u*m+d*v+p*b,i[5]=u*f+d*y+p*x,i[8]=u*g+d*_+p*S,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],l=e[7],c=e[8];return t*a*c-t*o*l-n*i*c+n*o*s+r*i*l-r*a*s}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],l=e[7],c=e[8],h=c*a-o*l,u=o*s-c*i,d=l*i-a*s,p=t*h+n*u+r*d;if(0===p)return this.set(0,0,0,0,0,0,0,0,0);const m=1/p;return e[0]=h*m,e[1]=(r*l-c*n)*m,e[2]=(o*n-r*a)*m,e[3]=u*m,e[4]=(c*t-r*s)*m,e[5]=(r*i-o*t)*m,e[6]=d*m,e[7]=(n*s-l*t)*m,e[8]=(a*t-n*i)*m,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,r,i,a,o){const s=Math.cos(i),l=Math.sin(i);return this.set(n*s,n*l,-n*(s*a+l*o)+a+e,-r*l,r*s,-r*(-l*a+s*o)+o+t,0,0,1),this}scale(e,t){const n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=t,n[4]*=t,n[7]*=t,this}rotate(e){const t=Math.cos(e),n=Math.sin(e),r=this.elements,i=r[0],a=r[3],o=r[6],s=r[1],l=r[4],c=r[7];return r[0]=t*i+n*s,r[3]=t*a+n*l,r[6]=t*o+n*c,r[1]=-n*i+t*s,r[4]=-n*a+t*l,r[7]=-n*o+t*c,this}translate(e,t){const n=this.elements;return n[0]+=e*n[2],n[3]+=e*n[5],n[6]+=e*n[8],n[1]+=t*n[2],n[4]+=t*n[5],n[7]+=t*n[8],this}equals(e){const t=this.elements,n=e.elements;for(let e=0;e<9;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return(new this.constructor).fromArray(this.elements)}}function arrayNeedsUint32(e){for(let t=e.length-1;t>=0;--t)if(e[t]>65535)return!0;return!1}function createElementNS(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}Matrix3.prototype.isMatrix3=!0;const _colorKeywords={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},_hslA={h:0,s:0,l:0},_hslB={h:0,s:0,l:0};function hue2rgb(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+6*(t-e)*n:n<.5?t:n<2/3?e+6*(t-e)*(2/3-n):e}function SRGBToLinear(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}function LinearToSRGB(e){return e<.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}class Color$1{constructor(e,t,n){return void 0===t&&void 0===n?this.set(e):this.setRGB(e,t,n)}set(e){return e&&e.isColor?this.copy(e):"number"==typeof e?this.setHex(e):"string"==typeof e&&this.setStyle(e),this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,this}setRGB(e,t,n){return this.r=e,this.g=t,this.b=n,this}setHSL(e,t,n){if(e=euclideanModulo(e,1),t=clamp(t,0,1),n=clamp(n,0,1),0===t)this.r=this.g=this.b=n;else{const r=n<=.5?n*(1+t):n+t-n*t,i=2*n-r;this.r=hue2rgb(i,r,e+1/3),this.g=hue2rgb(i,r,e),this.b=hue2rgb(i,r,e-1/3)}return this}setStyle(e){function t(t){void 0!==t&&parseFloat(t)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let n;if(n=/^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(e)){let e;const r=n[2];switch(n[1]){case"rgb":case"rgba":if(e=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(r))return this.r=Math.min(255,parseInt(e[1],10))/255,this.g=Math.min(255,parseInt(e[2],10))/255,this.b=Math.min(255,parseInt(e[3],10))/255,t(e[4]),this;if(e=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(r))return this.r=Math.min(100,parseInt(e[1],10))/100,this.g=Math.min(100,parseInt(e[2],10))/100,this.b=Math.min(100,parseInt(e[3],10))/100,t(e[4]),this;break;case"hsl":case"hsla":if(e=/^\s*(\d*\.?\d+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(r)){const n=parseFloat(e[1])/360,r=parseInt(e[2],10)/100,i=parseInt(e[3],10)/100;return t(e[4]),this.setHSL(n,r,i)}}}else if(n=/^\#([A-Fa-f\d]+)$/.exec(e)){const e=n[1],t=e.length;if(3===t)return this.r=parseInt(e.charAt(0)+e.charAt(0),16)/255,this.g=parseInt(e.charAt(1)+e.charAt(1),16)/255,this.b=parseInt(e.charAt(2)+e.charAt(2),16)/255,this;if(6===t)return this.r=parseInt(e.charAt(0)+e.charAt(1),16)/255,this.g=parseInt(e.charAt(2)+e.charAt(3),16)/255,this.b=parseInt(e.charAt(4)+e.charAt(5),16)/255,this}return e&&e.length>0?this.setColorName(e):this}setColorName(e){const t=_colorKeywords[e.toLowerCase()];return void 0!==t?this.setHex(t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=SRGBToLinear(e.r),this.g=SRGBToLinear(e.g),this.b=SRGBToLinear(e.b),this}copyLinearToSRGB(e){return this.r=LinearToSRGB(e.r),this.g=LinearToSRGB(e.g),this.b=LinearToSRGB(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0}getHexString(){return("000000"+this.getHex().toString(16)).slice(-6)}getHSL(e){const t=this.r,n=this.g,r=this.b,i=Math.max(t,n,r),a=Math.min(t,n,r);let o,s;const l=(a+i)/2;if(a===i)o=0,s=0;else{const e=i-a;switch(s=l<=.5?e/(i+a):e/(2-i-a),i){case t:o=(n-r)/e+(n<r?6:0);break;case n:o=(r-t)/e+2;break;case r:o=(t-n)/e+4}o/=6}return e.h=o,e.s=s,e.l=l,e}getStyle(){return"rgb("+(255*this.r|0)+","+(255*this.g|0)+","+(255*this.b|0)+")"}offsetHSL(e,t,n){return this.getHSL(_hslA),_hslA.h+=e,_hslA.s+=t,_hslA.l+=n,this.setHSL(_hslA.h,_hslA.s,_hslA.l),this}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(_hslA),e.getHSL(_hslB);const n=lerp(_hslA.h,_hslB.h,t),r=lerp(_hslA.s,_hslB.s,t),i=lerp(_hslA.l,_hslB.l,t);return this.setHSL(n,r,i),this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),!0===e.normalized&&(this.r/=255,this.g/=255,this.b/=255),this}toJSON(){return this.getHex()}}let _canvas;Color$1.NAMES=_colorKeywords,Color$1.prototype.isColor=!0,Color$1.prototype.r=1,Color$1.prototype.g=1,Color$1.prototype.b=1;class ImageUtils{static getDataURL(e){if(/^data:/i.test(e.src))return e.src;if("undefined"==typeof HTMLCanvasElement)return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{void 0===_canvas&&(_canvas=createElementNS("canvas")),_canvas.width=e.width,_canvas.height=e.height;const n=_canvas.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=_canvas}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){const t=createElementNS("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const r=n.getImageData(0,0,e.width,e.height),i=r.data;for(let e=0;e<i.length;e++)i[e]=255*SRGBToLinear(i[e]/255);return n.putImageData(r,0,0),t}if(e.data){const t=e.data.slice(0);for(let e=0;e<t.length;e++)t[e]=t instanceof Uint8Array||t instanceof Uint8ClampedArray?Math.floor(255*SRGBToLinear(t[e]/255)):SRGBToLinear(t[e]);return{data:t,width:e.width,height:e.height}}return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let textureId=0;class Texture extends EventDispatcher{constructor(e=Texture.DEFAULT_IMAGE,t=Texture.DEFAULT_MAPPING,n=ClampToEdgeWrapping,r=ClampToEdgeWrapping,i=LinearFilter,a=LinearMipmapLinearFilter,o=RGBAFormat,s=UnsignedByteType,l=1,c=LinearEncoding){super(),Object.defineProperty(this,"id",{value:textureId++}),this.uuid=generateUUID(),this.name="",this.image=e,this.mipmaps=[],this.mapping=t,this.wrapS=n,this.wrapT=r,this.magFilter=i,this.minFilter=a,this.anisotropy=l,this.format=o,this.internalFormat=null,this.type=s,this.offset=new Vector2(0,0),this.repeat=new Vector2(1,1),this.center=new Vector2(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Matrix3,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=c,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.needsPMREMUpdate=!1}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return(new this.constructor).copy(this)}copy(e){return this.name=e.name,this.image=e.image,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.encoding=e.encoding,this.userData=JSON.parse(JSON.stringify(e.userData)),this}toJSON(e){const t=void 0===e||"string"==typeof e;if(!t&&void 0!==e.textures[this.uuid])return e.textures[this.uuid];const n={metadata:{version:4.5,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,mapping:this.mapping,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,type:this.type,encoding:this.encoding,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};if(void 0!==this.image){const r=this.image;if(void 0===r.uuid&&(r.uuid=generateUUID()),!t&&void 0===e.images[r.uuid]){let t;if(Array.isArray(r)){t=[];for(let e=0,n=r.length;e<n;e++)t.push(serializeImage(r[e].isDataTexture?r[e].image:r[e]))}else t=serializeImage(r);e.images[r.uuid]={uuid:r.uuid,url:t}}n.image=r.uuid}return"{}"!==JSON.stringify(this.userData)&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==UVMapping)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case RepeatWrapping:e.x=e.x-Math.floor(e.x);break;case ClampToEdgeWrapping:e.x=e.x<0?0:1;break;case MirroredRepeatWrapping:e.x=1===Math.abs(Math.floor(e.x)%2)?Math.ceil(e.x)-e.x:e.x-Math.floor(e.x)}if(e.y<0||e.y>1)switch(this.wrapT){case RepeatWrapping:e.y=e.y-Math.floor(e.y);break;case ClampToEdgeWrapping:e.y=e.y<0?0:1;break;case MirroredRepeatWrapping:e.y=1===Math.abs(Math.floor(e.y)%2)?Math.ceil(e.y)-e.y:e.y-Math.floor(e.y)}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){!0===e&&this.version++}}function serializeImage(e){return"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap?ImageUtils.getDataURL(e):e.data?{data:Array.prototype.slice.call(e.data),width:e.width,height:e.height,type:e.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}Texture.DEFAULT_IMAGE=void 0,Texture.DEFAULT_MAPPING=UVMapping,Texture.prototype.isTexture=!0;class Vector4{constructor(e=0,t=0,n=0,r=1){this.x=e,this.y=t,this.z=n,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=void 0!==e.w?e.w:1,this}add(e,t){return void 0!==t?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this)}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e,t){return void 0!==t?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this)}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,n=this.y,r=this.z,i=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*i,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*i,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*i,this.w=a[3]*t+a[7]*n+a[11]*r+a[15]*i,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,r,i;const a=.01,o=.1,s=e.elements,l=s[0],c=s[4],h=s[8],u=s[1],d=s[5],p=s[9],m=s[2],f=s[6],g=s[10];if(Math.abs(c-u)<a&&Math.abs(h-m)<a&&Math.abs(p-f)<a){if(Math.abs(c+u)<o&&Math.abs(h+m)<o&&Math.abs(p+f)<o&&Math.abs(l+d+g-3)<o)return this.set(1,0,0,0),this;t=Math.PI;const e=(l+1)/2,s=(d+1)/2,v=(g+1)/2,y=(c+u)/4,_=(h+m)/4,b=(p+f)/4;return e>s&&e>v?e<a?(n=0,r=.707106781,i=.707106781):(n=Math.sqrt(e),r=y/n,i=_/n):s>v?s<a?(n=.707106781,r=0,i=.707106781):(r=Math.sqrt(s),n=y/r,i=b/r):v<a?(n=.707106781,r=.707106781,i=0):(i=Math.sqrt(v),n=_/i,r=b/i),this.set(n,r,i,t),this}let v=Math.sqrt((f-p)*(f-p)+(h-m)*(h-m)+(u-c)*(u-c));return Math.abs(v)<.001&&(v=1),this.x=(f-p)/v,this.y=(h-m)/v,this.z=(u-c)/v,this.w=Math.acos((l+d+g-1)/2),this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t,n){return void 0!==n&&console.warn("THREE.Vector4: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}Vector4.prototype.isVector4=!0;class WebGLRenderTarget extends EventDispatcher{constructor(e,t,n={}){super(),this.width=e,this.height=t,this.depth=1,this.scissor=new Vector4(0,0,e,t),this.scissorTest=!1,this.viewport=new Vector4(0,0,e,t),this.texture=new Texture(void 0,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.encoding),this.texture.isRenderTargetTexture=!0,this.texture.image={width:e,height:t,depth:1},this.texture.generateMipmaps=void 0!==n.generateMipmaps&&n.generateMipmaps,this.texture.internalFormat=void 0!==n.internalFormat?n.internalFormat:null,this.texture.minFilter=void 0!==n.minFilter?n.minFilter:LinearFilter,this.depthBuffer=void 0===n.depthBuffer||n.depthBuffer,this.stencilBuffer=void 0!==n.stencilBuffer&&n.stencilBuffer,this.depthTexture=void 0!==n.depthTexture?n.depthTexture:null}setTexture(e){e.image={width:this.width,height:this.height,depth:this.depth},this.texture=e}setSize(e,t,n=1){this.width===e&&this.height===t&&this.depth===n||(this.width=e,this.height=t,this.depth=n,this.texture.image.width=e,this.texture.image.height=t,this.texture.image.depth=n,this.dispose()),this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return(new this.constructor).copy(this)}copy(e){return this.width=e.width,this.height=e.height,this.depth=e.depth,this.viewport.copy(e.viewport),this.texture=e.texture.clone(),this.texture.image=Object.assign({},e.texture.image),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.depthTexture=e.depthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}}WebGLRenderTarget.prototype.isWebGLRenderTarget=!0;class WebGLMultipleRenderTargets extends WebGLRenderTarget{constructor(e,t,n){super(e,t);const r=this.texture;this.texture=[];for(let e=0;e<n;e++)this.texture[e]=r.clone()}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let r=0,i=this.texture.length;r<i;r++)this.texture[r].image.width=e,this.texture[r].image.height=t,this.texture[r].image.depth=n;this.dispose()}return this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t),this}copy(e){this.dispose(),this.width=e.width,this.height=e.height,this.depth=e.depth,this.viewport.set(0,0,this.width,this.height),this.scissor.set(0,0,this.width,this.height),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.depthTexture=e.depthTexture,this.texture.length=0;for(let t=0,n=e.texture.length;t<n;t++)this.texture[t]=e.texture[t].clone();return this}}WebGLMultipleRenderTargets.prototype.isWebGLMultipleRenderTargets=!0;class WebGLMultisampleRenderTarget extends WebGLRenderTarget{constructor(e,t,n={}){super(e,t,n),this.samples=4,this.ignoreDepthForMultisampleCopy=void 0===n.ignoreDepth||n.ignoreDepth,this.useRenderToTexture=void 0!==n.useRenderToTexture&&n.useRenderToTexture,this.useRenderbuffer=!1===this.useRenderToTexture}copy(e){return super.copy.call(this,e),this.samples=e.samples,this.useRenderToTexture=e.useRenderToTexture,this.useRenderbuffer=e.useRenderbuffer,this}}WebGLMultisampleRenderTarget.prototype.isWebGLMultisampleRenderTarget=!0;class Quaternion{constructor(e=0,t=0,n=0,r=1){this._x=e,this._y=t,this._z=n,this._w=r}static slerp(e,t,n,r){return console.warn("THREE.Quaternion: Static .slerp() has been deprecated. Use qm.slerpQuaternions( qa, qb, t ) instead."),n.slerpQuaternions(e,t,r)}static slerpFlat(e,t,n,r,i,a,o){let s=n[r+0],l=n[r+1],c=n[r+2],h=n[r+3];const u=i[a+0],d=i[a+1],p=i[a+2],m=i[a+3];if(0===o)return e[t+0]=s,e[t+1]=l,e[t+2]=c,void(e[t+3]=h);if(1===o)return e[t+0]=u,e[t+1]=d,e[t+2]=p,void(e[t+3]=m);if(h!==m||s!==u||l!==d||c!==p){let e=1-o;const t=s*u+l*d+c*p+h*m,n=t>=0?1:-1,r=1-t*t;if(r>Number.EPSILON){const i=Math.sqrt(r),a=Math.atan2(i,t*n);e=Math.sin(e*a)/i,o=Math.sin(o*a)/i}const i=o*n;if(s=s*e+u*i,l=l*e+d*i,c=c*e+p*i,h=h*e+m*i,e===1-o){const e=1/Math.sqrt(s*s+l*l+c*c+h*h);s*=e,l*=e,c*=e,h*=e}}e[t]=s,e[t+1]=l,e[t+2]=c,e[t+3]=h}static multiplyQuaternionsFlat(e,t,n,r,i,a){const o=n[r],s=n[r+1],l=n[r+2],c=n[r+3],h=i[a],u=i[a+1],d=i[a+2],p=i[a+3];return e[t]=o*p+c*h+s*d-l*u,e[t+1]=s*p+c*u+l*h-o*d,e[t+2]=l*p+c*d+o*u-s*h,e[t+3]=c*p-o*h-s*u-l*d,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t){if(!e||!e.isEuler)throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");const n=e._x,r=e._y,i=e._z,a=e._order,o=Math.cos,s=Math.sin,l=o(n/2),c=o(r/2),h=o(i/2),u=s(n/2),d=s(r/2),p=s(i/2);switch(a){case"XYZ":this._x=u*c*h+l*d*p,this._y=l*d*h-u*c*p,this._z=l*c*p+u*d*h,this._w=l*c*h-u*d*p;break;case"YXZ":this._x=u*c*h+l*d*p,this._y=l*d*h-u*c*p,this._z=l*c*p-u*d*h,this._w=l*c*h+u*d*p;break;case"ZXY":this._x=u*c*h-l*d*p,this._y=l*d*h+u*c*p,this._z=l*c*p+u*d*h,this._w=l*c*h-u*d*p;break;case"ZYX":this._x=u*c*h-l*d*p,this._y=l*d*h+u*c*p,this._z=l*c*p-u*d*h,this._w=l*c*h+u*d*p;break;case"YZX":this._x=u*c*h+l*d*p,this._y=l*d*h+u*c*p,this._z=l*c*p-u*d*h,this._w=l*c*h-u*d*p;break;case"XZY":this._x=u*c*h-l*d*p,this._y=l*d*h-u*c*p,this._z=l*c*p+u*d*h,this._w=l*c*h+u*d*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return!1!==t&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],r=t[4],i=t[8],a=t[1],o=t[5],s=t[9],l=t[2],c=t[6],h=t[10],u=n+o+h;if(u>0){const e=.5/Math.sqrt(u+1);this._w=.25/e,this._x=(c-s)*e,this._y=(i-l)*e,this._z=(a-r)*e}else if(n>o&&n>h){const e=2*Math.sqrt(1+n-o-h);this._w=(c-s)/e,this._x=.25*e,this._y=(r+a)/e,this._z=(i+l)/e}else if(o>h){const e=2*Math.sqrt(1+o-n-h);this._w=(i-l)/e,this._x=(r+a)/e,this._y=.25*e,this._z=(s+c)/e}else{const e=2*Math.sqrt(1+h-n-o);this._w=(a-r)/e,this._x=(i+l)/e,this._y=(s+c)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<Number.EPSILON?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(clamp(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(0===n)return this;const r=Math.min(1,t/n);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return 0===e?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e,t){return void 0!==t?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(e,t)):this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,r=e._y,i=e._z,a=e._w,o=t._x,s=t._y,l=t._z,c=t._w;return this._x=n*c+a*o+r*l-i*s,this._y=r*c+a*s+i*o-n*l,this._z=i*c+a*l+n*s-r*o,this._w=a*c-n*o-r*s-i*l,this._onChangeCallback(),this}slerp(e,t){if(0===t)return this;if(1===t)return this.copy(e);const n=this._x,r=this._y,i=this._z,a=this._w;let o=a*e._w+n*e._x+r*e._y+i*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=a,this._x=n,this._y=r,this._z=i,this;const s=1-o*o;if(s<=Number.EPSILON){const e=1-t;return this._w=e*a+t*this._w,this._x=e*n+t*this._x,this._y=e*r+t*this._y,this._z=e*i+t*this._z,this.normalize(),this._onChangeCallback(),this}const l=Math.sqrt(s),c=Math.atan2(l,o),h=Math.sin((1-t)*c)/l,u=Math.sin(t*c)/l;return this._w=a*h+this._w*u,this._x=n*h+this._x*u,this._y=r*h+this._y*u,this._z=i*h+this._z*u,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=Math.random(),t=Math.sqrt(1-e),n=Math.sqrt(e),r=2*Math.PI*Math.random(),i=2*Math.PI*Math.random();return this.set(t*Math.cos(r),n*Math.sin(i),n*Math.cos(i),t*Math.sin(r))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}}Quaternion.prototype.isQuaternion=!0;class Vector3{constructor(e=0,t=0,n=0){this.x=e,this.y=t,this.z=n}set(e,t,n){return void 0===n&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e,t){return void 0!==t?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this)}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e,t){return void 0!==t?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this)}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e,t){return void 0!==t?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(e,t)):(this.x*=e.x,this.y*=e.y,this.z*=e.z,this)}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return e&&e.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(_quaternion$4.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(_quaternion$4.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6]*r,this.y=i[1]*t+i[4]*n+i[7]*r,this.z=i[2]*t+i[5]*n+i[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,r=this.z,i=e.elements,a=1/(i[3]*t+i[7]*n+i[11]*r+i[15]);return this.x=(i[0]*t+i[4]*n+i[8]*r+i[12])*a,this.y=(i[1]*t+i[5]*n+i[9]*r+i[13])*a,this.z=(i[2]*t+i[6]*n+i[10]*r+i[14])*a,this}applyQuaternion(e){const t=this.x,n=this.y,r=this.z,i=e.x,a=e.y,o=e.z,s=e.w,l=s*t+a*r-o*n,c=s*n+o*t-i*r,h=s*r+i*n-a*t,u=-i*t-a*n-o*r;return this.x=l*s+u*-i+c*-o-h*-a,this.y=c*s+u*-a+h*-i-l*-o,this.z=h*s+u*-o+l*-a-c*-i,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[4]*n+i[8]*r,this.y=i[1]*t+i[5]*n+i[9]*r,this.z=i[2]*t+i[6]*n+i[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e,t){return void 0!==t?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(e,t)):this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,r=e.y,i=e.z,a=t.x,o=t.y,s=t.z;return this.x=r*s-i*o,this.y=i*a-n*s,this.z=n*o-r*a,this}projectOnVector(e){const t=e.lengthSq();if(0===t)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return _vector$c.copy(this).projectOnVector(e),this.sub(_vector$c)}reflect(e){return this.sub(_vector$c.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===t)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(clamp(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,4*t)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,3*t)}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t,n){return void 0!==n&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=2*(Math.random()-.5),t=Math.random()*Math.PI*2,n=Math.sqrt(1-e**2);return this.x=n*Math.cos(t),this.y=n*Math.sin(t),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}Vector3.prototype.isVector3=!0;const _vector$c=new Vector3,_quaternion$4=new Quaternion;class Box3{constructor(e=new Vector3(1/0,1/0,1/0),t=new Vector3(-1/0,-1/0,-1/0)){this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){let t=1/0,n=1/0,r=1/0,i=-1/0,a=-1/0,o=-1/0;for(let s=0,l=e.length;s<l;s+=3){const l=e[s],c=e[s+1],h=e[s+2];l<t&&(t=l),c<n&&(n=c),h<r&&(r=h),l>i&&(i=l),c>a&&(a=c),h>o&&(o=h)}return this.min.set(t,n,r),this.max.set(i,a,o),this}setFromBufferAttribute(e){let t=1/0,n=1/0,r=1/0,i=-1/0,a=-1/0,o=-1/0;for(let s=0,l=e.count;s<l;s++){const l=e.getX(s),c=e.getY(s),h=e.getZ(s);l<t&&(t=l),c<n&&(n=c),h<r&&(r=h),l>i&&(i=l),c>a&&(a=c),h>o&&(o=h)}return this.min.set(t,n,r),this.max.set(i,a,o),this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=_vector$b.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return(new this.constructor).copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);const n=e.geometry;if(void 0!==n)if(t&&null!=n.attributes&&void 0!==n.attributes.position){const t=n.attributes.position;for(let n=0,r=t.count;n<r;n++)_vector$b.fromBufferAttribute(t,n).applyMatrix4(e.matrixWorld),this.expandByPoint(_vector$b)}else null===n.boundingBox&&n.computeBoundingBox(),_box$3.copy(n.boundingBox),_box$3.applyMatrix4(e.matrixWorld),this.union(_box$3);const r=e.children;for(let e=0,n=r.length;e<n;e++)this.expandByObject(r[e],t);return this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y||e.z<this.min.z||e.z>this.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y||e.max.z<this.min.z||e.min.z>this.max.z)}intersectsSphere(e){return this.clampPoint(e.center,_vector$b),_vector$b.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(_center),_extents.subVectors(this.max,_center),_v0$2.subVectors(e.a,_center),_v1$7.subVectors(e.b,_center),_v2$3.subVectors(e.c,_center),_f0.subVectors(_v1$7,_v0$2),_f1.subVectors(_v2$3,_v1$7),_f2.subVectors(_v0$2,_v2$3);let t=[0,-_f0.z,_f0.y,0,-_f1.z,_f1.y,0,-_f2.z,_f2.y,_f0.z,0,-_f0.x,_f1.z,0,-_f1.x,_f2.z,0,-_f2.x,-_f0.y,_f0.x,0,-_f1.y,_f1.x,0,-_f2.y,_f2.x,0];return!!satForAxes(t,_v0$2,_v1$7,_v2$3,_extents)&&(t=[1,0,0,0,1,0,0,0,1],!!satForAxes(t,_v0$2,_v1$7,_v2$3,_extents)&&(_triangleNormal.crossVectors(_f0,_f1),t=[_triangleNormal.x,_triangleNormal.y,_triangleNormal.z],satForAxes(t,_v0$2,_v1$7,_v2$3,_extents)))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return _vector$b.copy(e).clamp(this.min,this.max).sub(e).length()}getBoundingSphere(e){return this.getCenter(e.center),e.radius=.5*this.getSize(_vector$b).length(),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()||(_points[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),_points[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),_points[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),_points[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),_points[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),_points[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),_points[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),_points[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(_points)),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}Box3.prototype.isBox3=!0;const _points=[new Vector3,new Vector3,new Vector3,new Vector3,new Vector3,new Vector3,new Vector3,new Vector3],_vector$b=new Vector3,_box$3=new Box3,_v0$2=new Vector3,_v1$7=new Vector3,_v2$3=new Vector3,_f0=new Vector3,_f1=new Vector3,_f2=new Vector3,_center=new Vector3,_extents=new Vector3,_triangleNormal=new Vector3,_testAxis=new Vector3;function satForAxes(e,t,n,r,i){for(let a=0,o=e.length-3;a<=o;a+=3){_testAxis.fromArray(e,a);const o=i.x*Math.abs(_testAxis.x)+i.y*Math.abs(_testAxis.y)+i.z*Math.abs(_testAxis.z),s=t.dot(_testAxis),l=n.dot(_testAxis),c=r.dot(_testAxis);if(Math.max(-Math.max(s,l,c),Math.min(s,l,c))>o)return!1}return!0}const _box$2=new Box3,_v1$6=new Vector3,_toFarthestPoint=new Vector3,_toPoint=new Vector3;class Sphere{constructor(e=new Vector3,t=-1){this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;void 0!==t?n.copy(t):_box$2.setFromPoints(e).getCenter(n);let r=0;for(let t=0,i=e.length;t<i;t++)r=Math.max(r,n.distanceToSquared(e[t]));return this.radius=Math.sqrt(r),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){const n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){_toPoint.subVectors(e,this.center);const t=_toPoint.lengthSq();if(t>this.radius*this.radius){const e=Math.sqrt(t),n=.5*(e-this.radius);this.center.add(_toPoint.multiplyScalar(n/e)),this.radius+=n}return this}union(e){return!0===this.center.equals(e.center)?_toFarthestPoint.set(0,0,1).multiplyScalar(e.radius):_toFarthestPoint.subVectors(e.center,this.center).normalize().multiplyScalar(e.radius),this.expandByPoint(_v1$6.copy(e.center).add(_toFarthestPoint)),this.expandByPoint(_v1$6.copy(e.center).sub(_toFarthestPoint)),this}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return(new this.constructor).copy(this)}}const _vector$a=new Vector3,_segCenter=new Vector3,_segDir=new Vector3,_diff=new Vector3,_edge1=new Vector3,_edge2=new Vector3,_normal$1=new Vector3;class Ray{constructor(e=new Vector3,t=new Vector3(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.direction).multiplyScalar(e).add(this.origin)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,_vector$a)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.direction).multiplyScalar(n).add(this.origin)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=_vector$a.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(_vector$a.copy(this.direction).multiplyScalar(t).add(this.origin),_vector$a.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){_segCenter.copy(e).add(t).multiplyScalar(.5),_segDir.copy(t).sub(e).normalize(),_diff.copy(this.origin).sub(_segCenter);const i=.5*e.distanceTo(t),a=-this.direction.dot(_segDir),o=_diff.dot(this.direction),s=-_diff.dot(_segDir),l=_diff.lengthSq(),c=Math.abs(1-a*a);let h,u,d,p;if(c>0)if(h=a*s-o,u=a*o-s,p=i*c,h>=0)if(u>=-p)if(u<=p){const e=1/c;h*=e,u*=e,d=h*(h+a*u+2*o)+u*(a*h+u+2*s)+l}else u=i,h=Math.max(0,-(a*u+o)),d=-h*h+u*(u+2*s)+l;else u=-i,h=Math.max(0,-(a*u+o)),d=-h*h+u*(u+2*s)+l;else u<=-p?(h=Math.max(0,-(-a*i+o)),u=h>0?-i:Math.min(Math.max(-i,-s),i),d=-h*h+u*(u+2*s)+l):u<=p?(h=0,u=Math.min(Math.max(-i,-s),i),d=u*(u+2*s)+l):(h=Math.max(0,-(a*i+o)),u=h>0?i:Math.min(Math.max(-i,-s),i),d=-h*h+u*(u+2*s)+l);else u=a>0?-i:i,h=Math.max(0,-(a*u+o)),d=-h*h+u*(u+2*s)+l;return n&&n.copy(this.direction).multiplyScalar(h).add(this.origin),r&&r.copy(_segDir).multiplyScalar(u).add(_segCenter),d}intersectSphere(e,t){_vector$a.subVectors(e.center,this.origin);const n=_vector$a.dot(this.direction),r=_vector$a.dot(_vector$a)-n*n,i=e.radius*e.radius;if(r>i)return null;const a=Math.sqrt(i-r),o=n-a,s=n+a;return o<0&&s<0?null:this.at(o<0?s:o,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(0===t)return 0===e.distanceToPoint(this.origin)?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return null===n?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);if(0===t)return!0;return e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,r,i,a,o,s;const l=1/this.direction.x,c=1/this.direction.y,h=1/this.direction.z,u=this.origin;return l>=0?(n=(e.min.x-u.x)*l,r=(e.max.x-u.x)*l):(n=(e.max.x-u.x)*l,r=(e.min.x-u.x)*l),c>=0?(i=(e.min.y-u.y)*c,a=(e.max.y-u.y)*c):(i=(e.max.y-u.y)*c,a=(e.min.y-u.y)*c),n>a||i>r?null:((i>n||n!=n)&&(n=i),(a<r||r!=r)&&(r=a),h>=0?(o=(e.min.z-u.z)*h,s=(e.max.z-u.z)*h):(o=(e.max.z-u.z)*h,s=(e.min.z-u.z)*h),n>s||o>r?null:((o>n||n!=n)&&(n=o),(s<r||r!=r)&&(r=s),r<0?null:this.at(n>=0?n:r,t)))}intersectsBox(e){return null!==this.intersectBox(e,_vector$a)}intersectTriangle(e,t,n,r,i){_edge1.subVectors(t,e),_edge2.subVectors(n,e),_normal$1.crossVectors(_edge1,_edge2);let a,o=this.direction.dot(_normal$1);if(o>0){if(r)return null;a=1}else{if(!(o<0))return null;a=-1,o=-o}_diff.subVectors(this.origin,e);const s=a*this.direction.dot(_edge2.crossVectors(_diff,_edge2));if(s<0)return null;const l=a*this.direction.dot(_edge1.cross(_diff));if(l<0)return null;if(s+l>o)return null;const c=-a*_diff.dot(_normal$1);return c<0?null:this.at(c/o,i)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return(new this.constructor).copy(this)}}class Matrix4{constructor(){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")}set(e,t,n,r,i,a,o,s,l,c,h,u,d,p,m,f){const g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=r,g[1]=i,g[5]=a,g[9]=o,g[13]=s,g[2]=l,g[6]=c,g[10]=h,g[14]=u,g[3]=d,g[7]=p,g[11]=m,g[15]=f,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return(new Matrix4).fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,n=e.elements,r=1/_v1$5.setFromMatrixColumn(e,0).length(),i=1/_v1$5.setFromMatrixColumn(e,1).length(),a=1/_v1$5.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*i,t[5]=n[5]*i,t[6]=n[6]*i,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){e&&e.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");const t=this.elements,n=e.x,r=e.y,i=e.z,a=Math.cos(n),o=Math.sin(n),s=Math.cos(r),l=Math.sin(r),c=Math.cos(i),h=Math.sin(i);if("XYZ"===e.order){const e=a*c,n=a*h,r=o*c,i=o*h;t[0]=s*c,t[4]=-s*h,t[8]=l,t[1]=n+r*l,t[5]=e-i*l,t[9]=-o*s,t[2]=i-e*l,t[6]=r+n*l,t[10]=a*s}else if("YXZ"===e.order){const e=s*c,n=s*h,r=l*c,i=l*h;t[0]=e+i*o,t[4]=r*o-n,t[8]=a*l,t[1]=a*h,t[5]=a*c,t[9]=-o,t[2]=n*o-r,t[6]=i+e*o,t[10]=a*s}else if("ZXY"===e.order){const e=s*c,n=s*h,r=l*c,i=l*h;t[0]=e-i*o,t[4]=-a*h,t[8]=r+n*o,t[1]=n+r*o,t[5]=a*c,t[9]=i-e*o,t[2]=-a*l,t[6]=o,t[10]=a*s}else if("ZYX"===e.order){const e=a*c,n=a*h,r=o*c,i=o*h;t[0]=s*c,t[4]=r*l-n,t[8]=e*l+i,t[1]=s*h,t[5]=i*l+e,t[9]=n*l-r,t[2]=-l,t[6]=o*s,t[10]=a*s}else if("YZX"===e.order){const e=a*s,n=a*l,r=o*s,i=o*l;t[0]=s*c,t[4]=i-e*h,t[8]=r*h+n,t[1]=h,t[5]=a*c,t[9]=-o*c,t[2]=-l*c,t[6]=n*h+r,t[10]=e-i*h}else if("XZY"===e.order){const e=a*s,n=a*l,r=o*s,i=o*l;t[0]=s*c,t[4]=-h,t[8]=l*c,t[1]=e*h+i,t[5]=a*c,t[9]=n*h-r,t[2]=r*h-n,t[6]=o*c,t[10]=i*h+e}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(_zero,e,_one)}lookAt(e,t,n){const r=this.elements;return _z.subVectors(e,t),0===_z.lengthSq()&&(_z.z=1),_z.normalize(),_x.crossVectors(n,_z),0===_x.lengthSq()&&(1===Math.abs(n.z)?_z.x+=1e-4:_z.z+=1e-4,_z.normalize(),_x.crossVectors(n,_z)),_x.normalize(),_y.crossVectors(_z,_x),r[0]=_x.x,r[4]=_y.x,r[8]=_z.x,r[1]=_x.y,r[5]=_y.y,r[9]=_z.y,r[2]=_x.z,r[6]=_y.z,r[10]=_z.z,this}multiply(e,t){return void 0!==t?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(e,t)):this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[4],s=n[8],l=n[12],c=n[1],h=n[5],u=n[9],d=n[13],p=n[2],m=n[6],f=n[10],g=n[14],v=n[3],y=n[7],_=n[11],b=n[15],x=r[0],S=r[4],w=r[8],C=r[12],M=r[1],E=r[5],T=r[9],I=r[13],A=r[2],k=r[6],P=r[10],R=r[14],N=r[3],L=r[7],D=r[11],$=r[15];return i[0]=a*x+o*M+s*A+l*N,i[4]=a*S+o*E+s*k+l*L,i[8]=a*w+o*T+s*P+l*D,i[12]=a*C+o*I+s*R+l*$,i[1]=c*x+h*M+u*A+d*N,i[5]=c*S+h*E+u*k+d*L,i[9]=c*w+h*T+u*P+d*D,i[13]=c*C+h*I+u*R+d*$,i[2]=p*x+m*M+f*A+g*N,i[6]=p*S+m*E+f*k+g*L,i[10]=p*w+m*T+f*P+g*D,i[14]=p*C+m*I+f*R+g*$,i[3]=v*x+y*M+_*A+b*N,i[7]=v*S+y*E+_*k+b*L,i[11]=v*w+y*T+_*P+b*D,i[15]=v*C+y*I+_*R+b*$,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[4],r=e[8],i=e[12],a=e[1],o=e[5],s=e[9],l=e[13],c=e[2],h=e[6],u=e[10],d=e[14];return e[3]*(+i*s*h-r*l*h-i*o*u+n*l*u+r*o*d-n*s*d)+e[7]*(+t*s*d-t*l*u+i*a*u-r*a*d+r*l*c-i*s*c)+e[11]*(+t*l*h-t*o*d-i*a*h+n*a*d+i*o*c-n*l*c)+e[15]*(-r*o*c-t*s*h+t*o*u+r*a*h-n*a*u+n*s*c)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){const r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],l=e[7],c=e[8],h=e[9],u=e[10],d=e[11],p=e[12],m=e[13],f=e[14],g=e[15],v=h*f*l-m*u*l+m*s*d-o*f*d-h*s*g+o*u*g,y=p*u*l-c*f*l-p*s*d+a*f*d+c*s*g-a*u*g,_=c*m*l-p*h*l+p*o*d-a*m*d-c*o*g+a*h*g,b=p*h*s-c*m*s-p*o*u+a*m*u+c*o*f-a*h*f,x=t*v+n*y+r*_+i*b;if(0===x)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const S=1/x;return e[0]=v*S,e[1]=(m*u*i-h*f*i-m*r*d+n*f*d+h*r*g-n*u*g)*S,e[2]=(o*f*i-m*s*i+m*r*l-n*f*l-o*r*g+n*s*g)*S,e[3]=(h*s*i-o*u*i-h*r*l+n*u*l+o*r*d-n*s*d)*S,e[4]=y*S,e[5]=(c*f*i-p*u*i+p*r*d-t*f*d-c*r*g+t*u*g)*S,e[6]=(p*s*i-a*f*i-p*r*l+t*f*l+a*r*g-t*s*g)*S,e[7]=(a*u*i-c*s*i+c*r*l-t*u*l-a*r*d+t*s*d)*S,e[8]=_*S,e[9]=(p*h*i-c*m*i-p*n*d+t*m*d+c*n*g-t*h*g)*S,e[10]=(a*m*i-p*o*i+p*n*l-t*m*l-a*n*g+t*o*g)*S,e[11]=(c*o*i-a*h*i-c*n*l+t*h*l+a*n*d-t*o*d)*S,e[12]=b*S,e[13]=(c*m*r-p*h*r+p*n*u-t*m*u-c*n*f+t*h*f)*S,e[14]=(p*o*r-a*m*r-p*n*s+t*m*s+a*n*f-t*o*f)*S,e[15]=(a*h*r-c*o*r+c*n*s-t*h*s-a*n*u+t*o*u)*S,this}scale(e){const t=this.elements,n=e.x,r=e.y,i=e.z;return t[0]*=n,t[4]*=r,t[8]*=i,t[1]*=n,t[5]*=r,t[9]*=i,t[2]*=n,t[6]*=r,t[10]*=i,t[3]*=n,t[7]*=r,t[11]*=i,this}getMaxScaleOnAxis(){const e=this.elements;return Math.sqrt(Math.max(e[0]*e[0]+e[1]*e[1]+e[2]*e[2],e[4]*e[4]+e[5]*e[5]+e[6]*e[6],e[8]*e[8]+e[9]*e[9]+e[10]*e[10]))}makeTranslation(e,t,n){return this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),r=Math.sin(t),i=1-n,a=e.x,o=e.y,s=e.z,l=i*a,c=i*o;return this.set(l*a+n,l*o-r*s,l*s+r*o,0,l*o+r*s,c*o+n,c*s-r*a,0,l*s-r*o,c*s+r*a,i*s*s+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,r,i,a){return this.set(1,n,i,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){const r=this.elements,i=t._x,a=t._y,o=t._z,s=t._w,l=i+i,c=a+a,h=o+o,u=i*l,d=i*c,p=i*h,m=a*c,f=a*h,g=o*h,v=s*l,y=s*c,_=s*h,b=n.x,x=n.y,S=n.z;return r[0]=(1-(m+g))*b,r[1]=(d+_)*b,r[2]=(p-y)*b,r[3]=0,r[4]=(d-_)*x,r[5]=(1-(u+g))*x,r[6]=(f+v)*x,r[7]=0,r[8]=(p+y)*S,r[9]=(f-v)*S,r[10]=(1-(u+m))*S,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){const r=this.elements;let i=_v1$5.set(r[0],r[1],r[2]).length();const a=_v1$5.set(r[4],r[5],r[6]).length(),o=_v1$5.set(r[8],r[9],r[10]).length();this.determinant()<0&&(i=-i),e.x=r[12],e.y=r[13],e.z=r[14],_m1$2.copy(this);const s=1/i,l=1/a,c=1/o;return _m1$2.elements[0]*=s,_m1$2.elements[1]*=s,_m1$2.elements[2]*=s,_m1$2.elements[4]*=l,_m1$2.elements[5]*=l,_m1$2.elements[6]*=l,_m1$2.elements[8]*=c,_m1$2.elements[9]*=c,_m1$2.elements[10]*=c,t.setFromRotationMatrix(_m1$2),n.x=i,n.y=a,n.z=o,this}makePerspective(e,t,n,r,i,a){void 0===a&&console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");const o=this.elements,s=2*i/(n-r),l=(t+e)/(t-e),c=(n+r)/(n-r),h=-(a+i)/(a-i),u=-2*a*i/(a-i);return o[0]=2*i/(t-e),o[4]=0,o[8]=l,o[12]=0,o[1]=0,o[5]=s,o[9]=c,o[13]=0,o[2]=0,o[6]=0,o[10]=h,o[14]=u,o[3]=0,o[7]=0,o[11]=-1,o[15]=0,this}makeOrthographic(e,t,n,r,i,a){const o=this.elements,s=1/(t-e),l=1/(n-r),c=1/(a-i),h=(t+e)*s,u=(n+r)*l,d=(a+i)*c;return o[0]=2*s,o[4]=0,o[8]=0,o[12]=-h,o[1]=0,o[5]=2*l,o[9]=0,o[13]=-u,o[2]=0,o[6]=0,o[10]=-2*c,o[14]=-d,o[3]=0,o[7]=0,o[11]=0,o[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let e=0;e<16;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}Matrix4.prototype.isMatrix4=!0;const _v1$5=new Vector3,_m1$2=new Matrix4,_zero=new Vector3(0,0,0),_one=new Vector3(1,1,1),_x=new Vector3,_y=new Vector3,_z=new Vector3,_matrix$1=new Matrix4,_quaternion$3=new Quaternion;class Euler{constructor(e=0,t=0,n=0,r=Euler.DefaultOrder){this._x=e,this._y=t,this._z=n,this._order=r}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,r=this._order){return this._x=e,this._y=t,this._z=n,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const r=e.elements,i=r[0],a=r[4],o=r[8],s=r[1],l=r[5],c=r[9],h=r[2],u=r[6],d=r[10];switch(t){case"XYZ":this._y=Math.asin(clamp(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-c,d),this._z=Math.atan2(-a,i)):(this._x=Math.atan2(u,l),this._z=0);break;case"YXZ":this._x=Math.asin(-clamp(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(o,d),this._z=Math.atan2(s,l)):(this._y=Math.atan2(-h,i),this._z=0);break;case"ZXY":this._x=Math.asin(clamp(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-h,d),this._z=Math.atan2(-a,l)):(this._y=0,this._z=Math.atan2(s,i));break;case"ZYX":this._y=Math.asin(-clamp(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(u,d),this._z=Math.atan2(s,i)):(this._x=0,this._z=Math.atan2(-a,l));break;case"YZX":this._z=Math.asin(clamp(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-c,l),this._y=Math.atan2(-h,i)):(this._x=0,this._y=Math.atan2(o,d));break;case"XZY":this._z=Math.asin(-clamp(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(u,l),this._y=Math.atan2(o,i)):(this._x=Math.atan2(-c,d),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,!0===n&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return _matrix$1.makeRotationFromQuaternion(e),this.setFromRotationMatrix(_matrix$1,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return _quaternion$3.setFromEuler(this),this.setFromQuaternion(_quaternion$3,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],void 0!==e[3]&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}toVector3(e){return e?e.set(this._x,this._y,this._z):new Vector3(this._x,this._y,this._z)}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}}Euler.prototype.isEuler=!0,Euler.DefaultOrder="XYZ",Euler.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"];class Layers{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return 0!=(this.mask&e.mask)}isEnabled(e){return 0!=(this.mask&(1<<e|0))}}let _object3DId=0;const _v1$4=new Vector3,_q1=new Quaternion,_m1$1=new Matrix4,_target=new Vector3,_position$3=new Vector3,_scale$2=new Vector3,_quaternion$2=new Quaternion,_xAxis=new Vector3(1,0,0),_yAxis=new Vector3(0,1,0),_zAxis=new Vector3(0,0,1),_addedEvent={type:"added"},_removedEvent={type:"removed"};class Object3D extends EventDispatcher{constructor(){super(),Object.defineProperty(this,"id",{value:_object3DId++}),this.uuid=generateUUID(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Object3D.DefaultUp.clone();const e=new Vector3,t=new Euler,n=new Quaternion,r=new Vector3(1,1,1);t._onChange((function i(){n.setFromEuler(t,!1)})),n._onChange((function a(){t.setFromQuaternion(n,void 0,!1)})),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new Matrix4},normalMatrix:{value:new Matrix3}}),this.matrix=new Matrix4,this.matrixWorld=new Matrix4,this.matrixAutoUpdate=Object3D.DefaultMatrixAutoUpdate,this.matrixWorldNeedsUpdate=!1,this.layers=new Layers,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return _q1.setFromAxisAngle(e,t),this.quaternion.multiply(_q1),this}rotateOnWorldAxis(e,t){return _q1.setFromAxisAngle(e,t),this.quaternion.premultiply(_q1),this}rotateX(e){return this.rotateOnAxis(_xAxis,e)}rotateY(e){return this.rotateOnAxis(_yAxis,e)}rotateZ(e){return this.rotateOnAxis(_zAxis,e)}translateOnAxis(e,t){return _v1$4.copy(e).applyQuaternion(this.quaternion),this.position.add(_v1$4.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(_xAxis,e)}translateY(e){return this.translateOnAxis(_yAxis,e)}translateZ(e){return this.translateOnAxis(_zAxis,e)}localToWorld(e){return e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return e.applyMatrix4(_m1$1.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?_target.copy(e):_target.set(e,t,n);const r=this.parent;this.updateWorldMatrix(!0,!1),_position$3.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?_m1$1.lookAt(_position$3,_target,this.up):_m1$1.lookAt(_target,_position$3,this.up),this.quaternion.setFromRotationMatrix(_m1$1),r&&(_m1$1.extractRotation(r.matrixWorld),_q1.setFromRotationMatrix(_m1$1),this.quaternion.premultiply(_q1.invert()))}add(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(null!==e.parent&&e.parent.remove(e),e.parent=this,this.children.push(e),e.dispatchEvent(_addedEvent)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.remove(arguments[e]);return this}const t=this.children.indexOf(e);return-1!==t&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(_removedEvent)),this}removeFromParent(){const e=this.parent;return null!==e&&e.remove(this),this}clear(){for(let e=0;e<this.children.length;e++){const t=this.children[e];t.parent=null,t.dispatchEvent(_removedEvent)}return this.children.length=0,this}attach(e){return this.updateWorldMatrix(!0,!1),_m1$1.copy(this.matrixWorld).invert(),null!==e.parent&&(e.parent.updateWorldMatrix(!0,!1),_m1$1.multiply(e.parent.matrixWorld)),e.applyMatrix4(_m1$1),this.add(e),e.updateWorldMatrix(!1,!0),this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,r=this.children.length;n<r;n++){const r=this.children[n].getObjectByProperty(e,t);if(void 0!==r)return r}}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(_position$3,e,_scale$2),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(_position$3,_quaternion$2,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverse(e)}traverseVisible(e){if(!1===this.visible)return;e(this);const t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverseVisible(e)}traverseAncestors(e){const t=this.parent;null!==t&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t){const n=this.parent;if(!0===e&&null!==n&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),!0===t){const e=this.children;for(let t=0,n=e.length;t<n;t++)e[t].updateWorldMatrix(!1,!0)}}toJSON(e){const t=void 0===e||"string"==typeof e,n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{}},n.metadata={version:4.5,type:"Object",generator:"Object3D.toJSON"});const r={};function i(t,n){return void 0===t[n.uuid]&&(t[n.uuid]=n.toJSON(e)),n.uuid}if(r.uuid=this.uuid,r.type=this.type,""!==this.name&&(r.name=this.name),!0===this.castShadow&&(r.castShadow=!0),!0===this.receiveShadow&&(r.receiveShadow=!0),!1===this.visible&&(r.visible=!1),!1===this.frustumCulled&&(r.frustumCulled=!1),0!==this.renderOrder&&(r.renderOrder=this.renderOrder),"{}"!==JSON.stringify(this.userData)&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),!1===this.matrixAutoUpdate&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(r.instanceColor=this.instanceColor.toJSON())),this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=i(e.geometries,this.geometry);const t=this.geometry.parameters;if(void 0!==t&&void 0!==t.shapes){const n=t.shapes;if(Array.isArray(n))for(let t=0,r=n.length;t<r;t++){i(e.shapes,n[t])}else i(e.shapes,n)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),void 0!==this.skeleton&&(i(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),void 0!==this.material)if(Array.isArray(this.material)){const t=[];for(let n=0,r=this.material.length;n<r;n++)t.push(i(e.materials,this.material[n]));r.material=t}else r.material=i(e.materials,this.material);if(this.children.length>0){r.children=[];for(let t=0;t<this.children.length;t++)r.children.push(this.children[t].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let t=0;t<this.animations.length;t++){r.animations.push(i(e.animations,this.animations[t]))}}if(t){const t=a(e.geometries),r=a(e.materials),i=a(e.textures),o=a(e.images),s=a(e.shapes),l=a(e.skeletons),c=a(e.animations);t.length>0&&(n.geometries=t),r.length>0&&(n.materials=r),i.length>0&&(n.textures=i),o.length>0&&(n.images=o),s.length>0&&(n.shapes=s),l.length>0&&(n.skeletons=l),c.length>0&&(n.animations=c)}return n.object=r,n;function a(e){const t=[];for(const n in e){const r=e[n];delete r.metadata,t.push(r)}return t}}clone(e){return(new this.constructor).copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.userData=JSON.parse(JSON.stringify(e.userData)),!0===t)for(let t=0;t<e.children.length;t++){this.add(e.children[t].clone())}return this}}Object3D.DefaultUp=new Vector3(0,1,0),Object3D.DefaultMatrixAutoUpdate=!0,Object3D.prototype.isObject3D=!0;const _v0$1=new Vector3,_v1$3=new Vector3,_v2$2=new Vector3,_v3$1=new Vector3,_vab=new Vector3,_vac=new Vector3,_vbc=new Vector3,_vap=new Vector3,_vbp=new Vector3,_vcp=new Vector3;class Triangle{constructor(e=new Vector3,t=new Vector3,n=new Vector3){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,r){r.subVectors(n,t),_v0$1.subVectors(e,t),r.cross(_v0$1);const i=r.lengthSq();return i>0?r.multiplyScalar(1/Math.sqrt(i)):r.set(0,0,0)}static getBarycoord(e,t,n,r,i){_v0$1.subVectors(r,t),_v1$3.subVectors(n,t),_v2$2.subVectors(e,t);const a=_v0$1.dot(_v0$1),o=_v0$1.dot(_v1$3),s=_v0$1.dot(_v2$2),l=_v1$3.dot(_v1$3),c=_v1$3.dot(_v2$2),h=a*l-o*o;if(0===h)return i.set(-2,-1,-1);const u=1/h,d=(l*s-o*c)*u,p=(a*c-o*s)*u;return i.set(1-d-p,p,d)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,_v3$1),_v3$1.x>=0&&_v3$1.y>=0&&_v3$1.x+_v3$1.y<=1}static getUV(e,t,n,r,i,a,o,s){return this.getBarycoord(e,t,n,r,_v3$1),s.set(0,0),s.addScaledVector(i,_v3$1.x),s.addScaledVector(a,_v3$1.y),s.addScaledVector(o,_v3$1.z),s}static isFrontFacing(e,t,n,r){return _v0$1.subVectors(n,t),_v1$3.subVectors(e,t),_v0$1.cross(_v1$3).dot(r)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,n,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,r),this}clone(){return(new this.constructor).copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return _v0$1.subVectors(this.c,this.b),_v1$3.subVectors(this.a,this.b),.5*_v0$1.cross(_v1$3).length()}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Triangle.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Triangle.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,n,r,i){return Triangle.getUV(e,this.a,this.b,this.c,t,n,r,i)}containsPoint(e){return Triangle.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Triangle.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,r=this.b,i=this.c;let a,o;_vab.subVectors(r,n),_vac.subVectors(i,n),_vap.subVectors(e,n);const s=_vab.dot(_vap),l=_vac.dot(_vap);if(s<=0&&l<=0)return t.copy(n);_vbp.subVectors(e,r);const c=_vab.dot(_vbp),h=_vac.dot(_vbp);if(c>=0&&h<=c)return t.copy(r);const u=s*h-c*l;if(u<=0&&s>=0&&c<=0)return a=s/(s-c),t.copy(n).addScaledVector(_vab,a);_vcp.subVectors(e,i);const d=_vab.dot(_vcp),p=_vac.dot(_vcp);if(p>=0&&d<=p)return t.copy(i);const m=d*l-s*p;if(m<=0&&l>=0&&p<=0)return o=l/(l-p),t.copy(n).addScaledVector(_vac,o);const f=c*p-d*h;if(f<=0&&h-c>=0&&d-p>=0)return _vbc.subVectors(i,r),o=(h-c)/(h-c+(d-p)),t.copy(r).addScaledVector(_vbc,o);const g=1/(f+m+u);return a=m*g,o=u*g,t.copy(n).addScaledVector(_vab,a).addScaledVector(_vac,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}let materialId=0;class Material extends EventDispatcher{constructor(){super(),Object.defineProperty(this,"id",{value:materialId++}),this.uuid=generateUUID(),this.name="",this.type="Material",this.fog=!0,this.blending=NormalBlending,this.side=FrontSide,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.blendSrc=SrcAlphaFactor,this.blendDst=OneMinusSrcAlphaFactor,this.blendEquation=AddEquation,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=LessEqualDepth,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=AlwaysStencilFunc,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=KeepStencilOp,this.stencilZFail=KeepStencilOp,this.stencilZPass=KeepStencilOp,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.alphaWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(void 0!==e)for(const t in e){const n=e[t];if(void 0===n){console.warn("THREE.Material: '"+t+"' parameter is undefined.");continue}if("shading"===t){console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=n===FlatShading;continue}const r=this[t];void 0!==r?r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n:console.warn("THREE."+this.type+": '"+t+"' is not a property of this material.")}}toJSON(e){const t=void 0===e||"string"==typeof e;t&&(e={textures:{},images:{}});const n={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};function r(e){const t=[];for(const n in e){const r=e[n];delete r.metadata,t.push(r)}return t}if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),void 0!==this.roughness&&(n.roughness=this.roughness),void 0!==this.metalness&&(n.metalness=this.metalness),void 0!==this.sheen&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity&&1!==this.emissiveIntensity&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(n.shininess=this.shininess),void 0!==this.clearcoat&&(n.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,void 0!==this.combine&&(n.combine=this.combine)),void 0!==this.envMapIntensity&&(n.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(n.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),void 0!==this.transmission&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),void 0!==this.thickness&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),void 0!==this.attenuationDistance&&(n.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(n.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(n.size=this.size),null!==this.shadowSide&&(n.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==NormalBlending&&(n.blending=this.blending),this.side!==FrontSide&&(n.side=this.side),this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),!0===this.transparent&&(n.transparent=this.transparent),n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.alphaWrite=this.alphaWrite,n.stencilWrite=this.stencilWrite,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,this.rotation&&0!==this.rotation&&(n.rotation=this.rotation),!0===this.polygonOffset&&(n.polygonOffset=!0),0!==this.polygonOffsetFactor&&(n.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth&&1!==this.linewidth&&(n.linewidth=this.linewidth),void 0!==this.dashSize&&(n.dashSize=this.dashSize),void 0!==this.gapSize&&(n.gapSize=this.gapSize),void 0!==this.scale&&(n.scale=this.scale),!0===this.dithering&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),!0===this.alphaToCoverage&&(n.alphaToCoverage=this.alphaToCoverage),!0===this.premultipliedAlpha&&(n.premultipliedAlpha=this.premultipliedAlpha),!0===this.wireframe&&(n.wireframe=this.wireframe),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(n.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(n.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(n.flatShading=this.flatShading),!1===this.visible&&(n.visible=!1),!1===this.toneMapped&&(n.toneMapped=!1),"{}"!==JSON.stringify(this.userData)&&(n.userData=this.userData),t){const t=r(e.textures),i=r(e.images);t.length>0&&(n.textures=t),i.length>0&&(n.images=i)}return n}clone(){return(new this.constructor).copy(this)}copy(e){this.name=e.name,this.fog=e.fog,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let n=null;if(null!==t){const e=t.length;n=new Array(e);for(let r=0;r!==e;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.alphaWrite=e.alphaWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){!0===e&&this.version++}}Material.prototype.isMaterial=!0;class MeshBasicMaterial extends Material{constructor(e){super(),this.type="MeshBasicMaterial",this.color=new Color$1(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=MultiplyOperation,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this}}MeshBasicMaterial.prototype.isMeshBasicMaterial=!0;const _vector$9=new Vector3,_vector2$1=new Vector2;class BufferAttribute{constructor(e,t,n){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.name="",this.array=e,this.itemSize=t,this.count=void 0!==e?e.length/t:0,this.normalized=!0===n,this.usage=StaticDrawUsage,this.updateRange={offset:0,count:-1},this.version=0}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,i=this.itemSize;r<i;r++)this.array[e+r]=t.array[n+r];return this}copyArray(e){return this.array.set(e),this}copyColorsArray(e){const t=this.array;let n=0;for(let r=0,i=e.length;r<i;r++){let i=e[r];void 0===i&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",r),i=new Color$1),t[n++]=i.r,t[n++]=i.g,t[n++]=i.b}return this}copyVector2sArray(e){const t=this.array;let n=0;for(let r=0,i=e.length;r<i;r++){let i=e[r];void 0===i&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",r),i=new Vector2),t[n++]=i.x,t[n++]=i.y}return this}copyVector3sArray(e){const t=this.array;let n=0;for(let r=0,i=e.length;r<i;r++){let i=e[r];void 0===i&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",r),i=new Vector3),t[n++]=i.x,t[n++]=i.y,t[n++]=i.z}return this}copyVector4sArray(e){const t=this.array;let n=0;for(let r=0,i=e.length;r<i;r++){let i=e[r];void 0===i&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",r),i=new Vector4),t[n++]=i.x,t[n++]=i.y,t[n++]=i.z,t[n++]=i.w}return this}applyMatrix3(e){if(2===this.itemSize)for(let t=0,n=this.count;t<n;t++)_vector2$1.fromBufferAttribute(this,t),_vector2$1.applyMatrix3(e),this.setXY(t,_vector2$1.x,_vector2$1.y);else if(3===this.itemSize)for(let t=0,n=this.count;t<n;t++)_vector$9.fromBufferAttribute(this,t),_vector$9.applyMatrix3(e),this.setXYZ(t,_vector$9.x,_vector$9.y,_vector$9.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)_vector$9.x=this.getX(t),_vector$9.y=this.getY(t),_vector$9.z=this.getZ(t),_vector$9.applyMatrix4(e),this.setXYZ(t,_vector$9.x,_vector$9.y,_vector$9.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)_vector$9.x=this.getX(t),_vector$9.y=this.getY(t),_vector$9.z=this.getZ(t),_vector$9.applyNormalMatrix(e),this.setXYZ(t,_vector$9.x,_vector$9.y,_vector$9.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)_vector$9.x=this.getX(t),_vector$9.y=this.getY(t),_vector$9.z=this.getZ(t),_vector$9.transformDirection(e),this.setXYZ(t,_vector$9.x,_vector$9.y,_vector$9.z);return this}set(e,t=0){return this.array.set(e,t),this}getX(e){return this.array[e*this.itemSize]}setX(e,t){return this.array[e*this.itemSize]=t,this}getY(e){return this.array[e*this.itemSize+1]}setY(e,t){return this.array[e*this.itemSize+1]=t,this}getZ(e){return this.array[e*this.itemSize+2]}setZ(e,t){return this.array[e*this.itemSize+2]=t,this}getW(e){return this.array[e*this.itemSize+3]}setW(e,t){return this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return this.array[(e*=this.itemSize)+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,r){return this.array[(e*=this.itemSize)+0]=t,this.array[e+1]=n,this.array[e+2]=r,this}setXYZW(e,t,n,r,i){return this.array[(e*=this.itemSize)+0]=t,this.array[e+1]=n,this.array[e+2]=r,this.array[e+3]=i,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.prototype.slice.call(this.array),normalized:this.normalized};return""!==this.name&&(e.name=this.name),this.usage!==StaticDrawUsage&&(e.usage=this.usage),0===this.updateRange.offset&&-1===this.updateRange.count||(e.updateRange=this.updateRange),e}}BufferAttribute.prototype.isBufferAttribute=!0;class Uint16BufferAttribute extends BufferAttribute{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class Uint32BufferAttribute extends BufferAttribute{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class Float16BufferAttribute extends BufferAttribute{constructor(e,t,n){super(new Uint16Array(e),t,n)}}Float16BufferAttribute.prototype.isFloat16BufferAttribute=!0;class Float32BufferAttribute extends BufferAttribute{constructor(e,t,n){super(new Float32Array(e),t,n)}}let _id$1=0;const _m1=new Matrix4,_obj=new Object3D,_offset=new Vector3,_box$1=new Box3,_boxMorphTargets=new Box3,_vector$8=new Vector3;class BufferGeometry extends EventDispatcher{constructor(){super(),Object.defineProperty(this,"id",{value:_id$1++}),this.uuid=generateUUID(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return this.index=Array.isArray(e)?new(arrayNeedsUint32(e)?Uint32BufferAttribute:Uint16BufferAttribute)(e,1):e,this}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return void 0!==this.attributes[e]}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;void 0!==t&&(t.applyMatrix4(e),t.needsUpdate=!0);const n=this.attributes.normal;if(void 0!==n){const t=(new Matrix3).getNormalMatrix(e);n.applyNormalMatrix(t),n.needsUpdate=!0}const r=this.attributes.tangent;return void 0!==r&&(r.transformDirection(e),r.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}applyQuaternion(e){return _m1.makeRotationFromQuaternion(e),this.applyMatrix4(_m1),this}rotateX(e){return _m1.makeRotationX(e),this.applyMatrix4(_m1),this}rotateY(e){return _m1.makeRotationY(e),this.applyMatrix4(_m1),this}rotateZ(e){return _m1.makeRotationZ(e),this.applyMatrix4(_m1),this}translate(e,t,n){return _m1.makeTranslation(e,t,n),this.applyMatrix4(_m1),this}scale(e,t,n){return _m1.makeScale(e,t,n),this.applyMatrix4(_m1),this}lookAt(e){return _obj.lookAt(e),_obj.updateMatrix(),this.applyMatrix4(_obj.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(_offset).negate(),this.translate(_offset.x,_offset.y,_offset.z),this}setFromPoints(e){const t=[];for(let n=0,r=e.length;n<r;n++){const r=e[n];t.push(r.x,r.y,r.z||0)}return this.setAttribute("position",new Float32BufferAttribute(t,3)),this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new Box3);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute)return console.error('THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".',this),void this.boundingBox.set(new Vector3(-1/0,-1/0,-1/0),new Vector3(1/0,1/0,1/0));if(void 0!==e){if(this.boundingBox.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){_box$1.setFromBufferAttribute(t[e]),this.morphTargetsRelative?(_vector$8.addVectors(this.boundingBox.min,_box$1.min),this.boundingBox.expandByPoint(_vector$8),_vector$8.addVectors(this.boundingBox.max,_box$1.max),this.boundingBox.expandByPoint(_vector$8)):(this.boundingBox.expandByPoint(_box$1.min),this.boundingBox.expandByPoint(_box$1.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new Sphere);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute)return console.error('THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".',this),void this.boundingSphere.set(new Vector3,1/0);if(e){const n=this.boundingSphere.center;if(_box$1.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){_boxMorphTargets.setFromBufferAttribute(t[e]),this.morphTargetsRelative?(_vector$8.addVectors(_box$1.min,_boxMorphTargets.min),_box$1.expandByPoint(_vector$8),_vector$8.addVectors(_box$1.max,_boxMorphTargets.max),_box$1.expandByPoint(_vector$8)):(_box$1.expandByPoint(_boxMorphTargets.min),_box$1.expandByPoint(_boxMorphTargets.max))}_box$1.getCenter(n);let r=0;for(let t=0,i=e.count;t<i;t++)_vector$8.fromBufferAttribute(e,t),r=Math.max(r,n.distanceToSquared(_vector$8));if(t)for(let i=0,a=t.length;i<a;i++){const a=t[i],o=this.morphTargetsRelative;for(let t=0,i=a.count;t<i;t++)_vector$8.fromBufferAttribute(a,t),o&&(_offset.fromBufferAttribute(e,t),_vector$8.add(_offset)),r=Math.max(r,n.distanceToSquared(_vector$8))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(null===e||void 0===t.position||void 0===t.normal||void 0===t.uv)return void console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");const n=e.array,r=t.position.array,i=t.normal.array,a=t.uv.array,o=r.length/3;void 0===t.tangent&&this.setAttribute("tangent",new BufferAttribute(new Float32Array(4*o),4));const s=t.tangent.array,l=[],c=[];for(let e=0;e<o;e++)l[e]=new Vector3,c[e]=new Vector3;const h=new Vector3,u=new Vector3,d=new Vector3,p=new Vector2,m=new Vector2,f=new Vector2,g=new Vector3,v=new Vector3;function y(e,t,n){h.fromArray(r,3*e),u.fromArray(r,3*t),d.fromArray(r,3*n),p.fromArray(a,2*e),m.fromArray(a,2*t),f.fromArray(a,2*n),u.sub(h),d.sub(h),m.sub(p),f.sub(p);const i=1/(m.x*f.y-f.x*m.y);isFinite(i)&&(g.copy(u).multiplyScalar(f.y).addScaledVector(d,-m.y).multiplyScalar(i),v.copy(d).multiplyScalar(m.x).addScaledVector(u,-f.x).multiplyScalar(i),l[e].add(g),l[t].add(g),l[n].add(g),c[e].add(v),c[t].add(v),c[n].add(v))}let _=this.groups;0===_.length&&(_=[{start:0,count:n.length}]);for(let e=0,t=_.length;e<t;++e){const t=_[e],r=t.start;for(let e=r,i=r+t.count;e<i;e+=3)y(n[e+0],n[e+1],n[e+2])}const b=new Vector3,x=new Vector3,S=new Vector3,w=new Vector3;function C(e){S.fromArray(i,3*e),w.copy(S);const t=l[e];b.copy(t),b.sub(S.multiplyScalar(S.dot(t))).normalize(),x.crossVectors(w,t);const n=x.dot(c[e])<0?-1:1;s[4*e]=b.x,s[4*e+1]=b.y,s[4*e+2]=b.z,s[4*e+3]=n}for(let e=0,t=_.length;e<t;++e){const t=_[e],r=t.start;for(let e=r,i=r+t.count;e<i;e+=3)C(n[e+0]),C(n[e+1]),C(n[e+2])}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(void 0!==t){let n=this.getAttribute("normal");if(void 0===n)n=new BufferAttribute(new Float32Array(3*t.count),3),this.setAttribute("normal",n);else for(let e=0,t=n.count;e<t;e++)n.setXYZ(e,0,0,0);const r=new Vector3,i=new Vector3,a=new Vector3,o=new Vector3,s=new Vector3,l=new Vector3,c=new Vector3,h=new Vector3;if(e)for(let u=0,d=e.count;u<d;u+=3){const d=e.getX(u+0),p=e.getX(u+1),m=e.getX(u+2);r.fromBufferAttribute(t,d),i.fromBufferAttribute(t,p),a.fromBufferAttribute(t,m),c.subVectors(a,i),h.subVectors(r,i),c.cross(h),o.fromBufferAttribute(n,d),s.fromBufferAttribute(n,p),l.fromBufferAttribute(n,m),o.add(c),s.add(c),l.add(c),n.setXYZ(d,o.x,o.y,o.z),n.setXYZ(p,s.x,s.y,s.z),n.setXYZ(m,l.x,l.y,l.z)}else for(let e=0,o=t.count;e<o;e+=3)r.fromBufferAttribute(t,e+0),i.fromBufferAttribute(t,e+1),a.fromBufferAttribute(t,e+2),c.subVectors(a,i),h.subVectors(r,i),c.cross(h),n.setXYZ(e+0,c.x,c.y,c.z),n.setXYZ(e+1,c.x,c.y,c.z),n.setXYZ(e+2,c.x,c.y,c.z);this.normalizeNormals(),n.needsUpdate=!0}}merge(e,t){if(!e||!e.isBufferGeometry)return void console.error("THREE.BufferGeometry.merge(): geometry not an instance of THREE.BufferGeometry.",e);void 0===t&&(t=0,console.warn("THREE.BufferGeometry.merge(): Overwriting original geometry, starting at offset=0. Use BufferGeometryUtils.mergeBufferGeometries() for lossless merge."));const n=this.attributes;for(const r in n){if(void 0===e.attributes[r])continue;const i=n[r].array,a=e.attributes[r],o=a.array,s=a.itemSize*t,l=Math.min(o.length,i.length-s);for(let e=0,t=s;e<l;e++,t++)i[t]=o[e]}return this}normalizeNormals(){const e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)_vector$8.fromBufferAttribute(e,t),_vector$8.normalize(),e.setXYZ(t,_vector$8.x,_vector$8.y,_vector$8.z)}toNonIndexed(){function e(e,t){const n=e.array,r=e.itemSize,i=e.normalized,a=new n.constructor(t.length*r);let o=0,s=0;for(let i=0,l=t.length;i<l;i++){o=e.isInterleavedBufferAttribute?t[i]*e.data.stride+e.offset:t[i]*r;for(let e=0;e<r;e++)a[s++]=n[o++]}return new BufferAttribute(a,r,i)}if(null===this.index)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new BufferGeometry,n=this.index.array,r=this.attributes;for(const i in r){const a=e(r[i],n);t.setAttribute(i,a)}const i=this.morphAttributes;for(const r in i){const a=[],o=i[r];for(let t=0,r=o.length;t<r;t++){const r=e(o[t],n);a.push(r)}t.morphAttributes[r]=a}t.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let e=0,n=a.length;e<n;e++){const n=a[e];t.addGroup(n.start,n.count,n.materialIndex)}return t}toJSON(){const e={metadata:{version:4.5,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,""!==this.name&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),void 0!==this.parameters){const t=this.parameters;for(const n in t)void 0!==t[n]&&(e[n]=t[n]);return e}e.data={attributes:{}};const t=this.index;null!==t&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const t in n){e.data.attributes[t]=n[t].toJSON(e.data)}const r={};let i=!1;for(const t in this.morphAttributes){const n=this.morphAttributes[t],a=[];for(let t=0,r=n.length;t<r;t++){a.push(n[t].toJSON(e.data))}a.length>0&&(r[t]=a,i=!0)}i&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return null!==o&&(e.data.boundingSphere={center:o.center.toArray(),radius:o.radius}),e}clone(){return(new this.constructor).copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;null!==n&&this.setIndex(n.clone(t));const r=e.attributes;for(const e in r){this.setAttribute(e,r[e].clone(t))}const i=e.morphAttributes;for(const e in i){const n=[],r=i[e];for(let e=0,i=r.length;e<i;e++)n.push(r[e].clone(t));this.morphAttributes[e]=n}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let e=0,t=a.length;e<t;e++){const t=a[e];this.addGroup(t.start,t.count,t.materialIndex)}const o=e.boundingBox;null!==o&&(this.boundingBox=o.clone());const s=e.boundingSphere;return null!==s&&(this.boundingSphere=s.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,void 0!==e.parameters&&(this.parameters=Object.assign({},e.parameters)),this}dispose(){this.dispatchEvent({type:"dispose"})}}BufferGeometry.prototype.isBufferGeometry=!0;const _inverseMatrix$2=new Matrix4,_ray$2=new Ray,_sphere$3=new Sphere,_vA$1=new Vector3,_vB$1=new Vector3,_vC$1=new Vector3,_tempA=new Vector3,_tempB=new Vector3,_tempC=new Vector3,_morphA=new Vector3,_morphB=new Vector3,_morphC=new Vector3,_uvA$1=new Vector2,_uvB$1=new Vector2,_uvC$1=new Vector2,_intersectionPoint=new Vector3,_intersectionPointWorld=new Vector3;class Mesh extends Object3D{constructor(e=new BufferGeometry,t=new MeshBasicMaterial){super(),this.type="Mesh",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e){return super.copy(e),void 0!==e.morphTargetInfluences&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),void 0!==e.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=e.material,this.geometry=e.geometry,this}updateMorphTargets(){const e=this.geometry;if(e.isBufferGeometry){const t=e.morphAttributes,n=Object.keys(t);if(n.length>0){const e=t[n[0]];if(void 0!==e){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,n=e.length;t<n;t++){const n=e[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[n]=t}}}}else{const t=e.morphTargets;void 0!==t&&t.length>0&&console.error("THREE.Mesh.updateMorphTargets() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}}raycast(e,t){const n=this.geometry,r=this.material,i=this.matrixWorld;if(void 0===r)return;if(null===n.boundingSphere&&n.computeBoundingSphere(),_sphere$3.copy(n.boundingSphere),_sphere$3.applyMatrix4(i),!1===e.ray.intersectsSphere(_sphere$3))return;if(_inverseMatrix$2.copy(i).invert(),_ray$2.copy(e.ray).applyMatrix4(_inverseMatrix$2),null!==n.boundingBox&&!1===_ray$2.intersectsBox(n.boundingBox))return;let a;if(n.isBufferGeometry){const i=n.index,o=n.attributes.position,s=n.morphAttributes.position,l=n.morphTargetsRelative,c=n.attributes.uv,h=n.attributes.uv2,u=n.groups,d=n.drawRange;if(null!==i)if(Array.isArray(r))for(let n=0,p=u.length;n<p;n++){const p=u[n],m=r[p.materialIndex];for(let n=Math.max(p.start,d.start),r=Math.min(i.count,Math.min(p.start+p.count,d.start+d.count));n<r;n+=3){const r=i.getX(n),u=i.getX(n+1),d=i.getX(n+2);a=checkBufferGeometryIntersection(this,m,e,_ray$2,o,s,l,c,h,r,u,d),a&&(a.faceIndex=Math.floor(n/3),a.face.materialIndex=p.materialIndex,t.push(a))}}else{for(let n=Math.max(0,d.start),u=Math.min(i.count,d.start+d.count);n<u;n+=3){const u=i.getX(n),d=i.getX(n+1),p=i.getX(n+2);a=checkBufferGeometryIntersection(this,r,e,_ray$2,o,s,l,c,h,u,d,p),a&&(a.faceIndex=Math.floor(n/3),t.push(a))}}else if(void 0!==o)if(Array.isArray(r))for(let n=0,i=u.length;n<i;n++){const i=u[n],p=r[i.materialIndex];for(let n=Math.max(i.start,d.start),r=Math.min(o.count,Math.min(i.start+i.count,d.start+d.count));n<r;n+=3){a=checkBufferGeometryIntersection(this,p,e,_ray$2,o,s,l,c,h,n,n+1,n+2),a&&(a.faceIndex=Math.floor(n/3),a.face.materialIndex=i.materialIndex,t.push(a))}}else{for(let n=Math.max(0,d.start),i=Math.min(o.count,d.start+d.count);n<i;n+=3){a=checkBufferGeometryIntersection(this,r,e,_ray$2,o,s,l,c,h,n,n+1,n+2),a&&(a.faceIndex=Math.floor(n/3),t.push(a))}}}else n.isGeometry&&console.error("THREE.Mesh.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}}function checkIntersection(e,t,n,r,i,a,o,s){let l;if(l=t.side===BackSide?r.intersectTriangle(o,a,i,!0,s):r.intersectTriangle(i,a,o,t.side!==DoubleSide,s),null===l)return null;_intersectionPointWorld.copy(s),_intersectionPointWorld.applyMatrix4(e.matrixWorld);const c=n.ray.origin.distanceTo(_intersectionPointWorld);return c<n.near||c>n.far?null:{distance:c,point:_intersectionPointWorld.clone(),object:e}}function checkBufferGeometryIntersection(e,t,n,r,i,a,o,s,l,c,h,u){_vA$1.fromBufferAttribute(i,c),_vB$1.fromBufferAttribute(i,h),_vC$1.fromBufferAttribute(i,u);const d=e.morphTargetInfluences;if(a&&d){_morphA.set(0,0,0),_morphB.set(0,0,0),_morphC.set(0,0,0);for(let e=0,t=a.length;e<t;e++){const t=d[e],n=a[e];0!==t&&(_tempA.fromBufferAttribute(n,c),_tempB.fromBufferAttribute(n,h),_tempC.fromBufferAttribute(n,u),o?(_morphA.addScaledVector(_tempA,t),_morphB.addScaledVector(_tempB,t),_morphC.addScaledVector(_tempC,t)):(_morphA.addScaledVector(_tempA.sub(_vA$1),t),_morphB.addScaledVector(_tempB.sub(_vB$1),t),_morphC.addScaledVector(_tempC.sub(_vC$1),t)))}_vA$1.add(_morphA),_vB$1.add(_morphB),_vC$1.add(_morphC)}e.isSkinnedMesh&&(e.boneTransform(c,_vA$1),e.boneTransform(h,_vB$1),e.boneTransform(u,_vC$1));const p=checkIntersection(e,t,n,r,_vA$1,_vB$1,_vC$1,_intersectionPoint);if(p){s&&(_uvA$1.fromBufferAttribute(s,c),_uvB$1.fromBufferAttribute(s,h),_uvC$1.fromBufferAttribute(s,u),p.uv=Triangle.getUV(_intersectionPoint,_vA$1,_vB$1,_vC$1,_uvA$1,_uvB$1,_uvC$1,new Vector2)),l&&(_uvA$1.fromBufferAttribute(l,c),_uvB$1.fromBufferAttribute(l,h),_uvC$1.fromBufferAttribute(l,u),p.uv2=Triangle.getUV(_intersectionPoint,_vA$1,_vB$1,_vC$1,_uvA$1,_uvB$1,_uvC$1,new Vector2));const e={a:c,b:h,c:u,normal:new Vector3,materialIndex:0};Triangle.getNormal(_vA$1,_vB$1,_vC$1,e.normal),p.face=e}return p}Mesh.prototype.isMesh=!0;class BoxGeometry extends BufferGeometry{constructor(e=1,t=1,n=1,r=1,i=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:i,depthSegments:a};const o=this;r=Math.floor(r),i=Math.floor(i),a=Math.floor(a);const s=[],l=[],c=[],h=[];let u=0,d=0;function p(e,t,n,r,i,a,p,m,f,g,v){const y=a/f,_=p/g,b=a/2,x=p/2,S=m/2,w=f+1,C=g+1;let M=0,E=0;const T=new Vector3;for(let a=0;a<C;a++){const o=a*_-x;for(let s=0;s<w;s++){T[e]=(s*y-b)*r,T[t]=o*i,T[n]=S,l.push(T.x,T.y,T.z),T[e]=0,T[t]=0,T[n]=m>0?1:-1,c.push(T.x,T.y,T.z),h.push(s/f),h.push(1-a/g),M+=1}}for(let e=0;e<g;e++)for(let t=0;t<f;t++){const n=u+t+w*(e+1),r=u+(t+1)+w*(e+1),i=u+(t+1)+w*e;s.push(u+t+w*e,n,i),s.push(n,r,i),E+=6}o.addGroup(d,E,v),d+=E,u+=M}p("z","y","x",-1,-1,n,t,e,a,i,0),p("z","y","x",1,-1,n,t,-e,a,i,1),p("x","z","y",1,1,e,n,t,r,a,2),p("x","z","y",1,-1,e,n,-t,r,a,3),p("x","y","z",1,-1,e,t,n,r,i,4),p("x","y","z",-1,-1,e,t,-n,r,i,5),this.setIndex(s),this.setAttribute("position",new Float32BufferAttribute(l,3)),this.setAttribute("normal",new Float32BufferAttribute(c,3)),this.setAttribute("uv",new Float32BufferAttribute(h,2))}static fromJSON(e){return new BoxGeometry(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function cloneUniforms(e){const t={};for(const n in e){t[n]={};for(const r in e[n]){const i=e[n][r];t[n][r]=i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?i.clone():Array.isArray(i)?i.slice():i}}return t}function mergeUniforms(e){const t={};for(let n=0;n<e.length;n++){const r=cloneUniforms(e[n]);for(const e in r)t[e]=r[e]}return t}const UniformsUtils={clone:cloneUniforms,merge:mergeUniforms};var default_vertex="void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",default_fragment="void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}";class ShaderMaterial extends Material{constructor(e){super(),this.type="ShaderMaterial",this.defines={},this.uniforms={},this.vertexShader=default_vertex,this.fragmentShader=default_fragment,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv2:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,void 0!==e&&(void 0!==e.attributes&&console.error("THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead."),this.setValues(e))}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=cloneUniforms(e.uniforms),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){const t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const n in this.uniforms){const r=this.uniforms[n].value;t.uniforms[n]=r&&r.isTexture?{type:"t",value:r.toJSON(e).uuid}:r&&r.isColor?{type:"c",value:r.getHex()}:r&&r.isVector2?{type:"v2",value:r.toArray()}:r&&r.isVector3?{type:"v3",value:r.toArray()}:r&&r.isVector4?{type:"v4",value:r.toArray()}:r&&r.isMatrix3?{type:"m3",value:r.toArray()}:r&&r.isMatrix4?{type:"m4",value:r.toArray()}:{value:r}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader;const n={};for(const e in this.extensions)!0===this.extensions[e]&&(n[e]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}ShaderMaterial.prototype.isShaderMaterial=!0;class Camera extends Object3D{constructor(){super(),this.type="Camera",this.matrixWorldInverse=new Matrix4,this.projectionMatrix=new Matrix4,this.projectionMatrixInverse=new Matrix4}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(-t[8],-t[9],-t[10]).normalize()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return(new this.constructor).copy(this)}}Camera.prototype.isCamera=!0;class PerspectiveCamera extends Camera{constructor(e=50,t=1,n=.1,r=2e3){super(),this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=r,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=null===e.view?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=2*RAD2DEG*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(.5*DEG2RAD*this.fov);return.5*this.getFilmHeight()/e}getEffectiveFOV(){return 2*RAD2DEG*Math.atan(Math.tan(.5*DEG2RAD*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,t,n,r,i,a){this.aspect=e/t,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=i,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(.5*DEG2RAD*this.fov)/this.zoom,n=2*t,r=this.aspect*n,i=-.5*r;const a=this.view;if(null!==this.view&&this.view.enabled){const e=a.fullWidth,o=a.fullHeight;i+=a.offsetX*r/e,t-=a.offsetY*n/o,r*=a.width/e,n*=a.height/o}const o=this.filmOffset;0!==o&&(i+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(i,i+r,t,t-n,e,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,null!==this.view&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}PerspectiveCamera.prototype.isPerspectiveCamera=!0;const fov=90,aspect=1;class CubeCamera extends Object3D{constructor(e,t,n){if(super(),this.type="CubeCamera",!0!==n.isWebGLCubeRenderTarget)return void console.error("THREE.CubeCamera: The constructor now expects an instance of WebGLCubeRenderTarget as third parameter.");this.renderTarget=n;const r=new PerspectiveCamera(fov,aspect,e,t);r.layers=this.layers,r.up.set(0,-1,0),r.lookAt(new Vector3(1,0,0)),this.add(r);const i=new PerspectiveCamera(fov,aspect,e,t);i.layers=this.layers,i.up.set(0,-1,0),i.lookAt(new Vector3(-1,0,0)),this.add(i);const a=new PerspectiveCamera(fov,aspect,e,t);a.layers=this.layers,a.up.set(0,0,1),a.lookAt(new Vector3(0,1,0)),this.add(a);const o=new PerspectiveCamera(fov,aspect,e,t);o.layers=this.layers,o.up.set(0,0,-1),o.lookAt(new Vector3(0,-1,0)),this.add(o);const s=new PerspectiveCamera(fov,aspect,e,t);s.layers=this.layers,s.up.set(0,-1,0),s.lookAt(new Vector3(0,0,1)),this.add(s);const l=new PerspectiveCamera(fov,aspect,e,t);l.layers=this.layers,l.up.set(0,-1,0),l.lookAt(new Vector3(0,0,-1)),this.add(l)}update(e,t){null===this.parent&&this.updateMatrixWorld();const n=this.renderTarget,[r,i,a,o,s,l]=this.children,c=e.xr.enabled,h=e.getRenderTarget();e.xr.enabled=!1;const u=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0),e.render(t,r),e.setRenderTarget(n,1),e.render(t,i),e.setRenderTarget(n,2),e.render(t,a),e.setRenderTarget(n,3),e.render(t,o),e.setRenderTarget(n,4),e.render(t,s),n.texture.generateMipmaps=u,e.setRenderTarget(n,5),e.render(t,l),e.setRenderTarget(h),e.xr.enabled=c,n.texture.needsPMREMUpdate=!0}}class CubeTexture extends Texture{constructor(e,t,n,r,i,a,o,s,l,c){super(e=void 0!==e?e:[],t=void 0!==t?t:CubeReflectionMapping,n,r,i,a,o,s,l,c),this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}CubeTexture.prototype.isCubeTexture=!0;class WebGLCubeRenderTarget extends WebGLRenderTarget{constructor(e,t,n){Number.isInteger(t)&&(console.warn("THREE.WebGLCubeRenderTarget: constructor signature is now WebGLCubeRenderTarget( size, options )"),t=n),super(e,e,t),this.texture=new CubeTexture(void 0,(t=t||{}).mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.encoding),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=void 0!==t.generateMipmaps&&t.generateMipmaps,this.texture.minFilter=void 0!==t.minFilter?t.minFilter:LinearFilter}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.format=RGBAFormat,this.texture.encoding=t.encoding,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:"\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include <begin_vertex>\n\t\t\t\t\t#include <project_vertex>\n\n\t\t\t\t}\n\t\t\t",fragmentShader:"\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include <common>\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t"},r=new BoxGeometry(5,5,5),i=new ShaderMaterial({name:"CubemapFromEquirect",uniforms:cloneUniforms(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:BackSide,blending:NoBlending});i.uniforms.tEquirect.value=t;const a=new Mesh(r,i),o=t.minFilter;t.minFilter===LinearMipmapLinearFilter&&(t.minFilter=LinearFilter);return new CubeCamera(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t,n,r){const i=e.getRenderTarget();for(let i=0;i<6;i++)e.setRenderTarget(this,i),e.clear(t,n,r);e.setRenderTarget(i)}}WebGLCubeRenderTarget.prototype.isWebGLCubeRenderTarget=!0;const _vector1=new Vector3,_vector2=new Vector3,_normalMatrix=new Matrix3;class Plane{constructor(e=new Vector3(1,0,0),t=0){this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,r){return this.normal.set(e,t,n),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const r=_vector1.subVectors(n,t).cross(_vector2.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(this.normal).multiplyScalar(-this.distanceToPoint(e)).add(e)}intersectLine(e,t){const n=e.delta(_vector1),r=this.normal.dot(n);if(0===r)return 0===this.distanceToPoint(e.start)?t.copy(e.start):null;const i=-(e.start.dot(this.normal)+this.constant)/r;return i<0||i>1?null:t.copy(n).multiplyScalar(i).add(e.start)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const n=t||_normalMatrix.getNormalMatrix(e),r=this.coplanarPoint(_vector1).applyMatrix4(e),i=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(i),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return(new this.constructor).copy(this)}}Plane.prototype.isPlane=!0;const _sphere$2=new Sphere,_vector$7=new Vector3;class Frustum{constructor(e=new Plane,t=new Plane,n=new Plane,r=new Plane,i=new Plane,a=new Plane){this.planes=[e,t,n,r,i,a]}set(e,t,n,r,i,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(r),o[4].copy(i),o[5].copy(a),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e){const t=this.planes,n=e.elements,r=n[0],i=n[1],a=n[2],o=n[3],s=n[4],l=n[5],c=n[6],h=n[7],u=n[8],d=n[9],p=n[10],m=n[11],f=n[12],g=n[13],v=n[14],y=n[15];return t[0].setComponents(o-r,h-s,m-u,y-f).normalize(),t[1].setComponents(o+r,h+s,m+u,y+f).normalize(),t[2].setComponents(o+i,h+l,m+d,y+g).normalize(),t[3].setComponents(o-i,h-l,m-d,y-g).normalize(),t[4].setComponents(o-a,h-c,m-p,y-v).normalize(),t[5].setComponents(o+a,h+c,m+p,y+v).normalize(),this}intersectsObject(e){const t=e.geometry;return null===t.boundingSphere&&t.computeBoundingSphere(),_sphere$2.copy(t.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(_sphere$2)}intersectsSprite(e){return _sphere$2.center.set(0,0,0),_sphere$2.radius=.7071067811865476,_sphere$2.applyMatrix4(e.matrixWorld),this.intersectsSphere(_sphere$2)}intersectsSphere(e){const t=this.planes,n=e.center,r=-e.radius;for(let e=0;e<6;e++){if(t[e].distanceToPoint(n)<r)return!1}return!0}intersectsBox(e){const t=this.planes;for(let n=0;n<6;n++){const r=t[n];if(_vector$7.x=r.normal.x>0?e.max.x:e.min.x,_vector$7.y=r.normal.y>0?e.max.y:e.min.y,_vector$7.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(_vector$7)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}}function WebGLAnimation(){let e=null,t=!1,n=null,r=null;function i(t,a){n(t,a),r=e.requestAnimationFrame(i)}return{start:function(){!0!==t&&null!==n&&(r=e.requestAnimationFrame(i),t=!0)},stop:function(){e.cancelAnimationFrame(r),t=!1},setAnimationLoop:function(e){n=e},setContext:function(t){e=t}}}function WebGLAttributes(e,t){const n=t.isWebGL2,r=new WeakMap;return{get:function i(e){return e.isInterleavedBufferAttribute&&(e=e.data),r.get(e)},remove:function a(t){t.isInterleavedBufferAttribute&&(t=t.data);const n=r.get(t);n&&(e.deleteBuffer(n.buffer),r.delete(t))},update:function o(t,i){if(t.isGLBufferAttribute){const e=r.get(t);return void((!e||e.version<t.version)&&r.set(t,{buffer:t.buffer,type:t.type,bytesPerElement:t.elementSize,version:t.version}))}t.isInterleavedBufferAttribute&&(t=t.data);const a=r.get(t);void 0===a?r.set(t,(function o(t,r){const i=t.array,a=t.usage,o=e.createBuffer();e.bindBuffer(r,o),e.bufferData(r,i,a),t.onUploadCallback();let s=5126;return i instanceof Float32Array?s=5126:i instanceof Float64Array?console.warn("THREE.WebGLAttributes: Unsupported data buffer format: Float64Array."):i instanceof Uint16Array?t.isFloat16BufferAttribute?n?s=5131:console.warn("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2."):s=5123:i instanceof Int16Array?s=5122:i instanceof Uint32Array?s=5125:i instanceof Int32Array?s=5124:i instanceof Int8Array?s=5120:(i instanceof Uint8Array||i instanceof Uint8ClampedArray)&&(s=5121),{buffer:o,type:s,bytesPerElement:i.BYTES_PER_ELEMENT,version:t.version}})(t,i)):a.version<t.version&&(!(function s(t,r,i){const a=r.array,o=r.updateRange;e.bindBuffer(i,t),-1===o.count?e.bufferSubData(i,0,a):(n?e.bufferSubData(i,o.offset*a.BYTES_PER_ELEMENT,a,o.offset,o.count):e.bufferSubData(i,o.offset*a.BYTES_PER_ELEMENT,a.subarray(o.offset,o.offset+o.count)),o.count=-1)})(a.buffer,t,i),a.version=t.version)}}}class PlaneGeometry extends BufferGeometry{constructor(e=1,t=1,n=1,r=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:r};const i=e/2,a=t/2,o=Math.floor(n),s=Math.floor(r),l=o+1,c=s+1,h=e/o,u=t/s,d=[],p=[],m=[],f=[];for(let e=0;e<c;e++){const t=e*u-a;for(let n=0;n<l;n++){p.push(n*h-i,-t,0),m.push(0,0,1),f.push(n/o),f.push(1-e/s)}}for(let e=0;e<s;e++)for(let t=0;t<o;t++){const n=t+l*(e+1),r=t+1+l*(e+1),i=t+1+l*e;d.push(t+l*e,n,i),d.push(n,r,i)}this.setIndex(d),this.setAttribute("position",new Float32BufferAttribute(p,3)),this.setAttribute("normal",new Float32BufferAttribute(m,3)),this.setAttribute("uv",new Float32BufferAttribute(f,2))}static fromJSON(e){return new PlaneGeometry(e.width,e.height,e.widthSegments,e.heightSegments)}}var alphamap_fragment="#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vUv ).g;\n#endif",alphamap_pars_fragment="#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",alphatest_fragment="#ifdef USE_ALPHATEST\n\tif ( diffuseColor.a < alphaTest ) discard;\n#endif",alphatest_pars_fragment="#ifdef USE_ALPHATEST\n\tuniform float alphaTest;\n#endif",aomap_fragment="#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );\n\t#endif\n#endif",aomap_pars_fragment="#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",begin_vertex="vec3 transformed = vec3( position );",beginnormal_vertex="vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif",bsdfs="vec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 f0, const in float f90, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, 1.0, dotVH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif",bumpmap_pars_fragment="#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {\n\t\tvec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\n\t\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 ) * faceDirection;\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif",clipping_planes_fragment="#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#pragma unroll_loop_end\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\tif ( clipped ) discard;\n\t#endif\n#endif",clipping_planes_pars_fragment="#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex="#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",clipping_planes_vertex="#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",color_fragment="#if defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#elif defined( USE_COLOR )\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment="#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif",color_pars_vertex="#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvarying vec3 vColor;\n#endif",color_vertex="#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif",common="#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal;\n#endif\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\treturn dot( weights, color.rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}",cube_uv_reflection_fragment="#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_maxMipLevel 8.0\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_maxTileSize 256.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\tfloat texelSize = 1.0 / ( 3.0 * cubeUV_maxTileSize );\n\t\tvec2 uv = getUV( direction, face ) * ( faceSize - 1.0 ) + 0.5;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tif ( mipInt < cubeUV_maxMipLevel ) {\n\t\t\tuv.y += 2.0 * cubeUV_maxTileSize;\n\t\t}\n\t\tuv.y += filterInt * 2.0 * cubeUV_minTileSize;\n\t\tuv.x += 3.0 * max( 0.0, cubeUV_maxTileSize - 2.0 * faceSize );\n\t\tuv *= texelSize;\n\t\treturn texture2D( envMap, uv ).rgb;\n\t}\n\t#define r0 1.0\n\t#define v0 0.339\n\t#define m0 - 2.0\n\t#define r1 0.8\n\t#define v1 0.276\n\t#define m1 - 1.0\n\t#define r4 0.4\n\t#define v4 0.046\n\t#define m4 2.0\n\t#define r5 0.305\n\t#define v5 0.016\n\t#define m5 3.0\n\t#define r6 0.21\n\t#define v6 0.0038\n\t#define m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= r1 ) {\n\t\t\tmip = ( r0 - roughness ) * ( m1 - m0 ) / ( r0 - r1 ) + m0;\n\t\t} else if ( roughness >= r4 ) {\n\t\t\tmip = ( r1 - roughness ) * ( m4 - m1 ) / ( r1 - r4 ) + m1;\n\t\t} else if ( roughness >= r5 ) {\n\t\t\tmip = ( r4 - roughness ) * ( m5 - m4 ) / ( r4 - r5 ) + m4;\n\t\t} else if ( roughness >= r6 ) {\n\t\t\tmip = ( r5 - roughness ) * ( m6 - m5 ) / ( r5 - r6 ) + m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), m0, cubeUV_maxMipLevel );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif",defaultnormal_vertex="vec3 transformedNormal = objectNormal;\n#ifdef USE_INSTANCING\n\tmat3 m = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n\ttransformedNormal = m * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",displacementmap_pars_vertex="#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex="#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment="#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment="#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",encodings_fragment="gl_FragColor = linearToOutputTexel( gl_FragColor );",encodings_pars_fragment="vec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}",envmap_fragment="#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif",envmap_common_pars_fragment="#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif",envmap_pars_fragment="#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex="#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_vertex="#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif",fog_vertex="#ifdef USE_FOG\n\tvFogDepth = - mvPosition.z;\n#endif",fog_pars_vertex="#ifdef USE_FOG\n\tvarying float vFogDepth;\n#endif",fog_fragment="#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment="#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float vFogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif",gradientmap_pars_fragment="#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn vec3( texture2D( gradientMap, coord ).r );\n\t#else\n\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t#endif\n}",lightmap_fragment="#ifdef USE_LIGHTMAP\n\tvec4 lightMapTexel = texture2D( lightMap, vUv2 );\n\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tlightMapIrradiance *= PI;\n\t#endif\n\treflectedLight.indirectDiffuse += lightMapIrradiance;\n#endif",lightmap_pars_fragment="#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_vertex="vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\nvIndirectFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n\tvIndirectBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\nvIndirectFront += getAmbientLightIrradiance( ambientLightColor );\nvIndirectFront += getLightProbeIrradiance( lightProbe, geometry.normal );\n#ifdef DOUBLE_SIDED\n\tvIndirectBack += getAmbientLightIrradiance( ambientLightColor );\n\tvIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry.normal );\n#endif\n#if NUM_POINT_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tgetPointLightInfo( pointLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( - dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tgetSpotLightInfo( spotLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( - dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_DIR_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tgetDirectionalLightInfo( directionalLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( - dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry.normal );\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif",lights_pars_begin="uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\t#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\tif ( cutoffDistance > 0.0 ) {\n\t\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\t}\n\t\treturn distanceFalloff;\n\t#else\n\t\tif ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\t\treturn pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t\t}\n\t\treturn 1.0;\n\t#endif\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif",envmap_physical_pars_fragment="#if defined( USE_ENVMAP )\n\t#ifdef ENVMAP_MODE_REFRACTION\n\t\tuniform float refractionRatio;\n\t#endif\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#if defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#if defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 reflectVec;\n\t\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\t\treflectVec = reflect( - viewDir, normal );\n\t\t\t\treflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t\t#else\n\t\t\t\treflectVec = refract( - viewDir, normal, refractionRatio );\n\t\t\t#endif\n\t\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n#endif",lights_toon_fragment="ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment="varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon\n#define Material_LightProbeLOD( material )\t(0)",lights_phong_fragment="BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment="varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)",lights_physical_fragment="PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\t#ifdef SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULARINTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vUv ).a;\n\t\t#endif\n\t\t#ifdef USE_SPECULARCOLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vUv ).rgb;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = mix( min( pow2( ( ior - 1.0 ) / ( ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEENCOLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\n\t#ifdef USE_SHEENROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vUv ).a;\n\t#endif\n#endif",lights_physical_pars_fragment="struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\n\tfloat specularF90;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n};\nvec3 clearcoatSpecular = vec3( 0.0 );\nvec3 sheenSpecular = vec3( 0.0 );\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat r2 = roughness * roughness;\n\tfloat a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;\n\tfloat b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;\n\tfloat DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );\n\treturn saturate( DG * RECIPROCAL_PI );\n}\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n\treturn fab;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\tvec3 FssEss = specularColor * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3(    0, 1,    0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecular += ccIrradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.clearcoatNormal, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecular += irradiance * BRDF_Sheen( directLight.direction, geometry.viewDir, geometry.normal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.roughness );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometry.clearcoatNormal, geometry.viewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecular += irradiance * material.sheenColor * IBLSheenBRDF( geometry.normal, geometry.viewDir, material.sheenRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\tcomputeMultiscattering( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",lights_fragment_begin="\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n#ifdef USE_CLEARCOAT\n\tgeometry.clearcoatNormal = clearcoatNormal;\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry.normal );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps="#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vUv2 );\n\t\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getIBLIrradiance( geometry.normal );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tradiance += getIBLRadiance( geometry.viewDir, geometry.normal, material.roughness );\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif",lights_fragment_end="#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\n#endif",logdepthbuf_fragment="#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment="#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex="#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif",logdepthbuf_vertex="#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif",map_fragment="#ifdef USE_MAP\n\tvec4 sampledDiffuseColor = texture2D( map, vUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\tsampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w );\n\t#endif\n\tdiffuseColor *= sampledDiffuseColor;\n#endif",map_pars_fragment="#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment="#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n#endif\n#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, uv );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment="#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tuniform mat3 uvTransform;\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment="float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment="#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphnormal_vertex="#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1, 2 ) * morphTargetInfluences[ i ];\n\t\t}\n\t#else\n\t\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n\t\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n\t\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n\t\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n\t#endif\n#endif",morphtarget_pars_vertex="#ifdef USE_MORPHTARGETS\n\tuniform float morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t\tuniform sampler2DArray morphTargetsTexture;\n\t\tuniform vec2 morphTargetsTextureSize;\n\t\tvec3 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset, const in int stride ) {\n\t\t\tfloat texelIndex = float( vertexIndex * stride + offset );\n\t\t\tfloat y = floor( texelIndex / morphTargetsTextureSize.x );\n\t\t\tfloat x = texelIndex - y * morphTargetsTextureSize.x;\n\t\t\tvec3 morphUV = vec3( ( x + 0.5 ) / morphTargetsTextureSize.x, y / morphTargetsTextureSize.y, morphTargetIndex );\n\t\t\treturn texture( morphTargetsTexture, morphUV ).xyz;\n\t\t}\n\t#else\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\tuniform float morphTargetInfluences[ 8 ];\n\t\t#else\n\t\t\tuniform float morphTargetInfluences[ 4 ];\n\t\t#endif\n\t#endif\n#endif",morphtarget_vertex="#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\t#ifndef USE_MORPHNORMALS\n\t\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0, 1 ) * morphTargetInfluences[ i ];\n\t\t\t#else\n\t\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0, 2 ) * morphTargetInfluences[ i ];\n\t\t\t#endif\n\t\t}\n\t#else\n\t\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\n\t\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\n\t\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\n\t\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\n\t\t\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\n\t\t\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\n\t\t\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\n\t\t#endif\n\t#endif\n#endif",normal_fragment_begin="float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\t#ifdef USE_TANGENT\n\t\tvec3 tangent = normalize( vTangent );\n\t\tvec3 bitangent = normalize( vBitangent );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\ttangent = tangent * faceDirection;\n\t\t\tbitangent = bitangent * faceDirection;\n\t\t#endif\n\t\t#if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tmat3 vTBN = mat3( tangent, bitangent, normal );\n\t\t#endif\n\t#endif\n#endif\nvec3 geometryNormal = normal;",normal_fragment_maps="#ifdef OBJECTSPACE_NORMALMAP\n\tnormal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( TANGENTSPACE_NORMALMAP )\n\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\t#ifdef USE_TANGENT\n\t\tnormal = normalize( vTBN * mapN );\n\t#else\n\t\tnormal = perturbNormal2Arb( - vViewPosition, normal, mapN, faceDirection );\n\t#endif\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",normal_pars_fragment="#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_pars_vertex="#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_vertex="#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif",normalmap_pars_fragment="#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN, float faceDirection ) {\n\t\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\t\tvec3 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : faceDirection * inversesqrt( det );\n\t\treturn normalize( T * ( mapN.x * scale ) + B * ( mapN.y * scale ) + N * mapN.z );\n\t}\n#endif",clearcoat_normal_fragment_begin="#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = geometryNormal;\n#endif",clearcoat_normal_fragment_maps="#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\t#ifdef USE_TANGENT\n\t\tclearcoatNormal = normalize( vTBN * clearcoatMapN );\n\t#else\n\t\tclearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN, faceDirection );\n\t#endif\n#endif",clearcoat_pars_fragment="#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif",output_fragment="#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= transmissionAlpha + 0.1;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );",packing="vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nvec4 pack2HalfToRGBA( vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\n}",premultiplied_alpha_fragment="#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex="vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment="#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment="#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",roughnessmap_fragment="float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment="#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment="#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), \n\t\t\t\t\t\t  texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t  f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), \n\t\t\t\t\t\t  texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t  f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif",shadowmap_pars_vertex="#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",shadowmap_vertex="#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SPOT_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0\n\t\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\tvec4 shadowWorldPosition;\n\t#endif\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n#endif",shadowmask_pars_fragment="float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}",skinbase_vertex="#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex="#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\t#ifdef BONE_TEXTURE\n\t\tuniform highp sampler2D boneTexture;\n\t\tuniform int boneTextureSize;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\t\ty = dy * ( y + 0.5 );\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\treturn bone;\n\t\t}\n\t#else\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\t\t}\n\t#endif\n#endif",skinning_vertex="#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex="#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",specularmap_fragment="float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment="#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment="#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment="#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3(  1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108,  1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605,  1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmission_fragment="#ifdef USE_TRANSMISSION\n\tfloat transmissionAlpha = 1.0;\n\tfloat transmissionFactor = transmission;\n\tfloat thicknessFactor = thickness;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\ttransmissionFactor *= texture2D( transmissionMap, vUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tthicknessFactor *= texture2D( thicknessMap, vUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmission = getIBLVolumeRefraction(\n\t\tn, v, roughnessFactor, material.diffuseColor, material.specularColor, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, ior, thicknessFactor,\n\t\tattenuationColor, attenuationDistance );\n\ttotalDiffuse = mix( totalDiffuse, transmission.rgb, transmissionFactor );\n\ttransmissionAlpha = mix( transmissionAlpha, transmission.a, transmissionFactor );\n#endif",transmission_pars_fragment="#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tvec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( const in float roughness, const in float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n\t\tfloat framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\treturn texture2DLodEXT( transmissionSamplerMap, fragCoord.xy, framebufferLod );\n\t\t#else\n\t\t\treturn texture2D( transmissionSamplerMap, fragCoord.xy, framebufferLod );\n\t\t#endif\n\t}\n\tvec3 applyVolumeAttenuation( const in vec3 radiance, const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tif ( attenuationDistance == 0.0 ) {\n\t\t\treturn radiance;\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance * radiance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n\t\tconst in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n\t\tconst in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,\n\t\tconst in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\trefractionCoords += 1.0;\n\t\trefractionCoords /= 2.0;\n\t\tvec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\tvec3 attenuatedColor = applyVolumeAttenuation( transmittedLight.rgb, length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor * diffuseColor, transmittedLight.a );\n\t}\n#endif",uv_pars_fragment="#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )\n\tvarying vec2 vUv;\n#endif",uv_pars_vertex="#ifdef USE_UV\n\t#ifdef UVS_VERTEX_ONLY\n\t\tvec2 vUv;\n\t#else\n\t\tvarying vec2 vUv;\n\t#endif\n\tuniform mat3 uvTransform;\n#endif",uv_vertex="#ifdef USE_UV\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n#endif",uv2_pars_fragment="#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif",uv2_pars_vertex="#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n\tuniform mat3 uv2Transform;\n#endif",uv2_vertex="#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;\n#endif",worldpos_vertex="#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION )\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif";const vertex$g="varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",fragment$g="uniform sampler2D t2D;\nvarying vec2 vUv;\nvoid main() {\n\tgl_FragColor = texture2D( t2D, vUv );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}",vertex$f="varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}",fragment$f="#include <envmap_common_pars_fragment>\nuniform float opacity;\nvarying vec3 vWorldDirection;\n#include <cube_uv_reflection_fragment>\nvoid main() {\n\tvec3 vReflect = vWorldDirection;\n\t#include <envmap_fragment>\n\tgl_FragColor = envColor;\n\tgl_FragColor.a *= opacity;\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}",vertex$e="#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvHighPrecisionZW = gl_Position.zw;\n}",fragment$e="#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <logdepthbuf_fragment>\n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#endif\n}",vertex$d="#define DISTANCE\nvarying vec3 vWorldPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\tvWorldPosition = worldPosition.xyz;\n}",fragment$d="#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main () {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}",vertex$c="varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n}",fragment$c="uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}",vertex$b="uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include <color_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",fragment$b="uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <color_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",vertex$a="#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinbase_vertex>\n\t\t#include <skinnormal_vertex>\n\t\t#include <defaultnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\n}",fragment$a="uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\t\treflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include <aomap_fragment>\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include <envmap_fragment>\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",vertex$9="#define LAMBERT\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <envmap_pars_vertex>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <lights_lambert_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",fragment$9="uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <fog_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <emissivemap_fragment>\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack;\n\t#else\n\t\treflectedLight.indirectDiffuse += vIndirectFront;\n\t#endif\n\t#include <lightmap_fragment>\n\treflectedLight.indirectDiffuse *= BRDF_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Lambert( diffuseColor.rgb ) * getShadowMask();\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",vertex$8="#define MATCAP\nvarying vec3 vViewPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n\tvViewPosition = - mvPosition.xyz;\n}",fragment$8="#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <fog_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t#else\n\t\tvec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",vertex$7="#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",fragment$7="#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#include <packing>\n#include <uv_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n}",vertex$6="#define PHONG\nvarying vec3 vViewPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",fragment$6="#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_phong_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",vertex$5="#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n#ifdef USE_TRANSMISSION\n\tvWorldPosition = worldPosition.xyz;\n#endif\n}",fragment$5="#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULARINTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n\t#ifdef USE_SPECULARCOLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEENCOLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEENROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\nvarying vec3 vViewPosition;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <bsdfs>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_physical_pars_fragment>\n#include <transmission_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <clearcoat_normal_fragment_begin>\n\t#include <clearcoat_normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include <transmission_fragment>\n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_SHEEN\n\t\tfloat sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );\n\t\toutgoingLight = outgoingLight * sheenEnergyComp + sheenSpecular;\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + clearcoatSpecular * material.clearcoat;\n\t#endif\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",vertex$4="#define TOON\nvarying vec3 vViewPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",fragment$4="#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_toon_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_toon_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",vertex$3="uniform float size;\nuniform float scale;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <color_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <fog_vertex>\n}",fragment$3="uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_particle_fragment>\n\t#include <color_fragment>\n\t#include <alphatest_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",vertex$2="#include <common>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\nvoid main() {\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",fragment$2="uniform vec3 color;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}",vertex$1="uniform float rotation;\nuniform vec2 center;\n#include <common>\n#include <uv_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",fragment$1="uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}",ShaderChunk={alphamap_fragment:alphamap_fragment,alphamap_pars_fragment:alphamap_pars_fragment,alphatest_fragment:alphatest_fragment,alphatest_pars_fragment:alphatest_pars_fragment,aomap_fragment:aomap_fragment,aomap_pars_fragment:aomap_pars_fragment,begin_vertex:begin_vertex,beginnormal_vertex:beginnormal_vertex,bsdfs:bsdfs,bumpmap_pars_fragment:bumpmap_pars_fragment,clipping_planes_fragment:clipping_planes_fragment,clipping_planes_pars_fragment:clipping_planes_pars_fragment,clipping_planes_pars_vertex:clipping_planes_pars_vertex,clipping_planes_vertex:clipping_planes_vertex,color_fragment:color_fragment,color_pars_fragment:color_pars_fragment,color_pars_vertex:color_pars_vertex,color_vertex:color_vertex,common:common,cube_uv_reflection_fragment:cube_uv_reflection_fragment,defaultnormal_vertex:defaultnormal_vertex,displacementmap_pars_vertex:displacementmap_pars_vertex,displacementmap_vertex:displacementmap_vertex,emissivemap_fragment:emissivemap_fragment,emissivemap_pars_fragment:emissivemap_pars_fragment,encodings_fragment:encodings_fragment,encodings_pars_fragment:encodings_pars_fragment,envmap_fragment:envmap_fragment,envmap_common_pars_fragment:envmap_common_pars_fragment,envmap_pars_fragment:envmap_pars_fragment,envmap_pars_vertex:envmap_pars_vertex,envmap_physical_pars_fragment:envmap_physical_pars_fragment,envmap_vertex:envmap_vertex,fog_vertex:fog_vertex,fog_pars_vertex:fog_pars_vertex,fog_fragment:fog_fragment,fog_pars_fragment:fog_pars_fragment,gradientmap_pars_fragment:gradientmap_pars_fragment,lightmap_fragment:lightmap_fragment,lightmap_pars_fragment:lightmap_pars_fragment,lights_lambert_vertex:lights_lambert_vertex,lights_pars_begin:lights_pars_begin,lights_toon_fragment:lights_toon_fragment,lights_toon_pars_fragment:lights_toon_pars_fragment,lights_phong_fragment:lights_phong_fragment,lights_phong_pars_fragment:lights_phong_pars_fragment,lights_physical_fragment:lights_physical_fragment,lights_physical_pars_fragment:lights_physical_pars_fragment,lights_fragment_begin:lights_fragment_begin,lights_fragment_maps:lights_fragment_maps,lights_fragment_end:lights_fragment_end,logdepthbuf_fragment:logdepthbuf_fragment,logdepthbuf_pars_fragment:logdepthbuf_pars_fragment,logdepthbuf_pars_vertex:logdepthbuf_pars_vertex,logdepthbuf_vertex:logdepthbuf_vertex,map_fragment:map_fragment,map_pars_fragment:map_pars_fragment,map_particle_fragment:map_particle_fragment,map_particle_pars_fragment:map_particle_pars_fragment,metalnessmap_fragment:metalnessmap_fragment,metalnessmap_pars_fragment:metalnessmap_pars_fragment,morphnormal_vertex:morphnormal_vertex,morphtarget_pars_vertex:morphtarget_pars_vertex,morphtarget_vertex:morphtarget_vertex,normal_fragment_begin:normal_fragment_begin,normal_fragment_maps:normal_fragment_maps,normal_pars_fragment:normal_pars_fragment,normal_pars_vertex:normal_pars_vertex,normal_vertex:normal_vertex,normalmap_pars_fragment:normalmap_pars_fragment,clearcoat_normal_fragment_begin:clearcoat_normal_fragment_begin,clearcoat_normal_fragment_maps:clearcoat_normal_fragment_maps,clearcoat_pars_fragment:clearcoat_pars_fragment,output_fragment:output_fragment,packing:packing,premultiplied_alpha_fragment:premultiplied_alpha_fragment,project_vertex:project_vertex,dithering_fragment:dithering_fragment,dithering_pars_fragment:dithering_pars_fragment,roughnessmap_fragment:roughnessmap_fragment,roughnessmap_pars_fragment:roughnessmap_pars_fragment,shadowmap_pars_fragment:shadowmap_pars_fragment,shadowmap_pars_vertex:shadowmap_pars_vertex,shadowmap_vertex:shadowmap_vertex,shadowmask_pars_fragment:shadowmask_pars_fragment,skinbase_vertex:skinbase_vertex,skinning_pars_vertex:skinning_pars_vertex,skinning_vertex:skinning_vertex,skinnormal_vertex:skinnormal_vertex,specularmap_fragment:specularmap_fragment,specularmap_pars_fragment:specularmap_pars_fragment,tonemapping_fragment:tonemapping_fragment,tonemapping_pars_fragment:tonemapping_pars_fragment,transmission_fragment:transmission_fragment,transmission_pars_fragment:transmission_pars_fragment,uv_pars_fragment:uv_pars_fragment,uv_pars_vertex:uv_pars_vertex,uv_vertex:uv_vertex,uv2_pars_fragment:uv2_pars_fragment,uv2_pars_vertex:uv2_pars_vertex,uv2_vertex:uv2_vertex,worldpos_vertex:worldpos_vertex,background_vert:vertex$g,background_frag:fragment$g,cube_vert:vertex$f,cube_frag:fragment$f,depth_vert:vertex$e,depth_frag:fragment$e,distanceRGBA_vert:vertex$d,distanceRGBA_frag:fragment$d,equirect_vert:vertex$c,equirect_frag:fragment$c,linedashed_vert:vertex$b,linedashed_frag:fragment$b,meshbasic_vert:vertex$a,meshbasic_frag:fragment$a,meshlambert_vert:vertex$9,meshlambert_frag:fragment$9,meshmatcap_vert:vertex$8,meshmatcap_frag:fragment$8,meshnormal_vert:vertex$7,meshnormal_frag:fragment$7,meshphong_vert:vertex$6,meshphong_frag:fragment$6,meshphysical_vert:vertex$5,meshphysical_frag:fragment$5,meshtoon_vert:vertex$4,meshtoon_frag:fragment$4,points_vert:vertex$3,points_frag:fragment$3,shadow_vert:vertex$2,shadow_frag:fragment$2,sprite_vert:vertex$1,sprite_frag:fragment$1},UniformsLib={common:{diffuse:{value:new Color$1(16777215)},opacity:{value:1},map:{value:null},uvTransform:{value:new Matrix3},uv2Transform:{value:new Matrix3},alphaMap:{value:null},alphaTest:{value:0}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new Vector2(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Color$1(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotShadowMap:{value:[]},spotShadowMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Color$1(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new Matrix3}},sprite:{diffuse:{value:new Color$1(16777215)},opacity:{value:1},center:{value:new Vector2(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new Matrix3}}},ShaderLib={basic:{uniforms:mergeUniforms([UniformsLib.common,UniformsLib.specularmap,UniformsLib.envmap,UniformsLib.aomap,UniformsLib.lightmap,UniformsLib.fog]),vertexShader:ShaderChunk.meshbasic_vert,fragmentShader:ShaderChunk.meshbasic_frag},lambert:{uniforms:mergeUniforms([UniformsLib.common,UniformsLib.specularmap,UniformsLib.envmap,UniformsLib.aomap,UniformsLib.lightmap,UniformsLib.emissivemap,UniformsLib.fog,UniformsLib.lights,{emissive:{value:new Color$1(0)}}]),vertexShader:ShaderChunk.meshlambert_vert,fragmentShader:ShaderChunk.meshlambert_frag},phong:{uniforms:mergeUniforms([UniformsLib.common,UniformsLib.specularmap,UniformsLib.envmap,UniformsLib.aomap,UniformsLib.lightmap,UniformsLib.emissivemap,UniformsLib.bumpmap,UniformsLib.normalmap,UniformsLib.displacementmap,UniformsLib.fog,UniformsLib.lights,{emissive:{value:new Color$1(0)},specular:{value:new Color$1(1118481)},shininess:{value:30}}]),vertexShader:ShaderChunk.meshphong_vert,fragmentShader:ShaderChunk.meshphong_frag},standard:{uniforms:mergeUniforms([UniformsLib.common,UniformsLib.envmap,UniformsLib.aomap,UniformsLib.lightmap,UniformsLib.emissivemap,UniformsLib.bumpmap,UniformsLib.normalmap,UniformsLib.displacementmap,UniformsLib.roughnessmap,UniformsLib.metalnessmap,UniformsLib.fog,UniformsLib.lights,{emissive:{value:new Color$1(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:ShaderChunk.meshphysical_vert,fragmentShader:ShaderChunk.meshphysical_frag},toon:{uniforms:mergeUniforms([UniformsLib.common,UniformsLib.aomap,UniformsLib.lightmap,UniformsLib.emissivemap,UniformsLib.bumpmap,UniformsLib.normalmap,UniformsLib.displacementmap,UniformsLib.gradientmap,UniformsLib.fog,UniformsLib.lights,{emissive:{value:new Color$1(0)}}]),vertexShader:ShaderChunk.meshtoon_vert,fragmentShader:ShaderChunk.meshtoon_frag},matcap:{uniforms:mergeUniforms([UniformsLib.common,UniformsLib.bumpmap,UniformsLib.normalmap,UniformsLib.displacementmap,UniformsLib.fog,{matcap:{value:null}}]),vertexShader:ShaderChunk.meshmatcap_vert,fragmentShader:ShaderChunk.meshmatcap_frag},points:{uniforms:mergeUniforms([UniformsLib.points,UniformsLib.fog]),vertexShader:ShaderChunk.points_vert,fragmentShader:ShaderChunk.points_frag},dashed:{uniforms:mergeUniforms([UniformsLib.common,UniformsLib.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:ShaderChunk.linedashed_vert,fragmentShader:ShaderChunk.linedashed_frag},depth:{uniforms:mergeUniforms([UniformsLib.common,UniformsLib.displacementmap]),vertexShader:ShaderChunk.depth_vert,fragmentShader:ShaderChunk.depth_frag},normal:{uniforms:mergeUniforms([UniformsLib.common,UniformsLib.bumpmap,UniformsLib.normalmap,UniformsLib.displacementmap,{opacity:{value:1}}]),vertexShader:ShaderChunk.meshnormal_vert,fragmentShader:ShaderChunk.meshnormal_frag},sprite:{uniforms:mergeUniforms([UniformsLib.sprite,UniformsLib.fog]),vertexShader:ShaderChunk.sprite_vert,fragmentShader:ShaderChunk.sprite_frag},background:{uniforms:{uvTransform:{value:new Matrix3},t2D:{value:null}},vertexShader:ShaderChunk.background_vert,fragmentShader:ShaderChunk.background_frag},cube:{uniforms:mergeUniforms([UniformsLib.envmap,{opacity:{value:1}}]),vertexShader:ShaderChunk.cube_vert,fragmentShader:ShaderChunk.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:ShaderChunk.equirect_vert,fragmentShader:ShaderChunk.equirect_frag},distanceRGBA:{uniforms:mergeUniforms([UniformsLib.common,UniformsLib.displacementmap,{referencePosition:{value:new Vector3},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:ShaderChunk.distanceRGBA_vert,fragmentShader:ShaderChunk.distanceRGBA_frag},shadow:{uniforms:mergeUniforms([UniformsLib.lights,UniformsLib.fog,{color:{value:new Color$1(0)},opacity:{value:1}}]),vertexShader:ShaderChunk.shadow_vert,fragmentShader:ShaderChunk.shadow_frag}};function WebGLBackground(e,t,n,r,i,a){const o=new Color$1(0);let s,l,c=!0===i?0:1,h=null,u=0,d=null;function p(e,t){n.buffers.color.setClear(e.r,e.g,e.b,t,a)}return{getClearColor:function(){return o},setClearColor:function(e,t=1){o.set(e),c=t,p(o,c)},getClearAlpha:function(){return c},setClearAlpha:function(e){c=e,p(o,c)},render:function m(n,i){let a=!1,m=!0===i.isScene?i.background:null;m&&m.isTexture&&(m=t.get(m));const f=e.xr,g=f.getSession&&f.getSession();g&&"additive"===g.environmentBlendMode&&(m=null),null===m?p(o,c):m&&m.isColor&&(p(m,1),a=!0),(e.autoClear||a)&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),m&&(m.isCubeTexture||m.mapping===CubeUVReflectionMapping)?(void 0===l&&(l=new Mesh(new BoxGeometry(1,1,1),new ShaderMaterial({name:"BackgroundCubeMaterial",uniforms:cloneUniforms(ShaderLib.cube.uniforms),vertexShader:ShaderLib.cube.vertexShader,fragmentShader:ShaderLib.cube.fragmentShader,side:BackSide,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(e,t,n){this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(l)),l.material.uniforms.envMap.value=m,l.material.uniforms.flipEnvMap.value=m.isCubeTexture&&!1===m.isRenderTargetTexture?-1:1,h===m&&u===m.version&&d===e.toneMapping||(l.material.needsUpdate=!0,h=m,u=m.version,d=e.toneMapping),n.unshift(l,l.geometry,l.material,0,0,null)):m&&m.isTexture&&(void 0===s&&(s=new Mesh(new PlaneGeometry(2,2),new ShaderMaterial({name:"BackgroundMaterial",uniforms:cloneUniforms(ShaderLib.background.uniforms),vertexShader:ShaderLib.background.vertexShader,fragmentShader:ShaderLib.background.fragmentShader,side:FrontSide,depthTest:!1,depthWrite:!1,fog:!1})),s.geometry.deleteAttribute("normal"),Object.defineProperty(s.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(s)),s.material.uniforms.t2D.value=m,!0===m.matrixAutoUpdate&&m.updateMatrix(),s.material.uniforms.uvTransform.value.copy(m.matrix),h===m&&u===m.version&&d===e.toneMapping||(s.material.needsUpdate=!0,h=m,u=m.version,d=e.toneMapping),n.unshift(s,s.geometry,s.material,0,0,null))}}}function WebGLBindingStates(e,t,n,r){const i=e.getParameter(34921),a=r.isWebGL2?null:t.get("OES_vertex_array_object"),o=r.isWebGL2||null!==a,s={},l=d(null);let c=l;function h(t){return r.isWebGL2?e.bindVertexArray(t):a.bindVertexArrayOES(t)}function u(t){return r.isWebGL2?e.deleteVertexArray(t):a.deleteVertexArrayOES(t)}function d(e){const t=[],n=[],r=[];for(let e=0;e<i;e++)t[e]=0,n[e]=0,r[e]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:t,enabledAttributes:n,attributeDivisors:r,object:e,attributes:{},index:null}}function p(){const e=c.newAttributes;for(let t=0,n=e.length;t<n;t++)e[t]=0}function m(e){f(e,0)}function f(n,i){const a=c.enabledAttributes,o=c.attributeDivisors;if(c.newAttributes[n]=1,0===a[n]&&(e.enableVertexAttribArray(n),a[n]=1),o[n]!==i){(r.isWebGL2?e:t.get("ANGLE_instanced_arrays"))[r.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](n,i),o[n]=i}}function g(){const t=c.newAttributes,n=c.enabledAttributes;for(let r=0,i=n.length;r<i;r++)n[r]!==t[r]&&(e.disableVertexAttribArray(r),n[r]=0)}function v(t,n,i,a,o,s){!0!==r.isWebGL2||5124!==i&&5125!==i?e.vertexAttribPointer(t,n,i,a,o,s):e.vertexAttribIPointer(t,n,i,o,s)}function y(){_(),c!==l&&(c=l,h(c.object))}function _(){l.geometry=null,l.program=null,l.wireframe=!1}return{setup:function b(i,l,u,y,_){let b=!1;if(o){const t=(function x(t,n,i){const o=!0===i.wireframe;let l=s[t.id];void 0===l&&(l={},s[t.id]=l);let c=l[n.id];void 0===c&&(c={},l[n.id]=c);let h=c[o];void 0===h&&(h=d((function u(){return r.isWebGL2?e.createVertexArray():a.createVertexArrayOES()})()),c[o]=h);return h})(y,u,l);c!==t&&(c=t,h(c.object)),b=(function S(e,t){const n=c.attributes,r=e.attributes;let i=0;for(const e in r){const t=n[e],a=r[e];if(void 0===t)return!0;if(t.attribute!==a)return!0;if(t.data!==a.data)return!0;i++}return c.attributesNum!==i||c.index!==t})(y,_),b&&(function w(e,t){const n={},r=e.attributes;let i=0;for(const e in r){const t=r[e],a={};a.attribute=t,t.data&&(a.data=t.data),n[e]=a,i++}c.attributes=n,c.attributesNum=i,c.index=t})(y,_)}else{const e=!0===l.wireframe;c.geometry===y.id&&c.program===u.id&&c.wireframe===e||(c.geometry=y.id,c.program=u.id,c.wireframe=e,b=!0)}!0===i.isInstancedMesh&&(b=!0),null!==_&&n.update(_,34963),b&&(!(function C(i,a,o,s){if(!1===r.isWebGL2&&(i.isInstancedMesh||s.isInstancedBufferGeometry)&&null===t.get("ANGLE_instanced_arrays"))return;p();const l=s.attributes,c=o.getAttributes(),h=a.defaultAttributeValues;for(const t in c){const r=c[t];if(r.location>=0){let a=l[t];if(void 0===a&&("instanceMatrix"===t&&i.instanceMatrix&&(a=i.instanceMatrix),"instanceColor"===t&&i.instanceColor&&(a=i.instanceColor)),void 0!==a){const t=a.normalized,o=a.itemSize,l=n.get(a);if(void 0===l)continue;const c=l.buffer,h=l.type,u=l.bytesPerElement;if(a.isInterleavedBufferAttribute){const n=a.data,l=n.stride,d=a.offset;if(n&&n.isInstancedInterleavedBuffer){for(let e=0;e<r.locationSize;e++)f(r.location+e,n.meshPerAttribute);!0!==i.isInstancedMesh&&void 0===s._maxInstanceCount&&(s._maxInstanceCount=n.meshPerAttribute*n.count)}else for(let e=0;e<r.locationSize;e++)m(r.location+e);e.bindBuffer(34962,c);for(let e=0;e<r.locationSize;e++)v(r.location+e,o/r.locationSize,h,t,l*u,(d+o/r.locationSize*e)*u)}else{if(a.isInstancedBufferAttribute){for(let e=0;e<r.locationSize;e++)f(r.location+e,a.meshPerAttribute);!0!==i.isInstancedMesh&&void 0===s._maxInstanceCount&&(s._maxInstanceCount=a.meshPerAttribute*a.count)}else for(let e=0;e<r.locationSize;e++)m(r.location+e);e.bindBuffer(34962,c);for(let e=0;e<r.locationSize;e++)v(r.location+e,o/r.locationSize,h,t,o*u,o/r.locationSize*e*u)}}else if(void 0!==h){const n=h[t];if(void 0!==n)switch(n.length){case 2:e.vertexAttrib2fv(r.location,n);break;case 3:e.vertexAttrib3fv(r.location,n);break;case 4:e.vertexAttrib4fv(r.location,n);break;default:e.vertexAttrib1fv(r.location,n)}}}}g()})(i,l,u,y),null!==_&&e.bindBuffer(34963,n.get(_).buffer))},reset:y,resetDefaultState:_,dispose:function x(){y();for(const e in s){const t=s[e];for(const e in t){const n=t[e];for(const e in n)u(n[e].object),delete n[e];delete t[e]}delete s[e]}},releaseStatesOfGeometry:function S(e){if(void 0===s[e.id])return;const t=s[e.id];for(const e in t){const n=t[e];for(const e in n)u(n[e].object),delete n[e];delete t[e]}delete s[e.id]},releaseStatesOfProgram:function w(e){for(const t in s){const n=s[t];if(void 0===n[e.id])continue;const r=n[e.id];for(const e in r)u(r[e].object),delete r[e];delete n[e.id]}},initAttributes:p,enableAttribute:m,disableUnusedAttributes:g}}function WebGLBufferRenderer(e,t,n,r){const i=r.isWebGL2;let a;this.setMode=function o(e){a=e},this.render=function s(t,r){e.drawArrays(a,t,r),n.update(r,a,1)},this.renderInstances=function l(r,o,s){if(0===s)return;let l,c;if(i)l=e,c="drawArraysInstanced";else if(l=t.get("ANGLE_instanced_arrays"),c="drawArraysInstancedANGLE",null===l)return void console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");l[c](a,r,o,s),n.update(o,a,s)}}function WebGLCapabilities(e,t,n){let r;function i(t){if("highp"===t){if(e.getShaderPrecisionFormat(35633,36338).precision>0&&e.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";t="mediump"}return"mediump"===t&&e.getShaderPrecisionFormat(35633,36337).precision>0&&e.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}const a="undefined"!=typeof WebGL2RenderingContext&&e instanceof WebGL2RenderingContext||"undefined"!=typeof WebGL2ComputeRenderingContext&&e instanceof WebGL2ComputeRenderingContext;let o=void 0!==n.precision?n.precision:"highp";const s=i(o);s!==o&&(console.warn("THREE.WebGLRenderer:",o,"not supported, using",s,"instead."),o=s);const l=a||t.has("WEBGL_draw_buffers"),c=!0===n.logarithmicDepthBuffer,h=e.getParameter(34930),u=e.getParameter(35660),d=e.getParameter(3379),p=e.getParameter(34076),m=e.getParameter(34921),f=e.getParameter(36347),g=e.getParameter(36348),v=e.getParameter(36349),y=u>0,_=a||t.has("OES_texture_float");return{isWebGL2:a,drawBuffers:l,getMaxAnisotropy:function b(){if(void 0!==r)return r;if(!0===t.has("EXT_texture_filter_anisotropic")){const n=t.get("EXT_texture_filter_anisotropic");r=e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r},getMaxPrecision:i,precision:o,logarithmicDepthBuffer:c,maxTextures:h,maxVertexTextures:u,maxTextureSize:d,maxCubemapSize:p,maxAttributes:m,maxVertexUniforms:f,maxVaryings:g,maxFragmentUniforms:v,vertexTextures:y,floatFragmentTextures:_,floatVertexTextures:y&&_,maxSamples:a?e.getParameter(36183):0}}function WebGLClipping(e){const t=this;let n=null,r=0,i=!1,a=!1;const o=new Plane,s=new Matrix3,l={value:null,needsUpdate:!1};function c(){l.value!==n&&(l.value=n,l.needsUpdate=r>0),t.numPlanes=r,t.numIntersection=0}function h(e,n,r,i){const a=null!==e?e.length:0;let c=null;if(0!==a){if(c=l.value,!0!==i||null===c){const t=r+4*a,i=n.matrixWorldInverse;s.getNormalMatrix(i),(null===c||c.length<t)&&(c=new Float32Array(t));for(let t=0,n=r;t!==a;++t,n+=4)o.copy(e[t]).applyMatrix4(i,s),o.normal.toArray(c,n),c[n+3]=o.constant}l.value=c,l.needsUpdate=!0}return t.numPlanes=a,t.numIntersection=0,c}this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(e,t,a){const o=0!==e.length||t||0!==r||i;return i=t,n=h(e,a,0),r=e.length,o},this.beginShadows=function(){a=!0,h(null)},this.endShadows=function(){a=!1,c()},this.setState=function(t,o,s){const u=t.clippingPlanes,d=t.clipIntersection,p=t.clipShadows,m=e.get(t);if(!i||null===u||0===u.length||a&&!p)a?h(null):c();else{const e=a?0:r,t=4*e;let i=m.clippingState||null;l.value=i,i=h(u,o,t,s);for(let e=0;e!==t;++e)i[e]=n[e];m.clippingState=i,this.numIntersection=d?this.numPlanes:0,this.numPlanes+=e}}}function WebGLCubeMaps(e){let t=new WeakMap;function n(e,t){return t===EquirectangularReflectionMapping?e.mapping=CubeReflectionMapping:t===EquirectangularRefractionMapping&&(e.mapping=CubeRefractionMapping),e}function r(e){const n=e.target;n.removeEventListener("dispose",r);const i=t.get(n);void 0!==i&&(t.delete(n),i.dispose())}return{get:function i(a){if(a&&a.isTexture&&!1===a.isRenderTargetTexture){const i=a.mapping;if(i===EquirectangularReflectionMapping||i===EquirectangularRefractionMapping){if(t.has(a)){return n(t.get(a).texture,a.mapping)}{const i=a.image;if(i&&i.height>0){const o=new WebGLCubeRenderTarget(i.height/2);return o.fromEquirectangularTexture(e,a),t.set(a,o),a.addEventListener("dispose",r),n(o.texture,a.mapping)}return null}}}return a},dispose:function a(){t=new WeakMap}}}ShaderLib.physical={uniforms:mergeUniforms([ShaderLib.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new Vector2(1,1)},clearcoatNormalMap:{value:null},sheen:{value:0},sheenColor:{value:new Color$1(0)},sheenColorMap:{value:null},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},transmission:{value:0},transmissionMap:{value:null},transmissionSamplerSize:{value:new Vector2},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},attenuationDistance:{value:0},attenuationColor:{value:new Color$1(0)},specularIntensity:{value:1},specularIntensityMap:{value:null},specularColor:{value:new Color$1(1,1,1)},specularColorMap:{value:null}}]),vertexShader:ShaderChunk.meshphysical_vert,fragmentShader:ShaderChunk.meshphysical_frag};class OrthographicCamera extends Camera{constructor(e=-1,t=1,n=1,r=-1,i=.1,a=2e3){super(),this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=r,this.near=i,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=null===e.view?null:Object.assign({},e.view),this}setViewOffset(e,t,n,r,i,a){null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=i,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,r=(this.top+this.bottom)/2;let i=n-e,a=n+e,o=r+t,s=r-t;if(null!==this.view&&this.view.enabled){const e=(this.right-this.left)/this.view.fullWidth/this.zoom,t=(this.top-this.bottom)/this.view.fullHeight/this.zoom;i+=e*this.view.offsetX,a=i+e*this.view.width,o-=t*this.view.offsetY,s=o-t*this.view.height}this.projectionMatrix.makeOrthographic(i,a,o,s,this.near,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,null!==this.view&&(t.object.view=Object.assign({},this.view)),t}}OrthographicCamera.prototype.isOrthographicCamera=!0;class RawShaderMaterial extends ShaderMaterial{constructor(e){super(e),this.type="RawShaderMaterial"}}RawShaderMaterial.prototype.isRawShaderMaterial=!0;const LOD_MIN=4,LOD_MAX=8,SIZE_MAX=Math.pow(2,LOD_MAX),EXTRA_LOD_SIGMA=[.125,.215,.35,.446,.526,.582],TOTAL_LODS=LOD_MAX-LOD_MIN+1+EXTRA_LOD_SIGMA.length,MAX_SAMPLES=20,_flatCamera=new OrthographicCamera,{_lodPlanes:_lodPlanes,_sizeLods:_sizeLods,_sigmas:_sigmas}=_createPlanes(),_clearColor=new Color$1;let _oldTarget=null;const PHI=(1+Math.sqrt(5))/2,INV_PHI=1/PHI,_axisDirections=[new Vector3(1,1,1),new Vector3(-1,1,1),new Vector3(1,1,-1),new Vector3(-1,1,-1),new Vector3(0,PHI,INV_PHI),new Vector3(0,PHI,-INV_PHI),new Vector3(INV_PHI,0,PHI),new Vector3(-INV_PHI,0,PHI),new Vector3(PHI,INV_PHI,0),new Vector3(-PHI,INV_PHI,0)];class PMREMGenerator{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._blurMaterial=_getBlurShader(MAX_SAMPLES),this._equirectShader=null,this._cubemapShader=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,r=100){_oldTarget=this._renderer.getRenderTarget();const i=this._allocateTargets();return this._sceneToCubeUV(e,n,r,i),t>0&&this._blur(i,0,0,t),this._applyPMREM(i),this._cleanup(i),i}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){null===this._cubemapShader&&(this._cubemapShader=_getCubemapShader(),this._compileMaterial(this._cubemapShader))}compileEquirectangularShader(){null===this._equirectShader&&(this._equirectShader=_getEquirectShader(),this._compileMaterial(this._equirectShader))}dispose(){this._blurMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose(),null!==this._cubemapShader&&this._cubemapShader.dispose(),null!==this._equirectShader&&this._equirectShader.dispose();for(let e=0;e<_lodPlanes.length;e++)_lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(_oldTarget),e.scissorTest=!1,_setViewport(e,0,0,e.width,e.height)}_fromTexture(e,t){_oldTarget=this._renderer.getRenderTarget();const n=t||this._allocateTargets(e);return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(e){const t={magFilter:LinearFilter,minFilter:LinearFilter,generateMipmaps:!1,type:HalfFloatType,format:RGBAFormat,encoding:LinearEncoding,depthBuffer:!1},n=_createRenderTarget(t);return n.depthBuffer=!e,null===this._pingPongRenderTarget&&(this._pingPongRenderTarget=_createRenderTarget(t)),n}_compileMaterial(e){const t=new Mesh(_lodPlanes[0],e);this._renderer.compile(t,_flatCamera)}_sceneToCubeUV(e,t,n,r){const i=new PerspectiveCamera(90,1,t,n),a=[1,-1,1,1,1,1],o=[1,1,1,-1,-1,-1],s=this._renderer,l=s.autoClear,c=s.toneMapping;s.getClearColor(_clearColor),s.toneMapping=NoToneMapping,s.autoClear=!1;const h=new MeshBasicMaterial({name:"PMREM.Background",side:BackSide,depthWrite:!1,depthTest:!1}),u=new Mesh(new BoxGeometry,h);let d=!1;const p=e.background;p?p.isColor&&(h.color.copy(p),e.background=null,d=!0):(h.color.copy(_clearColor),d=!0);for(let t=0;t<6;t++){const n=t%3;0===n?(i.up.set(0,a[t],0),i.lookAt(o[t],0,0)):1===n?(i.up.set(0,0,a[t]),i.lookAt(0,o[t],0)):(i.up.set(0,a[t],0),i.lookAt(0,0,o[t])),_setViewport(r,n*SIZE_MAX,t>2?SIZE_MAX:0,SIZE_MAX,SIZE_MAX),s.setRenderTarget(r),d&&s.render(u,i),s.render(e,i)}u.geometry.dispose(),u.material.dispose(),s.toneMapping=c,s.autoClear=l,e.background=p}_textureToCubeUV(e,t){const n=this._renderer,r=e.mapping===CubeReflectionMapping||e.mapping===CubeRefractionMapping;r?(null===this._cubemapShader&&(this._cubemapShader=_getCubemapShader()),this._cubemapShader.uniforms.flipEnvMap.value=!1===e.isRenderTargetTexture?-1:1):null===this._equirectShader&&(this._equirectShader=_getEquirectShader());const i=r?this._cubemapShader:this._equirectShader,a=new Mesh(_lodPlanes[0],i),o=i.uniforms;o.envMap.value=e,r||o.texelSize.value.set(1/e.image.width,1/e.image.height),_setViewport(t,0,0,3*SIZE_MAX,2*SIZE_MAX),n.setRenderTarget(t),n.render(a,_flatCamera)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;for(let t=1;t<TOTAL_LODS;t++){const n=Math.sqrt(_sigmas[t]*_sigmas[t]-_sigmas[t-1]*_sigmas[t-1]);this._blur(e,t-1,t,n,_axisDirections[(t-1)%_axisDirections.length])}t.autoClear=n}_blur(e,t,n,r,i){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,r,"latitudinal",i),this._halfBlur(a,e,n,n,r,"longitudinal",i)}_halfBlur(e,t,n,r,i,a,o){const s=this._renderer,l=this._blurMaterial;"latitudinal"!==a&&"longitudinal"!==a&&console.error("blur direction must be either latitudinal or longitudinal!");const c=new Mesh(_lodPlanes[r],l),h=l.uniforms,u=_sizeLods[n]-1,d=isFinite(i)?Math.PI/(2*u):2*Math.PI/(2*MAX_SAMPLES-1),p=i/d,m=isFinite(i)?1+Math.floor(3*p):MAX_SAMPLES;m>MAX_SAMPLES&&console.warn(`sigmaRadians, ${i}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${MAX_SAMPLES}`);const f=[];let g=0;for(let e=0;e<MAX_SAMPLES;++e){const t=e/p,n=Math.exp(-t*t/2);f.push(n),0===e?g+=n:e<m&&(g+=2*n)}for(let e=0;e<f.length;e++)f[e]=f[e]/g;h.envMap.value=e.texture,h.samples.value=m,h.weights.value=f,h.latitudinal.value="latitudinal"===a,o&&(h.poleAxis.value=o),h.dTheta.value=d,h.mipInt.value=LOD_MAX-n;const v=_sizeLods[r];_setViewport(t,3*Math.max(0,SIZE_MAX-2*v),(0===r?0:2*SIZE_MAX)+2*v*(r>LOD_MAX-LOD_MIN?r-LOD_MAX+LOD_MIN:0),3*v,2*v),s.setRenderTarget(t),s.render(c,_flatCamera)}}function _createPlanes(){const e=[],t=[],n=[];let r=LOD_MAX;for(let i=0;i<TOTAL_LODS;i++){const a=Math.pow(2,r);t.push(a);let o=1/a;i>LOD_MAX-LOD_MIN?o=EXTRA_LOD_SIGMA[i-LOD_MAX+LOD_MIN-1]:0===i&&(o=0),n.push(o);const s=1/(a-1),l=-s/2,c=1+s/2,h=[l,l,c,l,c,c,l,l,c,c,l,c],u=6,d=6,p=3,m=2,f=1,g=new Float32Array(p*d*u),v=new Float32Array(m*d*u),y=new Float32Array(f*d*u);for(let e=0;e<u;e++){const t=e%3*2/3-1,n=e>2?0:-1;g.set([t,n,0,t+2/3,n,0,t+2/3,n+1,0,t,n,0,t+2/3,n+1,0,t,n+1,0],p*d*e),v.set(h,m*d*e);y.set([e,e,e,e,e,e],f*d*e)}const _=new BufferGeometry;_.setAttribute("position",new BufferAttribute(g,p)),_.setAttribute("uv",new BufferAttribute(v,m)),_.setAttribute("faceIndex",new BufferAttribute(y,f)),e.push(_),r>LOD_MIN&&r--}return{_lodPlanes:e,_sizeLods:t,_sigmas:n}}function _createRenderTarget(e){const t=new WebGLRenderTarget(3*SIZE_MAX,3*SIZE_MAX,e);return t.texture.mapping=CubeUVReflectionMapping,t.texture.name="PMREM.cubeUv",t.scissorTest=!0,t}function _setViewport(e,t,n,r,i){e.viewport.set(t,n,r,i),e.scissor.set(t,n,r,i)}function _getBlurShader(e){const t=new Float32Array(e),n=new Vector3(0,1,0);return new RawShaderMaterial({name:"SphericalGaussianBlur",defines:{n:e},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:t},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:n}},vertexShader:_getCommonVertexShader(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform int samples;\n\t\t\tuniform float weights[ n ];\n\t\t\tuniform bool latitudinal;\n\t\t\tuniform float dTheta;\n\t\t\tuniform float mipInt;\n\t\t\tuniform vec3 poleAxis;\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include <cube_uv_reflection_fragment>\n\n\t\t\tvec3 getSample( float theta, vec3 axis ) {\n\n\t\t\t\tfloat cosTheta = cos( theta );\n\t\t\t\t// Rodrigues' axis-angle rotation\n\t\t\t\tvec3 sampleDirection = vOutputDirection * cosTheta\n\t\t\t\t\t+ cross( axis, vOutputDirection ) * sin( theta )\n\t\t\t\t\t+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\n\n\t\t\t\treturn bilinearCubeUV( envMap, sampleDirection, mipInt );\n\n\t\t\t}\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\n\n\t\t\t\tif ( all( equal( axis, vec3( 0.0 ) ) ) ) {\n\n\t\t\t\t\taxis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\n\n\t\t\t\t}\n\n\t\t\t\taxis = normalize( axis );\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\n\n\t\t\t\tfor ( int i = 1; i < n; i++ ) {\n\n\t\t\t\t\tif ( i >= samples ) {\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tfloat theta = dTheta * float( i );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\n\n\t\t\t\t}\n\n\t\t\t}\n\t\t",blending:NoBlending,depthTest:!1,depthWrite:!1})}function _getEquirectShader(){const e=new Vector2(1,1);return new RawShaderMaterial({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null},texelSize:{value:e}},vertexShader:_getCommonVertexShader(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform vec2 texelSize;\n\n\t\t\t#include <common>\n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\n\t\t\t\tvec3 outputDirection = normalize( vOutputDirection );\n\t\t\t\tvec2 uv = equirectUv( outputDirection );\n\n\t\t\t\tvec2 f = fract( uv / texelSize - 0.5 );\n\t\t\t\tuv -= f * texelSize;\n\t\t\t\tvec3 tl = texture2D ( envMap, uv ).rgb;\n\t\t\t\tuv.x += texelSize.x;\n\t\t\t\tvec3 tr = texture2D ( envMap, uv ).rgb;\n\t\t\t\tuv.y += texelSize.y;\n\t\t\t\tvec3 br = texture2D ( envMap, uv ).rgb;\n\t\t\t\tuv.x -= texelSize.x;\n\t\t\t\tvec3 bl = texture2D ( envMap, uv ).rgb;\n\n\t\t\t\tvec3 tm = mix( tl, tr, f.x );\n\t\t\t\tvec3 bm = mix( bl, br, f.x );\n\t\t\t\tgl_FragColor.rgb = mix( tm, bm, f.y );\n\n\t\t\t}\n\t\t",blending:NoBlending,depthTest:!1,depthWrite:!1})}function _getCubemapShader(){return new RawShaderMaterial({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:_getCommonVertexShader(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tuniform float flipEnvMap;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform samplerCube envMap;\n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );\n\n\t\t\t}\n\t\t",blending:NoBlending,depthTest:!1,depthWrite:!1})}function _getCommonVertexShader(){return"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute vec3 position;\n\t\tattribute vec2 uv;\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t"}function WebGLCubeUVMaps(e){let t=new WeakMap,n=null;function r(e){const n=e.target;n.removeEventListener("dispose",r);const i=t.get(n);void 0!==i&&(t.delete(n),i.dispose())}return{get:function i(a){if(a&&a.isTexture){const i=a.mapping,o=i===EquirectangularReflectionMapping||i===EquirectangularRefractionMapping,s=i===CubeReflectionMapping||i===CubeRefractionMapping;if(o||s){if(a.isRenderTargetTexture&&!0===a.needsPMREMUpdate){a.needsPMREMUpdate=!1;let r=t.get(a);return null===n&&(n=new PMREMGenerator(e)),r=o?n.fromEquirectangular(a,r):n.fromCubemap(a,r),t.set(a,r),r.texture}if(t.has(a))return t.get(a).texture;{const i=a.image;if(o&&i&&i.height>0||s&&i&&(function o(e){let t=0;const n=6;for(let r=0;r<n;r++)void 0!==e[r]&&t++;return t===n})(i)){null===n&&(n=new PMREMGenerator(e));const i=o?n.fromEquirectangular(a):n.fromCubemap(a);return t.set(a,i),a.addEventListener("dispose",r),i.texture}return null}}}return a},dispose:function a(){t=new WeakMap,null!==n&&(n.dispose(),n=null)}}}function WebGLExtensions(e){const t={};function n(n){if(void 0!==t[n])return t[n];let r;switch(n){case"WEBGL_depth_texture":r=e.getExtension("WEBGL_depth_texture")||e.getExtension("MOZ_WEBGL_depth_texture")||e.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":r=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":r=e.getExtension("WEBGL_compressed_texture_s3tc")||e.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":r=e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:r=e.getExtension(n)}return t[n]=r,r}return{has:function(e){return null!==n(e)},init:function(e){e.isWebGL2?n("EXT_color_buffer_float"):(n("WEBGL_depth_texture"),n("OES_texture_float"),n("OES_texture_half_float"),n("OES_texture_half_float_linear"),n("OES_standard_derivatives"),n("OES_element_index_uint"),n("OES_vertex_array_object"),n("ANGLE_instanced_arrays")),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float"),n("WEBGL_multisampled_render_to_texture")},get:function(e){const t=n(e);return null===t&&console.warn("THREE.WebGLRenderer: "+e+" extension not supported."),t}}}function WebGLGeometries(e,t,n,r){const i={},a=new WeakMap;function o(e){const s=e.target;null!==s.index&&t.remove(s.index);for(const e in s.attributes)t.remove(s.attributes[e]);s.removeEventListener("dispose",o),delete i[s.id];const l=a.get(s);l&&(t.remove(l),a.delete(s)),r.releaseStatesOfGeometry(s),!0===s.isInstancedBufferGeometry&&delete s._maxInstanceCount,n.memory.geometries--}function s(e){const n=[],r=e.index,i=e.attributes.position;let o=0;if(null!==r){const e=r.array;o=r.version;for(let t=0,r=e.length;t<r;t+=3){const r=e[t+0],i=e[t+1],a=e[t+2];n.push(r,i,i,a,a,r)}}else{o=i.version;for(let e=0,t=i.array.length/3-1;e<t;e+=3){const t=e+0,r=e+1,i=e+2;n.push(t,r,r,i,i,t)}}const s=new(arrayNeedsUint32(n)?Uint32BufferAttribute:Uint16BufferAttribute)(n,1);s.version=o;const l=a.get(e);l&&t.remove(l),a.set(e,s)}return{get:function l(e,t){return!0===i[t.id]||(t.addEventListener("dispose",o),i[t.id]=!0,n.memory.geometries++),t},update:function c(e){const n=e.attributes;for(const e in n)t.update(n[e],34962);const r=e.morphAttributes;for(const e in r){const n=r[e];for(let e=0,r=n.length;e<r;e++)t.update(n[e],34962)}},getWireframeAttribute:function h(e){const t=a.get(e);if(t){const n=e.index;null!==n&&t.version<n.version&&s(e)}else s(e);return a.get(e)}}}function WebGLIndexedBufferRenderer(e,t,n,r){const i=r.isWebGL2;let a,o,s;this.setMode=function l(e){a=e},this.setIndex=function c(e){o=e.type,s=e.bytesPerElement},this.render=function h(t,r){e.drawElements(a,r,o,t*s),n.update(r,a,1)},this.renderInstances=function u(r,l,c){if(0===c)return;let h,u;if(i)h=e,u="drawElementsInstanced";else if(h=t.get("ANGLE_instanced_arrays"),u="drawElementsInstancedANGLE",null===h)return void console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");h[u](a,l,o,r*s,c),n.update(l,a,c)}}function WebGLInfo(e){const t={frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:{geometries:0,textures:0},render:t,programs:null,autoReset:!0,reset:function n(){t.frame++,t.calls=0,t.triangles=0,t.points=0,t.lines=0},update:function r(e,n,i){switch(t.calls++,n){case 4:t.triangles+=i*(e/3);break;case 1:t.lines+=i*(e/2);break;case 3:t.lines+=i*(e-1);break;case 2:t.lines+=i*e;break;case 0:t.points+=i*e;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",n)}}}}class DataTexture2DArray extends Texture{constructor(e=null,t=1,n=1,r=1){super(null),this.image={data:e,width:t,height:n,depth:r},this.magFilter=NearestFilter,this.minFilter=NearestFilter,this.wrapR=ClampToEdgeWrapping,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}function numericalSort(e,t){return e[0]-t[0]}function absNumericalSort(e,t){return Math.abs(t[1])-Math.abs(e[1])}function denormalize(e,t){let n=1;const r=t.isInterleavedBufferAttribute?t.data.array:t.array;r instanceof Int8Array?n=127:r instanceof Int16Array?n=32767:r instanceof Int32Array?n=2147483647:console.error("THREE.WebGLMorphtargets: Unsupported morph attribute data type: ",r),e.divideScalar(n)}function WebGLMorphtargets(e,t,n){const r={},i=new Float32Array(8),a=new WeakMap,o=new Vector3,s=[];for(let e=0;e<8;e++)s[e]=[e,0];return{update:function l(c,h,u,d){const p=c.morphTargetInfluences;if(!0===t.isWebGL2){const r=h.morphAttributes.position.length;let i=a.get(h);if(void 0===i||i.count!==r){void 0!==i&&i.texture.dispose();const e=void 0!==h.morphAttributes.normal,n=h.morphAttributes.position,s=h.morphAttributes.normal||[],l=!0===e?2:1;let c=h.attributes.position.count*l,u=1;c>t.maxTextureSize&&(u=Math.ceil(c/t.maxTextureSize),c=t.maxTextureSize);const d=new Float32Array(c*u*4*r),p=new DataTexture2DArray(d,c,u,r);p.format=RGBAFormat,p.type=FloatType,p.needsUpdate=!0;const m=4*l;for(let t=0;t<r;t++){const r=n[t],i=s[t],a=c*u*4*t;for(let t=0;t<r.count;t++){o.fromBufferAttribute(r,t),!0===r.normalized&&denormalize(o,r);const n=t*m;d[a+n+0]=o.x,d[a+n+1]=o.y,d[a+n+2]=o.z,d[a+n+3]=0,!0===e&&(o.fromBufferAttribute(i,t),!0===i.normalized&&denormalize(o,i),d[a+n+4]=o.x,d[a+n+5]=o.y,d[a+n+6]=o.z,d[a+n+7]=0)}}i={count:r,texture:p,size:new Vector2(c,u)},a.set(h,i),h.addEventListener("dispose",(function e(){p.dispose(),a.delete(h),h.removeEventListener("dispose",e)}))}let s=0;for(let e=0;e<p.length;e++)s+=p[e];const l=h.morphTargetsRelative?1:1-s;d.getUniforms().setValue(e,"morphTargetBaseInfluence",l),d.getUniforms().setValue(e,"morphTargetInfluences",p),d.getUniforms().setValue(e,"morphTargetsTexture",i.texture,n),d.getUniforms().setValue(e,"morphTargetsTextureSize",i.size)}else{const t=void 0===p?0:p.length;let n=r[h.id];if(void 0===n||n.length!==t){n=[];for(let e=0;e<t;e++)n[e]=[e,0];r[h.id]=n}for(let e=0;e<t;e++){const t=n[e];t[0]=e,t[1]=p[e]}n.sort(absNumericalSort);for(let e=0;e<8;e++)e<t&&n[e][1]?(s[e][0]=n[e][0],s[e][1]=n[e][1]):(s[e][0]=Number.MAX_SAFE_INTEGER,s[e][1]=0);s.sort(numericalSort);const a=h.morphAttributes.position,o=h.morphAttributes.normal;let l=0;for(let e=0;e<8;e++){const t=s[e],n=t[0],r=t[1];n!==Number.MAX_SAFE_INTEGER&&r?(a&&h.getAttribute("morphTarget"+e)!==a[n]&&h.setAttribute("morphTarget"+e,a[n]),o&&h.getAttribute("morphNormal"+e)!==o[n]&&h.setAttribute("morphNormal"+e,o[n]),i[e]=r,l+=r):(a&&!0===h.hasAttribute("morphTarget"+e)&&h.deleteAttribute("morphTarget"+e),o&&!0===h.hasAttribute("morphNormal"+e)&&h.deleteAttribute("morphNormal"+e),i[e]=0)}const c=h.morphTargetsRelative?1:1-l;d.getUniforms().setValue(e,"morphTargetBaseInfluence",c),d.getUniforms().setValue(e,"morphTargetInfluences",i)}}}}function WebGLObjects(e,t,n,r){let i=new WeakMap;function a(e){const t=e.target;t.removeEventListener("dispose",a),n.remove(t.instanceMatrix),null!==t.instanceColor&&n.remove(t.instanceColor)}return{update:function o(e){const o=r.render.frame,s=t.get(e,e.geometry);return i.get(s)!==o&&(t.update(s),i.set(s,o)),e.isInstancedMesh&&(!1===e.hasEventListener("dispose",a)&&e.addEventListener("dispose",a),n.update(e.instanceMatrix,34962),null!==e.instanceColor&&n.update(e.instanceColor,34962)),s},dispose:function s(){i=new WeakMap}}}DataTexture2DArray.prototype.isDataTexture2DArray=!0;class DataTexture3D extends Texture{constructor(e=null,t=1,n=1,r=1){super(null),this.image={data:e,width:t,height:n,depth:r},this.magFilter=NearestFilter,this.minFilter=NearestFilter,this.wrapR=ClampToEdgeWrapping,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}DataTexture3D.prototype.isDataTexture3D=!0;const emptyTexture=new Texture,emptyTexture2dArray=new DataTexture2DArray,emptyTexture3d=new DataTexture3D,emptyCubeTexture=new CubeTexture,arrayCacheF32=[],arrayCacheI32=[],mat4array=new Float32Array(16),mat3array=new Float32Array(9),mat2array=new Float32Array(4);function flatten(e,t,n){const r=e[0];if(r<=0||r>0)return e;const i=t*n;let a=arrayCacheF32[i];if(void 0===a&&(a=new Float32Array(i),arrayCacheF32[i]=a),0!==t){r.toArray(a,0);for(let r=1,i=0;r!==t;++r)i+=n,e[r].toArray(a,i)}return a}function arraysEqual(e,t){if(e.length!==t.length)return!1;for(let n=0,r=e.length;n<r;n++)if(e[n]!==t[n])return!1;return!0}function copyArray(e,t){for(let n=0,r=t.length;n<r;n++)e[n]=t[n]}function allocTexUnits(e,t){let n=arrayCacheI32[t];void 0===n&&(n=new Int32Array(t),arrayCacheI32[t]=n);for(let r=0;r!==t;++r)n[r]=e.allocateTextureUnit();return n}function setValueV1f(e,t){const n=this.cache;n[0]!==t&&(e.uniform1f(this.addr,t),n[0]=t)}function setValueV2f(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y||(e.uniform2f(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y);else{if(arraysEqual(n,t))return;e.uniform2fv(this.addr,t),copyArray(n,t)}}function setValueV3f(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z||(e.uniform3f(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z);else if(void 0!==t.r)n[0]===t.r&&n[1]===t.g&&n[2]===t.b||(e.uniform3f(this.addr,t.r,t.g,t.b),n[0]=t.r,n[1]=t.g,n[2]=t.b);else{if(arraysEqual(n,t))return;e.uniform3fv(this.addr,t),copyArray(n,t)}}function setValueV4f(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z&&n[3]===t.w||(e.uniform4f(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w);else{if(arraysEqual(n,t))return;e.uniform4fv(this.addr,t),copyArray(n,t)}}function setValueM2(e,t){const n=this.cache,r=t.elements;if(void 0===r){if(arraysEqual(n,t))return;e.uniformMatrix2fv(this.addr,!1,t),copyArray(n,t)}else{if(arraysEqual(n,r))return;mat2array.set(r),e.uniformMatrix2fv(this.addr,!1,mat2array),copyArray(n,r)}}function setValueM3(e,t){const n=this.cache,r=t.elements;if(void 0===r){if(arraysEqual(n,t))return;e.uniformMatrix3fv(this.addr,!1,t),copyArray(n,t)}else{if(arraysEqual(n,r))return;mat3array.set(r),e.uniformMatrix3fv(this.addr,!1,mat3array),copyArray(n,r)}}function setValueM4(e,t){const n=this.cache,r=t.elements;if(void 0===r){if(arraysEqual(n,t))return;e.uniformMatrix4fv(this.addr,!1,t),copyArray(n,t)}else{if(arraysEqual(n,r))return;mat4array.set(r),e.uniformMatrix4fv(this.addr,!1,mat4array),copyArray(n,r)}}function setValueV1i(e,t){const n=this.cache;n[0]!==t&&(e.uniform1i(this.addr,t),n[0]=t)}function setValueV2i(e,t){const n=this.cache;arraysEqual(n,t)||(e.uniform2iv(this.addr,t),copyArray(n,t))}function setValueV3i(e,t){const n=this.cache;arraysEqual(n,t)||(e.uniform3iv(this.addr,t),copyArray(n,t))}function setValueV4i(e,t){const n=this.cache;arraysEqual(n,t)||(e.uniform4iv(this.addr,t),copyArray(n,t))}function setValueV1ui(e,t){const n=this.cache;n[0]!==t&&(e.uniform1ui(this.addr,t),n[0]=t)}function setValueV2ui(e,t){const n=this.cache;arraysEqual(n,t)||(e.uniform2uiv(this.addr,t),copyArray(n,t))}function setValueV3ui(e,t){const n=this.cache;arraysEqual(n,t)||(e.uniform3uiv(this.addr,t),copyArray(n,t))}function setValueV4ui(e,t){const n=this.cache;arraysEqual(n,t)||(e.uniform4uiv(this.addr,t),copyArray(n,t))}function setValueT1(e,t,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(e.uniform1i(this.addr,i),r[0]=i),n.safeSetTexture2D(t||emptyTexture,i)}function setValueT3D1(e,t,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(e.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(t||emptyTexture3d,i)}function setValueT6(e,t,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(e.uniform1i(this.addr,i),r[0]=i),n.safeSetTextureCube(t||emptyCubeTexture,i)}function setValueT2DArray1(e,t,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(e.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(t||emptyTexture2dArray,i)}function getSingularSetter(e){switch(e){case 5126:return setValueV1f;case 35664:return setValueV2f;case 35665:return setValueV3f;case 35666:return setValueV4f;case 35674:return setValueM2;case 35675:return setValueM3;case 35676:return setValueM4;case 5124:case 35670:return setValueV1i;case 35667:case 35671:return setValueV2i;case 35668:case 35672:return setValueV3i;case 35669:case 35673:return setValueV4i;case 5125:return setValueV1ui;case 36294:return setValueV2ui;case 36295:return setValueV3ui;case 36296:return setValueV4ui;case 35678:case 36198:case 36298:case 36306:case 35682:return setValueT1;case 35679:case 36299:case 36307:return setValueT3D1;case 35680:case 36300:case 36308:case 36293:return setValueT6;case 36289:case 36303:case 36311:case 36292:return setValueT2DArray1}}function setValueV1fArray(e,t){e.uniform1fv(this.addr,t)}function setValueV2fArray(e,t){const n=flatten(t,this.size,2);e.uniform2fv(this.addr,n)}function setValueV3fArray(e,t){const n=flatten(t,this.size,3);e.uniform3fv(this.addr,n)}function setValueV4fArray(e,t){const n=flatten(t,this.size,4);e.uniform4fv(this.addr,n)}function setValueM2Array(e,t){const n=flatten(t,this.size,4);e.uniformMatrix2fv(this.addr,!1,n)}function setValueM3Array(e,t){const n=flatten(t,this.size,9);e.uniformMatrix3fv(this.addr,!1,n)}function setValueM4Array(e,t){const n=flatten(t,this.size,16);e.uniformMatrix4fv(this.addr,!1,n)}function setValueV1iArray(e,t){e.uniform1iv(this.addr,t)}function setValueV2iArray(e,t){e.uniform2iv(this.addr,t)}function setValueV3iArray(e,t){e.uniform3iv(this.addr,t)}function setValueV4iArray(e,t){e.uniform4iv(this.addr,t)}function setValueV1uiArray(e,t){e.uniform1uiv(this.addr,t)}function setValueV2uiArray(e,t){e.uniform2uiv(this.addr,t)}function setValueV3uiArray(e,t){e.uniform3uiv(this.addr,t)}function setValueV4uiArray(e,t){e.uniform4uiv(this.addr,t)}function setValueT1Array(e,t,n){const r=t.length,i=allocTexUnits(n,r);e.uniform1iv(this.addr,i);for(let e=0;e!==r;++e)n.safeSetTexture2D(t[e]||emptyTexture,i[e])}function setValueT3DArray(e,t,n){const r=t.length,i=allocTexUnits(n,r);e.uniform1iv(this.addr,i);for(let e=0;e!==r;++e)n.setTexture3D(t[e]||emptyTexture3d,i[e])}function setValueT6Array(e,t,n){const r=t.length,i=allocTexUnits(n,r);e.uniform1iv(this.addr,i);for(let e=0;e!==r;++e)n.safeSetTextureCube(t[e]||emptyCubeTexture,i[e])}function setValueT2DArrayArray(e,t,n){const r=t.length,i=allocTexUnits(n,r);e.uniform1iv(this.addr,i);for(let e=0;e!==r;++e)n.setTexture2DArray(t[e]||emptyTexture2dArray,i[e])}function getPureArraySetter(e){switch(e){case 5126:return setValueV1fArray;case 35664:return setValueV2fArray;case 35665:return setValueV3fArray;case 35666:return setValueV4fArray;case 35674:return setValueM2Array;case 35675:return setValueM3Array;case 35676:return setValueM4Array;case 5124:case 35670:return setValueV1iArray;case 35667:case 35671:return setValueV2iArray;case 35668:case 35672:return setValueV3iArray;case 35669:case 35673:return setValueV4iArray;case 5125:return setValueV1uiArray;case 36294:return setValueV2uiArray;case 36295:return setValueV3uiArray;case 36296:return setValueV4uiArray;case 35678:case 36198:case 36298:case 36306:case 35682:return setValueT1Array;case 35679:case 36299:case 36307:return setValueT3DArray;case 35680:case 36300:case 36308:case 36293:return setValueT6Array;case 36289:case 36303:case 36311:case 36292:return setValueT2DArrayArray}}function SingleUniform(e,t,n){this.id=e,this.addr=n,this.cache=[],this.setValue=getSingularSetter(t.type)}function PureArrayUniform(e,t,n){this.id=e,this.addr=n,this.cache=[],this.size=t.size,this.setValue=getPureArraySetter(t.type)}function StructuredUniform(e){this.id=e,this.seq=[],this.map={}}PureArrayUniform.prototype.updateCache=function(e){const t=this.cache;e instanceof Float32Array&&t.length!==e.length&&(this.cache=new Float32Array(e.length)),copyArray(t,e)},StructuredUniform.prototype.setValue=function(e,t,n){const r=this.seq;for(let i=0,a=r.length;i!==a;++i){const a=r[i];a.setValue(e,t[a.id],n)}};const RePathPart=/(\w+)(\])?(\[|\.)?/g;function addUniform(e,t){e.seq.push(t),e.map[t.id]=t}function parseUniform(e,t,n){const r=e.name,i=r.length;for(RePathPart.lastIndex=0;;){const a=RePathPart.exec(r),o=RePathPart.lastIndex;let s=a[1];const l=a[3];if("]"===a[2]&&(s|=0),void 0===l||"["===l&&o+2===i){addUniform(n,void 0===l?new SingleUniform(s,e,t):new PureArrayUniform(s,e,t));break}{let e=n.map[s];void 0===e&&(e=new StructuredUniform(s),addUniform(n,e)),n=e}}}function WebGLUniforms(e,t){this.seq=[],this.map={};const n=e.getProgramParameter(t,35718);for(let r=0;r<n;++r){const n=e.getActiveUniform(t,r);parseUniform(n,e.getUniformLocation(t,n.name),this)}}function WebGLShader(e,t,n){const r=e.createShader(t);return e.shaderSource(r,n),e.compileShader(r),r}WebGLUniforms.prototype.setValue=function(e,t,n,r){const i=this.map[t];void 0!==i&&i.setValue(e,n,r)},WebGLUniforms.prototype.setOptional=function(e,t,n){const r=t[n];void 0!==r&&this.setValue(e,n,r)},WebGLUniforms.upload=function(e,t,n,r){for(let i=0,a=t.length;i!==a;++i){const a=t[i],o=n[a.id];!1!==o.needsUpdate&&a.setValue(e,o.value,r)}},WebGLUniforms.seqWithValue=function(e,t){const n=[];for(let r=0,i=e.length;r!==i;++r){const i=e[r];i.id in t&&n.push(i)}return n};let programIdCount=0;function addLineNumbers(e){const t=e.split("\n");for(let e=0;e<t.length;e++)t[e]=e+1+": "+t[e];return t.join("\n")}function getEncodingComponents(e){switch(e){case LinearEncoding:return["Linear","( value )"];case sRGBEncoding:return["sRGB","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported encoding:",e),["Linear","( value )"]}}function getShaderErrors(e,t,n){const r=e.getShaderParameter(t,35713),i=e.getShaderInfoLog(t).trim();return r&&""===i?"":n.toUpperCase()+"\n\n"+i+"\n\n"+addLineNumbers(e.getShaderSource(t))}function getTexelEncodingFunction(e,t){const n=getEncodingComponents(t);return"vec4 "+e+"( vec4 value ) { return LinearTo"+n[0]+n[1]+"; }"}function getToneMappingFunction(e,t){let n;switch(t){case LinearToneMapping:n="Linear";break;case ReinhardToneMapping:n="Reinhard";break;case CineonToneMapping:n="OptimizedCineon";break;case ACESFilmicToneMapping:n="ACESFilmic";break;case CustomToneMapping:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),n="Linear"}return"vec3 "+e+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}function generateExtensions(e){return[e.extensionDerivatives||e.envMapCubeUV||e.bumpMap||e.tangentSpaceNormalMap||e.clearcoatNormalMap||e.flatShading||"physical"===e.shaderID?"#extension GL_OES_standard_derivatives : enable":"",(e.extensionFragDepth||e.logarithmicDepthBuffer)&&e.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",e.extensionDrawBuffers&&e.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(e.extensionShaderTextureLOD||e.envMap||e.transmission)&&e.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(filterEmptyLine).join("\n")}function generateDefines(e){const t=[];for(const n in e){const r=e[n];!1!==r&&t.push("#define "+n+" "+r)}return t.join("\n")}function fetchAttributeLocations(e,t){const n={},r=e.getProgramParameter(t,35721);for(let i=0;i<r;i++){const r=e.getActiveAttrib(t,i),a=r.name;let o=1;35674===r.type&&(o=2),35675===r.type&&(o=3),35676===r.type&&(o=4),n[a]={type:r.type,location:e.getAttribLocation(t,a),locationSize:o}}return n}function filterEmptyLine(e){return""!==e}function replaceLightNums(e,t){return e.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function replaceClippingPlaneNums(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}const includePattern=/^[ \t]*#include +<([\w\d./]+)>/gm;function resolveIncludes(e){return e.replace(includePattern,includeReplacer)}function includeReplacer(e,t){const n=ShaderChunk[t];if(void 0===n)throw new Error("Can not resolve #include <"+t+">");return resolveIncludes(n)}const deprecatedUnrollLoopPattern=/#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,unrollLoopPattern=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function unrollLoops(e){return e.replace(unrollLoopPattern,loopReplacer).replace(deprecatedUnrollLoopPattern,deprecatedLoopReplacer)}function deprecatedLoopReplacer(e,t,n,r){return console.warn("WebGLProgram: #pragma unroll_loop shader syntax is deprecated. Please use #pragma unroll_loop_start syntax instead."),loopReplacer(e,t,n,r)}function loopReplacer(e,t,n,r){let i="";for(let e=parseInt(t);e<parseInt(n);e++)i+=r.replace(/\[\s*i\s*\]/g,"[ "+e+" ]").replace(/UNROLLED_LOOP_INDEX/g,e);return i}function generatePrecision(e){let t="precision "+e.precision+" float;\nprecision "+e.precision+" int;";return"highp"===e.precision?t+="\n#define HIGH_PRECISION":"mediump"===e.precision?t+="\n#define MEDIUM_PRECISION":"lowp"===e.precision&&(t+="\n#define LOW_PRECISION"),t}function generateShadowMapTypeDefine(e){let t="SHADOWMAP_TYPE_BASIC";return e.shadowMapType===PCFShadowMap?t="SHADOWMAP_TYPE_PCF":e.shadowMapType===PCFSoftShadowMap?t="SHADOWMAP_TYPE_PCF_SOFT":e.shadowMapType===VSMShadowMap&&(t="SHADOWMAP_TYPE_VSM"),t}function generateEnvMapTypeDefine(e){let t="ENVMAP_TYPE_CUBE";if(e.envMap)switch(e.envMapMode){case CubeReflectionMapping:case CubeRefractionMapping:t="ENVMAP_TYPE_CUBE";break;case CubeUVReflectionMapping:case CubeUVRefractionMapping:t="ENVMAP_TYPE_CUBE_UV"}return t}function generateEnvMapModeDefine(e){let t="ENVMAP_MODE_REFLECTION";if(e.envMap)switch(e.envMapMode){case CubeRefractionMapping:case CubeUVRefractionMapping:t="ENVMAP_MODE_REFRACTION"}return t}function generateEnvMapBlendingDefine(e){let t="ENVMAP_BLENDING_NONE";if(e.envMap)switch(e.combine){case MultiplyOperation:t="ENVMAP_BLENDING_MULTIPLY";break;case MixOperation:t="ENVMAP_BLENDING_MIX";break;case AddOperation:t="ENVMAP_BLENDING_ADD"}return t}function WebGLProgram(e,t,n,r){const i=e.getContext(),a=n.defines;let o=n.vertexShader,s=n.fragmentShader;const l=generateShadowMapTypeDefine(n),c=generateEnvMapTypeDefine(n),h=generateEnvMapModeDefine(n),u=generateEnvMapBlendingDefine(n),d=n.isWebGL2?"":generateExtensions(n),p=generateDefines(a),m=i.createProgram();let f,g,v=n.glslVersion?"#version "+n.glslVersion+"\n":"";n.isRawShaderMaterial?(f=[p].filter(filterEmptyLine).join("\n"),f.length>0&&(f+="\n"),g=[d,p].filter(filterEmptyLine).join("\n"),g.length>0&&(g+="\n")):(f=[generatePrecision(n),"#define SHADER_NAME "+n.shaderName,p,n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define MAX_BONES "+n.maxBones,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+h:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMap&&n.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",n.normalMap&&n.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.displacementMap&&n.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",n.specularColorMap?"#define USE_SPECULARCOLORMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEENCOLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEENROUGHNESSMAP":"",n.vertexTangents?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUvs?"#define USE_UV":"",n.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.useVertexTexture?"#define BONE_TEXTURE":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&!1===n.flatShading?"#define USE_MORPHNORMALS":"",n.morphTargets&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",n.morphTargets&&n.isWebGL2?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(filterEmptyLine).join("\n"),g=[d,generatePrecision(n),"#define SHADER_NAME "+n.shaderName,p,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+c:"",n.envMap?"#define "+h:"",n.envMap?"#define "+u:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMap&&n.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",n.normalMap&&n.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",n.specularColorMap?"#define USE_SPECULARCOLORMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEENCOLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEENROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.vertexTangents?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUvs?"#define USE_UV":"",n.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"",(n.extensionShaderTextureLOD||n.envMap)&&n.rendererExtensionShaderTextureLod?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==NoToneMapping?"#define TONE_MAPPING":"",n.toneMapping!==NoToneMapping?ShaderChunk.tonemapping_pars_fragment:"",n.toneMapping!==NoToneMapping?getToneMappingFunction("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.alphaWrite?"":"#define OPAQUE",ShaderChunk.encodings_pars_fragment,getTexelEncodingFunction("linearToOutputTexel",n.outputEncoding),n.depthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(filterEmptyLine).join("\n")),o=resolveIncludes(o),o=replaceLightNums(o,n),o=replaceClippingPlaneNums(o,n),s=resolveIncludes(s),s=replaceLightNums(s,n),s=replaceClippingPlaneNums(s,n),o=unrollLoops(o),s=unrollLoops(s),n.isWebGL2&&!0!==n.isRawShaderMaterial&&(v="#version 300 es\n",f=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+f,g=["#define varying in",n.glslVersion===GLSL3?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===GLSL3?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join("\n")+"\n"+g);const y=v+g+s,_=WebGLShader(i,35633,v+f+o),b=WebGLShader(i,35632,y);if(i.attachShader(m,_),i.attachShader(m,b),void 0!==n.index0AttributeName?i.bindAttribLocation(m,0,n.index0AttributeName):!0===n.morphTargets&&i.bindAttribLocation(m,0,"position"),i.linkProgram(m),e.debug.checkShaderErrors){const e=i.getProgramInfoLog(m).trim(),t=i.getShaderInfoLog(_).trim(),n=i.getShaderInfoLog(b).trim();let r=!0,a=!0;if(!1===i.getProgramParameter(m,35714)){r=!1;const t=getShaderErrors(i,_,"vertex"),n=getShaderErrors(i,b,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(m,35715)+"\n\nProgram Info Log: "+e+"\n"+t+"\n"+n)}else""!==e?console.warn("THREE.WebGLProgram: Program Info Log:",e):""!==t&&""!==n||(a=!1);a&&(this.diagnostics={runnable:r,programLog:e,vertexShader:{log:t,prefix:f},fragmentShader:{log:n,prefix:g}})}let x,S;return i.deleteShader(_),i.deleteShader(b),this.getUniforms=function(){return void 0===x&&(x=new WebGLUniforms(i,m)),x},this.getAttributes=function(){return void 0===S&&(S=fetchAttributeLocations(i,m)),S},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(m),this.program=void 0},this.name=n.shaderName,this.id=programIdCount++,this.cacheKey=t,this.usedTimes=1,this.program=m,this.vertexShader=_,this.fragmentShader=b,this}let _id=0;class WebGLShaderCache{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.fragmentShader,n=this._getShaderStage(e.vertexShader),r=this._getShaderStage(t),i=this._getShaderCacheForMaterial(e);return!1===i.has(n)&&(i.add(n),n.usedTimes++),!1===i.has(r)&&(i.add(r),r.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const e of t)e.usedTimes--,0===e.usedTimes&&this.shaderCache.delete(e);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;return!1===t.has(e)&&t.set(e,new Set),t.get(e)}_getShaderStage(e){const t=this.shaderCache;if(!1===t.has(e)){const n=new WebGLShaderStage;t.set(e,n)}return t.get(e)}}class WebGLShaderStage{constructor(){this.id=_id++,this.usedTimes=0}}function WebGLPrograms(e,t,n,r,i,a,o){const s=new Layers,l=new WebGLShaderCache,c=[],h=i.isWebGL2,u=i.logarithmicDepthBuffer,d=i.floatVertexTextures,p=i.maxVertexUniforms,m=i.vertexTextures;let f=i.precision;const g={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};return{getParameters:function v(a,s,c,y,_){const b=y.fog,x=(a.isMeshStandardMaterial?n:t).get(a.envMap||(a.isMeshStandardMaterial?y.environment:null)),S=g[a.type],w=_.isSkinnedMesh?(function C(e){const t=e.skeleton.bones;if(d)return 1024;{const e=Math.floor((p-20)/4),n=Math.min(e,t.length);return n<t.length?(console.warn("THREE.WebGLRenderer: Skeleton has "+t.length+" bones. This GPU supports "+n+"."),0):n}})(_):0;let M,E,T,I;if(null!==a.precision&&(f=i.getMaxPrecision(a.precision),f!==a.precision&&console.warn("THREE.WebGLProgram.getParameters:",a.precision,"not supported, using",f,"instead.")),S){const e=ShaderLib[S];M=e.vertexShader,E=e.fragmentShader}else M=a.vertexShader,E=a.fragmentShader,l.update(a),T=l.getVertexShaderID(a),I=l.getFragmentShaderID(a);const A=e.getRenderTarget(),k=a.clearcoat>0;return{isWebGL2:h,shaderID:S,shaderName:a.type,vertexShader:M,fragmentShader:E,defines:a.defines,customVertexShaderID:T,customFragmentShaderID:I,isRawShaderMaterial:!0===a.isRawShaderMaterial,glslVersion:a.glslVersion,precision:f,instancing:!0===_.isInstancedMesh,instancingColor:!0===_.isInstancedMesh&&null!==_.instanceColor,supportsVertexTextures:m,outputEncoding:null===A?e.outputEncoding:!0===A.isXRRenderTarget?A.texture.encoding:LinearEncoding,map:!!a.map,matcap:!!a.matcap,envMap:!!x,envMapMode:x&&x.mapping,envMapCubeUV:!!x&&(x.mapping===CubeUVReflectionMapping||x.mapping===CubeUVRefractionMapping),lightMap:!!a.lightMap,aoMap:!!a.aoMap,emissiveMap:!!a.emissiveMap,bumpMap:!!a.bumpMap,normalMap:!!a.normalMap,objectSpaceNormalMap:a.normalMapType===ObjectSpaceNormalMap,tangentSpaceNormalMap:a.normalMapType===TangentSpaceNormalMap,decodeVideoTexture:!!a.map&&!0===a.map.isVideoTexture&&a.map.encoding===sRGBEncoding,clearcoat:k,clearcoatMap:k&&!!a.clearcoatMap,clearcoatRoughnessMap:k&&!!a.clearcoatRoughnessMap,clearcoatNormalMap:k&&!!a.clearcoatNormalMap,displacementMap:!!a.displacementMap,roughnessMap:!!a.roughnessMap,metalnessMap:!!a.metalnessMap,specularMap:!!a.specularMap,specularIntensityMap:!!a.specularIntensityMap,specularColorMap:!!a.specularColorMap,alphaMap:!!a.alphaMap,alphaTest:a.alphaTest>0,alphaWrite:a.alphaWrite||a.transparent,gradientMap:!!a.gradientMap,sheen:a.sheen>0,sheenColorMap:!!a.sheenColorMap,sheenRoughnessMap:!!a.sheenRoughnessMap,transmission:a.transmission>0,transmissionMap:!!a.transmissionMap,thicknessMap:!!a.thicknessMap,combine:a.combine,vertexTangents:!!a.normalMap&&!!_.geometry&&!!_.geometry.attributes.tangent,vertexColors:a.vertexColors,vertexAlphas:!0===a.vertexColors&&!!_.geometry&&!!_.geometry.attributes.color&&4===_.geometry.attributes.color.itemSize,vertexUvs:!!(a.map||a.bumpMap||a.normalMap||a.specularMap||a.alphaMap||a.emissiveMap||a.roughnessMap||a.metalnessMap||a.clearcoatMap||a.clearcoatRoughnessMap||a.clearcoatNormalMap||a.displacementMap||a.transmissionMap||a.thicknessMap||a.specularIntensityMap||a.specularColorMap||a.sheenColorMap||a.sheenRoughnessMap),uvsVertexOnly:!(a.map||a.bumpMap||a.normalMap||a.specularMap||a.alphaMap||a.emissiveMap||a.roughnessMap||a.metalnessMap||a.clearcoatNormalMap||a.transmission>0||a.transmissionMap||a.thicknessMap||a.specularIntensityMap||a.specularColorMap||a.sheen>0||a.sheenColorMap||a.sheenRoughnessMap||!a.displacementMap),fog:!!b,useFog:a.fog,fogExp2:b&&b.isFogExp2,flatShading:!!a.flatShading,sizeAttenuation:a.sizeAttenuation,logarithmicDepthBuffer:u,skinning:!0===_.isSkinnedMesh&&w>0,maxBones:w,useVertexTexture:d,morphTargets:!!_.geometry&&!!_.geometry.morphAttributes.position,morphNormals:!!_.geometry&&!!_.geometry.morphAttributes.normal,morphTargetsCount:_.geometry&&_.geometry.morphAttributes.position?_.geometry.morphAttributes.position.length:0,numDirLights:s.directional.length,numPointLights:s.point.length,numSpotLights:s.spot.length,numRectAreaLights:s.rectArea.length,numHemiLights:s.hemi.length,numDirLightShadows:s.directionalShadowMap.length,numPointLightShadows:s.pointShadowMap.length,numSpotLightShadows:s.spotShadowMap.length,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:a.dithering,shadowMapEnabled:e.shadowMap.enabled&&c.length>0,shadowMapType:e.shadowMap.type,toneMapping:a.toneMapped?e.toneMapping:NoToneMapping,physicallyCorrectLights:e.physicallyCorrectLights,premultipliedAlpha:a.premultipliedAlpha,doubleSided:a.side===DoubleSide,flipSided:a.side===BackSide,depthPacking:void 0!==a.depthPacking&&a.depthPacking,index0AttributeName:a.index0AttributeName,extensionDerivatives:a.extensions&&a.extensions.derivatives,extensionFragDepth:a.extensions&&a.extensions.fragDepth,extensionDrawBuffers:a.extensions&&a.extensions.drawBuffers,extensionShaderTextureLOD:a.extensions&&a.extensions.shaderTextureLOD,rendererExtensionFragDepth:h||r.has("EXT_frag_depth"),rendererExtensionDrawBuffers:h||r.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:h||r.has("EXT_shader_texture_lod"),customProgramCacheKey:a.customProgramCacheKey()}},getProgramCacheKey:function y(t){const n=[];if(t.shaderID?n.push(t.shaderID):(n.push(t.customVertexShaderID),n.push(t.customFragmentShaderID)),void 0!==t.defines)for(const e in t.defines)n.push(e),n.push(t.defines[e]);return!1===t.isRawShaderMaterial&&(!(function r(e,t){e.push(t.precision),e.push(t.outputEncoding),e.push(t.envMapMode),e.push(t.combine),e.push(t.vertexUvs),e.push(t.fogExp2),e.push(t.sizeAttenuation),e.push(t.maxBones),e.push(t.morphTargetsCount),e.push(t.numDirLights),e.push(t.numPointLights),e.push(t.numSpotLights),e.push(t.numHemiLights),e.push(t.numRectAreaLights),e.push(t.numDirLightShadows),e.push(t.numPointLightShadows),e.push(t.numSpotLightShadows),e.push(t.shadowMapType),e.push(t.toneMapping),e.push(t.numClippingPlanes),e.push(t.numClipIntersection),e.push(t.alphaWrite)})(n,t),(function i(e,t){s.disableAll(),t.isWebGL2&&s.enable(0);t.supportsVertexTextures&&s.enable(1);t.instancing&&s.enable(2);t.instancingColor&&s.enable(3);t.map&&s.enable(4);t.matcap&&s.enable(5);t.envMap&&s.enable(6);t.envMapCubeUV&&s.enable(7);t.lightMap&&s.enable(8);t.aoMap&&s.enable(9);t.emissiveMap&&s.enable(10);t.bumpMap&&s.enable(11);t.normalMap&&s.enable(12);t.objectSpaceNormalMap&&s.enable(13);t.tangentSpaceNormalMap&&s.enable(14);t.clearcoat&&s.enable(15);t.clearcoatMap&&s.enable(16);t.clearcoatRoughnessMap&&s.enable(17);t.clearcoatNormalMap&&s.enable(18);t.displacementMap&&s.enable(19);t.specularMap&&s.enable(20);t.roughnessMap&&s.enable(21);t.metalnessMap&&s.enable(22);t.gradientMap&&s.enable(23);t.alphaMap&&s.enable(24);t.alphaTest&&s.enable(25);t.vertexColors&&s.enable(26);t.vertexAlphas&&s.enable(27);t.vertexUvs&&s.enable(28);t.vertexTangents&&s.enable(29);t.uvsVertexOnly&&s.enable(30);t.fog&&s.enable(31);e.push(s.mask),s.disableAll(),t.useFog&&s.enable(0);t.flatShading&&s.enable(1);t.logarithmicDepthBuffer&&s.enable(2);t.skinning&&s.enable(3);t.useVertexTexture&&s.enable(4);t.morphTargets&&s.enable(5);t.morphNormals&&s.enable(6);t.premultipliedAlpha&&s.enable(7);t.shadowMapEnabled&&s.enable(8);t.physicallyCorrectLights&&s.enable(9);t.doubleSided&&s.enable(10);t.flipSided&&s.enable(11);t.depthPacking&&s.enable(12);t.dithering&&s.enable(13);t.specularIntensityMap&&s.enable(14);t.specularColorMap&&s.enable(15);t.transmission&&s.enable(16);t.transmissionMap&&s.enable(17);t.thicknessMap&&s.enable(18);t.sheen&&s.enable(19);t.sheenColorMap&&s.enable(20);t.sheenRoughnessMap&&s.enable(21);t.decodeVideoTexture&&s.enable(22);e.push(s.mask)})(n,t),n.push(e.outputEncoding)),n.push(t.customProgramCacheKey),n.join()},getUniforms:function _(e){const t=g[e.type];let n;if(t){n=UniformsUtils.clone(ShaderLib[t].uniforms)}else n=e.uniforms;return n},acquireProgram:function b(t,n){let r;for(let e=0,t=c.length;e<t;e++){const t=c[e];if(t.cacheKey===n){r=t,++r.usedTimes;break}}return void 0===r&&(r=new WebGLProgram(e,n,t,a),c.push(r)),r},releaseProgram:function x(e){if(0==--e.usedTimes){const t=c.indexOf(e);c[t]=c[c.length-1],c.pop(),e.destroy()}},releaseShaderCache:function S(e){l.remove(e)},programs:c,dispose:function w(){l.dispose()}}}function WebGLProperties(){let e=new WeakMap;return{get:function t(n){let r=e.get(n);return void 0===r&&(r={},e.set(n,r)),r},remove:function n(t){e.delete(t)},update:function r(t,n,i){e.get(t)[n]=i},dispose:function i(){e=new WeakMap}}}function painterSortStable(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.material.id!==t.material.id?e.material.id-t.material.id:e.z!==t.z?e.z-t.z:e.id-t.id}function reversePainterSortStable(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:e.id-t.id}function WebGLRenderList(){const e=[];let t=0;const n=[],r=[],i=[];function a(n,r,i,a,o,s){let l=e[t];return void 0===l?(l={id:n.id,object:n,geometry:r,material:i,groupOrder:a,renderOrder:n.renderOrder,z:o,group:s},e[t]=l):(l.id=n.id,l.object=n,l.geometry=r,l.material=i,l.groupOrder=a,l.renderOrder=n.renderOrder,l.z=o,l.group=s),t++,l}return{opaque:n,transmissive:r,transparent:i,init:function o(){t=0,n.length=0,r.length=0,i.length=0},push:function s(e,t,o,l,c,h){const u=a(e,t,o,l,c,h);o.transmission>0?r.push(u):!0===o.transparent?i.push(u):n.push(u)},unshift:function l(e,t,o,s,c,h){const u=a(e,t,o,s,c,h);o.transmission>0?r.unshift(u):!0===o.transparent?i.unshift(u):n.unshift(u)},finish:function c(){for(let n=t,r=e.length;n<r;n++){const t=e[n];if(null===t.id)break;t.id=null,t.object=null,t.geometry=null,t.material=null,t.group=null}},sort:function h(e,t){n.length>1&&n.sort(e||painterSortStable),r.length>1&&r.sort(t||reversePainterSortStable),i.length>1&&i.sort(t||reversePainterSortStable)}}}function WebGLRenderLists(){let e=new WeakMap;return{get:function t(n,r){let i;return!1===e.has(n)?(i=new WebGLRenderList,e.set(n,[i])):r>=e.get(n).length?(i=new WebGLRenderList,e.get(n).push(i)):i=e.get(n)[r],i},dispose:function n(){e=new WeakMap}}}function UniformsCache(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let n;switch(t.type){case"DirectionalLight":n={direction:new Vector3,color:new Color$1};break;case"SpotLight":n={position:new Vector3,direction:new Vector3,color:new Color$1,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new Vector3,color:new Color$1,distance:0,decay:0};break;case"HemisphereLight":n={direction:new Vector3,skyColor:new Color$1,groundColor:new Color$1};break;case"RectAreaLight":n={color:new Color$1,position:new Vector3,halfWidth:new Vector3,halfHeight:new Vector3}}return e[t.id]=n,n}}}function ShadowUniformsCache(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let n;switch(t.type){case"DirectionalLight":case"SpotLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Vector2};break;case"PointLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Vector2,shadowCameraNear:1,shadowCameraFar:1e3}}return e[t.id]=n,n}}}let nextVersion=0;function shadowCastingLightsFirst(e,t){return(t.castShadow?1:0)-(e.castShadow?1:0)}function WebGLLights(e,t){const n=new UniformsCache,r=ShadowUniformsCache(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadow:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[]};for(let e=0;e<9;e++)i.probe.push(new Vector3);const a=new Vector3,o=new Matrix4,s=new Matrix4;return{setup:function l(a,o){let s=0,l=0,c=0;for(let e=0;e<9;e++)i.probe[e].set(0,0,0);let h=0,u=0,d=0,p=0,m=0,f=0,g=0,v=0;a.sort(shadowCastingLightsFirst);const y=!0!==o?Math.PI:1;for(let e=0,t=a.length;e<t;e++){const t=a[e],o=t.color,_=t.intensity,b=t.distance,x=t.shadow&&t.shadow.map?t.shadow.map.texture:null;if(t.isAmbientLight)s+=o.r*_*y,l+=o.g*_*y,c+=o.b*_*y;else if(t.isLightProbe)for(let e=0;e<9;e++)i.probe[e].addScaledVector(t.sh.coefficients[e],_);else if(t.isDirectionalLight){const e=n.get(t);if(e.color.copy(t.color).multiplyScalar(t.intensity*y),t.castShadow){const e=t.shadow,n=r.get(t);n.shadowBias=e.bias,n.shadowNormalBias=e.normalBias,n.shadowRadius=e.radius,n.shadowMapSize=e.mapSize,i.directionalShadow[h]=n,i.directionalShadowMap[h]=x,i.directionalShadowMatrix[h]=t.shadow.matrix,f++}i.directional[h]=e,h++}else if(t.isSpotLight){const e=n.get(t);if(e.position.setFromMatrixPosition(t.matrixWorld),e.color.copy(o).multiplyScalar(_*y),e.distance=b,e.coneCos=Math.cos(t.angle),e.penumbraCos=Math.cos(t.angle*(1-t.penumbra)),e.decay=t.decay,t.castShadow){const e=t.shadow,n=r.get(t);n.shadowBias=e.bias,n.shadowNormalBias=e.normalBias,n.shadowRadius=e.radius,n.shadowMapSize=e.mapSize,i.spotShadow[d]=n,i.spotShadowMap[d]=x,i.spotShadowMatrix[d]=t.shadow.matrix,v++}i.spot[d]=e,d++}else if(t.isRectAreaLight){const e=n.get(t);e.color.copy(o).multiplyScalar(_),e.halfWidth.set(.5*t.width,0,0),e.halfHeight.set(0,.5*t.height,0),i.rectArea[p]=e,p++}else if(t.isPointLight){const e=n.get(t);if(e.color.copy(t.color).multiplyScalar(t.intensity*y),e.distance=t.distance,e.decay=t.decay,t.castShadow){const e=t.shadow,n=r.get(t);n.shadowBias=e.bias,n.shadowNormalBias=e.normalBias,n.shadowRadius=e.radius,n.shadowMapSize=e.mapSize,n.shadowCameraNear=e.camera.near,n.shadowCameraFar=e.camera.far,i.pointShadow[u]=n,i.pointShadowMap[u]=x,i.pointShadowMatrix[u]=t.shadow.matrix,g++}i.point[u]=e,u++}else if(t.isHemisphereLight){const e=n.get(t);e.skyColor.copy(t.color).multiplyScalar(_*y),e.groundColor.copy(t.groundColor).multiplyScalar(_*y),i.hemi[m]=e,m++}}p>0&&(t.isWebGL2||!0===e.has("OES_texture_float_linear")?(i.rectAreaLTC1=UniformsLib.LTC_FLOAT_1,i.rectAreaLTC2=UniformsLib.LTC_FLOAT_2):!0===e.has("OES_texture_half_float_linear")?(i.rectAreaLTC1=UniformsLib.LTC_HALF_1,i.rectAreaLTC2=UniformsLib.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),i.ambient[0]=s,i.ambient[1]=l,i.ambient[2]=c;const _=i.hash;_.directionalLength===h&&_.pointLength===u&&_.spotLength===d&&_.rectAreaLength===p&&_.hemiLength===m&&_.numDirectionalShadows===f&&_.numPointShadows===g&&_.numSpotShadows===v||(i.directional.length=h,i.spot.length=d,i.rectArea.length=p,i.point.length=u,i.hemi.length=m,i.directionalShadow.length=f,i.directionalShadowMap.length=f,i.pointShadow.length=g,i.pointShadowMap.length=g,i.spotShadow.length=v,i.spotShadowMap.length=v,i.directionalShadowMatrix.length=f,i.pointShadowMatrix.length=g,i.spotShadowMatrix.length=v,_.directionalLength=h,_.pointLength=u,_.spotLength=d,_.rectAreaLength=p,_.hemiLength=m,_.numDirectionalShadows=f,_.numPointShadows=g,_.numSpotShadows=v,i.version=nextVersion++)},setupView:function c(e,t){let n=0,r=0,l=0,c=0,h=0;const u=t.matrixWorldInverse;for(let t=0,d=e.length;t<d;t++){const d=e[t];if(d.isDirectionalLight){const e=i.directional[n];e.direction.setFromMatrixPosition(d.matrixWorld),a.setFromMatrixPosition(d.target.matrixWorld),e.direction.sub(a),e.direction.transformDirection(u),n++}else if(d.isSpotLight){const e=i.spot[l];e.position.setFromMatrixPosition(d.matrixWorld),e.position.applyMatrix4(u),e.direction.setFromMatrixPosition(d.matrixWorld),a.setFromMatrixPosition(d.target.matrixWorld),e.direction.sub(a),e.direction.transformDirection(u),l++}else if(d.isRectAreaLight){const e=i.rectArea[c];e.position.setFromMatrixPosition(d.matrixWorld),e.position.applyMatrix4(u),s.identity(),o.copy(d.matrixWorld),o.premultiply(u),s.extractRotation(o),e.halfWidth.set(.5*d.width,0,0),e.halfHeight.set(0,.5*d.height,0),e.halfWidth.applyMatrix4(s),e.halfHeight.applyMatrix4(s),c++}else if(d.isPointLight){const e=i.point[r];e.position.setFromMatrixPosition(d.matrixWorld),e.position.applyMatrix4(u),r++}else if(d.isHemisphereLight){const e=i.hemi[h];e.direction.setFromMatrixPosition(d.matrixWorld),e.direction.transformDirection(u),e.direction.normalize(),h++}}},state:i}}function WebGLRenderState(e,t){const n=new WebGLLights(e,t),r=[],i=[];return{init:function a(){r.length=0,i.length=0},state:{lightsArray:r,shadowsArray:i,lights:n},setupLights:function o(e){n.setup(r,e)},setupLightsView:function s(e){n.setupView(r,e)},pushLight:function l(e){r.push(e)},pushShadow:function c(e){i.push(e)}}}function WebGLRenderStates(e,t){let n=new WeakMap;return{get:function r(i,a=0){let o;return!1===n.has(i)?(o=new WebGLRenderState(e,t),n.set(i,[o])):a>=n.get(i).length?(o=new WebGLRenderState(e,t),n.get(i).push(o)):o=n.get(i)[a],o},dispose:function i(){n=new WeakMap}}}class MeshDepthMaterial extends Material{constructor(e){super(),this.type="MeshDepthMaterial",this.depthPacking=BasicDepthPacking,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}MeshDepthMaterial.prototype.isMeshDepthMaterial=!0;class MeshDistanceMaterial extends Material{constructor(e){super(),this.type="MeshDistanceMaterial",this.referencePosition=new Vector3,this.nearDistance=1,this.farDistance=1e3,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.fog=!1,this.setValues(e)}copy(e){return super.copy(e),this.referencePosition.copy(e.referencePosition),this.nearDistance=e.nearDistance,this.farDistance=e.farDistance,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}MeshDistanceMaterial.prototype.isMeshDistanceMaterial=!0;const vertex="void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",fragment="uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include <packing>\nvoid main() {\n\tconst float samples = float( VSM_SAMPLES );\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}";function WebGLShadowMap(e,t,n){let r=new Frustum;const i=new Vector2,a=new Vector2,o=new Vector4,s=new MeshDepthMaterial({depthPacking:RGBADepthPacking}),l=new MeshDistanceMaterial,c={},h=n.maxTextureSize,u={0:BackSide,1:FrontSide,2:DoubleSide},d=new ShaderMaterial({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Vector2},radius:{value:4}},vertexShader:vertex,fragmentShader:fragment}),p=d.clone();p.defines.HORIZONTAL_PASS=1;const m=new BufferGeometry;m.setAttribute("position",new BufferAttribute(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const f=new Mesh(m,d),g=this;function v(n,r){const i=t.update(f);d.defines.VSM_SAMPLES!==n.blurSamples&&(d.defines.VSM_SAMPLES=n.blurSamples,p.defines.VSM_SAMPLES=n.blurSamples,d.needsUpdate=!0,p.needsUpdate=!0),d.uniforms.shadow_pass.value=n.map.texture,d.uniforms.resolution.value=n.mapSize,d.uniforms.radius.value=n.radius,e.setRenderTarget(n.mapPass),e.clear(),e.renderBufferDirect(r,null,i,d,f,null),p.uniforms.shadow_pass.value=n.mapPass.texture,p.uniforms.resolution.value=n.mapSize,p.uniforms.radius.value=n.radius,e.setRenderTarget(n.map),e.clear(),e.renderBufferDirect(r,null,i,p,f,null)}function y(t,n,r,i,a,o,h){let d=null;const p=!0===i.isPointLight?t.customDistanceMaterial:t.customDepthMaterial;if(d=void 0!==p?p:!0===i.isPointLight?l:s,e.localClippingEnabled&&!0===r.clipShadows&&0!==r.clippingPlanes.length||r.displacementMap&&0!==r.displacementScale||r.alphaMap&&r.alphaTest>0){const e=d.uuid,t=r.uuid;let n=c[e];void 0===n&&(n={},c[e]=n);let i=n[t];void 0===i&&(i=d.clone(),n[t]=i),d=i}return d.visible=r.visible,d.wireframe=r.wireframe,d.side=h===VSMShadowMap?null!==r.shadowSide?r.shadowSide:r.side:null!==r.shadowSide?r.shadowSide:u[r.side],d.alphaMap=r.alphaMap,d.alphaTest=r.alphaTest,d.clipShadows=r.clipShadows,d.clippingPlanes=r.clippingPlanes,d.clipIntersection=r.clipIntersection,d.displacementMap=r.displacementMap,d.displacementScale=r.displacementScale,d.displacementBias=r.displacementBias,d.wireframeLinewidth=r.wireframeLinewidth,d.linewidth=r.linewidth,!0===i.isPointLight&&!0===d.isMeshDistanceMaterial&&(d.referencePosition.setFromMatrixPosition(i.matrixWorld),d.nearDistance=a,d.farDistance=o),d}function _(n,i,a,o,s){if(!1===n.visible)return;if(n.layers.test(i.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&s===VSMShadowMap)&&(!n.frustumCulled||r.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(a.matrixWorldInverse,n.matrixWorld);const r=t.update(n),i=n.material;if(Array.isArray(i)){const t=r.groups;for(let l=0,c=t.length;l<c;l++){const c=t[l],h=i[c.materialIndex];if(h&&h.visible){const t=y(n,0,h,o,a.near,a.far,s);e.renderBufferDirect(a,null,r,t,n,c)}}}else if(i.visible){const t=y(n,0,i,o,a.near,a.far,s);e.renderBufferDirect(a,null,r,t,n,null)}}const l=n.children;for(let e=0,t=l.length;e<t;e++)_(l[e],i,a,o,s)}this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=PCFShadowMap,this.render=function(t,n,s){if(!1===g.enabled)return;if(!1===g.autoUpdate&&!1===g.needsUpdate)return;if(0===t.length)return;const l=e.getRenderTarget(),c=e.getActiveCubeFace(),u=e.getActiveMipmapLevel(),d=e.state;d.setBlending(NoBlending),d.buffers.color.setClear(1,1,1,1),d.buffers.depth.setTest(!0),d.setScissorTest(!1);for(let l=0,c=t.length;l<c;l++){const c=t[l],u=c.shadow;if(void 0===u){console.warn("THREE.WebGLShadowMap:",c,"has no shadow.");continue}if(!1===u.autoUpdate&&!1===u.needsUpdate)continue;i.copy(u.mapSize);const p=u.getFrameExtents();if(i.multiply(p),a.copy(u.mapSize),(i.x>h||i.y>h)&&(i.x>h&&(a.x=Math.floor(h/p.x),i.x=a.x*p.x,u.mapSize.x=a.x),i.y>h&&(a.y=Math.floor(h/p.y),i.y=a.y*p.y,u.mapSize.y=a.y)),null===u.map&&!u.isPointLightShadow&&this.type===VSMShadowMap){const e={minFilter:LinearFilter,magFilter:LinearFilter,format:RGBAFormat};u.map=new WebGLRenderTarget(i.x,i.y,e),u.map.texture.name=c.name+".shadowMap",u.mapPass=new WebGLRenderTarget(i.x,i.y,e),u.camera.updateProjectionMatrix()}if(null===u.map){u.map=new WebGLRenderTarget(i.x,i.y,{minFilter:NearestFilter,magFilter:NearestFilter,format:RGBAFormat}),u.map.texture.name=c.name+".shadowMap",u.camera.updateProjectionMatrix()}e.setRenderTarget(u.map),e.clear();const m=u.getViewportCount();for(let e=0;e<m;e++){const t=u.getViewport(e);o.set(a.x*t.x,a.y*t.y,a.x*t.z,a.y*t.w),d.viewport(o),u.updateMatrices(c,e),r=u.getFrustum(),_(n,s,u.camera,c,this.type)}u.isPointLightShadow||this.type!==VSMShadowMap||v(u,s),u.needsUpdate=!1}g.needsUpdate=!1,e.setRenderTarget(l,c,u)}}function WebGLState(e,t,n){const r=n.isWebGL2;const i=new(function a(){let t=!1;const n=new Vector4;let r=null;const i=new Vector4(0,0,0,0);return{setMask:function(n){r===n||t||(e.colorMask(n,n,n,n),r=n)},setLocked:function(e){t=e},setClear:function(t,r,a,o,s){!0===s&&(t*=o,r*=o,a*=o),n.set(t,r,a,o),!1===i.equals(n)&&(e.clearColor(t,r,a,o),i.copy(n))},reset:function(){t=!1,r=null,i.set(-1,0,0,0)}}}),o=new(function s(){let t=!1,n=null,r=null,i=null;return{setTest:function(e){e?V(2929):H(2929)},setMask:function(r){n===r||t||(e.depthMask(r),n=r)},setFunc:function(t){if(r!==t){if(t)switch(t){case NeverDepth:e.depthFunc(512);break;case AlwaysDepth:e.depthFunc(519);break;case LessDepth:e.depthFunc(513);break;case LessEqualDepth:e.depthFunc(515);break;case EqualDepth:e.depthFunc(514);break;case GreaterEqualDepth:e.depthFunc(518);break;case GreaterDepth:e.depthFunc(516);break;case NotEqualDepth:e.depthFunc(517);break;default:e.depthFunc(515)}else e.depthFunc(515);r=t}},setLocked:function(e){t=e},setClear:function(t){i!==t&&(e.clearDepth(t),i=t)},reset:function(){t=!1,n=null,r=null,i=null}}}),l=new(function c(){let t=!1,n=null,r=null,i=null,a=null,o=null,s=null,l=null,c=null;return{setTest:function(e){t||(e?V(2960):H(2960))},setMask:function(r){n===r||t||(e.stencilMask(r),n=r)},setFunc:function(t,n,o){r===t&&i===n&&a===o||(e.stencilFunc(t,n,o),r=t,i=n,a=o)},setOp:function(t,n,r){o===t&&s===n&&l===r||(e.stencilOp(t,n,r),o=t,s=n,l=r)},setLocked:function(e){t=e},setClear:function(t){c!==t&&(e.clearStencil(t),c=t)},reset:function(){t=!1,n=null,r=null,i=null,a=null,o=null,s=null,l=null,c=null}}});let h={},u={},d=new WeakMap,p=[],m=null,f=!1,g=null,v=null,y=null,_=null,b=null,x=null,S=null,w=!1,C=null,M=null,E=null,T=null,I=null;const A=e.getParameter(35661);let k=!1,P=0;const R=e.getParameter(7938);-1!==R.indexOf("WebGL")?(P=parseFloat(/^WebGL (\d)/.exec(R)[1]),k=P>=1):-1!==R.indexOf("OpenGL ES")&&(P=parseFloat(/^OpenGL ES (\d)/.exec(R)[1]),k=P>=2);let N=null,L={};const D=e.getParameter(3088),$=e.getParameter(2978),z=(new Vector4).fromArray(D),F=(new Vector4).fromArray($);function O(t,n,r){const i=new Uint8Array(4),a=e.createTexture();e.bindTexture(t,a),e.texParameteri(t,10241,9728),e.texParameteri(t,10240,9728);for(let t=0;t<r;t++)e.texImage2D(n+t,0,6408,1,1,0,6408,5121,i);return a}const B={};function V(t){!0!==h[t]&&(e.enable(t),h[t]=!0)}function H(t){!1!==h[t]&&(e.disable(t),h[t]=!1)}B[3553]=O(3553,3553,1),B[34067]=O(34067,34069,6),i.setClear(0,0,0,1),o.setClear(1),l.setClear(0),V(2929),o.setFunc(LessEqualDepth),j(!1),q(CullFaceBack),V(2884),W(NoBlending);const U={[AddEquation]:32774,[SubtractEquation]:32778,[ReverseSubtractEquation]:32779};if(r)U[MinEquation]=32775,U[MaxEquation]=32776;else{const e=t.get("EXT_blend_minmax");null!==e&&(U[MinEquation]=e.MIN_EXT,U[MaxEquation]=e.MAX_EXT)}const G={[ZeroFactor]:0,[OneFactor]:1,[SrcColorFactor]:768,[SrcAlphaFactor]:770,[SrcAlphaSaturateFactor]:776,[DstColorFactor]:774,[DstAlphaFactor]:772,[OneMinusSrcColorFactor]:769,[OneMinusSrcAlphaFactor]:771,[OneMinusDstColorFactor]:775,[OneMinusDstAlphaFactor]:773};function W(t,n,r,i,a,o,s,l){if(t!==NoBlending){if(!1===f&&(V(3042),f=!0),t===CustomBlending)a=a||n,o=o||r,s=s||i,n===v&&a===b||(e.blendEquationSeparate(U[n],U[a]),v=n,b=a),r===y&&i===_&&o===x&&s===S||(e.blendFuncSeparate(G[r],G[i],G[o],G[s]),y=r,_=i,x=o,S=s),g=t,w=null;else if(t!==g||l!==w){if(v===AddEquation&&b===AddEquation||(e.blendEquation(32774),v=AddEquation,b=AddEquation),l)switch(t){case NormalBlending:e.blendFuncSeparate(1,771,1,771);break;case AdditiveBlending:e.blendFunc(1,1);break;case SubtractiveBlending:e.blendFuncSeparate(0,769,0,1);break;case MultiplyBlending:e.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",t)}else switch(t){case NormalBlending:e.blendFuncSeparate(770,771,1,771);break;case AdditiveBlending:e.blendFunc(770,1);break;case SubtractiveBlending:e.blendFuncSeparate(0,769,0,1);break;case MultiplyBlending:e.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",t)}y=null,_=null,x=null,S=null,g=t,w=l}}else!0===f&&(H(3042),f=!1)}function j(t){C!==t&&(e.frontFace(t?2304:2305),C=t)}function q(t){t!==CullFaceNone?(V(2884),t!==M&&e.cullFace(t===CullFaceBack?1029:t===CullFaceFront?1028:1032)):H(2884),M=t}function X(t,n,r){t?(V(32823),T===n&&I===r||(e.polygonOffset(n,r),T=n,I=r)):H(32823)}function K(t){void 0===t&&(t=33984+A-1),N!==t&&(e.activeTexture(t),N=t)}return{buffers:{color:i,depth:o,stencil:l},enable:V,disable:H,bindFramebuffer:function Y(t,n){return u[t]!==n&&(e.bindFramebuffer(t,n),u[t]=n,r&&(36009===t&&(u[36160]=n),36160===t&&(u[36009]=n)),!0)},drawBuffers:function Z(r,i){let a=p,o=!1;if(r)if(a=d.get(i),void 0===a&&(a=[],d.set(i,a)),r.isWebGLMultipleRenderTargets){const e=r.texture;if(a.length!==e.length||36064!==a[0]){for(let t=0,n=e.length;t<n;t++)a[t]=36064+t;a.length=e.length,o=!0}}else 36064!==a[0]&&(a[0]=36064,o=!0);else 1029!==a[0]&&(a[0]=1029,o=!0);o&&(n.isWebGL2?e.drawBuffers(a):t.get("WEBGL_draw_buffers").drawBuffersWEBGL(a))},useProgram:function J(t){return m!==t&&(e.useProgram(t),m=t,!0)},setBlending:W,setMaterial:function Q(e,t){e.side===DoubleSide?H(2884):V(2884);let n=e.side===BackSide;t&&(n=!n),j(n),e.blending===NormalBlending&&!1===e.transparent?W(NoBlending):W(e.blending,e.blendEquation,e.blendSrc,e.blendDst,e.blendEquationAlpha,e.blendSrcAlpha,e.blendDstAlpha,e.premultipliedAlpha),o.setFunc(e.depthFunc),o.setTest(e.depthTest),o.setMask(e.depthWrite),i.setMask(e.colorWrite);const r=e.stencilWrite;l.setTest(r),r&&(l.setMask(e.stencilWriteMask),l.setFunc(e.stencilFunc,e.stencilRef,e.stencilFuncMask),l.setOp(e.stencilFail,e.stencilZFail,e.stencilZPass)),X(e.polygonOffset,e.polygonOffsetFactor,e.polygonOffsetUnits),!0===e.alphaToCoverage?V(32926):H(32926)},setFlipSided:j,setCullFace:q,setLineWidth:function ee(t){t!==E&&(k&&e.lineWidth(t),E=t)},setPolygonOffset:X,setScissorTest:function te(e){e?V(3089):H(3089)},activeTexture:K,bindTexture:function ne(t,n){null===N&&K();let r=L[N];void 0===r&&(r={type:void 0,texture:void 0},L[N]=r),r.type===t&&r.texture===n||(e.bindTexture(t,n||B[t]),r.type=t,r.texture=n)},unbindTexture:function re(){const t=L[N];void 0!==t&&void 0!==t.type&&(e.bindTexture(t.type,null),t.type=void 0,t.texture=void 0)},compressedTexImage2D:function ie(){try{e.compressedTexImage2D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texImage2D:function ae(){try{e.texImage2D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texImage3D:function oe(){try{e.texImage3D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texStorage2D:function se(){try{e.texStorage2D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texStorage3D:function le(){try{e.texStorage3D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texSubImage2D:function ce(){try{e.texSubImage2D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texSubImage3D:function he(){try{e.texSubImage3D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},compressedTexSubImage2D:function ue(){try{e.compressedTexSubImage2D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},scissor:function de(t){!1===z.equals(t)&&(e.scissor(t.x,t.y,t.z,t.w),z.copy(t))},viewport:function pe(t){!1===F.equals(t)&&(e.viewport(t.x,t.y,t.z,t.w),F.copy(t))},reset:function me(){e.disable(3042),e.disable(2884),e.disable(2929),e.disable(32823),e.disable(3089),e.disable(2960),e.disable(32926),e.blendEquation(32774),e.blendFunc(1,0),e.blendFuncSeparate(1,0,1,0),e.colorMask(!0,!0,!0,!0),e.clearColor(0,0,0,0),e.depthMask(!0),e.depthFunc(513),e.clearDepth(1),e.stencilMask(4294967295),e.stencilFunc(519,0,4294967295),e.stencilOp(7680,7680,7680),e.clearStencil(0),e.cullFace(1029),e.frontFace(2305),e.polygonOffset(0,0),e.activeTexture(33984),e.bindFramebuffer(36160,null),!0===r&&(e.bindFramebuffer(36009,null),e.bindFramebuffer(36008,null)),e.useProgram(null),e.lineWidth(1),e.scissor(0,0,e.canvas.width,e.canvas.height),e.viewport(0,0,e.canvas.width,e.canvas.height),h={},N=null,L={},u={},d=new WeakMap,p=[],m=null,f=!1,g=null,v=null,y=null,_=null,b=null,x=null,S=null,w=!1,C=null,M=null,E=null,T=null,I=null,z.set(0,0,e.canvas.width,e.canvas.height),F.set(0,0,e.canvas.width,e.canvas.height),i.reset(),o.reset(),l.reset()}}}function WebGLTextures(e,t,n,r,i,a,o){const s=i.isWebGL2,l=i.maxTextures,c=i.maxCubemapSize,h=i.maxTextureSize,u=i.maxSamples,d=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):void 0,p=new WeakMap;let m,f=!1;try{f="undefined"!=typeof OffscreenCanvas&&null!==new OffscreenCanvas(1,1).getContext("2d")}catch(e){}function g(e,t){return f?new OffscreenCanvas(e,t):createElementNS("canvas")}function v(e,t,n,r){let i=1;if((e.width>r||e.height>r)&&(i=r/Math.max(e.width,e.height)),i<1||!0===t){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){const r=t?floorPowerOfTwo:Math.floor,a=r(i*e.width),o=r(i*e.height);void 0===m&&(m=g(a,o));const s=n?g(a,o):m;s.width=a,s.height=o;return s.getContext("2d").drawImage(e,0,0,a,o),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+e.width+"x"+e.height+") to ("+a+"x"+o+")."),s}return"data"in e&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+e.width+"x"+e.height+")."),e}return e}function y(e){return isPowerOfTwo(e.width)&&isPowerOfTwo(e.height)}function _(e,t){return e.generateMipmaps&&t&&e.minFilter!==NearestFilter&&e.minFilter!==LinearFilter}function b(t){e.generateMipmap(t)}function x(n,r,i,a,o=!1){if(!1===s)return r;if(null!==n){if(void 0!==e[n])return e[n];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+n+"'")}let l=r;return 6403===r&&(5126===i&&(l=33326),5131===i&&(l=33325),5121===i&&(l=33321)),33319===r&&(5126===i&&(l=33328),5131===i&&(l=33327),5121===i&&(l=33323)),6408===r&&(5126===i&&(l=34836),5131===i&&(l=34842),5121===i&&(l=a===sRGBEncoding&&!1===o?35907:32856),32819===i&&(l=32854),32820===i&&(l=32855)),33325!==l&&33326!==l&&33327!==l&&33328!==l&&34842!==l&&34836!==l||t.get("EXT_color_buffer_float"),l}function S(e,t,n){return!0===_(e,n)||e.isFramebufferTexture&&e.minFilter!==NearestFilter&&e.minFilter!==LinearFilter?Math.log2(Math.max(t.width,t.height))+1:void 0!==e.mipmaps&&e.mipmaps.length>0?e.mipmaps.length:e.isCompressedTexture&&Array.isArray(e.image)?t.mipmaps.length:1}function w(e){return e===NearestFilter||e===NearestMipmapNearestFilter||e===NearestMipmapLinearFilter?9728:9729}function C(t){const n=t.target;n.removeEventListener("dispose",C),(function i(t){const n=r.get(t);if(void 0===n.__webglInit)return;e.deleteTexture(n.__webglTexture),r.remove(t)})(n),n.isVideoTexture&&p.delete(n),o.memory.textures--}function M(t){const n=t.target;n.removeEventListener("dispose",M),(function i(t){const n=t.texture,i=r.get(t),a=r.get(n);if(!t)return;void 0!==a.__webglTexture&&(e.deleteTexture(a.__webglTexture),o.memory.textures--);t.depthTexture&&t.depthTexture.dispose();if(t.isWebGLCubeRenderTarget)for(let t=0;t<6;t++)e.deleteFramebuffer(i.__webglFramebuffer[t]),i.__webglDepthbuffer&&e.deleteRenderbuffer(i.__webglDepthbuffer[t]);else e.deleteFramebuffer(i.__webglFramebuffer),i.__webglDepthbuffer&&e.deleteRenderbuffer(i.__webglDepthbuffer),i.__webglMultisampledFramebuffer&&e.deleteFramebuffer(i.__webglMultisampledFramebuffer),i.__webglColorRenderbuffer&&e.deleteRenderbuffer(i.__webglColorRenderbuffer),i.__webglDepthRenderbuffer&&e.deleteRenderbuffer(i.__webglDepthRenderbuffer);if(t.isWebGLMultipleRenderTargets)for(let t=0,i=n.length;t<i;t++){const i=r.get(n[t]);i.__webglTexture&&(e.deleteTexture(i.__webglTexture),o.memory.textures--),r.remove(n[t])}r.remove(n),r.remove(t)})(n)}let E=0;function T(e,t){const i=r.get(e);if(e.isVideoTexture&&(function a(e){const t=o.render.frame;p.get(e)!==t&&(p.set(e,t),e.update())})(e),e.version>0&&i.__version!==e.version){const n=e.image;if(void 0===n)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined");else{if(!1!==n.complete)return void N(i,e,t);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}n.activeTexture(33984+t),n.bindTexture(3553,i.__webglTexture)}function I(t,i){const o=r.get(t);t.version>0&&o.__version!==t.version?(function l(t,r,i){if(6!==r.image.length)return;R(t,r),n.activeTexture(33984+i),n.bindTexture(34067,t.__webglTexture),e.pixelStorei(37440,r.flipY),e.pixelStorei(37441,r.premultiplyAlpha),e.pixelStorei(3317,r.unpackAlignment),e.pixelStorei(37443,0);const o=r&&(r.isCompressedTexture||r.image[0].isCompressedTexture),l=r.image[0]&&r.image[0].isDataTexture,h=[];for(let e=0;e<6;e++)h[e]=o||l?l?r.image[e].image:r.image[e]:v(r.image[e],!1,!0,c),h[e]=F(r,h[e]);const u=h[0],d=y(u)||s,p=a.convert(r.format,r.encoding),m=a.convert(r.type),f=x(r.internalFormat,p,m,r.encoding),g=s&&!0!==r.isVideoTexture,w=void 0===t.__version;let C,M=S(r,u,d);if(P(34067,r,d),o){g&&w&&n.texStorage2D(34067,M,f,u.width,u.height);for(let e=0;e<6;e++){C=h[e].mipmaps;for(let t=0;t<C.length;t++){const i=C[t];r.format!==RGBAFormat?null!==p?g?n.compressedTexSubImage2D(34069+e,t,0,0,i.width,i.height,p,i.data):n.compressedTexImage2D(34069+e,t,f,i.width,i.height,0,i.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):g?n.texSubImage2D(34069+e,t,0,0,i.width,i.height,p,m,i.data):n.texImage2D(34069+e,t,f,i.width,i.height,0,p,m,i.data)}}}else{C=r.mipmaps,g&&w&&(C.length>0&&M++,n.texStorage2D(34067,M,f,h[0].width,h[0].height));for(let e=0;e<6;e++)if(l){g?n.texSubImage2D(34069+e,0,0,0,h[e].width,h[e].height,p,m,h[e].data):n.texImage2D(34069+e,0,f,h[e].width,h[e].height,0,p,m,h[e].data);for(let t=0;t<C.length;t++){const r=C[t].image[e].image;g?n.texSubImage2D(34069+e,t+1,0,0,r.width,r.height,p,m,r.data):n.texImage2D(34069+e,t+1,f,r.width,r.height,0,p,m,r.data)}}else{g?n.texSubImage2D(34069+e,0,0,0,p,m,h[e]):n.texImage2D(34069+e,0,f,p,m,h[e]);for(let t=0;t<C.length;t++){const r=C[t];g?n.texSubImage2D(34069+e,t+1,0,0,p,m,r.image[e]):n.texImage2D(34069+e,t+1,f,p,m,r.image[e])}}}_(r,d)&&b(34067);t.__version=r.version,r.onUpdate&&r.onUpdate(r)})(o,t,i):(n.activeTexture(33984+i),n.bindTexture(34067,o.__webglTexture))}const A={[RepeatWrapping]:10497,[ClampToEdgeWrapping]:33071,[MirroredRepeatWrapping]:33648},k={[NearestFilter]:9728,[NearestMipmapNearestFilter]:9984,[NearestMipmapLinearFilter]:9986,[LinearFilter]:9729,[LinearMipmapNearestFilter]:9985,[LinearMipmapLinearFilter]:9987};function P(n,a,o){if(o?(e.texParameteri(n,10242,A[a.wrapS]),e.texParameteri(n,10243,A[a.wrapT]),32879!==n&&35866!==n||e.texParameteri(n,32882,A[a.wrapR]),e.texParameteri(n,10240,k[a.magFilter]),e.texParameteri(n,10241,k[a.minFilter])):(e.texParameteri(n,10242,33071),e.texParameteri(n,10243,33071),32879!==n&&35866!==n||e.texParameteri(n,32882,33071),a.wrapS===ClampToEdgeWrapping&&a.wrapT===ClampToEdgeWrapping||console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),e.texParameteri(n,10240,w(a.magFilter)),e.texParameteri(n,10241,w(a.minFilter)),a.minFilter!==NearestFilter&&a.minFilter!==LinearFilter&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),!0===t.has("EXT_texture_filter_anisotropic")){const o=t.get("EXT_texture_filter_anisotropic");if(a.type===FloatType&&!1===t.has("OES_texture_float_linear"))return;if(!1===s&&a.type===HalfFloatType&&!1===t.has("OES_texture_half_float_linear"))return;(a.anisotropy>1||r.get(a).__currentAnisotropy)&&(e.texParameterf(n,o.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,i.getMaxAnisotropy())),r.get(a).__currentAnisotropy=a.anisotropy)}}function R(t,n){void 0===t.__webglInit&&(t.__webglInit=!0,n.addEventListener("dispose",C),t.__webglTexture=e.createTexture(),o.memory.textures++)}function N(t,r,i){let o=3553;r.isDataTexture2DArray&&(o=35866),r.isDataTexture3D&&(o=32879),R(t,r),n.activeTexture(33984+i),n.bindTexture(o,t.__webglTexture),e.pixelStorei(37440,r.flipY),e.pixelStorei(37441,r.premultiplyAlpha),e.pixelStorei(3317,r.unpackAlignment),e.pixelStorei(37443,0);const l=(function c(e){return!s&&(e.wrapS!==ClampToEdgeWrapping||e.wrapT!==ClampToEdgeWrapping||e.minFilter!==NearestFilter&&e.minFilter!==LinearFilter)})(r)&&!1===y(r.image);let u=v(r.image,l,!1,h);u=F(r,u);const d=y(u)||s,p=a.convert(r.format,r.encoding);let m,f=a.convert(r.type),g=x(r.internalFormat,p,f,r.encoding,r.isVideoTexture);P(o,r,d);const w=r.mipmaps,C=s&&!0!==r.isVideoTexture,M=void 0===t.__version,E=S(r,u,d);if(r.isDepthTexture)g=6402,s?g=r.type===FloatType?36012:r.type===UnsignedIntType?33190:r.type===UnsignedInt248Type?35056:33189:r.type===FloatType&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),r.format===DepthFormat&&6402===g&&r.type!==UnsignedShortType&&r.type!==UnsignedIntType&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),r.type=UnsignedShortType,f=a.convert(r.type)),r.format===DepthStencilFormat&&6402===g&&(g=34041,r.type!==UnsignedInt248Type&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),r.type=UnsignedInt248Type,f=a.convert(r.type))),C&&M?n.texStorage2D(3553,1,g,u.width,u.height):n.texImage2D(3553,0,g,u.width,u.height,0,p,f,null);else if(r.isDataTexture)if(w.length>0&&d){C&&M&&n.texStorage2D(3553,E,g,w[0].width,w[0].height);for(let e=0,t=w.length;e<t;e++)m=w[e],C?n.texSubImage2D(3553,0,0,0,m.width,m.height,p,f,m.data):n.texImage2D(3553,e,g,m.width,m.height,0,p,f,m.data);r.generateMipmaps=!1}else C?(M&&n.texStorage2D(3553,E,g,u.width,u.height),n.texSubImage2D(3553,0,0,0,u.width,u.height,p,f,u.data)):n.texImage2D(3553,0,g,u.width,u.height,0,p,f,u.data);else if(r.isCompressedTexture){C&&M&&n.texStorage2D(3553,E,g,w[0].width,w[0].height);for(let e=0,t=w.length;e<t;e++)m=w[e],r.format!==RGBAFormat?null!==p?C?n.compressedTexSubImage2D(3553,e,0,0,m.width,m.height,p,m.data):n.compressedTexImage2D(3553,e,g,m.width,m.height,0,m.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):C?n.texSubImage2D(3553,e,0,0,m.width,m.height,p,f,m.data):n.texImage2D(3553,e,g,m.width,m.height,0,p,f,m.data)}else if(r.isDataTexture2DArray)C?(M&&n.texStorage3D(35866,E,g,u.width,u.height,u.depth),n.texSubImage3D(35866,0,0,0,0,u.width,u.height,u.depth,p,f,u.data)):n.texImage3D(35866,0,g,u.width,u.height,u.depth,0,p,f,u.data);else if(r.isDataTexture3D)C?(M&&n.texStorage3D(32879,E,g,u.width,u.height,u.depth),n.texSubImage3D(32879,0,0,0,0,u.width,u.height,u.depth,p,f,u.data)):n.texImage3D(32879,0,g,u.width,u.height,u.depth,0,p,f,u.data);else if(r.isFramebufferTexture)C&&M?n.texStorage2D(3553,E,g,u.width,u.height):n.texImage2D(3553,0,g,u.width,u.height,0,p,f,null);else if(w.length>0&&d){C&&M&&n.texStorage2D(3553,E,g,w[0].width,w[0].height);for(let e=0,t=w.length;e<t;e++)m=w[e],C?n.texSubImage2D(3553,e,0,0,p,f,m):n.texImage2D(3553,e,g,p,f,m);r.generateMipmaps=!1}else C?(M&&n.texStorage2D(3553,E,g,u.width,u.height),n.texSubImage2D(3553,0,0,0,p,f,u)):n.texImage2D(3553,0,g,p,f,u);_(r,d)&&b(o),t.__version=r.version,r.onUpdate&&r.onUpdate(r)}function L(t,i,o,s,l){const c=a.convert(o.format,o.encoding),h=a.convert(o.type),u=x(o.internalFormat,c,h,o.encoding);r.get(i).__hasExternalTextures||(32879===l||35866===l?n.texImage3D(l,0,u,i.width,i.height,i.depth,0,c,h,null):n.texImage2D(l,0,u,i.width,i.height,0,c,h,null)),n.bindFramebuffer(36160,t),i.useRenderToTexture?d.framebufferTexture2DMultisampleEXT(36160,s,l,r.get(o).__webglTexture,0,z(i)):e.framebufferTexture2D(36160,s,l,r.get(o).__webglTexture,0),n.bindFramebuffer(36160,null)}function D(t,n,r){if(e.bindRenderbuffer(36161,t),n.depthBuffer&&!n.stencilBuffer){let i=33189;if(r||n.useRenderToTexture){const t=n.depthTexture;t&&t.isDepthTexture&&(t.type===FloatType?i=36012:t.type===UnsignedIntType&&(i=33190));const r=z(n);n.useRenderToTexture?d.renderbufferStorageMultisampleEXT(36161,r,i,n.width,n.height):e.renderbufferStorageMultisample(36161,r,i,n.width,n.height)}else e.renderbufferStorage(36161,i,n.width,n.height);e.framebufferRenderbuffer(36160,36096,36161,t)}else if(n.depthBuffer&&n.stencilBuffer){const i=z(n);r&&n.useRenderbuffer?e.renderbufferStorageMultisample(36161,i,35056,n.width,n.height):n.useRenderToTexture?d.renderbufferStorageMultisampleEXT(36161,i,35056,n.width,n.height):e.renderbufferStorage(36161,34041,n.width,n.height),e.framebufferRenderbuffer(36160,33306,36161,t)}else{const t=!0===n.isWebGLMultipleRenderTargets?n.texture[0]:n.texture,i=a.convert(t.format,t.encoding),o=a.convert(t.type),s=x(t.internalFormat,i,o,t.encoding),l=z(n);r&&n.useRenderbuffer?e.renderbufferStorageMultisample(36161,l,s,n.width,n.height):n.useRenderToTexture?d.renderbufferStorageMultisampleEXT(36161,l,s,n.width,n.height):e.renderbufferStorage(36161,s,n.width,n.height)}e.bindRenderbuffer(36161,null)}function $(t){const i=r.get(t),a=!0===t.isWebGLCubeRenderTarget;if(t.depthTexture&&!i.__autoAllocateDepthBuffer){if(a)throw new Error("target.depthTexture not supported in Cube render targets");!(function o(t,i){if(i&&i.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(36160,t),!i.depthTexture||!i.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");r.get(i.depthTexture).__webglTexture&&i.depthTexture.image.width===i.width&&i.depthTexture.image.height===i.height||(i.depthTexture.image.width=i.width,i.depthTexture.image.height=i.height,i.depthTexture.needsUpdate=!0),T(i.depthTexture,0);const a=r.get(i.depthTexture).__webglTexture,o=z(i);if(i.depthTexture.format===DepthFormat)i.useRenderToTexture?d.framebufferTexture2DMultisampleEXT(36160,36096,3553,a,0,o):e.framebufferTexture2D(36160,36096,3553,a,0);else{if(i.depthTexture.format!==DepthStencilFormat)throw new Error("Unknown depthTexture format");i.useRenderToTexture?d.framebufferTexture2DMultisampleEXT(36160,33306,3553,a,0,o):e.framebufferTexture2D(36160,33306,3553,a,0)}})(i.__webglFramebuffer,t)}else if(a){i.__webglDepthbuffer=[];for(let r=0;r<6;r++)n.bindFramebuffer(36160,i.__webglFramebuffer[r]),i.__webglDepthbuffer[r]=e.createRenderbuffer(),D(i.__webglDepthbuffer[r],t,!1)}else n.bindFramebuffer(36160,i.__webglFramebuffer),i.__webglDepthbuffer=e.createRenderbuffer(),D(i.__webglDepthbuffer,t,!1);n.bindFramebuffer(36160,null)}function z(e){return s&&(e.useRenderbuffer||e.useRenderToTexture)?Math.min(u,e.samples):0}function F(e,n){const r=e.encoding,i=e.format,a=e.type;return!0===e.isCompressedTexture||!0===e.isVideoTexture||e.format===_SRGBAFormat||r!==LinearEncoding&&(r===sRGBEncoding?!1===s?!0===t.has("EXT_sRGB")&&i===RGBAFormat?(e.format=_SRGBAFormat,e.minFilter=LinearFilter,e.generateMipmaps=!1):n=ImageUtils.sRGBToLinear(n):i===RGBAFormat&&a===UnsignedByteType||console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",r)),n}let O=!1,B=!1;this.allocateTextureUnit=function V(){const e=E;return e>=l&&console.warn("THREE.WebGLTextures: Trying to use "+e+" texture units while this GPU supports only "+l),E+=1,e},this.resetTextureUnits=function H(){E=0},this.setTexture2D=T,this.setTexture2DArray=function U(e,t){const i=r.get(e);e.version>0&&i.__version!==e.version?N(i,e,t):(n.activeTexture(33984+t),n.bindTexture(35866,i.__webglTexture))},this.setTexture3D=function G(e,t){const i=r.get(e);e.version>0&&i.__version!==e.version?N(i,e,t):(n.activeTexture(33984+t),n.bindTexture(32879,i.__webglTexture))},this.setTextureCube=I,this.rebindTextures=function W(e,t,n){const i=r.get(e);void 0!==t&&L(i.__webglFramebuffer,e,e.texture,36064,3553),void 0!==n&&$(e)},this.setupRenderTarget=function j(t){const l=t.texture,c=r.get(t),h=r.get(l);t.addEventListener("dispose",M),!0!==t.isWebGLMultipleRenderTargets&&(void 0===h.__webglTexture&&(h.__webglTexture=e.createTexture()),h.__version=l.version,o.memory.textures++);const u=!0===t.isWebGLCubeRenderTarget,d=!0===t.isWebGLMultipleRenderTargets,p=l.isDataTexture3D||l.isDataTexture2DArray,m=y(t)||s;if(u){c.__webglFramebuffer=[];for(let t=0;t<6;t++)c.__webglFramebuffer[t]=e.createFramebuffer()}else if(c.__webglFramebuffer=e.createFramebuffer(),d)if(i.drawBuffers){const n=t.texture;for(let t=0,i=n.length;t<i;t++){const i=r.get(n[t]);void 0===i.__webglTexture&&(i.__webglTexture=e.createTexture(),o.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");else if(t.useRenderbuffer)if(s){c.__webglMultisampledFramebuffer=e.createFramebuffer(),c.__webglColorRenderbuffer=e.createRenderbuffer(),e.bindRenderbuffer(36161,c.__webglColorRenderbuffer);const r=a.convert(l.format,l.encoding),i=a.convert(l.type),o=x(l.internalFormat,r,i,l.encoding),s=z(t);e.renderbufferStorageMultisample(36161,s,o,t.width,t.height),n.bindFramebuffer(36160,c.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(36160,36064,36161,c.__webglColorRenderbuffer),e.bindRenderbuffer(36161,null),t.depthBuffer&&(c.__webglDepthRenderbuffer=e.createRenderbuffer(),D(c.__webglDepthRenderbuffer,t,!0)),n.bindFramebuffer(36160,null)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.");if(u){n.bindTexture(34067,h.__webglTexture),P(34067,l,m);for(let e=0;e<6;e++)L(c.__webglFramebuffer[e],t,l,36064,34069+e);_(l,m)&&b(34067),n.unbindTexture()}else if(d){const e=t.texture;for(let i=0,a=e.length;i<a;i++){const a=e[i],o=r.get(a);n.bindTexture(3553,o.__webglTexture),P(3553,a,m),L(c.__webglFramebuffer,t,a,36064+i,3553),_(a,m)&&b(3553)}n.unbindTexture()}else{let e=3553;if(p)if(s){e=l.isDataTexture3D?32879:35866}else console.warn("THREE.DataTexture3D and THREE.DataTexture2DArray only supported with WebGL2.");n.bindTexture(e,h.__webglTexture),P(e,l,m),L(c.__webglFramebuffer,t,l,36064,e),_(l,m)&&b(e),n.unbindTexture()}t.depthBuffer&&$(t)},this.updateRenderTargetMipmap=function q(e){const t=y(e)||s,i=!0===e.isWebGLMultipleRenderTargets?e.texture:[e.texture];for(let a=0,o=i.length;a<o;a++){const o=i[a];if(_(o,t)){const t=e.isWebGLCubeRenderTarget?34067:3553,i=r.get(o).__webglTexture;n.bindTexture(t,i),b(t),n.unbindTexture()}}},this.updateMultisampleRenderTarget=function X(t){if(t.useRenderbuffer)if(s){const i=t.width,a=t.height;let o=16384;const s=[36064],l=t.stencilBuffer?33306:36096;t.depthBuffer&&s.push(l),t.ignoreDepthForMultisampleCopy||(t.depthBuffer&&(o|=256),t.stencilBuffer&&(o|=1024));const c=r.get(t);n.bindFramebuffer(36008,c.__webglMultisampledFramebuffer),n.bindFramebuffer(36009,c.__webglFramebuffer),t.ignoreDepthForMultisampleCopy&&(e.invalidateFramebuffer(36008,[l]),e.invalidateFramebuffer(36009,[l])),e.blitFramebuffer(0,0,i,a,0,0,i,a,o,9728),e.invalidateFramebuffer(36008,s),n.bindFramebuffer(36008,null),n.bindFramebuffer(36009,c.__webglMultisampledFramebuffer)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.")},this.setupDepthRenderbuffer=$,this.setupFrameBufferTexture=L,this.safeSetTexture2D=function K(e,t){e&&e.isWebGLRenderTarget&&(!1===O&&(console.warn("THREE.WebGLTextures.safeSetTexture2D: don't use render targets as textures. Use their .texture property instead."),O=!0),e=e.texture),T(e,t)},this.safeSetTextureCube=function Y(e,t){e&&e.isWebGLCubeRenderTarget&&(!1===B&&(console.warn("THREE.WebGLTextures.safeSetTextureCube: don't use cube render targets as textures. Use their .texture property instead."),B=!0),e=e.texture),I(e,t)}}function WebGLUtils(e,t,n){const r=n.isWebGL2;return{convert:function i(e,n=null){let i;if(e===UnsignedByteType)return 5121;if(e===UnsignedShort4444Type)return 32819;if(e===UnsignedShort5551Type)return 32820;if(e===ByteType)return 5120;if(e===ShortType)return 5122;if(e===UnsignedShortType)return 5123;if(e===IntType)return 5124;if(e===UnsignedIntType)return 5125;if(e===FloatType)return 5126;if(e===HalfFloatType)return r?5131:(i=t.get("OES_texture_half_float"),null!==i?i.HALF_FLOAT_OES:null);if(e===AlphaFormat)return 6406;if(e===RGBAFormat)return 6408;if(e===LuminanceFormat)return 6409;if(e===LuminanceAlphaFormat)return 6410;if(e===DepthFormat)return 6402;if(e===DepthStencilFormat)return 34041;if(e===RedFormat)return 6403;if(e===_SRGBAFormat)return i=t.get("EXT_sRGB"),null!==i?i.SRGB_ALPHA_EXT:null;if(e===RedIntegerFormat)return 36244;if(e===RGFormat)return 33319;if(e===RGIntegerFormat)return 33320;if(e===RGBAIntegerFormat)return 36249;if(e===RGB_S3TC_DXT1_Format||e===RGBA_S3TC_DXT1_Format||e===RGBA_S3TC_DXT3_Format||e===RGBA_S3TC_DXT5_Format)if(n===sRGBEncoding){if(i=t.get("WEBGL_compressed_texture_s3tc_srgb"),null===i)return null;if(e===RGB_S3TC_DXT1_Format)return i.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(e===RGBA_S3TC_DXT1_Format)return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(e===RGBA_S3TC_DXT3_Format)return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(e===RGBA_S3TC_DXT5_Format)return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else{if(i=t.get("WEBGL_compressed_texture_s3tc"),null===i)return null;if(e===RGB_S3TC_DXT1_Format)return i.COMPRESSED_RGB_S3TC_DXT1_EXT;if(e===RGBA_S3TC_DXT1_Format)return i.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(e===RGBA_S3TC_DXT3_Format)return i.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(e===RGBA_S3TC_DXT5_Format)return i.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(e===RGB_PVRTC_4BPPV1_Format||e===RGB_PVRTC_2BPPV1_Format||e===RGBA_PVRTC_4BPPV1_Format||e===RGBA_PVRTC_2BPPV1_Format){if(i=t.get("WEBGL_compressed_texture_pvrtc"),null===i)return null;if(e===RGB_PVRTC_4BPPV1_Format)return i.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(e===RGB_PVRTC_2BPPV1_Format)return i.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(e===RGBA_PVRTC_4BPPV1_Format)return i.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(e===RGBA_PVRTC_2BPPV1_Format)return i.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(e===RGB_ETC1_Format)return i=t.get("WEBGL_compressed_texture_etc1"),null!==i?i.COMPRESSED_RGB_ETC1_WEBGL:null;if(e===RGB_ETC2_Format||e===RGBA_ETC2_EAC_Format){if(i=t.get("WEBGL_compressed_texture_etc"),null===i)return null;if(e===RGB_ETC2_Format)return n===sRGBEncoding?i.COMPRESSED_SRGB8_ETC2:i.COMPRESSED_RGB8_ETC2;if(e===RGBA_ETC2_EAC_Format)return n===sRGBEncoding?i.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:i.COMPRESSED_RGBA8_ETC2_EAC}if(e===RGBA_ASTC_4x4_Format||e===RGBA_ASTC_5x4_Format||e===RGBA_ASTC_5x5_Format||e===RGBA_ASTC_6x5_Format||e===RGBA_ASTC_6x6_Format||e===RGBA_ASTC_8x5_Format||e===RGBA_ASTC_8x6_Format||e===RGBA_ASTC_8x8_Format||e===RGBA_ASTC_10x5_Format||e===RGBA_ASTC_10x6_Format||e===RGBA_ASTC_10x8_Format||e===RGBA_ASTC_10x10_Format||e===RGBA_ASTC_12x10_Format||e===RGBA_ASTC_12x12_Format){if(i=t.get("WEBGL_compressed_texture_astc"),null===i)return null;if(e===RGBA_ASTC_4x4_Format)return n===sRGBEncoding?i.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:i.COMPRESSED_RGBA_ASTC_4x4_KHR;if(e===RGBA_ASTC_5x4_Format)return n===sRGBEncoding?i.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:i.COMPRESSED_RGBA_ASTC_5x4_KHR;if(e===RGBA_ASTC_5x5_Format)return n===sRGBEncoding?i.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:i.COMPRESSED_RGBA_ASTC_5x5_KHR;if(e===RGBA_ASTC_6x5_Format)return n===sRGBEncoding?i.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:i.COMPRESSED_RGBA_ASTC_6x5_KHR;if(e===RGBA_ASTC_6x6_Format)return n===sRGBEncoding?i.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:i.COMPRESSED_RGBA_ASTC_6x6_KHR;if(e===RGBA_ASTC_8x5_Format)return n===sRGBEncoding?i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:i.COMPRESSED_RGBA_ASTC_8x5_KHR;if(e===RGBA_ASTC_8x6_Format)return n===sRGBEncoding?i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:i.COMPRESSED_RGBA_ASTC_8x6_KHR;if(e===RGBA_ASTC_8x8_Format)return n===sRGBEncoding?i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:i.COMPRESSED_RGBA_ASTC_8x8_KHR;if(e===RGBA_ASTC_10x5_Format)return n===sRGBEncoding?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:i.COMPRESSED_RGBA_ASTC_10x5_KHR;if(e===RGBA_ASTC_10x6_Format)return n===sRGBEncoding?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:i.COMPRESSED_RGBA_ASTC_10x6_KHR;if(e===RGBA_ASTC_10x8_Format)return n===sRGBEncoding?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:i.COMPRESSED_RGBA_ASTC_10x8_KHR;if(e===RGBA_ASTC_10x10_Format)return n===sRGBEncoding?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:i.COMPRESSED_RGBA_ASTC_10x10_KHR;if(e===RGBA_ASTC_12x10_Format)return n===sRGBEncoding?i.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:i.COMPRESSED_RGBA_ASTC_12x10_KHR;if(e===RGBA_ASTC_12x12_Format)return n===sRGBEncoding?i.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:i.COMPRESSED_RGBA_ASTC_12x12_KHR}if(e===RGBA_BPTC_Format){if(i=t.get("EXT_texture_compression_bptc"),null===i)return null;if(e===RGBA_BPTC_Format)return n===sRGBEncoding?i.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:i.COMPRESSED_RGBA_BPTC_UNORM_EXT}return e===UnsignedInt248Type?r?34042:(i=t.get("WEBGL_depth_texture"),null!==i?i.UNSIGNED_INT_24_8_WEBGL:null):void 0}}}class ArrayCamera extends PerspectiveCamera{constructor(e=[]){super(),this.cameras=e}}ArrayCamera.prototype.isArrayCamera=!0;class Group extends Object3D{constructor(){super(),this.type="Group"}}Group.prototype.isGroup=!0;const _moveEvent={type:"move"};class WebXRController{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return null===this._hand&&(this._hand=new Group,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return null===this._targetRay&&(this._targetRay=new Group,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Vector3,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Vector3),this._targetRay}getGripSpace(){return null===this._grip&&(this._grip=new Group,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Vector3,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Vector3),this._grip}dispatchEvent(e){return null!==this._targetRay&&this._targetRay.dispatchEvent(e),null!==this._grip&&this._grip.dispatchEvent(e),null!==this._hand&&this._hand.dispatchEvent(e),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),null!==this._targetRay&&(this._targetRay.visible=!1),null!==this._grip&&(this._grip.visible=!1),null!==this._hand&&(this._hand.visible=!1),this}update(e,t,n){let r=null,i=null,a=null;const o=this._targetRay,s=this._grip,l=this._hand;if(e&&"visible-blurred"!==t.session.visibilityState)if(null!==o&&(r=t.getPose(e.targetRaySpace,n),null!==r&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(_moveEvent))),l&&e.hand){a=!0;for(const r of e.hand.values()){const e=t.getJointPose(r,n);if(void 0===l.joints[r.jointName]){const e=new Group;e.matrixAutoUpdate=!1,e.visible=!1,l.joints[r.jointName]=e,l.add(e)}const i=l.joints[r.jointName];null!==e&&(i.matrix.fromArray(e.transform.matrix),i.matrix.decompose(i.position,i.rotation,i.scale),i.jointRadius=e.radius),i.visible=null!==e}const r=l.joints["index-finger-tip"].position.distanceTo(l.joints["thumb-tip"].position),i=.02,o=.005;l.inputState.pinching&&r>i+o?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&r<=i-o&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else null!==s&&e.gripSpace&&(i=t.getPose(e.gripSpace,n),null!==i&&(s.matrix.fromArray(i.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale),i.linearVelocity?(s.hasLinearVelocity=!0,s.linearVelocity.copy(i.linearVelocity)):s.hasLinearVelocity=!1,i.angularVelocity?(s.hasAngularVelocity=!0,s.angularVelocity.copy(i.angularVelocity)):s.hasAngularVelocity=!1));return null!==o&&(o.visible=null!==r),null!==s&&(s.visible=null!==i),null!==l&&(l.visible=null!==a),this}}class DepthTexture extends Texture{constructor(e,t,n,r,i,a,o,s,l,c){if((c=void 0!==c?c:DepthFormat)!==DepthFormat&&c!==DepthStencilFormat)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===n&&c===DepthFormat&&(n=UnsignedShortType),void 0===n&&c===DepthStencilFormat&&(n=UnsignedInt248Type),super(null,r,i,a,o,s,c,n,l),this.image={width:e,height:t},this.magFilter=void 0!==o?o:NearestFilter,this.minFilter=void 0!==s?s:NearestFilter,this.flipY=!1,this.generateMipmaps=!1}}DepthTexture.prototype.isDepthTexture=!0;class WebXRManager extends EventDispatcher{constructor(e,t){super();const n=this;let r=null,i=1,a=null,o="local-floor";const s=e.extensions.has("WEBGL_multisampled_render_to_texture");let l=null,c=null,h=null,u=null,d=!1,p=null;const m=t.getContextAttributes();let f=null,g=null;const v=[],y=new Map,_=new PerspectiveCamera;_.layers.enable(1),_.viewport=new Vector4;const b=new PerspectiveCamera;b.layers.enable(2),b.viewport=new Vector4;const x=[_,b],S=new ArrayCamera;S.layers.enable(1),S.layers.enable(2);let w=null,C=null;function M(e){const t=y.get(e.inputSource);t&&t.dispatchEvent({type:e.type,data:e.inputSource})}function E(){y.forEach((function(e,t){e.disconnect(t)})),y.clear(),w=null,C=null,e.setRenderTarget(f),u=null,h=null,c=null,r=null,g=null,R.stop(),n.isPresenting=!1,n.dispatchEvent({type:"sessionend"})}function T(e){const t=r.inputSources;for(let e=0;e<v.length;e++)y.set(t[e],v[e]);for(let t=0;t<e.removed.length;t++){const n=e.removed[t],r=y.get(n);r&&(r.dispatchEvent({type:"disconnected",data:n}),y.delete(n))}for(let t=0;t<e.added.length;t++){const n=e.added[t],r=y.get(n);r&&r.dispatchEvent({type:"connected",data:n})}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(e){let t=v[e];return void 0===t&&(t=new WebXRController,v[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=v[e];return void 0===t&&(t=new WebXRController,v[e]=t),t.getGripSpace()},this.getHand=function(e){let t=v[e];return void 0===t&&(t=new WebXRController,v[e]=t),t.getHandSpace()},this.setFramebufferScaleFactor=function(e){i=e,!0===n.isPresenting&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(e){o=e,!0===n.isPresenting&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return a},this.getBaseLayer=function(){return null!==h?h:u},this.getBinding=function(){return c},this.getFrame=function(){return p},this.getSession=function(){return r},this.setSession=async function(l){if(r=l,null!==r){if(f=e.getRenderTarget(),r.addEventListener("select",M),r.addEventListener("selectstart",M),r.addEventListener("selectend",M),r.addEventListener("squeeze",M),r.addEventListener("squeezestart",M),r.addEventListener("squeezeend",M),r.addEventListener("end",E),r.addEventListener("inputsourceschange",T),!0!==m.xrCompatible&&await t.makeXRCompatible(),void 0===r.renderState.layers||!1===e.capabilities.isWebGL2){u=new XRWebGLLayer(r,t,{antialias:void 0!==r.renderState.layers||m.antialias,alpha:m.alpha,depth:m.depth,stencil:m.stencil,framebufferScaleFactor:i}),r.updateRenderState({baseLayer:u}),g=new WebGLRenderTarget(u.framebufferWidth,u.framebufferHeight,{format:RGBAFormat,type:UnsignedByteType,encoding:e.outputEncoding})}else{d=m.antialias;let n=null,a=null,o=null;m.depth&&(o=m.stencil?35056:33190,n=m.stencil?DepthStencilFormat:DepthFormat,a=m.stencil?UnsignedInt248Type:UnsignedShortType);const l={colorFormat:e.outputEncoding===sRGBEncoding?35907:32856,depthFormat:o,scaleFactor:i};c=new XRWebGLBinding(r,t),h=c.createProjectionLayer(l),r.updateRenderState({layers:[h]}),g=d?new WebGLMultisampleRenderTarget(h.textureWidth,h.textureHeight,{format:RGBAFormat,type:UnsignedByteType,depthTexture:new DepthTexture(h.textureWidth,h.textureHeight,a,void 0,void 0,void 0,void 0,void 0,void 0,n),stencilBuffer:m.stencil,ignoreDepth:h.ignoreDepthValues,useRenderToTexture:s,encoding:e.outputEncoding}):new WebGLRenderTarget(h.textureWidth,h.textureHeight,{format:RGBAFormat,type:UnsignedByteType,depthTexture:new DepthTexture(h.textureWidth,h.textureHeight,a,void 0,void 0,void 0,void 0,void 0,void 0,n),stencilBuffer:m.stencil,ignoreDepth:h.ignoreDepthValues,encoding:e.outputEncoding})}g.isXRRenderTarget=!0,this.setFoveation(1),a=await r.requestReferenceSpace(o),R.setContext(r),R.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}};const I=new Vector3,A=new Vector3;function k(e,t){null===t?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}this.updateCamera=function(e){if(null===r)return;S.near=b.near=_.near=e.near,S.far=b.far=_.far=e.far,w===S.near&&C===S.far||(r.updateRenderState({depthNear:S.near,depthFar:S.far}),w=S.near,C=S.far);const t=e.parent,n=S.cameras;k(S,t);for(let e=0;e<n.length;e++)k(n[e],t);S.matrixWorld.decompose(S.position,S.quaternion,S.scale),e.position.copy(S.position),e.quaternion.copy(S.quaternion),e.scale.copy(S.scale),e.matrix.copy(S.matrix),e.matrixWorld.copy(S.matrixWorld);const i=e.children;for(let e=0,t=i.length;e<t;e++)i[e].updateMatrixWorld(!0);2===n.length?(function a(e,t,n){I.setFromMatrixPosition(t.matrixWorld),A.setFromMatrixPosition(n.matrixWorld);const r=I.distanceTo(A),i=t.projectionMatrix.elements,a=n.projectionMatrix.elements,o=i[14]/(i[10]-1),s=i[14]/(i[10]+1),l=(i[9]+1)/i[5],c=(i[9]-1)/i[5],h=(i[8]-1)/i[0],u=(a[8]+1)/a[0],d=o*h,p=o*u,m=r/(-h+u),f=m*-h;t.matrixWorld.decompose(e.position,e.quaternion,e.scale),e.translateX(f),e.translateZ(m),e.matrixWorld.compose(e.position,e.quaternion,e.scale),e.matrixWorldInverse.copy(e.matrixWorld).invert();const g=o+m,v=s+m;e.projectionMatrix.makePerspective(d-f,p+(r-f),l*s/v*g,c*s/v*g,g,v)})(S,_,b):S.projectionMatrix.copy(_.projectionMatrix)},this.getCamera=function(){return S},this.getFoveation=function(){return null!==h?h.fixedFoveation:null!==u?u.fixedFoveation:void 0},this.setFoveation=function(e){null!==h&&(h.fixedFoveation=e),null!==u&&void 0!==u.fixedFoveation&&(u.fixedFoveation=e)};let P=null;const R=new WebGLAnimation;R.setAnimationLoop((function N(t,n){if(l=n.getViewerPose(a),p=n,null!==l){const t=l.views;null!==u&&(e.setRenderTargetFramebuffer(g,u.framebuffer),e.setRenderTarget(g));let n=!1;t.length!==S.cameras.length&&(S.cameras.length=0,n=!0);for(let r=0;r<t.length;r++){const i=t[r];let a=null;if(null!==u)a=u.getViewport(i);else{const t=c.getViewSubImage(h,i);a=t.viewport,0===r&&(e.setRenderTargetTextures(g,t.colorTexture,h.ignoreDepthValues?void 0:t.depthStencilTexture),e.setRenderTarget(g))}const o=x[r];o.matrix.fromArray(i.transform.matrix),o.projectionMatrix.fromArray(i.projectionMatrix),o.viewport.set(a.x,a.y,a.width,a.height),0===r&&S.matrix.copy(o.matrix),!0===n&&S.cameras.push(o)}}const i=r.inputSources;for(let e=0;e<v.length;e++){v[e].update(i[e],n,a)}P&&P(t,n),p=null})),this.setAnimationLoop=function(e){P=e},this.dispose=function(){}}}function WebGLMaterials(e){function t(t,n){t.opacity.value=n.opacity,n.color&&t.diffuse.value.copy(n.color),n.emissive&&t.emissive.value.copy(n.emissive).multiplyScalar(n.emissiveIntensity),n.map&&(t.map.value=n.map),n.alphaMap&&(t.alphaMap.value=n.alphaMap),n.specularMap&&(t.specularMap.value=n.specularMap),n.alphaTest>0&&(t.alphaTest.value=n.alphaTest);const r=e.get(n).envMap;let i,a;r&&(t.envMap.value=r,t.flipEnvMap.value=r.isCubeTexture&&!1===r.isRenderTargetTexture?-1:1,t.reflectivity.value=n.reflectivity,t.ior.value=n.ior,t.refractionRatio.value=n.refractionRatio),n.lightMap&&(t.lightMap.value=n.lightMap,t.lightMapIntensity.value=n.lightMapIntensity),n.aoMap&&(t.aoMap.value=n.aoMap,t.aoMapIntensity.value=n.aoMapIntensity),n.map?i=n.map:n.specularMap?i=n.specularMap:n.displacementMap?i=n.displacementMap:n.normalMap?i=n.normalMap:n.bumpMap?i=n.bumpMap:n.roughnessMap?i=n.roughnessMap:n.metalnessMap?i=n.metalnessMap:n.alphaMap?i=n.alphaMap:n.emissiveMap?i=n.emissiveMap:n.clearcoatMap?i=n.clearcoatMap:n.clearcoatNormalMap?i=n.clearcoatNormalMap:n.clearcoatRoughnessMap?i=n.clearcoatRoughnessMap:n.specularIntensityMap?i=n.specularIntensityMap:n.specularColorMap?i=n.specularColorMap:n.transmissionMap?i=n.transmissionMap:n.thicknessMap?i=n.thicknessMap:n.sheenColorMap?i=n.sheenColorMap:n.sheenRoughnessMap&&(i=n.sheenRoughnessMap),void 0!==i&&(i.isWebGLRenderTarget&&(i=i.texture),!0===i.matrixAutoUpdate&&i.updateMatrix(),t.uvTransform.value.copy(i.matrix)),n.aoMap?a=n.aoMap:n.lightMap&&(a=n.lightMap),void 0!==a&&(a.isWebGLRenderTarget&&(a=a.texture),!0===a.matrixAutoUpdate&&a.updateMatrix(),t.uv2Transform.value.copy(a.matrix))}function n(t,n){t.roughness.value=n.roughness,t.metalness.value=n.metalness,n.roughnessMap&&(t.roughnessMap.value=n.roughnessMap),n.metalnessMap&&(t.metalnessMap.value=n.metalnessMap),n.emissiveMap&&(t.emissiveMap.value=n.emissiveMap),n.bumpMap&&(t.bumpMap.value=n.bumpMap,t.bumpScale.value=n.bumpScale,n.side===BackSide&&(t.bumpScale.value*=-1)),n.normalMap&&(t.normalMap.value=n.normalMap,t.normalScale.value.copy(n.normalScale),n.side===BackSide&&t.normalScale.value.negate()),n.displacementMap&&(t.displacementMap.value=n.displacementMap,t.displacementScale.value=n.displacementScale,t.displacementBias.value=n.displacementBias);e.get(n).envMap&&(t.envMapIntensity.value=n.envMapIntensity)}return{refreshFogUniforms:function r(e,t){e.fogColor.value.copy(t.color),t.isFog?(e.fogNear.value=t.near,e.fogFar.value=t.far):t.isFogExp2&&(e.fogDensity.value=t.density)},refreshMaterialUniforms:function i(e,r,a,o,s){r.isMeshBasicMaterial?t(e,r):r.isMeshLambertMaterial?(t(e,r),(function l(e,t){t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap)})(e,r)):r.isMeshToonMaterial?(t(e,r),(function c(e,t){t.gradientMap&&(e.gradientMap.value=t.gradientMap);t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap);t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,t.side===BackSide&&(e.bumpScale.value*=-1));t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),t.side===BackSide&&e.normalScale.value.negate());t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)})(e,r)):r.isMeshPhongMaterial?(t(e,r),(function h(e,t){e.specular.value.copy(t.specular),e.shininess.value=Math.max(t.shininess,1e-4),t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap);t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,t.side===BackSide&&(e.bumpScale.value*=-1));t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),t.side===BackSide&&e.normalScale.value.negate());t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)})(e,r)):r.isMeshStandardMaterial?(t(e,r),r.isMeshPhysicalMaterial?(function u(e,t,r){n(e,t),e.ior.value=t.ior,t.sheen>0&&(e.sheenColor.value.copy(t.sheenColor).multiplyScalar(t.sheen),e.sheenRoughness.value=t.sheenRoughness,t.sheenColorMap&&(e.sheenColorMap.value=t.sheenColorMap),t.sheenRoughnessMap&&(e.sheenRoughnessMap.value=t.sheenRoughnessMap));t.clearcoat>0&&(e.clearcoat.value=t.clearcoat,e.clearcoatRoughness.value=t.clearcoatRoughness,t.clearcoatMap&&(e.clearcoatMap.value=t.clearcoatMap),t.clearcoatRoughnessMap&&(e.clearcoatRoughnessMap.value=t.clearcoatRoughnessMap),t.clearcoatNormalMap&&(e.clearcoatNormalScale.value.copy(t.clearcoatNormalScale),e.clearcoatNormalMap.value=t.clearcoatNormalMap,t.side===BackSide&&e.clearcoatNormalScale.value.negate()));t.transmission>0&&(e.transmission.value=t.transmission,e.transmissionSamplerMap.value=r.texture,e.transmissionSamplerSize.value.set(r.width,r.height),t.transmissionMap&&(e.transmissionMap.value=t.transmissionMap),e.thickness.value=t.thickness,t.thicknessMap&&(e.thicknessMap.value=t.thicknessMap),e.attenuationDistance.value=t.attenuationDistance,e.attenuationColor.value.copy(t.attenuationColor));e.specularIntensity.value=t.specularIntensity,e.specularColor.value.copy(t.specularColor),t.specularIntensityMap&&(e.specularIntensityMap.value=t.specularIntensityMap);t.specularColorMap&&(e.specularColorMap.value=t.specularColorMap)})(e,r,s):n(e,r)):r.isMeshMatcapMaterial?(t(e,r),(function d(e,t){t.matcap&&(e.matcap.value=t.matcap);t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,t.side===BackSide&&(e.bumpScale.value*=-1));t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),t.side===BackSide&&e.normalScale.value.negate());t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)})(e,r)):r.isMeshDepthMaterial?(t(e,r),(function p(e,t){t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)})(e,r)):r.isMeshDistanceMaterial?(t(e,r),(function m(e,t){t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias);e.referencePosition.value.copy(t.referencePosition),e.nearDistance.value=t.nearDistance,e.farDistance.value=t.farDistance})(e,r)):r.isMeshNormalMaterial?(t(e,r),(function f(e,t){t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,t.side===BackSide&&(e.bumpScale.value*=-1));t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),t.side===BackSide&&e.normalScale.value.negate());t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)})(e,r)):r.isLineBasicMaterial?(!(function g(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity})(e,r),r.isLineDashedMaterial&&(function v(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale})(e,r)):r.isPointsMaterial?(function y(e,t,n,r){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.size.value=t.size*n,e.scale.value=.5*r,t.map&&(e.map.value=t.map);t.alphaMap&&(e.alphaMap.value=t.alphaMap);t.alphaTest>0&&(e.alphaTest.value=t.alphaTest);let i;t.map?i=t.map:t.alphaMap&&(i=t.alphaMap);void 0!==i&&(!0===i.matrixAutoUpdate&&i.updateMatrix(),e.uvTransform.value.copy(i.matrix))})(e,r,a,o):r.isSpriteMaterial?(function _(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.rotation.value=t.rotation,t.map&&(e.map.value=t.map);t.alphaMap&&(e.alphaMap.value=t.alphaMap);t.alphaTest>0&&(e.alphaTest.value=t.alphaTest);let n;t.map?n=t.map:t.alphaMap&&(n=t.alphaMap);void 0!==n&&(!0===n.matrixAutoUpdate&&n.updateMatrix(),e.uvTransform.value.copy(n.matrix))})(e,r):r.isShadowMaterial?(e.color.value.copy(r.color),e.opacity.value=r.opacity):r.isShaderMaterial&&(r.uniformsNeedUpdate=!1)}}}function createCanvasElement(){const e=createElementNS("canvas");return e.style.display="block",e}function WebGLRenderer(e={}){const t=void 0!==e.canvas?e.canvas:createCanvasElement(),n=void 0!==e.context?e.context:null,r=void 0!==e.alpha&&e.alpha,i=void 0===e.depth||e.depth,a=void 0===e.stencil||e.stencil,o=void 0!==e.antialias&&e.antialias,s=void 0===e.premultipliedAlpha||e.premultipliedAlpha,l=void 0!==e.preserveDrawingBuffer&&e.preserveDrawingBuffer,c=void 0!==e.powerPreference?e.powerPreference:"default",h=void 0!==e.failIfMajorPerformanceCaveat&&e.failIfMajorPerformanceCaveat;let u=null,d=null;const p=[],m=[];this.domElement=t,this.debug={checkShaderErrors:!0},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.outputEncoding=LinearEncoding,this.physicallyCorrectLights=!1,this.toneMapping=NoToneMapping,this.toneMappingExposure=1;const f=this;let g=!1,v=0,y=0,_=null,b=-1,x=null;const S=new Vector4,w=new Vector4;let C=null,M=t.width,E=t.height,T=1,I=null,A=null;const k=new Vector4(0,0,M,E),P=new Vector4(0,0,M,E);let R=!1;const N=new Frustum;let L=!1,D=!1,$=null;const z=new Matrix4,F=new Vector3,O={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function B(){return null===_?T:1}let V,H,U,G,W,j,q,X,K,Y,Z,J,Q,ee,te,ne,re,ie,ae,oe,se,le,ce,he=n;function ue(e,n){for(let r=0;r<e.length;r++){const i=t.getContext(e[r],n);if(null!==i)return i}return null}try{const e={alpha:!0,depth:i,stencil:a,antialias:o,premultipliedAlpha:s,preserveDrawingBuffer:l,powerPreference:c,failIfMajorPerformanceCaveat:h};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${REVISION}`),t.addEventListener("webglcontextlost",me,!1),t.addEventListener("webglcontextrestored",fe,!1),null===he){const t=["webgl2","webgl","experimental-webgl"];if(!0===f.isWebGL1Renderer&&t.shift(),he=ue(t,e),null===he)throw ue(t)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}void 0===he.getShaderPrecisionFormat&&(he.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(e){throw console.error("THREE.WebGLRenderer: "+e.message),e}function de(){V=new WebGLExtensions(he),H=new WebGLCapabilities(he,V,e),V.init(H),le=new WebGLUtils(he,V,H),U=new WebGLState(he,V,H),G=new WebGLInfo(he),W=new WebGLProperties,j=new WebGLTextures(he,V,U,W,H,le,G),q=new WebGLCubeMaps(f),X=new WebGLCubeUVMaps(f),K=new WebGLAttributes(he,H),ce=new WebGLBindingStates(he,V,K,H),Y=new WebGLGeometries(he,K,G,ce),Z=new WebGLObjects(he,Y,K,G),ae=new WebGLMorphtargets(he,H,j),ne=new WebGLClipping(W),J=new WebGLPrograms(f,q,X,V,H,ce,ne),Q=new WebGLMaterials(W),ee=new WebGLRenderLists,te=new WebGLRenderStates(V,H),ie=new WebGLBackground(f,q,U,Z,r,s),re=new WebGLShadowMap(f,Z,H),oe=new WebGLBufferRenderer(he,V,G,H),se=new WebGLIndexedBufferRenderer(he,V,G,H),G.programs=J.programs,f.capabilities=H,f.extensions=V,f.properties=W,f.renderLists=ee,f.shadowMap=re,f.state=U,f.info=G}de();const pe=new WebXRManager(f,he);function me(e){e.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),g=!0}function fe(){console.log("THREE.WebGLRenderer: Context Restored."),g=!1;const e=G.autoReset,t=re.enabled,n=re.autoUpdate,r=re.needsUpdate,i=re.type;de(),G.autoReset=e,re.enabled=t,re.autoUpdate=n,re.needsUpdate=r,re.type=i}function ge(e){const t=e.target;t.removeEventListener("dispose",ge),(function n(e){(function t(e){const t=W.get(e).programs;void 0!==t&&(t.forEach((function(e){J.releaseProgram(e)})),e.isShaderMaterial&&J.releaseShaderCache(e))})(e),W.remove(e)})(t)}this.xr=pe,this.getContext=function(){return he},this.getContextAttributes=function(){return he.getContextAttributes()},this.forceContextLoss=function(){const e=V.get("WEBGL_lose_context");e&&e.loseContext()},this.forceContextRestore=function(){const e=V.get("WEBGL_lose_context");e&&e.restoreContext()},this.getPixelRatio=function(){return T},this.setPixelRatio=function(e){void 0!==e&&(T=e,this.setSize(M,E,!1))},this.getSize=function(e){return e.set(M,E)},this.setSize=function(e,n,r){pe.isPresenting?console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting."):(M=e,E=n,t.width=Math.floor(e*T),t.height=Math.floor(n*T),!1!==r&&(t.style.width=e+"px",t.style.height=n+"px"),this.setViewport(0,0,e,n))},this.getDrawingBufferSize=function(e){return e.set(M*T,E*T).floor()},this.setDrawingBufferSize=function(e,n,r){M=e,E=n,T=r,t.width=Math.floor(e*r),t.height=Math.floor(n*r),this.setViewport(0,0,e,n)},this.getCurrentViewport=function(e){return e.copy(S)},this.getViewport=function(e){return e.copy(k)},this.setViewport=function(e,t,n,r){e.isVector4?k.set(e.x,e.y,e.z,e.w):k.set(e,t,n,r),U.viewport(S.copy(k).multiplyScalar(T).floor())},this.getScissor=function(e){return e.copy(P)},this.setScissor=function(e,t,n,r){e.isVector4?P.set(e.x,e.y,e.z,e.w):P.set(e,t,n,r),U.scissor(w.copy(P).multiplyScalar(T).floor())},this.getScissorTest=function(){return R},this.setScissorTest=function(e){U.setScissorTest(R=e)},this.setOpaqueSort=function(e){I=e},this.setTransparentSort=function(e){A=e},this.getClearColor=function(e){return e.copy(ie.getClearColor())},this.setClearColor=function(){ie.setClearColor.apply(ie,arguments)},this.getClearAlpha=function(){return ie.getClearAlpha()},this.setClearAlpha=function(){ie.setClearAlpha.apply(ie,arguments)},this.clear=function(e,t,n){let r=0;(void 0===e||e)&&(r|=16384),(void 0===t||t)&&(r|=256),(void 0===n||n)&&(r|=1024),he.clear(r)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",me,!1),t.removeEventListener("webglcontextrestored",fe,!1),ee.dispose(),te.dispose(),W.dispose(),q.dispose(),X.dispose(),Z.dispose(),ce.dispose(),J.dispose(),pe.dispose(),pe.removeEventListener("sessionstart",ye),pe.removeEventListener("sessionend",_e),$&&($.dispose(),$=null),be.stop()},this.renderBufferDirect=function(e,t,n,r,i,a){null===t&&(t=O);const o=i.isMesh&&i.matrixWorld.determinant()<0,s=(function l(e,t,n,r,i){!0!==t.isScene&&(t=O);j.resetTextureUnits();const a=t.fog,o=r.isMeshStandardMaterial?t.environment:null,s=null===_?f.outputEncoding:!0===_.isXRRenderTarget?_.texture.encoding:LinearEncoding,l=(r.isMeshStandardMaterial?X:q).get(r.envMap||o),c=!0===r.vertexColors&&!!n.attributes.color&&4===n.attributes.color.itemSize,h=!!r.normalMap&&!!n.attributes.tangent,u=!!n.morphAttributes.position,p=!!n.morphAttributes.normal,m=n.morphAttributes.position?n.morphAttributes.position.length:0,g=r.toneMapped?f.toneMapping:NoToneMapping,v=W.get(r),y=d.state.lights;if(!0===L&&(!0===D||e!==x)){ne.setState(r,e,e===x&&r.id===b)}let S=!1;r.version===v.__version?v.needsLights&&v.lightsStateVersion!==y.state.version||v.outputEncoding!==s||i.isInstancedMesh&&!1===v.instancing?S=!0:i.isInstancedMesh||!0!==v.instancing?i.isSkinnedMesh&&!1===v.skinning?S=!0:i.isSkinnedMesh||!0!==v.skinning?v.envMap!==l||r.fog&&v.fog!==a?S=!0:void 0===v.numClippingPlanes||v.numClippingPlanes===ne.numPlanes&&v.numIntersection===ne.numIntersection?(v.vertexAlphas!==c||v.vertexTangents!==h||v.morphTargets!==u||v.morphNormals!==p||v.toneMapping!==g||!0===H.isWebGL2&&v.morphTargetsCount!==m)&&(S=!0):S=!0:S=!0:S=!0:(S=!0,v.__version=r.version);let w=v.currentProgram;!0===S&&(w=Me(r,t,i));let C=!1,M=!1,I=!1;const A=w.getUniforms(),k=v.uniforms;U.useProgram(w.program)&&(C=!0,M=!0,I=!0);r.id!==b&&(b=r.id,M=!0);if(C||x!==e){if(A.setValue(he,"projectionMatrix",e.projectionMatrix),H.logarithmicDepthBuffer&&A.setValue(he,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),x!==e&&(x=e,M=!0,I=!0),r.isShaderMaterial||r.isMeshPhongMaterial||r.isMeshToonMaterial||r.isMeshStandardMaterial||r.envMap){const t=A.map.cameraPosition;void 0!==t&&t.setValue(he,F.setFromMatrixPosition(e.matrixWorld))}(r.isMeshPhongMaterial||r.isMeshToonMaterial||r.isMeshLambertMaterial||r.isMeshBasicMaterial||r.isMeshStandardMaterial||r.isShaderMaterial)&&A.setValue(he,"isOrthographic",!0===e.isOrthographicCamera),(r.isMeshPhongMaterial||r.isMeshToonMaterial||r.isMeshLambertMaterial||r.isMeshBasicMaterial||r.isMeshStandardMaterial||r.isShaderMaterial||r.isShadowMaterial||i.isSkinnedMesh)&&A.setValue(he,"viewMatrix",e.matrixWorldInverse)}if(i.isSkinnedMesh){A.setOptional(he,i,"bindMatrix"),A.setOptional(he,i,"bindMatrixInverse");const e=i.skeleton;e&&(H.floatVertexTextures?(null===e.boneTexture&&e.computeBoneTexture(),A.setValue(he,"boneTexture",e.boneTexture,j),A.setValue(he,"boneTextureSize",e.boneTextureSize)):A.setOptional(he,e,"boneMatrices"))}!n||void 0===n.morphAttributes.position&&void 0===n.morphAttributes.normal||ae.update(i,n,r,w);(M||v.receiveShadow!==i.receiveShadow)&&(v.receiveShadow=i.receiveShadow,A.setValue(he,"receiveShadow",i.receiveShadow));M&&(A.setValue(he,"toneMappingExposure",f.toneMappingExposure),v.needsLights&&(function P(e,t){e.ambientLightColor.needsUpdate=t,e.lightProbe.needsUpdate=t,e.directionalLights.needsUpdate=t,e.directionalLightShadows.needsUpdate=t,e.pointLights.needsUpdate=t,e.pointLightShadows.needsUpdate=t,e.spotLights.needsUpdate=t,e.spotLightShadows.needsUpdate=t,e.rectAreaLights.needsUpdate=t,e.hemisphereLights.needsUpdate=t})(k,I),a&&r.fog&&Q.refreshFogUniforms(k,a),Q.refreshMaterialUniforms(k,r,T,E,$),WebGLUniforms.upload(he,v.uniformsList,k,j));r.isShaderMaterial&&!0===r.uniformsNeedUpdate&&(WebGLUniforms.upload(he,v.uniformsList,k,j),r.uniformsNeedUpdate=!1);r.isSpriteMaterial&&A.setValue(he,"center",i.center);return A.setValue(he,"modelViewMatrix",i.modelViewMatrix),A.setValue(he,"normalMatrix",i.normalMatrix),A.setValue(he,"modelMatrix",i.matrixWorld),w})(e,t,n,r,i);U.setMaterial(r,o);let c=n.index;const h=n.attributes.position;if(null===c){if(void 0===h||0===h.count)return}else if(0===c.count)return;let u,p=1;!0===r.wireframe&&(c=Y.getWireframeAttribute(n),p=2),ce.setup(i,r,s,n,c);let m=oe;null!==c&&(u=K.get(c),m=se,m.setIndex(u));const g=null!==c?c.count:h.count,v=n.drawRange.start*p,y=n.drawRange.count*p,S=null!==a?a.start*p:0,w=null!==a?a.count*p:1/0,C=Math.max(v,S),M=Math.min(g,v+y,S+w)-1,I=Math.max(0,M-C+1);if(0!==I){if(i.isMesh)!0===r.wireframe?(U.setLineWidth(r.wireframeLinewidth*B()),m.setMode(1)):m.setMode(4);else if(i.isLine){let e=r.linewidth;void 0===e&&(e=1),U.setLineWidth(e*B()),m.setMode(i.isLineSegments?1:i.isLineLoop?2:3)}else i.isPoints?m.setMode(0):i.isSprite&&m.setMode(4);if(i.isInstancedMesh)m.renderInstances(C,I,i.count);else if(n.isInstancedBufferGeometry){const e=Math.min(n.instanceCount,n._maxInstanceCount);m.renderInstances(C,I,e)}else m.render(C,I)}},this.compile=function(e,t){d=te.get(e),d.init(),m.push(d),e.traverseVisible((function(e){e.isLight&&e.layers.test(t.layers)&&(d.pushLight(e),e.castShadow&&d.pushShadow(e))})),d.setupLights(f.physicallyCorrectLights),e.traverse((function(t){const n=t.material;if(n)if(Array.isArray(n))for(let r=0;r<n.length;r++){Me(n[r],e,t)}else Me(n,e,t)})),m.pop(),d=null};let ve=null;function ye(){be.stop()}function _e(){be.start()}const be=new WebGLAnimation;function xe(e,t,n,r){if(!1===e.visible)return;if(e.layers.test(t.layers))if(e.isGroup)n=e.renderOrder;else if(e.isLOD)!0===e.autoUpdate&&e.update(t);else if(e.isLight)d.pushLight(e),e.castShadow&&d.pushShadow(e);else if(e.isSprite){if(!e.frustumCulled||N.intersectsSprite(e)){r&&F.setFromMatrixPosition(e.matrixWorld).applyMatrix4(z);const t=Z.update(e),i=e.material;i.visible&&u.push(e,t,i,n,F.z,null)}}else if((e.isMesh||e.isLine||e.isPoints)&&(e.isSkinnedMesh&&e.skeleton.frame!==G.render.frame&&(e.skeleton.update(),e.skeleton.frame=G.render.frame),!e.frustumCulled||N.intersectsObject(e))){r&&F.setFromMatrixPosition(e.matrixWorld).applyMatrix4(z);const t=Z.update(e),i=e.material;if(Array.isArray(i)){const r=t.groups;for(let a=0,o=r.length;a<o;a++){const o=r[a],s=i[o.materialIndex];s&&s.visible&&u.push(e,t,s,n,F.z,o)}}else i.visible&&u.push(e,t,i,n,F.z,null)}const i=e.children;for(let e=0,a=i.length;e<a;e++)xe(i[e],t,n,r)}function Se(e,t,n,r){const i=e.opaque,a=e.transmissive,s=e.transparent;d.setupLightsView(n),a.length>0&&(function l(e,t,n){if(null===$){$=new(!0===o&&!0===H.isWebGL2?WebGLMultisampleRenderTarget:WebGLRenderTarget)(1024,1024,{generateMipmaps:!0,type:null!==le.convert(HalfFloatType)?HalfFloatType:UnsignedByteType,minFilter:LinearMipmapLinearFilter,magFilter:NearestFilter,wrapS:ClampToEdgeWrapping,wrapT:ClampToEdgeWrapping,useRenderToTexture:V.has("WEBGL_multisampled_render_to_texture")})}const r=f.getRenderTarget();f.setRenderTarget($),f.clear();const i=f.toneMapping;f.toneMapping=NoToneMapping,we(e,t,n),f.toneMapping=i,j.updateMultisampleRenderTarget($),j.updateRenderTargetMipmap($),f.setRenderTarget(r)})(i,t,n),r&&U.viewport(S.copy(r)),i.length>0&&we(i,t,n),a.length>0&&we(a,t,n),s.length>0&&we(s,t,n)}function we(e,t,n){const r=!0===t.isScene?t.overrideMaterial:null;for(let i=0,a=e.length;i<a;i++){const a=e[i],o=a.object,s=a.geometry,l=null===r?a.material:r,c=a.group;o.layers.test(n.layers)&&Ce(o,t,n,s,l,c)}}function Ce(e,t,n,r,i,a){e.onBeforeRender(f,t,n,r,i,a),e.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix),i.onBeforeRender(f,t,n,r,e,a),!0===i.transparent&&i.side===DoubleSide?(i.side=BackSide,i.needsUpdate=!0,f.renderBufferDirect(n,t,r,i,e,a),i.side=FrontSide,i.needsUpdate=!0,f.renderBufferDirect(n,t,r,i,e,a),i.side=DoubleSide):f.renderBufferDirect(n,t,r,i,e,a),e.onAfterRender(f,t,n,r,i,a)}function Me(e,t,n){!0!==t.isScene&&(t=O);const r=W.get(e),i=d.state.lights,a=i.state.version,o=J.getParameters(e,i.state,d.state.shadowsArray,t,n),s=J.getProgramCacheKey(o);let l=r.programs;r.environment=e.isMeshStandardMaterial?t.environment:null,r.fog=t.fog,r.envMap=(e.isMeshStandardMaterial?X:q).get(e.envMap||r.environment),void 0===l&&(e.addEventListener("dispose",ge),l=new Map,r.programs=l);let c=l.get(s);if(void 0!==c){if(r.currentProgram===c&&r.lightsStateVersion===a)return Ee(e,o),c}else o.uniforms=J.getUniforms(e),e.onBuild(n,o,f),e.onBeforeCompile(o,f),c=J.acquireProgram(o,s),l.set(s,c),r.uniforms=o.uniforms;const h=r.uniforms;(e.isShaderMaterial||e.isRawShaderMaterial)&&!0!==e.clipping||(h.clippingPlanes=ne.uniform),Ee(e,o),r.needsLights=(function u(e){return e.isMeshLambertMaterial||e.isMeshToonMaterial||e.isMeshPhongMaterial||e.isMeshStandardMaterial||e.isShadowMaterial||e.isShaderMaterial&&!0===e.lights})(e),r.lightsStateVersion=a,r.needsLights&&(h.ambientLightColor.value=i.state.ambient,h.lightProbe.value=i.state.probe,h.directionalLights.value=i.state.directional,h.directionalLightShadows.value=i.state.directionalShadow,h.spotLights.value=i.state.spot,h.spotLightShadows.value=i.state.spotShadow,h.rectAreaLights.value=i.state.rectArea,h.ltc_1.value=i.state.rectAreaLTC1,h.ltc_2.value=i.state.rectAreaLTC2,h.pointLights.value=i.state.point,h.pointLightShadows.value=i.state.pointShadow,h.hemisphereLights.value=i.state.hemi,h.directionalShadowMap.value=i.state.directionalShadowMap,h.directionalShadowMatrix.value=i.state.directionalShadowMatrix,h.spotShadowMap.value=i.state.spotShadowMap,h.spotShadowMatrix.value=i.state.spotShadowMatrix,h.pointShadowMap.value=i.state.pointShadowMap,h.pointShadowMatrix.value=i.state.pointShadowMatrix);const p=c.getUniforms(),m=WebGLUniforms.seqWithValue(p.seq,h);return r.currentProgram=c,r.uniformsList=m,c}function Ee(e,t){const n=W.get(e);n.outputEncoding=t.outputEncoding,n.instancing=t.instancing,n.skinning=t.skinning,n.morphTargets=t.morphTargets,n.morphNormals=t.morphNormals,n.morphTargetsCount=t.morphTargetsCount,n.numClippingPlanes=t.numClippingPlanes,n.numIntersection=t.numClipIntersection,n.vertexAlphas=t.vertexAlphas,n.vertexTangents=t.vertexTangents,n.toneMapping=t.toneMapping}be.setAnimationLoop((function Te(e){ve&&ve(e)})),"undefined"!=typeof window&&be.setContext(window),this.setAnimationLoop=function(e){ve=e,pe.setAnimationLoop(e),null===e?be.stop():be.start()},pe.addEventListener("sessionstart",ye),pe.addEventListener("sessionend",_e),this.render=function(e,t){if(void 0!==t&&!0!==t.isCamera)return void console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");if(!0===g)return;!0===e.autoUpdate&&e.updateMatrixWorld(),null===t.parent&&t.updateMatrixWorld(),!0===pe.enabled&&!0===pe.isPresenting&&(!0===pe.cameraAutoUpdate&&pe.updateCamera(t),t=pe.getCamera()),!0===e.isScene&&e.onBeforeRender(f,e,t,_),d=te.get(e,m.length),d.init(),m.push(d),z.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),N.setFromProjectionMatrix(z),D=this.localClippingEnabled,L=ne.init(this.clippingPlanes,D,t),u=ee.get(e,p.length),u.init(),p.push(u),xe(e,t,0,f.sortObjects),u.finish(),!0===f.sortObjects&&u.sort(I,A),!0===L&&ne.beginShadows();if(re.render(d.state.shadowsArray,e,t),!0===L&&ne.endShadows(),!0===this.info.autoReset&&this.info.reset(),ie.render(u,e),d.setupLights(f.physicallyCorrectLights),t.isArrayCamera){const n=t.cameras;for(let t=0,r=n.length;t<r;t++){const r=n[t];Se(u,e,r,r.viewport)}}else Se(u,e,t);null!==_&&(j.updateMultisampleRenderTarget(_),j.updateRenderTargetMipmap(_)),!0===e.isScene&&e.onAfterRender(f,e,t),U.buffers.depth.setTest(!0),U.buffers.depth.setMask(!0),U.buffers.color.setMask(!0),U.setPolygonOffset(!1),ce.resetDefaultState(),b=-1,x=null,m.pop(),d=m.length>0?m[m.length-1]:null,p.pop(),u=p.length>0?p[p.length-1]:null},this.getActiveCubeFace=function(){return v},this.getActiveMipmapLevel=function(){return y},this.getRenderTarget=function(){return _},this.setRenderTargetTextures=function(e,t,n){W.get(e.texture).__webglTexture=t,W.get(e.depthTexture).__webglTexture=n;const r=W.get(e);r.__hasExternalTextures=!0,r.__hasExternalTextures&&(r.__autoAllocateDepthBuffer=void 0===n,r.__autoAllocateDepthBuffer||e.useRenderToTexture&&(console.warn("render-to-texture extension was disabled because an external texture was provided"),e.useRenderToTexture=!1,e.useRenderbuffer=!0))},this.setRenderTargetFramebuffer=function(e,t){const n=W.get(e);n.__webglFramebuffer=t,n.__useDefaultFramebuffer=void 0===t},this.setRenderTarget=function(e,t=0,n=0){_=e,v=t,y=n;let r=!0;if(e){const t=W.get(e);void 0!==t.__useDefaultFramebuffer?(U.bindFramebuffer(36160,null),r=!1):void 0===t.__webglFramebuffer?j.setupRenderTarget(e):t.__hasExternalTextures&&j.rebindTextures(e,W.get(e.texture).__webglTexture,W.get(e.depthTexture).__webglTexture)}let i=null,a=!1,o=!1;if(e){const n=e.texture;(n.isDataTexture3D||n.isDataTexture2DArray)&&(o=!0);const r=W.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(i=r[t],a=!0):i=e.useRenderbuffer?W.get(e).__webglMultisampledFramebuffer:r,S.copy(e.viewport),w.copy(e.scissor),C=e.scissorTest}else S.copy(k).multiplyScalar(T).floor(),w.copy(P).multiplyScalar(T).floor(),C=R;if(U.bindFramebuffer(36160,i)&&H.drawBuffers&&r&&U.drawBuffers(e,i),U.viewport(S),U.scissor(w),U.setScissorTest(C),a){const r=W.get(e.texture);he.framebufferTexture2D(36160,36064,34069+t,r.__webglTexture,n)}else if(o){const r=W.get(e.texture);he.framebufferTextureLayer(36160,36064,r.__webglTexture,n||0,t||0)}b=-1},this.readRenderTargetPixels=function(e,t,n,r,i,a,o){if(!e||!e.isWebGLRenderTarget)return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let s=W.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==o&&(s=s[o]),s){U.bindFramebuffer(36160,s);try{const o=e.texture,s=o.format,l=o.type;if(s!==RGBAFormat&&le.convert(s)!==he.getParameter(35739))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");const c=l===HalfFloatType&&(V.has("EXT_color_buffer_half_float")||H.isWebGL2&&V.has("EXT_color_buffer_float"));if(!(l===UnsignedByteType||le.convert(l)===he.getParameter(35738)||l===FloatType&&(H.isWebGL2||V.has("OES_texture_float")||V.has("WEBGL_color_buffer_float"))||c))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");36053===he.checkFramebufferStatus(36160)?t>=0&&t<=e.width-r&&n>=0&&n<=e.height-i&&he.readPixels(t,n,r,i,le.convert(s),le.convert(l),a):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{const e=null!==_?W.get(_).__webglFramebuffer:null;U.bindFramebuffer(36160,e)}}},this.copyFramebufferToTexture=function(e,t,n=0){if(!0!==t.isFramebufferTexture)return void console.error("THREE.WebGLRenderer: copyFramebufferToTexture() can only be used with FramebufferTexture.");const r=Math.pow(2,-n),i=Math.floor(t.image.width*r),a=Math.floor(t.image.height*r);j.setTexture2D(t,0),he.copyTexSubImage2D(3553,n,0,0,e.x,e.y,i,a),U.unbindTexture()},this.copyTextureToTexture=function(e,t,n,r=0){const i=t.image.width,a=t.image.height,o=le.convert(n.format),s=le.convert(n.type);j.setTexture2D(n,0),he.pixelStorei(37440,n.flipY),he.pixelStorei(37441,n.premultiplyAlpha),he.pixelStorei(3317,n.unpackAlignment),t.isDataTexture?he.texSubImage2D(3553,r,e.x,e.y,i,a,o,s,t.image.data):t.isCompressedTexture?he.compressedTexSubImage2D(3553,r,e.x,e.y,t.mipmaps[0].width,t.mipmaps[0].height,o,t.mipmaps[0].data):he.texSubImage2D(3553,r,e.x,e.y,o,s,t.image),0===r&&n.generateMipmaps&&he.generateMipmap(3553),U.unbindTexture()},this.copyTextureToTexture3D=function(e,t,n,r,i=0){if(f.isWebGL1Renderer)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");const a=e.max.x-e.min.x+1,o=e.max.y-e.min.y+1,s=e.max.z-e.min.z+1,l=le.convert(r.format),c=le.convert(r.type);let h;if(r.isDataTexture3D)j.setTexture3D(r,0),h=32879;else{if(!r.isDataTexture2DArray)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");j.setTexture2DArray(r,0),h=35866}he.pixelStorei(37440,r.flipY),he.pixelStorei(37441,r.premultiplyAlpha),he.pixelStorei(3317,r.unpackAlignment);const u=he.getParameter(3314),d=he.getParameter(32878),p=he.getParameter(3316),m=he.getParameter(3315),g=he.getParameter(32877),v=n.isCompressedTexture?n.mipmaps[0]:n.image;he.pixelStorei(3314,v.width),he.pixelStorei(32878,v.height),he.pixelStorei(3316,e.min.x),he.pixelStorei(3315,e.min.y),he.pixelStorei(32877,e.min.z),n.isDataTexture||n.isDataTexture3D?he.texSubImage3D(h,i,t.x,t.y,t.z,a,o,s,l,c,v.data):n.isCompressedTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),he.compressedTexSubImage3D(h,i,t.x,t.y,t.z,a,o,s,l,v.data)):he.texSubImage3D(h,i,t.x,t.y,t.z,a,o,s,l,c,v),he.pixelStorei(3314,u),he.pixelStorei(32878,d),he.pixelStorei(3316,p),he.pixelStorei(3315,m),he.pixelStorei(32877,g),0===i&&r.generateMipmaps&&he.generateMipmap(h),U.unbindTexture()},this.initTexture=function(e){j.setTexture2D(e,0),U.unbindTexture()},this.resetState=function(){v=0,y=0,_=null,U.reset(),ce.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}WebGLRenderer.prototype.isWebGLRenderer=!0;class WebGL1Renderer extends WebGLRenderer{}WebGL1Renderer.prototype.isWebGL1Renderer=!0;class Fog{constructor(e,t=1,n=1e3){this.name="",this.color=new Color$1(e),this.near=t,this.far=n}clone(){return new Fog(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}}Fog.prototype.isFog=!0;class Scene extends Object3D{constructor(){super(),this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),null!==e.background&&(this.background=e.background.clone()),null!==e.environment&&(this.environment=e.environment.clone()),null!==e.fog&&(this.fog=e.fog.clone()),null!==e.overrideMaterial&&(this.overrideMaterial=e.overrideMaterial.clone()),this.autoUpdate=e.autoUpdate,this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return null!==this.fog&&(t.object.fog=this.fog.toJSON()),t}}Scene.prototype.isScene=!0;class InterleavedBuffer{constructor(e,t){this.array=e,this.stride=t,this.count=void 0!==e?e.length/t:0,this.usage=StaticDrawUsage,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=generateUUID()}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let r=0,i=this.stride;r<i;r++)this.array[e+r]=t.array[n+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){void 0===e.arrayBuffers&&(e.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=generateUUID()),void 0===e.arrayBuffers[this.array.buffer._uuid]&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return void 0===e.arrayBuffers&&(e.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=generateUUID()),void 0===e.arrayBuffers[this.array.buffer._uuid]&&(e.arrayBuffers[this.array.buffer._uuid]=Array.prototype.slice.call(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}InterleavedBuffer.prototype.isInterleavedBuffer=!0;const _vector$6=new Vector3;class InterleavedBufferAttribute{constructor(e,t,n,r=!1){this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=!0===r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)_vector$6.x=this.getX(t),_vector$6.y=this.getY(t),_vector$6.z=this.getZ(t),_vector$6.applyMatrix4(e),this.setXYZ(t,_vector$6.x,_vector$6.y,_vector$6.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)_vector$6.x=this.getX(t),_vector$6.y=this.getY(t),_vector$6.z=this.getZ(t),_vector$6.applyNormalMatrix(e),this.setXYZ(t,_vector$6.x,_vector$6.y,_vector$6.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)_vector$6.x=this.getX(t),_vector$6.y=this.getY(t),_vector$6.z=this.getZ(t),_vector$6.transformDirection(e),this.setXYZ(t,_vector$6.x,_vector$6.y,_vector$6.z);return this}setX(e,t){return this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){return this.data.array[e*this.data.stride+this.offset]}getY(e){return this.data.array[e*this.data.stride+this.offset+1]}getZ(e){return this.data.array[e*this.data.stride+this.offset+2]}getW(e){return this.data.array[e*this.data.stride+this.offset+3]}setXY(e,t,n){return this.data.array[(e=e*this.data.stride+this.offset)+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,r){return this.data.array[(e=e*this.data.stride+this.offset)+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this}setXYZW(e,t,n,r,i){return this.data.array[(e=e*this.data.stride+this.offset)+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this.data.array[e+3]=i,this}clone(e){if(void 0===e){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interlaved buffer attribute will deinterleave buffer data.");const e=[];for(let t=0;t<this.count;t++){const n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return new BufferAttribute(new this.array.constructor(e),this.itemSize,this.normalized)}return void 0===e.interleavedBuffers&&(e.interleavedBuffers={}),void 0===e.interleavedBuffers[this.data.uuid]&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new InterleavedBufferAttribute(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(void 0===e){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interlaved buffer attribute will deinterleave buffer data.");const e=[];for(let t=0;t<this.count;t++){const n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}return void 0===e.interleavedBuffers&&(e.interleavedBuffers={}),void 0===e.interleavedBuffers[this.data.uuid]&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}InterleavedBufferAttribute.prototype.isInterleavedBufferAttribute=!0;class SpriteMaterial extends Material{constructor(e){super(),this.type="SpriteMaterial",this.color=new Color$1(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this}}let _geometry;SpriteMaterial.prototype.isSpriteMaterial=!0;const _intersectPoint=new Vector3,_worldScale=new Vector3,_mvPosition=new Vector3,_alignedPosition=new Vector2,_rotatedPosition=new Vector2,_viewWorldMatrix=new Matrix4,_vA=new Vector3,_vB=new Vector3,_vC=new Vector3,_uvA=new Vector2,_uvB=new Vector2,_uvC=new Vector2;class Sprite extends Object3D{constructor(e){if(super(),this.type="Sprite",void 0===_geometry){_geometry=new BufferGeometry;const e=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),t=new InterleavedBuffer(e,5);_geometry.setIndex([0,1,2,0,2,3]),_geometry.setAttribute("position",new InterleavedBufferAttribute(t,3,0,!1)),_geometry.setAttribute("uv",new InterleavedBufferAttribute(t,2,3,!1))}this.geometry=_geometry,this.material=void 0!==e?e:new SpriteMaterial,this.center=new Vector2(.5,.5)}raycast(e,t){null===e.camera&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),_worldScale.setFromMatrixScale(this.matrixWorld),_viewWorldMatrix.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),_mvPosition.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&!1===this.material.sizeAttenuation&&_worldScale.multiplyScalar(-_mvPosition.z);const n=this.material.rotation;let r,i;0!==n&&(i=Math.cos(n),r=Math.sin(n));const a=this.center;transformVertex(_vA.set(-.5,-.5,0),_mvPosition,a,_worldScale,r,i),transformVertex(_vB.set(.5,-.5,0),_mvPosition,a,_worldScale,r,i),transformVertex(_vC.set(.5,.5,0),_mvPosition,a,_worldScale,r,i),_uvA.set(0,0),_uvB.set(1,0),_uvC.set(1,1);let o=e.ray.intersectTriangle(_vA,_vB,_vC,!1,_intersectPoint);if(null===o&&(transformVertex(_vB.set(-.5,.5,0),_mvPosition,a,_worldScale,r,i),_uvB.set(0,1),o=e.ray.intersectTriangle(_vA,_vC,_vB,!1,_intersectPoint),null===o))return;const s=e.ray.origin.distanceTo(_intersectPoint);s<e.near||s>e.far||t.push({distance:s,point:_intersectPoint.clone(),uv:Triangle.getUV(_intersectPoint,_vA,_vB,_vC,_uvA,_uvB,_uvC,new Vector2),face:null,object:this})}copy(e){return super.copy(e),void 0!==e.center&&this.center.copy(e.center),this.material=e.material,this}}function transformVertex(e,t,n,r,i,a){_alignedPosition.subVectors(e,n).addScalar(.5).multiply(r),void 0!==i?(_rotatedPosition.x=a*_alignedPosition.x-i*_alignedPosition.y,_rotatedPosition.y=i*_alignedPosition.x+a*_alignedPosition.y):_rotatedPosition.copy(_alignedPosition),e.copy(t),e.x+=_rotatedPosition.x,e.y+=_rotatedPosition.y,e.applyMatrix4(_viewWorldMatrix)}Sprite.prototype.isSprite=!0;const _basePosition=new Vector3,_skinIndex=new Vector4,_skinWeight=new Vector4,_vector$5=new Vector3,_matrix=new Matrix4;class SkinnedMesh extends Mesh{constructor(e,t){super(e,t),this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new Matrix4,this.bindMatrixInverse=new Matrix4}copy(e){return super.copy(e),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,this}bind(e,t){this.skeleton=e,void 0===t&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new Vector4,t=this.geometry.attributes.skinWeight;for(let n=0,r=t.count;n<r;n++){e.x=t.getX(n),e.y=t.getY(n),e.z=t.getZ(n),e.w=t.getW(n);const r=1/e.manhattanLength();r!==1/0?e.multiplyScalar(r):e.set(1,0,0,0),t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),"attached"===this.bindMode?this.bindMatrixInverse.copy(this.matrixWorld).invert():"detached"===this.bindMode?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}boneTransform(e,t){const n=this.skeleton,r=this.geometry;_skinIndex.fromBufferAttribute(r.attributes.skinIndex,e),_skinWeight.fromBufferAttribute(r.attributes.skinWeight,e),_basePosition.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let e=0;e<4;e++){const r=_skinWeight.getComponent(e);if(0!==r){const i=_skinIndex.getComponent(e);_matrix.multiplyMatrices(n.bones[i].matrixWorld,n.boneInverses[i]),t.addScaledVector(_vector$5.copy(_basePosition).applyMatrix4(_matrix),r)}}return t.applyMatrix4(this.bindMatrixInverse)}}SkinnedMesh.prototype.isSkinnedMesh=!0;class Bone extends Object3D{constructor(){super(),this.type="Bone"}}Bone.prototype.isBone=!0;class DataTexture extends Texture{constructor(e=null,t=1,n=1,r,i,a,o,s,l=NearestFilter,c=NearestFilter,h,u){super(null,a,o,s,l,c,r,i,h,u),this.image={data:e,width:t,height:n},this.magFilter=l,this.minFilter=c,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}DataTexture.prototype.isDataTexture=!0;class InstancedBufferAttribute extends BufferAttribute{constructor(e,t,n,r=1){"number"==typeof n&&(r=n,n=!1,console.error("THREE.InstancedBufferAttribute: The constructor now expects normalized as the third argument.")),super(e,t,n),this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}InstancedBufferAttribute.prototype.isInstancedBufferAttribute=!0;const _instanceLocalMatrix=new Matrix4,_instanceWorldMatrix=new Matrix4,_instanceIntersects=[],_mesh=new Mesh;class InstancedMesh extends Mesh{constructor(e,t,n){super(e,t),this.instanceMatrix=new InstancedBufferAttribute(new Float32Array(16*n),16),this.instanceColor=null,this.count=n,this.frustumCulled=!1}copy(e){return super.copy(e),this.instanceMatrix.copy(e.instanceMatrix),null!==e.instanceColor&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,this}getColorAt(e,t){t.fromArray(this.instanceColor.array,3*e)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,16*e)}raycast(e,t){const n=this.matrixWorld,r=this.count;if(_mesh.geometry=this.geometry,_mesh.material=this.material,void 0!==_mesh.material)for(let i=0;i<r;i++){this.getMatrixAt(i,_instanceLocalMatrix),_instanceWorldMatrix.multiplyMatrices(n,_instanceLocalMatrix),_mesh.matrixWorld=_instanceWorldMatrix,_mesh.raycast(e,_instanceIntersects);for(let e=0,n=_instanceIntersects.length;e<n;e++){const n=_instanceIntersects[e];n.instanceId=i,n.object=this,t.push(n)}_instanceIntersects.length=0}}setColorAt(e,t){null===this.instanceColor&&(this.instanceColor=new InstancedBufferAttribute(new Float32Array(3*this.instanceMatrix.count),3)),t.toArray(this.instanceColor.array,3*e)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,16*e)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"})}}InstancedMesh.prototype.isInstancedMesh=!0;class LineBasicMaterial extends Material{constructor(e){super(),this.type="LineBasicMaterial",this.color=new Color$1(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this}}LineBasicMaterial.prototype.isLineBasicMaterial=!0;const _start$1=new Vector3,_end$1=new Vector3,_inverseMatrix$1=new Matrix4,_ray$1=new Ray,_sphere$1=new Sphere;class Line extends Object3D{constructor(e=new BufferGeometry,t=new LineBasicMaterial){super(),this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e){return super.copy(e),this.material=e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.isBufferGeometry)if(null===e.index){const t=e.attributes.position,n=[0];for(let e=1,r=t.count;e<r;e++)_start$1.fromBufferAttribute(t,e-1),_end$1.fromBufferAttribute(t,e),n[e]=n[e-1],n[e]+=_start$1.distanceTo(_end$1);e.setAttribute("lineDistance",new Float32BufferAttribute(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");else e.isGeometry&&console.error("THREE.Line.computeLineDistances() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.");return this}raycast(e,t){const n=this.geometry,r=this.matrixWorld,i=e.params.Line.threshold,a=n.drawRange;if(null===n.boundingSphere&&n.computeBoundingSphere(),_sphere$1.copy(n.boundingSphere),_sphere$1.applyMatrix4(r),_sphere$1.radius+=i,!1===e.ray.intersectsSphere(_sphere$1))return;_inverseMatrix$1.copy(r).invert(),_ray$1.copy(e.ray).applyMatrix4(_inverseMatrix$1);const o=i/((this.scale.x+this.scale.y+this.scale.z)/3),s=o*o,l=new Vector3,c=new Vector3,h=new Vector3,u=new Vector3,d=this.isLineSegments?2:1;if(n.isBufferGeometry){const r=n.index,i=n.attributes.position;if(null!==r){for(let n=Math.max(0,a.start),o=Math.min(r.count,a.start+a.count)-1;n<o;n+=d){const a=r.getX(n),o=r.getX(n+1);l.fromBufferAttribute(i,a),c.fromBufferAttribute(i,o);if(_ray$1.distanceSqToSegment(l,c,u,h)>s)continue;u.applyMatrix4(this.matrixWorld);const d=e.ray.origin.distanceTo(u);d<e.near||d>e.far||t.push({distance:d,point:h.clone().applyMatrix4(this.matrixWorld),index:n,face:null,faceIndex:null,object:this})}}else{for(let n=Math.max(0,a.start),r=Math.min(i.count,a.start+a.count)-1;n<r;n+=d){l.fromBufferAttribute(i,n),c.fromBufferAttribute(i,n+1);if(_ray$1.distanceSqToSegment(l,c,u,h)>s)continue;u.applyMatrix4(this.matrixWorld);const r=e.ray.origin.distanceTo(u);r<e.near||r>e.far||t.push({distance:r,point:h.clone().applyMatrix4(this.matrixWorld),index:n,face:null,faceIndex:null,object:this})}}}else n.isGeometry&&console.error("THREE.Line.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}updateMorphTargets(){const e=this.geometry;if(e.isBufferGeometry){const t=e.morphAttributes,n=Object.keys(t);if(n.length>0){const e=t[n[0]];if(void 0!==e){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,n=e.length;t<n;t++){const n=e[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[n]=t}}}}else{const t=e.morphTargets;void 0!==t&&t.length>0&&console.error("THREE.Line.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}}Line.prototype.isLine=!0;const _start=new Vector3,_end=new Vector3;class LineSegments extends Line{constructor(e,t){super(e,t),this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.isBufferGeometry)if(null===e.index){const t=e.attributes.position,n=[];for(let e=0,r=t.count;e<r;e+=2)_start.fromBufferAttribute(t,e),_end.fromBufferAttribute(t,e+1),n[e]=0===e?0:n[e-1],n[e+1]=n[e]+_start.distanceTo(_end);e.setAttribute("lineDistance",new Float32BufferAttribute(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");else e.isGeometry&&console.error("THREE.LineSegments.computeLineDistances() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.");return this}}LineSegments.prototype.isLineSegments=!0;class LineLoop extends Line{constructor(e,t){super(e,t),this.type="LineLoop"}}LineLoop.prototype.isLineLoop=!0;class PointsMaterial extends Material{constructor(e){super(),this.type="PointsMaterial",this.color=new Color$1(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this}}PointsMaterial.prototype.isPointsMaterial=!0;const _inverseMatrix=new Matrix4,_ray=new Ray,_sphere=new Sphere,_position$2=new Vector3;class Points extends Object3D{constructor(e=new BufferGeometry,t=new PointsMaterial){super(),this.type="Points",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e){return super.copy(e),this.material=e.material,this.geometry=e.geometry,this}raycast(e,t){const n=this.geometry,r=this.matrixWorld,i=e.params.Points.threshold,a=n.drawRange;if(null===n.boundingSphere&&n.computeBoundingSphere(),_sphere.copy(n.boundingSphere),_sphere.applyMatrix4(r),_sphere.radius+=i,!1===e.ray.intersectsSphere(_sphere))return;_inverseMatrix.copy(r).invert(),_ray.copy(e.ray).applyMatrix4(_inverseMatrix);const o=i/((this.scale.x+this.scale.y+this.scale.z)/3),s=o*o;if(n.isBufferGeometry){const i=n.index,o=n.attributes.position;if(null!==i){for(let n=Math.max(0,a.start),l=Math.min(i.count,a.start+a.count);n<l;n++){const a=i.getX(n);_position$2.fromBufferAttribute(o,a),testPoint(_position$2,a,s,r,e,t,this)}}else{for(let n=Math.max(0,a.start),i=Math.min(o.count,a.start+a.count);n<i;n++)_position$2.fromBufferAttribute(o,n),testPoint(_position$2,n,s,r,e,t,this)}}else console.error("THREE.Points.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}updateMorphTargets(){const e=this.geometry;if(e.isBufferGeometry){const t=e.morphAttributes,n=Object.keys(t);if(n.length>0){const e=t[n[0]];if(void 0!==e){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,n=e.length;t<n;t++){const n=e[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[n]=t}}}}else{const t=e.morphTargets;void 0!==t&&t.length>0&&console.error("THREE.Points.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}}function testPoint(e,t,n,r,i,a,o){const s=_ray.distanceSqToPoint(e);if(s<n){const n=new Vector3;_ray.closestPointToPoint(e,n),n.applyMatrix4(r);const l=i.ray.origin.distanceTo(n);if(l<i.near||l>i.far)return;a.push({distance:l,distanceToRay:Math.sqrt(s),point:n,index:t,face:null,object:o})}}Points.prototype.isPoints=!0;class VideoTexture extends Texture{constructor(e,t,n,r,i,a,o,s,l){super(e,t,n,r,i,a,o,s,l),this.minFilter=void 0!==a?a:LinearFilter,this.magFilter=void 0!==i?i:LinearFilter,this.generateMipmaps=!1;const c=this;"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback((function t(){c.needsUpdate=!0,e.requestVideoFrameCallback(t)}))}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;!1==="requestVideoFrameCallback"in e&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}VideoTexture.prototype.isVideoTexture=!0;class FramebufferTexture extends Texture{constructor(e,t,n){super({width:e,height:t}),this.format=n,this.magFilter=NearestFilter,this.minFilter=NearestFilter,this.generateMipmaps=!1,this.needsUpdate=!0}}FramebufferTexture.prototype.isFramebufferTexture=!0;class CompressedTexture extends Texture{constructor(e,t,n,r,i,a,o,s,l,c,h,u){super(null,a,o,s,l,c,r,i,h,u),this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}CompressedTexture.prototype.isCompressedTexture=!0;class CanvasTexture extends Texture{constructor(e,t,n,r,i,a,o,s,l){super(e,t,n,r,i,a,o,s,l),this.needsUpdate=!0}}CanvasTexture.prototype.isCanvasTexture=!0,new Vector3,new Vector3,new Vector3,new Triangle;class Curve{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){const n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let n,r=this.getPoint(0),i=0;t.push(0);for(let a=1;a<=e;a++)n=this.getPoint(a/e),i+=n.distanceTo(r),t.push(i),r=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const n=this.getLengths();let r=0;const i=n.length;let a;a=t||e*n[i-1];let o,s=0,l=i-1;for(;s<=l;)if(r=Math.floor(s+(l-s)/2),o=n[r]-a,o<0)s=r+1;else{if(!(o>0)){l=r;break}l=r-1}if(r=l,n[r]===a)return r/(i-1);const c=n[r];return(r+(a-c)/(n[r+1]-c))/(i-1)}getTangent(e,t){const n=1e-4;let r=e-n,i=e+n;r<0&&(r=0),i>1&&(i=1);const a=this.getPoint(r),o=this.getPoint(i),s=t||(a.isVector2?new Vector2:new Vector3);return s.copy(o).sub(a).normalize(),s}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t){const n=new Vector3,r=[],i=[],a=[],o=new Vector3,s=new Matrix4;for(let t=0;t<=e;t++){r[t]=this.getTangentAt(t/e,new Vector3)}i[0]=new Vector3,a[0]=new Vector3;let l=Number.MAX_VALUE;const c=Math.abs(r[0].x),h=Math.abs(r[0].y),u=Math.abs(r[0].z);c<=l&&(l=c,n.set(1,0,0)),h<=l&&(l=h,n.set(0,1,0)),u<=l&&n.set(0,0,1),o.crossVectors(r[0],n).normalize(),i[0].crossVectors(r[0],o),a[0].crossVectors(r[0],i[0]);for(let t=1;t<=e;t++){if(i[t]=i[t-1].clone(),a[t]=a[t-1].clone(),o.crossVectors(r[t-1],r[t]),o.length()>Number.EPSILON){o.normalize();const e=Math.acos(clamp(r[t-1].dot(r[t]),-1,1));i[t].applyMatrix4(s.makeRotationAxis(o,e))}a[t].crossVectors(r[t],i[t])}if(!0===t){let t=Math.acos(clamp(i[0].dot(i[e]),-1,1));t/=e,r[0].dot(o.crossVectors(i[0],i[e]))>0&&(t=-t);for(let n=1;n<=e;n++)i[n].applyMatrix4(s.makeRotationAxis(r[n],t*n)),a[n].crossVectors(r[n],i[n])}return{tangents:r,normals:i,binormals:a}}clone(){return(new this.constructor).copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class EllipseCurve extends Curve{constructor(e=0,t=0,n=1,r=1,i=0,a=2*Math.PI,o=!1,s=0){super(),this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=r,this.aStartAngle=i,this.aEndAngle=a,this.aClockwise=o,this.aRotation=s}getPoint(e,t){const n=t||new Vector2,r=2*Math.PI;let i=this.aEndAngle-this.aStartAngle;const a=Math.abs(i)<Number.EPSILON;for(;i<0;)i+=r;for(;i>r;)i-=r;i<Number.EPSILON&&(i=a?0:r),!0!==this.aClockwise||a||(i===r?i=-r:i-=r);const o=this.aStartAngle+e*i;let s=this.aX+this.xRadius*Math.cos(o),l=this.aY+this.yRadius*Math.sin(o);if(0!==this.aRotation){const e=Math.cos(this.aRotation),t=Math.sin(this.aRotation),n=s-this.aX,r=l-this.aY;s=n*e-r*t+this.aX,l=n*t+r*e+this.aY}return n.set(s,l)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){const e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}}EllipseCurve.prototype.isEllipseCurve=!0;class ArcCurve extends EllipseCurve{constructor(e,t,n,r,i,a){super(e,t,n,n,r,i,a),this.type="ArcCurve"}}function CubicPoly(){let e=0,t=0,n=0,r=0;function i(i,a,o,s){e=i,t=o,n=-3*i+3*a-2*o-s,r=2*i-2*a+o+s}return{initCatmullRom:function(e,t,n,r,a){i(t,n,a*(n-e),a*(r-t))},initNonuniformCatmullRom:function(e,t,n,r,a,o,s){let l=(t-e)/a-(n-e)/(a+o)+(n-t)/o,c=(n-t)/o-(r-t)/(o+s)+(r-n)/s;l*=o,c*=o,i(t,n,l,c)},calc:function(i){const a=i*i;return e+t*i+n*a+r*(a*i)}}}ArcCurve.prototype.isArcCurve=!0;const tmp=new Vector3,px=new CubicPoly,py=new CubicPoly,pz=new CubicPoly;class CatmullRomCurve3 extends Curve{constructor(e=[],t=!1,n="centripetal",r=.5){super(),this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=n,this.tension=r}getPoint(e,t=new Vector3){const n=t,r=this.points,i=r.length,a=(i-(this.closed?0:1))*e;let o,s,l=Math.floor(a),c=a-l;this.closed?l+=l>0?0:(Math.floor(Math.abs(l)/i)+1)*i:0===c&&l===i-1&&(l=i-2,c=1),this.closed||l>0?o=r[(l-1)%i]:(tmp.subVectors(r[0],r[1]).add(r[0]),o=tmp);const h=r[l%i],u=r[(l+1)%i];if(this.closed||l+2<i?s=r[(l+2)%i]:(tmp.subVectors(r[i-1],r[i-2]).add(r[i-1]),s=tmp),"centripetal"===this.curveType||"chordal"===this.curveType){const e="chordal"===this.curveType?.5:.25;let t=Math.pow(o.distanceToSquared(h),e),n=Math.pow(h.distanceToSquared(u),e),r=Math.pow(u.distanceToSquared(s),e);n<1e-4&&(n=1),t<1e-4&&(t=n),r<1e-4&&(r=n),px.initNonuniformCatmullRom(o.x,h.x,u.x,s.x,t,n,r),py.initNonuniformCatmullRom(o.y,h.y,u.y,s.y,t,n,r),pz.initNonuniformCatmullRom(o.z,h.z,u.z,s.z,t,n,r)}else"catmullrom"===this.curveType&&(px.initCatmullRom(o.x,h.x,u.x,s.x,this.tension),py.initCatmullRom(o.y,h.y,u.y,s.y,this.tension),pz.initCatmullRom(o.z,h.z,u.z,s.z,this.tension));return n.set(px.calc(c),py.calc(c),pz.calc(c)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){this.points.push(e.points[t].clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){e.points.push(this.points[t].toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const n=e.points[t];this.points.push((new Vector3).fromArray(n))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}}function CatmullRom(e,t,n,r,i){const a=.5*(r-t),o=.5*(i-n),s=e*e;return(2*n-2*r+a+o)*(e*s)+(-3*n+3*r-2*a-o)*s+a*e+n}function QuadraticBezierP0(e,t){const n=1-e;return n*n*t}function QuadraticBezierP1(e,t){return 2*(1-e)*e*t}function QuadraticBezierP2(e,t){return e*e*t}function QuadraticBezier(e,t,n,r){return QuadraticBezierP0(e,t)+QuadraticBezierP1(e,n)+QuadraticBezierP2(e,r)}function CubicBezierP0(e,t){const n=1-e;return n*n*n*t}function CubicBezierP1(e,t){const n=1-e;return 3*n*n*e*t}function CubicBezierP2(e,t){return 3*(1-e)*e*e*t}function CubicBezierP3(e,t){return e*e*e*t}function CubicBezier(e,t,n,r,i){return CubicBezierP0(e,t)+CubicBezierP1(e,n)+CubicBezierP2(e,r)+CubicBezierP3(e,i)}CatmullRomCurve3.prototype.isCatmullRomCurve3=!0;class CubicBezierCurve extends Curve{constructor(e=new Vector2,t=new Vector2,n=new Vector2,r=new Vector2){super(),this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=n,this.v3=r}getPoint(e,t=new Vector2){const n=t,r=this.v0,i=this.v1,a=this.v2,o=this.v3;return n.set(CubicBezier(e,r.x,i.x,a.x,o.x),CubicBezier(e,r.y,i.y,a.y,o.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}CubicBezierCurve.prototype.isCubicBezierCurve=!0;class CubicBezierCurve3 extends Curve{constructor(e=new Vector3,t=new Vector3,n=new Vector3,r=new Vector3){super(),this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=n,this.v3=r}getPoint(e,t=new Vector3){const n=t,r=this.v0,i=this.v1,a=this.v2,o=this.v3;return n.set(CubicBezier(e,r.x,i.x,a.x,o.x),CubicBezier(e,r.y,i.y,a.y,o.y),CubicBezier(e,r.z,i.z,a.z,o.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}CubicBezierCurve3.prototype.isCubicBezierCurve3=!0;class LineCurve extends Curve{constructor(e=new Vector2,t=new Vector2){super(),this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new Vector2){const n=t;return 1===e?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t){const n=t||new Vector2;return n.copy(this.v2).sub(this.v1).normalize(),n}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}LineCurve.prototype.isLineCurve=!0;class LineCurve3 extends Curve{constructor(e=new Vector3,t=new Vector3){super(),this.type="LineCurve3",this.isLineCurve3=!0,this.v1=e,this.v2=t}getPoint(e,t=new Vector3){const n=t;return 1===e?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class QuadraticBezierCurve extends Curve{constructor(e=new Vector2,t=new Vector2,n=new Vector2){super(),this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new Vector2){const n=t,r=this.v0,i=this.v1,a=this.v2;return n.set(QuadraticBezier(e,r.x,i.x,a.x),QuadraticBezier(e,r.y,i.y,a.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}QuadraticBezierCurve.prototype.isQuadraticBezierCurve=!0;class QuadraticBezierCurve3 extends Curve{constructor(e=new Vector3,t=new Vector3,n=new Vector3){super(),this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new Vector3){const n=t,r=this.v0,i=this.v1,a=this.v2;return n.set(QuadraticBezier(e,r.x,i.x,a.x),QuadraticBezier(e,r.y,i.y,a.y),QuadraticBezier(e,r.z,i.z,a.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}QuadraticBezierCurve3.prototype.isQuadraticBezierCurve3=!0;class SplineCurve extends Curve{constructor(e=[]){super(),this.type="SplineCurve",this.points=e}getPoint(e,t=new Vector2){const n=t,r=this.points,i=(r.length-1)*e,a=Math.floor(i),o=i-a,s=r[0===a?a:a-1],l=r[a],c=r[a>r.length-2?r.length-1:a+1],h=r[a>r.length-3?r.length-1:a+2];return n.set(CatmullRom(o,s.x,l.x,c.x,h.x),CatmullRom(o,s.y,l.y,c.y,h.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){this.points.push(e.points[t].clone())}return this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){e.points.push(this.points[t].toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const n=e.points[t];this.points.push((new Vector2).fromArray(n))}return this}}SplineCurve.prototype.isSplineCurve=!0;var Curves=Object.freeze({__proto__:null,ArcCurve:ArcCurve,CatmullRomCurve3:CatmullRomCurve3,CubicBezierCurve:CubicBezierCurve,CubicBezierCurve3:CubicBezierCurve3,EllipseCurve:EllipseCurve,LineCurve:LineCurve,LineCurve3:LineCurve3,QuadraticBezierCurve:QuadraticBezierCurve,QuadraticBezierCurve3:QuadraticBezierCurve3,SplineCurve:SplineCurve});class CurvePath extends Curve{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){const e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);e.equals(t)||this.curves.push(new LineCurve(t,e))}getPoint(e,t){const n=e*this.getLength(),r=this.getCurveLengths();let i=0;for(;i<r.length;){if(r[i]>=n){const e=r[i]-n,a=this.curves[i],o=a.getLength();return a.getPointAt(0===o?0:1-e/o,t)}i++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let n=0,r=this.curves.length;n<r;n++)t+=this.curves[n].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){const t=[];let n;for(let r=0,i=this.curves;r<i.length;r++){const a=i[r],o=a.getPoints(a&&a.isEllipseCurve?2*e:a&&(a.isLineCurve||a.isLineCurve3)?1:a&&a.isSplineCurve?e*a.points.length:e);for(let e=0;e<o.length;e++){const r=o[e];n&&n.equals(r)||(t.push(r),n=r)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){this.curves.push(e.curves[t].clone())}return this.autoClose=e.autoClose,this}toJSON(){const e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,n=this.curves.length;t<n;t++){e.curves.push(this.curves[t].toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){const n=e.curves[t];this.curves.push((new Curves[n.type]).fromJSON(n))}return this}}class Path extends CurvePath{constructor(e){super(),this.type="Path",this.currentPoint=new Vector2,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,n=e.length;t<n;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){const n=new LineCurve(this.currentPoint.clone(),new Vector2(e,t));return this.curves.push(n),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,n,r){const i=new QuadraticBezierCurve(this.currentPoint.clone(),new Vector2(e,t),new Vector2(n,r));return this.curves.push(i),this.currentPoint.set(n,r),this}bezierCurveTo(e,t,n,r,i,a){const o=new CubicBezierCurve(this.currentPoint.clone(),new Vector2(e,t),new Vector2(n,r),new Vector2(i,a));return this.curves.push(o),this.currentPoint.set(i,a),this}splineThru(e){const t=[this.currentPoint.clone()].concat(e),n=new SplineCurve(t);return this.curves.push(n),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,n,r,i,a){return this.absarc(e+this.currentPoint.x,t+this.currentPoint.y,n,r,i,a),this}absarc(e,t,n,r,i,a){return this.absellipse(e,t,n,n,r,i,a),this}ellipse(e,t,n,r,i,a,o,s){return this.absellipse(e+this.currentPoint.x,t+this.currentPoint.y,n,r,i,a,o,s),this}absellipse(e,t,n,r,i,a,o,s){const l=new EllipseCurve(e,t,n,r,i,a,o,s);if(this.curves.length>0){const e=l.getPoint(0);e.equals(this.currentPoint)||this.lineTo(e.x,e.y)}this.curves.push(l);const c=l.getPoint(1);return this.currentPoint.copy(c),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class Shape extends Path{constructor(e){super(e),this.uuid=generateUUID(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let n=0,r=this.holes.length;n<r;n++)t[n]=this.holes[n].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){this.holes.push(e.holes[t].clone())}return this}toJSON(){const e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,n=this.holes.length;t<n;t++){e.holes.push(this.holes[t].toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){const n=e.holes[t];this.holes.push((new Path).fromJSON(n))}return this}}const Earcut={triangulate:function(e,t,n=2){const r=t&&t.length,i=r?t[0]*n:e.length;let a=linkedList(e,0,i,n,!0);const o=[];if(!a||a.next===a.prev)return o;let s,l,c,h,u,d,p;if(r&&(a=eliminateHoles(e,t,a,n)),e.length>80*n){s=c=e[0],l=h=e[1];for(let t=n;t<i;t+=n)u=e[t],d=e[t+1],u<s&&(s=u),d<l&&(l=d),u>c&&(c=u),d>h&&(h=d);p=Math.max(c-s,h-l),p=0!==p?1/p:0}return earcutLinked(a,o,n,s,l,p),o}};function linkedList(e,t,n,r,i){let a,o;if(i===signedArea(e,t,n,r)>0)for(a=t;a<n;a+=r)o=insertNode(a,e[a],e[a+1],o);else for(a=n-r;a>=t;a-=r)o=insertNode(a,e[a],e[a+1],o);return o&&equals(o,o.next)&&(removeNode(o),o=o.next),o}function filterPoints(e,t){if(!e)return e;t||(t=e);let n,r=e;do{if(n=!1,r.steiner||!equals(r,r.next)&&0!==area(r.prev,r,r.next))r=r.next;else{if(removeNode(r),r=t=r.prev,r===r.next)break;n=!0}}while(n||r!==t);return t}function earcutLinked(e,t,n,r,i,a,o){if(!e)return;!o&&a&&indexCurve(e,r,i,a);let s,l,c=e;for(;e.prev!==e.next;)if(s=e.prev,l=e.next,a?isEarHashed(e,r,i,a):isEar(e))t.push(s.i/n),t.push(e.i/n),t.push(l.i/n),removeNode(e),e=l.next,c=l.next;else if((e=l)===c){o?1===o?earcutLinked(e=cureLocalIntersections(filterPoints(e),t,n),t,n,r,i,a,2):2===o&&splitEarcut(e,t,n,r,i,a):earcutLinked(filterPoints(e),t,n,r,i,a,1);break}}function isEar(e){const t=e.prev,n=e,r=e.next;if(area(t,n,r)>=0)return!1;let i=e.next.next;for(;i!==e.prev;){if(pointInTriangle(t.x,t.y,n.x,n.y,r.x,r.y,i.x,i.y)&&area(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function isEarHashed(e,t,n,r){const i=e.prev,a=e,o=e.next;if(area(i,a,o)>=0)return!1;const s=i.x>a.x?i.x>o.x?i.x:o.x:a.x>o.x?a.x:o.x,l=i.y>a.y?i.y>o.y?i.y:o.y:a.y>o.y?a.y:o.y,c=zOrder(i.x<a.x?i.x<o.x?i.x:o.x:a.x<o.x?a.x:o.x,i.y<a.y?i.y<o.y?i.y:o.y:a.y<o.y?a.y:o.y,t,n,r),h=zOrder(s,l,t,n,r);let u=e.prevZ,d=e.nextZ;for(;u&&u.z>=c&&d&&d.z<=h;){if(u!==e.prev&&u!==e.next&&pointInTriangle(i.x,i.y,a.x,a.y,o.x,o.y,u.x,u.y)&&area(u.prev,u,u.next)>=0)return!1;if(u=u.prevZ,d!==e.prev&&d!==e.next&&pointInTriangle(i.x,i.y,a.x,a.y,o.x,o.y,d.x,d.y)&&area(d.prev,d,d.next)>=0)return!1;d=d.nextZ}for(;u&&u.z>=c;){if(u!==e.prev&&u!==e.next&&pointInTriangle(i.x,i.y,a.x,a.y,o.x,o.y,u.x,u.y)&&area(u.prev,u,u.next)>=0)return!1;u=u.prevZ}for(;d&&d.z<=h;){if(d!==e.prev&&d!==e.next&&pointInTriangle(i.x,i.y,a.x,a.y,o.x,o.y,d.x,d.y)&&area(d.prev,d,d.next)>=0)return!1;d=d.nextZ}return!0}function cureLocalIntersections(e,t,n){let r=e;do{const i=r.prev,a=r.next.next;!equals(i,a)&&intersects(i,r,r.next,a)&&locallyInside(i,a)&&locallyInside(a,i)&&(t.push(i.i/n),t.push(r.i/n),t.push(a.i/n),removeNode(r),removeNode(r.next),r=e=a),r=r.next}while(r!==e);return filterPoints(r)}function splitEarcut(e,t,n,r,i,a){let o=e;do{let e=o.next.next;for(;e!==o.prev;){if(o.i!==e.i&&isValidDiagonal(o,e)){let s=splitPolygon(o,e);return o=filterPoints(o,o.next),s=filterPoints(s,s.next),earcutLinked(o,t,n,r,i,a),void earcutLinked(s,t,n,r,i,a)}e=e.next}o=o.next}while(o!==e)}function eliminateHoles(e,t,n,r){const i=[];let a,o,s,l,c;for(a=0,o=t.length;a<o;a++)s=t[a]*r,l=a<o-1?t[a+1]*r:e.length,c=linkedList(e,s,l,r,!1),c===c.next&&(c.steiner=!0),i.push(getLeftmost(c));for(i.sort(compareX),a=0;a<i.length;a++)eliminateHole(i[a],n),n=filterPoints(n,n.next);return n}function compareX(e,t){return e.x-t.x}function eliminateHole(e,t){if(t=findHoleBridge(e,t)){const n=splitPolygon(t,e);filterPoints(t,t.next),filterPoints(n,n.next)}}function findHoleBridge(e,t){let n=t;const r=e.x,i=e.y;let a,o=-1/0;do{if(i<=n.y&&i>=n.next.y&&n.next.y!==n.y){const e=n.x+(i-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(e<=r&&e>o){if(o=e,e===r){if(i===n.y)return n;if(i===n.next.y)return n.next}a=n.x<n.next.x?n:n.next}}n=n.next}while(n!==t);if(!a)return null;if(r===o)return a;const s=a,l=a.x,c=a.y;let h,u=1/0;n=a;do{r>=n.x&&n.x>=l&&r!==n.x&&pointInTriangle(i<c?r:o,i,l,c,i<c?o:r,i,n.x,n.y)&&(h=Math.abs(i-n.y)/(r-n.x),locallyInside(n,e)&&(h<u||h===u&&(n.x>a.x||n.x===a.x&&sectorContainsSector(a,n)))&&(a=n,u=h)),n=n.next}while(n!==s);return a}function sectorContainsSector(e,t){return area(e.prev,e,t.prev)<0&&area(t.next,e,e.next)<0}function indexCurve(e,t,n,r){let i=e;do{null===i.z&&(i.z=zOrder(i.x,i.y,t,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,sortLinked(i)}function sortLinked(e){let t,n,r,i,a,o,s,l,c=1;do{for(n=e,e=null,a=null,o=0;n;){for(o++,r=n,s=0,t=0;t<c&&(s++,r=r.nextZ,r);t++);for(l=c;s>0||l>0&&r;)0!==s&&(0===l||!r||n.z<=r.z)?(i=n,n=n.nextZ,s--):(i=r,r=r.nextZ,l--),a?a.nextZ=i:e=i,i.prevZ=a,a=i;n=r}a.nextZ=null,c*=2}while(o>1);return e}function zOrder(e,t,n,r,i){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-n)*i)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-r)*i)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function getLeftmost(e){let t=e,n=e;do{(t.x<n.x||t.x===n.x&&t.y<n.y)&&(n=t),t=t.next}while(t!==e);return n}function pointInTriangle(e,t,n,r,i,a,o,s){return(i-o)*(t-s)-(e-o)*(a-s)>=0&&(e-o)*(r-s)-(n-o)*(t-s)>=0&&(n-o)*(a-s)-(i-o)*(r-s)>=0}function isValidDiagonal(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!intersectsPolygon(e,t)&&(locallyInside(e,t)&&locallyInside(t,e)&&middleInside(e,t)&&(area(e.prev,e,t.prev)||area(e,t.prev,t))||equals(e,t)&&area(e.prev,e,e.next)>0&&area(t.prev,t,t.next)>0)}function area(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function equals(e,t){return e.x===t.x&&e.y===t.y}function intersects(e,t,n,r){const i=sign(area(e,t,n)),a=sign(area(e,t,r)),o=sign(area(n,r,e)),s=sign(area(n,r,t));return i!==a&&o!==s||(!(0!==i||!onSegment(e,n,t))||(!(0!==a||!onSegment(e,r,t))||(!(0!==o||!onSegment(n,e,r))||!(0!==s||!onSegment(n,t,r)))))}function onSegment(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function sign(e){return e>0?1:e<0?-1:0}function intersectsPolygon(e,t){let n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&intersects(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}function locallyInside(e,t){return area(e.prev,e,e.next)<0?area(e,t,e.next)>=0&&area(e,e.prev,t)>=0:area(e,t,e.prev)<0||area(e,e.next,t)<0}function middleInside(e,t){let n=e,r=!1;const i=(e.x+t.x)/2,a=(e.y+t.y)/2;do{n.y>a!=n.next.y>a&&n.next.y!==n.y&&i<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next}while(n!==e);return r}function splitPolygon(e,t){const n=new Node$1(e.i,e.x,e.y),r=new Node$1(t.i,t.x,t.y),i=e.next,a=t.prev;return e.next=t,t.prev=e,n.next=i,i.prev=n,r.next=n,n.prev=r,a.next=r,r.prev=a,r}function insertNode(e,t,n,r){const i=new Node$1(e,t,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function removeNode(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function Node$1(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function signedArea(e,t,n,r){let i=0;for(let a=t,o=n-r;a<n;a+=r)i+=(e[o]-e[a])*(e[a+1]+e[o+1]),o=a;return i}class ShapeUtils{static area(e){const t=e.length;let n=0;for(let r=t-1,i=0;i<t;r=i++)n+=e[r].x*e[i].y-e[i].x*e[r].y;return.5*n}static isClockWise(e){return ShapeUtils.area(e)<0}static triangulateShape(e,t){const n=[],r=[],i=[];removeDupEndPts(e),addContour(n,e);let a=e.length;t.forEach(removeDupEndPts);for(let e=0;e<t.length;e++)r.push(a),a+=t[e].length,addContour(n,t[e]);const o=Earcut.triangulate(n,r);for(let e=0;e<o.length;e+=3)i.push(o.slice(e,e+3));return i}}function removeDupEndPts(e){const t=e.length;t>2&&e[t-1].equals(e[0])&&e.pop()}function addContour(e,t){for(let n=0;n<t.length;n++)e.push(t[n].x),e.push(t[n].y)}class ExtrudeGeometry extends BufferGeometry{constructor(e=new Shape([new Vector2(.5,.5),new Vector2(-.5,.5),new Vector2(-.5,-.5),new Vector2(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];const n=this,r=[],i=[];for(let t=0,n=e.length;t<n;t++){a(e[t])}function a(e){const a=[],o=void 0!==t.curveSegments?t.curveSegments:12,s=void 0!==t.steps?t.steps:1;let l=void 0!==t.depth?t.depth:1,c=void 0===t.bevelEnabled||t.bevelEnabled,h=void 0!==t.bevelThickness?t.bevelThickness:.2,u=void 0!==t.bevelSize?t.bevelSize:h-.1,d=void 0!==t.bevelOffset?t.bevelOffset:0,p=void 0!==t.bevelSegments?t.bevelSegments:3;const m=t.extrudePath,f=void 0!==t.UVGenerator?t.UVGenerator:WorldUVGenerator;void 0!==t.amount&&(console.warn("THREE.ExtrudeBufferGeometry: amount has been renamed to depth."),l=t.amount);let g,v,y,_,b,x=!1;m&&(g=m.getSpacedPoints(s),x=!0,c=!1,v=m.computeFrenetFrames(s,!1),y=new Vector3,_=new Vector3,b=new Vector3),c||(p=0,h=0,u=0,d=0);const S=e.extractPoints(o);let w=S.shape;const C=S.holes;if(!ShapeUtils.isClockWise(w)){w=w.reverse();for(let e=0,t=C.length;e<t;e++){const t=C[e];ShapeUtils.isClockWise(t)&&(C[e]=t.reverse())}}const M=ShapeUtils.triangulateShape(w,C),E=w;for(let e=0,t=C.length;e<t;e++){w=w.concat(C[e])}function T(e,t,n){return t||console.error("THREE.ExtrudeGeometry: vec does not exist"),t.clone().multiplyScalar(n).add(e)}const I=w.length,A=M.length;function k(e,t,n){let r,i,a;const o=e.x-t.x,s=e.y-t.y,l=n.x-e.x,c=n.y-e.y,h=o*o+s*s;if(Math.abs(o*c-s*l)>Number.EPSILON){const u=Math.sqrt(h),d=Math.sqrt(l*l+c*c),p=t.x-s/u,m=t.y+o/u,f=((n.x-c/d-p)*c-(n.y+l/d-m)*l)/(o*c-s*l);r=p+o*f-e.x,i=m+s*f-e.y;const g=r*r+i*i;if(g<=2)return new Vector2(r,i);a=Math.sqrt(g/2)}else{let e=!1;o>Number.EPSILON?l>Number.EPSILON&&(e=!0):o<-Number.EPSILON?l<-Number.EPSILON&&(e=!0):Math.sign(s)===Math.sign(c)&&(e=!0),e?(r=-s,i=o,a=Math.sqrt(h)):(r=o,i=s,a=Math.sqrt(h/2))}return new Vector2(r/a,i/a)}const P=[];for(let e=0,t=E.length,n=t-1,r=e+1;e<t;e++,n++,r++)n===t&&(n=0),r===t&&(r=0),P[e]=k(E[e],E[n],E[r]);const R=[];let N,L=P.concat();for(let e=0,t=C.length;e<t;e++){const t=C[e];N=[];for(let e=0,n=t.length,r=n-1,i=e+1;e<n;e++,r++,i++)r===n&&(r=0),i===n&&(i=0),N[e]=k(t[e],t[r],t[i]);R.push(N),L=L.concat(N)}for(let e=0;e<p;e++){const t=e/p,n=h*Math.cos(t*Math.PI/2),r=u*Math.sin(t*Math.PI/2)+d;for(let e=0,t=E.length;e<t;e++){const t=T(E[e],P[e],r);z(t.x,t.y,-n)}for(let e=0,t=C.length;e<t;e++){const t=C[e];N=R[e];for(let e=0,i=t.length;e<i;e++){const i=T(t[e],N[e],r);z(i.x,i.y,-n)}}}const D=u+d;for(let e=0;e<I;e++){const t=c?T(w[e],L[e],D):w[e];x?(_.copy(v.normals[0]).multiplyScalar(t.x),y.copy(v.binormals[0]).multiplyScalar(t.y),b.copy(g[0]).add(_).add(y),z(b.x,b.y,b.z)):z(t.x,t.y,0)}for(let e=1;e<=s;e++)for(let t=0;t<I;t++){const n=c?T(w[t],L[t],D):w[t];x?(_.copy(v.normals[e]).multiplyScalar(n.x),y.copy(v.binormals[e]).multiplyScalar(n.y),b.copy(g[e]).add(_).add(y),z(b.x,b.y,b.z)):z(n.x,n.y,l/s*e)}for(let e=p-1;e>=0;e--){const t=e/p,n=h*Math.cos(t*Math.PI/2),r=u*Math.sin(t*Math.PI/2)+d;for(let e=0,t=E.length;e<t;e++){const t=T(E[e],P[e],r);z(t.x,t.y,l+n)}for(let e=0,t=C.length;e<t;e++){const t=C[e];N=R[e];for(let e=0,i=t.length;e<i;e++){const i=T(t[e],N[e],r);x?z(i.x,i.y+g[s-1].y,g[s-1].x+n):z(i.x,i.y,l+n)}}}function $(e,t){let n=e.length;for(;--n>=0;){const r=n;let i=n-1;i<0&&(i=e.length-1);for(let e=0,n=s+2*p;e<n;e++){const n=I*e,a=I*(e+1);O(t+r+n,t+i+n,t+i+a,t+r+a)}}}function z(e,t,n){a.push(e),a.push(t),a.push(n)}function F(e,t,i){B(e),B(t),B(i);const a=r.length/3,o=f.generateTopUV(n,r,a-3,a-2,a-1);V(o[0]),V(o[1]),V(o[2])}function O(e,t,i,a){B(e),B(t),B(a),B(t),B(i),B(a);const o=r.length/3,s=f.generateSideWallUV(n,r,o-6,o-3,o-2,o-1);V(s[0]),V(s[1]),V(s[3]),V(s[1]),V(s[2]),V(s[3])}function B(e){r.push(a[3*e+0]),r.push(a[3*e+1]),r.push(a[3*e+2])}function V(e){i.push(e.x),i.push(e.y)}!(function H(){const e=r.length/3;if(c){let e=0,t=I*e;for(let e=0;e<A;e++){const n=M[e];F(n[2]+t,n[1]+t,n[0]+t)}e=s+2*p,t=I*e;for(let e=0;e<A;e++){const n=M[e];F(n[0]+t,n[1]+t,n[2]+t)}}else{for(let e=0;e<A;e++){const t=M[e];F(t[2],t[1],t[0])}for(let e=0;e<A;e++){const t=M[e];F(t[0]+I*s,t[1]+I*s,t[2]+I*s)}}n.addGroup(e,r.length/3-e,0)})(),(function U(){const e=r.length/3;let t=0;$(E,t),t+=E.length;for(let e=0,n=C.length;e<n;e++){const n=C[e];$(n,t),t+=n.length}n.addGroup(e,r.length/3-e,1)})()}this.setAttribute("position",new Float32BufferAttribute(r,3)),this.setAttribute("uv",new Float32BufferAttribute(i,2)),this.computeVertexNormals()}toJSON(){const e=super.toJSON();return toJSON$1(this.parameters.shapes,this.parameters.options,e)}static fromJSON(e,t){const n=[];for(let r=0,i=e.shapes.length;r<i;r++){n.push(t[e.shapes[r]])}const r=e.options.extrudePath;return void 0!==r&&(e.options.extrudePath=(new Curves[r.type]).fromJSON(r)),new ExtrudeGeometry(n,e.options)}}const WorldUVGenerator={generateTopUV:function(e,t,n,r,i){const a=t[3*r],o=t[3*r+1],s=t[3*i],l=t[3*i+1];return[new Vector2(t[3*n],t[3*n+1]),new Vector2(a,o),new Vector2(s,l)]},generateSideWallUV:function(e,t,n,r,i,a){const o=t[3*n],s=t[3*n+1],l=t[3*n+2],c=t[3*r],h=t[3*r+1],u=t[3*r+2],d=t[3*i],p=t[3*i+1],m=t[3*i+2],f=t[3*a],g=t[3*a+1],v=t[3*a+2];return Math.abs(s-h)<Math.abs(o-c)?[new Vector2(o,1-l),new Vector2(c,1-u),new Vector2(d,1-m),new Vector2(f,1-v)]:[new Vector2(s,1-l),new Vector2(h,1-u),new Vector2(p,1-m),new Vector2(g,1-v)]}};function toJSON$1(e,t,n){if(n.shapes=[],Array.isArray(e))for(let t=0,r=e.length;t<r;t++){n.shapes.push(e[t].uuid)}else n.shapes.push(e.uuid);return void 0!==t.extrudePath&&(n.options.extrudePath=t.extrudePath.toJSON()),n}class ShapeGeometry extends BufferGeometry{constructor(e=new Shape([new Vector2(0,.5),new Vector2(-.5,-.5),new Vector2(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};const n=[],r=[],i=[],a=[];let o=0,s=0;if(!1===Array.isArray(e))l(e);else for(let t=0;t<e.length;t++)l(e[t]),this.addGroup(o,s,t),o+=s,s=0;function l(e){const o=r.length/3,l=e.extractPoints(t);let c=l.shape;const h=l.holes;!1===ShapeUtils.isClockWise(c)&&(c=c.reverse());for(let e=0,t=h.length;e<t;e++){const t=h[e];!0===ShapeUtils.isClockWise(t)&&(h[e]=t.reverse())}const u=ShapeUtils.triangulateShape(c,h);for(let e=0,t=h.length;e<t;e++){c=c.concat(h[e])}for(let e=0,t=c.length;e<t;e++){const t=c[e];r.push(t.x,t.y,0),i.push(0,0,1),a.push(t.x,t.y)}for(let e=0,t=u.length;e<t;e++){const t=u[e];n.push(t[0]+o,t[1]+o,t[2]+o),s+=3}}this.setIndex(n),this.setAttribute("position",new Float32BufferAttribute(r,3)),this.setAttribute("normal",new Float32BufferAttribute(i,3)),this.setAttribute("uv",new Float32BufferAttribute(a,2))}toJSON(){const e=super.toJSON();return toJSON(this.parameters.shapes,e)}static fromJSON(e,t){const n=[];for(let r=0,i=e.shapes.length;r<i;r++){n.push(t[e.shapes[r]])}return new ShapeGeometry(n,e.curveSegments)}}function toJSON(e,t){if(t.shapes=[],Array.isArray(e))for(let n=0,r=e.length;n<r;n++){t.shapes.push(e[n].uuid)}else t.shapes.push(e.uuid);return t}class ShadowMaterial extends Material{constructor(e){super(),this.type="ShadowMaterial",this.color=new Color$1(0),this.transparent=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this}}ShadowMaterial.prototype.isShadowMaterial=!0;class MeshStandardMaterial extends Material{constructor(e){super(),this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new Color$1(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Color$1(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=TangentSpaceNormalMap,this.normalScale=new Vector2(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this}}MeshStandardMaterial.prototype.isMeshStandardMaterial=!0;class MeshPhysicalMaterial extends MeshStandardMaterial{constructor(e){super(),this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Vector2(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return clamp(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(e){this.ior=(1+.4*e)/(1-.4*e)}}),this.sheenColor=new Color$1(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=0,this.attenuationColor=new Color$1(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Color$1(1,1,1),this.specularColorMap=null,this._sheen=0,this._clearcoat=0,this._transmission=0,this.setValues(e)}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.ior=e.ior,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}MeshPhysicalMaterial.prototype.isMeshPhysicalMaterial=!0;class MeshPhongMaterial extends Material{constructor(e){super(),this.type="MeshPhongMaterial",this.color=new Color$1(16777215),this.specular=new Color$1(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Color$1(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=TangentSpaceNormalMap,this.normalScale=new Vector2(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=MultiplyOperation,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this}}MeshPhongMaterial.prototype.isMeshPhongMaterial=!0;class MeshToonMaterial extends Material{constructor(e){super(),this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new Color$1(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Color$1(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=TangentSpaceNormalMap,this.normalScale=new Vector2(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this}}MeshToonMaterial.prototype.isMeshToonMaterial=!0;class MeshNormalMaterial extends Material{constructor(e){super(),this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=TangentSpaceNormalMap,this.normalScale=new Vector2(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}MeshNormalMaterial.prototype.isMeshNormalMaterial=!0;class MeshLambertMaterial extends Material{constructor(e){super(),this.type="MeshLambertMaterial",this.color=new Color$1(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Color$1(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=MultiplyOperation,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this}}MeshLambertMaterial.prototype.isMeshLambertMaterial=!0;class MeshMatcapMaterial extends Material{constructor(e){super(),this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Color$1(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=TangentSpaceNormalMap,this.normalScale=new Vector2(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this}}MeshMatcapMaterial.prototype.isMeshMatcapMaterial=!0;class LineDashedMaterial extends LineBasicMaterial{constructor(e){super(),this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}LineDashedMaterial.prototype.isLineDashedMaterial=!0;const AnimationUtils={arraySlice:function(e,t,n){return AnimationUtils.isTypedArray(e)?new e.constructor(e.subarray(t,void 0!==n?n:e.length)):e.slice(t,n)},convertArray:function(e,t,n){return!e||!n&&e.constructor===t?e:"number"==typeof t.BYTES_PER_ELEMENT?new t(e):Array.prototype.slice.call(e)},isTypedArray:function(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)},getKeyframeOrder:function(e){const t=e.length,n=new Array(t);for(let e=0;e!==t;++e)n[e]=e;return n.sort((function r(t,n){return e[t]-e[n]})),n},sortedArray:function(e,t,n){const r=e.length,i=new e.constructor(r);for(let a=0,o=0;o!==r;++a){const r=n[a]*t;for(let n=0;n!==t;++n)i[o++]=e[r+n]}return i},flattenJSON:function(e,t,n,r){let i=1,a=e[0];for(;void 0!==a&&void 0===a[r];)a=e[i++];if(void 0===a)return;let o=a[r];if(void 0!==o)if(Array.isArray(o))do{o=a[r],void 0!==o&&(t.push(a.time),n.push.apply(n,o)),a=e[i++]}while(void 0!==a);else if(void 0!==o.toArray)do{o=a[r],void 0!==o&&(t.push(a.time),o.toArray(n,n.length)),a=e[i++]}while(void 0!==a);else do{o=a[r],void 0!==o&&(t.push(a.time),n.push(o)),a=e[i++]}while(void 0!==a)},subclip:function(e,t,n,r,i=30){const a=e.clone();a.name=t;const o=[];for(let e=0;e<a.tracks.length;++e){const t=a.tracks[e],s=t.getValueSize(),l=[],c=[];for(let e=0;e<t.times.length;++e){const a=t.times[e]*i;if(!(a<n||a>=r)){l.push(t.times[e]);for(let n=0;n<s;++n)c.push(t.values[e*s+n])}}0!==l.length&&(t.times=AnimationUtils.convertArray(l,t.times.constructor),t.values=AnimationUtils.convertArray(c,t.values.constructor),o.push(t))}a.tracks=o;let s=1/0;for(let e=0;e<a.tracks.length;++e)s>a.tracks[e].times[0]&&(s=a.tracks[e].times[0]);for(let e=0;e<a.tracks.length;++e)a.tracks[e].shift(-1*s);return a.resetDuration(),a},makeClipAdditive:function(e,t=0,n=e,r=30){r<=0&&(r=30);const i=n.tracks.length,a=t/r;for(let t=0;t<i;++t){const r=n.tracks[t],i=r.ValueTypeName;if("bool"===i||"string"===i)continue;const o=e.tracks.find((function(e){return e.name===r.name&&e.ValueTypeName===i}));if(void 0===o)continue;let s=0;const l=r.getValueSize();r.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(s=l/3);let c=0;const h=o.getValueSize();o.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(c=h/3);const u=r.times.length-1;let d;if(a<=r.times[0]){d=AnimationUtils.arraySlice(r.values,s,l-s)}else if(a>=r.times[u]){const e=u*l+s;d=AnimationUtils.arraySlice(r.values,e,e+l-s)}else{const e=r.createInterpolant(),t=s,n=l-s;e.evaluate(a),d=AnimationUtils.arraySlice(e.resultBuffer,t,n)}if("quaternion"===i){(new Quaternion).fromArray(d).normalize().conjugate().toArray(d)}const p=o.times.length;for(let e=0;e<p;++e){const t=e*h+c;if("quaternion"===i)Quaternion.multiplyQuaternionsFlat(o.values,t,d,0,o.values,t);else{const e=h-2*c;for(let n=0;n<e;++n)o.values[t+n]-=d[n]}}}return e.blendMode=AdditiveAnimationBlendMode,e}};class Interpolant{constructor(e,t,n,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=void 0!==r?r:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let n=this._cachedIndex,r=t[n],i=t[n-1];e:{t:{let a;n:{r:if(!(e<r)){for(let a=n+2;;){if(void 0===r){if(e<i)break r;return n=t.length,this._cachedIndex=n,this.afterEnd_(n-1,e,i)}if(n===a)break;if(i=r,r=t[++n],e<r)break t}a=t.length;break n}if(e>=i)break e;{const o=t[1];e<o&&(n=2,i=o);for(let a=n-2;;){if(void 0===i)return this._cachedIndex=0,this.beforeStart_(0,e,r);if(n===a)break;if(r=i,i=t[--n-1],e>=i)break t}a=n,n=0}}for(;n<a;){const r=n+a>>>1;e<t[r]?a=r:n=r+1}if(r=t[n],i=t[n-1],void 0===i)return this._cachedIndex=0,this.beforeStart_(0,e,r);if(void 0===r)return n=t.length,this._cachedIndex=n,this.afterEnd_(n-1,i,e)}this._cachedIndex=n,this.intervalChanged_(n,i,r)}return this.interpolate_(n,i,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,r=this.valueSize,i=e*r;for(let e=0;e!==r;++e)t[e]=n[i+e];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}Interpolant.prototype.beforeStart_=Interpolant.prototype.copySampleValue_,Interpolant.prototype.afterEnd_=Interpolant.prototype.copySampleValue_;class CubicInterpolant extends Interpolant{constructor(e,t,n,r){super(e,t,n,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:ZeroCurvatureEnding,endingEnd:ZeroCurvatureEnding}}intervalChanged_(e,t,n){const r=this.parameterPositions;let i=e-2,a=e+1,o=r[i],s=r[a];if(void 0===o)switch(this.getSettings_().endingStart){case ZeroSlopeEnding:i=e,o=2*t-n;break;case WrapAroundEnding:i=r.length-2,o=t+r[i]-r[i+1];break;default:i=e,o=n}if(void 0===s)switch(this.getSettings_().endingEnd){case ZeroSlopeEnding:a=e,s=2*n-t;break;case WrapAroundEnding:a=1,s=n+r[1]-r[0];break;default:a=e-1,s=t}const l=.5*(n-t),c=this.valueSize;this._weightPrev=l/(t-o),this._weightNext=l/(s-n),this._offsetPrev=i*c,this._offsetNext=a*c}interpolate_(e,t,n,r){const i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=e*o,l=s-o,c=this._offsetPrev,h=this._offsetNext,u=this._weightPrev,d=this._weightNext,p=(n-t)/(r-t),m=p*p,f=m*p,g=-u*f+2*u*m-u*p,v=(1+u)*f+(-1.5-2*u)*m+(-.5+u)*p+1,y=(-1-d)*f+(1.5+d)*m+.5*p,_=d*f-d*m;for(let e=0;e!==o;++e)i[e]=g*a[c+e]+v*a[l+e]+y*a[s+e]+_*a[h+e];return i}}class LinearInterpolant extends Interpolant{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){const i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=e*o,l=s-o,c=(n-t)/(r-t),h=1-c;for(let e=0;e!==o;++e)i[e]=a[l+e]*h+a[s+e]*c;return i}}class DiscreteInterpolant extends Interpolant{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e){return this.copySampleValue_(e-1)}}class KeyframeTrack{constructor(e,t,n,r){if(void 0===e)throw new Error("THREE.KeyframeTrack: track name is undefined");if(void 0===t||0===t.length)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=AnimationUtils.convertArray(t,this.TimeBufferType),this.values=AnimationUtils.convertArray(n,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:AnimationUtils.convertArray(e.times,Array),values:AnimationUtils.convertArray(e.values,Array)};const t=e.getInterpolation();t!==e.DefaultInterpolation&&(n.interpolation=t)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new DiscreteInterpolant(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new LinearInterpolant(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new CubicInterpolant(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case InterpolateDiscrete:t=this.InterpolantFactoryMethodDiscrete;break;case InterpolateLinear:t=this.InterpolantFactoryMethodLinear;break;case InterpolateSmooth:t=this.InterpolantFactoryMethodSmooth}if(void 0===t){const t="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(void 0===this.createInterpolant){if(e===this.DefaultInterpolation)throw new Error(t);this.setInterpolation(this.DefaultInterpolation)}return console.warn("THREE.KeyframeTrack:",t),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return InterpolateDiscrete;case this.InterpolantFactoryMethodLinear:return InterpolateLinear;case this.InterpolantFactoryMethodSmooth:return InterpolateSmooth}}getValueSize(){return this.values.length/this.times.length}shift(e){if(0!==e){const t=this.times;for(let n=0,r=t.length;n!==r;++n)t[n]+=e}return this}scale(e){if(1!==e){const t=this.times;for(let n=0,r=t.length;n!==r;++n)t[n]*=e}return this}trim(e,t){const n=this.times,r=n.length;let i=0,a=r-1;for(;i!==r&&n[i]<e;)++i;for(;-1!==a&&n[a]>t;)--a;if(++a,0!==i||a!==r){i>=a&&(a=Math.max(a,1),i=a-1);const e=this.getValueSize();this.times=AnimationUtils.arraySlice(n,i,a),this.values=AnimationUtils.arraySlice(this.values,i*e,a*e)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!=0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const n=this.times,r=this.values,i=n.length;0===i&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let t=0;t!==i;t++){const r=n[t];if("number"==typeof r&&isNaN(r)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,t,r),e=!1;break}if(null!==a&&a>r){console.error("THREE.KeyframeTrack: Out of order keys.",this,t,r,a),e=!1;break}a=r}if(void 0!==r&&AnimationUtils.isTypedArray(r))for(let t=0,n=r.length;t!==n;++t){const n=r[t];if(isNaN(n)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,t,n),e=!1;break}}return e}optimize(){const e=AnimationUtils.arraySlice(this.times),t=AnimationUtils.arraySlice(this.values),n=this.getValueSize(),r=this.getInterpolation()===InterpolateSmooth,i=e.length-1;let a=1;for(let o=1;o<i;++o){let i=!1;const s=e[o];if(s!==e[o+1]&&(1!==o||s!==e[0]))if(r)i=!0;else{const e=o*n,r=e-n,a=e+n;for(let o=0;o!==n;++o){const n=t[e+o];if(n!==t[r+o]||n!==t[a+o]){i=!0;break}}}if(i){if(o!==a){e[a]=e[o];const r=o*n,i=a*n;for(let e=0;e!==n;++e)t[i+e]=t[r+e]}++a}}if(i>0){e[a]=e[i];for(let e=i*n,r=a*n,o=0;o!==n;++o)t[r+o]=t[e+o];++a}return a!==e.length?(this.times=AnimationUtils.arraySlice(e,0,a),this.values=AnimationUtils.arraySlice(t,0,a*n)):(this.times=e,this.values=t),this}clone(){const e=AnimationUtils.arraySlice(this.times,0),t=AnimationUtils.arraySlice(this.values,0),n=new(0,this.constructor)(this.name,e,t);return n.createInterpolant=this.createInterpolant,n}}KeyframeTrack.prototype.TimeBufferType=Float32Array,KeyframeTrack.prototype.ValueBufferType=Float32Array,KeyframeTrack.prototype.DefaultInterpolation=InterpolateLinear;class BooleanKeyframeTrack extends KeyframeTrack{}BooleanKeyframeTrack.prototype.ValueTypeName="bool",BooleanKeyframeTrack.prototype.ValueBufferType=Array,BooleanKeyframeTrack.prototype.DefaultInterpolation=InterpolateDiscrete,BooleanKeyframeTrack.prototype.InterpolantFactoryMethodLinear=void 0,BooleanKeyframeTrack.prototype.InterpolantFactoryMethodSmooth=void 0;class ColorKeyframeTrack extends KeyframeTrack{}ColorKeyframeTrack.prototype.ValueTypeName="color";class NumberKeyframeTrack extends KeyframeTrack{}NumberKeyframeTrack.prototype.ValueTypeName="number";class QuaternionLinearInterpolant extends Interpolant{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){const i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=(n-t)/(r-t);let l=e*o;for(let e=l+o;l!==e;l+=4)Quaternion.slerpFlat(i,0,a,l-o,a,l,s);return i}}class QuaternionKeyframeTrack extends KeyframeTrack{InterpolantFactoryMethodLinear(e){return new QuaternionLinearInterpolant(this.times,this.values,this.getValueSize(),e)}}QuaternionKeyframeTrack.prototype.ValueTypeName="quaternion",QuaternionKeyframeTrack.prototype.DefaultInterpolation=InterpolateLinear,QuaternionKeyframeTrack.prototype.InterpolantFactoryMethodSmooth=void 0;class StringKeyframeTrack extends KeyframeTrack{}StringKeyframeTrack.prototype.ValueTypeName="string",StringKeyframeTrack.prototype.ValueBufferType=Array,StringKeyframeTrack.prototype.DefaultInterpolation=InterpolateDiscrete,StringKeyframeTrack.prototype.InterpolantFactoryMethodLinear=void 0,StringKeyframeTrack.prototype.InterpolantFactoryMethodSmooth=void 0;class VectorKeyframeTrack extends KeyframeTrack{}VectorKeyframeTrack.prototype.ValueTypeName="vector";class AnimationClip{constructor(e,t=-1,n,r=NormalAnimationBlendMode){this.name=e,this.tracks=n,this.duration=t,this.blendMode=r,this.uuid=generateUUID(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,r=1/(e.fps||1);for(let e=0,i=n.length;e!==i;++e)t.push(parseKeyframeTrack(n[e]).scale(r));const i=new this(e.name,e.duration,t,e.blendMode);return i.uuid=e.uuid,i}static toJSON(e){const t=[],n=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let e=0,r=n.length;e!==r;++e)t.push(KeyframeTrack.toJSON(n[e]));return r}static CreateFromMorphTargetSequence(e,t,n,r){const i=t.length,a=[];for(let e=0;e<i;e++){let o=[],s=[];o.push((e+i-1)%i,e,(e+1)%i),s.push(0,1,0);const l=AnimationUtils.getKeyframeOrder(o);o=AnimationUtils.sortedArray(o,1,l),s=AnimationUtils.sortedArray(s,1,l),r||0!==o[0]||(o.push(i),s.push(s[0])),a.push(new NumberKeyframeTrack(".morphTargetInfluences["+t[e].name+"]",o,s).scale(1/n))}return new this(e,-1,a)}static findByName(e,t){let n=e;if(!Array.isArray(e)){const t=e;n=t.geometry&&t.geometry.animations||t.animations}for(let e=0;e<n.length;e++)if(n[e].name===t)return n[e];return null}static CreateClipsFromMorphTargetSequences(e,t,n){const r={},i=/^([\w-]*?)([\d]+)$/;for(let t=0,n=e.length;t<n;t++){const n=e[t],a=n.name.match(i);if(a&&a.length>1){const e=a[1];let t=r[e];t||(r[e]=t=[]),t.push(n)}}const a=[];for(const e in r)a.push(this.CreateFromMorphTargetSequence(e,r[e],t,n));return a}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(e,t,n,r,i){if(0!==n.length){const a=[],o=[];AnimationUtils.flattenJSON(n,a,o,r),0!==a.length&&i.push(new e(t,a,o))}},r=[],i=e.name||"default",a=e.fps||30,o=e.blendMode;let s=e.length||-1;const l=e.hierarchy||[];for(let e=0;e<l.length;e++){const i=l[e].keys;if(i&&0!==i.length)if(i[0].morphTargets){const e={};let t;for(t=0;t<i.length;t++)if(i[t].morphTargets)for(let n=0;n<i[t].morphTargets.length;n++)e[i[t].morphTargets[n]]=-1;for(const n in e){const e=[],a=[];for(let r=0;r!==i[t].morphTargets.length;++r){const r=i[t];e.push(r.time),a.push(r.morphTarget===n?1:0)}r.push(new NumberKeyframeTrack(".morphTargetInfluence["+n+"]",e,a))}s=e.length*(a||1)}else{const a=".bones["+t[e].name+"]";n(VectorKeyframeTrack,a+".position",i,"pos",r),n(QuaternionKeyframeTrack,a+".quaternion",i,"rot",r),n(VectorKeyframeTrack,a+".scale",i,"scl",r)}}if(0===r.length)return null;return new this(i,s,r,o)}resetDuration(){let e=0;for(let t=0,n=this.tracks.length;t!==n;++t){const n=this.tracks[t];e=Math.max(e,n.times[n.times.length-1])}return this.duration=e,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}function getTrackTypeForValueTypeName(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return NumberKeyframeTrack;case"vector":case"vector2":case"vector3":case"vector4":return VectorKeyframeTrack;case"color":return ColorKeyframeTrack;case"quaternion":return QuaternionKeyframeTrack;case"bool":case"boolean":return BooleanKeyframeTrack;case"string":return StringKeyframeTrack}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}function parseKeyframeTrack(e){if(void 0===e.type)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const t=getTrackTypeForValueTypeName(e.type);if(void 0===e.times){const t=[],n=[];AnimationUtils.flattenJSON(e.keys,t,n,"value"),e.times=t,e.values=n}return void 0!==t.parse?t.parse(e):new t(e.name,e.times,e.values,e.interpolation)}const Cache={enabled:!1,files:{},add:function(e,t){!1!==this.enabled&&(this.files[e]=t)},get:function(e){if(!1!==this.enabled)return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}};class LoadingManager{constructor(e,t,n){const r=this;let i,a=!1,o=0,s=0;const l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(e){s++,!1===a&&void 0!==r.onStart&&r.onStart(e,o,s),a=!0},this.itemEnd=function(e){o++,void 0!==r.onProgress&&r.onProgress(e,o,s),o===s&&(a=!1,void 0!==r.onLoad&&r.onLoad())},this.itemError=function(e){void 0!==r.onError&&r.onError(e)},this.resolveURL=function(e){return i?i(e):e},this.setURLModifier=function(e){return i=e,this},this.addHandler=function(e,t){return l.push(e,t),this},this.removeHandler=function(e){const t=l.indexOf(e);return-1!==t&&l.splice(t,2),this},this.getHandler=function(e){for(let t=0,n=l.length;t<n;t+=2){const n=l[t],r=l[t+1];if(n.global&&(n.lastIndex=0),n.test(e))return r}return null}}}const DefaultLoadingManager=new LoadingManager;class Loader{constructor(e){this.manager=void 0!==e?e:DefaultLoadingManager,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const n=this;return new Promise((function(r,i){n.load(e,r,t,i)}))}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}}const loading={};class FileLoader extends Loader{constructor(e){super(e)}load(e,t,n,r){void 0===e&&(e=""),void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);const i=Cache.get(e);if(void 0!==i)return this.manager.itemStart(e),setTimeout((()=>{t&&t(i),this.manager.itemEnd(e)}),0),i;if(void 0!==loading[e])return void loading[e].push({onLoad:t,onProgress:n,onError:r});loading[e]=[],loading[e].push({onLoad:t,onProgress:n,onError:r});const a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),o=this.mimeType,s=this.responseType;fetch(a).then((t=>{if(200===t.status||0===t.status){if(0===t.status&&console.warn("THREE.FileLoader: HTTP Status 0 received."),"undefined"==typeof ReadableStream||void 0===t.body.getReader)return t;const n=loading[e],r=t.body.getReader(),i=t.headers.get("Content-Length"),a=i?parseInt(i):0,o=0!==a;let s=0;const l=new ReadableStream({start(e){!(function t(){r.read().then((({done:r,value:i})=>{if(r)e.close();else{s+=i.byteLength;const r=new ProgressEvent("progress",{lengthComputable:o,loaded:s,total:a});for(let e=0,t=n.length;e<t;e++){const t=n[e];t.onProgress&&t.onProgress(r)}e.enqueue(i),t()}}))})()}});return new Response(l)}throw Error(`fetch for "${t.url}" responded with ${t.status}: ${t.statusText}`)})).then((e=>{switch(s){case"arraybuffer":return e.arrayBuffer();case"blob":return e.blob();case"document":return e.text().then((e=>(new DOMParser).parseFromString(e,o)));case"json":return e.json();default:if(void 0===o)return e.text();{const t=/charset="?([^;"\s]*)"?/i.exec(o),n=t&&t[1]?t[1].toLowerCase():void 0,r=new TextDecoder(n);return e.arrayBuffer().then((e=>r.decode(e)))}}})).then((t=>{Cache.add(e,t);const n=loading[e];delete loading[e];for(let e=0,r=n.length;e<r;e++){const r=n[e];r.onLoad&&r.onLoad(t)}})).catch((t=>{const n=loading[e];if(void 0===n)throw this.manager.itemError(e),t;delete loading[e];for(let e=0,r=n.length;e<r;e++){const r=n[e];r.onError&&r.onError(t)}this.manager.itemError(e)})).finally((()=>{this.manager.itemEnd(e)})),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class ImageLoader extends Loader{constructor(e){super(e)}load(e,t,n,r){void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);const i=this,a=Cache.get(e);if(void 0!==a)return i.manager.itemStart(e),setTimeout((function(){t&&t(a),i.manager.itemEnd(e)}),0),a;const o=createElementNS("img");function s(){c(),Cache.add(e,this),t&&t(this),i.manager.itemEnd(e)}function l(t){c(),r&&r(t),i.manager.itemError(e),i.manager.itemEnd(e)}function c(){o.removeEventListener("load",s,!1),o.removeEventListener("error",l,!1)}return o.addEventListener("load",s,!1),o.addEventListener("error",l,!1),"data:"!==e.substr(0,5)&&void 0!==this.crossOrigin&&(o.crossOrigin=this.crossOrigin),i.manager.itemStart(e),o.src=e,o}}class CubeTextureLoader extends Loader{constructor(e){super(e)}load(e,t,n,r){const i=new CubeTexture,a=new ImageLoader(this.manager);a.setCrossOrigin(this.crossOrigin),a.setPath(this.path);let o=0;function s(n){a.load(e[n],(function(e){i.images[n]=e,o++,6===o&&(i.needsUpdate=!0,t&&t(i))}),void 0,r)}for(let t=0;t<e.length;++t)s(t);return i}}class TextureLoader extends Loader{constructor(e){super(e)}load(e,t,n,r){const i=new Texture,a=new ImageLoader(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(e,(function(e){i.image=e,i.needsUpdate=!0,void 0!==t&&t(i)}),n,r),i}}class Light extends Object3D{constructor(e,t=1){super(),this.type="Light",this.color=new Color$1(e),this.intensity=t}dispose(){}copy(e){return super.copy(e),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,void 0!==this.groundColor&&(t.object.groundColor=this.groundColor.getHex()),void 0!==this.distance&&(t.object.distance=this.distance),void 0!==this.angle&&(t.object.angle=this.angle),void 0!==this.decay&&(t.object.decay=this.decay),void 0!==this.penumbra&&(t.object.penumbra=this.penumbra),void 0!==this.shadow&&(t.object.shadow=this.shadow.toJSON()),t}}Light.prototype.isLight=!0;class HemisphereLight extends Light{constructor(e,t,n){super(e,n),this.type="HemisphereLight",this.position.copy(Object3D.DefaultUp),this.updateMatrix(),this.groundColor=new Color$1(t)}copy(e){return Light.prototype.copy.call(this,e),this.groundColor.copy(e.groundColor),this}}HemisphereLight.prototype.isHemisphereLight=!0;const _projScreenMatrix$1=new Matrix4,_lightPositionWorld$1=new Vector3,_lookTarget$1=new Vector3;class LightShadow{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Vector2(512,512),this.map=null,this.mapPass=null,this.matrix=new Matrix4,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Frustum,this._frameExtents=new Vector2(1,1),this._viewportCount=1,this._viewports=[new Vector4(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;_lightPositionWorld$1.setFromMatrixPosition(e.matrixWorld),t.position.copy(_lightPositionWorld$1),_lookTarget$1.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(_lookTarget$1),t.updateMatrixWorld(),_projScreenMatrix$1.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(_projScreenMatrix$1),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(t.projectionMatrix),n.multiply(t.matrixWorldInverse)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return(new this.constructor).copy(this)}toJSON(){const e={};return 0!==this.bias&&(e.bias=this.bias),0!==this.normalBias&&(e.normalBias=this.normalBias),1!==this.radius&&(e.radius=this.radius),512===this.mapSize.x&&512===this.mapSize.y||(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class SpotLightShadow extends LightShadow{constructor(){super(new PerspectiveCamera(50,1,.5,500)),this.focus=1}updateMatrices(e){const t=this.camera,n=2*RAD2DEG*e.angle*this.focus,r=this.mapSize.width/this.mapSize.height,i=e.distance||t.far;n===t.fov&&r===t.aspect&&i===t.far||(t.fov=n,t.aspect=r,t.far=i,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}SpotLightShadow.prototype.isSpotLightShadow=!0;class SpotLight extends Light{constructor(e,t,n=0,r=Math.PI/3,i=0,a=1){super(e,t),this.type="SpotLight",this.position.copy(Object3D.DefaultUp),this.updateMatrix(),this.target=new Object3D,this.distance=n,this.angle=r,this.penumbra=i,this.decay=a,this.shadow=new SpotLightShadow}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}SpotLight.prototype.isSpotLight=!0;const _projScreenMatrix=new Matrix4,_lightPositionWorld=new Vector3,_lookTarget=new Vector3;class PointLightShadow extends LightShadow{constructor(){super(new PerspectiveCamera(90,1,.5,500)),this._frameExtents=new Vector2(4,2),this._viewportCount=6,this._viewports=[new Vector4(2,1,1,1),new Vector4(0,1,1,1),new Vector4(3,1,1,1),new Vector4(1,1,1,1),new Vector4(3,0,1,1),new Vector4(1,0,1,1)],this._cubeDirections=[new Vector3(1,0,0),new Vector3(-1,0,0),new Vector3(0,0,1),new Vector3(0,0,-1),new Vector3(0,1,0),new Vector3(0,-1,0)],this._cubeUps=[new Vector3(0,1,0),new Vector3(0,1,0),new Vector3(0,1,0),new Vector3(0,1,0),new Vector3(0,0,1),new Vector3(0,0,-1)]}updateMatrices(e,t=0){const n=this.camera,r=this.matrix,i=e.distance||n.far;i!==n.far&&(n.far=i,n.updateProjectionMatrix()),_lightPositionWorld.setFromMatrixPosition(e.matrixWorld),n.position.copy(_lightPositionWorld),_lookTarget.copy(n.position),_lookTarget.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(_lookTarget),n.updateMatrixWorld(),r.makeTranslation(-_lightPositionWorld.x,-_lightPositionWorld.y,-_lightPositionWorld.z),_projScreenMatrix.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(_projScreenMatrix)}}PointLightShadow.prototype.isPointLightShadow=!0;class PointLight extends Light{constructor(e,t,n=0,r=1){super(e,t),this.type="PointLight",this.distance=n,this.decay=r,this.shadow=new PointLightShadow}get power(){return 4*this.intensity*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}PointLight.prototype.isPointLight=!0;class DirectionalLightShadow extends LightShadow{constructor(){super(new OrthographicCamera(-5,5,5,-5,.5,500))}}DirectionalLightShadow.prototype.isDirectionalLightShadow=!0;class DirectionalLight extends Light{constructor(e,t){super(e,t),this.type="DirectionalLight",this.position.copy(Object3D.DefaultUp),this.updateMatrix(),this.target=new Object3D,this.shadow=new DirectionalLightShadow}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}DirectionalLight.prototype.isDirectionalLight=!0;class AmbientLight extends Light{constructor(e,t){super(e,t),this.type="AmbientLight"}}AmbientLight.prototype.isAmbientLight=!0;class RectAreaLight extends Light{constructor(e,t,n=10,r=10){super(e,t),this.type="RectAreaLight",this.width=n,this.height=r}get power(){return this.intensity*this.width*this.height*Math.PI}set power(e){this.intensity=e/(this.width*this.height*Math.PI)}copy(e){return super.copy(e),this.width=e.width,this.height=e.height,this}toJSON(e){const t=super.toJSON(e);return t.object.width=this.width,t.object.height=this.height,t}}RectAreaLight.prototype.isRectAreaLight=!0;class SphericalHarmonics3{constructor(){this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new Vector3)}set(e){for(let t=0;t<9;t++)this.coefficients[t].copy(e[t]);return this}zero(){for(let e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this}getAt(e,t){const n=e.x,r=e.y,i=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.282095),t.addScaledVector(a[1],.488603*r),t.addScaledVector(a[2],.488603*i),t.addScaledVector(a[3],.488603*n),t.addScaledVector(a[4],n*r*1.092548),t.addScaledVector(a[5],r*i*1.092548),t.addScaledVector(a[6],.315392*(3*i*i-1)),t.addScaledVector(a[7],n*i*1.092548),t.addScaledVector(a[8],.546274*(n*n-r*r)),t}getIrradianceAt(e,t){const n=e.x,r=e.y,i=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.886227),t.addScaledVector(a[1],1.023328*r),t.addScaledVector(a[2],1.023328*i),t.addScaledVector(a[3],1.023328*n),t.addScaledVector(a[4],.858086*n*r),t.addScaledVector(a[5],.858086*r*i),t.addScaledVector(a[6],.743125*i*i-.247708),t.addScaledVector(a[7],.858086*n*i),t.addScaledVector(a[8],.429043*(n*n-r*r)),t}add(e){for(let t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}addScaledSH(e,t){for(let n=0;n<9;n++)this.coefficients[n].addScaledVector(e.coefficients[n],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let n=0;n<9;n++)this.coefficients[n].lerp(e.coefficients[n],t);return this}equals(e){for(let t=0;t<9;t++)if(!this.coefficients[t].equals(e.coefficients[t]))return!1;return!0}copy(e){return this.set(e.coefficients)}clone(){return(new this.constructor).copy(this)}fromArray(e,t=0){const n=this.coefficients;for(let r=0;r<9;r++)n[r].fromArray(e,t+3*r);return this}toArray(e=[],t=0){const n=this.coefficients;for(let r=0;r<9;r++)n[r].toArray(e,t+3*r);return e}static getBasisAt(e,t){const n=e.x,r=e.y,i=e.z;t[0]=.282095,t[1]=.488603*r,t[2]=.488603*i,t[3]=.488603*n,t[4]=1.092548*n*r,t[5]=1.092548*r*i,t[6]=.315392*(3*i*i-1),t[7]=1.092548*n*i,t[8]=.546274*(n*n-r*r)}}SphericalHarmonics3.prototype.isSphericalHarmonics3=!0;class LightProbe extends Light{constructor(e=new SphericalHarmonics3,t=1){super(void 0,t),this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}fromJSON(e){return this.intensity=e.intensity,this.sh.fromArray(e.sh),this}toJSON(e){const t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}}LightProbe.prototype.isLightProbe=!0;class LoaderUtils{static decodeText(e){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);let t="";for(let n=0,r=e.length;n<r;n++)t+=String.fromCharCode(e[n]);try{return decodeURIComponent(escape(t))}catch(e){return t}}static extractUrlBase(e){const t=e.lastIndexOf("/");return-1===t?"./":e.substr(0,t+1)}static resolveURL(e,t){return"string"!=typeof e||""===e?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}}class InstancedBufferGeometry extends BufferGeometry{constructor(){super(),this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}clone(){return(new this.constructor).copy(this)}toJSON(){const e=super.toJSON(this);return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}}InstancedBufferGeometry.prototype.isInstancedBufferGeometry=!0;class ImageBitmapLoader extends Loader{constructor(e){super(e),"undefined"==typeof createImageBitmap&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),"undefined"==typeof fetch&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,n,r){void 0===e&&(e=""),void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);const i=this,a=Cache.get(e);if(void 0!==a)return i.manager.itemStart(e),setTimeout((function(){t&&t(a),i.manager.itemEnd(e)}),0),a;const o={};o.credentials="anonymous"===this.crossOrigin?"same-origin":"include",o.headers=this.requestHeader,fetch(e,o).then((function(e){return e.blob()})).then((function(e){return createImageBitmap(e,Object.assign(i.options,{colorSpaceConversion:"none"}))})).then((function(n){Cache.add(e,n),t&&t(n),i.manager.itemEnd(e)})).catch((function(t){r&&r(t),i.manager.itemError(e),i.manager.itemEnd(e)})),i.manager.itemStart(e)}}let _context;ImageBitmapLoader.prototype.isImageBitmapLoader=!0;const AudioContext={getContext:function(){return void 0===_context&&(_context=new(window.AudioContext||window.webkitAudioContext)),_context},setContext:function(e){_context=e}};class AudioLoader extends Loader{constructor(e){super(e)}load(e,t,n,r){const i=this,a=new FileLoader(this.manager);a.setResponseType("arraybuffer"),a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,(function(n){try{const e=n.slice(0);AudioContext.getContext().decodeAudioData(e,(function(e){t(e)}))}catch(t){r?r(t):console.error(t),i.manager.itemError(e)}}),n,r)}}class HemisphereLightProbe extends LightProbe{constructor(e,t,n=1){super(void 0,n);const r=(new Color$1).set(e),i=(new Color$1).set(t),a=new Vector3(r.r,r.g,r.b),o=new Vector3(i.r,i.g,i.b),s=Math.sqrt(Math.PI),l=s*Math.sqrt(.75);this.sh.coefficients[0].copy(a).add(o).multiplyScalar(s),this.sh.coefficients[1].copy(a).sub(o).multiplyScalar(l)}}HemisphereLightProbe.prototype.isHemisphereLightProbe=!0;class AmbientLightProbe extends LightProbe{constructor(e,t=1){super(void 0,t);const n=(new Color$1).set(e);this.sh.coefficients[0].set(n.r,n.g,n.b).multiplyScalar(2*Math.sqrt(Math.PI))}}AmbientLightProbe.prototype.isAmbientLightProbe=!0;class Audio extends Object3D{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(!0===this.isPlaying)return void console.warn("THREE.Audio: Audio is already playing.");if(!1===this.hasPlaybackControl)return void console.warn("THREE.Audio: this Audio has no playback control.");this._startedAt=this.context.currentTime+e;const t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(!1!==this.hasPlaybackControl)return!0===this.isPlaying&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,!0===this.loop&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this;console.warn("THREE.Audio: this Audio has no playback control.")}stop(){if(!1!==this.hasPlaybackControl)return this._progress=0,this.source.stop(),this.source.onended=null,this.isPlaying=!1,this;console.warn("THREE.Audio: this Audio has no playback control.")}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].connect(this.filters[e]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].disconnect(this.filters[e]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this._connected=!1,this}getFilters(){return this.filters}setFilters(e){return e||(e=[]),!0===this._connected?(this.disconnect(),this.filters=e.slice(),this.connect()):this.filters=e.slice(),this}setDetune(e){if(this.detune=e,void 0!==this.source.detune)return!0===this.isPlaying&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this}getDetune(){return this.detune}getFilter(){return this.getFilters()[0]}setFilter(e){return this.setFilters(e?[e]:[])}setPlaybackRate(e){if(!1!==this.hasPlaybackControl)return this.playbackRate=e,!0===this.isPlaying&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this;console.warn("THREE.Audio: this Audio has no playback control.")}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1}getLoop(){return!1===this.hasPlaybackControl?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop}setLoop(e){if(!1!==this.hasPlaybackControl)return this.loop=e,!0===this.isPlaying&&(this.source.loop=this.loop),this;console.warn("THREE.Audio: this Audio has no playback control.")}setLoopStart(e){return this.loopStart=e,this}setLoopEnd(e){return this.loopEnd=e,this}getVolume(){return this.gain.gain.value}setVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}}class PropertyMixer{constructor(e,t,n){let r,i,a;switch(this.binding=e,this.valueSize=n,t){case"quaternion":r=this._slerp,i=this._slerpAdditive,a=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(6*n),this._workIndex=5;break;case"string":case"bool":r=this._select,i=this._select,a=this._setAdditiveIdentityOther,this.buffer=new Array(5*n);break;default:r=this._lerp,i=this._lerpAdditive,a=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(5*n)}this._mixBufferRegion=r,this._mixBufferRegionAdditive=i,this._setIdentity=a,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){const n=this.buffer,r=this.valueSize,i=e*r+r;let a=this.cumulativeWeight;if(0===a){for(let e=0;e!==r;++e)n[i+e]=n[e];a=t}else{a+=t;this._mixBufferRegion(n,i,0,t/a,r)}this.cumulativeWeight=a}accumulateAdditive(e){const t=this.buffer,n=this.valueSize,r=n*this._addIndex;0===this.cumulativeWeightAdditive&&this._setIdentity(),this._mixBufferRegionAdditive(t,r,0,e,n),this.cumulativeWeightAdditive+=e}apply(e){const t=this.valueSize,n=this.buffer,r=e*t+t,i=this.cumulativeWeight,a=this.cumulativeWeightAdditive,o=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,i<1){this._mixBufferRegion(n,r,t*this._origIndex,1-i,t)}a>0&&this._mixBufferRegionAdditive(n,r,this._addIndex*t,1,t);for(let e=t,i=t+t;e!==i;++e)if(n[e]!==n[e+t]){o.setValue(n,r);break}}saveOriginalState(){const e=this.buffer,t=this.valueSize,n=t*this._origIndex;this.binding.getValue(e,n);for(let r=t,i=n;r!==i;++r)e[r]=e[n+r%t];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){this.binding.setValue(this.buffer,3*this.valueSize)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n<t;n++)this.buffer[n]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){const e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let n=0;n<this.valueSize;n++)this.buffer[t+n]=this.buffer[e+n]}_select(e,t,n,r,i){if(r>=.5)for(let r=0;r!==i;++r)e[t+r]=e[n+r]}_slerp(e,t,n,r){Quaternion.slerpFlat(e,t,e,t,e,n,r)}_slerpAdditive(e,t,n,r,i){const a=this._workIndex*i;Quaternion.multiplyQuaternionsFlat(e,a,e,t,e,n),Quaternion.slerpFlat(e,t,e,t,e,a,r)}_lerp(e,t,n,r,i){const a=1-r;for(let o=0;o!==i;++o){const i=t+o;e[i]=e[i]*a+e[n+o]*r}}_lerpAdditive(e,t,n,r,i){for(let a=0;a!==i;++a){const i=t+a;e[i]=e[i]+e[n+a]*r}}}const _RESERVED_CHARS_RE="\\[\\]\\.:\\/",_reservedRe=new RegExp("["+_RESERVED_CHARS_RE+"]","g"),_wordChar="[^"+_RESERVED_CHARS_RE+"]",_wordCharOrDot="[^"+_RESERVED_CHARS_RE.replace("\\.","")+"]",_directoryRe=/((?:WC+[\/:])*)/.source.replace("WC",_wordChar),_nodeRe=/(WCOD+)?/.source.replace("WCOD",_wordCharOrDot),_objectRe=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",_wordChar),_propertyRe=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",_wordChar),_trackRe=new RegExp("^"+_directoryRe+_nodeRe+_objectRe+_propertyRe+"$"),_supportedObjectNames=["material","materials","bones"];class Composite{constructor(e,t,n){const r=n||PropertyBinding.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();const n=this._bindings[this._targetGroup.nCachedObjects_];void 0!==n&&n.getValue(e,t)}setValue(e,t){const n=this._bindings;for(let r=this._targetGroup.nCachedObjects_,i=n.length;r!==i;++r)n[r].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class PropertyBinding{constructor(e,t,n){this.path=t,this.parsedPath=n||PropertyBinding.parseTrackName(t),this.node=PropertyBinding.findNode(e,this.parsedPath.nodeName)||e,this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new PropertyBinding.Composite(e,t,n):new PropertyBinding(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(_reservedRe,"")}static parseTrackName(e){const t=_trackRe.exec(e);if(!t)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=n.nodeName&&n.nodeName.lastIndexOf(".");if(void 0!==r&&-1!==r){const e=n.nodeName.substring(r+1);-1!==_supportedObjectNames.indexOf(e)&&(n.nodeName=n.nodeName.substring(0,r),n.objectName=e)}if(null===n.propertyName||0===n.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(!t||""===t||"."===t||-1===t||t===e.name||t===e.uuid)return e;if(e.skeleton){const n=e.skeleton.getBoneByName(t);if(void 0!==n)return n}if(e.children){const n=function(e){for(let r=0;r<e.length;r++){const i=e[r];if(i.name===t||i.uuid===t)return i;const a=n(i.children);if(a)return a}return null},r=n(e.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)e[t++]=n[r]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){const n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)n[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)n[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)n[r]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node;const t=this.parsedPath,n=t.objectName,r=t.propertyName;let i=t.propertyIndex;if(e||(e=PropertyBinding.findNode(this.rootNode,t.nodeName)||this.rootNode,this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e)return void console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.");if(n){let r=t.objectIndex;switch(n){case"materials":if(!e.material)return void console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);if(!e.material.materials)return void console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);e=e.material.materials;break;case"bones":if(!e.skeleton)return void console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);e=e.skeleton.bones;for(let t=0;t<e.length;t++)if(e[t].name===r){r=t;break}break;default:if(void 0===e[n])return void console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);e=e[n]}if(void 0!==r){if(void 0===e[r])return void console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);e=e[r]}}const a=e[r];if(void 0===a){return void console.error("THREE.PropertyBinding: Trying to update property for track: "+t.nodeName+"."+r+" but it wasn't found.",e)}let o=this.Versioning.None;this.targetObject=e,void 0!==e.needsUpdate?o=this.Versioning.NeedsUpdate:void 0!==e.matrixWorldNeedsUpdate&&(o=this.Versioning.MatrixWorldNeedsUpdate);let s=this.BindingType.Direct;if(void 0!==i){if("morphTargetInfluences"===r){if(!e.geometry)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);if(!e.geometry.isBufferGeometry)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences on THREE.Geometry. Use THREE.BufferGeometry instead.",this);if(!e.geometry.morphAttributes)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);void 0!==e.morphTargetDictionary[i]&&(i=e.morphTargetDictionary[i])}s=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=i}else void 0!==a.fromArray&&void 0!==a.toArray?(s=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(s=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=r;this.getValue=this.GetterByBindingType[s],this.setValue=this.SetterByBindingTypeAndVersioning[s][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}PropertyBinding.Composite=Composite,PropertyBinding.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},PropertyBinding.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},PropertyBinding.prototype.GetterByBindingType=[PropertyBinding.prototype._getValue_direct,PropertyBinding.prototype._getValue_array,PropertyBinding.prototype._getValue_arrayElement,PropertyBinding.prototype._getValue_toArray],PropertyBinding.prototype.SetterByBindingTypeAndVersioning=[[PropertyBinding.prototype._setValue_direct,PropertyBinding.prototype._setValue_direct_setNeedsUpdate,PropertyBinding.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[PropertyBinding.prototype._setValue_array,PropertyBinding.prototype._setValue_array_setNeedsUpdate,PropertyBinding.prototype._setValue_array_setMatrixWorldNeedsUpdate],[PropertyBinding.prototype._setValue_arrayElement,PropertyBinding.prototype._setValue_arrayElement_setNeedsUpdate,PropertyBinding.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[PropertyBinding.prototype._setValue_fromArray,PropertyBinding.prototype._setValue_fromArray_setNeedsUpdate,PropertyBinding.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class AnimationAction{constructor(e,t,n=null,r=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=r;const i=t.tracks,a=i.length,o=new Array(a),s={endingStart:ZeroCurvatureEnding,endingEnd:ZeroCurvatureEnding};for(let e=0;e!==a;++e){const t=i[e].createInterpolant(null);o[e]=t,t.settings=s}this._interpolantSettings=s,this._interpolants=o,this._propertyBindings=new Array(a),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=LoopRepeat,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&0!==this.timeScale&&null===this._startTime&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,n){if(e.fadeOut(t),this.fadeIn(t),n){const n=this._clip.duration,r=e._clip.duration,i=n/r;e.warp(1,r/n,t),this.warp(i,1,t)}return this}crossFadeTo(e,t,n){return e.crossFadeFrom(this,t,n)}stopFading(){const e=this._weightInterpolant;return null!==e&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,n){const r=this._mixer,i=r.time,a=this.timeScale;let o=this._timeScaleInterpolant;null===o&&(o=r._lendControlInterpolant(),this._timeScaleInterpolant=o);const s=o.parameterPositions,l=o.sampleValues;return s[0]=i,s[1]=i+n,l[0]=e/a,l[1]=t/a,this}stopWarping(){const e=this._timeScaleInterpolant;return null!==e&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,n,r){if(!this.enabled)return void this._updateWeight(e);const i=this._startTime;if(null!==i){const r=(e-i)*n;if(r<0||0===n)return;this._startTime=null,t=n*r}t*=this._updateTimeScale(e);const a=this._updateTime(t),o=this._updateWeight(e);if(o>0){const e=this._interpolants,t=this._propertyBindings;switch(this.blendMode){case AdditiveAnimationBlendMode:for(let n=0,r=e.length;n!==r;++n)e[n].evaluate(a),t[n].accumulateAdditive(o);break;case NormalAnimationBlendMode:default:for(let n=0,i=e.length;n!==i;++n)e[n].evaluate(a),t[n].accumulate(r,o)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const n=this._weightInterpolant;if(null!==n){const r=n.evaluate(e)[0];t*=r,e>n.parameterPositions[1]&&(this.stopFading(),0===r&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const n=this._timeScaleInterpolant;if(null!==n){t*=n.evaluate(e)[0],e>n.parameterPositions[1]&&(this.stopWarping(),0===t?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,n=this.loop;let r=this.time+e,i=this._loopCount;const a=n===LoopPingPong;if(0===e)return-1===i?r:a&&1==(1&i)?t-r:r;if(n===LoopOnce){-1===i&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(r>=t)r=t;else{if(!(r<0)){this.time=r;break e}r=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(-1===i&&(e>=0?(i=0,this._setEndings(!0,0===this.repetitions,a)):this._setEndings(0===this.repetitions,!0,a)),r>=t||r<0){const n=Math.floor(r/t);r-=t*n,i+=Math.abs(n);const o=this.repetitions-i;if(o<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,r=e>0?t:0,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(1===o){const t=e<0;this._setEndings(t,!t,a)}else this._setEndings(!1,!1,a);this._loopCount=i,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:n})}}else this.time=r;if(a&&1==(1&i))return t-r}return r}_setEndings(e,t,n){const r=this._interpolantSettings;n?(r.endingStart=ZeroSlopeEnding,r.endingEnd=ZeroSlopeEnding):(r.endingStart=e?this.zeroSlopeAtStart?ZeroSlopeEnding:ZeroCurvatureEnding:WrapAroundEnding,r.endingEnd=t?this.zeroSlopeAtEnd?ZeroSlopeEnding:ZeroCurvatureEnding:WrapAroundEnding)}_scheduleFading(e,t,n){const r=this._mixer,i=r.time;let a=this._weightInterpolant;null===a&&(a=r._lendControlInterpolant(),this._weightInterpolant=a);const o=a.parameterPositions,s=a.sampleValues;return o[0]=i,s[0]=t,o[1]=i+e,s[1]=n,this}}class AnimationMixer extends EventDispatcher{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const n=e._localRoot||this._root,r=e._clip.tracks,i=r.length,a=e._propertyBindings,o=e._interpolants,s=n.uuid,l=this._bindingsByRootAndName;let c=l[s];void 0===c&&(c={},l[s]=c);for(let e=0;e!==i;++e){const i=r[e],l=i.name;let h=c[l];if(void 0!==h)++h.referenceCount,a[e]=h;else{if(h=a[e],void 0!==h){null===h._cacheIndex&&(++h.referenceCount,this._addInactiveBinding(h,s,l));continue}h=new PropertyMixer(PropertyBinding.create(n,l,t&&t._propertyBindings[e].binding.parsedPath),i.ValueTypeName,i.getValueSize()),++h.referenceCount,this._addInactiveBinding(h,s,l),a[e]=h}o[e].resultBuffer=h.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(null===e._cacheIndex){const t=(e._localRoot||this._root).uuid,n=e._clip.uuid,r=this._actionsByClip[n];this._bindAction(e,r&&r.knownActions[0]),this._addInactiveAction(e,n,t)}const t=e._propertyBindings;for(let e=0,n=t.length;e!==n;++e){const n=t[e];0==n.useCount++&&(this._lendBinding(n),n.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let e=0,n=t.length;e!==n;++e){const n=t[e];0==--n.useCount&&(n.restoreOriginalState(),this._takeBackBinding(n))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){const t=e._cacheIndex;return null!==t&&t<this._nActiveActions}_addInactiveAction(e,t,n){const r=this._actions,i=this._actionsByClip;let a=i[t];if(void 0===a)a={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,i[t]=a;else{const t=a.knownActions;e._byClipCacheIndex=t.length,t.push(e)}e._cacheIndex=r.length,r.push(e),a.actionByRoot[n]=e}_removeInactiveAction(e){const t=this._actions,n=t[t.length-1],r=e._cacheIndex;n._cacheIndex=r,t[r]=n,t.pop(),e._cacheIndex=null;const i=e._clip.uuid,a=this._actionsByClip,o=a[i],s=o.knownActions,l=s[s.length-1],c=e._byClipCacheIndex;l._byClipCacheIndex=c,s[c]=l,s.pop(),e._byClipCacheIndex=null;delete o.actionByRoot[(e._localRoot||this._root).uuid],0===s.length&&delete a[i],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){const t=e._propertyBindings;for(let e=0,n=t.length;e!==n;++e){const n=t[e];0==--n.referenceCount&&this._removeInactiveBinding(n)}}_lendAction(e){const t=this._actions,n=e._cacheIndex,r=this._nActiveActions++,i=t[r];e._cacheIndex=r,t[r]=e,i._cacheIndex=n,t[n]=i}_takeBackAction(e){const t=this._actions,n=e._cacheIndex,r=--this._nActiveActions,i=t[r];e._cacheIndex=r,t[r]=e,i._cacheIndex=n,t[n]=i}_addInactiveBinding(e,t,n){const r=this._bindingsByRootAndName,i=this._bindings;let a=r[t];void 0===a&&(a={},r[t]=a),a[n]=e,e._cacheIndex=i.length,i.push(e)}_removeInactiveBinding(e){const t=this._bindings,n=e.binding,r=n.rootNode.uuid,i=n.path,a=this._bindingsByRootAndName,o=a[r],s=t[t.length-1],l=e._cacheIndex;s._cacheIndex=l,t[l]=s,t.pop(),delete o[i],0===Object.keys(o).length&&delete a[r]}_lendBinding(e){const t=this._bindings,n=e._cacheIndex,r=this._nActiveBindings++,i=t[r];e._cacheIndex=r,t[r]=e,i._cacheIndex=n,t[n]=i}_takeBackBinding(e){const t=this._bindings,n=e._cacheIndex,r=--this._nActiveBindings,i=t[r];e._cacheIndex=r,t[r]=e,i._cacheIndex=n,t[n]=i}_lendControlInterpolant(){const e=this._controlInterpolants,t=this._nActiveControlInterpolants++;let n=e[t];return void 0===n&&(n=new LinearInterpolant(new Float32Array(2),new Float32Array(2),1,this._controlInterpolantsResultBuffer),n.__cacheIndex=t,e[t]=n),n}_takeBackControlInterpolant(e){const t=this._controlInterpolants,n=e.__cacheIndex,r=--this._nActiveControlInterpolants,i=t[r];e.__cacheIndex=r,t[r]=e,i.__cacheIndex=n,t[n]=i}clipAction(e,t,n){const r=t||this._root,i=r.uuid;let a="string"==typeof e?AnimationClip.findByName(r,e):e;const o=null!==a?a.uuid:e,s=this._actionsByClip[o];let l=null;if(void 0===n&&(n=null!==a?a.blendMode:NormalAnimationBlendMode),void 0!==s){const e=s.actionByRoot[i];if(void 0!==e&&e.blendMode===n)return e;l=s.knownActions[0],null===a&&(a=l._clip)}if(null===a)return null;const c=new AnimationAction(this,a,t,n);return this._bindAction(c,l),this._addInactiveAction(c,o,i),c}existingAction(e,t){const n=t||this._root,r=n.uuid,i="string"==typeof e?AnimationClip.findByName(n,e):e,a=this._actionsByClip[i?i.uuid:e];return void 0!==a&&a.actionByRoot[r]||null}stopAllAction(){const e=this._actions;for(let t=this._nActiveActions-1;t>=0;--t)e[t].stop();return this}update(e){const t=this._actions,n=this._nActiveActions,r=this.time+=e*=this.timeScale,i=Math.sign(e),a=this._accuIndex^=1;for(let o=0;o!==n;++o){t[o]._update(r,e,i,a)}const o=this._bindings,s=this._nActiveBindings;for(let e=0;e!==s;++e)o[e].apply(a);return this}setTime(e){this.time=0;for(let e=0;e<this._actions.length;e++)this._actions[e].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){const t=this._actions,n=e.uuid,r=this._actionsByClip,i=r[n];if(void 0!==i){const e=i.knownActions;for(let n=0,r=e.length;n!==r;++n){const r=e[n];this._deactivateAction(r);const i=r._cacheIndex,a=t[t.length-1];r._cacheIndex=null,r._byClipCacheIndex=null,a._cacheIndex=i,t[i]=a,t.pop(),this._removeInactiveBindingsForAction(r)}delete r[n]}}uncacheRoot(e){const t=e.uuid,n=this._actionsByClip;for(const e in n){const r=n[e].actionByRoot[t];void 0!==r&&(this._deactivateAction(r),this._removeInactiveAction(r))}const r=this._bindingsByRootAndName[t];if(void 0!==r)for(const e in r){const t=r[e];t.restoreOriginalState(),this._removeInactiveBinding(t)}}uncacheAction(e,t){const n=this.existingAction(e,t);null!==n&&(this._deactivateAction(n),this._removeInactiveAction(n))}}AnimationMixer.prototype._controlInterpolantsResultBuffer=new Float32Array(1);class InstancedInterleavedBuffer extends InterleavedBuffer{constructor(e,t,n=1){super(e,t),this.meshPerAttribute=n}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){const t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){const t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}}InstancedInterleavedBuffer.prototype.isInstancedInterleavedBuffer=!0;class Spherical{constructor(e=1,t=0,n=0){return this.radius=e,this.phi=t,this.theta=n,this}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){const e=1e-6;return this.phi=Math.max(e,Math.min(Math.PI-e,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+t*t+n*n),0===this.radius?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,n),this.phi=Math.acos(clamp(t/this.radius,-1,1))),this}clone(){return(new this.constructor).copy(this)}}const _vector$2=new Vector3,_boneMatrix=new Matrix4,_matrixWorldInv=new Matrix4;class SkeletonHelper extends LineSegments{constructor(e){const t=getBoneList(e),n=new BufferGeometry,r=[],i=[],a=new Color$1(0,0,1),o=new Color$1(0,1,0);for(let e=0;e<t.length;e++){const n=t[e];n.parent&&n.parent.isBone&&(r.push(0,0,0),r.push(0,0,0),i.push(a.r,a.g,a.b),i.push(o.r,o.g,o.b))}n.setAttribute("position",new Float32BufferAttribute(r,3)),n.setAttribute("color",new Float32BufferAttribute(i,3));super(n,new LineBasicMaterial({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0})),this.type="SkeletonHelper",this.isSkeletonHelper=!0,this.root=e,this.bones=t,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}updateMatrixWorld(e){const t=this.bones,n=this.geometry,r=n.getAttribute("position");_matrixWorldInv.copy(this.root.matrixWorld).invert();for(let e=0,n=0;e<t.length;e++){const i=t[e];i.parent&&i.parent.isBone&&(_boneMatrix.multiplyMatrices(_matrixWorldInv,i.matrixWorld),_vector$2.setFromMatrixPosition(_boneMatrix),r.setXYZ(n,_vector$2.x,_vector$2.y,_vector$2.z),_boneMatrix.multiplyMatrices(_matrixWorldInv,i.parent.matrixWorld),_vector$2.setFromMatrixPosition(_boneMatrix),r.setXYZ(n+1,_vector$2.x,_vector$2.y,_vector$2.z),n+=2)}n.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}}function getBoneList(e){const t=[];e&&e.isBone&&t.push(e);for(let n=0;n<e.children.length;n++)t.push.apply(t,getBoneList(e.children[n]));return t}class GridHelper extends LineSegments{constructor(e=10,t=10,n=4473924,r=8947848){n=new Color$1(n),r=new Color$1(r);const i=t/2,a=e/t,o=e/2,s=[],l=[];for(let e=0,c=0,h=-o;e<=t;e++,h+=a){s.push(-o,0,h,o,0,h),s.push(h,0,-o,h,0,o);const t=e===i?n:r;t.toArray(l,c),c+=3,t.toArray(l,c),c+=3,t.toArray(l,c),c+=3,t.toArray(l,c),c+=3}const c=new BufferGeometry;c.setAttribute("position",new Float32BufferAttribute(s,3)),c.setAttribute("color",new Float32BufferAttribute(l,3));super(c,new LineBasicMaterial({vertexColors:!0,toneMapped:!1})),this.type="GridHelper"}}class AxesHelper extends LineSegments{constructor(e=1){const t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],n=new BufferGeometry;n.setAttribute("position",new Float32BufferAttribute(t,3)),n.setAttribute("color",new Float32BufferAttribute([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],3));super(n,new LineBasicMaterial({vertexColors:!0,toneMapped:!1})),this.type="AxesHelper"}setColors(e,t,n){const r=new Color$1,i=this.geometry.attributes.color.array;return r.set(e),r.toArray(i,0),r.toArray(i,3),r.set(t),r.toArray(i,6),r.toArray(i,9),r.set(n),r.toArray(i,12),r.toArray(i,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}const _floatView=new Float32Array(1);new Int32Array(_floatView.buffer),Curve.create=function(e,t){return console.log("THREE.Curve.create() has been deprecated"),e.prototype=Object.create(Curve.prototype),e.prototype.constructor=e,e.prototype.getPoint=t,e},Path.prototype.fromPoints=function(e){return console.warn("THREE.Path: .fromPoints() has been renamed to .setFromPoints()."),this.setFromPoints(e)},GridHelper.prototype.setColors=function(){console.error("THREE.GridHelper: setColors() has been deprecated, pass them in the constructor instead.")},SkeletonHelper.prototype.update=function(){console.error("THREE.SkeletonHelper: update() no longer needs to be called.")},Loader.prototype.extractUrlBase=function(e){return console.warn("THREE.Loader: .extractUrlBase() has been deprecated. Use THREE.LoaderUtils.extractUrlBase() instead."),LoaderUtils.extractUrlBase(e)},Loader.Handlers={add:function(){console.error("THREE.Loader: Handlers.add() has been removed. Use LoadingManager.addHandler() instead.")},get:function(){console.error("THREE.Loader: Handlers.get() has been removed. Use LoadingManager.getHandler() instead.")}},Box3.prototype.center=function(e){return console.warn("THREE.Box3: .center() has been renamed to .getCenter()."),this.getCenter(e)},Box3.prototype.empty=function(){return console.warn("THREE.Box3: .empty() has been renamed to .isEmpty()."),this.isEmpty()},Box3.prototype.isIntersectionBox=function(e){return console.warn("THREE.Box3: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(e)},Box3.prototype.isIntersectionSphere=function(e){return console.warn("THREE.Box3: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(e)},Box3.prototype.size=function(e){return console.warn("THREE.Box3: .size() has been renamed to .getSize()."),this.getSize(e)},Sphere.prototype.empty=function(){return console.warn("THREE.Sphere: .empty() has been renamed to .isEmpty()."),this.isEmpty()},Frustum.prototype.setFromMatrix=function(e){return console.warn("THREE.Frustum: .setFromMatrix() has been renamed to .setFromProjectionMatrix()."),this.setFromProjectionMatrix(e)},Matrix3.prototype.flattenToArrayOffset=function(e,t){return console.warn("THREE.Matrix3: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."),this.toArray(e,t)},Matrix3.prototype.multiplyVector3=function(e){return console.warn("THREE.Matrix3: .multiplyVector3() has been removed. Use vector.applyMatrix3( matrix ) instead."),e.applyMatrix3(this)},Matrix3.prototype.multiplyVector3Array=function(){console.error("THREE.Matrix3: .multiplyVector3Array() has been removed.")},Matrix3.prototype.applyToBufferAttribute=function(e){return console.warn("THREE.Matrix3: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix3( matrix ) instead."),e.applyMatrix3(this)},Matrix3.prototype.applyToVector3Array=function(){console.error("THREE.Matrix3: .applyToVector3Array() has been removed.")},Matrix3.prototype.getInverse=function(e){return console.warn("THREE.Matrix3: .getInverse() has been removed. Use matrixInv.copy( matrix ).invert(); instead."),this.copy(e).invert()},Matrix4.prototype.extractPosition=function(e){return console.warn("THREE.Matrix4: .extractPosition() has been renamed to .copyPosition()."),this.copyPosition(e)},Matrix4.prototype.flattenToArrayOffset=function(e,t){return console.warn("THREE.Matrix4: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."),this.toArray(e,t)},Matrix4.prototype.getPosition=function(){return console.warn("THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead."),(new Vector3).setFromMatrixColumn(this,3)},Matrix4.prototype.setRotationFromQuaternion=function(e){return console.warn("THREE.Matrix4: .setRotationFromQuaternion() has been renamed to .makeRotationFromQuaternion()."),this.makeRotationFromQuaternion(e)},Matrix4.prototype.multiplyToArray=function(){console.warn("THREE.Matrix4: .multiplyToArray() has been removed.")},Matrix4.prototype.multiplyVector3=function(e){return console.warn("THREE.Matrix4: .multiplyVector3() has been removed. Use vector.applyMatrix4( matrix ) instead."),e.applyMatrix4(this)},Matrix4.prototype.multiplyVector4=function(e){return console.warn("THREE.Matrix4: .multiplyVector4() has been removed. Use vector.applyMatrix4( matrix ) instead."),e.applyMatrix4(this)},Matrix4.prototype.multiplyVector3Array=function(){console.error("THREE.Matrix4: .multiplyVector3Array() has been removed.")},Matrix4.prototype.rotateAxis=function(e){console.warn("THREE.Matrix4: .rotateAxis() has been removed. Use Vector3.transformDirection( matrix ) instead."),e.transformDirection(this)},Matrix4.prototype.crossVector=function(e){return console.warn("THREE.Matrix4: .crossVector() has been removed. Use vector.applyMatrix4( matrix ) instead."),e.applyMatrix4(this)},Matrix4.prototype.translate=function(){console.error("THREE.Matrix4: .translate() has been removed.")},Matrix4.prototype.rotateX=function(){console.error("THREE.Matrix4: .rotateX() has been removed.")},Matrix4.prototype.rotateY=function(){console.error("THREE.Matrix4: .rotateY() has been removed.")},Matrix4.prototype.rotateZ=function(){console.error("THREE.Matrix4: .rotateZ() has been removed.")},Matrix4.prototype.rotateByAxis=function(){console.error("THREE.Matrix4: .rotateByAxis() has been removed.")},Matrix4.prototype.applyToBufferAttribute=function(e){return console.warn("THREE.Matrix4: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix4( matrix ) instead."),e.applyMatrix4(this)},Matrix4.prototype.applyToVector3Array=function(){console.error("THREE.Matrix4: .applyToVector3Array() has been removed.")},Matrix4.prototype.makeFrustum=function(e,t,n,r,i,a){return console.warn("THREE.Matrix4: .makeFrustum() has been removed. Use .makePerspective( left, right, top, bottom, near, far ) instead."),this.makePerspective(e,t,r,n,i,a)},Matrix4.prototype.getInverse=function(e){return console.warn("THREE.Matrix4: .getInverse() has been removed. Use matrixInv.copy( matrix ).invert(); instead."),this.copy(e).invert()},Plane.prototype.isIntersectionLine=function(e){return console.warn("THREE.Plane: .isIntersectionLine() has been renamed to .intersectsLine()."),this.intersectsLine(e)},Quaternion.prototype.multiplyVector3=function(e){return console.warn("THREE.Quaternion: .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead."),e.applyQuaternion(this)},Quaternion.prototype.inverse=function(){return console.warn("THREE.Quaternion: .inverse() has been renamed to invert()."),this.invert()},Ray.prototype.isIntersectionBox=function(e){return console.warn("THREE.Ray: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(e)},Ray.prototype.isIntersectionPlane=function(e){return console.warn("THREE.Ray: .isIntersectionPlane() has been renamed to .intersectsPlane()."),this.intersectsPlane(e)},Ray.prototype.isIntersectionSphere=function(e){return console.warn("THREE.Ray: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(e)},Triangle.prototype.area=function(){return console.warn("THREE.Triangle: .area() has been renamed to .getArea()."),this.getArea()},Triangle.prototype.barycoordFromPoint=function(e,t){return console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord()."),this.getBarycoord(e,t)},Triangle.prototype.midpoint=function(e){return console.warn("THREE.Triangle: .midpoint() has been renamed to .getMidpoint()."),this.getMidpoint(e)},Triangle.prototypenormal=function(e){return console.warn("THREE.Triangle: .normal() has been renamed to .getNormal()."),this.getNormal(e)},Triangle.prototype.plane=function(e){return console.warn("THREE.Triangle: .plane() has been renamed to .getPlane()."),this.getPlane(e)},Triangle.barycoordFromPoint=function(e,t,n,r,i){return console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord()."),Triangle.getBarycoord(e,t,n,r,i)},Triangle.normal=function(e,t,n,r){return console.warn("THREE.Triangle: .normal() has been renamed to .getNormal()."),Triangle.getNormal(e,t,n,r)},Shape.prototype.extractAllPoints=function(e){return console.warn("THREE.Shape: .extractAllPoints() has been removed. Use .extractPoints() instead."),this.extractPoints(e)},Shape.prototype.extrude=function(e){return console.warn("THREE.Shape: .extrude() has been removed. Use ExtrudeGeometry() instead."),new ExtrudeGeometry(this,e)},Shape.prototype.makeGeometry=function(e){return console.warn("THREE.Shape: .makeGeometry() has been removed. Use ShapeGeometry() instead."),new ShapeGeometry(this,e)},Vector2.prototype.fromAttribute=function(e,t,n){return console.warn("THREE.Vector2: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(e,t,n)},Vector2.prototype.distanceToManhattan=function(e){return console.warn("THREE.Vector2: .distanceToManhattan() has been renamed to .manhattanDistanceTo()."),this.manhattanDistanceTo(e)},Vector2.prototype.lengthManhattan=function(){return console.warn("THREE.Vector2: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()},Vector3.prototype.setEulerFromRotationMatrix=function(){console.error("THREE.Vector3: .setEulerFromRotationMatrix() has been removed. Use Euler.setFromRotationMatrix() instead.")},Vector3.prototype.setEulerFromQuaternion=function(){console.error("THREE.Vector3: .setEulerFromQuaternion() has been removed. Use Euler.setFromQuaternion() instead.")},Vector3.prototype.getPositionFromMatrix=function(e){return console.warn("THREE.Vector3: .getPositionFromMatrix() has been renamed to .setFromMatrixPosition()."),this.setFromMatrixPosition(e)},Vector3.prototype.getScaleFromMatrix=function(e){return console.warn("THREE.Vector3: .getScaleFromMatrix() has been renamed to .setFromMatrixScale()."),this.setFromMatrixScale(e)},Vector3.prototype.getColumnFromMatrix=function(e,t){return console.warn("THREE.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn()."),this.setFromMatrixColumn(t,e)},Vector3.prototype.applyProjection=function(e){return console.warn("THREE.Vector3: .applyProjection() has been removed. Use .applyMatrix4( m ) instead."),this.applyMatrix4(e)},Vector3.prototype.fromAttribute=function(e,t,n){return console.warn("THREE.Vector3: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(e,t,n)},Vector3.prototype.distanceToManhattan=function(e){return console.warn("THREE.Vector3: .distanceToManhattan() has been renamed to .manhattanDistanceTo()."),this.manhattanDistanceTo(e)},Vector3.prototype.lengthManhattan=function(){return console.warn("THREE.Vector3: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()},Vector4.prototype.fromAttribute=function(e,t,n){return console.warn("THREE.Vector4: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(e,t,n)},Vector4.prototype.lengthManhattan=function(){return console.warn("THREE.Vector4: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()},Object3D.prototype.getChildByName=function(e){return console.warn("THREE.Object3D: .getChildByName() has been renamed to .getObjectByName()."),this.getObjectByName(e)},Object3D.prototype.renderDepth=function(){console.warn("THREE.Object3D: .renderDepth has been removed. Use .renderOrder, instead.")},Object3D.prototype.translate=function(e,t){return console.warn("THREE.Object3D: .translate() has been removed. Use .translateOnAxis( axis, distance ) instead."),this.translateOnAxis(t,e)},Object3D.prototype.getWorldRotation=function(){console.error("THREE.Object3D: .getWorldRotation() has been removed. Use THREE.Object3D.getWorldQuaternion( target ) instead.")},Object3D.prototype.applyMatrix=function(e){return console.warn("THREE.Object3D: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(e)},Object.defineProperties(Object3D.prototype,{eulerOrder:{get:function(){return console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."),this.rotation.order},set:function(e){console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."),this.rotation.order=e}},useQuaternion:{get:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")},set:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")}}}),Mesh.prototype.setDrawMode=function(){console.error("THREE.Mesh: .setDrawMode() has been removed. The renderer now always assumes THREE.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary.")},Object.defineProperties(Mesh.prototype,{drawMode:{get:function(){return console.error("THREE.Mesh: .drawMode has been removed. The renderer now always assumes THREE.TrianglesDrawMode."),TrianglesDrawMode},set:function(){console.error("THREE.Mesh: .drawMode has been removed. The renderer now always assumes THREE.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary.")}}}),SkinnedMesh.prototype.initBones=function(){console.error("THREE.SkinnedMesh: initBones() has been removed.")},PerspectiveCamera.prototype.setLens=function(e,t){console.warn("THREE.PerspectiveCamera.setLens is deprecated. Use .setFocalLength and .filmGauge for a photographic setup."),void 0!==t&&(this.filmGauge=t),this.setFocalLength(e)},Object.defineProperties(Light.prototype,{onlyShadow:{set:function(){console.warn("THREE.Light: .onlyShadow has been removed.")}},shadowCameraFov:{set:function(e){console.warn("THREE.Light: .shadowCameraFov is now .shadow.camera.fov."),this.shadow.camera.fov=e}},shadowCameraLeft:{set:function(e){console.warn("THREE.Light: .shadowCameraLeft is now .shadow.camera.left."),this.shadow.camera.left=e}},shadowCameraRight:{set:function(e){console.warn("THREE.Light: .shadowCameraRight is now .shadow.camera.right."),this.shadow.camera.right=e}},shadowCameraTop:{set:function(e){console.warn("THREE.Light: .shadowCameraTop is now .shadow.camera.top."),this.shadow.camera.top=e}},shadowCameraBottom:{set:function(e){console.warn("THREE.Light: .shadowCameraBottom is now .shadow.camera.bottom."),this.shadow.camera.bottom=e}},shadowCameraNear:{set:function(e){console.warn("THREE.Light: .shadowCameraNear is now .shadow.camera.near."),this.shadow.camera.near=e}},shadowCameraFar:{set:function(e){console.warn("THREE.Light: .shadowCameraFar is now .shadow.camera.far."),this.shadow.camera.far=e}},shadowCameraVisible:{set:function(){console.warn("THREE.Light: .shadowCameraVisible has been removed. Use new THREE.CameraHelper( light.shadow.camera ) instead.")}},shadowBias:{set:function(e){console.warn("THREE.Light: .shadowBias is now .shadow.bias."),this.shadow.bias=e}},shadowDarkness:{set:function(){console.warn("THREE.Light: .shadowDarkness has been removed.")}},shadowMapWidth:{set:function(e){console.warn("THREE.Light: .shadowMapWidth is now .shadow.mapSize.width."),this.shadow.mapSize.width=e}},shadowMapHeight:{set:function(e){console.warn("THREE.Light: .shadowMapHeight is now .shadow.mapSize.height."),this.shadow.mapSize.height=e}}}),Object.defineProperties(BufferAttribute.prototype,{length:{get:function(){return console.warn("THREE.BufferAttribute: .length has been deprecated. Use .count instead."),this.array.length}},dynamic:{get:function(){return console.warn("THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead."),this.usage===DynamicDrawUsage},set:function(){console.warn("THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead."),this.setUsage(DynamicDrawUsage)}}}),BufferAttribute.prototype.setDynamic=function(e){return console.warn("THREE.BufferAttribute: .setDynamic() has been deprecated. Use .setUsage() instead."),this.setUsage(!0===e?DynamicDrawUsage:StaticDrawUsage),this},BufferAttribute.prototype.copyIndicesArray=function(){console.error("THREE.BufferAttribute: .copyIndicesArray() has been removed.")},BufferAttribute.prototype.setArray=function(){console.error("THREE.BufferAttribute: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers")},BufferGeometry.prototype.addIndex=function(e){console.warn("THREE.BufferGeometry: .addIndex() has been renamed to .setIndex()."),this.setIndex(e)},BufferGeometry.prototype.addAttribute=function(e,t){return console.warn("THREE.BufferGeometry: .addAttribute() has been renamed to .setAttribute()."),t&&t.isBufferAttribute||t&&t.isInterleavedBufferAttribute?"index"===e?(console.warn("THREE.BufferGeometry.addAttribute: Use .setIndex() for index attribute."),this.setIndex(t),this):this.setAttribute(e,t):(console.warn("THREE.BufferGeometry: .addAttribute() now expects ( name, attribute )."),this.setAttribute(e,new BufferAttribute(arguments[1],arguments[2])))},BufferGeometry.prototype.addDrawCall=function(e,t,n){void 0!==n&&console.warn("THREE.BufferGeometry: .addDrawCall() no longer supports indexOffset."),console.warn("THREE.BufferGeometry: .addDrawCall() is now .addGroup()."),this.addGroup(e,t)},BufferGeometry.prototype.clearDrawCalls=function(){console.warn("THREE.BufferGeometry: .clearDrawCalls() is now .clearGroups()."),this.clearGroups()},BufferGeometry.prototype.computeOffsets=function(){console.warn("THREE.BufferGeometry: .computeOffsets() has been removed.")},BufferGeometry.prototype.removeAttribute=function(e){return console.warn("THREE.BufferGeometry: .removeAttribute() has been renamed to .deleteAttribute()."),this.deleteAttribute(e)},BufferGeometry.prototype.applyMatrix=function(e){return console.warn("THREE.BufferGeometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(e)},Object.defineProperties(BufferGeometry.prototype,{drawcalls:{get:function(){return console.error("THREE.BufferGeometry: .drawcalls has been renamed to .groups."),this.groups}},offsets:{get:function(){return console.warn("THREE.BufferGeometry: .offsets has been renamed to .groups."),this.groups}}}),InterleavedBuffer.prototype.setDynamic=function(e){return console.warn("THREE.InterleavedBuffer: .setDynamic() has been deprecated. Use .setUsage() instead."),this.setUsage(!0===e?DynamicDrawUsage:StaticDrawUsage),this},InterleavedBuffer.prototype.setArray=function(){console.error("THREE.InterleavedBuffer: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers")},ExtrudeGeometry.prototype.getArrays=function(){console.error("THREE.ExtrudeGeometry: .getArrays() has been removed.")},ExtrudeGeometry.prototype.addShapeList=function(){console.error("THREE.ExtrudeGeometry: .addShapeList() has been removed.")},ExtrudeGeometry.prototype.addShape=function(){console.error("THREE.ExtrudeGeometry: .addShape() has been removed.")},Scene.prototype.dispose=function(){console.error("THREE.Scene: .dispose() has been removed.")},Object.defineProperties(Material.prototype,{wrapAround:{get:function(){console.warn("THREE.Material: .wrapAround has been removed.")},set:function(){console.warn("THREE.Material: .wrapAround has been removed.")}},overdraw:{get:function(){console.warn("THREE.Material: .overdraw has been removed.")},set:function(){console.warn("THREE.Material: .overdraw has been removed.")}},wrapRGB:{get:function(){return console.warn("THREE.Material: .wrapRGB has been removed."),new Color$1}},shading:{get:function(){console.error("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead.")},set:function(e){console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=e===FlatShading}},stencilMask:{get:function(){return console.warn("THREE."+this.type+": .stencilMask has been removed. Use .stencilFuncMask instead."),this.stencilFuncMask},set:function(e){console.warn("THREE."+this.type+": .stencilMask has been removed. Use .stencilFuncMask instead."),this.stencilFuncMask=e}},vertexTangents:{get:function(){console.warn("THREE."+this.type+": .vertexTangents has been removed.")},set:function(){console.warn("THREE."+this.type+": .vertexTangents has been removed.")}}}),Object.defineProperties(ShaderMaterial.prototype,{derivatives:{get:function(){return console.warn("THREE.ShaderMaterial: .derivatives has been moved to .extensions.derivatives."),this.extensions.derivatives},set:function(e){console.warn("THREE. ShaderMaterial: .derivatives has been moved to .extensions.derivatives."),this.extensions.derivatives=e}}}),WebGLRenderer.prototype.clearTarget=function(e,t,n,r){console.warn("THREE.WebGLRenderer: .clearTarget() has been deprecated. Use .setRenderTarget() and .clear() instead."),this.setRenderTarget(e),this.clear(t,n,r)},WebGLRenderer.prototype.animate=function(e){console.warn("THREE.WebGLRenderer: .animate() is now .setAnimationLoop()."),this.setAnimationLoop(e)},WebGLRenderer.prototype.getCurrentRenderTarget=function(){return console.warn("THREE.WebGLRenderer: .getCurrentRenderTarget() is now .getRenderTarget()."),this.getRenderTarget()},WebGLRenderer.prototype.getMaxAnisotropy=function(){return console.warn("THREE.WebGLRenderer: .getMaxAnisotropy() is now .capabilities.getMaxAnisotropy()."),this.capabilities.getMaxAnisotropy()},WebGLRenderer.prototype.getPrecision=function(){return console.warn("THREE.WebGLRenderer: .getPrecision() is now .capabilities.precision."),this.capabilities.precision},WebGLRenderer.prototype.resetGLState=function(){return console.warn("THREE.WebGLRenderer: .resetGLState() is now .state.reset()."),this.state.reset()},WebGLRenderer.prototype.supportsFloatTextures=function(){return console.warn("THREE.WebGLRenderer: .supportsFloatTextures() is now .extensions.get( 'OES_texture_float' )."),this.extensions.get("OES_texture_float")},WebGLRenderer.prototype.supportsHalfFloatTextures=function(){return console.warn("THREE.WebGLRenderer: .supportsHalfFloatTextures() is now .extensions.get( 'OES_texture_half_float' )."),this.extensions.get("OES_texture_half_float")},WebGLRenderer.prototype.supportsStandardDerivatives=function(){return console.warn("THREE.WebGLRenderer: .supportsStandardDerivatives() is now .extensions.get( 'OES_standard_derivatives' )."),this.extensions.get("OES_standard_derivatives")},WebGLRenderer.prototype.supportsCompressedTextureS3TC=function(){return console.warn("THREE.WebGLRenderer: .supportsCompressedTextureS3TC() is now .extensions.get( 'WEBGL_compressed_texture_s3tc' )."),this.extensions.get("WEBGL_compressed_texture_s3tc")},WebGLRenderer.prototype.supportsCompressedTexturePVRTC=function(){return console.warn("THREE.WebGLRenderer: .supportsCompressedTexturePVRTC() is now .extensions.get( 'WEBGL_compressed_texture_pvrtc' )."),this.extensions.get("WEBGL_compressed_texture_pvrtc")},WebGLRenderer.prototype.supportsBlendMinMax=function(){return console.warn("THREE.WebGLRenderer: .supportsBlendMinMax() is now .extensions.get( 'EXT_blend_minmax' )."),this.extensions.get("EXT_blend_minmax")},WebGLRenderer.prototype.supportsVertexTextures=function(){return console.warn("THREE.WebGLRenderer: .supportsVertexTextures() is now .capabilities.vertexTextures."),this.capabilities.vertexTextures},WebGLRenderer.prototype.supportsInstancedArrays=function(){return console.warn("THREE.WebGLRenderer: .supportsInstancedArrays() is now .extensions.get( 'ANGLE_instanced_arrays' )."),this.extensions.get("ANGLE_instanced_arrays")},WebGLRenderer.prototype.enableScissorTest=function(e){console.warn("THREE.WebGLRenderer: .enableScissorTest() is now .setScissorTest()."),this.setScissorTest(e)},WebGLRenderer.prototype.initMaterial=function(){console.warn("THREE.WebGLRenderer: .initMaterial() has been removed.")},WebGLRenderer.prototype.addPrePlugin=function(){console.warn("THREE.WebGLRenderer: .addPrePlugin() has been removed.")},WebGLRenderer.prototype.addPostPlugin=function(){console.warn("THREE.WebGLRenderer: .addPostPlugin() has been removed.")},WebGLRenderer.prototype.updateShadowMap=function(){console.warn("THREE.WebGLRenderer: .updateShadowMap() has been removed.")},WebGLRenderer.prototype.setFaceCulling=function(){console.warn("THREE.WebGLRenderer: .setFaceCulling() has been removed.")},WebGLRenderer.prototype.allocTextureUnit=function(){console.warn("THREE.WebGLRenderer: .allocTextureUnit() has been removed.")},WebGLRenderer.prototype.setTexture=function(){console.warn("THREE.WebGLRenderer: .setTexture() has been removed.")},WebGLRenderer.prototype.setTexture2D=function(){console.warn("THREE.WebGLRenderer: .setTexture2D() has been removed.")},WebGLRenderer.prototype.setTextureCube=function(){console.warn("THREE.WebGLRenderer: .setTextureCube() has been removed.")},WebGLRenderer.prototype.getActiveMipMapLevel=function(){return console.warn("THREE.WebGLRenderer: .getActiveMipMapLevel() is now .getActiveMipmapLevel()."),this.getActiveMipmapLevel()},Object.defineProperties(WebGLRenderer.prototype,{shadowMapEnabled:{get:function(){return this.shadowMap.enabled},set:function(e){console.warn("THREE.WebGLRenderer: .shadowMapEnabled is now .shadowMap.enabled."),this.shadowMap.enabled=e}},shadowMapType:{get:function(){return this.shadowMap.type},set:function(e){console.warn("THREE.WebGLRenderer: .shadowMapType is now .shadowMap.type."),this.shadowMap.type=e}},shadowMapCullFace:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.")}},context:{get:function(){return console.warn("THREE.WebGLRenderer: .context has been removed. Use .getContext() instead."),this.getContext()}},vr:{get:function(){return console.warn("THREE.WebGLRenderer: .vr has been renamed to .xr"),this.xr}},gammaInput:{get:function(){return console.warn("THREE.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead."),!1},set:function(){console.warn("THREE.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead.")}},gammaOutput:{get:function(){return console.warn("THREE.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead."),!1},set:function(e){console.warn("THREE.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead."),this.outputEncoding=!0===e?sRGBEncoding:LinearEncoding}},toneMappingWhitePoint:{get:function(){return console.warn("THREE.WebGLRenderer: .toneMappingWhitePoint has been removed."),1},set:function(){console.warn("THREE.WebGLRenderer: .toneMappingWhitePoint has been removed.")}},gammaFactor:{get:function(){return console.warn("THREE.WebGLRenderer: .gammaFactor has been removed."),2},set:function(){console.warn("THREE.WebGLRenderer: .gammaFactor has been removed.")}}}),Object.defineProperties(WebGLShadowMap.prototype,{cullFace:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.")}},renderReverseSided:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.")}},renderSingleSided:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.")}}}),Object.defineProperties(WebGLRenderTarget.prototype,{wrapS:{get:function(){return console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."),this.texture.wrapS},set:function(e){console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."),this.texture.wrapS=e}},wrapT:{get:function(){return console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."),this.texture.wrapT},set:function(e){console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."),this.texture.wrapT=e}},magFilter:{get:function(){return console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."),this.texture.magFilter},set:function(e){console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."),this.texture.magFilter=e}},minFilter:{get:function(){return console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."),this.texture.minFilter},set:function(e){console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."),this.texture.minFilter=e}},anisotropy:{get:function(){return console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."),this.texture.anisotropy},set:function(e){console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."),this.texture.anisotropy=e}},offset:{get:function(){return console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."),this.texture.offset},set:function(e){console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."),this.texture.offset=e}},repeat:{get:function(){return console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."),this.texture.repeat},set:function(e){console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."),this.texture.repeat=e}},format:{get:function(){return console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."),this.texture.format},set:function(e){console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."),this.texture.format=e}},type:{get:function(){return console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."),this.texture.type},set:function(e){console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."),this.texture.type=e}},generateMipmaps:{get:function(){return console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."),this.texture.generateMipmaps},set:function(e){console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."),this.texture.generateMipmaps=e}}}),Audio.prototype.load=function(e){console.warn("THREE.Audio: .load has been deprecated. Use THREE.AudioLoader instead.");const t=this;return(new AudioLoader).load(e,(function(e){t.setBuffer(e)})),this},CubeCamera.prototype.updateCubeMap=function(e,t){return console.warn("THREE.CubeCamera: .updateCubeMap() is now .update()."),this.update(e,t)},CubeCamera.prototype.clear=function(e,t,n,r){return console.warn("THREE.CubeCamera: .clear() is now .renderTarget.clear()."),this.renderTarget.clear(e,t,n,r)},ImageUtils.crossOrigin=void 0,ImageUtils.loadTexture=function(e,t,n,r){console.warn("THREE.ImageUtils.loadTexture has been deprecated. Use THREE.TextureLoader() instead.");const i=new TextureLoader;i.setCrossOrigin(this.crossOrigin);const a=i.load(e,n,void 0,r);return t&&(a.mapping=t),a},ImageUtils.loadTextureCube=function(e,t,n,r){console.warn("THREE.ImageUtils.loadTextureCube has been deprecated. Use THREE.CubeTextureLoader() instead.");const i=new CubeTextureLoader;i.setCrossOrigin(this.crossOrigin);const a=i.load(e,n,void 0,r);return t&&(a.mapping=t),a},ImageUtils.loadCompressedTexture=function(){console.error("THREE.ImageUtils.loadCompressedTexture has been removed. Use THREE.DDSLoader instead.")},ImageUtils.loadCompressedTextureCube=function(){console.error("THREE.ImageUtils.loadCompressedTextureCube has been removed. Use THREE.DDSLoader instead.")},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:REVISION}})),"undefined"!=typeof window&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=REVISION);const TASK_DELAY_MS=200;function shuffle(e){let t,n,r=e.length;for(;r;)n=Math.floor(Math.random()*r--),t=e[r],e[r]=e[n],e[n]=t;return e}function range(e){const t=[];for(let n=0;n<e;n++)t.push(n);return t}function classed(e,t,n){const r=e.className.split(" ");if(n){if(t in r)return;r.push(t)}else{const e=r.indexOf(t);if(-1===e)return;r.splice(e,1)}e.className=r.join(" ")}function vector3DToScreenCoords(e,t,n,r){let i=window.devicePixelRatio,a=(new Vector3).copy(r).project(e);return[(a.x+1)/2*t*i,-(a.y-1)/2*n*i]}function vector3FromPackedArray(e,t){const n=3*t;return new Vector3(e[n],e[n+1],e[n+2])}function getNearFarPoints(e,t,n){let r=1/0,i=0;const a=(new Vector3).copy(n).sub(t),o=(new Vector3).copy(a).normalize(),s=e.length/3;let l=0,c=new Vector3,h=new Vector3;for(let n=0;n<s;n++){c.x=e[l],c.y=e[l+1],c.z=e[l+2],l+=3,h.copy(c).sub(t);const n=o.dot(h);n<0||(i=n>i?n:i,r=n<r?n:r)}return[r,i]}function createTexture(e){let t=new Texture(e);return t.needsUpdate=!0,t.minFilter=LinearFilter,t.generateMipmaps=!1,t.flipY=!1,t}function assert(e,t){if(!e)throw t=t||"Assertion failed",new Error(t)}function getSearchPredicate(e,t,n){let r;if(t){let t=new RegExp(e,"i");r=e=>t.test(e.metadata[n].toString())}else e=e.toLowerCase(),r=t=>t.metadata[n].toString().toLowerCase().indexOf(e)>=0;return r}function runAsyncTask(e,t,n=null,r=TASK_DELAY_MS){let i=null==n;return n=setModalMessage(e,n),new Promise(((e,a)=>{setTimeout((()=>{try{let r=t();i&&setModalMessage(null,n),e(r)}catch(e){a(e)}return!0}),r)}))}function getURLParams(e){if(!e)return{};let t=-1!==e.indexOf("?")?e.split("?")[1]:e;t.indexOf("#")&&(t=t.split("#")[0]);const n=t.split("&");let r={};for(let e=0;e<n.length;e++){let t=n[e].split("=");r[t[0].toLowerCase()]=decodeURIComponent(t[1])}return r}const SUBSTR_GEN_TENSORS=["/Adagrad"];function tensorIsGenerated(e){for(let t=0;t<SUBSTR_GEN_TENSORS.length;t++)if(e.indexOf(SUBSTR_GEN_TENSORS[t])>=0)return!0;return!1}function xor(e,t){return(e||t)&&!(e&&t)}function hasWebGLSupport(){return __awaiter$1(this,void 0,void 0,(function*(){try{let e=document.createElement("canvas"),t=e.getContext("webgl")||e.getContext("experimental-webgl");return yield ready(),null!=t&&"webgl"===getBackend()}catch(e){return!1}}))}function ascending(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function bisector(e){return 1===e.length&&(e=ascendingComparator(e)),{left:function(t,n,r,i){for(null==r&&(r=0),null==i&&(i=t.length);r<i;){var a=r+i>>>1;e(t[a],n)<0?r=a+1:i=a}return r},right:function(t,n,r,i){for(null==r&&(r=0),null==i&&(i=t.length);r<i;){var a=r+i>>>1;e(t[a],n)>0?i=a:r=a+1}return r}}}function ascendingComparator(e){return function(t,n){return ascending(e(t),n)}}var ascendingBisect=bisector(ascending),bisectRight=ascendingBisect.right;function extent(e,t){var n,r,i,a=e.length,o=-1;if(null==t){for(;++o<a;)if(null!=(n=e[o])&&n>=n)for(r=i=n;++o<a;)null!=(n=e[o])&&(r>n&&(r=n),i<n&&(i=n))}else for(;++o<a;)if(null!=(n=t(e[o],o,e))&&n>=n)for(r=i=n;++o<a;)null!=(n=t(e[o],o,e))&&(r>n&&(r=n),i<n&&(i=n));return[r,i]}var e10=Math.sqrt(50),e5=Math.sqrt(10),e2=Math.sqrt(2);function ticks(e,t,n){var r,i,a,o,s=-1;if(n=+n,(e=+e)===(t=+t)&&n>0)return[e];if((r=t<e)&&(i=e,e=t,t=i),0===(o=tickIncrement(e,t,n))||!isFinite(o))return[];if(o>0)for(e=Math.ceil(e/o),t=Math.floor(t/o),a=new Array(i=Math.ceil(t-e+1));++s<i;)a[s]=(e+s)*o;else for(e=Math.floor(e*o),t=Math.ceil(t*o),a=new Array(i=Math.ceil(e-t+1));++s<i;)a[s]=(e-s)/o;return r&&a.reverse(),a}function tickIncrement(e,t,n){var r=(t-e)/Math.max(0,n),i=Math.floor(Math.log(r)/Math.LN10),a=r/Math.pow(10,i);return i>=0?(a>=e10?10:a>=e5?5:a>=e2?2:1)*Math.pow(10,i):-Math.pow(10,-i)/(a>=e10?10:a>=e5?5:a>=e2?2:1)}function tickStep(e,t,n){var r=Math.abs(t-e)/Math.max(0,n),i=Math.pow(10,Math.floor(Math.log(r)/Math.LN10)),a=r/i;return a>=e10?i*=10:a>=e5?i*=5:a>=e2&&(i*=2),t<e?-i:i}var noop={value:function(){}};function dispatch(){for(var e,t=0,n=arguments.length,r={};t<n;++t){if(!(e=arguments[t]+"")||e in r||/[\s.]/.test(e))throw new Error("illegal type: "+e);r[e]=[]}return new Dispatch(r)}function Dispatch(e){this._=e}function parseTypenames(e,t){return e.trim().split(/^|\s+/).map((function(e){var n="",r=e.indexOf(".");if(r>=0&&(n=e.slice(r+1),e=e.slice(0,r)),e&&!t.hasOwnProperty(e))throw new Error("unknown type: "+e);return{type:e,name:n}}))}function get(e,t){for(var n,r=0,i=e.length;r<i;++r)if((n=e[r]).name===t)return n.value}function set(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=noop,e=e.slice(0,r).concat(e.slice(r+1));break}return null!=n&&e.push({name:t,value:n}),e}function define(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function extend(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function Color(){}Dispatch.prototype=dispatch.prototype={constructor:Dispatch,on:function(e,t){var n,r=this._,i=parseTypenames(e+"",r),a=-1,o=i.length;if(!(arguments.length<2)){if(null!=t&&"function"!=typeof t)throw new Error("invalid callback: "+t);for(;++a<o;)if(n=(e=i[a]).type)r[n]=set(r[n],e.name,t);else if(null==t)for(n in r)r[n]=set(r[n],e.name,null);return this}for(;++a<o;)if((n=(e=i[a]).type)&&(n=get(r[n],e.name)))return n},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new Dispatch(e)},call:function(e,t){if((n=arguments.length-2)>0)for(var n,r,i=new Array(n),a=0;a<n;++a)i[a]=arguments[a+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(a=0,n=(r=this._[e]).length;a<n;++a)r[a].value.apply(t,i)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var r=this._[e],i=0,a=r.length;i<a;++i)r[i].value.apply(t,n)}};var darker=.7,brighter=1/darker,reI="\\s*([+-]?\\d+)\\s*",reN="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)\\s*",reP="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)%\\s*",reHex=/^#([0-9a-f]{3,8})$/,reRgbInteger=new RegExp("^rgb\\("+[reI,reI,reI]+"\\)$"),reRgbPercent=new RegExp("^rgb\\("+[reP,reP,reP]+"\\)$"),reRgbaInteger=new RegExp("^rgba\\("+[reI,reI,reI,reN]+"\\)$"),reRgbaPercent=new RegExp("^rgba\\("+[reP,reP,reP,reN]+"\\)$"),reHslPercent=new RegExp("^hsl\\("+[reN,reP,reP]+"\\)$"),reHslaPercent=new RegExp("^hsla\\("+[reN,reP,reP,reN]+"\\)$"),named={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};function color_formatHex(){return this.rgb().formatHex()}function color_formatHsl(){return hslConvert(this).formatHsl()}function color_formatRgb(){return this.rgb().formatRgb()}function color(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=reHex.exec(e))?(n=t[1].length,t=parseInt(t[1],16),6===n?rgbn(t):3===n?new Rgb(t>>8&15|t>>4&240,t>>4&15|240&t,(15&t)<<4|15&t,1):8===n?rgba(t>>24&255,t>>16&255,t>>8&255,(255&t)/255):4===n?rgba(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|240&t,((15&t)<<4|15&t)/255):null):(t=reRgbInteger.exec(e))?new Rgb(t[1],t[2],t[3],1):(t=reRgbPercent.exec(e))?new Rgb(255*t[1]/100,255*t[2]/100,255*t[3]/100,1):(t=reRgbaInteger.exec(e))?rgba(t[1],t[2],t[3],t[4]):(t=reRgbaPercent.exec(e))?rgba(255*t[1]/100,255*t[2]/100,255*t[3]/100,t[4]):(t=reHslPercent.exec(e))?hsla(t[1],t[2]/100,t[3]/100,1):(t=reHslaPercent.exec(e))?hsla(t[1],t[2]/100,t[3]/100,t[4]):named.hasOwnProperty(e)?rgbn(named[e]):"transparent"===e?new Rgb(NaN,NaN,NaN,0):null}function rgbn(e){return new Rgb(e>>16&255,e>>8&255,255&e,1)}function rgba(e,t,n,r){return r<=0&&(e=t=n=NaN),new Rgb(e,t,n,r)}function rgbConvert(e){return e instanceof Color||(e=color(e)),e?new Rgb((e=e.rgb()).r,e.g,e.b,e.opacity):new Rgb}function rgb(e,t,n,r){return 1===arguments.length?rgbConvert(e):new Rgb(e,t,n,null==r?1:r)}function Rgb(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}function rgb_formatHex(){return"#"+hex(this.r)+hex(this.g)+hex(this.b)}function rgb_formatRgb(){var e=this.opacity;return(1===(e=isNaN(e)?1:Math.max(0,Math.min(1,e)))?"rgb(":"rgba(")+Math.max(0,Math.min(255,Math.round(this.r)||0))+", "+Math.max(0,Math.min(255,Math.round(this.g)||0))+", "+Math.max(0,Math.min(255,Math.round(this.b)||0))+(1===e?")":", "+e+")")}function hex(e){return((e=Math.max(0,Math.min(255,Math.round(e)||0)))<16?"0":"")+e.toString(16)}function hsla(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Hsl(e,t,n,r)}function hslConvert(e){if(e instanceof Hsl)return new Hsl(e.h,e.s,e.l,e.opacity);if(e instanceof Color||(e=color(e)),!e)return new Hsl;if(e instanceof Hsl)return e;var t=(e=e.rgb()).r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),a=Math.max(t,n,r),o=NaN,s=a-i,l=(a+i)/2;return s?(o=t===a?(n-r)/s+6*(n<r):n===a?(r-t)/s+2:(t-n)/s+4,s/=l<.5?a+i:2-a-i,o*=60):s=l>0&&l<1?0:o,new Hsl(o,s,l,e.opacity)}function hsl(e,t,n,r){return 1===arguments.length?hslConvert(e):new Hsl(e,t,n,null==r?1:r)}function Hsl(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}function hsl2rgb(e,t,n){return 255*(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)}function constant$1(e){return function(){return e}}function linear$1(e,t){return function(n){return e+n*t}}function exponential(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}function gamma(e){return 1==(e=+e)?nogamma:function(t,n){return n-t?exponential(t,n,e):constant$1(isNaN(t)?n:t)}}function nogamma(e,t){var n=t-e;return n?linear$1(e,n):constant$1(isNaN(e)?t:e)}define(Color,color,{copy:function(e){return Object.assign(new this.constructor,this,e)},displayable:function(){return this.rgb().displayable()},hex:color_formatHex,formatHex:color_formatHex,formatHsl:color_formatHsl,formatRgb:color_formatRgb,toString:color_formatRgb}),define(Rgb,rgb,extend(Color,{brighter:function(e){return e=null==e?brighter:Math.pow(brighter,e),new Rgb(this.r*e,this.g*e,this.b*e,this.opacity)},darker:function(e){return e=null==e?darker:Math.pow(darker,e),new Rgb(this.r*e,this.g*e,this.b*e,this.opacity)},rgb:function(){return this},displayable:function(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:rgb_formatHex,formatHex:rgb_formatHex,formatRgb:rgb_formatRgb,toString:rgb_formatRgb})),define(Hsl,hsl,extend(Color,{brighter:function(e){return e=null==e?brighter:Math.pow(brighter,e),new Hsl(this.h,this.s,this.l*e,this.opacity)},darker:function(e){return e=null==e?darker:Math.pow(darker,e),new Hsl(this.h,this.s,this.l*e,this.opacity)},rgb:function(){var e=this.h%360+360*(this.h<0),t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new Rgb(hsl2rgb(e>=240?e-240:e+120,i,r),hsl2rgb(e,i,r),hsl2rgb(e<120?e+240:e-120,i,r),this.opacity)},displayable:function(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl:function(){var e=this.opacity;return(1===(e=isNaN(e)?1:Math.max(0,Math.min(1,e)))?"hsl(":"hsla(")+(this.h||0)+", "+100*(this.s||0)+"%, "+100*(this.l||0)+"%"+(1===e?")":", "+e+")")}}));var interpolateRgb=(function e(t){var n=gamma(t);function r(e,t){var r=n((e=rgb(e)).r,(t=rgb(t)).r),i=n(e.g,t.g),a=n(e.b,t.b),o=nogamma(e.opacity,t.opacity);return function(t){return e.r=r(t),e.g=i(t),e.b=a(t),e.opacity=o(t),e+""}}return r.gamma=e,r})(1);function numberArray(e,t){t||(t=[]);var n,r=e?Math.min(t.length,e.length):0,i=t.slice();return function(a){for(n=0;n<r;++n)i[n]=e[n]*(1-a)+t[n]*a;return i}}function isNumberArray(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function genericArray(e,t){var n,r=t?t.length:0,i=e?Math.min(r,e.length):0,a=new Array(i),o=new Array(r);for(n=0;n<i;++n)a[n]=interpolateValue(e[n],t[n]);for(;n<r;++n)o[n]=t[n];return function(e){for(n=0;n<i;++n)o[n]=a[n](e);return o}}function date(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function interpolateNumber(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function object(e,t){var n,r={},i={};for(n in null!==e&&"object"==typeof e||(e={}),null!==t&&"object"==typeof t||(t={}),t)n in e?r[n]=interpolateValue(e[n],t[n]):i[n]=t[n];return function(e){for(n in r)i[n]=r[n](e);return i}}var reA=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,reB=new RegExp(reA.source,"g");function zero(e){return function(){return e}}function one(e){return function(t){return e(t)+""}}function interpolateString(e,t){var n,r,i,a=reA.lastIndex=reB.lastIndex=0,o=-1,s=[],l=[];for(e+="",t+="";(n=reA.exec(e))&&(r=reB.exec(t));)(i=r.index)>a&&(i=t.slice(a,i),s[o]?s[o]+=i:s[++o]=i),(n=n[0])===(r=r[0])?s[o]?s[o]+=r:s[++o]=r:(s[++o]=null,l.push({i:o,x:interpolateNumber(n,r)})),a=reB.lastIndex;return a<t.length&&(i=t.slice(a),s[o]?s[o]+=i:s[++o]=i),s.length<2?l[0]?one(l[0].x):zero(t):(t=l.length,function(e){for(var n,r=0;r<t;++r)s[(n=l[r]).i]=n.x(e);return s.join("")})}function interpolateValue(e,t){var n,r=typeof t;return null==t||"boolean"===r?constant$1(t):("number"===r?interpolateNumber:"string"===r?(n=color(t))?(t=n,interpolateRgb):interpolateString:t instanceof color?interpolateRgb:t instanceof Date?date:isNumberArray(t)?numberArray:Array.isArray(t)?genericArray:"function"!=typeof t.valueOf&&"function"!=typeof t.toString||isNaN(t)?object:interpolateNumber)(e,t)}function interpolateRound(e,t){return e=+e,t=+t,function(n){return Math.round(e*(1-n)+t*n)}}dispatch("start","end","cancel","interrupt");var prefix="$";function Map$1(){}function map$2(e,t){var n=new Map$1;if(e instanceof Map$1)e.each((function(e,t){n.set(t,e)}));else if(Array.isArray(e)){var r,i=-1,a=e.length;if(null==t)for(;++i<a;)n.set(i,e[i]);else for(;++i<a;)n.set(t(r=e[i],i,e),r)}else if(e)for(var o in e)n.set(o,e[o]);return n}function Set$1(){}Map$1.prototype=map$2.prototype={constructor:Map$1,has:function(e){return prefix+e in this},get:function(e){return this[prefix+e]},set:function(e,t){return this[prefix+e]=t,this},remove:function(e){var t=prefix+e;return t in this&&delete this[t]},clear:function(){for(var e in this)e[0]===prefix&&delete this[e]},keys:function(){var e=[];for(var t in this)t[0]===prefix&&e.push(t.slice(1));return e},values:function(){var e=[];for(var t in this)t[0]===prefix&&e.push(this[t]);return e},entries:function(){var e=[];for(var t in this)t[0]===prefix&&e.push({key:t.slice(1),value:this[t]});return e},size:function(){var e=0;for(var t in this)t[0]===prefix&&++e;return e},empty:function(){for(var e in this)if(e[0]===prefix)return!1;return!0},each:function(e){for(var t in this)t[0]===prefix&&e(this[t],t.slice(1),this)}};var proto=map$2.prototype;function formatDecimal(e){return Math.abs(e=Math.round(e))>=1e21?e.toLocaleString("en").replace(/,/g,""):e.toString(10)}function formatDecimalParts(e,t){if((n=(e=t?e.toExponential(t-1):e.toExponential()).indexOf("e"))<0)return null;var n,r=e.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+e.slice(n+1)]}function exponent(e){return(e=formatDecimalParts(Math.abs(e)))?e[1]:NaN}function formatGroup(e,t){return function(n,r){for(var i=n.length,a=[],o=0,s=e[0],l=0;i>0&&s>0&&(l+s+1>r&&(s=Math.max(1,r-l)),a.push(n.substring(i-=s,i+s)),!((l+=s+1)>r));)s=e[o=(o+1)%e.length];return a.reverse().join(t)}}function formatNumerals(e){return function(t){return t.replace(/[0-9]/g,(function(t){return e[+t]}))}}Set$1.prototype={constructor:Set$1,has:proto.has,add:function(e){return this[prefix+(e+="")]=e,this},remove:proto.remove,clear:proto.clear,values:proto.keys,size:proto.size,empty:proto.empty,each:proto.each};var re=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i,prefixExponent;function formatSpecifier(e){if(!(t=re.exec(e)))throw new Error("invalid format: "+e);var t;return new FormatSpecifier({fill:t[1],align:t[2],sign:t[3],symbol:t[4],zero:t[5],width:t[6],comma:t[7],precision:t[8]&&t[8].slice(1),trim:t[9],type:t[10]})}function FormatSpecifier(e){this.fill=void 0===e.fill?" ":e.fill+"",this.align=void 0===e.align?">":e.align+"",this.sign=void 0===e.sign?"-":e.sign+"",this.symbol=void 0===e.symbol?"":e.symbol+"",this.zero=!!e.zero,this.width=void 0===e.width?void 0:+e.width,this.comma=!!e.comma,this.precision=void 0===e.precision?void 0:+e.precision,this.trim=!!e.trim,this.type=void 0===e.type?"":e.type+""}function formatTrim(e){e:for(var t,n=e.length,r=1,i=-1;r<n;++r)switch(e[r]){case".":i=t=r;break;case"0":0===i&&(i=r),t=r;break;default:if(!+e[r])break e;i>0&&(i=0)}return i>0?e.slice(0,i)+e.slice(t+1):e}function formatPrefixAuto(e,t){var n=formatDecimalParts(e,t);if(!n)return e+"";var r=n[0],i=n[1],a=i-(prefixExponent=3*Math.max(-8,Math.min(8,Math.floor(i/3))))+1,o=r.length;return a===o?r:a>o?r+new Array(a-o+1).join("0"):a>0?r.slice(0,a)+"."+r.slice(a):"0."+new Array(1-a).join("0")+formatDecimalParts(e,Math.max(0,t+a-1))[0]}function formatRounded(e,t){var n=formatDecimalParts(e,t);if(!n)return e+"";var r=n[0],i=n[1];return i<0?"0."+new Array(-i).join("0")+r:r.length>i+1?r.slice(0,i+1)+"."+r.slice(i+1):r+new Array(i-r.length+2).join("0")}formatSpecifier.prototype=FormatSpecifier.prototype,FormatSpecifier.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(void 0===this.width?"":Math.max(1,0|this.width))+(this.comma?",":"")+(void 0===this.precision?"":"."+Math.max(0,0|this.precision))+(this.trim?"~":"")+this.type};var formatTypes={"%":function(e,t){return(100*e).toFixed(t)},b:function(e){return Math.round(e).toString(2)},c:function(e){return e+""},d:formatDecimal,e:function(e,t){return e.toExponential(t)},f:function(e,t){return e.toFixed(t)},g:function(e,t){return e.toPrecision(t)},o:function(e){return Math.round(e).toString(8)},p:function(e,t){return formatRounded(100*e,t)},r:formatRounded,s:formatPrefixAuto,X:function(e){return Math.round(e).toString(16).toUpperCase()},x:function(e){return Math.round(e).toString(16)}};function identity$1(e){return e}var map$1=Array.prototype.map,prefixes=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"],locale,format,formatPrefix;function formatLocale(e){var t=void 0===e.grouping||void 0===e.thousands?identity$1:formatGroup(map$1.call(e.grouping,Number),e.thousands+""),n=void 0===e.currency?"":e.currency[0]+"",r=void 0===e.currency?"":e.currency[1]+"",i=void 0===e.decimal?".":e.decimal+"",a=void 0===e.numerals?identity$1:formatNumerals(map$1.call(e.numerals,String)),o=void 0===e.percent?"%":e.percent+"",s=void 0===e.minus?"-":e.minus+"",l=void 0===e.nan?"NaN":e.nan+"";function c(e){var c=(e=formatSpecifier(e)).fill,h=e.align,u=e.sign,d=e.symbol,p=e.zero,m=e.width,f=e.comma,g=e.precision,v=e.trim,y=e.type;"n"===y?(f=!0,y="g"):formatTypes[y]||(void 0===g&&(g=12),v=!0,y="g"),(p||"0"===c&&"="===h)&&(p=!0,c="0",h="=");var _="$"===d?n:"#"===d&&/[boxX]/.test(y)?"0"+y.toLowerCase():"",b="$"===d?r:/[%p]/.test(y)?o:"",x=formatTypes[y],S=/[defgprs%]/.test(y);function w(e){var n,r,o,d=_,w=b;if("c"===y)w=x(e)+w,e="";else{var C=(e=+e)<0||1/e<0;if(e=isNaN(e)?l:x(Math.abs(e),g),v&&(e=formatTrim(e)),C&&0==+e&&"+"!==u&&(C=!1),d=(C?"("===u?u:s:"-"===u||"("===u?"":u)+d,w=("s"===y?prefixes[8+prefixExponent/3]:"")+w+(C&&"("===u?")":""),S)for(n=-1,r=e.length;++n<r;)if(48>(o=e.charCodeAt(n))||o>57){w=(46===o?i+e.slice(n+1):e.slice(n))+w,e=e.slice(0,n);break}}f&&!p&&(e=t(e,1/0));var M=d.length+e.length+w.length,E=M<m?new Array(m-M+1).join(c):"";switch(f&&p&&(e=t(E+e,E.length?m-w.length:1/0),E=""),h){case"<":e=d+e+w+E;break;case"=":e=d+E+e+w;break;case"^":e=E.slice(0,M=E.length>>1)+d+e+w+E.slice(M);break;default:e=E+d+e+w}return a(e)}return g=void 0===g?6:/[gprs]/.test(y)?Math.max(1,Math.min(21,g)):Math.max(0,Math.min(20,g)),w.toString=function(){return e+""},w}return{format:c,formatPrefix:function h(e,t){var n=c(((e=formatSpecifier(e)).type="f",e)),r=3*Math.max(-8,Math.min(8,Math.floor(exponent(t)/3))),i=Math.pow(10,-r),a=prefixes[8+r/3];return function(e){return n(i*e)+a}}}}function defaultLocale(e){return locale=formatLocale(e),format=locale.format,formatPrefix=locale.formatPrefix,locale}function precisionFixed(e){return Math.max(0,-exponent(Math.abs(e)))}function precisionPrefix(e,t){return Math.max(0,3*Math.max(-8,Math.min(8,Math.floor(exponent(t)/3)))-exponent(Math.abs(e)))}function precisionRound(e,t){return e=Math.abs(e),t=Math.abs(t)-e,Math.max(0,exponent(t)-exponent(e))+1}function defaultSource(){return Math.random()}defaultLocale({decimal:".",thousands:",",grouping:[3],currency:["$",""],minus:"-"});var normal=(function e(t){function n(e,n){var r,i;return e=null==e?0:+e,n=null==n?1:+n,function(){var a;if(null!=r)a=r,r=null;else do{r=2*t()-1,a=2*t()-1,i=r*r+a*a}while(!i||i>1);return e+n*a*Math.sqrt(-2*Math.log(i)/i)}}return n.source=e,n})(defaultSource);function initRange(e,t){switch(arguments.length){case 0:break;case 1:this.range(e);break;default:this.range(t).domain(e)}return this}var array=Array.prototype,map=array.map,slice=array.slice,implicit={name:"implicit"};function ordinal(){var e=map$2(),t=[],n=[],r=implicit;function i(i){var a=i+"",o=e.get(a);if(!o){if(r!==implicit)return r;e.set(a,o=t.push(i))}return n[(o-1)%n.length]}return i.domain=function(n){if(!arguments.length)return t.slice();t=[],e=map$2();for(var r,a,o=-1,s=n.length;++o<s;)e.has(a=(r=n[o])+"")||e.set(a,t.push(r));return i},i.range=function(e){return arguments.length?(n=slice.call(e),i):n.slice()},i.unknown=function(e){return arguments.length?(r=e,i):r},i.copy=function(){return ordinal(t,n).unknown(r)},initRange.apply(i,arguments),i}function constant(e){return function(){return e}}function number(e){return+e}var unit$1=[0,1];function identity(e){return e}function normalize(e,t){return(t-=e=+e)?function(n){return(n-e)/t}:constant(isNaN(t)?NaN:.5)}function clamper(e){var t,n=e[0],r=e[e.length-1];return n>r&&(t=n,n=r,r=t),function(e){return Math.max(n,Math.min(r,e))}}function bimap(e,t,n){var r=e[0],i=e[1],a=t[0],o=t[1];return i<r?(r=normalize(i,r),a=n(o,a)):(r=normalize(r,i),a=n(a,o)),function(e){return a(r(e))}}function polymap(e,t,n){var r=Math.min(e.length,t.length)-1,i=new Array(r),a=new Array(r),o=-1;for(e[r]<e[0]&&(e=e.slice().reverse(),t=t.slice().reverse());++o<r;)i[o]=normalize(e[o],e[o+1]),a[o]=n(t[o],t[o+1]);return function(t){var n=bisectRight(e,t,1,r)-1;return a[n](i[n](t))}}function copy(e,t){return t.domain(e.domain()).range(e.range()).interpolate(e.interpolate()).clamp(e.clamp()).unknown(e.unknown())}function transformer(){var e,t,n,r,i,a,o=unit$1,s=unit$1,l=interpolateValue,c=identity;function h(){return r=Math.min(o.length,s.length)>2?polymap:bimap,i=a=null,u}function u(t){return isNaN(t=+t)?n:(i||(i=r(o.map(e),s,l)))(e(c(t)))}return u.invert=function(n){return c(t((a||(a=r(s,o.map(e),interpolateNumber)))(n)))},u.domain=function(e){return arguments.length?(o=map.call(e,number),c===identity||(c=clamper(o)),h()):o.slice()},u.range=function(e){return arguments.length?(s=slice.call(e),h()):s.slice()},u.rangeRound=function(e){return s=slice.call(e),l=interpolateRound,h()},u.clamp=function(e){return arguments.length?(c=e?clamper(o):identity,u):c!==identity},u.interpolate=function(e){return arguments.length?(l=e,h()):l},u.unknown=function(e){return arguments.length?(n=e,u):n},function(n,r){return e=n,t=r,h()}}function continuous(e,t){return transformer()(e,t)}function tickFormat(e,t,n,r){var i,a=tickStep(e,t,n);switch((r=formatSpecifier(null==r?",f":r)).type){case"s":var o=Math.max(Math.abs(e),Math.abs(t));return null!=r.precision||isNaN(i=precisionPrefix(a,o))||(r.precision=i),formatPrefix(r,o);case"":case"e":case"g":case"p":case"r":null!=r.precision||isNaN(i=precisionRound(a,Math.max(Math.abs(e),Math.abs(t))))||(r.precision=i-("e"===r.type));break;case"f":case"%":null!=r.precision||isNaN(i=precisionFixed(a))||(r.precision=i-2*("%"===r.type))}return format(r)}function linearish(e){var t=e.domain;return e.ticks=function(e){var n=t();return ticks(n[0],n[n.length-1],null==e?10:e)},e.tickFormat=function(e,n){var r=t();return tickFormat(r[0],r[r.length-1],null==e?10:e,n)},e.nice=function(n){null==n&&(n=10);var r,i=t(),a=0,o=i.length-1,s=i[a],l=i[o];return l<s&&(r=s,s=l,l=r,r=a,a=o,o=r),(r=tickIncrement(s,l,n))>0?r=tickIncrement(s=Math.floor(s/r)*r,l=Math.ceil(l/r)*r,n):r<0&&(r=tickIncrement(s=Math.ceil(s*r)/r,l=Math.floor(l*r)/r,n)),r>0?(i[a]=Math.floor(s/r)*r,i[o]=Math.ceil(l/r)*r,t(i)):r<0&&(i[a]=Math.ceil(s*r)/r,i[o]=Math.floor(l*r)/r,t(i)),e},e}function linear(){var e=continuous(identity,identity);return e.copy=function(){return copy(e,linear())},initRange.apply(e,arguments),linearish(e)}function transformPow(e){return function(t){return t<0?-Math.pow(-t,e):Math.pow(t,e)}}function transformSqrt(e){return e<0?-Math.sqrt(-e):Math.sqrt(e)}function transformSquare(e){return e<0?-e*e:e*e}function powish(e){var t=e(identity,identity),n=1;function r(){return 1===n?e(identity,identity):.5===n?e(transformSqrt,transformSquare):e(transformPow(n),transformPow(1/n))}return t.exponent=function(e){return arguments.length?(n=+e,r()):n},linearish(t)}function pow(){var e=powish(transformer());return e.copy=function(){return copy(e,pow()).exponent(e.exponent())},initRange.apply(e,arguments),e}function colors(e){for(var t=e.length/6|0,n=new Array(t),r=0;r<t;)n[r]="#"+e.slice(6*r,6*++r);return n}var category10=colors("1f77b4ff7f0e2ca02cd627289467bd8c564be377c27f7f7fbcbd2217becf");function dot(e,t){assert(e.length===t.length,"Vectors a and b must be of same length");let n=0;for(let r=0;r<e.length;++r)n+=e[r]*t[r];return n}function sub(e,t){assert(e.length===t.length,"Vectors a and b must be of same length");let n=new Float32Array(e.length);for(let r=0;r<e.length;++r)n[r]=e[r]-t[r];return n}function norm2(e){let t=0;for(let n=0;n<e.length;++n)t+=e[n]*e[n];return t}function dist(e,t){return Math.sqrt(dist2(e,t))}function dist2(e,t){assert(e.length===t.length,"Vectors a and b must be of same length");let n=0;for(let r=0;r<e.length;++r){let i=e[r]-t[r];n+=i*i}return n}function unit(e){let t=Math.sqrt(norm2(e));assert(t>=0,"Norm of the vector must be > 0");for(let n=0;n<e.length;++n)e[n]/=t}function projectRandom(e,t){let n=e[0].length,r=e.length,i=new Array(r);for(let e=0;e<r;++e)i[e]=new Float32Array(t);for(let a=0;a<t;++a){let t=rn(n);for(let n=0;n<r;++n)i[n][a]=dot(e[n],t)}return i}function centroid(e,t){if(0===e.length)return null;null==t&&(t=e=>e),assert(e.length>=0,"`vectors` must be of length >= 1");let n=new Float32Array(t(e[0]).length);for(let r=0;r<e.length;++r){let i=t(e[r]);for(let e=0;e<n.length;++e)n[e]+=i[e]}for(let t=0;t<n.length;++t)n[t]/=e.length;return n}function rn(e){const t=normal();let n=new Float32Array(e);for(let r=0;r<e;++r)n[r]=t();return n}function cosDistNorm(e,t){return 1-dot(e,t)}function cosDist(e,t){return 1-cosSim(e,t)}function cosSim(e,t){return dot(e,t)/Math.sqrt(norm2(e)*norm2(t))}function toTypedArray(e,t){let n=e.length,r=t(e[0]).length,i=new Float32Array(n*r);for(let a=0;a<n;++a){let n=t(e[a]);for(let e=0;e<r;++e)i[a*r+e]=n[e]}return i}const OPTIMAL_GPU_BLOCK_SIZE=256,KNN_GPU_MSG_ID="knn-gpu";function findKNNGPUCosDistNorm(e,t,n){const r=e.length,i=n(e[0]).length,a=new Array(r);let o=Math.ceil(r/OPTIMAL_GPU_BLOCK_SIZE);const s=Math.floor(r/o);o+=r%s?1:0;let l=0,c=0,h=1/(2*o),u=0;const d=tensor(toTypedArray(e,n),[r,i]),p=transpose$2(d),m=matMul(d,p),f=sub$3(1,m);let g=f;if(s*o>r){g=pad(f,[[0,s*o-r],[0,0]])}const v=split(g,new Array(o).fill(s),0);function y(i){runAsyncTask("Finding nearest neighbors: "+(100*c).toFixed()+"%",(()=>__awaiter$1(this,void 0,void 0,(function*(){const e=yield v[u].data();c+=h;for(let n=0;n<s;n++){let i=new KMin(t),o=l+n;if(o>=r)break;for(let t=0;t<r;t++){if(t===o)continue;const a=e[n*r+t];a>=0&&i.add(a,{index:t,dist:a})}a[o]=i.getMinKItems()}c+=h,l+=s,u++}))),KNN_GPU_MSG_ID).then((()=>{u<o?y(i):(setModalMessage(null,KNN_GPU_MSG_ID),d.dispose(),p.dispose(),m.dispose(),f.dispose(),v.forEach((e=>e.dispose())),i(a))}),(r=>{setModalMessage(null,KNN_GPU_MSG_ID);findKNN(e,t,n,((e,t,n)=>cosDistNorm(e,t))).then((e=>{i(e)}))}))}return new Promise((e=>y(e)))}function findKNN(e,t,n,r){return runAsyncTask("Finding nearest neighbors...",(()=>{let i=e.length,a=new Array(i),o=new Array(i);for(let e=0;e<i;e++)o[e]=new KMin(t);for(let a=0;a<i;a++){let s=n(e[a]),l=o[a];for(let c=a+1;c<i;c++){let i=o[c],h=l.getSize()===t&&l.getLargestKey()||Number.MAX_VALUE,u=i.getSize()===t&&i.getLargestKey()||Number.MAX_VALUE,d=Math.max(h,u),p=r(s,n(e[c]),d);p>=0&&(l.add(p,{index:c,dist:p}),i.add(p,{index:a,dist:p}))}}for(let e=0;e<i;e++)a[e]=o[e].getMinKItems();return a}))}function findKNNofPoint(e,t,n,r,i){let a=new KMin(n),o=r(e[t]);for(let n=0;n<e.length;++n){if(n===t)continue;let s=i(o,r(e[n]));a.add(s,{index:n,dist:s})}return a.getMinKItems()}const IS_FIREFOX=navigator.userAgent.toLowerCase().indexOf("firefox")>=0,TSNE_SAMPLE_SIZE=1e4,UMAP_SAMPLE_SIZE=5e3,PCA_SAMPLE_SIZE=5e4,PCA_SAMPLE_DIM=200,NUM_PCA_COMPONENTS$1=10,UMAP_MSG_ID="umap-optimization",SEQUENCE_METADATA_ATTRS=["__next__","__seq_next__"];function getSequenceNextPointIndex(e){let t=null;for(let n of SEQUENCE_METADATA_ATTRS)if(n in e&&""!==e[n]){t=e[n];break}return null==t?null:+t}class DataSet{constructor(e,t){this.shuffledDataIndices=[],this.projections={},this.tSNEIteration=0,this.tSNEShouldPause=!1,this.tSNEShouldStop=!0,this.superviseInput="",this.dim=[0,0],this.hasTSNERun=!1,this.hasUmapRun=!1,this.points=e,this.shuffledDataIndices=shuffle(range(this.points.length)),this.sequences=this.computeSequences(e),this.dim=[this.points.length,this.points[0].vector.length],this.spriteAndMetadataInfo=t}computeSequences(e){let t=new Int8Array(e.length),n={},r=[];for(let i=0;i<e.length;i++){if(t[i])continue;t[i]=1;let a=getSequenceNextPointIndex(e[i].metadata);if(null==a)continue;if(a in n){let e=n[a];e.pointIndices.unshift(i),n[i]=e;continue}let o={pointIndices:[]};n[i]=o,r.push(o);let s=i;for(;e[s];){o.pointIndices.push(s);let n=getSequenceNextPointIndex(e[s].metadata);null!=n?(t[n]=1,s=n):s=-1}}return r}projectionCanBeRendered(e){return"tsne"!==e||this.tSNEIteration>0}getSubset(e){let t=(null!=e&&e.length>0?e.map((e=>this.points[e])):this.points).map((e=>({metadata:e.metadata,index:e.index,vector:e.vector.slice(),projections:{}})));return new DataSet(t,this.spriteAndMetadataInfo)}normalize(){let e=centroid(this.points,(e=>e.vector));if(null==e)throw Error("centroid should not be null");for(let t=0;t<this.points.length;++t){let n=this.points[t];n.vector=sub(n.vector,e),norm2(n.vector)>0&&unit(n.vector)}}projectLinear(e,t){this.projections[t]=!0,this.points.forEach((n=>{n.projections[t]=dot(n.vector,e)}))}projectPCA(){return null!=this.projections["pca-0"]?Promise.resolve(null):runAsyncTask("Computing PCA...",(()=>{let e=this.points[0].vector.length,t=this.shuffledDataIndices.map((e=>this.points[e].vector));e>PCA_SAMPLE_DIM&&(t=projectRandom(t,PCA_SAMPLE_DIM));const n=t.slice(0,PCA_SAMPLE_SIZE),{dot:r,transpose:i,svd:a}=numeric1_2_6,o=a((0,numeric1_2_6.div)(r(i(n),n),n.length)),s=o.S;let l=0;for(let e=0;e<s.length;++e)l+=s[e];for(let e=0;e<s.length;++e)s[e]/=l;this.fracVariancesExplained=s;let c=o.U,h=t.map((e=>{let t=new Float32Array(NUM_PCA_COMPONENTS$1);for(let n=0;n<NUM_PCA_COMPONENTS$1;n++){let r=0;for(let t=0;t<e.length;t++)r+=e[t]*c[t][n];t[n]=r}return t}));for(let e=0;e<NUM_PCA_COMPONENTS$1;e++){let t="pca-"+e;this.projections[t]=!0;for(let n=0;n<h.length;n++){this.points[this.shuffledDataIndices[n]].projections[t]=h[n][e]}}}))}projectTSNE(e,t,n,r){this.hasTSNERun=!0;let i=Math.floor(3*e);this.tsne=new TSNE({epsilon:t,perplexity:e,dim:n}),this.tsne.setSupervision(this.superviseLabels,this.superviseInput),this.tsne.setSuperviseFactor(this.superviseFactor),this.tSNEShouldPause=!1,this.tSNEShouldStop=!1,this.tSNEIteration=0;let a=this.shuffledDataIndices.slice(0,TSNE_SAMPLE_SIZE),o=()=>{if(this.tSNEShouldStop)return this.projections.tsne=!1,r(null),this.tsne=null,void(this.hasTSNERun=!1);if(!this.tSNEShouldPause){this.tsne.step();let e=this.tsne.getSolution();a.forEach(((t,r)=>{let i=this.points[t];i.projections["tsne-0"]=e[r*n+0],i.projections["tsne-1"]=e[r*n+1],3===n&&(i.projections["tsne-2"]=e[r*n+2])})),this.projections.tsne=!0,this.tSNEIteration++,r(this.tSNEIteration)}requestAnimationFrame(o)};const s=a.map((e=>this.points[e]));this.computeKnn(s,i).then((e=>{runAsyncTask("Initializing T-SNE...",(()=>{this.tsne.initDataDist(e)})).then(o)}))}projectUmap(e,t,n){return __awaiter$1(this,void 0,void 0,(function*(){this.hasUmapRun=!0,this.umap=new UMAP({nComponents:e,nNeighbors:t});let r=0;const i=this.shuffledDataIndices.slice(0,UMAP_SAMPLE_SIZE),a=i.map((e=>this.points[e])),o=a.map((e=>Array.from(e.vector))),s=yield this.computeKnn(a,t),l=yield runAsyncTask("Initializing UMAP...",(()=>{const e=s.map((e=>e.map((e=>e.index)))),t=s.map((e=>e.map((e=>e.dist))));return this.umap.setPrecomputedKNN(e,t),this.umap.initializeFit(o)}),UMAP_MSG_ID);return new Promise(((t,a)=>{const o=()=>{const s=Math.min(10,l-r);for(let e=0;e<s;e++)r=this.umap.step();runAsyncTask(`Optimizing UMAP (epoch ${r} of ${l})`,(()=>{if(r<l)requestAnimationFrame(o);else{const a=this.umap.getEmbedding();i.forEach(((t,n)=>{const r=this.points[t];r.projections["umap-0"]=a[n][0],r.projections["umap-1"]=a[n][1],3===e&&(r.projections["umap-2"]=a[n][2])})),this.projections.umap=!0,setModalMessage(null,UMAP_MSG_ID),this.hasUmapRun=!0,n(r),t()}}),UMAP_MSG_ID,0).catch((e=>{setModalMessage(null,UMAP_MSG_ID),a(e)}))};requestAnimationFrame(o)}))}))}computeKnn(e,t){return __awaiter$1(this,void 0,void 0,(function*(){if(null!=this.nearest&&this.nearest.length>=e.length&&(this.nearest&&this.nearest.length?this.nearest[0].length:0)>=t)return Promise.resolve(this.nearest.slice(0,e.length).map((e=>e.slice(0,t))));{const n=(yield hasWebGLSupport())&&!IS_FIREFOX,r=yield n?findKNNGPUCosDistNorm(e,t,(e=>e.vector)):findKNN(e,t,(e=>e.vector),((e,t)=>cosDistNorm(e,t)));return this.nearest=r,Promise.resolve(r)}}))}perturbTsne(){if(this.hasTSNERun&&this.tsne){this.tsne.perturb();let e=this.tsne.getDim(),t=this.tsne.getSolution();this.shuffledDataIndices.slice(0,TSNE_SAMPLE_SIZE).forEach(((n,r)=>{let i=this.points[n];i.projections["tsne-0"]=t[r*e+0],i.projections["tsne-1"]=t[r*e+1],3===e&&(i.projections["tsne-2"]=t[r*e+2])}))}}setSupervision(e,t){null!=e&&(this.superviseLabels=this.shuffledDataIndices.slice(0,TSNE_SAMPLE_SIZE).map((t=>void 0!==this.points[t].metadata[e]?String(this.points[t].metadata[e]):`Unknown #${t}`))),null!=t&&(this.superviseInput=t),this.tsne&&this.tsne.setSupervision(this.superviseLabels,this.superviseInput)}setSuperviseFactor(e){null!=e&&(this.superviseFactor=e,this.tsne&&this.tsne.setSuperviseFactor(e))}mergeMetadata(e){if(e.pointsInfo.length!==this.points.length){let t=`Number of tensors (${this.points.length}) do not match the number of lines in metadata (${e.pointsInfo.length}).`;if(1===e.stats.length&&this.points.length+1===e.pointsInfo.length)return setErrorMessage(t+" Single column metadata should not have a header row.","merging metadata"),!1;if(e.stats.length>1&&this.points.length-1===e.pointsInfo.length)return setErrorMessage(t+" Multi-column metadata should have a header row with column labels.","merging metadata"),!1;setWarningMessage(t)}return this.spriteAndMetadataInfo=e,e.pointsInfo.slice(0,this.points.length).forEach(((e,t)=>this.points[t].metadata=e)),!0}stopTSNE(){this.tSNEShouldStop=!0}findNeighbors(e,t,n){return findKNNofPoint(this.points,e,n,(e=>e.vector),t).slice(0,n)}query(e,t,n){let r=getSearchPredicate(e,t,n),i=[];return this.points.forEach(((e,t)=>{r(e)&&i.push(t)})),i}}class Projection{constructor(e,t,n,r){this.projectionType=e,this.projectionComponents=t,this.dimensionality=n,this.dataSet=r}}class State{constructor(){this.label="",this.isSelected=!1,this.tSNEIteration=0,this.tSNEPerplexity=0,this.tSNELearningRate=0,this.tSNEis3d=!0,this.umapIs3d=!0,this.umapNeighbors=15,this.pcaComponentDimensions=[],this.projections=[],this.selectedPoints=[]}}function getProjectionComponents(e,t){if(t.length>3)throw new RangeError("components length must be <= 3");const n=[null,null,null],r="custom"===e?"linear":e;for(let e=0;e<t.length;++e)null!=t[e]&&(n[e]=r+"-"+t[e]);return n}function stateGetAccessorDimensions(e){let t;switch(e.selectedProjection){case"pca":t=e.pcaComponentDimensions.slice();break;case"tsne":t=[0,1],e.tSNEis3d&&t.push(2);break;case"umap":t=[0,1],e.umapIs3d&&t.push(2);break;case"custom":t=["x","y"];break;default:throw new Error("Unexpected fallthrough")}return t}const NUM_COLORS_COLOR_MAP=50,MAX_SPRITE_IMAGE_SIZE_PX=8192,METADATA_MSG_ID="metadata",TENSORS_MSG_ID="tensors";function retrieveTensorAsBytes(e,t,n,r,i,a){setModalMessage("Fetching tensor values...",TENSORS_MSG_ID);let o=new XMLHttpRequest;o.open("GET",i),o.responseType="arraybuffer",o.onprogress=e=>{if(e.lengthComputable){setModalMessage("Fetching tensor values: "+(100*e.loaded/e.total).toFixed(1)+"%",TENSORS_MSG_ID)}},o.onload=()=>{if(200!==o.status){return void setErrorMessage(String.fromCharCode.apply(null,new Uint8Array(o.response)),"fetching tensors")}let e;try{e=new Float32Array(o.response)}catch(e){return void setErrorMessage(e,"parsing tensor bytes")}let n=t.tensorShape[1],r=e.length/n;t.tensorShape[0]>r&&setWarningMessage(`Showing the first ${r.toLocaleString()} of ${t.tensorShape[0].toLocaleString()} data points`),parseTensorsFromFloat32Array(e,n).then((e=>{a(new DataSet(e))}))},o.send()}function parseRawTensors(e,t){parseTensors(e).then((e=>{t(new DataSet(e))}))}function parseRawMetadata(e,t){parseMetadata(e).then((e=>t(e)))}function streamParse(e,t,n=1e6,r="\n"){return new Promise(((i,a)=>{let o=0,s=e.byteLength-1,l="";function c(e){o+=n;let a=e.split(r),c=l+a[0];if(1===a.length)return l=c,void h(o,n);l=a[a.length-1],t(c);for(let e=1;e<a.length-1;e++)t(a[e]);if(o>=s)return l&&t(l),void i();h(o,n)}function h(t,n){const r=e.slice(t,t+n),i=new Blob([r]),a=new FileReader;a.onload=e=>c(e.target.result),a.readAsText(i)}h(o,n)}))}function parseTensors(e,t="\t"){return setModalMessage("Parsing tensors...",TENSORS_MSG_ID),new Promise(((n,r)=>{const i=[];let a;streamParse(e,(e=>{if(""===(e=e.trim()))return;const n=e.split(t),r={metadata:{},vector:null,index:i.length,projections:null};if(isNaN(n[0])||a===n.length-1?(r.metadata.label=n[0],r.vector=new Float32Array(n.slice(1).map(Number))):r.vector=new Float32Array(n.map(Number)),i.push(r),null==a&&(a=r.vector.length),a!==r.vector.length)throw setModalMessage("Parsing failed. Vector dimensions do not match"),Error("Parsing failed");if(a<=1)throw setModalMessage("Parsing failed. Found a vector with only one dimension?"),Error("Parsing failed")})).then((()=>{setModalMessage(null,TENSORS_MSG_ID),n(i)}))}))}function parseTensorsFromFloat32Array(e,t){return runAsyncTask("Parsing tensors...",(()=>{const n=e.length/t,r=[];let i=0;for(let a=0;a<n;++a)r.push({metadata:{},vector:e.subarray(i,i+t),index:a,projections:null}),i+=t;return r}),TENSORS_MSG_ID).then((e=>(setModalMessage(null,TENSORS_MSG_ID),e)))}function analyzeMetadata(e,t){const n=e.map((e=>({name:e,isNumeric:!0,tooManyUniqueValues:!1,min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY}))),r=e.map((()=>new Object));return t.forEach((t=>{e.forEach(((e,i)=>{const a=n[i],o=r[i],s=t[e];null!=s&&(a.tooManyUniqueValues||(s in o?o[s]++:o[s]=1,Object.keys(o).length>NUM_COLORS_COLOR_MAP&&(a.tooManyUniqueValues=!0)),isNaN(s)?a.isNumeric=!1:(t[e]=+s,a.min=Math.min(a.min,+s),a.max=Math.max(a.max,+s)))}))})),n.forEach(((e,t)=>{e.uniqueEntries=Object.keys(r[t]).map((e=>({label:e,count:r[t][e]})))})),n}function parseMetadata(e){return setModalMessage("Parsing metadata...",METADATA_MSG_ID),new Promise(((t,n)=>{let r=[],i=!1,a=0,o=["label"];streamParse(e,(e=>{if(0===e.trim().length)return;if(0===a&&(i=e.indexOf("\t")>=0,i))return o=e.split("\t"),void a++;a++;let t=e.split("\t"),n={};r.push(n),o.forEach(((e,r)=>{let i=t[r];i=""===i?null:i,n[e]=i}))})).then((()=>{setModalMessage(null,METADATA_MSG_ID),t({stats:analyzeMetadata(o,r),pointsInfo:r})}))}))}function fetchImage(e){return new Promise(((t,n)=>{let r=new Image;r.onload=()=>t(r),r.onerror=e=>n(e),r.crossOrigin="",r.src=e}))}function retrieveSpriteAndMetadataInfo(e,t,n,r){let i=Promise.resolve({});e&&(i=new Promise(((t,n)=>{setModalMessage("Fetching metadata...",METADATA_MSG_ID);const r=new XMLHttpRequest;r.open("GET",e),r.responseType="arraybuffer",r.onreadystatechange=()=>{if(4===r.readyState)if(200===r.status)t(parseMetadata(r.response));else{const e=new FileReader;e.onload=()=>{setErrorMessage(e.result,"fetching metadata"),n()},e.readAsText(new Blob([r.response]))}},r.send(null)})));let a=null,o=null;t&&(a=setModalMessage("Fetching sprite image..."),o=fetchImage(t)),Promise.all([i,o]).then((e=>{a&&setModalMessage(null,a);const[t,i]=e;if(i&&(i.height>MAX_SPRITE_IMAGE_SIZE_PX||i.width>MAX_SPRITE_IMAGE_SIZE_PX))setModalMessage(`Error: Sprite image of dimensions ${i.width}px x ${i.height}px exceeds maximum dimensions ${MAX_SPRITE_IMAGE_SIZE_PX}px x ${MAX_SPRITE_IMAGE_SIZE_PX}px`);else{t.spriteImage=i,t.spriteMetadata=n;try{r(t)}catch(e){setModalMessage(String(e))}}}))}const BYTES_EXTENSION=".bytes";class DemoDataProvider{constructor(e){this.projectorConfigPath=e}getEmbeddingInfo(e){let t=this.projectorConfig.embeddings;for(let n=0;n<t.length;n++){let r=t[n];if(r.tensorName===e)return r}return null}retrieveRuns(e){e(["Demo"])}retrieveProjectorConfig(e,t){const n=setModalMessage("Fetching projector config..."),r=new XMLHttpRequest;r.open("GET",this.projectorConfigPath),r.onerror=e=>{let t=e.message;null!=r.responseText&&(t="Cannot fetch projector config, possibly a Cross-Origin request error."),setErrorMessage(t,"fetching projector config")},r.onload=()=>{const e=JSON.parse(r.responseText);setModalMessage(null,n),this.projectorConfig=e,t(e)},r.send()}retrieveTensor(e,t,n){let r=this.getEmbeddingInfo(t),i=`${r.tensorPath}`;if(r.tensorPath.substr(-1*BYTES_EXTENSION.length)===BYTES_EXTENSION)retrieveTensorAsBytes(this,this.getEmbeddingInfo(t),e,t,i,n);else{setModalMessage("Fetching tensors...",TENSORS_MSG_ID);const e=new XMLHttpRequest;e.open("GET",i),e.responseType="arraybuffer",e.onerror=()=>{setErrorMessage(e.responseText,"fetching tensors")},e.onload=()=>{parseTensors(e.response).then((e=>{n(new DataSet(e))}))},e.send()}}retrieveSpriteAndMetadata(e,t,n){let r=this.getEmbeddingInfo(t),i=null;r.sprite&&r.sprite.imagePath&&(i=r.sprite.imagePath),retrieveSpriteAndMetadataInfo(r.metadataPath,i,r.sprite,n)}getBookmarks(e,t,n){let r=this.getEmbeddingInfo(t),i=setModalMessage("Fetching bookmarks...");const a=new XMLHttpRequest;a.open("GET",r.bookmarksPath),a.onerror=e=>{setErrorMessage(a.responseText)},a.onload=()=>{const e=JSON.parse(a.responseText);setModalMessage(null,i),n(e)},a.send()}}class ProtoDataProvider{constructor(e){this.dataProto=e}retrieveRuns(e){e(["proto"])}retrieveProjectorConfig(e,t){t({modelCheckpointPath:"proto",embeddings:[{tensorName:"proto",tensorShape:this.dataProto.shape,metadataPath:"proto"}]})}retrieveTensor(e,t,n){n(this.flatArrayToDataset(this.dataProto.tensor))}retrieveSpriteAndMetadata(e,t,n){let r=this.dataProto.metadata.columns.map((e=>e.name)),i=this.dataProto.shape[0],a=new Array(i);this.dataProto.metadata.columns.forEach((e=>{let t=e.numericValues||e.stringValues;for(let n=0;n<i;n++)a[n]=a[n]||{},a[n][e.name]=t[n]}));let o=Promise.resolve(null);null!=this.dataProto.metadata.sprite&&(o=new Promise(((e,t)=>{const n=new Image;n.onload=()=>e(n),n.onerror=()=>t("Failed converting base64 to an image"),n.src=this.dataProto.metadata.sprite.imageBase64}))),o.then((e=>{const t={stats:analyzeMetadata(r,a),pointsInfo:a};null!=e&&(t.spriteImage=e,t.spriteMetadata={singleImageDim:this.dataProto.metadata.sprite.singleImageDim,imagePath:"proto"}),n(t)}))}getBookmarks(e,t,n){return n([])}flatArrayToDataset(e){let t=[],n=this.dataProto.shape[0],r=this.dataProto.shape[1];if(n*r!==e.length)throw"The shape doesn't match the length of the flattened array";for(let i=0;i<n;i++){let n=i*r;t.push({vector:new Float32Array(e.slice(n,n+r)),metadata:{},projections:null,index:i})}return new DataSet(t)}}const LIMIT_NUM_POINTS=1e5;class ServerDataProvider{constructor(e){this.runProjectorConfigCache={},this.routePrefix=e}getEmbeddingInfo(e,t,n){this.retrieveProjectorConfig(e,(e=>{const r=e.embeddings;for(let e=0;e<r.length;e++){const i=r[e];if(i.tensorName===t)return void n(i)}n(null)}))}retrieveRuns(e){const t=setModalMessage("Fetching runs..."),n=new XMLHttpRequest;n.open("GET",`${this.routePrefix}/runs`),n.onerror=e=>{setErrorMessage(n.responseText,"fetching runs")},n.onload=()=>{const r=JSON.parse(n.responseText);setModalMessage(null,t),e(r)},n.send()}retrieveProjectorConfig(e,t){if(e in this.runProjectorConfigCache)return void t(this.runProjectorConfigCache[e]);const n=setModalMessage("Fetching projector config..."),r=new XMLHttpRequest;r.open("GET",`${this.routePrefix}/info?run=${e}`),r.onerror=e=>{setErrorMessage(r.responseText,"fetching projector config")},r.onload=()=>{const i=JSON.parse(r.responseText);setModalMessage(null,n),this.runProjectorConfigCache[e]=i,t(i)},r.send()}retrieveTensor(e,t,n){this.getEmbeddingInfo(e,t,(r=>{retrieveTensorAsBytes(this,r,e,t,`${this.routePrefix}/tensor?run=${e}&name=${t}&num_rows=${LIMIT_NUM_POINTS}`,n)}))}retrieveSpriteAndMetadata(e,t,n){this.getEmbeddingInfo(e,t,(r=>{let i=null;r.metadataPath&&(i=`${this.routePrefix}/metadata?run=${e}&name=${t}&num_rows=${LIMIT_NUM_POINTS}`);let a=null;r.sprite&&r.sprite.imagePath&&(a=`${this.routePrefix}/sprite_image?run=${e}&name=${t}`),retrieveSpriteAndMetadataInfo(i,a,r.sprite,n)}))}getBookmarks(e,t,n){const r=setModalMessage("Fetching bookmarks..."),i=new XMLHttpRequest;i.open("GET",`${this.routePrefix}/bookmarks?run=${e}&name=${t}`),i.onerror=e=>{setErrorMessage(i.responseText,"fetching bookmarks")},i.onload=()=>{setModalMessage(null,r);const e=JSON.parse(i.responseText);n(e)},i.send()}}class LabelRenderParams{constructor(e,t,n,r,i,a,o){this.pointIndices=e,this.labelStrings=t,this.scaleFactors=n,this.useSceneOpacityFlags=r,this.defaultFontSize=i,this.fillColors=a,this.strokeColors=o}}var CameraType;!(function(e){e[e.Perspective=0]="Perspective",e[e.Orthographic=1]="Orthographic"})(CameraType||(CameraType={}));class RenderContext{constructor(e,t,n,r,i,a,o,s,l,c,h,u,d,p){this.camera=e,this.cameraType=t,this.cameraTarget=n,this.screenWidth=r,this.screenHeight=i,this.nearestCameraSpacePointZ=a,this.farthestCameraSpacePointZ=o,this.backgroundColor=s,this.pointColors=l,this.pointScaleFactors=c,this.labels=h,this.polylineColors=u,this.polylineOpacities=d,this.polylineWidths=p}}const _changeEvent={type:"change"},_startEvent={type:"start"},_endEvent={type:"end"};class OrbitControls extends EventDispatcher{constructor(e,t){super(),void 0===t&&console.warn('THREE.OrbitControls: The second parameter "domElement" is now mandatory.'),t===document&&console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.'),this.object=e,this.domElement=t,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new Vector3,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:MOUSE.ROTATE,MIDDLE:MOUSE.DOLLY,RIGHT:MOUSE.PAN},this.touches={ONE:TOUCH.ROTATE,TWO:TOUCH.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this.getPolarAngle=function(){return o.phi},this.getAzimuthalAngle=function(){return o.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.listenToKeyEvents=function(e){e.addEventListener("keydown",U),this._domElementKeyEvents=e},this.saveState=function(){n.target0.copy(n.target),n.position0.copy(n.object.position),n.zoom0=n.object.zoom},this.reset=function(){n.target.copy(n.target0),n.object.position.copy(n.position0),n.object.zoom=n.zoom0,n.object.updateProjectionMatrix(),n.dispatchEvent(_changeEvent),n.update(),i=r.NONE},this.update=(function(){const t=new Vector3,u=(new Quaternion).setFromUnitVectors(e.up,new Vector3(0,1,0)),d=u.clone().invert(),p=new Vector3,m=new Quaternion,f=2*Math.PI;return function e(){const g=n.object.position;t.copy(g).sub(n.target),t.applyQuaternion(u),o.setFromVector3(t),n.autoRotate&&i===r.NONE&&w((function v(){return 2*Math.PI/60/60*n.autoRotateSpeed})()),n.enableDamping?(o.theta+=s.theta*n.dampingFactor,o.phi+=s.phi*n.dampingFactor):(o.theta+=s.theta,o.phi+=s.phi);let y=n.minAzimuthAngle,_=n.maxAzimuthAngle;return isFinite(y)&&isFinite(_)&&(y<-Math.PI?y+=f:y>Math.PI&&(y-=f),_<-Math.PI?_+=f:_>Math.PI&&(_-=f),o.theta=y<=_?Math.max(y,Math.min(_,o.theta)):o.theta>(y+_)/2?Math.max(y,o.theta):Math.min(_,o.theta)),o.phi=Math.max(n.minPolarAngle,Math.min(n.maxPolarAngle,o.phi)),o.makeSafe(),o.radius*=l,o.radius=Math.max(n.minDistance,Math.min(n.maxDistance,o.radius)),!0===n.enableDamping?n.target.addScaledVector(c,n.dampingFactor):n.target.add(c),t.setFromSpherical(o),t.applyQuaternion(d),g.copy(n.target).add(t),n.object.lookAt(n.target),!0===n.enableDamping?(s.theta*=1-n.dampingFactor,s.phi*=1-n.dampingFactor,c.multiplyScalar(1-n.dampingFactor)):(s.set(0,0,0),c.set(0,0,0)),l=1,!!(h||p.distanceToSquared(n.object.position)>a||8*(1-m.dot(n.object.quaternion))>a)&&(n.dispatchEvent(_changeEvent),p.copy(n.object.position),m.copy(n.object.quaternion),h=!1,!0)}})(),this.dispose=function(){n.domElement.removeEventListener("contextmenu",G),n.domElement.removeEventListener("pointerdown",F),n.domElement.removeEventListener("pointercancel",V),n.domElement.removeEventListener("wheel",H),n.domElement.removeEventListener("pointermove",O),n.domElement.removeEventListener("pointerup",B),null!==n._domElementKeyEvents&&n._domElementKeyEvents.removeEventListener("keydown",U)};const n=this,r={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let i=r.NONE;const a=1e-6,o=new Spherical,s=new Spherical;let l=1;const c=new Vector3;let h=!1;const u=new Vector2,d=new Vector2,p=new Vector2,m=new Vector2,f=new Vector2,g=new Vector2,v=new Vector2,y=new Vector2,_=new Vector2,b=[],x={};function S(){return Math.pow(.95,n.zoomSpeed)}function w(e){s.theta-=e}function C(e){s.phi-=e}const M=(function(){const e=new Vector3;return function t(n,r){e.setFromMatrixColumn(r,0),e.multiplyScalar(-n),c.add(e)}})(),E=(function(){const e=new Vector3;return function t(r,i){!0===n.screenSpacePanning?e.setFromMatrixColumn(i,1):(e.setFromMatrixColumn(i,0),e.crossVectors(n.object.up,e)),e.multiplyScalar(r),c.add(e)}})(),T=(function(){const e=new Vector3;return function t(r,i){const a=n.domElement;if(n.object.isPerspectiveCamera){e.copy(n.object.position).sub(n.target);let t=e.length();t*=Math.tan(n.object.fov/2*Math.PI/180),M(2*r*t/a.clientHeight,n.object.matrix),E(2*i*t/a.clientHeight,n.object.matrix)}else n.object.isOrthographicCamera?(M(r*(n.object.right-n.object.left)/n.object.zoom/a.clientWidth,n.object.matrix),E(i*(n.object.top-n.object.bottom)/n.object.zoom/a.clientHeight,n.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),n.enablePan=!1)}})();function I(e){n.object.isPerspectiveCamera?l/=e:n.object.isOrthographicCamera?(n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom*e)),n.object.updateProjectionMatrix(),h=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function A(e){n.object.isPerspectiveCamera?l*=e:n.object.isOrthographicCamera?(n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/e)),n.object.updateProjectionMatrix(),h=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function k(e){u.set(e.clientX,e.clientY)}function P(e){m.set(e.clientX,e.clientY)}function R(){if(1===b.length)u.set(b[0].pageX,b[0].pageY);else{u.set(.5*(b[0].pageX+b[1].pageX),.5*(b[0].pageY+b[1].pageY))}}function N(){if(1===b.length)m.set(b[0].pageX,b[0].pageY);else{m.set(.5*(b[0].pageX+b[1].pageX),.5*(b[0].pageY+b[1].pageY))}}function L(){const e=b[0].pageX-b[1].pageX,t=b[0].pageY-b[1].pageY,n=Math.sqrt(e*e+t*t);v.set(0,n)}function D(e){if(1==b.length)d.set(e.pageX,e.pageY);else{const t=q(e);d.set(.5*(e.pageX+t.x),.5*(e.pageY+t.y))}p.subVectors(d,u).multiplyScalar(n.rotateSpeed);const t=n.domElement;w(2*Math.PI*p.x/t.clientHeight),C(2*Math.PI*p.y/t.clientHeight),u.copy(d)}function $(e){if(1===b.length)f.set(e.pageX,e.pageY);else{const t=q(e);f.set(.5*(e.pageX+t.x),.5*(e.pageY+t.y))}g.subVectors(f,m).multiplyScalar(n.panSpeed),T(g.x,g.y),m.copy(f)}function z(e){const t=q(e),r=e.pageX-t.x,i=e.pageY-t.y,a=Math.sqrt(r*r+i*i);y.set(0,a),_.set(0,Math.pow(y.y/v.y,n.zoomSpeed)),I(_.y),v.copy(y)}function F(e){!1!==n.enabled&&(0===b.length&&(n.domElement.setPointerCapture(e.pointerId),n.domElement.addEventListener("pointermove",O),n.domElement.addEventListener("pointerup",B)),(function t(e){b.push(e)})(e),"touch"===e.pointerType?(function a(e){switch(j(e),b.length){case 1:switch(n.touches.ONE){case TOUCH.ROTATE:if(!1===n.enableRotate)return;R(),i=r.TOUCH_ROTATE;break;case TOUCH.PAN:if(!1===n.enablePan)return;N(),i=r.TOUCH_PAN;break;default:i=r.NONE}break;case 2:switch(n.touches.TWO){case TOUCH.DOLLY_PAN:if(!1===n.enableZoom&&!1===n.enablePan)return;!(function e(){n.enableZoom&&L(),n.enablePan&&N()})(),i=r.TOUCH_DOLLY_PAN;break;case TOUCH.DOLLY_ROTATE:if(!1===n.enableZoom&&!1===n.enableRotate)return;!(function t(){n.enableZoom&&L(),n.enableRotate&&R()})(),i=r.TOUCH_DOLLY_ROTATE;break;default:i=r.NONE}break;default:i=r.NONE}i!==r.NONE&&n.dispatchEvent(_startEvent)})(e):(function o(e){let t;switch(e.button){case 0:t=n.mouseButtons.LEFT;break;case 1:t=n.mouseButtons.MIDDLE;break;case 2:t=n.mouseButtons.RIGHT;break;default:t=-1}switch(t){case MOUSE.DOLLY:if(!1===n.enableZoom)return;!(function t(e){v.set(e.clientX,e.clientY)})(e),i=r.DOLLY;break;case MOUSE.ROTATE:if(e.ctrlKey||e.metaKey||e.shiftKey){if(!1===n.enablePan)return;P(e),i=r.PAN}else{if(!1===n.enableRotate)return;k(e),i=r.ROTATE}break;case MOUSE.PAN:if(e.ctrlKey||e.metaKey||e.shiftKey){if(!1===n.enableRotate)return;k(e),i=r.ROTATE}else{if(!1===n.enablePan)return;P(e),i=r.PAN}break;default:i=r.NONE}i!==r.NONE&&n.dispatchEvent(_startEvent)})(e))}function O(e){!1!==n.enabled&&("touch"===e.pointerType?(function t(e){switch(j(e),i){case r.TOUCH_ROTATE:if(!1===n.enableRotate)return;D(e),n.update();break;case r.TOUCH_PAN:if(!1===n.enablePan)return;$(e),n.update();break;case r.TOUCH_DOLLY_PAN:if(!1===n.enableZoom&&!1===n.enablePan)return;!(function t(e){n.enableZoom&&z(e),n.enablePan&&$(e)})(e),n.update();break;case r.TOUCH_DOLLY_ROTATE:if(!1===n.enableZoom&&!1===n.enableRotate)return;!(function a(e){n.enableZoom&&z(e),n.enableRotate&&D(e)})(e),n.update();break;default:i=r.NONE}})(e):(function a(e){if(!1===n.enabled)return;switch(i){case r.ROTATE:if(!1===n.enableRotate)return;!(function t(e){d.set(e.clientX,e.clientY),p.subVectors(d,u).multiplyScalar(n.rotateSpeed);const t=n.domElement;w(2*Math.PI*p.x/t.clientHeight),C(2*Math.PI*p.y/t.clientHeight),u.copy(d),n.update()})(e);break;case r.DOLLY:if(!1===n.enableZoom)return;!(function i(e){y.set(e.clientX,e.clientY),_.subVectors(y,v),_.y>0?I(S()):_.y<0&&A(S()),v.copy(y),n.update()})(e);break;case r.PAN:if(!1===n.enablePan)return;!(function a(e){f.set(e.clientX,e.clientY),g.subVectors(f,m).multiplyScalar(n.panSpeed),T(g.x,g.y),m.copy(f),n.update()})(e)}})(e))}function B(e){W(e),0===b.length&&(n.domElement.releasePointerCapture(e.pointerId),n.domElement.removeEventListener("pointermove",O),n.domElement.removeEventListener("pointerup",B)),n.dispatchEvent(_endEvent),i=r.NONE}function V(e){W(e)}function H(e){!1!==n.enabled&&!1!==n.enableZoom&&i===r.NONE&&(e.preventDefault(),n.dispatchEvent(_startEvent),(function t(e){e.deltaY<0?A(S()):e.deltaY>0&&I(S()),n.update()})(e),n.dispatchEvent(_endEvent))}function U(e){!1!==n.enabled&&!1!==n.enablePan&&(function t(e){let t=!1;switch(e.code){case n.keys.UP:T(0,n.keyPanSpeed),t=!0;break;case n.keys.BOTTOM:T(0,-n.keyPanSpeed),t=!0;break;case n.keys.LEFT:T(n.keyPanSpeed,0),t=!0;break;case n.keys.RIGHT:T(-n.keyPanSpeed,0),t=!0}t&&(e.preventDefault(),n.update())})(e)}function G(e){!1!==n.enabled&&e.preventDefault()}function W(e){delete x[e.pointerId];for(let t=0;t<b.length;t++)if(b[t].pointerId==e.pointerId)return void b.splice(t,1)}function j(e){let t=x[e.pointerId];void 0===t&&(t=new Vector2,x[e.pointerId]=t),t.set(e.pageX,e.pageY)}function q(e){return x[(e.pointerId===b[0].pointerId?b[1]:b[0]).pointerId]}n.domElement.addEventListener("contextmenu",G),n.domElement.addEventListener("pointerdown",F),n.domElement.addEventListener("pointercancel",V),n.domElement.addEventListener("wheel",H,{passive:!1}),this.update()}}const FILL="#dddddd",FILL_OPACITY=.2,STROKE="#aaaaaa",STROKE_WIDTH=2,STROKE_DASHARRAY="10 5";class ScatterPlotRectangleSelector{constructor(e,t){this.svgElement=e.querySelector("#selector"),this.rectElement=document.createElementNS("http://www.w3.org/2000/svg","rect"),this.rectElement.style.stroke=STROKE,this.rectElement.style.strokeDasharray=STROKE_DASHARRAY,this.rectElement.style.strokeWidth=""+STROKE_WIDTH,this.rectElement.style.fill=FILL,this.rectElement.style.fillOpacity=""+FILL_OPACITY,this.svgElement.appendChild(this.rectElement),this.selectionCallback=t,this.isMouseDown=!1}onMouseDown(e,t){this.isMouseDown=!0,this.svgElement.style.display="block",this.startCoordinates=[e,t],this.lastBoundingBox={x:this.startCoordinates[0],y:this.startCoordinates[1],width:1,height:1}}onMouseMove(e,t){this.isMouseDown&&(this.lastBoundingBox.x=Math.min(e,this.startCoordinates[0]),this.lastBoundingBox.y=Math.max(t,this.startCoordinates[1]),this.lastBoundingBox.width=Math.max(e,this.startCoordinates[0])-this.lastBoundingBox.x,this.lastBoundingBox.height=this.lastBoundingBox.y-Math.min(t,this.startCoordinates[1]),this.rectElement.setAttribute("x",""+this.lastBoundingBox.x),this.rectElement.setAttribute("y",""+(this.lastBoundingBox.y-this.lastBoundingBox.height)),this.rectElement.setAttribute("width",""+this.lastBoundingBox.width),this.rectElement.setAttribute("height",""+this.lastBoundingBox.height))}onMouseUp(){this.isMouseDown=!1,this.svgElement.style.display="none",this.rectElement.setAttribute("width","0"),this.rectElement.setAttribute("height","0"),this.selectionCallback(this.lastBoundingBox)}}const BACKGROUND_COLOR=16777215,CUBE_LENGTH=2,MAX_ZOOM=5*CUBE_LENGTH,MIN_ZOOM=.025*CUBE_LENGTH,PERSP_CAMERA_FOV_VERTICAL=70,PERSP_CAMERA_NEAR_CLIP_PLANE=.01,PERSP_CAMERA_FAR_CLIP_PLANE=100,ORTHO_CAMERA_FRUSTUM_HALF_EXTENT=1.2,SHIFT_KEY=16,CTRL_KEY=17,ORBIT_MOUSE_ROTATION_SPEED=1,ORBIT_ANIMATION_ROTATION_CYCLE_IN_SECONDS=7;var MouseMode;!(function(e){e[e.AREA_SELECT=0]="AREA_SELECT",e[e.CAMERA_AND_CLICK_SELECT=1]="CAMERA_AND_CLICK_SELECT"})(MouseMode||(MouseMode={}));class CameraDef{constructor(){this.orthographic=!1}}class ScatterPlot{constructor(e,t){this.container=e,this.projectorEventContext=t,this.START_CAMERA_POS_3D=new Vector3(.45,.9,1.6),this.START_CAMERA_TARGET_3D=new Vector3(0,0,0),this.START_CAMERA_POS_2D=new Vector3(0,0,4),this.START_CAMERA_TARGET_2D=new Vector3(0,0,0),this.visualizers=[],this.onCameraMoveListeners=[],this.backgroundColor=BACKGROUND_COLOR,this.dimensionality=3,this.cameraDef=null,this.orbitAnimationOnNextCameraCreation=!1,this.selecting=!1,this.mouseIsDown=!1,this.isDragSequence=!1,this.getLayoutValues(),this.scene=new Scene,this.renderer=new WebGLRenderer({alpha:!0,premultipliedAlpha:!1,antialias:!1}),this.renderer.setClearColor(BACKGROUND_COLOR,1),this.container.appendChild(this.renderer.domElement),this.light=new PointLight(16772287,1,0),this.scene.add(this.light),this.setDimensions(3),this.recreateCamera(this.makeDefaultCameraDef(this.dimensionality)),this.renderer.render(this.scene,this.camera),this.rectangleSelector=new ScatterPlotRectangleSelector(this.container,(e=>this.selectBoundingBox(e))),this.addInteractionListeners()}addInteractionListeners(){this.container.addEventListener("mousemove",this.onMouseMove.bind(this)),this.container.addEventListener("mousedown",this.onMouseDown.bind(this)),this.container.addEventListener("mouseup",this.onMouseUp.bind(this)),this.container.addEventListener("click",this.onClick.bind(this)),window.addEventListener("keydown",this.onKeyDown.bind(this),!1),window.addEventListener("keyup",this.onKeyUp.bind(this),!1)}addCameraControlsEventListeners(e){e.addEventListener("start",(()=>{this.stopOrbitAnimation(),this.onCameraMoveListeners.forEach((t=>t(this.camera.position,e.target)))})),e.addEventListener("change",(()=>{this.render()})),e.addEventListener("end",(()=>{}))}makeOrbitControls(e,t,n){null!=this.orbitCameraControls&&this.orbitCameraControls.dispose();const r=new OrbitControls(e,this.renderer.domElement);r.target0=new Vector3(t.target[0],t.target[1],t.target[2]),r.position0=(new Vector3).copy(e.position),r.zoom0=t.zoom,r.enableRotate=n,r.autoRotate=!1,r.rotateSpeed=ORBIT_MOUSE_ROTATION_SPEED,n?(r.mouseButtons.ORBIT=MOUSE.LEFT,r.mouseButtons.PAN=MOUSE.RIGHT):(r.mouseButtons.ORBIT=null,r.mouseButtons.PAN=MOUSE.LEFT),r.reset(),this.camera=e,this.orbitCameraControls=r,this.addCameraControlsEventListeners(this.orbitCameraControls)}makeCamera3D(e,t,n){let r;{r=new PerspectiveCamera(PERSP_CAMERA_FOV_VERTICAL,t/n,PERSP_CAMERA_NEAR_CLIP_PLANE,PERSP_CAMERA_FAR_CLIP_PLANE),r.position.set(e.position[0],e.position[1],e.position[2]);const i=new Vector3(e.target[0],e.target[1],e.target[2]);r.lookAt(i),r.zoom=e.zoom,r.updateProjectionMatrix()}this.camera=r,this.makeOrbitControls(r,e,!0)}makeCamera2D(e,t,n){let r;const i=new Vector3(e.target[0],e.target[1],e.target[2]);{const a=t/n;let o=-ORTHO_CAMERA_FRUSTUM_HALF_EXTENT,s=ORTHO_CAMERA_FRUSTUM_HALF_EXTENT,l=-ORTHO_CAMERA_FRUSTUM_HALF_EXTENT,c=ORTHO_CAMERA_FRUSTUM_HALF_EXTENT;a>1?(o*=a,s*=a):(c/=a,l/=a),r=new OrthographicCamera(o,s,c,l,-1e3,1e3),r.position.set(e.position[0],e.position[1],e.position[2]),r.up=new Vector3(0,1,0),r.lookAt(i),r.zoom=e.zoom,r.updateProjectionMatrix()}this.camera=r,this.makeOrbitControls(r,e,!1)}makeDefaultCameraDef(e){const t=new CameraDef;return t.orthographic=2===e,t.zoom=1,t.orthographic?(t.position=[this.START_CAMERA_POS_2D.x,this.START_CAMERA_POS_2D.y,this.START_CAMERA_POS_2D.z],t.target=[this.START_CAMERA_TARGET_2D.x,this.START_CAMERA_TARGET_2D.y,this.START_CAMERA_TARGET_2D.z]):(t.position=[this.START_CAMERA_POS_3D.x,this.START_CAMERA_POS_3D.y,this.START_CAMERA_POS_3D.z],t.target=[this.START_CAMERA_TARGET_3D.x,this.START_CAMERA_TARGET_3D.y,this.START_CAMERA_TARGET_3D.z]),t}recreateCamera(e){e.orthographic?this.makeCamera2D(e,this.width,this.height):this.makeCamera3D(e,this.width,this.height),this.orbitCameraControls.minDistance=MIN_ZOOM,this.orbitCameraControls.maxDistance=MAX_ZOOM,this.orbitCameraControls.update(),this.orbitAnimationOnNextCameraCreation&&this.startOrbitAnimation()}onClick(e,t=!0){if(!e||!this.selecting){if(!this.isDragSequence&&t){this.projectorEventContext.notifySelectionChanged(null!=this.nearestPoint?[this.nearestPoint]:[])}this.isDragSequence=!1,this.render()}}onMouseDown(e){this.isDragSequence=!1,this.mouseIsDown=!0,this.selecting?(this.orbitCameraControls.enabled=!1,this.rectangleSelector.onMouseDown(e.offsetX,e.offsetY),this.setNearestPointToMouse(e)):!e.ctrlKey&&this.sceneIs3D()&&this.orbitCameraControls.mouseButtons.ORBIT===MOUSE.RIGHT?(this.orbitCameraControls.mouseButtons.ORBIT=MOUSE.LEFT,this.orbitCameraControls.mouseButtons.PAN=MOUSE.RIGHT):e.ctrlKey&&this.sceneIs3D()&&this.orbitCameraControls.mouseButtons.ORBIT===MOUSE.LEFT&&(this.orbitCameraControls.mouseButtons.ORBIT=MOUSE.RIGHT,this.orbitCameraControls.mouseButtons.PAN=MOUSE.LEFT)}onMouseUp(e){this.selecting&&(this.orbitCameraControls.enabled=!0,this.rectangleSelector.onMouseUp(),this.render()),this.mouseIsDown=!1}onMouseMove(e){this.isDragSequence=this.mouseIsDown,this.selecting&&this.mouseIsDown?(this.rectangleSelector.onMouseMove(e.offsetX,e.offsetY),this.render()):this.mouseIsDown||(this.setNearestPointToMouse(e),this.projectorEventContext.notifyHoverOverPoint(this.nearestPoint))}onKeyDown(e){e.keyCode===CTRL_KEY&&this.sceneIs3D()&&(this.orbitCameraControls.mouseButtons.ORBIT=MOUSE.RIGHT,this.orbitCameraControls.mouseButtons.PAN=MOUSE.LEFT),e.keyCode===SHIFT_KEY&&(this.selecting=!0,this.container.style.cursor="crosshair")}onKeyUp(e){e.keyCode===CTRL_KEY&&this.sceneIs3D()&&(this.orbitCameraControls.mouseButtons.ORBIT=MOUSE.LEFT,this.orbitCameraControls.mouseButtons.PAN=MOUSE.RIGHT),e.keyCode===SHIFT_KEY&&(this.selecting=this.getMouseMode()===MouseMode.AREA_SELECT,this.selecting||(this.container.style.cursor="default"),this.render())}getPointIndicesFromPickingTexture(e){if(null==this.worldSpacePointPositions)return null;const t=this.worldSpacePointPositions.length/3,n=window.devicePixelRatio||1,r=Math.floor(e.x*n),i=Math.floor(e.y*n),a=Math.floor(e.width*n),o=Math.floor(e.height*n);let s=new Uint8Array(a*o*4);this.renderer.readRenderTargetPixels(this.pickingTexture,r,this.pickingTexture.height-i,a,o,s);let l=new Uint8Array(this.worldSpacePointPositions.length);for(let e=0;e<a*o;e++){const n=s[4*e]<<16|s[4*e+1]<<8|s[4*e+2];16777215!==n&&n<t&&(l[n]=1)}let c=[];for(let e=0;e<l.length;e++)1===l[e]&&c.push(e);return c}selectBoundingBox(e){let t=this.getPointIndicesFromPickingTexture(e);this.projectorEventContext.notifySelectionChanged(t)}setNearestPointToMouse(e){if(null==this.pickingTexture)return void(this.nearestPoint=null);const t=this.getPointIndicesFromPickingTexture({x:e.offsetX,y:e.offsetY,width:1,height:1});this.nearestPoint=null!=t?t[0]:null}getLayoutValues(){return this.width=this.container.offsetWidth,this.height=Math.max(1,this.container.offsetHeight),[this.width,this.height]}sceneIs3D(){return 3===this.dimensionality}remove3dAxisFromScene(){const e=this.scene.getObjectByName("axes");return null!=e&&this.scene.remove(e),e}add3dAxis(){const e=new AxesHelper;e.name="axes",this.scene.add(e)}setDimensions(e){if(2!==e&&3!==e)throw new RangeError("dimensionality must be 2 or 3");this.dimensionality=e;const t=this.cameraDef||this.makeDefaultCameraDef(e);this.recreateCamera(t),this.remove3dAxisFromScene(),3===e&&this.add3dAxis()}getCameraDef(){const e=new CameraDef,t=this.camera.position,n=this.orbitCameraControls.target;return e.orthographic=!this.sceneIs3D(),e.position=[t.x,t.y,t.z],e.target=[n.x,n.y,n.z],e.zoom=this.camera.zoom,e}setCameraParametersForNextCameraCreation(e,t){this.cameraDef=e,this.orbitAnimationOnNextCameraCreation=t}getCameraPosition(){const e=this.camera.position;return[e.x,e.y,e.z]}getCameraTarget(){let e=this.orbitCameraControls.target;return[e.x,e.y,e.z]}setCameraPositionAndTarget(e,t){this.stopOrbitAnimation(),this.camera.position.set(e[0],e[1],e[2]),this.orbitCameraControls.target.set(t[0],t[1],t[2]),this.orbitCameraControls.update(),this.render()}startOrbitAnimation(){this.sceneIs3D()&&(null!=this.orbitAnimationId&&this.stopOrbitAnimation(),this.orbitCameraControls.autoRotate=!0,this.orbitCameraControls.rotateSpeed=ORBIT_ANIMATION_ROTATION_CYCLE_IN_SECONDS,this.updateOrbitAnimation())}updateOrbitAnimation(){this.orbitCameraControls.update(),this.orbitAnimationId=requestAnimationFrame((()=>this.updateOrbitAnimation()))}stopOrbitAnimation(){this.orbitCameraControls.autoRotate=!1,this.orbitCameraControls.rotateSpeed=ORBIT_MOUSE_ROTATION_SPEED,null!=this.orbitAnimationId&&(cancelAnimationFrame(this.orbitAnimationId),this.orbitAnimationId=null)}addVisualizer(e){this.scene&&e.setScene(this.scene),e.onResize(this.width,this.height),e.onPointPositionsChanged(this.worldSpacePointPositions),this.visualizers.push(e)}removeAllVisualizers(){this.visualizers.forEach((e=>e.dispose())),this.visualizers=[]}setPointPositions(e){this.worldSpacePointPositions=e,this.visualizers.forEach((t=>t.onPointPositionsChanged(e)))}render(){{const e=this.camera.position.clone();e.x+=1,e.y+=1,this.light.position.set(e.x,e.y,e.z)}const e=this.camera instanceof PerspectiveCamera?CameraType.Perspective:CameraType.Orthographic;let t=[0,0];null!=this.worldSpacePointPositions&&(t=getNearFarPoints(this.worldSpacePointPositions,this.camera.position,this.orbitCameraControls.target));const n=new RenderContext(this.camera,e,this.orbitCameraControls.target,this.width,this.height,t[0],t[1],this.backgroundColor,this.pointColors,this.pointScaleFactors,this.labels,this.polylineColors,this.polylineOpacities,this.polylineWidths);this.visualizers.forEach((e=>e.onPickingRender(n)));{const e=this.remove3dAxisFromScene();this.renderer.setRenderTarget(this.pickingTexture?this.pickingTexture:null),this.renderer.render(this.scene,this.camera),this.renderer.setRenderTarget(null),null!=e&&this.scene.add(e)}this.visualizers.forEach((e=>e.onRender(n))),this.renderer.render(this.scene,this.camera)}setMouseMode(e){this.mouseMode=e,e===MouseMode.AREA_SELECT?(this.selecting=!0,this.container.style.cursor="crosshair"):(this.selecting=!1,this.container.style.cursor="default")}setPointColors(e){this.pointColors=e}setPointScaleFactors(e){this.pointScaleFactors=e}setLabels(e){this.labels=e}setPolylineColors(e){this.polylineColors=e}setPolylineOpacities(e){this.polylineOpacities=e}setPolylineWidths(e){this.polylineWidths=e}getMouseMode(){return this.mouseMode}resetZoom(){this.recreateCamera(this.makeDefaultCameraDef(this.dimensionality)),this.render()}setDayNightMode(e){const t=this.container.querySelectorAll("canvas"),n=e?"invert(100%)":null;for(let e=0;e<t.length;e++)t[e].style.filter=n}resize(e=!0){const[t,n]=[this.width,this.height],[r,i]=this.getLayoutValues();if(3===this.dimensionality){const e=this.camera;e.aspect=r/i,e.updateProjectionMatrix()}else{const e=this.camera,a=(e.right-e.left)*(r/t)/2,o=(e.top-e.bottom)*(i/n)/2;e.top=o,e.bottom=-o,e.left=-a,e.right=a,e.updateProjectionMatrix()}const a=window.devicePixelRatio||1;this.renderer.setPixelRatio(a),this.renderer.setSize(r,i);{const e=new Vector2;this.renderer.getSize(e);const t=this.renderer.getPixelRatio();this.pickingTexture=new WebGLRenderTarget(e.width*t,e.height*t),this.pickingTexture.texture.minFilter=LinearFilter}this.visualizers.forEach((e=>e.onResize(r,i))),e&&this.render()}onCameraMove(e){this.onCameraMoveListeners.push(e)}clickOnPoint(e){this.nearestPoint=e,this.onClick(null,!1)}}const FONT_SIZE=80,ONE_OVER_FONT_SIZE=1/FONT_SIZE,LABEL_SCALE=2.2,LABEL_COLOR="black",LABEL_BACKGROUND="white",MAX_CANVAS_DIMENSION=8192,NUM_GLYPHS=256,RGB_ELEMENTS_PER_ENTRY=3,XYZ_ELEMENTS_PER_ENTRY=3,UV_ELEMENTS_PER_ENTRY=2,VERTICES_PER_GLYPH=6,VERTEX_SHADER=`\n    attribute vec2 posObj;\n    attribute vec3 color;\n    varying vec2 vUv;\n    varying vec3 vColor;\n\n    void main() {\n      vUv = uv;\n      vColor = color;\n\n      // Rotate label to face camera.\n\n      vec4 vRight = vec4(\n        modelViewMatrix[0][0], modelViewMatrix[1][0], modelViewMatrix[2][0], 0);\n\n      vec4 vUp = vec4(\n        modelViewMatrix[0][1], modelViewMatrix[1][1], modelViewMatrix[2][1], 0);\n\n      vec4 vAt = -vec4(\n        modelViewMatrix[0][2], modelViewMatrix[1][2], modelViewMatrix[2][2], 0);\n\n      mat4 pointToCamera = mat4(vRight, vUp, vAt, vec4(0, 0, 0, 1));\n\n      vec2 scaledPos = posObj * ${ONE_OVER_FONT_SIZE} * ${LABEL_SCALE};\n\n      vec4 posRotated = pointToCamera * vec4(scaledPos, 0, 1);\n      vec4 mvPosition = modelViewMatrix * (vec4(position, 0) + posRotated);\n      gl_Position = projectionMatrix * mvPosition;\n    }`,FRAGMENT_SHADER="\n    uniform sampler2D shaderTexture;\n    uniform bool picking;\n    varying vec2 vUv;\n    varying vec3 vColor;\n\n    void main() {\n      if (picking) {\n        gl_FragColor = vec4(vColor, 1.0);\n      } else {\n        vec4 fromTexture = texture2D(shaderTexture, vUv);\n        gl_FragColor = vec4(vColor, 1.0) * fromTexture;\n      }\n    }";class ScatterPlotVisualizer3DLabels{createGlyphTexture(){let e=document.createElement("canvas");e.width=MAX_CANVAS_DIMENSION,e.height=FONT_SIZE;let t=e.getContext("2d");t.font="bold "+.75*FONT_SIZE+"px roboto",t.textBaseline="top",t.fillStyle=LABEL_BACKGROUND,t.rect(0,0,e.width,e.height),t.fill(),t.fillStyle=LABEL_COLOR;let n=t.measureText(" ").width,r=new Float32Array(NUM_GLYPHS),i=new Float32Array(NUM_GLYPHS),a=0;for(let e=0;e<NUM_GLYPHS;e++){let o=" "+String.fromCharCode(e),s=t.measureText(o).width;r[e]=s-n,i[e]=a,t.fillText(o,a-n,0),a+=s}return{texture:createTexture(e),lengths:r,offsets:i}}processLabelVerts(e){let t=0;this.labelVertexMap=[];for(let n=0;n<e;n++){const e=this.labelStrings[n];let r=[];for(let n=0;n<e.length;n++){for(let e=0;e<VERTICES_PER_GLYPH;e++)r.push(t*VERTICES_PER_GLYPH+e);t++}this.labelVertexMap.push(r)}this.totalVertexCount=t*VERTICES_PER_GLYPH}createColorBuffers(e){this.pickingColors=new Float32Array(this.totalVertexCount*RGB_ELEMENTS_PER_ENTRY),this.renderColors=new Float32Array(this.totalVertexCount*RGB_ELEMENTS_PER_ENTRY);for(let t=0;t<e;t++){let e=new Color$1(t);this.labelVertexMap[t].forEach((t=>{this.pickingColors[RGB_ELEMENTS_PER_ENTRY*t]=e.r,this.pickingColors[RGB_ELEMENTS_PER_ENTRY*t+1]=e.g,this.pickingColors[RGB_ELEMENTS_PER_ENTRY*t+2]=e.b,this.renderColors[RGB_ELEMENTS_PER_ENTRY*t]=1,this.renderColors[RGB_ELEMENTS_PER_ENTRY*t+1]=1,this.renderColors[RGB_ELEMENTS_PER_ENTRY*t+2]=1}))}}createLabels(){if(null==this.labelStrings||null==this.worldSpacePointPositions)return;const e=this.worldSpacePointPositions.length/XYZ_ELEMENTS_PER_ENTRY;if(e!==this.labelStrings.length)return;this.glyphTexture=this.createGlyphTexture(),this.uniforms={shaderTexture:{type:"t"},picking:{type:"bool"}},this.material=new ShaderMaterial({uniforms:this.uniforms,transparent:!0,vertexShader:VERTEX_SHADER,fragmentShader:FRAGMENT_SHADER}),this.processLabelVerts(e),this.createColorBuffers(e);let t=new Float32Array(this.totalVertexCount*XYZ_ELEMENTS_PER_ENTRY);this.positions=new BufferAttribute(t,XYZ_ELEMENTS_PER_ENTRY);let n=new Float32Array(this.totalVertexCount*XYZ_ELEMENTS_PER_ENTRY),r=new Float32Array(this.totalVertexCount*UV_ELEMENTS_PER_ENTRY),i=new Float32Array(this.totalVertexCount*RGB_ELEMENTS_PER_ENTRY),a=new BufferAttribute(n,2),o=new BufferAttribute(r,UV_ELEMENTS_PER_ENTRY),s=new BufferAttribute(i,RGB_ELEMENTS_PER_ENTRY);this.geometry=new BufferGeometry,this.geometry.setAttribute("posObj",a),this.geometry.setAttribute("position",this.positions),this.geometry.setAttribute("uv",o),this.geometry.setAttribute("color",s);let l=0;for(let t=0;t<e;t++){const e=this.labelStrings[t];let n=0;for(let t=0;t<e.length;t++){let r=e.charCodeAt(t);n+=this.glyphTexture.lengths[r]}n/=-2;for(let t=0;t<e.length;t++){let r=e.charCodeAt(t),i=this.glyphTexture.lengths[r],s=(n+i)/FONT_SIZE,c=n/FONT_SIZE,h=FONT_SIZE/FONT_SIZE;a.setXY(l*VERTICES_PER_GLYPH+0,c,0),a.setXY(l*VERTICES_PER_GLYPH+1,s,0),a.setXY(l*VERTICES_PER_GLYPH+2,c,h),a.setXY(l*VERTICES_PER_GLYPH+3,c,h),a.setXY(l*VERTICES_PER_GLYPH+4,s,0),a.setXY(l*VERTICES_PER_GLYPH+5,s,h);let u=this.glyphTexture.offsets[r],d=this.glyphTexture.offsets[r]+i;u/=MAX_CANVAS_DIMENSION,d/=MAX_CANVAS_DIMENSION;let p=1,m=0;o.setXY(l*VERTICES_PER_GLYPH+0,u,p),o.setXY(l*VERTICES_PER_GLYPH+1,d,p),o.setXY(l*VERTICES_PER_GLYPH+2,u,m),o.setXY(l*VERTICES_PER_GLYPH+3,u,m),o.setXY(l*VERTICES_PER_GLYPH+4,d,p),o.setXY(l*VERTICES_PER_GLYPH+5,d,m),l++,n+=i}}for(let t=0;t<e;t++){const e=vector3FromPackedArray(this.worldSpacePointPositions,t);this.labelVertexMap[t].forEach((t=>{this.positions.setXYZ(t,e.x,e.y,e.z)}))}this.labelsMesh=new Mesh(this.geometry,this.material),this.labelsMesh.frustumCulled=!1,this.scene.add(this.labelsMesh)}colorLabels(e){if(null==this.labelStrings||null==this.geometry||null==e)return;const t=new BufferAttribute(this.renderColors,3);this.geometry.setAttribute("color",t);const n=e.length/XYZ_ELEMENTS_PER_ENTRY;let r=0;for(let i=0;i<n;++i){const n=new Color$1(e[r],e[r+1],e[r+2]),a=this.labelVertexMap[i].length;for(let e=0;e<a;++e)t.setXYZ(this.labelVertexMap[i][e],n.r,n.g,n.b);r+=RGB_ELEMENTS_PER_ENTRY}t.needsUpdate=!0}setScene(e){this.scene=e}dispose(){this.labelsMesh&&(this.scene&&this.scene.remove(this.labelsMesh),this.labelsMesh=null),this.geometry&&(this.geometry.dispose(),this.geometry=null),null!=this.glyphTexture&&null!=this.glyphTexture.texture&&(this.glyphTexture.texture.dispose(),this.glyphTexture.texture=null)}onPickingRender(e){if(null==this.geometry&&this.createLabels(),null==this.geometry)return;this.material.uniforms.shaderTexture.value=this.glyphTexture.texture,this.material.uniforms.picking.value=!0;const t=new BufferAttribute(this.pickingColors,3);this.geometry.setAttribute("color",t),t.needsUpdate=!0}onRender(e){if(null==this.geometry&&this.createLabels(),null==this.geometry)return;this.colorLabels(e.pointColors),this.material.uniforms.shaderTexture.value=this.glyphTexture.texture,this.material.uniforms.picking.value=!1;const t=new BufferAttribute(this.renderColors,3);this.geometry.setAttribute("color",t),t.needsUpdate=!0}onPointPositionsChanged(e){this.worldSpacePointPositions=e,this.dispose()}setLabelStrings(e){this.labelStrings=e,this.dispose()}onResize(e,t){}}class CollisionGrid{constructor(e,t,n){this.bound=e,this.cellWidth=t,this.cellHeight=n,this.numHorizCells=Math.ceil(this.boundWidth(e)/t),this.numVertCells=Math.ceil(this.boundHeight(e)/n),this.grid=new Array(this.numHorizCells*this.numVertCells)}boundWidth(e){return e.hiX-e.loX}boundHeight(e){return e.hiY-e.loY}boundsIntersect(e,t){return!(e.loX>t.hiX||e.loY>t.hiY||e.hiX<t.loX||e.hiY<t.loY)}insert(e,t=!1){if(e.hiX<this.bound.loX||e.loX>this.bound.hiX||e.hiY<this.bound.loY||e.loY>this.bound.hiY)return!1;let n=this.getCellX(e.loX),r=this.getCellX(e.hiX),i=this.getCellY(e.loY),a=this.getCellY(e.hiY),o=i*this.numHorizCells+n,s=o;for(let t=i;t<=a;t++){for(let t=n;t<=r;t++){let t=this.grid[s++];if(t)for(let n=0;n<t.length;n++)if(this.boundsIntersect(e,t[n]))return!1}s+=this.numHorizCells-(r-n+1)}if(t)return!0;s=o;for(let t=i;t<=a;t++){for(let t=n;t<=r;t++)this.grid[s]?this.grid[s].push(e):this.grid[s]=[e],s++;s+=this.numHorizCells-(r-n+1)}return!0}getCellX(e){return Math.floor((e-this.bound.loX)/this.cellWidth)}getCellY(e){return Math.floor((e-this.bound.loY)/this.cellHeight)}}const MAX_LABELS_ON_SCREEN=1e4,LABEL_STROKE_WIDTH=3,LABEL_FILL_WIDTH=6;class ScatterPlotVisualizerCanvasLabels{constructor(e){this.labelsActive=!0,this.canvas=document.createElement("canvas"),e.appendChild(this.canvas),this.gc=this.canvas.getContext("2d"),this.canvas.style.position="absolute",this.canvas.style.left="0",this.canvas.style.top="0",this.canvas.style.pointerEvents="none"}removeAllLabels(){const e=this.canvas.width*window.devicePixelRatio,t=this.canvas.height*window.devicePixelRatio;this.gc.clearRect(0,0,e,t)}makeLabels(e){if(null==e.labels||0===e.labels.pointIndices.length)return;if(null==this.worldSpacePointPositions)return;const t=e.labels,n=e.cameraType===CameraType.Perspective,r=parseInt(this.gc.font,10),i=window.devicePixelRatio;let a;{const e=this.canvas.width*i,t=this.canvas.height*i;a=new CollisionGrid({loX:0,hiX:e,loY:0,hiY:t},e/25,t/50)}let o=pow().exponent(Math.E).domain([e.farthestCameraSpacePointZ,e.nearestCameraSpacePointZ]).range([.1,1]);const s=e.camera.position,l=s.clone().sub(e.cameraTarget);let c=new Vector3;this.gc.textBaseline="middle",this.gc.miterLimit=2;const h=Math.min(MAX_LABELS_ON_SCREEN,t.pointIndices.length);for(let u=0;u<h;++u){let h;h=vector3FromPackedArray(this.worldSpacePointPositions,t.pointIndices[u]);if(c.copy(s).sub(h),l.dot(c)<0)continue;let[d,p]=vector3DToScreenCoords(e.camera,e.screenWidth,e.screenHeight,h);d+=4;const m={loX:d-2,hiX:d+1+2,loY:p-r/2-2,hiY:p+r/2+2};if(a.insert(m,!0)){const e=t.labelStrings[u];if(this.gc.font=t.defaultFontSize*t.scaleFactors[u]*i+"px roboto",m.hiX+=this.gc.measureText(e).width-1,a.insert(m)){let r=1;n&&1===t.useSceneOpacityFlags[u]&&(r=o(c.length())),this.gc.fillStyle=this.styleStringFromPackedRgba(t.fillColors,u,r),this.gc.strokeStyle=this.styleStringFromPackedRgba(t.strokeColors,u,r),this.gc.lineWidth=LABEL_STROKE_WIDTH,this.gc.strokeText(e,d,p),this.gc.lineWidth=LABEL_FILL_WIDTH,this.gc.fillText(e,d,p)}}}}styleStringFromPackedRgba(e,t,n){const r=3*t;return"rgba("+e[r]+","+e[r+1]+","+e[r+2]+","+n+")"}onResize(e,t){let n=window.devicePixelRatio;this.canvas.width=e*n,this.canvas.height=t*n,this.canvas.style.width=e+"px",this.canvas.style.height=t+"px"}dispose(){this.removeAllLabels(),this.canvas=null,this.gc=null}onPointPositionsChanged(e){this.worldSpacePointPositions=e,this.removeAllLabels()}onRender(e){this.labelsActive&&(this.removeAllLabels(),this.makeLabels(e))}setScene(e){}onPickingRender(e){}}const RGB_NUM_ELEMENTS$1=3,XYZ_NUM_ELEMENTS$1=3;class ScatterPlotVisualizerPolylines{constructor(){this.polylinePositionBuffer={},this.polylineColorBuffer={}}updateSequenceIndicesInDataSet(e){for(let t=0;t<e.sequences.length;t++){const n=e.sequences[t];for(let r=0;r<n.pointIndices.length-1;r++)e.points[n.pointIndices[r]].sequenceIndex=t,e.points[n.pointIndices[r+1]].sequenceIndex=t}}createPolylines(e){if(this.dataSet&&this.dataSet.sequences){this.updateSequenceIndicesInDataSet(this.dataSet),this.polylines=[];for(let t=0;t<this.dataSet.sequences.length;t++){const n=new BufferGeometry;n.setAttribute("position",this.polylinePositionBuffer[t]),n.setAttribute("color",this.polylineColorBuffer[t]);const r=new LineBasicMaterial({linewidth:1,opacity:1,transparent:!0,vertexColors:!0}),i=new LineSegments(n,r);i.frustumCulled=!1,this.polylines.push(i),e.add(i)}}}dispose(){if(null!=this.polylines){for(let e=0;e<this.polylines.length;e++)this.scene.remove(this.polylines[e]),this.polylines[e].geometry.dispose();this.polylines=null,this.polylinePositionBuffer={},this.polylineColorBuffer={}}}setScene(e){this.scene=e}setDataSet(e){this.dataSet=e}onPointPositionsChanged(e){if(null!=e&&null==this.polylines||this.dispose(),null!=e&&null!=this.dataSet){for(let e=0;e<this.dataSet.sequences.length;e++){const t=2*(this.dataSet.sequences[e].pointIndices.length-1);let n=new Float32Array(t*XYZ_NUM_ELEMENTS$1);this.polylinePositionBuffer[e]=new BufferAttribute(n,XYZ_NUM_ELEMENTS$1);let r=new Float32Array(t*RGB_NUM_ELEMENTS$1);this.polylineColorBuffer[e]=new BufferAttribute(r,RGB_NUM_ELEMENTS$1)}for(let t=0;t<this.dataSet.sequences.length;t++){const n=this.dataSet.sequences[t];let r=0;for(let i=0;i<n.pointIndices.length-1;i++){const a=n.pointIndices[i+1],o=vector3FromPackedArray(e,n.pointIndices[i]),s=vector3FromPackedArray(e,a);this.polylinePositionBuffer[t].setXYZ(r,o.x,o.y,o.z),this.polylinePositionBuffer[t].setXYZ(r+1,s.x,s.y,s.z),r+=2}this.polylinePositionBuffer[t].needsUpdate=!0}null==this.polylines&&this.createPolylines(this.scene)}}onRender(e){if(null!=this.polylines)for(let t=0;t<this.polylines.length;t++){const n=this.polylines[t].material;n.opacity=e.polylineOpacities[t],n.linewidth=e.polylineWidths[t];const r=new BufferAttribute(e.polylineColors[t],3);this.polylineColorBuffer[t]=r,r.needsUpdate=!0,this.polylines[t].geometry.setAttribute("color",r)}}onPickingRender(e){}onResize(e,t){}}const NUM_POINTS_FOG_THRESHOLD=5e3,MIN_POINT_SIZE=5,IMAGE_SIZE=30,RGB_NUM_ELEMENTS=3,INDEX_NUM_ELEMENTS=1,XYZ_NUM_ELEMENTS=3;function createVertexShader(){return`\n  // Index of the specific vertex (passed in as bufferAttribute), and the\n  // variable that will be used to pass it to the fragment shader.\n  attribute float spriteIndex;\n  attribute vec3 color;\n  attribute float scaleFactor;\n\n  varying vec2 xyIndex;\n  varying vec3 vColor;\n\n  uniform bool sizeAttenuation;\n  uniform float pointSize;\n  uniform float spritesPerRow;\n  uniform float spritesPerColumn;\n\n  ${ShaderChunk.fog_pars_vertex}\n\n  void main() {\n    // Pass index and color values to fragment shader.\n    vColor = color;\n    xyIndex = vec2(mod(spriteIndex, spritesPerRow),\n              floor(spriteIndex / spritesPerColumn));\n\n    // Transform current vertex by modelViewMatrix (model world position and\n    // camera world position matrix).\n    vec4 cameraSpacePos = modelViewMatrix * vec4(position, 1.0);\n\n    // Project vertex in camera-space to screen coordinates using the camera's\n    // projection matrix.\n    gl_Position = projectionMatrix * cameraSpacePos;\n\n    // Create size attenuation (if we're in 3D mode) by making the size of\n    // each point inversly proportional to its distance to the camera.\n    float outputPointSize = pointSize;\n    if (sizeAttenuation) {\n      outputPointSize = -pointSize / cameraSpacePos.z;\n    } else {  // Create size attenuation (if we're in 2D mode)\n      const float PI = 3.1415926535897932384626433832795;\n      const float minScale = 0.1;  // minimum scaling factor\n      const float outSpeed = 2.0;  // shrink speed when zooming out\n      const float outNorm = (1. - minScale) / atan(outSpeed);\n      const float maxScale = 15.0;  // maximum scaling factor\n      const float inSpeed = 0.02;  // enlarge speed when zooming in\n      const float zoomOffset = 0.3;  // offset zoom pivot\n      float zoom = projectionMatrix[0][0] + zoomOffset;  // zoom pivot\n      float scale = zoom < 1. ? 1. + outNorm * atan(outSpeed * (zoom - 1.)) :\n                    1. + 2. / PI * (maxScale - 1.) * atan(inSpeed * (zoom - 1.));\n      outputPointSize = pointSize * scale;\n    }\n\n    gl_PointSize =\n      max(outputPointSize * scaleFactor, ${MIN_POINT_SIZE.toFixed(1)});\n  }`}const FRAGMENT_SHADER_POINT_TEST_CHUNK="\n  bool point_in_unit_circle(vec2 spriteCoord) {\n    vec2 centerToP = spriteCoord - vec2(0.5, 0.5);\n    return dot(centerToP, centerToP) < (0.5 * 0.5);\n  }\n\n  bool point_in_unit_equilateral_triangle(vec2 spriteCoord) {\n    vec3 v0 = vec3(0, 1, 0);\n    vec3 v1 = vec3(0.5, 0, 0);\n    vec3 v2 = vec3(1, 1, 0);\n    vec3 p = vec3(spriteCoord, 0);\n    float p_in_v0_v1 = cross(v1 - v0, p - v0).z;\n    float p_in_v1_v2 = cross(v2 - v1, p - v1).z;\n    return (p_in_v0_v1 > 0.0) && (p_in_v1_v2 > 0.0);\n  }\n\n  bool point_in_unit_square(vec2 spriteCoord) {\n    return true;\n  }\n";function createFragmentShader(){return`\n  varying vec2 xyIndex;\n  varying vec3 vColor;\n\n  uniform sampler2D spriteTexture;\n  uniform float spritesPerRow;\n  uniform float spritesPerColumn;\n  uniform bool isImage;\n\n  ${ShaderChunk.common}\n  ${ShaderChunk.fog_pars_fragment}\n  ${FRAGMENT_SHADER_POINT_TEST_CHUNK}\n\n  void main() {\n    if (isImage) {\n      // Coordinates of the vertex within the entire sprite image.\n      vec2 coords =\n        (gl_PointCoord + xyIndex) / vec2(spritesPerRow, spritesPerColumn);\n      if (texture2D(spriteTexture, coords).a==0.0) {\n        discard;\n      }\n      gl_FragColor = vec4(vColor, 1.0) * texture2D(spriteTexture, coords);\n    } else {\n      bool inside = point_in_unit_circle(gl_PointCoord);\n      if (!inside) {\n        discard;\n      }\n      gl_FragColor = vec4(vColor, 1);\n    }\n    ${ShaderChunk.fog_fragment}\n  }`}const FRAGMENT_SHADER_PICKING=`\n  varying vec2 xyIndex;\n  varying vec3 vColor;\n  uniform bool isImage;\n\n  ${FRAGMENT_SHADER_POINT_TEST_CHUNK}\n\n  void main() {\n    xyIndex; // Silence 'unused variable' warning.\n    if (isImage) {\n      gl_FragColor = vec4(vColor, 1);\n    } else {\n      bool inside = point_in_unit_circle(gl_PointCoord);\n      if (!inside) {\n        discard;\n      }\n      gl_FragColor = vec4(vColor, 1);\n    }\n  }`;class ScatterPlotVisualizerSprites{constructor(){this.VERTEX_SHADER=createVertexShader(),this.FRAGMENT_SHADER=createFragmentShader(),this.texture=null,this.standinTextureForPoints=createTexture(document.createElement("canvas")),this.renderMaterial=this.createRenderMaterial(!1),this.pickingMaterial=this.createPickingMaterial(!1)}createTextureFromSpriteAtlas(e,t,n){this.texture=createTexture(e),this.spritesPerRow=e.width/t[0],this.spritesPerColumn=e.height/t[1],this.spriteDimensions=t,this.spriteIndexBufferAttribute=new BufferAttribute(n,INDEX_NUM_ELEMENTS),null!=this.points&&this.points.geometry.setAttribute("spriteIndex",this.spriteIndexBufferAttribute)}createUniforms(){return{spriteTexture:{type:"t"},spritesPerRow:{type:"f"},spritesPerColumn:{type:"f"},fogColor:{type:"c"},fogNear:{type:"f"},fogFar:{type:"f"},isImage:{type:"bool"},sizeAttenuation:{type:"bool"},pointSize:{type:"f"}}}createRenderMaterial(e){const t=this.createUniforms();return new ShaderMaterial({uniforms:t,vertexShader:this.VERTEX_SHADER,fragmentShader:this.FRAGMENT_SHADER,transparent:!e,depthTest:e,depthWrite:e,fog:!0,blending:NormalBlending})}createPickingMaterial(e){const t=this.createUniforms();return new ShaderMaterial({uniforms:t,vertexShader:this.VERTEX_SHADER,fragmentShader:FRAGMENT_SHADER_PICKING,transparent:!0,depthTest:!0,depthWrite:!0,fog:!1,blending:NormalBlending})}createPointSprites(e,t){const n=this.createGeometry(null!=t?t.length/XYZ_NUM_ELEMENTS:0);this.fog=new Fog(16777215),this.points=new Points(n,this.renderMaterial),this.points.frustumCulled=!1,null!=this.spriteIndexBufferAttribute&&this.points.geometry.setAttribute("spriteIndex",this.spriteIndexBufferAttribute),e.add(this.points)}calculatePointSize(e){if(null!=this.texture)return e?IMAGE_SIZE:this.spriteDimensions[0];const t=200/Math.log(null!=this.worldSpacePointPositions?this.worldSpacePointPositions.length/XYZ_NUM_ELEMENTS:1)/Math.log(8);return e?t:t/1.5}createGeometry(e){const t=e;this.pickingColors=new Float32Array(t*RGB_NUM_ELEMENTS);{let e=0;for(let n=0;n<t;n++){const t=new Color$1(n);this.pickingColors[e++]=t.r,this.pickingColors[e++]=t.g,this.pickingColors[e++]=t.b}}const n=new BufferGeometry;return n.setAttribute("position",new BufferAttribute(void 0,XYZ_NUM_ELEMENTS)),n.setAttribute("color",new BufferAttribute(void 0,RGB_NUM_ELEMENTS)),n.setAttribute("scaleFactor",new BufferAttribute(void 0,INDEX_NUM_ELEMENTS)),n}setFogDistances(e,t,n){if(e){const e=this.worldSpacePointPositions.length/XYZ_NUM_ELEMENTS;this.fog.near=t;let r=2-Math.min(e,NUM_POINTS_FOG_THRESHOLD)/NUM_POINTS_FOG_THRESHOLD;this.fog.far=n*r}else this.fog.near=1/0,this.fog.far=1/0}dispose(){this.disposeGeometry(),this.disposeTextureAtlas()}disposeGeometry(){null!=this.points&&(this.scene.remove(this.points),this.points.geometry.dispose(),this.points=null,this.worldSpacePointPositions=null)}disposeTextureAtlas(){null!=this.texture&&this.texture.dispose(),this.texture=null,this.renderMaterial=null,this.pickingMaterial=null}setScene(e){this.scene=e}setSpriteAtlas(e,t,n){this.disposeTextureAtlas(),this.createTextureFromSpriteAtlas(e,t,n),this.renderMaterial=this.createRenderMaterial(!0),this.pickingMaterial=this.createPickingMaterial(!0)}clearSpriteAtlas(){this.disposeTextureAtlas(),this.renderMaterial=this.createRenderMaterial(!1),this.pickingMaterial=this.createPickingMaterial(!1)}onPointPositionsChanged(e){if(null==e||0===e.length)return void this.dispose();null!=this.points&&this.worldSpacePointPositions.length!==e.length&&this.disposeGeometry(),this.worldSpacePointPositions=e,null==this.points&&this.createPointSprites(this.scene,e);const t=new BufferAttribute(e,3);this.points.geometry.setAttribute("position",t),t.needsUpdate=!0}onPickingRender(e){if(null==this.points)return;const t=e.cameraType===CameraType.Perspective;this.pickingMaterial.uniforms.spritesPerRow.value=this.spritesPerRow,this.pickingMaterial.uniforms.spritesPerRow.value=this.spritesPerColumn,this.pickingMaterial.uniforms.sizeAttenuation.value=t,this.pickingMaterial.uniforms.pointSize.value=this.calculatePointSize(t),this.points.material=this.pickingMaterial;const n=new BufferAttribute(this.pickingColors,3);this.points.geometry.setAttribute("color",n),n.needsUpdate=!0;const r=new BufferAttribute(e.pointScaleFactors,1);this.points.geometry.setAttribute("scaleFactor",r),r.needsUpdate=!0}onRender(e){if(!this.points)return;const t=e.camera instanceof PerspectiveCamera;this.setFogDistances(t,e.nearestCameraSpacePointZ,e.farthestCameraSpacePointZ),this.scene.fog=this.fog,this.scene.fog.color=new Color$1(e.backgroundColor),this.renderMaterial.uniforms.fogColor.value=this.scene.fog.color,this.renderMaterial.uniforms.fogNear.value=this.fog.near,this.renderMaterial.uniforms.fogFar.value=this.fog.far,this.renderMaterial.uniforms.spritesPerRow.value=this.spritesPerRow,this.renderMaterial.uniforms.spritesPerColumn.value=this.spritesPerColumn,this.renderMaterial.uniforms.isImage.value=null!=this.texture,this.renderMaterial.uniforms.spriteTexture.value=null!=this.texture?this.texture:this.standinTextureForPoints,this.renderMaterial.uniforms.sizeAttenuation.value=t,this.renderMaterial.uniforms.pointSize.value=this.calculatePointSize(t),this.points.material=this.renderMaterial,this.renderColors=e.pointColors;const n=new BufferAttribute(this.renderColors,3);this.points.geometry.setAttribute("color",n),n.needsUpdate=!0;const r=new BufferAttribute(e.pointScaleFactors,1);this.points.geometry.setAttribute("scaleFactor",r),r.needsUpdate=!0}onResize(e,t){}}const LABEL_FONT_SIZE=10,LABEL_SCALE_DEFAULT=1,LABEL_SCALE_LARGE=2,LABEL_FILL_COLOR_SELECTED=0,LABEL_FILL_COLOR_HOVER=0,LABEL_FILL_COLOR_NEIGHBOR=0,LABEL_STROKE_COLOR_SELECTED=16777215,LABEL_STROKE_COLOR_HOVER=16777215,LABEL_STROKE_COLOR_NEIGHBOR=16777215,POINT_COLOR_UNSELECTED=14935011,POINT_COLOR_NO_SELECTION=7697881,POINT_COLOR_SELECTED=16410214,POINT_COLOR_HOVER=7736143,POINT_SCALE_DEFAULT=1,POINT_SCALE_SELECTED=1.2,POINT_SCALE_NEIGHBOR=1.2,POINT_SCALE_HOVER=1.2,LABELS_3D_COLOR_UNSELECTED=16777215,LABELS_3D_COLOR_NO_SELECTION=16777215,SPRITE_IMAGE_COLOR_UNSELECTED=16777215,SPRITE_IMAGE_COLOR_NO_SELECTION=16777215,POLYLINE_START_HUE=60,POLYLINE_END_HUE=360,POLYLINE_SATURATION=1,POLYLINE_LIGHTNESS=.3,POLYLINE_DEFAULT_OPACITY=.2,POLYLINE_DEFAULT_LINEWIDTH=2,POLYLINE_SELECTED_OPACITY=.9,POLYLINE_SELECTED_LINEWIDTH=3,POLYLINE_DESELECTED_OPACITY=.05,SCATTER_PLOT_CUBE_LENGTH=2,NN_COLOR_SCALE=linear().domain([1,.7,.4]).range(["hsl(285, 80%, 40%)","hsl(0, 80%, 65%)","hsl(40, 70%, 60%)"]).clamp(!0);class ProjectorScatterPlotAdapter{constructor(e,t){this.scatterPlotContainer=e,this.renderLabelsIn3D=!1,this.scatterPlot=new ScatterPlot(e,t),t.registerProjectionChangedListener((e=>{this.projection=e,this.updateScatterPlotWithNewProjection(e)})),t.registerSelectionChangedListener(((e,t)=>{this.selectedPointIndices=e,this.neighborsOfFirstSelectedPoint=t,this.updateScatterPlotPositions(),this.updateScatterPlotAttributes(),this.scatterPlot.render()})),t.registerHoverListener((e=>{this.hoverPointIndex=e,this.updateScatterPlotAttributes(),this.scatterPlot.render()})),t.registerDistanceMetricChangedListener((e=>{this.distanceMetric=e,this.updateScatterPlotAttributes(),this.scatterPlot.render()})),this.createVisualizers(!1)}notifyProjectionPositionsUpdated(){this.updateScatterPlotPositions(),this.scatterPlot.render()}setDataSet(e){if(null!=this.projection&&(this.projection.dataSet=e),null!=this.polylineVisualizer&&this.polylineVisualizer.setDataSet(e),null!=this.labels3DVisualizer&&this.labels3DVisualizer.setLabelStrings(this.generate3DLabelsArray(e,this.labelPointAccessor)),null==this.spriteVisualizer)return;if(this.spriteVisualizer.clearSpriteAtlas(),null==e||null==e.spriteAndMetadataInfo)return;const t=e.spriteAndMetadataInfo;if(null==t.spriteImage||null==t.spriteMetadata)return;const n=e.points.length,r=new Float32Array(n);for(let t=0;t<n;++t)r[t]=e.points[t].index;this.spriteVisualizer.setSpriteAtlas(t.spriteImage,t.spriteMetadata.singleImageDim,r)}set3DLabelMode(e){this.renderLabelsIn3D=e,this.createVisualizers(e),this.updateScatterPlotAttributes(),this.scatterPlot.render()}setLegendPointColorer(e){this.legendPointColorer=e}setLabelPointAccessor(e){if(this.labelPointAccessor=e,null!=this.labels3DVisualizer){this.labels3DVisualizer.setLabelStrings(this.generate3DLabelsArray(null==this.projection?null:this.projection.dataSet,e))}}resize(){this.scatterPlot.resize()}populateBookmarkFromUI(e){e.cameraDef=this.scatterPlot.getCameraDef()}restoreUIFromBookmark(e){this.scatterPlot.setCameraParametersForNextCameraCreation(e.cameraDef,!1)}updateScatterPlotPositions(){const e=this.generatePointPositionArray(null==this.projection?null:this.projection.dataSet,null==this.projection?null:this.projection.projectionComponents);this.scatterPlot.setPointPositions(e)}updateScatterPlotAttributes(){if(null==this.projection)return;const e=this.projection.dataSet,t=this.selectedPointIndices,n=this.hoverPointIndex,r=this.neighborsOfFirstSelectedPoint,i=this.legendPointColorer,a=this.generatePointColorArray(e,i,this.distanceMetric,t,r,n,this.renderLabelsIn3D,this.getSpriteImageMode()),o=this.generatePointScaleFactorArray(e,t,r,n),s=this.generateVisibleLabelRenderParams(e,t,r,n),l=this.generateLineSegmentColorMap(e,i),c=this.generateLineSegmentOpacityArray(e,t),h=this.generateLineSegmentWidthArray(e,t);this.scatterPlot.setPointColors(a),this.scatterPlot.setPointScaleFactors(o),this.scatterPlot.setLabels(s),this.scatterPlot.setPolylineColors(l),this.scatterPlot.setPolylineOpacities(c),this.scatterPlot.setPolylineWidths(h)}render(){this.scatterPlot.render()}generatePointPositionArray(e,t){if(null==e)return null;const n=linear(),r=linear();let i=null;{const a=extent(e.points,((n,r)=>e.points[r].projections[t[0]])),o=extent(e.points,((n,r)=>e.points[r].projections[t[1]])),s=[-SCATTER_PLOT_CUBE_LENGTH/2,SCATTER_PLOT_CUBE_LENGTH/2];if(n.domain(a).range(s),r.domain(o).range(s),null!=t[2]){const n=extent(e.points,((n,r)=>e.points[r].projections[t[2]]));i=linear(),i.domain(n).range(s)}}const a=new Float32Array(3*e.points.length);let o=0;return e.points.forEach(((i,s)=>{a[o++]=n(e.points[s].projections[t[0]]),a[o++]=r(e.points[s].projections[t[1]]),a[o++]=0})),i&&(o=2,e.points.forEach(((n,r)=>{a[o]=i(e.points[r].projections[t[2]]),o+=3}))),a}generateVisibleLabelRenderParams(e,t,n,r){if(null==e)return null;const i=null==t?0:t.length,a=null==n?0:n.length,o=i+a+(null!=r?1:0),s=new Uint32Array(o),l=new Float32Array(o),c=new Int8Array(o),h=new Uint8Array(3*o),u=new Uint8Array(3*o),d=[];l.fill(LABEL_SCALE_DEFAULT),c.fill(1);let p=0;if(null!=r){d.push(this.getLabelText(e,r,this.labelPointAccessor)),s[p]=r,l[p]=LABEL_SCALE_LARGE,c[p]=0;const t=styleRgbFromHexColor(LABEL_FILL_COLOR_HOVER);packRgbIntoUint8Array(h,p,t[0],t[1],t[2]);const n=styleRgbFromHexColor(LABEL_STROKE_COLOR_HOVER);packRgbIntoUint8Array(u,p,n[0],n[1],n[1]),++p}{const n=i,r=styleRgbFromHexColor(LABEL_FILL_COLOR_SELECTED),a=styleRgbFromHexColor(LABEL_STROKE_COLOR_SELECTED);for(let i=0;i<n;++i){const o=t[i];d.push(this.getLabelText(e,o,this.labelPointAccessor)),s[p]=o,l[p]=LABEL_SCALE_LARGE,c[p]=1===n?0:1,packRgbIntoUint8Array(h,p,r[0],r[1],r[2]),packRgbIntoUint8Array(u,p,a[0],a[1],a[2]),++p}}{const t=a,r=styleRgbFromHexColor(LABEL_FILL_COLOR_NEIGHBOR),i=styleRgbFromHexColor(LABEL_STROKE_COLOR_NEIGHBOR);for(let a=0;a<t;++a){const t=n[a].index;d.push(this.getLabelText(e,t,this.labelPointAccessor)),s[p]=t,packRgbIntoUint8Array(h,p,r[0],r[1],r[2]),packRgbIntoUint8Array(u,p,i[0],i[1],i[2]),++p}}return new LabelRenderParams(new Float32Array(s),d,l,c,LABEL_FONT_SIZE,h,u)}generatePointScaleFactorArray(e,t,n,r){if(null==e)return new Float32Array(0);const i=new Float32Array(e.points.length);i.fill(POINT_SCALE_DEFAULT);const a=null==n?0:n.length;{const e=null==t?0:t.length;for(let n=0;n<e;++n){i[t[n]]=POINT_SCALE_SELECTED}}{const e=a;for(let t=0;t<e;++t){i[n[t].index]=POINT_SCALE_NEIGHBOR}}return null!=r&&(i[r]=POINT_SCALE_HOVER),i}generateLineSegmentColorMap(e,t){let n={};if(null==e)return n;for(let r=0;r<e.sequences.length;r++){let i=e.sequences[r],a=new Float32Array(2*(i.pointIndices.length-1)*3),o=0;if(t)for(let n=0;n<i.pointIndices.length-1;n++){const r=new Color$1(t(e,i.pointIndices[n])),s=new Color$1(t(e,i.pointIndices[n+1]));a[o++]=r.r,a[o++]=r.g,a[o++]=r.b,a[o++]=s.r,a[o++]=s.g,a[o++]=s.b}else for(let e=0;e<i.pointIndices.length-1;e++){const t=getDefaultPointInPolylineColor(e,i.pointIndices.length),n=getDefaultPointInPolylineColor(e+1,i.pointIndices.length);a[o++]=t.r,a[o++]=t.g,a[o++]=t.b,a[o++]=n.r,a[o++]=n.g,a[o++]=n.b}n[r]=a}return n}generateLineSegmentOpacityArray(e,t){if(null==e)return new Float32Array(0);const n=new Float32Array(e.sequences.length);if((null==t?0:t.length)>0){n.fill(POLYLINE_DESELECTED_OPACITY);n[e.points[t[0]].sequenceIndex]=POLYLINE_SELECTED_OPACITY}else n.fill(POLYLINE_DEFAULT_OPACITY);return n}generateLineSegmentWidthArray(e,t){if(null==e)return new Float32Array(0);const n=new Float32Array(e.sequences.length);n.fill(POLYLINE_DEFAULT_LINEWIDTH);if((null==t?0:t.length)>0){n[e.points[t[0]].sequenceIndex]=POLYLINE_SELECTED_LINEWIDTH}return n}generatePointColorArray(e,t,n,r,i,a,o,s){if(null==e)return new Float32Array(0);const l=null==r?0:r.length,c=null==i?0:i.length,h=new Float32Array(3*e.points.length);let u=POINT_COLOR_UNSELECTED,d=POINT_COLOR_NO_SELECTION;o&&(u=LABELS_3D_COLOR_UNSELECTED,d=LABELS_3D_COLOR_NO_SELECTION),s&&(u=SPRITE_IMAGE_COLOR_UNSELECTED,d=SPRITE_IMAGE_COLOR_NO_SELECTION);{const n=e.points.length;let r=0;if(l>0){const e=new Color$1(u);for(let t=0;t<n;++t)h[r++]=e.r,h[r++]=e.g,h[r++]=e.b}else if(null!=t)for(let i=0;i<n;++i){const n=new Color$1(t(e,i));h[r++]=n.r,h[r++]=n.g,h[r++]=n.b}else{const e=new Color$1(d);for(let t=0;t<n;++t)h[r++]=e.r,h[r++]=e.g,h[r++]=e.b}}{const e=l,t=new Color$1(POINT_COLOR_SELECTED);for(let n=0;n<e;++n){let e=3*r[n];h[e++]=t.r,h[e++]=t.g,h[e++]=t.b}}{const e=c;let t=e>0?i[0].dist:0;for(let r=0;r<e;++r){const e=new Color$1(dist2color(n,i[r].dist,t));let a=3*i[r].index;h[a++]=e.r,h[a++]=e.g,h[a++]=e.b}}if(null!=a){const e=new Color$1(POINT_COLOR_HOVER);let t=3*a;h[t++]=e.r,h[t++]=e.g,h[t++]=e.b}return h}generate3DLabelsArray(e,t){if(null==e||null==t)return null;let n=[];const r=e.points.length;for(let i=0;i<r;++i)n.push(this.getLabelText(e,i,t));return n}getLabelText(e,t,n){return void 0!==e.points[t].metadata[n]?String(e.points[t].metadata[n]):`Unknown #${t}`}updateScatterPlotWithNewProjection(e){if(null==e)return this.createVisualizers(this.renderLabelsIn3D),void this.scatterPlot.render();this.setDataSet(e.dataSet),this.scatterPlot.setDimensions(e.dimensionality),e.dataSet.projectionCanBeRendered(e.projectionType)&&(this.updateScatterPlotAttributes(),this.notifyProjectionPositionsUpdated()),this.scatterPlot.setCameraParametersForNextCameraCreation(null,!1)}createVisualizers(e){const t=null==this.projection?null:this.projection.dataSet,n=this.scatterPlot;n.removeAllVisualizers(),this.labels3DVisualizer=null,this.canvasLabelsVisualizer=null,this.spriteVisualizer=null,this.polylineVisualizer=null,e?(this.labels3DVisualizer=new ScatterPlotVisualizer3DLabels,this.labels3DVisualizer.setLabelStrings(this.generate3DLabelsArray(t,this.labelPointAccessor))):(this.spriteVisualizer=new ScatterPlotVisualizerSprites,n.addVisualizer(this.spriteVisualizer),this.canvasLabelsVisualizer=new ScatterPlotVisualizerCanvasLabels(this.scatterPlotContainer)),this.polylineVisualizer=new ScatterPlotVisualizerPolylines,this.setDataSet(t),this.spriteVisualizer&&n.addVisualizer(this.spriteVisualizer),this.labels3DVisualizer&&n.addVisualizer(this.labels3DVisualizer),this.canvasLabelsVisualizer&&n.addVisualizer(this.canvasLabelsVisualizer),n.addVisualizer(this.polylineVisualizer)}getSpriteImageMode(){if(null==this.projection)return!1;const e=this.projection.dataSet;return null!=e&&null!=e.spriteAndMetadataInfo&&null!=e.spriteAndMetadataInfo.spriteImage}}function packRgbIntoUint8Array(e,t,n,r,i){e[3*t]=n,e[3*t+1]=r,e[3*t+2]=i}function styleRgbFromHexColor(e){const t=new Color$1(e);return[255*t.r|0,255*t.g|0,255*t.b|0]}function getDefaultPointInPolylineColor(e,t){let n=hsl(POLYLINE_START_HUE+(POLYLINE_END_HUE-POLYLINE_START_HUE)*e/t,POLYLINE_SATURATION,POLYLINE_LIGHTNESS).rgb();return new Color$1(n.r/255,n.g/255,n.b/255)}function normalizeDist(e,t,n){return e===dist?n/t:1-t}function dist2color(e,t,n){return NN_COLOR_SCALE(normalizeDist(e,t,n))}const template$4=html`
  <style include="vz-projector-styles"></style>
  <style>
    #title {
      background-color: #fafafa;
      color: black;
      font-weight: 500;
      left: 0;
      line-height: 60px;
      padding-left: 24px;
      position: absolute;
      width: 276px;
    }
    #bookmark-container {
      background-color: #fafafa;
    }
    #icon-container {
      line-height: 60px;
      position: absolute;
      right: 0;
    }
    #header {
      border-top: 1px solid rgba(0, 0, 0, 0.1);
      position: relative;
    }
    #panel {
      background-color: #fafafa;
      position: relative;
      overflow-y: scroll;
      top: 60px;
      max-height: 50vh;
    }

    #save-container {
      text-align: center;
    }

    .state-radio {
      display: table-cell;
      vertical-align: middle;
      padding-top: 16px;
    }

    .state-label {
      display: table-cell;
      vertical-align: middle;
      top: 14px;
    }

    .state-label-input {
      width: 194px;
    }

    .state-clear {
      display: table-cell;
      vertical-align: middle;
      padding-top: 20px;
    }
    #state-file {
      display: none;
    }
    #no-bookmarks {
      padding: 0 24px;
    }
    #action-buttons-container .add-icon-button {
      background-color: #03a9f4;
      color: white;
      margin: 0 4px 4px auto;
      right: 7px;
      top: -4px;
    }
    .upload-download-icon-button {
      padding: 0;
    }
    #action-buttons-container {
      display: flex;
      margin-left: 34px;
      margin-top: 6px;
    }
    .ink-fab {
      border-radius: 50%;
      background: white;
      box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    }
    paper-textarea {
      --paper-input-container-input: {
        font-size: 12px;
      }
      --paper-font-caption: {
        display: none;
      }
    }
  </style>

  <!-- Bookmarking controls -->
  <div id="bookmark-container">
    <div id="header">
      <div id="title">
        BOOKMARKS ([[savedStates.length]])
        <paper-icon-button icon="help" class="help-icon"></paper-icon-button>
        <paper-tooltip animation-delay="0" position="top" offset="0">
          Open this drawer to save a set of views of the projection, including
          selected points. A file containing the bookmarks can then be saved and
          later loaded to view them.
        </paper-tooltip>
      </div>
      <div id="icon-container">
        <!-- Icons and event handlers are inverted because the tray expands upwards. -->
        <paper-icon-button
          id="expand-more"
          icon="expand-less"
          on-tap="_expandMore"
        ></paper-icon-button>
        <paper-icon-button
          id="expand-less"
          style="display: none"
          icon="expand-more"
          on-tap="_expandLess"
        ></paper-icon-button>
      </div>
    </div>
    <iron-collapse id="panel">
      <!-- Saving state section -->
      <div id="state-section">
        <template is="dom-if" if="[[!savedStates.length]]">
          <p id="no-bookmarks">
            No bookmarks yet, upload a bookmarks file or add a new bookmark by
            clicking the "+" below.
          </p>
        </template>

        <template is="dom-repeat" items="{{savedStates}}">
          <div class="state-row">
            <div class="state-radio">
              <template is="dom-if" if="{{item.isSelected}}">
                <paper-icon-button
                  icon="radio-button-checked"
                ></paper-icon-button>
              </template>
              <template is="dom-if" if="{{!item.isSelected}}">
                <paper-icon-button
                  icon="radio-button-unchecked"
                  data-index$="{{index}}"
                  on-tap="_radioButtonHandler"
                ></paper-icon-button>
              </template>
            </div>
            <div class="state-label">
              <paper-textarea
                value="[[item.label]]"
                class="state-label-input"
                on-keyup="_labelChange"
                data-index$="[[index]]"
                autoresizing
              ></paper-textarea>
            </div>
            <div class="state-clear">
              <paper-icon-button
                icon="clear"
                data-index$="{{index}}"
                on-tap="_clearButtonHandler"
              ></paper-icon-button>
            </div>
          </div>
        </template>

        <div id="action-buttons-container">
          <paper-icon-button
            class="upload-download-icon-button"
            icon="save"
            title="Save bookmarks"
            disabled="[[!hasStates]]"
            on-tap="_downloadFile"
          ></paper-icon-button>
          <paper-icon-button
            class="upload-download-icon-button"
            icon="file-upload"
            title="Load bookmarks"
            on-tap="_uploadFile"
          ></paper-icon-button>
          <paper-icon-button
            class="add-icon-button ink-fab"
            icon="add"
            title="Add bookmark"
            on-tap="_addBookmark"
          ></paper-icon-button>
          <input type="file" id="state-file" name="state-file" />
        </div>
      </div>
    </iron-collapse>
  </div>
`;let BookmarkPanel=class extends(LegacyElementMixin(PolymerElement)){constructor(){super(...arguments),this.hasStates=!1}ready(){super.ready(),this.savedStates=[],this.setupUploadButton(),this.ignoreNextProjectionEvent=!1,this.expandLessButton=this.$$("#expand-less"),this.expandMoreButton=this.$$("#expand-more")}initialize(e,t){this.projector=e,t.registerProjectionChangedListener((()=>{this.ignoreNextProjectionEvent?this.ignoreNextProjectionEvent=!1:this.clearStateSelection()}))}setSelectedTensor(e,t,n){this.addStates(null),t&&t.bookmarksPath?n.getBookmarks(e,t.tensorName,(e=>{this.addStates(e),this._expandMore()})):this._expandLess()}_expandMore(){this.$.panel.show(),this.expandMoreButton.style.display="none",this.expandLessButton.style.display=""}_expandLess(){this.$.panel.hide(),this.expandMoreButton.style.display="",this.expandLessButton.style.display="none"}_addBookmark(){let e=this.projector.getCurrentState();e.label="State "+this.savedStates.length,e.isSelected=!0,this.selectedState=this.savedStates.length;for(let e=0;e<this.savedStates.length;e++)this.savedStates[e].isSelected=!1,this.notifyPath("savedStates."+e+".isSelected",!1);this.push("savedStates",e),this.updateHasStates()}_downloadFile(){let e=this.serializeAllSavedStates(),t=new Blob([e],{type:"text/plain"}),n=window.URL.createObjectURL(t),r=document.createElement("a");document.body.appendChild(r),r.style.display="none",Object.assign(r,{href:n}),r.download="state",r.click(),document.body.removeChild(r),window.URL.revokeObjectURL(n)}_uploadFile(){this.$$("#state-file").click()}setupUploadButton(){const e=this.$$("#state-file");e.onchange=()=>{const t=e.files[0];e.value="";const n=new FileReader;n.onload=e=>{const t=JSON.parse(n.result);this.savedStatesValid(t)?(this.addStates(t),this.loadSavedState(0)):setWarningMessage(`Unable to load bookmarks: wrong dataset, expected dataset with shape (${t[0].dataSetDimensions}).`)},n.readAsText(t)}}addStates(e){if(null==e)this.savedStates=[];else for(let t=0;t<e.length;t++)e[t].isSelected=!1,this.push("savedStates",e[t]);this.updateHasStates()}clearStateSelection(){for(let e=0;e<this.savedStates.length;e++)this.setSelectionState(e,!1)}_radioButtonHandler(e){const t=this.getParentDataIndex(e);this.loadSavedState(t),this.setSelectionState(t,!0)}loadSavedState(e){for(let t=0;t<this.savedStates.length;t++)this.savedStates[t].isSelected?this.setSelectionState(t,!1):e===t&&(this.setSelectionState(t,!0),this.ignoreNextProjectionEvent=!0,this.projector.loadState(this.savedStates[t]))}setSelectionState(e,t){this.savedStates[e].isSelected=t;this.notifyPath("savedStates."+e+".isSelected",t)}getParentDataIndex(e){for(let t=0;t<e.path.length;t++){let n=e.path[t];if(n instanceof HTMLElement){let e=n.getAttribute("data-index");if(null!=e)return+e}}return-1}_clearButtonHandler(e){let t=this.getParentDataIndex(e);this.splice("savedStates",t,1),this.updateHasStates()}_labelChange(e){let t=this.getParentDataIndex(e);this.savedStates[t].label=e.target.value}_isSelectedState(e){return e===this.selectedState}_isNotSelectedState(e){return e!==this.selectedState}serializeAllSavedStates(){return JSON.stringify(this.savedStates)}loadSavedStates(e){this.savedStates=JSON.parse(e),this.updateHasStates()}updateHasStates(){this.hasStates=0!==this.savedStates.length}savedStatesValid(e){for(let t=0;t<e.length;t++)if(e[t].dataSetDimensions[0]!==this.projector.dataSet.dim[0]||e[t].dataSetDimensions[1]!==this.projector.dataSet.dim[1])return!1;return!0}};BookmarkPanel.template=template$4,__decorate([property({type:Object}),__metadata("design:type",Array)],BookmarkPanel.prototype,"savedStates",void 0),__decorate([property({type:Boolean}),__metadata("design:type",Boolean)],BookmarkPanel.prototype,"hasStates",void 0),__decorate([property({type:Number}),__metadata("design:type",Number)],BookmarkPanel.prototype,"selectedState",void 0),BookmarkPanel=__decorate([customElement("vz-projector-bookmark-panel")],BookmarkPanel);let TfWbrString=class extends PolymerElement{get _parts(){var e=this.value,t=this.delimiterPattern;const n=[];for(;;){const r=new RegExp(t,"g");if(r.test(e),0===r.lastIndex){n.push(e);break}n.push(e.slice(0,r.lastIndex)),e=e.slice(r.lastIndex)}return n}};TfWbrString.template=html`
    <!--
      This ugly formatting is required to prevent spaces from slipping
      into the HTML.
    -->
    <template is="dom-repeat" items="[[_parts]]" as="part"
      >[[part]]<wbr
    /></template>
  `,__decorate([property({type:String}),__metadata("design:type",String)],TfWbrString.prototype,"value",void 0),__decorate([property({type:String}),__metadata("design:type",String)],TfWbrString.prototype,"delimiterPattern",void 0),__decorate([computed("value","delimiterPattern"),__metadata("design:type",Array),__metadata("design:paramtypes",[])],TfWbrString.prototype,"_parts",null),TfWbrString=__decorate([customElement("tf-wbr-string")],TfWbrString);const template$3=html`
  <style include="vz-projector-styles"></style>
  <style>
    .container {
      padding: 5px 20px 20px 20px;
    }

    input[type='file'] {
      display: none;
    }

    .file-name {
      margin-right: 10px;
    }

    .dirs {
      color: rgba(0, 0, 0, 0.7);
      font-size: 12px;
    }

    .dirs table tr {
      vertical-align: top;
    }

    .dirs table tr td {
      padding-bottom: 10px;
    }

    paper-item {
      --paper-item-disabled: {
        border-bottom: 1px solid black;
        justify-content: center;
        font-size: 12px;
        line-height: normal;
        min-height: 0px;
      }
    }

    .item-details {
      margin-left: 5px;
      color: gray;
      font-size: 12px;
    }

    paper-input {
      font-size: 15px;
      --paper-input-container: {
        padding: 5px 0;
      }
      --paper-input-container-label-floating: {
        white-space: normal;
        line-height: normal;
      }
    }

    paper-dropdown-menu {
      width: 100%;
      --paper-input-container: {
        padding: 5px 0;
      }
      --paper-input-container-input: {
        font-size: 15px;
      }
      --paper-input-container-label-floating: {
        white-space: normal;
        line-height: normal;
      }
    }

    paper-dropdown-menu paper-item {
      justify-content: space-between;
    }

    .title {
      align-items: center;
      border-bottom: 1px solid rgba(0, 0, 0, 0.1);
      color: black;
      display: flex;
      font-weight: 500;
      height: 59px;
      padding-left: 20px;
    }

    #normalize-data-checkbox {
      margin: 10px 0;
    }

    #projector-config-template {
      --paper-input-container-input: {
        line-height: 13px;
        font-family: monospace;
        font-size: 12px;
      }
    }

    #generate-share-url {
      padding: 16px;
      margin-left: 24px;
    }

    #projector-share-button-container {
      margin: 10px 0;
    }

    .metadata-editor,
    .supervise-settings,
    .colorlabel-container {
      display: flex;
    }

    #labelby {
      width: 100px;
      margin-right: 10px;
    }

    #colorby {
      width: calc(100% - 110px);
    }

    [hidden] {
      display: none;
    }

    .supervise-settings paper-dropdown-menu {
      width: 100px;
      margin-right: 10px;
    }

    .supervise-settings paper-input {
      width: calc(100% - 110px);
    }

    .metadata-editor paper-dropdown-menu {
      width: 100px;
      margin-right: 10px;
    }

    .metadata-editor paper-input {
      width: calc(100% - 110px);
    }

    .config-checkbox {
      display: inline-block;
      font-size: 11px;
      margin-left: 10px;
    }

    .projector-config-options {
      margin-top: 12px;
    }

    .projector-config-dialog-container {
      padding: 24px;
    }

    .code {
      background-color: #f7f7f7;
      display: table;
      font-family: monospace;
      margin-top: 7px;
      padding: 15px;
    }

    .delimiter {
      color: #b71c1c;
    }

    .button-container {
      flex: 1 100%;
      margin-right: 5px;
    }

    .button-container paper-button {
      min-width: 50px;
      width: 100%;
    }

    #label-button {
      margin-right: 0px;
    }

    .upload-step {
      display: flex;
      justify-content: space-between;
      margin-bottom: 6px;
    }

    .upload-step paper-button {
      margin-left: 30px;
    }

    .step-label {
      color: rgb(38, 180, 226);
    }

    .scrollable-container {
      margin-top: 0;
      min-width: 400px;
    }

    #projectorConfigDialog p {
      margin: 8px 0 8px;
    }

    .data-step {
      margin-top: 40px;
    }

    .data-step-contents {
      display: table;
      width: 100%;
    }

    .data-step-contents-contents {
      display: table-cell;
      margin-top: 6px;
    }

    .data-step-contents-upload {
      display: table-cell;
      text-align: right;
      vertical-align: bottom;
    }

    #demo-data-buttons-container {
      display: none;
      margin-top: 10px;
    }
  </style>
  <div class="title">DATA</div>
  <div class="container">
    <!-- List of runs -->
    <template is="dom-if" if="[[_hasChoices(runNames)]]">
      <paper-dropdown-menu
        no-animations
        label="[[_getNumRunsLabel(runNames)]] found"
      >
        <paper-listbox
          attr-for-selected="value"
          class="dropdown-content"
          selected="{{selectedRun}}"
          slot="dropdown-content"
        >
          <template is="dom-repeat" items="[[runNames]]">
            <paper-item value="[[item]]" label="[[item]]">
              [[item]]
            </paper-item>
          </template>
        </paper-listbox>
      </paper-dropdown-menu>
    </template>

    <template is="dom-if" if="[[tensorNames]]">
      <!-- List of tensors in checkpoint -->
      <paper-dropdown-menu
        no-animations
        label="[[_getNumTensorsLabel(tensorNames)]] found"
      >
        <paper-listbox
          attr-for-selected="value"
          class="dropdown-content"
          selected="{{selectedTensor}}"
          slot="dropdown-content"
        >
          <template is="dom-repeat" items="[[tensorNames]]">
            <paper-item value="[[item.name]]" label="[[item.name]]">
              [[item.name]]
              <span class="item-details">
                [[item.shape.0]]x[[item.shape.1]]
              </span>
            </paper-item>
          </template>
        </paper-listbox>
      </paper-dropdown-menu>
    </template>

    <div hidden$="[[!_hasChoices(colorOptions)]]">
      <div class="colorlabel-container">
        <!-- Label by -->
        <paper-dropdown-menu id="labelby" no-animations label="Label by">
          <paper-listbox
            attr-for-selected="value"
            class="dropdown-content"
            selected="{{selectedLabelOption}}"
            slot="dropdown-content"
          >
            <template is="dom-repeat" items="[[labelOptions]]">
              <paper-item value="[[item]]" label="[[item]]">
                [[item]]
              </paper-item>
            </template>
          </paper-listbox>
        </paper-dropdown-menu>
        <!-- Color by -->
        <paper-dropdown-menu id="colorby" no-animations label="Color by">
          <paper-listbox
            attr-for-selected="value"
            class="dropdown-content"
            selected="{{selectedColorOptionName}}"
            slot="dropdown-content"
          >
            <template is="dom-repeat" items="[[colorOptions]]">
              <paper-item
                class$="[[getSeparatorClass(item.isSeparator)]]"
                value="[[item.name]]"
                label="[[item.name]]"
                disabled="[[item.isSeparator]]"
              >
                [[item.name]]
                <span class="item-details">[[item.desc]]</span>
              </paper-item>
            </template>
          </paper-listbox>
        </paper-dropdown-menu>
      </div>
      <div hidden$="[[!showForceCategoricalColorsCheckbox]]">
        <paper-checkbox id="force-categorical-checkbox"
          >Use categorical coloring</paper-checkbox
        >
        <paper-icon-button icon="help" class="help-icon"></paper-icon-button>
        <paper-tooltip
          position="bottom"
          animation-delay="0"
          fit-to-visible-bounds
        >
          For metadata fields that have many unique values we use a gradient
          color map by default. This checkbox allows you to force categorical
          coloring by a given metadata field.
        </paper-tooltip>
      </div>
      <template dom-if="[[colorLegendRenderInfo]]">
        <vz-projector-legend
          render-info="[[colorLegendRenderInfo]]"
        ></vz-projector-legend>
      </template>
    </div>
    <template is="dom-if" if="[[_hasChoice(labelOptions)]]">
      <!-- Supervise by -->
      <div hidden$="[[!showSuperviseSettings]]" class="supervise-settings">
        <paper-dropdown-menu no-animations label="Supervise with">
          <paper-listbox
            attr-for-selected="value"
            class="dropdown-content"
            on-selected-item-changed="superviseColumnChanged"
            selected="{{superviseColumn}}"
            slot="dropdown-content"
          >
            <template is="dom-repeat" items="[[metadataFields]]">
              <paper-item value="[[item]]" label="[[item]]">
                [[item]]
              </paper-item>
            </template>
          </paper-listbox>
        </paper-dropdown-menu>
        <paper-input
          value="{{superviseInput}}"
          label="{{superviseInputLabel}}"
          on-change="superviseInputChange"
          on-input="superviseInputTyping"
        >
        </paper-input>
      </div>
      <!-- Edit by -->
      <div class="metadata-editor">
        <paper-dropdown-menu no-animations label="Edit by">
          <paper-listbox
            attr-for-selected="value"
            class="dropdown-content"
            slot="dropdown-content"
            on-selected-item-changed="metadataEditorColumnChange"
            selected="{{metadataEditorColumn}}"
          >
            <template is="dom-repeat" items="[[metadataFields]]">
              <paper-item value="[[item]]" label="[[item]]">
                [[item]]
              </paper-item>
            </template>
          </paper-listbox>
        </paper-dropdown-menu>
        <paper-input
          value="{{metadataEditorInput}}"
          label="{{metadataEditorInputLabel}}"
          on-input="metadataEditorInputChange"
          on-keydown="metadataEditorInputKeydown"
        >
        </paper-input>
      </div>
    </template>
    <div id="demo-data-buttons-container">
      <span class="button-container">
        <paper-tooltip
          position="bottom"
          animation-delay="0"
          fit-to-visible-bounds
        >
          Load data from your computer
        </paper-tooltip>
        <paper-button id="upload" class="ink-button" on-tap="_openDataDialog"
          >Load</paper-button
        >
      </span>
      <span id="publish-container" class="button-container">
        <paper-tooltip
          position="bottom"
          animation-delay="0"
          fit-to-visible-bounds
        >
          Publish your embedding visualization and data
        </paper-tooltip>
        <paper-button
          id="host-embedding"
          class="ink-button"
          on-tap="_openConfigDialog"
          >Publish</paper-button
        >
      </span>
      <span class="button-container">
        <paper-tooltip
          position="bottom"
          animation-delay="0"
          fit-to-visible-bounds
        >
          Download the metadata with applied modifications
        </paper-tooltip>
        <paper-button class="ink-button" on-click="downloadMetadataClicked"
          >Download</paper-button
        >
        <a href="#" id="downloadMetadataLink" hidden></a>
      </span>
      <span id="label-button" class="button-container">
        <paper-tooltip
          position="bottom"
          animation-delay="0"
          fit-to-visible-bounds
        >
          Label selected metadata
        </paper-tooltip>
        <paper-button
          class="ink-button"
          on-click="metadataEditorButtonClicked"
          disabled="[[metadataEditorButtonDisabled]]"
          >Label</paper-button
        >
      </span>
    </div>
    <div>
      <paper-dialog id="dataDialog" with-backdrop>
        <h2>Load data from your computer</h2>
        <paper-dialog-scrollable class="scrollable-container">
          <div class="data-step" id="upload-tensors-step-container">
            <div class="upload-step">
              <div>
                <b
                  ><span class="step-label">Step 1:</span> Load a TSV file of
                  vectors.</b
                >
              </div>
            </div>
            <div class="data-step-contents">
              <div class="data-step-contents-contents">
                Example of 3 vectors with dimension 4:
                <div class="code">
                  0.1<span class="delimiter"> </span>0.2<span class="delimiter">
                  </span
                  >0.5<span class="delimiter"> </span>0.9<br />
                  0.2<span class="delimiter"> </span>0.1<span class="delimiter">
                  </span
                  >5.0<span class="delimiter"> </span>0.2<br />
                  0.4<span class="delimiter"> </span>0.1<span class="delimiter">
                  </span
                  >7.0<span class="delimiter"> </span>0.8
                </div>
              </div>
              <div class="data-step-contents-upload">
                <paper-button
                  id="upload-tensors"
                  title="Choose a TSV tensor file"
                  >Choose file</paper-button
                >
                <input type="file" id="file" name="file" />
              </div>
            </div>
          </div>
          <div class="data-step">
            <div class="upload-step">
              <div>
                <span class="step-label" id="upload-metadata-label"
                  ><b>Step 2</b> (optional):</span
                >
                <b>Load a TSV file of metadata.</b>
              </div>
            </div>
            <div class="data-step-contents">
              <div class="data-step-contents-contents">
                Example of 3 data points and 2 columns.<br />
                <i
                  >Note: If there is more than one column, the first row will be
                  parsed as column labels.</i
                >
                <div class="code">
                  <b>Pokémon<span class="delimiter"> </span>Species</b><br />
                  Wartortle<span class="delimiter"> </span>Turtle<br />
                  Venusaur<span class="delimiter"> </span>Seed<br />
                  Charmeleon<span class="delimiter"> </span>Flame
                </div>
              </div>
              <div class="data-step-contents-upload">
                <paper-button
                  id="upload-metadata"
                  title="Choose a TSV metadata file"
                  class="ink-button"
                  >Choose file</paper-button
                >
                <input type="file" id="file-metadata" name="file-metadata" />
              </div>
            </div>
          </div>
        </paper-dialog-scrollable>
        <div class="dismiss-dialog-note">Click outside to dismiss.</div>
      </paper-dialog>
      <paper-dialog id="projectorConfigDialog" with-backdrop>
        <h2>Publish your embedding visualization and data</h2>
        <paper-dialog-scrollable class="scrollable-container">
          <div>
            <p>
              If you'd like to share your visualization with the world, follow
              these simple steps. See
              <a
                target="_blank"
                rel="noopener noreferrer"
                href="https://www.tensorflow.org/get_started/embedding_viz"
                >this tutorial</a
              >
              for more.
            </p>
            <h4><span class="step-label">Step 1:</span> Make data public</h4>
            <p>
              Host tensors, metadata, sprite image, and bookmarks TSV files
              <i>publicly</i> on the web.
            </p>
            <p>
              One option is using a
              <a
                target="_blank"
                href="https://gist.github.com/"
                rel="noopener noreferrer"
                >github gist</a
              >. If you choose this approach, make sure to link directly to the
              raw file.
            </p>
          </div>
          <div>
            <h4><span class="step-label">Step 2:</span> Projector config</h4>
            <div class="projector-config-options">
              <i>Optional:</i>
              <div class="config-checkbox">
                <paper-checkbox id="config-metadata-checkbox" checked
                  >Metadata</paper-checkbox
                >
              </div>
              <div class="config-checkbox">
                <paper-checkbox id="config-sprite-checkbox"
                  >Sprite</paper-checkbox
                >
              </div>
              <div class="config-checkbox">
                <paper-checkbox id="config-bookmarks-checkbox"
                  >Bookmarks</paper-checkbox
                >
              </div>
            </div>
          </div>
          <paper-textarea
            id="projector-config-template"
            label="template_projector_config.json"
          ></paper-textarea>
          <div>
            <h4>
              <span class="step-label">Step 3:</span> Host projector config
            </h4>
            After you have hosted the projector config JSON file you built
            above, paste the URL to the config below.
          </div>
          <paper-input
            id="projector-config-url"
            label="Path to projector config"
          ></paper-input>
          <paper-input
            id="projector-share-url"
            label="Your shareable URL"
            readonly
          ></paper-input>
          <div id="projector-share-button-container">
            <a
              target="_blank"
              id="projector-share-url-link"
              rel="noopener noreferrer"
            >
              <paper-button title="Test your shareable URL" class="ink-button"
                >Test your shareable URL</paper-button
              >
            </a>
          </div>
        </paper-dialog-scrollable>
        <div class="dismiss-dialog-note">Click outside to dismiss.</div>
      </paper-dialog>
    </div>
    <paper-checkbox id="normalize-data-checkbox" checked="{{normalizeData}}">
      Sphereize data
      <paper-icon-button icon="help" class="help-icon"></paper-icon-button>
      <paper-tooltip
        position="bottom"
        animation-delay="0"
        fit-to-visible-bounds
      >
        The data is normalized by shifting each point by the centroid and making
        it unit norm.
      </paper-tooltip>
    </paper-checkbox>
    <div class="dirs">
      <table>
        <tr>
          <td>Checkpoint:</td>
          <td>
            <span id="checkpoint-file">
              <tf-wbr-string
                title="[[projectorConfig.modelCheckpointPath]]"
                delimiter-pattern="[[_wordDelimiter]]"
                value="[[projectorConfig.modelCheckpointPath]]"
              ></tf-wbr-string>
            </span>
          </td>
        </tr>
        <tr>
          <td>Metadata:</td>
          <td>
            <span id="metadata-file">
              <tf-wbr-string
                title="[[metadataFile]]"
                delimiter-pattern="[[_wordDelimiter]]"
                value="[[metadataFile]]"
              ></tf-wbr-string>
            </span>
          </td>
        </tr>
      </table>
    </div>
  </div>
`;let Legend=class extends(LegacyElementMixin(PolymerElement)){_renderInfoChanged(){null!=this.renderInfo&&this.renderInfo.thresholds&&this.async((()=>this.setupLinearGradient()))}_getLastThreshold(){if(null!=this.renderInfo&&null!=this.renderInfo.thresholds)return this.renderInfo.thresholds[this.renderInfo.thresholds.length-1].value}getOffset(e){const t=this.renderInfo.thresholds[0].value;return(100*(e-t)/(this.renderInfo.thresholds[this.renderInfo.thresholds.length-1].value-t)).toFixed(2)+"%"}setupLinearGradient(){const e=this.$$("#gradient"),t=this.$$("svg.gradient").clientWidth;this.$$("svg.gradient rect").style.width=t+"px",e.textContent="",this.renderInfo.thresholds.forEach((e=>{const t=document.createElementNS("http://www.w3.org/2000/svg","stop");t.setAttribute("offset",this.getOffset(e.value)),t.setAttribute("stop-color",e.color)}))}};Legend.template=html`
    <style include="vz-projector-styles"></style>
    <style>
      .item {
        display: flex;
        align-items: flex-start;
        margin-bottom: 10px;
      }

      .shape {
        width: 10px;
        height: 10px;
        margin-right: 10px;
        margin-top: 5px;
        border-radius: 50%;
      }

      .label {
        flex-grow: 1;
      }

      .gradient {
        width: 100%;
        height: 10px;
      }

      .gradient-boundaries {
        display: flex;
        justify-content: space-between;
      }
    </style>

    <template is="dom-repeat" items="[[renderInfo.items]]">
      <div class="item">
        <div class="shape" style="background-color: [[item.color]];"></div>
        <div class="label">[[item.label]]</div>
        <div class="info" style="color: [[item.color]];">[[item.count]]</div>
      </div>
    </template>

    <template is="dom-if" if="[[renderInfo.thresholds]]">
      <svg class="gradient">
        <defs>
          <linearGradient
            id="gradient"
            x1="0%"
            y1="100%"
            x2="100%"
            y2="100%"
          ></linearGradient>
        </defs>
        <rect height="10" style="fill: url('#gradient');"></rect>
      </svg>
      <div class="gradient-boundaries">
        <div>[[renderInfo.thresholds.0.value]]</div>
        <div>[[_getLastThreshold(renderInfo.thresholds)]]</div>
      </div>
    </template>
  `,__decorate([property({type:Object}),__metadata("design:type",Object)],Legend.prototype,"renderInfo",void 0),__decorate([observe("renderInfo"),__metadata("design:type",Function),__metadata("design:paramtypes",[]),__metadata("design:returntype",void 0)],Legend.prototype,"_renderInfoChanged",null),Legend=__decorate([customElement("vz-projector-legend")],Legend);let DataPanel=class extends(LegacyElementMixin(PolymerElement)){constructor(){super(...arguments),this.metadataEditorInputLabel="Tag selection as",this.superviseInputLabel="Ignored label",this.showSuperviseSettings=!1,this._wordDelimiter="[/=_,-]",this.forceCategoricalColoring=!1}ready(){super.ready(),this.normalizeData=!0,this.superviseInputSelected=""}initialize(e,t){this.projector=e,this.dataProvider=t,this.setupUploadButtons(),this.$$("#normalize-data-checkbox").addEventListener("change",(()=>{this.projector.setNormalizeData(this.normalizeData)}));let n=this.$$("#force-categorical-checkbox");n.addEventListener("change",(()=>{this.setForceCategoricalColoring(n.checked)})),this.dataProvider.retrieveRuns((e=>{this.runNames=e,this.runNames.length>0&&(this.selectedRun!=e[0]?this.selectedRun=e[0]:this._generateUiForNewCheckpointForRun(this.selectedRun))}))}setForceCategoricalColoring(e){this.forceCategoricalColoring=e,this.$$("#force-categorical-checkbox").checked=this.forceCategoricalColoring,this.updateMetadataUI(this.spriteAndMetadata.stats,this.metadataFile),this._selectedColorOptionNameChanged()}getSeparatorClass(e){return e?"separator":null}metadataChanged(e,t){this.spriteAndMetadata=e,null!=t&&(this.metadataFile=t),this.updateMetadataUI(this.spriteAndMetadata.stats,this.metadataFile),null!=this.selectedColorOptionName&&0!==this.colorOptions.filter((e=>e.name===this.selectedColorOptionName)).length||(this.selectedColorOptionName=this.colorOptions[0].name);let n=-1;this.metadataFields=e.stats.map(((e,t)=>(e.isNumeric||-1!==n||(n=t),e.name))),null!=this.metadataEditorColumn&&0!==this.metadataFields.filter((e=>e===this.metadataEditorColumn)).length||(this.metadataEditorColumn=this.metadataFields[Math.max(0,n)]),null!=this.superviseColumn&&0!==this.metadataFields.filter((e=>e===this.superviseColumn)).length||(this.superviseColumn=this.metadataFields[Math.max(0,n)],this.superviseInput=""),this.superviseInputChange()}projectionChanged(e){if(e)switch(e.projectionType){case"tsne":this.set("showSuperviseSettings",!0);break;default:this.set("showSuperviseSettings",!1)}}onProjectorSelectionChanged(e,t){this.selectedPointIndices=e,this.neighborsOfFirstPoint=t,this.metadataEditorInputChange()}updateMetadataUI(e,t){let n=-1;this.labelOptions=e.map(((e,t)=>(e.isNumeric||-1!==n||(n=t),e.name))),null!=this.selectedLabelOption&&0!==this.labelOptions.filter((e=>e===this.selectedLabelOption)).length||(this.selectedLabelOption=this.labelOptions[Math.max(0,n)]),null!=this.metadataEditorColumn&&0!==this.labelOptions.filter((e=>e===this.metadataEditorColumn)).length||(this.metadataEditorColumn=this.labelOptions[Math.max(0,n)]);const r=[{name:"No color map"}],i=e.filter((e=>!e.tooManyUniqueValues||e.isNumeric)).map((e=>{let t,n,r,i;if(this.forceCategoricalColoring||!e.tooManyUniqueValues){const r=ordinal(category10);let a=r.range(),o=a.map(((e,t)=>a[3*t%a.length]));n=e.uniqueEntries,r.range(o).domain(n.map((e=>e.label))),t=r;const s=e.uniqueEntries.length;i=`${s} ${s>a.length?" non-unique":""} colors`}else r=[{color:"#ffffdd",value:e.min},{color:"#1f2d86",value:e.max}],t=linear().domain(r.map((e=>e.value))).range(r.map((e=>e.color))),i="gradient";return{name:e.name,desc:i,map:t,items:n,thresholds:r,tooManyUniqueValues:e.tooManyUniqueValues}}));i.length>0&&r.push({name:"Metadata",isSeparator:!0}),this.colorOptions=r.concat(i)}metadataEditorContext(e){this.metadataEditorButtonDisabled=!e,this.projector&&this.projector.metadataEditorContext(e,this.metadataEditorColumn)}metadataEditorInputChange(){let e=this.metadataEditorColumn,t=this.metadataEditorInput,n=this.selectedPointIndices.length+this.neighborsOfFirstPoint.length;if(n>0)if(null!=t&&""!==t.trim())if(this.spriteAndMetadata.stats.filter((t=>t.name===e))[0].isNumeric&&isNaN(+t))this.metadataEditorInputLabel="Label must be numeric",this.metadataEditorContext(!1);else{let r=this.projector.dataSet.points.filter((n=>n.metadata[e].toString()===t.trim())).length;this.metadataEditorInputLabel=0===r?`Tag ${n} with new label`:`Tag ${n} points as`,this.metadataEditorContext(!0)}else this.metadataEditorInputLabel="Tag selection as",this.metadataEditorContext(!1);else this.metadataEditorContext(!1),this.metadataEditorInputLabel=null!=t&&""!==t.trim()?"Select points to tag":"Tag selection as"}metadataEditorInputKeydown(e){13===e.keyCode&&this.metadataEditorButtonClicked(),e.stopPropagation()}metadataEditorColumnChange(){this.metadataEditorInputChange()}metadataEditorButtonClicked(){if(!this.metadataEditorButtonDisabled){let e=this.metadataEditorInput.trim(),t=this.selectedPointIndices.length+this.neighborsOfFirstPoint.length;this.projector.metadataEdit(this.metadataEditorColumn,e),this.projector.metadataEditorContext(!0,this.metadataEditorColumn),this.metadataEditorInputLabel=`${t} labeled as '${e}'`}}downloadMetadataClicked(){if(this.projector&&this.projector.dataSet&&this.projector.dataSet.spriteAndMetadataInfo){let e=this.projector.dataSet.spriteAndMetadataInfo.stats.map((e=>e.name)).join("\t");this.projector.dataSet.spriteAndMetadataInfo.pointsInfo.forEach((t=>{let n=[];for(const e in t)n.push(t[e]);e+="\n"+n.join("\t")}));const t=new Blob([e],{type:"text/plain"}),n=this.$.downloadMetadataLink;n.download="metadata-edited.tsv",Object.assign(n,{href:window.URL.createObjectURL(t)}),n.click()}}superviseInputTyping(){let e=this.superviseInput.trim();if(null!=e&&""!==e.trim()){if(this.projector&&this.projector.dataSet){let t=this.projector.dataSet.points.filter((t=>t.metadata[this.superviseColumn].toString().trim()===e)).length;0===t?this.superviseInputLabel="Label not found":this.projector.dataSet.superviseInput!=e&&(this.superviseInputLabel=`Supervise without '${e}' [${t} points]`)}}else this.superviseInputLabel=""===this.superviseInputSelected?"No ignored label":`Supervising without '${this.superviseInputSelected}'`}superviseInputChange(){let e=this.superviseInput.trim();if(null==e||""===e.trim())return this.superviseInputSelected="",this.superviseInputLabel="No ignored label",void this.setSupervision(this.superviseColumn,"");if(this.projector&&this.projector.dataSet){let t=this.projector.dataSet.points.filter((t=>t.metadata[this.superviseColumn].toString().trim()===e)).length;0===t?this.superviseInputLabel=`Supervising without '${this.superviseInputSelected}'`:(this.superviseInputSelected=e,this.superviseInputLabel=`Supervising without '${e}' [${t} points]`,this.setSupervision(this.superviseColumn,e))}}superviseColumnChanged(){this.superviseInput="",this.superviseInputChange()}setSupervision(e,t){this.projector&&this.projector.dataSet&&this.projector.dataSet.setSupervision(e,t)}setNormalizeData(e){this.normalizeData=e}_selectedTensorChanged(){this.projector.updateDataSet(null,null,null),null!=this.selectedTensor&&(this.dataProvider.retrieveTensor(this.selectedRun,this.selectedTensor,(e=>{let t=this.getEmbeddingInfoByName(this.selectedTensor).metadataPath;this.dataProvider.retrieveSpriteAndMetadata(this.selectedRun,this.selectedTensor,(n=>{this.projector.updateDataSet(e,n,t)}))})),this.projector.setSelectedTensor(this.selectedRun,this.getEmbeddingInfoByName(this.selectedTensor)))}_generateUiForNewCheckpointForRun(e){this.dataProvider.retrieveProjectorConfig(e,(e=>{this.projectorConfig=e;let t=this.projectorConfig.embeddings.map((e=>e.tensorName)).filter((e=>{let t=this.getEmbeddingInfoByName(e).tensorShape;return 2===t.length&&t[0]>1&&t[1]>1})).sort(((e,t)=>{let n=this.getEmbeddingInfoByName(e),r=this.getEmbeddingInfoByName(t);if(xor(!!n.metadataPath,!!r.metadataPath))return n.metadataPath?-1:1;let i=tensorIsGenerated(e),a=tensorIsGenerated(t);if(xor(i,a))return a?-1:1;let o=n.tensorShape[0],s=r.tensorShape[0];return o!==s?s-o:e<=t?-1:1}));this.tensorNames=t.map((e=>({name:e,shape:this.getEmbeddingInfoByName(e).tensorShape})));const n="demo"===this.projector.servingMode?this.projectorConfig.embeddings[0].tensorName:t[0];this.selectedTensor===n?this._selectedTensorChanged():this.selectedTensor=n}))}_selectedLabelOptionChanged(){this.projector.setSelectedLabelOption(this.selectedLabelOption)}_selectedColorOptionNameChanged(){let e;for(let t=0;t<this.colorOptions.length;t++)if(this.colorOptions[t].name===this.selectedColorOptionName){e=this.colorOptions[t];break}if(e){if(this.showForceCategoricalColorsCheckbox=!!e.tooManyUniqueValues,null==e.map)this.colorLegendRenderInfo=null;else if(e.items){let t=e.items.map((t=>({color:e.map(t.label),label:t.label,count:t.count})));this.colorLegendRenderInfo={items:t,thresholds:null}}else this.colorLegendRenderInfo={items:null,thresholds:e.thresholds};this.projector.setSelectedColorOption(e)}}tensorWasReadFromFile(e,t){parseRawTensors(e,(e=>{const n=this.$$("#checkpoint-file");n.innerText=t,n.title=t,this.projector.updateDataSet(e)}))}metadataWasReadFromFile(e,t){parseRawMetadata(e,(e=>{this.projector.updateDataSet(this.projector.dataSet,e,t)}))}getEmbeddingInfoByName(e){for(let t=0;t<this.projectorConfig.embeddings.length;t++){const n=this.projectorConfig.embeddings[t];if(n.tensorName===e)return n}}setupUploadButtons(){const e=this.$$("#file");e.onchange=()=>{const t=e.files[0];e.value="";const n=new FileReader;n.onload=e=>{this.tensorWasReadFromFile(n.result,t.name)},n.readAsArrayBuffer(t)};this.$$("#upload-tensors").onclick=()=>{e.click()};const t=this.$$("#file-metadata");t.onchange=()=>{const e=t.files[0];t.value="";const n=new FileReader;n.onload=t=>{this.metadataWasReadFromFile(n.result,e.name)},n.readAsArrayBuffer(e)};this.$$("#upload-metadata").onclick=()=>{t.click()},"demo"!==this.projector.servingMode&&(this.$$("#publish-container").style.display="none",this.$$("#upload-tensors-step-container").style.display="none",this.$$("#upload-metadata-label").style.display="none"),this.$$("#demo-data-buttons-container").style.display="flex";const n=this.$$("#projector-config-template"),r={embeddings:[{tensorName:"My tensor",tensorShape:[1e3,50],tensorPath:"https://raw.githubusercontent.com/.../tensors.tsv",metadataPath:"https://raw.githubusercontent.com/.../optional.metadata.tsv"}]};this.setProjectorConfigTemplateJson(n,r);const i=this.$$("#config-sprite-checkbox");i.onchange=()=>{i.checked?r.embeddings[0].sprite={imagePath:"https://github.com/.../optional.sprite.png",singleImageDim:[32,32]}:delete r.embeddings[0].sprite,this.setProjectorConfigTemplateJson(n,r)};const a=this.$$("#config-bookmarks-checkbox");a.onchange=()=>{a.checked?r.embeddings[0].bookmarksPath="https://raw.githubusercontent.com/.../bookmarks.txt":delete r.embeddings[0].bookmarksPath,this.setProjectorConfigTemplateJson(n,r)};const o=this.$$("#config-metadata-checkbox");o.onchange=()=>{o.checked?r.embeddings[0].metadataPath="https://raw.githubusercontent.com/.../optional.metadata.tsv":delete r.embeddings[0].metadataPath,this.setProjectorConfigTemplateJson(n,r)};const s=this.$$("#projector-config-url"),l=this.$$("#projector-share-url"),c=this.$$("#projector-share-url-link");s.onchange=()=>{let e=location.protocol+"//"+location.host+location.pathname+"?config="+s.value;l.value=e,Object.assign(c,{href:e})}}setProjectorConfigTemplateJson(e,t){e.value=JSON.stringify(t,null,2)}_getNumTensorsLabel(){return 1===this.tensorNames.length?"1 tensor":this.tensorNames.length+" tensors"}_getNumRunsLabel(){return 1===this.runNames.length?"1 run":this.runNames.length+" runs"}_hasChoice(e){return e.length>0}_hasChoices(e){return e.length>1}_openDataDialog(){this.$.dataDialog.open()}_openConfigDialog(){this.$.projectorConfigDialog.open()}};DataPanel.template=template$3,__decorate([property({type:String}),__metadata("design:type",String)],DataPanel.prototype,"selectedTensor",void 0),__decorate([property({type:String}),__metadata("design:type",String)],DataPanel.prototype,"selectedRun",void 0),__decorate([property({type:String,notify:!0}),__metadata("design:type",String)],DataPanel.prototype,"selectedColorOptionName",void 0),__decorate([property({type:String,notify:!0}),__metadata("design:type",String)],DataPanel.prototype,"selectedLabelOption",void 0),__decorate([property({type:Boolean}),__metadata("design:type",Boolean)],DataPanel.prototype,"normalizeData",void 0),__decorate([property({type:Boolean}),__metadata("design:type",Boolean)],DataPanel.prototype,"showForceCategoricalColorsCheckbox",void 0),__decorate([property({type:String}),__metadata("design:type",String)],DataPanel.prototype,"metadataEditorInput",void 0),__decorate([property({type:String}),__metadata("design:type",String)],DataPanel.prototype,"metadataEditorInputLabel",void 0),__decorate([property({type:String}),__metadata("design:type",String)],DataPanel.prototype,"metadataEditorColumn",void 0),__decorate([property({type:Boolean}),__metadata("design:type",Boolean)],DataPanel.prototype,"metadataEditorButtonDisabled",void 0),__decorate([property({type:String}),__metadata("design:type",String)],DataPanel.prototype,"superviseInput",void 0),__decorate([property({type:String}),__metadata("design:type",String)],DataPanel.prototype,"superviseInputLabel",void 0),__decorate([property({type:String}),__metadata("design:type",String)],DataPanel.prototype,"superviseColumn",void 0),__decorate([property({type:Boolean}),__metadata("design:type",Boolean)],DataPanel.prototype,"showSuperviseSettings",void 0),__decorate([property({type:String}),__metadata("design:type",Object)],DataPanel.prototype,"_wordDelimiter",void 0),__decorate([observe("selectedTensor"),__metadata("design:type",Function),__metadata("design:paramtypes",[]),__metadata("design:returntype",void 0)],DataPanel.prototype,"_selectedTensorChanged",null),__decorate([observe("selectedRun"),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",void 0)],DataPanel.prototype,"_generateUiForNewCheckpointForRun",null),__decorate([observe("selectedLabelOption"),__metadata("design:type",Function),__metadata("design:paramtypes",[]),__metadata("design:returntype",void 0)],DataPanel.prototype,"_selectedLabelOptionChanged",null),__decorate([observe("selectedColorOptionName"),__metadata("design:type",Function),__metadata("design:paramtypes",[]),__metadata("design:returntype",void 0)],DataPanel.prototype,"_selectedColorOptionNameChanged",null),DataPanel=__decorate([customElement("vz-projector-data-panel")],DataPanel);let ProjectorInput=class extends(LegacyElementMixin(PolymerElement)){registerInputChangedListener(e){this.textChangedListeners.push(e)}ready(){super.ready(),this.inRegexMode=!1,this.textChangedListeners=[],this.paperInput=this.$$("paper-input"),this.inRegexModeButton=this.$$("paper-button"),this.paperInput.setAttribute("error-message","Invalid regex"),this.paperInput.addEventListener("input",(()=>{this.onTextChanged()})),this.paperInput.addEventListener("keydown",(e=>{e.stopPropagation()})),this.inRegexModeButton.addEventListener("click",(()=>this.onClickRegexModeButton())),this.updateRegexModeDisplaySlashes(),this.onTextChanged()}onClickRegexModeButton(){this.inRegexMode=this.inRegexModeButton.active,this.updateRegexModeDisplaySlashes(),this.onTextChanged()}notifyInputChanged(e,t){this.textChangedListeners.forEach((n=>n(e,t)))}onTextChanged(){try{this.inRegexMode&&new RegExp(this.paperInput.value)}catch(e){return this.paperInput.setAttribute("invalid","true"),this.message="",void this.notifyInputChanged(null,!0)}this.paperInput.removeAttribute("invalid"),this.notifyInputChanged(this.paperInput.value,this.inRegexMode)}updateRegexModeDisplaySlashes(){const e=this.paperInput.querySelectorAll(".slash"),t=this.inRegexMode?"":"none";for(let n=0;n<e.length;n++)e[n].style.display=t}getValue(){return this.paperInput.value}getInRegexMode(){return this.inRegexMode}setValue(e,t){this.inRegexModeButton.active=t,this.paperInput.value=e,this.onClickRegexModeButton()}};ProjectorInput.template=html`
    <style include="vz-projector-styles"></style>
    <style>
      .info {
        color: rgba(0, 0, 0, 0.5);
        display: block;
        font-size: 11px;
      }

      .toggle {
        font-size: 12px;
        height: 21px;
        margin: 0px;
        min-width: 0px;
        min-height: 0px;
        padding: 0;
        width: 17px;
      }

      .toggle[active] {
        background-color: #880e4f;
        color: white;
      }
    </style>

    <paper-input label="[[label]]">
      <div class="slash" prefix slot="prefix">/</div>
      <div class="slash" suffix slot="suffix">/</div>
      <div suffix slot="suffix">
        <paper-button id="regex" toggles class="toggle">.*</paper-button>
      </div>
    </paper-input>
    <paper-tooltip
      for="regex"
      position="bottom"
      animation-delay="0"
      fit-to-visible-bounds
    >
      Enable/disable regex mode.
    </paper-tooltip>
    <span class="info">[[message]]</span>
  `,__decorate([property({type:String}),__metadata("design:type",String)],ProjectorInput.prototype,"label",void 0),__decorate([property({type:String}),__metadata("design:type",String)],ProjectorInput.prototype,"message",void 0),ProjectorInput=__decorate([customElement("vz-projector-input")],ProjectorInput);const template$2=html`
  <style include="vz-projector-styles"></style>
  <style>
    :host {
      display: flex;
      flex-direction: column;
      /* Account for the bookmark pane at the bottom */
      height: calc(100% - 55px);
    }

    .container {
      display: block;
      padding: 10px 20px 0 20px;
    }

    .buttons {
      display: flex;
      height: 60px;
    }

    .button {
      margin-right: 10px;
      border: none;
      border-radius: 7px;
      font-size: 13px;
      padding: 10px;
      background: #e3e3e3;
    }

    .button:last-child {
      margin-right: 0;
    }

    .nn,
    .metadata-info {
      display: flex;
      flex-direction: column;
    }

    .nn > *,
    .metadata-info > * {
      padding: 0 20px;
    }

    .nn-list,
    .metadata-list {
      overflow-y: auto;
    }

    .nn-list .neighbor,
    .metadata-list .metadata {
      font-size: 12px;
      margin-bottom: 8px;
    }

    .nn-list .label-and-value,
    .metadata-list .label-and-value {
      display: flex;
      justify-content: space-between;
    }

    .label {
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .nn-list .value,
    .metadata-list .value {
      color: #666;
      float: right;
      font-weight: 300;
      margin-left: 8px;
    }

    .nn-list .bar,
    .metadata-list .bar {
      position: relative;
      border-top: 1px solid rgba(0, 0, 0, 0.15);
      margin: 2px 0;
    }

    .nn-list .bar .fill,
    .metadata-list .bar .fill {
      position: absolute;
      top: -1px;
      border-top: 1px solid white;
    }

    .nn-list .tick,
    .metadata-list .tick {
      position: absolute;
      top: 0px;
      height: 3px;
      border-left: 1px solid rgba(0, 0, 0, 0.15);
    }

    .nn-list .sprite-image,
    .metadata-list .sprite-image {
      width: 100%;
    }

    .nn-list.nn-img-show .sprite-image,
    .metadata-list.nn-img-show .sprite-image {
      display: block;
    }

    .nn-list .neighbor-link:hover,
    .metadata-list .metadata-link:hover {
      cursor: pointer;
    }

    .search-by {
      display: flex;
    }

    .search-by vz-projector-input {
      width: 100%;
    }

    .search-by paper-dropdown-menu {
      margin-left: 10px;
      width: 100px;
    }

    .distance .options {
      float: right;
    }

    .neighbor-image-controls {
      display: flex;
      padding: 0.8em 0.1em;
    }

    .options a {
      color: #727272;
      font-size: 13px;
      margin-left: 12px;
      text-decoration: none;
    }

    .options a.selected {
      color: #009efe;
    }

    .neighbors {
      margin-bottom: 15px;
    }

    .neighbors-options {
      margin-top: 6px;
    }

    .neighbors-options .option-label,
    .distance .option-label {
      color: #727272;
      margin-right: 2px;
      width: auto;
    }

    .num-neighbors-container {
      display: inline-block;
    }

    .nn-slider {
      --paper-slider-input: {
        width: 64px;
      }
      --paper-input-container-input: {
        font-size: 14px;
      }
    }

    .euclidean {
      margin-right: 10px;
    }

    .matches-list {
      padding: 0 20px;
    }

    .matches-list .row {
      border-bottom: 1px solid #ddd;
      cursor: pointer;
      display: flex;
      font-size: 12px;
      margin: 5px 0;
      padding: 4px 0;
    }

    .results {
      display: flex;
      flex-direction: column;
    }

    .results,
    .nn,
    .nn-list {
      flex: 1 0 100px;
    }
  </style>
  <div class="container">
    <div class="buttons">
      <button class="button reset-filter">Show All Data</button>
      <button class="button set-filter">Isolate selection</button>
      <button class="button clear-selection">Clear selection</button>
    </div>
    <div class="search-by">
      <vz-projector-input id="search-box" label="Search"></vz-projector-input>
      <paper-dropdown-menu no-animations label="by">
        <paper-listbox
          attr-for-selected="value"
          class="dropdown-content"
          selected="{{selectedMetadataField}}"
          slot="dropdown-content"
        >
          <template is="dom-repeat" items="[[metadataFields]]">
            <paper-item value="[[item]]" label="[[item]]">
              [[item]]
            </paper-item>
          </template>
        </paper-listbox>
      </paper-dropdown-menu>
    </div>
  </div>
  <div class="results">
    <div class="nn" style="display: none">
      <div class="neighbors">
        <div class="neighbors-options">
          <div class="slider num-nn">
            <span class="option-label">neighbors</span>
            <paper-icon-button
              icon="help"
              class="help-icon"
            ></paper-icon-button>
            <paper-tooltip
              position="bottom"
              animation-delay="0"
              fit-to-visible-bounds
            >
              The number of neighbors (in the original space) to show when
              clicking on a point.
            </paper-tooltip>
            <paper-slider
              class="nn-slider"
              pin
              min="5"
              max="999"
              editable
              value="{{numNN}}"
              on-change="updateNumNN"
            ></paper-slider>
          </div>
        </div>
        <div class="distance">
          <span class="option-label">distance</span>
          <div class="options">
            <a class="selected cosine" href="javascript:void(0);">COSINE</a>
            <a class="euclidean" href="javascript:void(0);">EUCLIDEAN</a>
          </div>
        </div>
        <div class="neighbor-image-controls">
          <template is="dom-if" if="[[spriteImagesAvailable]]">
            <paper-checkbox checked="{{showNeighborImages}}">
              show images
              <paper-icon-button
                icon="help"
                class="help-icon"
              ></paper-icon-button>
              <paper-tooltip
                position="bottom"
                animation-delay="0"
                fit-to-visible-bounds
              >
                Show the images of the nearest neighbors.
              </paper-tooltip>
            </paper-checkbox>
          </template>
        </div>
      </div>
      <p>Nearest points in the original space:</p>
      <div class="nn-list"></div>
    </div>
    <div class="metadata-info" style="display: none">
      <div class="neighbors-options">
        <div class="slider num-nn">
          <span class="option-label">neighbors</span>
          <paper-icon-button icon="help" class="help-icon"></paper-icon-button>
          <paper-tooltip
            position="bottom"
            animation-delay="0"
            fit-to-visible-bounds
          >
            The number of neighbors (in the selected space) to show when
            clicking on a point.
          </paper-tooltip>
          <paper-slider
            class="nn-slider"
            pin
            min="5"
            max="999"
            editable
            value="{{numNN}}"
            on-change="updateNumNN"
          ></paper-slider>
        </div>
      </div>
      <p>{{metadataColumn}} labels (click to apply):</p>
      <div class="metadata-list"></div>
    </div>
    <div class="matches-list" style="display: none">
      <div class="list"></div>
      <div class="limit-msg">Showing only the first 100 results...</div>
    </div>
  </div>
`,LIMIT_RESULTS=100,DEFAULT_NEIGHBORS=100;let InspectorPanel=class extends(LegacyElementMixin(PolymerElement)){constructor(){super(...arguments),this.numNN=DEFAULT_NEIGHBORS,this.showNeighborImages=!0,this.spriteImagesAvailable=!0}ready(){super.ready(),this.resetFilterButton=this.$$(".reset-filter"),this.setFilterButton=this.$$(".set-filter"),this.clearSelectionButton=this.$$(".clear-selection"),this.limitMessage=this.$$(".limit-msg"),this.searchBox=this.$$("#search-box"),this.displayContexts=[]}initialize(e,t){this.projector=e,this.projectorEventContext=t,this.setupUI(e),t.registerSelectionChangedListener(((e,t)=>this.updateInspectorPane(e,t)))}updateInspectorPane(e,t){this.neighborsOfFirstPoint=t,this.selectedPointIndices=e,this.updateFilterButtons(e.length+t.length),this.updateNeighborsList(t),this.updateSearchResults(0===t.length?e:[])}enableResetFilterButton(e){this.resetFilterButton.disabled=!e}restoreUIFromBookmark(e){this.enableResetFilterButton(null!=e.filteredPoints)}metadataChanged(e){let t=-1;if(this.metadataFields=e.stats.map(((e,n)=>(e.isNumeric||-1!==t||(t=n),e.name))),e.spriteMetadata&&e.spriteMetadata.imagePath){const[t,n]=e.spriteMetadata.singleImageDim;this.spriteMeta={imagePath:e.spriteImage.src,aspectRatio:t/n,nCols:Math.floor(e.spriteImage.width/t),singleImageDim:[t,n]}}else this.spriteMeta={};this.spriteImagesAvailable=!!this.spriteMeta.imagePath,null!=this.selectedMetadataField&&0!==this.metadataFields.filter((e=>e===this.selectedMetadataField)).length||(this.selectedMetadataField=this.metadataFields[Math.max(0,t)]),this.updateInspectorPane(this.selectedPointIndices,this.neighborsOfFirstPoint)}datasetChanged(){this.enableResetFilterButton(!1)}_refreshNeighborsList(){this.updateNeighborsList()}metadataEditorContext(e,t){if(!this.projector||!this.projector.dataSet)return;let n=this.projector.dataSet.spriteAndMetadataInfo.stats.filter((e=>e.name===t));if(!e||0===n.length||n[0].tooManyUniqueValues)return void this.removeContext(".metadata-info");this.metadataColumn=t,this.addContext(".metadata-info");let r=this.$$(".metadata-list");r.textContent="";let i=n[0].uniqueEntries.sort(((e,t)=>e.count-t.count)),a=i[i.length-1].count;i.forEach((e=>{const n=document.createElement("div");n.className="metadata";const i=document.createElement("a");i.className="metadata-link",i.title=e.label;const o=document.createElement("div");o.className="label-and-value";const s=document.createElement("div");s.className="label",s.style.color=dist2color(this.distFunc,a,e.count),s.innerText=e.label;const l=document.createElement("div");l.className="value",l.innerText=e.count.toString(),o.appendChild(s),o.appendChild(l);const c=document.createElement("div");c.className="bar";const h=document.createElement("div");h.className="fill",h.style.borderTopColor=dist2color(this.distFunc,a,e.count),h.style.width=100*normalizeDist(this.distFunc,a,e.count)+"%",c.appendChild(h);for(let e=1;e<4;e++){const t=document.createElement("div");t.className="tick",t.style.left=100*e/4+"%",c.appendChild(t)}i.appendChild(o),i.appendChild(c),n.appendChild(i),r.appendChild(n),i.onclick=()=>{this.projector.metadataEdit(t,e.label)}}))}addContext(e){-1===this.displayContexts.indexOf(e)&&this.displayContexts.push(e),this.displayContexts.forEach((e=>{this.$$(e).style.display="none"})),this.$$(e).style.display=null}removeContext(e){if(this.displayContexts=this.displayContexts.filter((t=>t!==e)),this.$$(e).style.display="none",this.displayContexts.length>0){this.$$(this.displayContexts[this.displayContexts.length-1]).style.display=null}}updateSearchResults(e){const t=this.$$(".matches-list").querySelector(".list");if(t.textContent="",0!==e.length){this.addContext(".matches-list"),this.limitMessage.style.display=e.length<=LIMIT_RESULTS?"none":null,e=e.slice(0,LIMIT_RESULTS);for(let n=0;n<e.length;n++){const r=e[n],i=document.createElement("div");i.className="row";const a=this.getLabelFromIndex(r),o=document.createElement("a");o.className="label",o.title=a,o.innerText=a,o.onmouseenter=()=>{this.projectorEventContext.notifyHoverOverPoint(r)},o.onmouseleave=()=>{this.projectorEventContext.notifyHoverOverPoint(null)},o.onclick=()=>{this.projectorEventContext.notifySelectionChanged([r])},i.appendChild(o),t.appendChild(i)}}else this.removeContext(".matches-list")}getLabelFromIndex(e){const t=this.projector.dataSet.points[e].metadata[this.selectedMetadataField];return void 0!==t?String(t):`Unknown #${e}`}spriteImageRenderer(){const e=this.spriteMeta.imagePath,{aspectRatio:t,nCols:n}=this.spriteMeta,r=100/t+"%",i=`${100*n}% ${100*n}%`,a=`url(${CSS.escape(e)})`;return e=>{const t=document.createElement("div");t.className="sprite-image",t.style.backgroundImage=a,t.style.paddingBottom=r,t.style.backgroundSize=i;const[o,s]=[Math.floor(e.index/n),e.index%n],[l,c]=[o/(n-1)*100,s/(n-1)*100];return t.style.backgroundPosition=`${c}% ${l}%`,t}}updateNeighborsList(e){if(this._currentNeighbors=e=e||this._currentNeighbors,null==e)return;const t=this.$$(".nn-list");if(t.textContent="",0===e.length)return void this.removeContext(".nn");this.addContext(".nn"),this.searchBox.message="";const n=e.length>0?e[0].dist:0;if(this.spriteImagesAvailable&&this.showNeighborImages)var r=this.spriteImageRenderer();for(let i=0;i<e.length;i++){const a=e[i],o=document.createElement("div");o.className="neighbor";const s=document.createElement("a");s.className="neighbor-link",s.title=this.getLabelFromIndex(a.index);const l=document.createElement("div");l.className="label-and-value";const c=document.createElement("div");c.className="label",c.style.color=dist2color(this.distFunc,a.dist,n),c.innerText=this.getLabelFromIndex(a.index);const h=document.createElement("div");h.className="value",h.innerText=a.dist.toFixed(3),l.appendChild(c),l.appendChild(h);const u=document.createElement("div");u.className="bar";const d=document.createElement("div");d.className="fill",d.style.borderTopColor=dist2color(this.distFunc,a.dist,n),d.style.width=100*normalizeDist(this.distFunc,a.dist,n)+"%",u.appendChild(d);for(let e=1;e<4;e++){const t=document.createElement("div");t.className="tick",t.style.left=100*e/4+"%",u.appendChild(t)}if(this.spriteImagesAvailable&&this.showNeighborImages){const e=r(a);o.appendChild(e)}s.appendChild(l),s.appendChild(u),o.appendChild(s),t.appendChild(o),s.onmouseenter=()=>{this.projectorEventContext.notifyHoverOverPoint(a.index)},s.onmouseleave=()=>{this.projectorEventContext.notifyHoverOverPoint(null)},s.onclick=()=>{this.projectorEventContext.notifySelectionChanged([a.index])}}}updateFilterButtons(e){e>1?(this.setFilterButton.innerText=`Isolate ${e} points`,this.setFilterButton.disabled=null,this.clearSelectionButton.disabled=null):(this.setFilterButton.disabled=!0,this.clearSelectionButton.disabled=!0)}setupUI(e){this.distFunc=cosDist;const t=this.$$(".distance a.euclidean");t.onclick=()=>{const n=this.root.querySelectorAll(".distance a");for(let e=0;e<n.length;e++)classed(n[e],"selected",!1);classed(t,"selected",!0),this.distFunc=dist,this.projectorEventContext.notifyDistanceMetricChanged(this.distFunc);const r=e.dataSet.findNeighbors(this.selectedPointIndices[0],this.distFunc,this.numNN);this.updateNeighborsList(r)};const n=this.$$(".distance a.cosine");n.onclick=()=>{const t=this.root.querySelectorAll(".distance a");for(let e=0;e<t.length;e++)classed(t[e],"selected",!1);classed(n,"selected",!0),this.distFunc=cosDist,this.projectorEventContext.notifyDistanceMetricChanged(this.distFunc);const r=e.dataSet.findNeighbors(this.selectedPointIndices[0],this.distFunc,this.numNN);this.updateNeighborsList(r)};const r=(t,n)=>{if(null==t||""===t.trim())return this.searchBox.message="",void this.projectorEventContext.notifySelectionChanged([]);const r=e.dataSet.query(t,n,this.selectedMetadataField);this.searchBox.message=0===r.length?"0 matches.":`${r.length} matches.`,this.projectorEventContext.notifySelectionChanged(r)};this.searchBox.registerInputChangedListener(((e,t)=>{r(e,t)})),this.setFilterButton.onclick=()=>{const t=this.selectedPointIndices.concat(this.neighborsOfFirstPoint.map((e=>e.index)));e.filterDataset(t),this.enableResetFilterButton(!0),this.updateFilterButtons(0)},this.resetFilterButton.onclick=()=>{e.resetFilterDataset(),this.enableResetFilterButton(!1)},this.clearSelectionButton.onclick=()=>{e.adjustSelectionAndHover([])},this.enableResetFilterButton(!1)}updateNumNN(){null!=this.selectedPointIndices&&this.projectorEventContext.notifySelectionChanged([this.selectedPointIndices[0]])}};InspectorPanel.template=template$2,__decorate([property({type:String}),__metadata("design:type",String)],InspectorPanel.prototype,"selectedMetadataField",void 0),__decorate([property({type:Array}),__metadata("design:type",Array)],InspectorPanel.prototype,"metadataFields",void 0),__decorate([property({type:String}),__metadata("design:type",String)],InspectorPanel.prototype,"metadataColumn",void 0),__decorate([property({type:Number}),__metadata("design:type",Number)],InspectorPanel.prototype,"numNN",void 0),__decorate([property({type:Object}),__metadata("design:type",Object)],InspectorPanel.prototype,"spriteMeta",void 0),__decorate([property({type:Boolean}),__metadata("design:type",Boolean)],InspectorPanel.prototype,"showNeighborImages",void 0),__decorate([property({type:Boolean}),__metadata("design:type",Boolean)],InspectorPanel.prototype,"spriteImagesAvailable",void 0),__decorate([observe("showNeighborImages","spriteImagesAvailable"),__metadata("design:type",Function),__metadata("design:paramtypes",[]),__metadata("design:returntype",void 0)],InspectorPanel.prototype,"_refreshNeighborsList",null),InspectorPanel=__decorate([customElement("vz-projector-inspector-panel")],InspectorPanel);let MetadataCard=class extends(LegacyElementMixin(PolymerElement)){constructor(){super(...arguments),this.hasMetadata=!1,this.isCollapsed=!1,this.collapseIcon="expand-less"}_toggleMetadataContainer(){this.$$("#metadata-container").toggle(),this.isCollapsed=!this.isCollapsed,this.set("collapseIcon",this.isCollapsed?"expand-more":"expand-less")}updateMetadata(e){if(this.pointMetadata=e,this.hasMetadata=null!=e,e){let t=[];for(let n in e)e.hasOwnProperty(n)&&t.push({key:n,value:e[n]});this.metadata=t,this.label=""+this.pointMetadata[this.labelOption]}}setLabelOption(e){this.labelOption=e,this.pointMetadata&&(this.label=""+this.pointMetadata[this.labelOption])}};MetadataCard.template=html`
    <style>
      #metadata-card {
        background-color: rgba(255, 255, 255, 0.9);
        box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.14),
          0 1px 5px 0 rgba(0, 0, 0, 0.12), 0 3px 1px -2px rgba(0, 0, 0, 0.2);
        width: 270px;
      }

      #header {
        background: #e9e9e9;
      }

      #icon-container {
        position: absolute;
        right: 0;
        top: 4px;
      }

      #metadata-label {
        font-weight: 400;
        font-size: 14px;
        line-height: 24px;
        padding: 12px 12px 8px;
        width: 230px;
        overflow-wrap: break-word;
      }

      #metadata-table {
        display: table;
        padding: 8px 12px 4px;
      }

      .metadata-row {
        display: table-row;
      }

      .metadata-key {
        font-weight: bold;
      }

      .metadata-key,
      .metadata-value {
        display: table-cell;
        font-size: 12px;
        padding: 3px 3px;
      }

      .metadata-value {
        word-wrap: anywhere; /* Firefox only -- word-wrap DNE in Chrome. anywhere DNE in Chrome */
        word-break: break-word; /* break-word DNE in Firefox */
      }
    </style>

    <template is="dom-if" if="[[hasMetadata]]">
      <div id="metadata-card">
        <div id="icon-container">
          <paper-icon-button
            icon="[[collapseIcon]]"
            on-tap="_toggleMetadataContainer"
          >
          </paper-icon-button>
        </div>
        <div id="header">
          <div id="metadata-label">[[label]]</div>
        </div>
        <iron-collapse id="metadata-container" opened>
          <div id="metadata-table">
            <template is="dom-repeat" items="[[metadata]]">
              <div class="metadata-row">
                <div class="metadata-key">[[item.key]]</div>
                <div class="metadata-value">[[item.value]]</div>
              </div>
            </template>
          </div>
        </iron-collapse>
      </div>
    </template>
  `,__decorate([property({type:Boolean}),__metadata("design:type",Boolean)],MetadataCard.prototype,"hasMetadata",void 0),__decorate([property({type:Boolean}),__metadata("design:type",Boolean)],MetadataCard.prototype,"isCollapsed",void 0),__decorate([property({type:String}),__metadata("design:type",String)],MetadataCard.prototype,"collapseIcon",void 0),__decorate([property({type:Array}),__metadata("design:type",Array)],MetadataCard.prototype,"metadata",void 0),__decorate([property({type:String}),__metadata("design:type",String)],MetadataCard.prototype,"label",void 0),MetadataCard=__decorate([customElement("vz-projector-metadata-card")],MetadataCard);const template$1=html`
    <style include="vz-projector-styles"></style>
    <style>
      :host {
        transition: height 0.2s;
      }

      .ink-button {
        border: none;
        border-radius: 2px;
        font-size: 13px;
        padding: 10px;
        min-width: 88px;
        flex-shrink: 0;
        background: #e3e3e3;
      }

      .ink-panel-buttons {
        margin-bottom: 10px;
      }

      .two-way-toggle {
        display: flex;
        flex-direction: row;
      }

      .two-way-toggle span {
        padding-right: 7px;
      }

      .has-border {
        border: 1px solid rgba(0, 0, 0, 0.1);
      }

      .toggle {
        min-width: 0px;
        font-size: 12px;
        width: 17px;
        min-height: 0px;
        height: 21px;
        padding: 0;
        margin: 0px;
      }

      .toggle[active] {
        background-color: #880e4f;
        color: white;
      }

      .two-columns {
        display: flex;
        justify-content: space-between;
      }

      .two-columns > :first-child {
        margin-right: 15px;
      }

      .two-columns > div {
        width: 50%;
      }

      .dropdown-item {
        justify-content: space-between;
        min-height: 35px;
      }

      .tsne-supervise-factor {
        margin-bottom: -8px;
      }

      #z-container {
        display: flex;
        align-items: center;
        width: 50%;
      }

      #z-checkbox {
        margin: 27px 0 0 5px;
        width: 18px;
      }

      #z-dropdown {
        flex-grow: 1;
      }

      .notice {
        color: #880e4f;
      }

      .container {
        padding: 20px;
      }

      .book-icon {
        height: 20px;
        color: rgba(0, 0, 0, 0.7);
      }

      .item-details {
        color: gray;
        font-size: 12px;
        margin-left: 5px;
      }

      .pca-dropdown {
        width: 100%;
      }

      .pca-dropdown paper-listbox {
        width: 135px;
      }

      .dropdown-item.header {
        border-bottom: 1px solid #aaa;
        color: #333;
        font-weight: bold;
      }

      #total-variance {
        color: rgba(0, 0, 0, 0.7);
      }
    </style>
    <div id="main">
      <div class="ink-panel-header">
        <div class="ink-tab-group">
          <div data-tab="umap" id="umap-tab" class="ink-tab projection-tab">
            UMAP
          </div>
          <paper-tooltip
            for="umap-tab"
            position="bottom"
            animation-delay="0"
            fit-to-visible-bounds
          >
            uniform manifold approximation and projection
          </paper-tooltip>

          <div data-tab="tsne" id="tsne-tab" class="ink-tab projection-tab">
            t-SNE
          </div>
          <paper-tooltip
            for="tsne-tab"
            position="bottom"
            animation-delay="0"
            fit-to-visible-bounds
          >
            t-distributed stochastic neighbor embedding
          </paper-tooltip>

          <div data-tab="pca" id="pca-tab" class="ink-tab projection-tab">
            PCA
          </div>
          <paper-tooltip
            for="pca-tab"
            position="bottom"
            animation-delay="0"
            fit-to-visible-bounds
          >
            Principal component analysis
          </paper-tooltip>

          <div
            data-tab="custom"
            id="custom-tab"
            class="ink-tab projection-tab"
            title="Linear projection of two custom vectors"
          >
            Custom
          </div>
          <paper-tooltip
            for="custom-tab"
            position="bottom"
            animation-delay="0"
            fit-to-visible-bounds
          >
            Search for two vectors upon which to project all points.
          </paper-tooltip>
        </div>
      </div>
      <div class="container">
        <!-- UMAP Controls -->
        <div data-panel="umap" class="ink-panel-content">
          <div class="slider">
            <label>Dimension</label>
            <div class="two-way-toggle">
              <span>2D</span>
              <paper-toggle-button id="umap-toggle" checked="{{umapIs3d}}"
                >3D</paper-toggle-button
              >
            </div>
          </div>
          <div class="slider umap-neighbors">
            <label>
              Neighbors
              <paper-icon-button
                icon="help"
                class="help-icon"
              ></paper-icon-button>
              <paper-tooltip
                position="right"
                animation-delay="0"
                fit-to-visible-bounds
              >
                The number of nearest neighbors used to compute the fuzzy
                simplicial set, which is used to approximate the overall shape
                of the manifold. The default value is 15.
              </paper-tooltip>
            </label>
            <paper-slider
              id="umap-neighbors-slider"
              value="{{umapNeighbors}}"
              pin
              min="5"
              max="50"
            ></paper-slider>
            <span>[[umapNeighbors]]</span>
          </div>
          <p>
            <button
              id="run-umap"
              class="ink-button"
              title="Run UMAP"
              on-tap="runUmap"
            >
              Run
            </button>
          </p>
          <p id="umap-sampling" class="notice">
            For faster results, the data will be sampled down to
            [[getUmapSampleSizeText()]] points.
          </p>
          <p>
            <iron-icon icon="book" class="book-icon"></iron-icon>
            <a
              target="_blank"
              rel="noopener"
              href="https://umap-learn.readthedocs.io/en/latest/how_umap_works.html"
            >
              Learn more about UMAP.
            </a>
          </p>
        </div>
        <!-- TSNE Controls -->
        <div data-panel="tsne" class="ink-panel-content">
          <div class="slider">
            <label>Dimension</label>
            <div class="two-way-toggle">
              <span>2D</span>
              <paper-toggle-button id="tsne-toggle" checked="{{tSNEis3d}}"
                >3D</paper-toggle-button
              >
            </div>
          </div>
          <div class="slider tsne-perplexity">
            <label>
              Perplexity
              <paper-icon-button
                icon="help"
                class="help-icon"
              ></paper-icon-button>
              <paper-tooltip
                position="right"
                animation-delay="0"
                fit-to-visible-bounds
              >
                The most appropriate perplexity value depends on the density of
                the data. Loosely speaking, a larger / denser dataset requires a
                larger perplexity. Typical values for perplexity range between 5
                and 50.
              </paper-tooltip>
            </label>
            <paper-slider
              id="perplexity-slider"
              pin
              min="2"
              max="100"
              value="30"
            ></paper-slider>
            <span></span>
          </div>
          <div class="slider tsne-learning-rate">
            <label>
              Learning rate
              <paper-icon-button
                icon="help"
                class="help-icon"
              ></paper-icon-button>
              <paper-tooltip
                position="right"
                animation-delay="0"
                fit-to-visible-bounds
              >
                The ideal learning rate often depends on the size of the data,
                with smaller datasets requiring smaller learning rates.
              </paper-tooltip>
            </label>
            <paper-slider
              id="learning-rate-slider"
              snaps
              min="-3"
              max="2"
              step="1"
              value="1"
              max-markers="6"
            >
            </paper-slider>
            <span></span>
          </div>
          <div class="slider tsne-supervise-factor">
            <label>
              Supervise
              <paper-icon-button
                icon="help"
                class="help-icon"
              ></paper-icon-button>
              <paper-tooltip
                position="right"
                animation-delay="0"
                fit-to-visible-bounds
              >
                The label importance used for supervision, from 0 (disabled) to
                100 (full importance).
              </paper-tooltip>
            </label>
            <paper-slider
              id="supervise-factor-slider"
              min="0"
              max="100"
              pin
              value="{{superviseFactor}}"
            >
            </paper-slider>
            <span></span>
          </div>
          <p>
            <button class="run-tsne ink-button" title="Re-run t-SNE">
              Run
            </button>
            <button class="pause-tsne ink-button" title="Pause t-SNE">
              Pause
            </button>
            <button class="perturb-tsne ink-button" title="Perturb t-SNE">
              Perturb
            </button>
          </p>
          <p>Iteration: <span class="run-tsne-iter">0</span></p>
          <p id="tsne-sampling" class="notice">
            For faster results, the data will be sampled down to
            [[getTsneSampleSizeText()]] points.
          </p>
          <p>
            <iron-icon icon="book" class="book-icon"></iron-icon>
            <a
              target="_blank"
              href="http://distill.pub/2016/misread-tsne/"
              rel="noopener noreferrer"
            >
              How to use t-SNE effectively.
            </a>
          </p>
        </div>
        <!-- PCA Controls -->
        <div data-panel="pca" class="ink-panel-content">
          <div class="two-columns">
            <div>
              <!-- Left column -->
              <paper-dropdown-menu
                class="pca-dropdown"
                vertical-align="bottom"
                no-animations
                label="X"
              >
                <paper-listbox
                  attr-for-selected="value"
                  class="dropdown-content"
                  selected="{{pcaX}}"
                  slot="dropdown-content"
                >
                  <paper-item disabled class="dropdown-item header">
                    <div>#</div>
                    <div>Variance (%)</div>
                  </paper-item>
                  <template is="dom-repeat" items="[[pcaComponents]]">
                    <paper-item
                      class="dropdown-item"
                      value="[[item.id]]"
                      label="Component #[[item.componentNumber]]"
                    >
                      <div>[[item.componentNumber]]</div>
                      <div class="item-details">[[item.percVariance]]</div>
                    </paper-item>
                  </template>
                </paper-listbox>
              </paper-dropdown-menu>
              <paper-dropdown-menu
                class="pca-dropdown"
                no-animations
                vertical-align="bottom"
                label="Z"
                disabled="[[!hasPcaZ]]"
                id="z-dropdown"
              >
                <paper-listbox
                  attr-for-selected="value"
                  class="dropdown-content"
                  selected="{{pcaZ}}"
                  slot="dropdown-content"
                >
                  <paper-item disabled class="dropdown-item header">
                    <div>#</div>
                    <div>Variance (%)</div>
                  </paper-item>
                  <template is="dom-repeat" items="[[pcaComponents]]">
                    <paper-item
                      class="dropdown-item"
                      value="[[item.id]]"
                      label="Component #[[item.componentNumber]]"
                    >
                      <div>[[item.componentNumber]]</div>
                      <div class="item-details">[[item.percVariance]]</div>
                    </paper-item>
                  </template>
                </paper-listbox>
              </paper-dropdown-menu>
            </div>
            <div>
              <!-- Right column -->
              <paper-dropdown-menu
                class="pca-dropdown"
                vertical-align="bottom"
                no-animations
                label="Y"
              >
                <paper-listbox
                  attr-for-selected="value"
                  class="dropdown-content"
                  selected="{{pcaY}}"
                  slot="dropdown-content"
                >
                  <paper-item disabled class="dropdown-item header">
                    <div>#</div>
                    <div>Variance (%)</div>
                  </paper-item>
                  <template is="dom-repeat" items="[[pcaComponents]]">
                    <paper-item
                      class="dropdown-item"
                      value="[[item.id]]"
                      label="Component #[[item.componentNumber]]"
                    >
                      <div>[[item.componentNumber]]</div>
                      <div class="item-details">[[item.percVariance]]</div>
                    </paper-item>
                  </template>
                </paper-listbox>
              </paper-dropdown-menu>
              <paper-checkbox
                id="z-checkbox"
                checked="{{pcaIs3d}}"
              ></paper-checkbox>
            </div>
          </div>
          <p id="pca-sampling" class="notice">
            PCA is approximate.
            <paper-icon-button
              icon="help"
              class="help-icon"
            ></paper-icon-button>
          </p>
          <div id="total-variance">Total variance</div>
          <paper-tooltip
            for="pca-sampling"
            position="top"
            animation-delay="0"
            fit-to-visible-bounds
          >
            For fast results, the data was sampled to [[getPcaSampleSizeText()]]
            points and randomly projected down to [[getPcaSampledDimText()]]
            dimensions.
          </paper-tooltip>
        </div>
        <!-- Custom Controls -->
        <div data-panel="custom" class="ink-panel-content">
          <paper-dropdown-menu
            style="width: 100%"
            no-animations
            label="Search by"
          >
            <paper-listbox
              attr-for-selected="value"
              class="dropdown-content"
              selected="{{customSelectedSearchByMetadataOption}}"
              slot="dropdown-content"
            >
              <template is="dom-repeat" items="[[searchByMetadataOptions]]">
                <paper-item
                  class="dropdown-item"
                  value="[[item]]"
                  label="[[item]]"
                >
                  [[item]]
                </paper-item>
              </template>
            </paper-listbox>
          </paper-dropdown-menu>
          <div class="two-columns">
            <vz-projector-input id="xLeft" label="Left"></vz-projector-input>
            <vz-projector-input id="xRight" label="Right"></vz-projector-input>
          </div>
          <div class="two-columns">
            <vz-projector-input id="yUp" label="Up"></vz-projector-input>
            <vz-projector-input id="yDown" label="Down"></vz-projector-input>
          </div>
        </div>
      </div>
    </div>
  </template>
  <script src="vz-projector-projections-panel.js"></script>
</dom-module>
`,NUM_PCA_COMPONENTS=10;let ProjectionsPanel=class extends(LegacyElementMixin(PolymerElement)){constructor(){super(...arguments),this.pcaIs3d=!0,this.tSNEis3d=!0,this.superviseFactor=0,this.umapIs3d=!0,this.umapNeighbors=15,this.pcaX=0,this.pcaY=1,this.pcaZ=2}initialize(e){this.polymerChangesTriggerReprojection=!0,this.projector=e,this.perplexity=30,this.learningRate=10,this.centroidValues={xLeft:null,xRight:null,yUp:null,yDown:null},this.clearCentroids(),this.setupUIControls()}ready(){super.ready(),this.zDropdown=this.$$("#z-dropdown"),this.runTsneButton=this.$$(".run-tsne"),this.pauseTsneButton=this.$$(".pause-tsne"),this.perturbTsneButton=this.$$(".perturb-tsne"),this.perplexitySlider=this.$$("#perplexity-slider"),this.learningRateInput=this.$$("#learning-rate-slider"),this.superviseFactorInput=this.$$("#supervise-factor-slider"),this.iterationLabelTsne=this.$$(".run-tsne-iter"),this.runUmapButton=this.$$("#run-umap")}disablePolymerChangesTriggerReprojection(){this.polymerChangesTriggerReprojection=!1}enablePolymerChangesTriggerReprojection(){this.polymerChangesTriggerReprojection=!0}updateTSNEPerplexityFromSliderChange(){this.perplexitySlider&&(this.perplexity=+this.perplexitySlider.value),this.$$(".tsne-perplexity span").innerText=""+this.perplexity}updateTSNELearningRateFromUIChange(){this.learningRateInput&&(this.learningRate=Math.pow(10,+this.learningRateInput.value)),this.$$(".tsne-learning-rate span").innerText=""+this.learningRate}updateTSNESuperviseFactorFromUIChange(){this.$$(".tsne-supervise-factor span").innerText=""+this.superviseFactor,this.dataSet&&this.dataSet.setSuperviseFactor(this.superviseFactor)}setupUIControls(){{const e=this,t=this.root.querySelectorAll(".ink-tab");for(let n=0;n<t.length;n++)t[n].addEventListener("click",(function(){let t=this.getAttribute("data-tab");e.showTab(t)}))}this.runTsneButton.addEventListener("click",(()=>{this.dataSet.hasTSNERun?this.dataSet.stopTSNE():this.runTSNE()})),this.pauseTsneButton.addEventListener("click",(()=>{this.dataSet.tSNEShouldPause?(this.dataSet.tSNEShouldPause=!1,this.pauseTsneButton.innerText="Pause"):(this.dataSet.tSNEShouldPause=!0,this.pauseTsneButton.innerText="Resume")})),this.perturbTsneButton.addEventListener("mousedown",(()=>{this.dataSet&&this.projector&&(this.dataSet.perturbTsne(),this.projector.notifyProjectionPositionsUpdated(),this.perturbInterval=window.setInterval((()=>{this.dataSet.perturbTsne(),this.projector.notifyProjectionPositionsUpdated()}),100))})),this.perturbTsneButton.addEventListener("mouseup",(()=>{clearInterval(this.perturbInterval)})),this.perplexitySlider.value=this.perplexity.toString(),this.perplexitySlider.addEventListener("change",(()=>this.updateTSNEPerplexityFromSliderChange())),this.updateTSNEPerplexityFromSliderChange(),this.learningRateInput.addEventListener("change",(()=>this.updateTSNELearningRateFromUIChange())),this.updateTSNELearningRateFromUIChange(),this.superviseFactorInput.addEventListener("change",(()=>this.updateTSNESuperviseFactorFromUIChange())),this.updateTSNESuperviseFactorFromUIChange(),this.setupCustomProjectionInputFields();const e=this.root.querySelectorAll("paper-dropdown-menu paper-input input");for(let t=0;t<e.length;t++)e[t].style.fontSize="14px"}restoreUIFromBookmark(e){this.disablePolymerChangesTriggerReprojection(),this.pcaX=e.pcaComponentDimensions[0],this.pcaY=e.pcaComponentDimensions[1],3===e.pcaComponentDimensions.length&&(this.pcaZ=e.pcaComponentDimensions[2]),this.pcaIs3d=3===e.pcaComponentDimensions.length,this.perplexitySlider&&(this.perplexitySlider.value=e.tSNEPerplexity.toString()),this.learningRateInput&&(this.learningRateInput.value=e.tSNELearningRate.toString()),this.tSNEis3d=e.tSNEis3d,this.umapIs3d=e.umapIs3d,this.umapNeighbors=e.umapNeighbors,this.customSelectedSearchByMetadataOption=e.customSelectedSearchByMetadataOption,this.customProjectionXLeftInput&&this.customProjectionXLeftInput.set(e.customXLeftText,e.customXLeftRegex),this.customProjectionXRightInput&&this.customProjectionXRightInput.set(e.customXRightText,e.customXRightRegex),this.customProjectionYUpInput&&this.customProjectionYUpInput.set(e.customYUpText,e.customYUpRegex),this.customProjectionYDownInput&&this.customProjectionYDownInput.set(e.customYDownText,e.customYDownRegex),this.computeAllCentroids(),this.setZDropdownEnabled(this.pcaIs3d),this.updateTSNEPerplexityFromSliderChange(),this.updateTSNELearningRateFromUIChange(),this.iterationLabelTsne&&(this.iterationLabelTsne.innerText=e.tSNEIteration.toString()),null!=e.selectedProjection&&this.showTab(e.selectedProjection),this.enablePolymerChangesTriggerReprojection()}populateBookmarkFromUI(e){this.disablePolymerChangesTriggerReprojection(),e.pcaComponentDimensions=[this.pcaX,this.pcaY],this.pcaIs3d&&e.pcaComponentDimensions.push(this.pcaZ),null!=this.perplexitySlider&&(e.tSNEPerplexity=+this.perplexitySlider.value),null!=this.learningRateInput&&(e.tSNELearningRate=+this.learningRateInput.value),e.tSNEis3d=this.tSNEis3d,e.umapIs3d=this.umapIs3d,e.customSelectedSearchByMetadataOption=this.customSelectedSearchByMetadataOption,null!=this.customProjectionXLeftInput&&(e.customXLeftText=this.customProjectionXLeftInput.getValue(),e.customXLeftRegex=this.customProjectionXLeftInput.getInRegexMode()),null!=this.customProjectionXRightInput&&(e.customXRightText=this.customProjectionXRightInput.getValue(),e.customXRightRegex=this.customProjectionXRightInput.getInRegexMode()),null!=this.customProjectionYUpInput&&(e.customYUpText=this.customProjectionYUpInput.getValue(),e.customYUpRegex=this.customProjectionYUpInput.getInRegexMode()),null!=this.customProjectionYDownInput&&(e.customYDownText=this.customProjectionYDownInput.getValue(),e.customYDownRegex=this.customProjectionYDownInput.getInRegexMode()),this.enablePolymerChangesTriggerReprojection()}setZDropdownEnabled(e){this.zDropdown&&(e?this.zDropdown.removeAttribute("disabled"):this.zDropdown.setAttribute("disabled","true"))}dataSetUpdated(e,t,n){this.dataSet=e,this.originalDataSet=t,this.dim=n;const r=null==e?0:e.points.length,i=Math.max(5,Math.ceil(Math.sqrt(r)/4));this.perplexitySlider.value=i.toString(),this.updateTSNEPerplexityFromSliderChange(),this.clearCentroids(),this.$$("#tsne-sampling").style.display=r>TSNE_SAMPLE_SIZE?null:"none";const a=null!=e&&(e.dim[0]>PCA_SAMPLE_DIM||e.dim[1]>PCA_SAMPLE_DIM);this.$$("#pca-sampling").style.display=a?null:"none",this.showTab("pca")}_pcaDimensionToggleObserver(){this.setZDropdownEnabled(this.pcaIs3d),this.beginProjection(this.currentProjection)}_tsneDimensionToggleObserver(){this.beginProjection(this.currentProjection)}_umapDimensionToggleObserver(){this.beginProjection(this.currentProjection)}metadataChanged(e){let t=-1;this.searchByMetadataOptions=e.stats.map(((e,n)=>(e.isNumeric||-1!==t||(t=n),e.name))),this.customSelectedSearchByMetadataOption=this.searchByMetadataOptions[Math.max(0,t)]}showTab(e){this.currentProjection=e;const t=this.$$('.ink-tab[data-tab="'+e+'"]'),n=this.root.querySelectorAll(".ink-tab");for(let e=0;e<n.length;e++)classed(n[e],"active",!1);classed(t,"active",!0);const r=this.root.querySelectorAll(".ink-panel-content");for(let e=0;e<r.length;e++)classed(r[e],"active",!1);if(classed(this.$$('.ink-panel-content[data-panel="'+e+'"]'),"active",!0),null!=this.$){const e=this.$.main;requestAnimationFrame((()=>{this.style.height=e.clientHeight+"px"}))}this.beginProjection(e)}beginProjection(e){!1!==this.polymerChangesTriggerReprojection&&("pca"===e?(null!=this.dataSet&&this.dataSet.stopTSNE(),this.showPCA()):"tsne"===e?this.showTSNE():"umap"===e?this.showUmap():"custom"===e&&(null!=this.dataSet&&this.dataSet.stopTSNE(),this.computeAllCentroids(),this.reprojectCustom()))}showTSNE(){const e=this.dataSet;if(null==e)return;const t=getProjectionComponents("tsne",[0,1,this.tSNEis3d?2:null]),n=new Projection("tsne",t,this.tSNEis3d?3:2,e);this.projector.setProjection(n),this.dataSet.hasTSNERun?this.projector.notifyProjectionPositionsUpdated():this.runTSNE()}runTSNE(){let e=!1;this.runTsneButton.innerText="Stop",this.runTsneButton.disabled=!0,this.pauseTsneButton.innerText="Pause",this.pauseTsneButton.disabled=!0,this.perturbTsneButton.disabled=!1,this.dataSet.projectTSNE(this.perplexity,this.learningRate,this.tSNEis3d?3:2,(t=>{null!=t?(this.runTsneButton.disabled=!1,this.pauseTsneButton.disabled=!1,this.iterationLabelTsne.innerText=""+t,this.projector.notifyProjectionPositionsUpdated(),!e&&this.dataSet.projections.tsne&&(this.projector.onProjectionChanged(),e=!0)):(this.runTsneButton.innerText="Re-run",this.runTsneButton.disabled=!1,this.pauseTsneButton.innerText="Pause",this.pauseTsneButton.disabled=!0,this.perturbTsneButton.disabled=!0,this.projector.onProjectionChanged())}))}showUmap(){const e=this.dataSet;if(null==e)return;const t=getProjectionComponents("umap",[0,1,this.umapIs3d?2:null]),n=new Projection("umap",t,this.umapIs3d?3:2,e);this.projector.setProjection(n),this.dataSet.hasUmapRun?this.projector.notifyProjectionPositionsUpdated():this.runUmap()}runUmap(){let e=!1;this.runUmapButton.disabled=!0;this.dataSet.projectUmap(this.umapIs3d?3:2,this.umapNeighbors,(t=>{null!=t?(this.runUmapButton.disabled=!1,this.projector.notifyProjectionPositionsUpdated(),!e&&this.dataSet.projections.umap&&(this.projector.onProjectionChanged(),e=!0)):(this.runUmapButton.innerText="Re-run",this.runUmapButton.disabled=!1,this.projector.onProjectionChanged())}))}showPCAIfEnabled(){this.polymerChangesTriggerReprojection&&this.showPCA()}updateTotalVarianceMessage(){let e=this.dataSet.fracVariancesExplained,t=e[this.pcaX]+e[this.pcaY],n="Total variance described: ";this.pcaIs3d&&(t+=e[this.pcaZ]),n+=(100*t).toFixed(1)+"%.",this.$$("#total-variance").textContent=n}showPCA(){null!=this.dataSet&&this.dataSet.projectPCA().then((()=>{const e=getProjectionComponents("pca",[this.pcaX,this.pcaY,this.pcaZ]),t=new Projection("pca",e,this.pcaIs3d?3:2,this.dataSet);this.projector.setProjection(t);let n=Math.min(NUM_PCA_COMPONENTS,this.dataSet.dim[1]);this.updateTotalVarianceMessage(),this.pcaComponents=range(n).map((e=>({id:e,componentNumber:e+1,percVariance:(100*this.dataSet.fracVariancesExplained[e]).toFixed(1)})))}))}reprojectCustom(){if(null==this.centroids||null==this.centroids.xLeft||null==this.centroids.xRight||null==this.centroids.yUp||null==this.centroids.yDown)return;const e=sub(this.centroids.xRight,this.centroids.xLeft);this.dataSet.projectLinear(e,"linear-x");const t=sub(this.centroids.yUp,this.centroids.yDown);this.dataSet.projectLinear(t,"linear-y");const n=getProjectionComponents("custom",["x","y"]),r=new Projection("custom",n,2,this.dataSet);this.projector.setProjection(r)}clearCentroids(){this.centroids={xLeft:null,xRight:null,yUp:null,yDown:null},this.allCentroid=null}_customSelectedSearchByMetadataOptionChanged(e,t){!1!==this.polymerChangesTriggerReprojection&&"custom"===this.currentProjection&&(this.computeAllCentroids(),this.reprojectCustom())}setupCustomProjectionInputFields(){this.customProjectionXLeftInput=this.setupCustomProjectionInputField("xLeft"),this.customProjectionXRightInput=this.setupCustomProjectionInputField("xRight"),this.customProjectionYUpInput=this.setupCustomProjectionInputField("yUp"),this.customProjectionYDownInput=this.setupCustomProjectionInputField("yDown")}computeAllCentroids(){this.computeCentroid("xLeft"),this.computeCentroid("xRight"),this.computeCentroid("yUp"),this.computeCentroid("yDown")}computeCentroid(e){const t=this.$$("#"+e);if(null==t)return;const n=t.getValue();if(null==n)return;let r=t.getInRegexMode(),i=this.getCentroid(n,r);0===i.numMatches?(t.message="0 matches. Using a random vector.",i.centroid=rn(this.dim)):t.message=`${i.numMatches} matches.`,this.centroids[e]=i.centroid,this.centroidValues[e]=n}setupCustomProjectionInputField(e){let t=this.$$("#"+e);return t.registerInputChangedListener(((t,n)=>{this.polymerChangesTriggerReprojection&&(this.computeCentroid(e),this.reprojectCustom())})),t}getCentroid(e,t){if(null==e||""===e)return{numMatches:0};let n=this.originalDataSet.query(e,t,this.customSelectedSearchByMetadataOption);return{centroid:centroid(n,(e=>this.originalDataSet.points[e].vector)),numMatches:n.length}}getPcaSampledDimText(){return PCA_SAMPLE_DIM.toLocaleString()}getPcaSampleSizeText(){return PCA_SAMPLE_SIZE.toLocaleString()}getTsneSampleSizeText(){return TSNE_SAMPLE_SIZE.toLocaleString()}getUmapSampleSizeText(){return UMAP_SAMPLE_SIZE.toLocaleString()}};ProjectionsPanel.template=template$1,__decorate([property({type:Boolean}),__metadata("design:type",Boolean)],ProjectionsPanel.prototype,"pcaIs3d",void 0),__decorate([property({type:Boolean}),__metadata("design:type",Boolean)],ProjectionsPanel.prototype,"tSNEis3d",void 0),__decorate([property({type:Number}),__metadata("design:type",Number)],ProjectionsPanel.prototype,"superviseFactor",void 0),__decorate([property({type:Boolean}),__metadata("design:type",Boolean)],ProjectionsPanel.prototype,"umapIs3d",void 0),__decorate([property({type:Number}),__metadata("design:type",Number)],ProjectionsPanel.prototype,"umapNeighbors",void 0),__decorate([property({type:Array}),__metadata("design:type",Array)],ProjectionsPanel.prototype,"pcaComponents",void 0),__decorate([property({type:Number}),__metadata("design:type",Number)],ProjectionsPanel.prototype,"pcaX",void 0),__decorate([property({type:Number}),__metadata("design:type",Number)],ProjectionsPanel.prototype,"pcaY",void 0),__decorate([property({type:Number}),__metadata("design:type",Number)],ProjectionsPanel.prototype,"pcaZ",void 0),__decorate([property({type:String}),__metadata("design:type",String)],ProjectionsPanel.prototype,"customSelectedSearchByMetadataOption",void 0),__decorate([observe("pcaIs3d"),__metadata("design:type",Function),__metadata("design:paramtypes",[]),__metadata("design:returntype",void 0)],ProjectionsPanel.prototype,"_pcaDimensionToggleObserver",null),__decorate([observe("tSNEis3d"),__metadata("design:type",Function),__metadata("design:paramtypes",[]),__metadata("design:returntype",void 0)],ProjectionsPanel.prototype,"_tsneDimensionToggleObserver",null),__decorate([observe("umapIs3d"),__metadata("design:type",Function),__metadata("design:paramtypes",[]),__metadata("design:returntype",void 0)],ProjectionsPanel.prototype,"_umapDimensionToggleObserver",null),__decorate([observe("pcaX","pcaY","pcaZ"),__metadata("design:type",Function),__metadata("design:paramtypes",[]),__metadata("design:returntype",void 0)],ProjectionsPanel.prototype,"showPCAIfEnabled",null),__decorate([observe("customSelectedSearchByMetadataOption"),__metadata("design:type",Function),__metadata("design:paramtypes",[String,String]),__metadata("design:returntype",void 0)],ProjectionsPanel.prototype,"_customSelectedSearchByMetadataOptionChanged",null),ProjectionsPanel=__decorate([customElement("vz-projector-projections-panel")],ProjectionsPanel);const template=html`
<style include="vz-projector-styles"></style>
    <style>
      :host {
        display: flex;
        width: 100%;
        height: 100%;
      }

      #container {
        display: flex;
        width: 100%;
        height: 100%;
        overflow: hidden;
      }

      .hidden {
        display: none !important;
      }

      /* Main */

      #main {
        position: relative;
        flex-grow: 2;
      }

      #main .stage {
        position: relative;
        flex-grow: 2;
      }

      #scatter {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
      }

      #selector {
        display: none;
        height: 100%;
        position: absolute;
        width: 100%;
      }

      #left-pane {
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        min-width: 312px;
        width: 312px;
        border-right: 1px solid rgba(0, 0, 0, 0.1);
        background: #fafafa;
      }

      #right-pane {
        border-left: 1px solid rgba(0, 0, 0, 0.1);
        background: #fafafa;
        display: flex;
        height: 100%;
        min-width: 300px;
        width: 300px;
      }

      .file-name {
        margin-right: 5px;
      }

      .control input[type='text']:focus {
        outline: none;
        border-bottom: 1px solid rgba(0, 0, 0, 1);
      }

      .control {
        display: inline-block;
        width: 45%;
        vertical-align: top;
        margin-right: 10px;
        overflow-x: hidden;
      }

      .control.last {
        margin-right: 0;
      }

      #notification-dialog {
        width: 400px;
        padding-bottom: 20px;
      }

      #notification-dialog paper-button {
        background: none;
        text-transform: uppercase;
      }

      #notification-dialog .progress {
        --paper-spinner-color: #880e4f;
        --paper-spinner-stroke-width: 2px;
      }

      #notify-msgs {
        text-align: center;
        display: block;
      }

      .notify-msg {
        font-weight: 500;
        margin: 0;
        padding: 0;
      }

      .notify-msg.error {
        text-align: left;
      }

      .brush .extent {
        stroke: #fff;
        fill-opacity: 0.125;
        shape-rendering: crispEdges;
      }

      .origin text {
        font-size: 12px;
        font-weight: 500;
      }

      .origin line {
        stroke: black;
        stroke-opacity: 0.2;
      }

      /* Ink Framework */

      /* - Buttons */
      .ink-button,
      ::shadow .ink-button {
        border: none;
        border-radius: 2px;
        font-size: 13px;
        padding: 10px;
        min-width: 100px;
        flex-shrink: 0;
        background: #e3e3e3;
      }

      .status-bar-panel {
        display: flex;
        align-items: center;
      }

      .status-bar-entry {
        border-left: 1px solid rgba(0, 0, 0, 0.5);
        margin-left: 5px;
        padding-left: 5px;
      }

      /* - Menubar */

      .ink-panel-menubar {
        align-items: center;
        position: relative;
        height: 60px;
        border-bottom: solid 1px #eee;
        padding: 0 24px;
        display: flex;
      }

      .ink-panel-menubar .ink-fabs {
        position: absolute;
        right: 12px;
        top: 40px;
        z-index: 1;
      }

      #bookmark-panel {
        bottom: 0;
        position: absolute;
        width: 300px;
      }
      #bookmark-panel-container {
        bottom: 60px;
        position: absolute;
      }

      .ink-fab {
        margin-left: 8px;
        border: 1px solid rgba(0, 0, 0, 0.02);
        background: white;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
      }

      #metadata-card {
        position: absolute;
        right: 5px;
        top: 25px;
      }

      #help-3d-icon {
        position: absolute;
        top: 20px;
        left: 20px;
      }

      #help3dDialog .main {
        margin: 0;
        padding: 20px;
      }

      #help3dDialog h3 {
        margin-top: 20px;
        margin-bottom: 5px;
      }

      #help3dDialog h3:first-child {
        margin-top: 0;
      }

      #data-panel {
        border-top: 1px solid rgba(0, 0, 0, 0.1);
        overflow-y: auto;
      }

      #toast {
        display: flex;
        align-items: center;
        --paper-toast-color: #eeff41;
      }
    </style>
    <paper-dialog id="notification-dialog" modal>
      <h2 id="notification-title"></h2>
      <paper-dialog-scrollable>
        <div id="notify-msgs"></div>
      </paper-dialog-scrollable>
      <div style="text-align: center;">
        <paper-spinner-lite active class="progress"></paper-spinner-lite>
      </div>
      <div class="buttons">
        <paper-button class="close-button" dialog-confirm autofocus
          >Close</paper-button
        >
      </div>
    </paper-dialog>
    <div id="container">
      <div id="left-pane" class="ink-panel">
        <vz-projector-data-panel id="data-panel"></vz-projector-data-panel>
        <vz-projector-projections-panel
          id="projections-panel"
        ></vz-projector-projections-panel>
      </div>
      <div id="main" class="ink-panel">
        <div class="ink-panel-menubar">
          <paper-icon-button
            id="selectMode"
            alt="Bounding box selection"
            toggles
            icon="image:photo-size-select-small"
          ></paper-icon-button>
          <paper-tooltip
            for="selectMode"
            position="bottom"
            animation-delay="0"
            fit-to-visible-bounds
            >Bounding box selection</paper-tooltip
          >

          <paper-icon-button
            id="editMode"
            alt="Edit current selection"
            toggles
            icon="image:exposure"
          ></paper-icon-button>
          <paper-tooltip
            for="editMode"
            position="bottom"
            animation-delay="0"
            fit-to-visible-bounds
            >Edit current selection</paper-tooltip
          >

          <paper-icon-button
            id="nightDayMode"
            alt="Enable/disable night mode"
            toggles
            icon="image:brightness-2"
          ></paper-icon-button>
          <paper-tooltip
            for="nightDayMode"
            position="bottom"
            animation-delay="0"
            fit-to-visible-bounds
            >Enable/disable night mode</paper-tooltip
          >

          <paper-icon-button
            id="labels3DMode"
            alt="Enable/disable 3D labels mode"
            toggles
            icon="font-download"
          ></paper-icon-button>
          <paper-tooltip
            for="labels3DMode"
            position="bottom"
            animation-delay="0"
            fit-to-visible-bounds
            >Enable/disable 3D labels mode</paper-tooltip
          >
          <div class="status-bar-panel">
            <div class="status-bar-entry">
              Points: <span class="numDataPoints">Loading...</span>
            </div>
            <div class="status-bar-entry">
              Dimension: <span class="dim">Loading...</span>
            </div>
            <div
              id="status-bar"
              class="status-bar-entry"
              style="display: none;"
            ></div>
          </div>
          <div class="ink-fabs">
            <paper-icon-button
              id="reset-zoom"
              class="ink-fab"
              alt="Reset zoom to fit all points"
              icon="home"
            ></paper-icon-button>
            <paper-tooltip for="reset-zoom" position="left" animation-delay="0"
              >Reset zoom to fit all points</paper-tooltip
            >
          </div>
        </div>
        <div class="stage">
          <div id="scatter">
            <svg id="selector"></svg>
          </div>
          <vz-projector-metadata-card
            id="metadata-card"
          ></vz-projector-metadata-card>
          <paper-icon-button
            raised
            onclick="help3dDialog.open()"
            icon="help-outline"
            id="help-3d-icon"
          ></paper-icon-button>
          <paper-tooltip animation-delay="0" for="help-3d-icon"
            >Help with interaction controls.</paper-tooltip
          >
          <paper-dialog id="help3dDialog" with-backdrop>
            <div class="main" dialog-confirm autofocus>
              <h3>3D controls</h3>
              <b>Rotate</b> Mouse left click.<br />
              <b>Pan</b> Mouse right click.<br />
              <b>Zoom</b> Mouse wheel.<br />
              Holding <b>ctrl</b> reverses the mouse clicks.
              <h3>2D controls</h3>
              <b>Pan</b> Mouse left click.<br />
              <b>Zoom</b> Mouse wheel.
              <div class="dismiss-dialog-note">Click anywhere to dismiss.</div>
            </div>
          </paper-dialog>
        </div>
      </div>
      <div id="right-pane" class="ink-panel">
        <div class="ink-panel-content active">
          <vz-projector-inspector-panel
            id="inspector-panel"
          ></vz-projector-inspector-panel>
        </div>
        <div id="bookmark-panel-container">
          <vz-projector-bookmark-panel
            id="bookmark-panel"
          ></vz-projector-bookmark-panel>
        </div>
      </div>
    </div>
    <paper-toast id="toast" always-on-top></paper-toast>
  </template>
`,THRESHOLD_DIM_NORMALIZE=50,POINT_COLOR_MISSING="black",INDEX_METADATA_FIELD="__index__",initialURLQueryString=window.location.search;let Projector=class extends(LegacyElementMixin(PolymerElement)){ready(){const e=Object.create(null,{ready:{get:()=>super.ready}});return __awaiter$1(this,void 0,void 0,(function*(){e.ready.call(this),setDomContainer(this),this.analyticsLogger=new AnalyticsLogger(this.pageViewLogging,this.eventLogging),this.analyticsLogger.logPageView("embeddings");if(!(yield hasWebGLSupport()))return this.analyticsLogger.logWebGLDisabled(),void setErrorMessage("Your browser or device does not have WebGL enabled. Please enable hardware acceleration, or use a browser that supports WebGL.");this.selectionChangedListeners=[],this.hoverListeners=[],this.projectionChangedListeners=[],this.distanceMetricChangedListeners=[],this.selectedPointIndices=[],this.neighborsOfFirstPoint=[],this.editMode=!1,this.dataPanel=this.$["data-panel"],this.inspectorPanel=this.$["inspector-panel"],this.projectionsPanel=this.$["projections-panel"],this.bookmarkPanel=this.$["bookmark-panel"],this.metadataCard=this.$["metadata-card"],this.statusBar=this.$$("#status-bar"),this.inspectorPanel.initialize(this,this),this.projectionsPanel.initialize(this),this.bookmarkPanel.initialize(this,this),this.setupUIControls(),this.initializeDataProvider()}))}setSelectedLabelOption(e){this.selectedLabelOption=e,this.metadataCard.setLabelOption(this.selectedLabelOption),this.projectorScatterPlotAdapter.setLabelPointAccessor(e),this.projectorScatterPlotAdapter.updateScatterPlotAttributes(),this.projectorScatterPlotAdapter.render()}setSelectedColorOption(e){this.selectedColorOption=e,this.projectorScatterPlotAdapter.setLegendPointColorer(this.getLegendPointColorer(e)),this.projectorScatterPlotAdapter.updateScatterPlotAttributes(),this.projectorScatterPlotAdapter.render()}setNormalizeData(e){this.normalizeData=e,this.setCurrentDataSet(this.originalDataSet.getSubset())}updateDataSet(e,t,n){if(this.dataSetFilterIndices=null,this.originalDataSet=e,null!=e){if(this.normalizeData=this.originalDataSet.dim[1]>=THRESHOLD_DIM_NORMALIZE,null==(t=t||{}).pointsInfo){let[n,r]=this.makeDefaultPointsInfoAndStats(e.points);t.pointsInfo=n,t.stats=r}if(!e.mergeMetadata(t))return}null!=this.projectorScatterPlotAdapter&&(null==e?(this.projectorScatterPlotAdapter.setLabelPointAccessor(null),this.setProjection(null)):(this.projectorScatterPlotAdapter.updateScatterPlotPositions(),this.projectorScatterPlotAdapter.updateScatterPlotAttributes(),this.projectorScatterPlotAdapter.resize(),this.projectorScatterPlotAdapter.render())),null!=e?(this.dataPanel.setNormalizeData(this.normalizeData),this.setCurrentDataSet(e.getSubset()),this.projectorScatterPlotAdapter.setLabelPointAccessor(this.selectedLabelOption),this.inspectorPanel.datasetChanged(),this.inspectorPanel.metadataChanged(t),this.projectionsPanel.metadataChanged(t),this.dataPanel.metadataChanged(t,n)):this.setCurrentDataSet(null)}metadataEdit(e,t){this.selectedPointIndices.forEach((n=>this.dataSet.points[n].metadata[e]=t)),this.neighborsOfFirstPoint.forEach((n=>this.dataSet.points[n.index].metadata[e]=t)),this.dataSet.spriteAndMetadataInfo.stats=analyzeMetadata(this.dataSet.spriteAndMetadataInfo.stats.map((e=>e.name)),this.dataSet.points.map((e=>e.metadata))),this.metadataChanged(this.dataSet.spriteAndMetadataInfo),this.metadataEditorContext(!0,e)}metadataChanged(e,t){null!=t&&(this.metadataFile=t),this.dataSet.spriteAndMetadataInfo=e,this.projectionsPanel.metadataChanged(e),this.inspectorPanel.metadataChanged(e),this.dataPanel.metadataChanged(e,this.metadataFile),this.metadataCard.updateMetadata(this.selectedPointIndices.length>0?this.dataSet.points[this.selectedPointIndices[0]].metadata:null),this.setSelectedLabelOption(this.selectedLabelOption)}metadataEditorContext(e,t){this.inspectorPanel&&this.inspectorPanel.metadataEditorContext(e,t)}setSelectedTensor(e,t){this.bookmarkPanel.setSelectedTensor(e,t,this.dataProvider)}registerSelectionChangedListener(e){this.selectionChangedListeners.push(e)}filterDataset(e){const t=this.selectedPointIndices.length;null==this.dataSetBeforeFilter&&(this.dataSetBeforeFilter=this.dataSet),this.setCurrentDataSet(this.dataSet.getSubset(e)),this.dataSetFilterIndices=e,this.projectorScatterPlotAdapter.updateScatterPlotPositions(),this.projectorScatterPlotAdapter.updateScatterPlotAttributes(),this.adjustSelectionAndHover(range(t))}resetFilterDataset(){const e=this.selectedPointIndices.map((e=>this.dataSet.points[e].index));this.setCurrentDataSet(this.dataSetBeforeFilter),null!=this.projection&&(this.projection.dataSet=this.dataSetBeforeFilter),this.dataSetBeforeFilter=null,this.projectorScatterPlotAdapter.updateScatterPlotPositions(),this.projectorScatterPlotAdapter.updateScatterPlotAttributes(),this.dataSetFilterIndices=[],this.adjustSelectionAndHover(e)}notifySelectionChanged(e){let t=[];if(this.editMode&&e.length>0)if(1===this.selectedPointIndices.length){let n=this.dataSet.points[this.selectedPointIndices[0]].vector;t=this.neighborsOfFirstPoint.filter((t=>0==e.filter((e=>e==t.index)).length)),e.forEach((e=>{if(e!=this.selectedPointIndices[0]&&0==this.neighborsOfFirstPoint.filter((t=>t.index==e)).length){let r=this.inspectorPanel.distFunc(n,this.dataSet.points[e].vector),i=0;for(;i<t.length&&t[i].dist<r;)i+=1;t.splice(i,0,{index:e,dist:r})}}))}else{let t=this.selectedPointIndices.filter((t=>0==e.filter((e=>e==t)).length));e.forEach((e=>{0==this.selectedPointIndices.filter((t=>t==e)).length&&t.push(e)})),this.selectedPointIndices=t,this.metadataCard.updateMetadata(this.selectedPointIndices.length>0?this.dataSet.points[this.selectedPointIndices[0]].metadata:null)}else this.selectedPointIndices=e,1===e.length?(t=this.dataSet.findNeighbors(e[0],this.inspectorPanel.distFunc,this.inspectorPanel.numNN),this.metadataCard.updateMetadata(this.dataSet.points[e[0]].metadata)):this.metadataCard.updateMetadata(null);this.selectionChangedListeners.forEach((e=>e(this.selectedPointIndices,t)))}registerHoverListener(e){this.hoverListeners.push(e)}notifyHoverOverPoint(e){this.hoverListeners.forEach((t=>t(e)))}registerProjectionChangedListener(e){this.projectionChangedListeners.push(e)}notifyProjectionChanged(e){this.projectionChangedListeners.forEach((t=>t(e)))}registerDistanceMetricChangedListener(e){this.distanceMetricChangedListeners.push(e)}notifyDistanceMetricChanged(e){this.distanceMetricChangedListeners.forEach((t=>t(e)))}_dataProtoChanged(e){let t=e?JSON.parse(e):null;this.initializeDataProvider(t)}makeDefaultPointsInfoAndStats(e){let t=[];return e.forEach((e=>{let n={};n[INDEX_METADATA_FIELD]=e.index,t.push(n)})),[t,[{name:INDEX_METADATA_FIELD,isNumeric:!1,tooManyUniqueValues:!0,min:0,max:t.length-1}]]}initializeDataProvider(e){if("demo"===this.servingMode){let e,t=getURLParams(initialURLQueryString);e="config"in t?t.config:this.projectorConfigJsonPath,this.dataProvider=new DemoDataProvider(e)}else if("server"===this.servingMode){if(!this.routePrefix)throw"route-prefix is a required parameter";this.dataProvider=new ServerDataProvider(this.routePrefix)}else{if("proto"!==this.servingMode||null==e)return;this.dataProvider=new ProtoDataProvider(e)}this.dataPanel.initialize(this,this.dataProvider)}getLegendPointColorer(e){if(null==e||null==e.map)return null;return(t,n)=>{let r=t.points[n].metadata[this.selectedColorOption.name];return null==r?POINT_COLOR_MISSING:e.map(r)}}get3DLabelModeButton(){return this.$$("#labels3DMode")}get3DLabelMode(){return this.get3DLabelModeButton().active}adjustSelectionAndHover(e,t){this.notifySelectionChanged(e),this.notifyHoverOverPoint(t),this.setMouseMode(MouseMode.CAMERA_AND_CLICK_SELECT)}setMouseMode(e){this.$$("#selectMode").active=e===MouseMode.AREA_SELECT,this.projectorScatterPlotAdapter.scatterPlot.setMouseMode(e)}setCurrentDataSet(e){this.adjustSelectionAndHover([]),null!=this.dataSet&&this.dataSet.stopTSNE(),null!=e&&this.normalizeData&&e.normalize(),this.dim=null==e?0:e.dim[1],this.$$("span.numDataPoints").innerText=null==e?"0":""+e.dim[0],this.$$("span.dim").innerText=null==e?"0":""+e.dim[1],this.dataSet=e,this.projectionsPanel.dataSetUpdated(this.dataSet,this.originalDataSet,this.dim),this.projectorScatterPlotAdapter.setDataSet(this.dataSet),this.projectorScatterPlotAdapter.scatterPlot.setCameraParametersForNextCameraCreation(null,!0)}setupUIControls(){this.$$("#reset-zoom").addEventListener("click",(()=>{this.projectorScatterPlotAdapter.scatterPlot.resetZoom(),this.projectorScatterPlotAdapter.scatterPlot.startOrbitAnimation()}));let e=this.$$("#selectMode");e.addEventListener("click",(t=>{this.setMouseMode(e.active?MouseMode.AREA_SELECT:MouseMode.CAMERA_AND_CLICK_SELECT)}));let t=this.$$("#nightDayMode");t.addEventListener("click",(()=>{this.projectorScatterPlotAdapter.scatterPlot.setDayNightMode(t.active)}));let n=this.$$("#editMode");n.addEventListener("click",(e=>{this.editMode=n.active}));this.get3DLabelModeButton().addEventListener("click",(()=>{this.projectorScatterPlotAdapter.set3DLabelMode(this.get3DLabelMode())})),window.addEventListener("resize",(()=>{this.projectorScatterPlotAdapter.resize()})),this.projectorScatterPlotAdapter=new ProjectorScatterPlotAdapter(this.getScatterContainer(),this),this.projectorScatterPlotAdapter.setLabelPointAccessor(this.selectedLabelOption),this.projectorScatterPlotAdapter.scatterPlot.onCameraMove(((e,t)=>this.bookmarkPanel.clearStateSelection())),this.registerHoverListener((e=>this.onHover(e))),this.registerProjectionChangedListener((e=>this.onProjectionChanged(e))),this.registerSelectionChangedListener(((e,t)=>this.onSelectionChanged(e,t)))}onHover(e){this.hoverPointIndex=e;let t=null;if(null!=e){const n=this.dataSet.points[e];n.metadata[this.selectedLabelOption]&&(t=n.metadata[this.selectedLabelOption].toString())}0===this.selectedPointIndices.length&&(this.statusBar.style.display=t?null:"none",this.statusBar.innerText=t)}getScatterContainer(){return this.$$("#scatter")}onSelectionChanged(e,t){this.selectedPointIndices=e,this.neighborsOfFirstPoint=t,this.dataPanel.onProjectorSelectionChanged(e,t);let n=this.selectedPointIndices.length+t.length;this.statusBar.innerText=`Selected ${n} points`,this.statusBar.style.display=n>0?null:"none"}onProjectionChanged(e){this.dataPanel.projectionChanged(e)}setProjection(e){this.projection=e,null!=e&&this.analyticsLogger.logProjectionChanged(e.projectionType),this.notifyProjectionChanged(e)}notifyProjectionPositionsUpdated(){this.projectorScatterPlotAdapter.notifyProjectionPositionsUpdated()}getCurrentState(){const e=new State;e.projections=[];for(let t=0;t<this.dataSet.points.length;t++){const n=this.dataSet.points[t],r={},i=Object.keys(n.projections);for(let e=0;e<i.length;++e)r[i[e]]=n.projections[i[e]];e.projections.push(r)}return e.selectedProjection=this.projection.projectionType,e.dataSetDimensions=this.dataSet.dim,e.tSNEIteration=this.dataSet.tSNEIteration,e.selectedPoints=this.selectedPointIndices,e.filteredPoints=this.dataSetFilterIndices,this.projectorScatterPlotAdapter.populateBookmarkFromUI(e),e.selectedColorOptionName=this.dataPanel.selectedColorOptionName,e.forceCategoricalColoring=this.dataPanel.forceCategoricalColoring,e.selectedLabelOption=this.selectedLabelOption,this.projectionsPanel.populateBookmarkFromUI(e),e}loadState(e){this.setProjection(null),this.projectionsPanel.disablePolymerChangesTriggerReprojection(),null!=this.dataSetBeforeFilter&&this.resetFilterDataset(),null!=e.filteredPoints&&this.filterDataset(e.filteredPoints),this.projectionsPanel.enablePolymerChangesTriggerReprojection();for(let t=0;t<e.projections.length;t++){const n=this.dataSet.points[t],r=e.projections[t],i=Object.keys(r);for(let e=0;e<i.length;++e)n.projections[i[e]]=r[i[e]]}this.dataSet.hasTSNERun="tsne"===e.selectedProjection,this.dataSet.tSNEIteration=e.tSNEIteration,this.projectionsPanel.restoreUIFromBookmark(e),this.inspectorPanel.restoreUIFromBookmark(e),this.dataPanel.selectedColorOptionName=e.selectedColorOptionName,this.dataPanel.setForceCategoricalColoring(!!e.forceCategoricalColoring),this.selectedLabelOption=e.selectedLabelOption,this.projectorScatterPlotAdapter.restoreUIFromBookmark(e);{const t=stateGetAccessorDimensions(e),n=getProjectionComponents(e.selectedProjection,t),r=new Projection(e.selectedProjection,n,t.length,this.dataSet);this.setProjection(r)}this.notifySelectionChanged(e.selectedPoints)}};Projector.template=template,__decorate([property({type:String}),__metadata("design:type",String)],Projector.prototype,"routePrefix",void 0),__decorate([property({type:String}),__metadata("design:type",String)],Projector.prototype,"dataProto",void 0),__decorate([property({type:String}),__metadata("design:type",String)],Projector.prototype,"servingMode",void 0),__decorate([property({type:String}),__metadata("design:type",String)],Projector.prototype,"projectorConfigJsonPath",void 0),__decorate([property({type:Boolean}),__metadata("design:type",Boolean)],Projector.prototype,"pageViewLogging",void 0),__decorate([property({type:Boolean}),__metadata("design:type",Boolean)],Projector.prototype,"eventLogging",void 0),__decorate([observe("dataProto"),__metadata("design:type",Function),__metadata("design:paramtypes",[String]),__metadata("design:returntype",void 0)],Projector.prototype,"_dataProtoChanged",null),Projector=__decorate([customElement("vz-projector")],Projector);let VzProjectorApp=class extends PolymerElement{constructor(){super(...arguments),this.pageViewLogging=!1,this.eventLogging=!1,this.projectorConfigJsonPath="",this.routePrefix="",this.servingMode="",this.documentationLink="",this.bugReportLink=""}};VzProjectorApp.template=html`
    <style include="vz-projector-styles"></style>
    <style>
      #appbar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0 24px;
        height: 60px;
        color: white;
        background: #560731;
      }

      #appbar .logo {
        font-size: 18px;
        font-weight: 300;
      }

      .icons {
        display: flex;
      }

      .icons a {
        color: white;
      }

      vz-projector {
        height: calc(100% - 60px);
      }

      #container {
        height: 100%;
      }
    </style>

    <div id="container">
      <div id="appbar">
        <div>Embedding Projector</div>
        <div class="icons">
          <a
            title="Documentation"
            target="_blank"
            href="[[documentationLink]]"
            rel="noopener noreferrer"
          >
            <paper-icon-button icon="help-outline"></paper-icon-button>
            <paper-tooltip
              position="bottom"
              animation-delay="0"
              fit-to-visible-bounds=""
            >
              Open documentation
            </paper-tooltip>
          </a>
          <a
            title="Report bug"
            target="_blank"
            href="[[bugReportLink]]"
            rel="noopener noreferrer"
          >
            <paper-icon-button icon="bug-report"></paper-icon-button>
            <paper-tooltip
              position="bottom"
              animation-delay="0"
              fit-to-visible-bounds=""
            >
              Report a bug
            </paper-tooltip>
          </a>
        </div>
      </div>
      <vz-projector
        route-prefix="[[routePrefix]]"
        serving-mode="[[servingMode]]"
        projector-config-json-path="[[projectorConfigJsonPath]]"
        page-view-logging="[[pageViewLogging]]"
        event-logging="[[eventLogging]]"
      >
      </vz-projector>
    </div>
  `,__decorate([property({type:Boolean}),__metadata("design:type",Boolean)],VzProjectorApp.prototype,"pageViewLogging",void 0),__decorate([property({type:Boolean}),__metadata("design:type",Boolean)],VzProjectorApp.prototype,"eventLogging",void 0),__decorate([property({type:String}),__metadata("design:type",String)],VzProjectorApp.prototype,"projectorConfigJsonPath",void 0),__decorate([property({type:String}),__metadata("design:type",String)],VzProjectorApp.prototype,"routePrefix",void 0),__decorate([property({type:String}),__metadata("design:type",String)],VzProjectorApp.prototype,"servingMode",void 0),__decorate([property({type:String}),__metadata("design:type",String)],VzProjectorApp.prototype,"documentationLink",void 0),__decorate([property({type:String}),__metadata("design:type",String)],VzProjectorApp.prototype,"bugReportLink",void 0),VzProjectorApp=__decorate([customElement("vz-projector-app")],VzProjectorApp);let VzProjectorDashboard=class extends PolymerElement{constructor(){super(...arguments),this._routePrefix="."}reload(){}connectedCallback(){if(super.connectedCallback(),this._initialized)return;let e=new XMLHttpRequest;e.open("GET",this._routePrefix+"/runs"),e.onload=()=>{this._initialized=!0;let t=JSON.parse(e.responseText);this.set("dataNotFound",0===t.length)},e.onerror=()=>{this.set("dataNotFound",!1)},e.send()}};VzProjectorDashboard.template=html`
    <template is="dom-if" if="[[dataNotFound]]">
      <div style="max-width: 540px; margin: 0 auto; padding: 80px 0 0">
        <h3>No checkpoint was found.</h3>
        <p>Probable causes:</p>
        <ul>
          <li>
            No checkpoint has been saved yet. Please refresh the page
            periodically.
          </li>

          <li>
            You are not saving any checkpoint. To save your model, create a
            <a href="https://www.tensorflow.org/api_docs/python/tf/train/Saver"
              ><code>tf.train.Saver</code></a
            >
            and save your model periodically by calling
            <code>saver.save(session, LOG_DIR/model.ckpt, step)</code>.
          </li>
        </ul>

        <p>
          If you’re new to using TensorBoard, and want to find out how to add
          data and set up your event files, check out the
          <a
            href="https://github.com/tensorflow/tensorboard/blob/master/README.md"
            >README</a
          >
          and perhaps the
          <a
            href="https://www.tensorflow.org/get_started/summaries_and_tensorboard"
            >TensorBoard tutorial</a
          >.
        </p>

        <p>
          If you think TensorBoard is configured properly, please see
          <a
            href="https://github.com/tensorflow/tensorboard/blob/master/README.md#my-tensorboard-isnt-showing-any-data-whats-wrong"
            >the section of the README devoted to missing data problems</a
          >
          and consider filing an issue on GitHub.
        </p>
      </div>
    </template>
    <template is="dom-if" if="[[!dataNotFound]]">
      <vz-projector
        id="projector"
        route-prefix="[[_routePrefix]]"
        serving-mode="server"
        page-view-logging=""
        event-logging=""
      ></vz-projector>
    </template>
  `,__decorate([property({type:Boolean}),__metadata("design:type",Boolean)],VzProjectorDashboard.prototype,"dataNotFound",void 0),__decorate([property({type:String}),__metadata("design:type",String)],VzProjectorDashboard.prototype,"_routePrefix",void 0),__decorate([property({type:Boolean}),__metadata("design:type",Boolean)],VzProjectorDashboard.prototype,"_initialized",void 0),VzProjectorDashboard=__decorate([customElement("vz-projector-dashboard")],VzProjectorDashboard)})();
