'use strict';

Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });

const lit = require('lit');
const decorators_js = require('lit/decorators.js');
const unsafeHtml_js = require('lit/directives/unsafe-html.js');
const DOMPurify = require('dompurify');
const safeCustomElement = require('../../shared/safe-custom-element.cjs');
const index = require('../../shared/tailwind-element/index.cjs');
const style = require('./style.css.cjs');

var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __decorateClass = (decorators, target, key, kind) => {
  var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
    if (decorator = decorators[i])
      result = (kind ? decorator(target, key, result) : decorator(result)) || result;
  if (kind && result) __defProp(target, key, result);
  return result;
};
const DEFAULT_OPTIONS = {
  ADD_ATTR: ["target"],
  // allow target attribute on anchor tags
  CUSTOM_ELEMENT_HANDLING: {
    tagNameCheck: /^lukso-/,
    attributeNameCheck: /.*/
  }
};
const NO_HTML_TAGS_OPTIONS = { ALLOWED_TAGS: [] };
exports.LuksoSanitize = class LuksoSanitize extends index.TailwindStyledElement(style) {
  constructor() {
    super(...arguments);
    this.htmlContent = "";
    this.isPre = false;
    this.stripHtmlTags = false;
  }
  sanitize() {
    if (this.stripHtmlTags) {
      return DOMPurify.sanitize(this.htmlContent, NO_HTML_TAGS_OPTIONS);
    }
    return DOMPurify.sanitize(this.htmlContent, DEFAULT_OPTIONS);
  }
  // in order to show HTML we  need to use unsafeHTML directive.
  // This is safe since we already sanitized content
  render() {
    return this.isPre ? lit.html`<!-- prettier-ignore -->
          <div
      class='whitespace-pre-wrap'>${unsafeHtml_js.unsafeHTML(this.sanitize())}</div>` : lit.html`${unsafeHtml_js.unsafeHTML(this.sanitize())}`;
  }
};
__decorateClass([
  decorators_js.property({ type: String, attribute: "html-content" })
], exports.LuksoSanitize.prototype, "htmlContent", 2);
__decorateClass([
  decorators_js.property({ type: Boolean, attribute: "is-pre" })
], exports.LuksoSanitize.prototype, "isPre", 2);
__decorateClass([
  decorators_js.property({ type: Boolean, attribute: "strip-html-tags" })
], exports.LuksoSanitize.prototype, "stripHtmlTags", 2);
exports.LuksoSanitize = __decorateClass([
  safeCustomElement.safeCustomElement("lukso-sanitize")
], exports.LuksoSanitize);

exports.DEFAULT_OPTIONS = DEFAULT_OPTIONS;
exports.NO_HTML_TAGS_OPTIONS = NO_HTML_TAGS_OPTIONS;
