import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
var _excluded = ["url", "responseFormatter", "extraBehaviorActions"];
import * as React from "react";
import BehaviorSetter from '@ali/lowcode-setter-behavior';
var defaultExtraBehaviorActions = [];

var LocalBehaviorSetter = /*#__PURE__*/function (_React$Component) {
  _inheritsLoose(LocalBehaviorSetter, _React$Component);

  function LocalBehaviorSetter() {
    return _React$Component.apply(this, arguments) || this;
  }

  var _proto = LocalBehaviorSetter.prototype;

  _proto.render = function render() {
    // ignore url && responseFormatter props, use default ones
    var _this$props = this.props,
        propsUrl = _this$props.url,
        propsFormatter = _this$props.responseFormatter,
        _this$props$extraBeha = _this$props.extraBehaviorActions,
        propsExtraBehaviorActions = _this$props$extraBeha === void 0 ? [] : _this$props$extraBeha,
        otherProps = _objectWithoutPropertiesLoose(_this$props, _excluded);

    var url = 'https://hn.algolia.com/api/v1/search?query';

    var responseFormatter = function responseFormatter(response) {
      return response.hits.map(function (item) {
        return {
          label: item.title,
          value: item.author
        };
      });
    };

    var extraBehaviorActions = propsExtraBehaviorActions.concat(defaultExtraBehaviorActions);
    return /*#__PURE__*/React.createElement(BehaviorSetter, _extends({}, otherProps, {
      url: url,
      responseFormatter: responseFormatter,
      extraBehaviorActions: extraBehaviorActions
    }));
  };

  return LocalBehaviorSetter;
}(React.Component);

export default LocalBehaviorSetter;