Liferay.Loader.define("commerce-frontend-taglib@10.1.5/quantity_selector/QuantitySelector.soy", ['module', 'exports', 'require', 'frontend-js-metal-web$metal-component', 'frontend-js-metal-web$metal-soy'], function (module, exports, require) {
  var define = undefined;
  var global = window;
  {
    Object.defineProperty(exports, "__esModule", {
      value: true
    });
    exports.default = exports.templates = exports.QuantitySelector = void 0;

    var _metalComponent = _interopRequireDefault(require("frontend-js-metal-web$metal-component"));

    var _metalSoy = _interopRequireDefault(require("frontend-js-metal-web$metal-soy"));

    function _interopRequireDefault(obj) {
      return obj && obj.__esModule ? obj : { default: obj };
    }

    function _typeof(obj) {
      "@babel/helpers - typeof";
      if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
        _typeof = function _typeof(obj) {
          return typeof obj;
        };
      } else {
        _typeof = function _typeof(obj) {
          return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
        };
      }return _typeof(obj);
    }

    function _classCallCheck(instance, Constructor) {
      if (!(instance instanceof Constructor)) {
        throw new TypeError("Cannot call a class as a function");
      }
    }

    function _possibleConstructorReturn(self, call) {
      if (call && (_typeof(call) === "object" || typeof call === "function")) {
        return call;
      }return _assertThisInitialized(self);
    }

    function _assertThisInitialized(self) {
      if (self === void 0) {
        throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
      }return self;
    }

    function _getPrototypeOf(o) {
      _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
        return o.__proto__ || Object.getPrototypeOf(o);
      };return _getPrototypeOf(o);
    }

    function _inherits(subClass, superClass) {
      if (typeof superClass !== "function" && superClass !== null) {
        throw new TypeError("Super expression must either be null or a function");
      }subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } });if (superClass) _setPrototypeOf(subClass, superClass);
    }

    function _setPrototypeOf(o, p) {
      _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
        o.__proto__ = p;return o;
      };return _setPrototypeOf(o, p);
    }

    var templates;
    exports.templates = templates;
    goog.loadModule(function (exports) {
      var soy = goog.require('soy');

      goog.require('soydata');

      // This file was automatically generated from QuantitySelector.soy.
      // Please don't edit this file by hand.

      /**
       * @fileoverview Templates in namespace QuantitySelector.
       * @public
       */

      goog.module('QuantitySelector.incrementaldom');

      goog.require('goog.soy.data.SanitizedContent');

      var incrementalDom = goog.require('incrementaldom');

      goog.require('soy.asserts');

      var soyIdom = goog.require('soy.idom');
      /**
       * @param {{
       *  quantity: (null|number|undefined),
       *  disabled: (boolean|null|undefined),
       *  allowedQuantities: (!Array<number>|null|undefined),
       *  quantitySelectorAdditionalClasses: (!goog.soy.data.SanitizedContent|null|string|undefined),
       *  _prevAvailable: (boolean|null|undefined),
       *  _nextAvailable: (boolean|null|undefined),
       *  _handleFormSubmit: (*|null|undefined),
       *  _handleInputKeyUp: (*|null|undefined),
       *  _handleArrowKeys: (*|null|undefined),
       *  _handlePrevQuantityButtonPressed: (*|null|undefined),
       *  _handleNextQuantityButtonPressed: (*|null|undefined),
       *  _handleSelectOption: (*|null|undefined)
       * }} opt_data
       * @param {Object<string, *>=} opt_ijData
       * @param {Object<string, *>=} opt_ijData_deprecated
       * @return {void}
       * @suppress {checkTypes}
       */

      function $render(opt_data, opt_ijData, opt_ijData_deprecated) {
        opt_ijData = opt_ijData_deprecated || opt_ijData;
        opt_data = opt_data || {};
        /** @type {null|number|undefined} */

        var quantity = soy.asserts.assertType(opt_data.quantity == null || goog.isNumber(opt_data.quantity), 'quantity', opt_data.quantity, 'null|number|undefined');
        /** @type {boolean|null|undefined} */

        var disabled = soy.asserts.assertType(opt_data.disabled == null || goog.isBoolean(opt_data.disabled) || opt_data.disabled === 1 || opt_data.disabled === 0, 'disabled', opt_data.disabled, 'boolean|null|undefined');
        /** @type {!Array<number>|null|undefined} */

        var allowedQuantities = soy.asserts.assertType(opt_data.allowedQuantities == null || goog.isArray(opt_data.allowedQuantities), 'allowedQuantities', opt_data.allowedQuantities, '!Array<number>|null|undefined');
        /** @type {!goog.soy.data.SanitizedContent|null|string|undefined} */

        var quantitySelectorAdditionalClasses = soy.asserts.assertType(opt_data.quantitySelectorAdditionalClasses == null || goog.isString(opt_data.quantitySelectorAdditionalClasses) || opt_data.quantitySelectorAdditionalClasses instanceof goog.soy.data.SanitizedContent, 'quantitySelectorAdditionalClasses', opt_data.quantitySelectorAdditionalClasses, '!goog.soy.data.SanitizedContent|null|string|undefined');
        /** @type {boolean|null|undefined} */

        var _prevAvailable = soy.asserts.assertType(opt_data._prevAvailable == null || goog.isBoolean(opt_data._prevAvailable) || opt_data._prevAvailable === 1 || opt_data._prevAvailable === 0, '_prevAvailable', opt_data._prevAvailable, 'boolean|null|undefined');
        /** @type {boolean|null|undefined} */

        var _nextAvailable = soy.asserts.assertType(opt_data._nextAvailable == null || goog.isBoolean(opt_data._nextAvailable) || opt_data._nextAvailable === 1 || opt_data._nextAvailable === 0, '_nextAvailable', opt_data._nextAvailable, 'boolean|null|undefined');
        /** @type {*|null|undefined} */

        var _handleFormSubmit = opt_data._handleFormSubmit;
        /** @type {*|null|undefined} */

        var _handleInputKeyUp = opt_data._handleInputKeyUp;
        /** @type {*|null|undefined} */

        var _handleArrowKeys = opt_data._handleArrowKeys;
        /** @type {*|null|undefined} */

        var _handlePrevQuantityButtonPressed = opt_data._handlePrevQuantityButtonPressed;
        /** @type {*|null|undefined} */

        var _handleNextQuantityButtonPressed = opt_data._handleNextQuantityButtonPressed;
        /** @type {*|null|undefined} */

        var _handleSelectOption = opt_data._handleSelectOption;
        var quantitySelectorClasses__soy3595 = '';
        quantitySelectorClasses__soy3595 += 'quantity-selector';
        quantitySelectorClasses__soy3595 += quantitySelectorAdditionalClasses ? ' ' + quantitySelectorAdditionalClasses : '';
        quantitySelectorClasses__soy3595 += disabled ? ' quantity-selector--disabled' : '';
        incrementalDom.elementOpenStart('form');
        incrementalDom.attr('class', quantitySelectorClasses__soy3595);
        incrementalDom.attr('data-onsubmit', _handleFormSubmit);
        incrementalDom.elementOpenEnd();

        if (allowedQuantities != null) {
          var selectAttributes__soy3615 = function selectAttributes__soy3615() {
            incrementalDom.attr('class', 'form-control');
            incrementalDom.attr('data-onchange', _handleSelectOption);

            if (disabled) {
              incrementalDom.attr('disabled', '');
            }
          };

          incrementalDom.elementOpenStart('select');
          selectAttributes__soy3615();
          incrementalDom.elementOpenEnd();
          var option3640List = allowedQuantities;
          var option3640ListLen = option3640List.length;

          for (var option3640Index = 0; option3640Index < option3640ListLen; option3640Index++) {
            var option3640Data = option3640List[option3640Index];

            var optionAttributes__soy3627 = function optionAttributes__soy3627() {
              incrementalDom.attr('value', option3640Data);

              if (option3640Data == quantity) {
                incrementalDom.attr('selected', 'selected');
              }
            };

            incrementalDom.elementOpenStart('option');
            optionAttributes__soy3627();
            incrementalDom.elementOpenEnd();
            soyIdom.print(option3640Data);
            incrementalDom.elementClose('option');
          }

          incrementalDom.elementClose('select');
        } else {
          incrementalDom.elementOpenStart('div');
          incrementalDom.attr('class', 'input-group justify-content-center');
          incrementalDom.elementOpenEnd();
          incrementalDom.elementOpenStart('div');
          incrementalDom.attr('class', 'input-group-item input-group-item-shrink input-group-prepend');
          incrementalDom.elementOpenEnd();
          incrementalDom.elementOpenStart('button');
          incrementalDom.attr('class', 'btn btn-monospaced btn-secondary h-100');
          incrementalDom.attr('type', 'submit');
          incrementalDom.attr('data-onclick', _handlePrevQuantityButtonPressed);

          if (_prevAvailable == false) {
            incrementalDom.attr('disabled', '');
          }

          incrementalDom.elementOpenEnd();
          incrementalDom.text("\u2013");
          incrementalDom.elementClose('button');
          incrementalDom.elementClose('div');
          incrementalDom.elementOpenStart('div');
          incrementalDom.attr('class', 'input-group-item input-group-item-shrink input-group-prepend');
          incrementalDom.elementOpenEnd();
          incrementalDom.elementOpenStart('input');
          incrementalDom.attr('name', 'quantity');
          incrementalDom.attr('type', 'text');
          incrementalDom.attr('class', 'form-control text-center');
          incrementalDom.attr('data-onkeyup', _handleInputKeyUp);
          incrementalDom.attr('data-onkeydown', _handleArrowKeys);

          if (quantity) {
            incrementalDom.attr('value', quantity);
          } else {
            incrementalDom.attr('value', '1');
          }

          if (disabled) {
            incrementalDom.attr('disabled', '');
          }

          incrementalDom.elementOpenEnd();
          incrementalDom.elementClose('input');
          incrementalDom.elementClose('div');
          incrementalDom.elementOpenStart('div');
          incrementalDom.attr('class', 'input-group-append input-group-item input-group-item-shrink');
          incrementalDom.elementOpenEnd();
          incrementalDom.elementOpenStart('button');
          incrementalDom.attr('class', 'btn btn-monospaced btn-secondary h-100');
          incrementalDom.attr('type', 'submit');
          incrementalDom.attr('data-onclick', _handleNextQuantityButtonPressed);

          if (_nextAvailable == false) {
            incrementalDom.attr('disabled', '');
          }

          incrementalDom.elementOpenEnd();
          incrementalDom.text('+');
          incrementalDom.elementClose('button');
          incrementalDom.elementClose('div');
          incrementalDom.elementClose('div');
        }

        incrementalDom.elementClose('form');
      }

      exports.render = $render;
      /**
       * @typedef {{
       *  quantity: (null|number|undefined),
       *  disabled: (boolean|null|undefined),
       *  allowedQuantities: (!Array<number>|null|undefined),
       *  quantitySelectorAdditionalClasses: (!goog.soy.data.SanitizedContent|null|string|undefined),
       *  _prevAvailable: (boolean|null|undefined),
       *  _nextAvailable: (boolean|null|undefined),
       *  _handleFormSubmit: (*|null|undefined),
       *  _handleInputKeyUp: (*|null|undefined),
       *  _handleArrowKeys: (*|null|undefined),
       *  _handlePrevQuantityButtonPressed: (*|null|undefined),
       *  _handleNextQuantityButtonPressed: (*|null|undefined),
       *  _handleSelectOption: (*|null|undefined)
       * }}
       */

      $render.Params;

      if (goog.DEBUG) {
        $render.soyTemplateName = 'QuantitySelector.render';
      }

      exports.render.params = ["quantity", "disabled", "allowedQuantities", "quantitySelectorAdditionalClasses", "_prevAvailable", "_nextAvailable", "_handleFormSubmit", "_handleInputKeyUp", "_handleArrowKeys", "_handlePrevQuantityButtonPressed", "_handleNextQuantityButtonPressed", "_handleSelectOption"];
      exports.render.types = {
        "quantity": "int|null",
        "disabled": "bool",
        "allowedQuantities": "list<number>",
        "quantitySelectorAdditionalClasses": "string",
        "_prevAvailable": "bool",
        "_nextAvailable": "bool",
        "_handleFormSubmit": "any",
        "_handleInputKeyUp": "any",
        "_handleArrowKeys": "any",
        "_handlePrevQuantityButtonPressed": "any",
        "_handleNextQuantityButtonPressed": "any",
        "_handleSelectOption": "any"
      };
      exports.templates = templates = exports;
      return exports;
    });

    var QuantitySelector = /*#__PURE__*/function (_Component) {
      _inherits(QuantitySelector, _Component);

      function QuantitySelector() {
        _classCallCheck(this, QuantitySelector);

        return _possibleConstructorReturn(this, _getPrototypeOf(QuantitySelector).apply(this, arguments));
      }

      return QuantitySelector;
    }(_metalComponent.default);

    exports.QuantitySelector = QuantitySelector;

    _metalSoy.default.register(QuantitySelector, templates);

    var _default = templates;
    /* jshint ignore:end */

    exports.default = _default;
    //# sourceMappingURL=QuantitySelector.soy.js.map
  }
});
//# sourceMappingURL=QuantitySelector.soy.js.map