'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

const index = require('./index-1141a245.js');

const dvnTagCloudCss = "dvn-tag-cloud dvn-button{margin-right:4px}";

function toggleOption(value = [], option) {
  if (value.indexOf(option) > -1) {
    return value.filter(o => o !== option);
  }
  else {
    return [...value, option];
  }
}
const DvnTagCloud = class {
  constructor(hostRef) {
    index.registerInstance(this, hostRef);
    this.change = index.createEvent(this, "change", 7);
    this.editable = false;
    this.value = [];
    this.options = [];
  }
  render() {
    const { disabled, editable, options, value } = this;
    if (editable) {
      return (index.h(index.Host, null, options.map(option => (index.h("dvn-button", { disabled: disabled, leaned: true, scale: "small", shape: "rounded", tint: value.includes(option.value) ? 'primary' : 'neutral', view: value.includes(option.value) ? 'solid' : 'outline', onClick: (e) => {
          e.preventDefault();
          e.stopPropagation();
          this.change.emit(toggleOption(this.value, option.value));
        } }, option.label)))));
    }
    return (index.h(index.Host, null, value.map(v => {
      var _a;
      return (index.h("dvn-button", { leaned: true, scale: "small", shape: "rounded", view: "outline", tagMode: true }, ((_a = options.find(o => o.value === v)) === null || _a === void 0 ? void 0 : _a.label) || v));
    })));
  }
};
DvnTagCloud.style = dvnTagCloudCss;

exports.dvn_tag_cloud = DvnTagCloud;
