text: /**
   * Copyright 2017 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.
   */
  
  import {MDCFoundation} from '../base';
  import {transformStyleProperties} from '../animation';
  
  import {cssClasses, strings} from './constants';
  
  export default class MDCLinearProgressFoundation extends MDCFoundation {
    static get cssClasses() {
      return cssClasses;
    }
  
    static get strings() {
      return strings;
    }
  
    static get defaultAdapter() {
      return {
        addClass: (/* className: string */) => {},
        getPrimaryBar: () => /* el: Element */ {},
        getBuffer: () => /* el: Element */ {},
        hasClass: (/* className: string */) => false,
        removeClass: (/* className: string */) => {},
        setStyle: (/* el: Element, styleProperty: string, value: string */) => {},
      };
    }
  
    constructor(adapter) {
      super(Object.assign(MDCLinearProgressFoundation.defaultAdapter, adapter));
    }
  
    init() {
      this.determinate_ = !this.adapter_.hasClass(cssClasses.INDETERMINATE_CLASS);
      this.reverse_ = this.adapter_.hasClass(cssClasses.REVERSED_CLASS);
      this.progress_ = 0;
    }
  
    setDeterminate(isDeterminate) {
      this.determinate_ = isDeterminate;
      if (this.determinate_) {
        this.adapter_.removeClass(cssClasses.INDETERMINATE_CLASS);
        this.setScale_(this.adapter_.getPrimaryBar(), this.progress_);
      } else {
        this.adapter_.addClass(cssClasses.INDETERMINATE_CLASS);
        this.setScale_(this.adapter_.getPrimaryBar(), 1);
        this.setScale_(this.adapter_.getBuffer(), 1);
      }
    }
  
    setProgress(value) {
      this.progress_ = value;
      if (this.determinate_) {
        this.setScale_(this.adapter_.getPrimaryBar(), value);
      }
    }
  
    setBuffer(value) {
      if (this.determinate_) {
        this.setScale_(this.adapter_.getBuffer(), value);
      }
    }
  
    setReverse(isReversed) {
      this.reverse_ = isReversed;
      if (this.reverse_) {
        this.adapter_.addClass(cssClasses.REVERSED_CLASS);
      } else {
        this.adapter_.removeClass(cssClasses.REVERSED_CLASS);
      }
    }
  
    open() {
      this.adapter_.removeClass(cssClasses.CLOSED_CLASS);
    }
  
    close() {
      this.adapter_.addClass(cssClasses.CLOSED_CLASS);
    }
  
    setScale_(el, scaleValue) {
      const value = 'scaleX(' + scaleValue + ')';
      transformStyleProperties.forEach((transformStyleProperty) => {
        this.adapter_.setStyle(el, transformStyleProperty, value);
      });
    }
  }
  