'use strict';

Liferay.Loader.define('frontend-taglib-clay$clay-dropdown@2.24.1/lib/ClayCreationMenuDropdown.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.templates = exports.ClayCreationMenuDropdown = undefined;

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

    var _metalComponent2 = _interopRequireDefault(_metalComponent);

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

    var _metalSoy2 = _interopRequireDefault(_metalSoy);

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

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

    function _possibleConstructorReturn(self, call) {
      if (!self) {
        throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
      }return call && (typeof call === "object" || typeof call === "function") ? call : self;
    }

    function _inherits(subClass, superClass) {
      if (typeof superClass !== "function" && superClass !== null) {
        throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
      }subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } });if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
    } /* jshint ignore:start */

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

      goog.require('soydata');

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

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

      goog.module('ClayCreationMenuDropdown.incrementaldom');

      goog.require('goog.soy.data.SanitizedContent');
      goog.require('goog.string');
      var incrementalDom = goog.require('incrementaldom');
      goog.require('soy.asserts');
      var soyIdom = goog.require('soy.idom');

      var $templateAlias2 = _metalSoy2.default.getTemplate('ClayDropdownBase.incrementaldom', 'render');

      var $templateAlias1 = _metalSoy2.default.getTemplate('ClayIcon.incrementaldom', 'render');

      /**
       * @param {{
       *  spritemap: (!goog.soy.data.SanitizedContent|string),
       *  _handleButtonClick: (*|null|undefined),
       *  _handleItemClick: (*|null|undefined),
       *  disabled: (boolean|null|undefined),
       *  elementClasses: (!goog.soy.data.SanitizedContent|null|string|undefined),
       *  expanded: (boolean|null|undefined),
       *  helpText: (!goog.soy.data.SanitizedContent|null|string|undefined),
       *  id: (!goog.soy.data.SanitizedContent|null|string|undefined),
       *  itemsIconAlignment: (!goog.soy.data.SanitizedContent|null|string|undefined),
       *  maxPrimaryItems: (null|number|undefined),
       *  maxSecondaryItems: (null|number|undefined),
       *  maxTotalItems: (null|number|undefined),
       *  preferredAlign: (!goog.soy.data.SanitizedContent|null|string|undefined),
       *  primaryItems: (!Array<?>|null|undefined),
       *  secondaryItems: (!Array<?>|null|undefined),
       *  toggle: (*|null|undefined),
       *  triggerAriaLabel: (!goog.soy.data.SanitizedContent|null|string|undefined),
       *  triggerClasses: (!goog.soy.data.SanitizedContent|null|string|undefined),
       *  triggerTitle: (!goog.soy.data.SanitizedContent|null|string|undefined),
       *  viewMoreURL: (!goog.soy.data.SanitizedContent|null|string|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;
        var $$temp;
        /** @type {!goog.soy.data.SanitizedContent|string} */
        var spritemap = soy.asserts.assertType(goog.isString(opt_data.spritemap) || opt_data.spritemap instanceof goog.soy.data.SanitizedContent, 'spritemap', opt_data.spritemap, '!goog.soy.data.SanitizedContent|string');
        /** @type {*|null|undefined} */
        var _handleButtonClick = opt_data._handleButtonClick;
        /** @type {*|null|undefined} */
        var _handleItemClick = opt_data._handleItemClick;
        /** @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 {!goog.soy.data.SanitizedContent|null|string|undefined} */
        var elementClasses = soy.asserts.assertType(opt_data.elementClasses == null || goog.isString(opt_data.elementClasses) || opt_data.elementClasses instanceof goog.soy.data.SanitizedContent, 'elementClasses', opt_data.elementClasses, '!goog.soy.data.SanitizedContent|null|string|undefined');
        /** @type {boolean|null|undefined} */
        var expanded = soy.asserts.assertType(opt_data.expanded == null || goog.isBoolean(opt_data.expanded) || opt_data.expanded === 1 || opt_data.expanded === 0, 'expanded', opt_data.expanded, 'boolean|null|undefined');
        /** @type {!goog.soy.data.SanitizedContent|null|string|undefined} */
        var helpText = soy.asserts.assertType(opt_data.helpText == null || goog.isString(opt_data.helpText) || opt_data.helpText instanceof goog.soy.data.SanitizedContent, 'helpText', opt_data.helpText, '!goog.soy.data.SanitizedContent|null|string|undefined');
        /** @type {!goog.soy.data.SanitizedContent|null|string|undefined} */
        var id = soy.asserts.assertType(opt_data.id == null || goog.isString(opt_data.id) || opt_data.id instanceof goog.soy.data.SanitizedContent, 'id', opt_data.id, '!goog.soy.data.SanitizedContent|null|string|undefined');
        /** @type {!goog.soy.data.SanitizedContent|null|string|undefined} */
        var itemsIconAlignment = soy.asserts.assertType(opt_data.itemsIconAlignment == null || goog.isString(opt_data.itemsIconAlignment) || opt_data.itemsIconAlignment instanceof goog.soy.data.SanitizedContent, 'itemsIconAlignment', opt_data.itemsIconAlignment, '!goog.soy.data.SanitizedContent|null|string|undefined');
        /** @type {null|number|undefined} */
        var maxPrimaryItems = soy.asserts.assertType(opt_data.maxPrimaryItems == null || goog.isNumber(opt_data.maxPrimaryItems), 'maxPrimaryItems', opt_data.maxPrimaryItems, 'null|number|undefined');
        /** @type {null|number|undefined} */
        var maxSecondaryItems = soy.asserts.assertType(opt_data.maxSecondaryItems == null || goog.isNumber(opt_data.maxSecondaryItems), 'maxSecondaryItems', opt_data.maxSecondaryItems, 'null|number|undefined');
        /** @type {null|number|undefined} */
        var maxTotalItems = soy.asserts.assertType(opt_data.maxTotalItems == null || goog.isNumber(opt_data.maxTotalItems), 'maxTotalItems', opt_data.maxTotalItems, 'null|number|undefined');
        /** @type {!goog.soy.data.SanitizedContent|null|string|undefined} */
        var preferredAlign = soy.asserts.assertType(opt_data.preferredAlign == null || goog.isString(opt_data.preferredAlign) || opt_data.preferredAlign instanceof goog.soy.data.SanitizedContent, 'preferredAlign', opt_data.preferredAlign, '!goog.soy.data.SanitizedContent|null|string|undefined');
        /** @type {!Array<?>|null|undefined} */
        var primaryItems = soy.asserts.assertType(opt_data.primaryItems == null || goog.isArray(opt_data.primaryItems), 'primaryItems', opt_data.primaryItems, '!Array<?>|null|undefined');
        /** @type {!Array<?>|null|undefined} */
        var secondaryItems = soy.asserts.assertType(opt_data.secondaryItems == null || goog.isArray(opt_data.secondaryItems), 'secondaryItems', opt_data.secondaryItems, '!Array<?>|null|undefined');
        /** @type {*|null|undefined} */
        var toggle = opt_data.toggle;
        /** @type {!goog.soy.data.SanitizedContent|null|string|undefined} */
        var triggerAriaLabel = soy.asserts.assertType(opt_data.triggerAriaLabel == null || goog.isString(opt_data.triggerAriaLabel) || opt_data.triggerAriaLabel instanceof goog.soy.data.SanitizedContent, 'triggerAriaLabel', opt_data.triggerAriaLabel, '!goog.soy.data.SanitizedContent|null|string|undefined');
        /** @type {!goog.soy.data.SanitizedContent|null|string|undefined} */
        var triggerClasses = soy.asserts.assertType(opt_data.triggerClasses == null || goog.isString(opt_data.triggerClasses) || opt_data.triggerClasses instanceof goog.soy.data.SanitizedContent, 'triggerClasses', opt_data.triggerClasses, '!goog.soy.data.SanitizedContent|null|string|undefined');
        /** @type {!goog.soy.data.SanitizedContent|null|string|undefined} */
        var triggerTitle = soy.asserts.assertType(opt_data.triggerTitle == null || goog.isString(opt_data.triggerTitle) || opt_data.triggerTitle instanceof goog.soy.data.SanitizedContent, 'triggerTitle', opt_data.triggerTitle, '!goog.soy.data.SanitizedContent|null|string|undefined');
        /** @type {!goog.soy.data.SanitizedContent|null|string|undefined} */
        var viewMoreURL = soy.asserts.assertType(opt_data.viewMoreURL == null || goog.isString(opt_data.viewMoreURL) || opt_data.viewMoreURL instanceof goog.soy.data.SanitizedContent, 'viewMoreURL', opt_data.viewMoreURL, '!goog.soy.data.SanitizedContent|null|string|undefined');
        var msg_2479__soy2480 = '';
        /** @desc  */
        var MSG_EXTERNAL_7011425206383801543 = Liferay.Language.get('more');
        msg_2479__soy2480 += MSG_EXTERNAL_7011425206383801543;
        var secondaryItemsFirstGroup__soy93 = secondaryItems != null ? secondaryItems[0] != null ? secondaryItems[0] : null : null;
        var secondaryItemsSecondGroup__soy95 = secondaryItems != null ? secondaryItems[1] != null ? secondaryItems[1] : null : null;
        var totalPrimaryItems__soy97 = primaryItems ? primaryItems.length : 0;
        var totalSecondaryItemsFirstGroup__soy99 = secondaryItemsFirstGroup__soy93 != null && secondaryItemsFirstGroup__soy93.items != null ? secondaryItemsFirstGroup__soy93.items.length : 0;
        var totalSecondaryItemsSecondGroup__soy101 = secondaryItemsSecondGroup__soy95 != null && secondaryItemsSecondGroup__soy95.items != null ? secondaryItemsSecondGroup__soy95.items.length : 0;
        var totalSecondaryItems__soy103 = totalSecondaryItemsFirstGroup__soy99 + totalSecondaryItemsSecondGroup__soy101;
        var totalItems__soy105 = totalPrimaryItems__soy97 + totalSecondaryItems__soy103;
        var defaultMaxPrimaryItems__soy107 = maxPrimaryItems ? totalPrimaryItems__soy97 > maxPrimaryItems ? maxPrimaryItems : totalPrimaryItems__soy97 : totalPrimaryItems__soy97 > 8 ? 8 : totalPrimaryItems__soy97;
        var tempDefaultMaxSecondaryItems__soy109 = maxSecondaryItems ? totalSecondaryItems__soy103 > maxSecondaryItems ? maxSecondaryItems : totalSecondaryItems__soy103 : totalSecondaryItems__soy103 > 7 ? 7 : totalSecondaryItems__soy103;
        var defaultMaxTotalItems__soy111 = ($$temp = maxTotalItems) == null ? 15 : $$temp;
        var defaultMaxSecondaryItems__soy113 = tempDefaultMaxSecondaryItems__soy109 > defaultMaxTotalItems__soy111 - defaultMaxPrimaryItems__soy107 ? defaultMaxTotalItems__soy111 - defaultMaxPrimaryItems__soy107 : tempDefaultMaxSecondaryItems__soy109;
        var showingItems__soy115 = totalSecondaryItems__soy103 == 0 ? totalPrimaryItems__soy97 > defaultMaxTotalItems__soy111 ? defaultMaxTotalItems__soy111 : totalPrimaryItems__soy97 : totalPrimaryItems__soy97 > defaultMaxPrimaryItems__soy107 ? totalSecondaryItems__soy103 > defaultMaxSecondaryItems__soy113 ? defaultMaxPrimaryItems__soy107 + defaultMaxSecondaryItems__soy113 : defaultMaxPrimaryItems__soy107 + totalSecondaryItems__soy103 : totalSecondaryItems__soy103 > defaultMaxSecondaryItems__soy113 ? totalPrimaryItems__soy97 + defaultMaxSecondaryItems__soy113 : totalPrimaryItems__soy97 + totalSecondaryItems__soy103;
        var primaryDropdownItems__soy117 = { items: primaryItems, maxItems: totalSecondaryItems__soy103 > 0 ? defaultMaxPrimaryItems__soy107 : defaultMaxTotalItems__soy111, separator: totalPrimaryItems__soy97 > 0 && totalSecondaryItems__soy103 > 0, type: 'group' };
        var secondaryDropdownItemsSecondGroup__soy119 = secondaryItemsSecondGroup__soy95 && totalSecondaryItemsFirstGroup__soy99 < defaultMaxSecondaryItems__soy113 ? { items: secondaryItemsSecondGroup__soy95.items, label: secondaryItemsSecondGroup__soy95.label, maxItems: defaultMaxSecondaryItems__soy113 - totalSecondaryItemsFirstGroup__soy99, type: 'group' } : null;
        var secondaryDropdownItemsFirstGroup__soy121 = secondaryItemsFirstGroup__soy93 ? { items: secondaryItemsFirstGroup__soy93.items, label: secondaryItemsFirstGroup__soy93.label, maxItems: defaultMaxSecondaryItems__soy113, separator: secondaryItemsFirstGroup__soy93.separator && secondaryDropdownItemsSecondGroup__soy119 != null, type: 'group' } : null;
        var items__soy123 = secondaryDropdownItemsFirstGroup__soy121 && secondaryDropdownItemsSecondGroup__soy119 ? [primaryDropdownItems__soy117, secondaryDropdownItemsFirstGroup__soy121, secondaryDropdownItemsSecondGroup__soy119] : secondaryDropdownItemsFirstGroup__soy121 ? [primaryDropdownItems__soy117, secondaryDropdownItemsFirstGroup__soy121] : [primaryDropdownItems__soy117];
        var textMore__soy125 = '';
        textMore__soy125 += msg_2479__soy2480;
        var showMoreButton__soy133 = showingItems__soy115 < totalItems__soy105 ? viewMoreURL != null ? { buttonStyle: 'secondary', href: viewMoreURL, label: textMore__soy125 } : { label: textMore__soy125, style: 'secondary' } : null;
        var trigger__soy135 = function trigger__soy135() {
          $templateAlias1({ spritemap: spritemap, symbol: 'plus' }, null, opt_ijData);
        };

        var param176 = '';
        if (triggerTitle) {
          param176 += triggerTitle;
        } else {
          var msg_2482__soy2483 = '';
          /** @desc  */
          var MSG_EXTERNAL_7387635272539030076 = Liferay.Language.get('new');
          msg_2482__soy2483 += MSG_EXTERNAL_7387635272539030076;
          param176 += msg_2482__soy2483;
        }
        $templateAlias2({ button: showMoreButton__soy133, caption: function param144() {
            if (showMoreButton__soy133) {
              /** @desc Says how many items of the total are being showed */
              var MSG_EXTERNAL_8004490453579465583 = Liferay.Language.get('showing-x-of-x-elements');
	MSG_EXTERNAL_8004490453579465583 = MSG_EXTERNAL_8004490453579465583.replace(/{(\d+)}/g, '\x01$1\x01');

              var lastIndex_149 = 0,
                  partRe_149 = /\x01\d+\x01/g,
                  match_149;
              do {
                match_149 = partRe_149.exec(MSG_EXTERNAL_8004490453579465583) || undefined;
                incrementalDom.text(goog.string.unescapeEntities(MSG_EXTERNAL_8004490453579465583.substring(lastIndex_149, match_149 && match_149.index)));
                lastIndex_149 = partRe_149.lastIndex;
                switch (match_149 && match_149[0]) {
                  case '\x011\x01':
                    soyIdom.print(totalItems__soy105);
                    break;
                  case '\x010\x01':
                    soyIdom.print(showingItems__soy115);
                    break;
                }
              } while (match_149);
            }
          }, disabled: disabled, elementClasses: elementClasses, events: { buttonClicked: _handleButtonClick, itemClicked: _handleItemClick, toggle: toggle }, expanded: expanded, helpText: showMoreButton__soy133 ? helpText : null, id: id, items: items__soy123, itemsIconAlignment: itemsIconAlignment, label: trigger__soy135, preferredAlign: preferredAlign, ref: 'dropdown', spritemap: spritemap, style: 'primary', triggerAriaLabel: triggerAriaLabel, triggerClasses: triggerClasses, triggerTitle: param176 }, null, opt_ijData);
      }
      exports.render = $render;
      /**
       * @typedef {{
       *  spritemap: (!goog.soy.data.SanitizedContent|string),
       *  _handleButtonClick: (*|null|undefined),
       *  _handleItemClick: (*|null|undefined),
       *  disabled: (boolean|null|undefined),
       *  elementClasses: (!goog.soy.data.SanitizedContent|null|string|undefined),
       *  expanded: (boolean|null|undefined),
       *  helpText: (!goog.soy.data.SanitizedContent|null|string|undefined),
       *  id: (!goog.soy.data.SanitizedContent|null|string|undefined),
       *  itemsIconAlignment: (!goog.soy.data.SanitizedContent|null|string|undefined),
       *  maxPrimaryItems: (null|number|undefined),
       *  maxSecondaryItems: (null|number|undefined),
       *  maxTotalItems: (null|number|undefined),
       *  preferredAlign: (!goog.soy.data.SanitizedContent|null|string|undefined),
       *  primaryItems: (!Array<?>|null|undefined),
       *  secondaryItems: (!Array<?>|null|undefined),
       *  toggle: (*|null|undefined),
       *  triggerAriaLabel: (!goog.soy.data.SanitizedContent|null|string|undefined),
       *  triggerClasses: (!goog.soy.data.SanitizedContent|null|string|undefined),
       *  triggerTitle: (!goog.soy.data.SanitizedContent|null|string|undefined),
       *  viewMoreURL: (!goog.soy.data.SanitizedContent|null|string|undefined)
       * }}
       */
      $render.Params;
      if (goog.DEBUG) {
        $render.soyTemplateName = 'ClayCreationMenuDropdown.render';
      }

      exports.render.params = ["spritemap", "_handleButtonClick", "_handleItemClick", "disabled", "elementClasses", "expanded", "helpText", "id", "itemsIconAlignment", "maxPrimaryItems", "maxSecondaryItems", "maxTotalItems", "preferredAlign", "primaryItems", "secondaryItems", "toggle", "triggerAriaLabel", "triggerClasses", "triggerTitle", "viewMoreURL"];
      exports.render.types = { "spritemap": "string", "_handleButtonClick": "any", "_handleItemClick": "any", "disabled": "bool", "elementClasses": "string", "expanded": "bool", "helpText": "string", "id": "string", "itemsIconAlignment": "string", "maxPrimaryItems": "int", "maxSecondaryItems": "int", "maxTotalItems": "int", "preferredAlign": "string", "primaryItems": "list<?>", "secondaryItems": "list<?>", "toggle": "any", "triggerAriaLabel": "string", "triggerClasses": "string", "triggerTitle": "string", "viewMoreURL": "string" };
      exports.templates = templates = exports;
      return exports;
    });

    var ClayCreationMenuDropdown = function (_Component) {
      _inherits(ClayCreationMenuDropdown, _Component);

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

        return _possibleConstructorReturn(this, (ClayCreationMenuDropdown.__proto__ || Object.getPrototypeOf(ClayCreationMenuDropdown)).apply(this, arguments));
      }

      return ClayCreationMenuDropdown;
    }(_metalComponent2.default);

    _metalSoy2.default.register(ClayCreationMenuDropdown, templates);
    exports.ClayCreationMenuDropdown = ClayCreationMenuDropdown;
    exports.templates = templates;
    exports.default = templates;
    /* jshint ignore:end */
    //# sourceMappingURL=ClayCreationMenuDropdown.soy.js.map
  }
});
//# sourceMappingURL=ClayCreationMenuDropdown.soy.js.map