"use strict";

function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = exports.WithTypePrimaryAndChevronAndLeftBadgeIcon = exports.WithTypePrimaryAndChevron = exports.WithStyledContent = exports.WithRightAddon = exports.WithDisabledBackgroundColor = exports.WithDifferentPaddings = exports.WithChevron = exports.TextOnlyContentIsFormattedCorrect = exports.Expanded = exports.Disabled = exports.DefaultCollapsed = exports.Controlled = void 0;
var _react = _interopRequireWildcard(require("react"));
var _styledComponents = _interopRequireDefault(require("styled-components"));
var _ = require("../..");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
var _default = exports.default = {
  title: 'Molecules / AccordionItem',
  parameters: {
    component: _.AccordionItem
  }
};
var StyledAccordionItem = (0, _styledComponents.default)(_.AccordionItem).withConfig({
  displayName: "AccordionItemstories__StyledAccordionItem",
  componentId: "sc-xlwwg8-0"
})(["", "{padding-left:", "px;}"], _.AccordionItem.components.Content, function (p) {
  return p.theme.spacing.unit(20);
});
var ExampleContent = function ExampleContent() {
  return _react.default.createElement(_.Typography, {
    as: "p",
    type: "secondary",
    color: function color(t) {
      return t.color.accordionText;
    }
  }, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat");
};
var DefaultCollapsed = exports.DefaultCollapsed = function DefaultCollapsed() {
  return _react.default.createElement(_.AccordionItem, {
    title: "Lemon drops and several cakes for two persons or more"
  }, _react.default.createElement(ExampleContent, null));
};
var Expanded = exports.Expanded = function Expanded() {
  return _react.default.createElement(_.AccordionItem, {
    title: "L\xE5g CO\u2082 risk",
    expandedInitial: true
  }, _react.default.createElement(ExampleContent, null));
};
var WithStyledContent = exports.WithStyledContent = function WithStyledContent() {
  return _react.default.createElement(StyledAccordionItem, {
    title: "Sustainability score"
  }, _react.default.createElement(ExampleContent, null));
};
var Controlled = exports.Controlled = function Controlled() {
  var ControlledExample = function ControlledExample() {
    var _useState = (0, _react.useState)([]),
      _useState2 = _slicedToArray(_useState, 2),
      expandedAreas = _useState2[0],
      setExpandedAreas = _useState2[1];
    var clickHandler = function clickHandler(id) {
      if (expandedAreas.includes(id)) {
        var removed = expandedAreas.filter(function (x) {
          return x !== id;
        });
        setExpandedAreas(_toConsumableArray(removed));
      } else {
        setExpandedAreas([].concat(_toConsumableArray(expandedAreas), [id]));
      }
    };
    return _react.default.createElement(_react.default.Fragment, null, _react.default.createElement(_.Box, {
      mb: 4
    }, _react.default.createElement(_.Flexbox, {
      container: true,
      gap: 4
    }, _react.default.createElement(_.Flexbox, {
      item: true
    }, _react.default.createElement(_.Button, {
      variant: "primary",
      onClick: function onClick() {
        return clickHandler('first');
      }
    }, "Toggle first")), _react.default.createElement(_.Flexbox, {
      item: true
    }, _react.default.createElement(_.Button, {
      variant: "primary",
      onClick: function onClick() {
        return clickHandler('second');
      }
    }, "Toggle second")))), _react.default.createElement(_.AccordionItem, {
      title: "L\xE5g CO\u2082 risk",
      expanded: expandedAreas.includes('first'),
      onClick: function onClick() {
        return clickHandler('first');
      }
    }, _react.default.createElement(ExampleContent, null)), _react.default.createElement(_.AccordionItem, {
      title: "Sustainability score",
      expanded: expandedAreas.includes('second'),
      onClick: function onClick() {
        return clickHandler('second');
      }
    }, _react.default.createElement(ExampleContent, null)));
  };
  return _react.default.createElement(ControlledExample, null);
};
var TextOnlyContentIsFormattedCorrect = exports.TextOnlyContentIsFormattedCorrect = function TextOnlyContentIsFormattedCorrect() {
  return _react.default.createElement(_react.default.Fragment, null, _react.default.createElement(_.AccordionItem, {
    title: "Content is text only"
  }, "Plain vanilla text content"), _react.default.createElement(_.AccordionItem, {
    title: "Content is a component"
  }, _react.default.createElement("div", null, "Content is wrapped in a div and does not get default text styling")));
};
var WithChevron = exports.WithChevron = function WithChevron() {
  return _react.default.createElement(_.AccordionItem, {
    withChevron: true,
    title: "How much risk are you willing to take?"
  }, _react.default.createElement(ExampleContent, null));
};
var WithTypePrimaryAndChevron = exports.WithTypePrimaryAndChevron = function WithTypePrimaryAndChevron() {
  return _react.default.createElement(_.AccordionItem, {
    type: "primary",
    withChevron: true,
    title: "How much risk are you willing to take?"
  }, _react.default.createElement(ExampleContent, null));
};
var WithTypePrimaryAndChevronAndLeftBadgeIcon = exports.WithTypePrimaryAndChevronAndLeftBadgeIcon = function WithTypePrimaryAndChevronAndLeftBadgeIcon() {
  return _react.default.createElement(_.AccordionItem, {
    disableFocusOutline: true,
    disableBackgroundColor: true,
    type: "primary",
    withChevron: true,
    title: "Leverage products without stop loss",
    label: "Valid until 2023-12-31",
    leftBadgeIcon: _react.default.createElement(_.Badge.Icon, {
      badgeColor: function badgeColor(t) {
        return t.color.badgeBackground;
      },
      badgeSize: "s"
    }, _react.default.createElement(_.Icon.Warning16, {
      color: function color(t) {
        return t.color.badgeIconColor;
      }
    }), ' ')
  }, _react.default.createElement(ExampleContent, null));
};
var WithRightAddon = exports.WithRightAddon = function WithRightAddon() {
  return _react.default.createElement(_.AccordionItem, {
    title: "How much risk are you willing to take?",
    rightAddon: _react.default.createElement(_.Button.Pill, {
      onClick: function onClick() {}
    }, "right addon")
  }, _react.default.createElement(ExampleContent, null));
};
var WithDisabledBackgroundColor = exports.WithDisabledBackgroundColor = function WithDisabledBackgroundColor() {
  return _react.default.createElement(_.AccordionItem, {
    title: "This card has its hover and focus color disabled",
    disableBackgroundColor: true
  }, _react.default.createElement(ExampleContent, null));
};
var WithDifferentPaddings = exports.WithDifferentPaddings = function WithDifferentPaddings() {
  return _react.default.createElement(_react.default.Fragment, null, _react.default.createElement(_.AccordionItem, {
    title: "This accordion item has a custom padding",
    p: 10
  }, _react.default.createElement(ExampleContent, null)), _react.default.createElement(_.AccordionItem, {
    title: "This accordion item has a custom horizontal padding",
    px: 20
  }, _react.default.createElement(ExampleContent, null)), _react.default.createElement(_.AccordionItem, {
    title: "This accordion item has a custom vertical padding",
    py: 10
  }, _react.default.createElement(ExampleContent, null)), _react.default.createElement(_.AccordionItem, {
    title: "This accordion item has a custom top padding",
    pt: 10
  }, _react.default.createElement(ExampleContent, null)), _react.default.createElement(_.AccordionItem, {
    title: "This accordion item has a custom bottom padding",
    pb: 10
  }, _react.default.createElement(ExampleContent, null)), _react.default.createElement(_.AccordionItem, {
    title: "This accordion item has a custom left padding",
    pl: 20
  }, _react.default.createElement(ExampleContent, null)), _react.default.createElement(_.AccordionItem, {
    title: "This accordion item has a custom right padding and chevron to demonstrate",
    pr: 20,
    withChevron: true
  }, _react.default.createElement(ExampleContent, null)));
};
var Disabled = exports.Disabled = function Disabled() {
  return _react.default.createElement(_react.default.Fragment, null, _react.default.createElement(_.AccordionItem, {
    title: "This accordion item is disabled",
    disabled: true
  }, _react.default.createElement(ExampleContent, null)), _react.default.createElement(_.AccordionItem, {
    title: "This accordion item is disabled with chevron",
    disabled: true,
    withChevron: true
  }, _react.default.createElement(ExampleContent, null)));
};