'use strict';

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

const index = require('./index-bb72bde3.js');
require('./common-a086c7ac.js');
require('./IntersectionHelper-16aa1ea1.js');
const Heading = require('./Heading-f7728cfd.js');
const Paragraph = require('./Paragraph-9df20a65.js');
require('./_commonjsHelpers-2e75ad90.js');
const index$1 = require('./index-4028a94b.js');
const PrismicResponsiveImage = require('./PrismicResponsiveImage-a8b65d5b.js');
require('./prismic-javascript.min-7ccc1fcb.js');
const prismic = require('./prismic-b998d186.js');
const tools = require('./tools-e30631c9.js');

const resourceTypeToPath = (type) => ({
  [prismic.ResourceType.Article]: 'articles',
  [prismic.ResourceType.Blog]: 'blogs',
  [prismic.ResourceType.Book]: 'books',
  [prismic.ResourceType.CaseStudy]: 'case-studies',
  [prismic.ResourceType.Course]: 'courses',
  [prismic.ResourceType.CustomerInterview]: 'customer-interviews',
  [prismic.ResourceType.Doc]: 'docs',
  [prismic.ResourceType.Guide]: 'guides',
  [prismic.ResourceType.Learning]: 'learning',
  [prismic.ResourceType.Podcast]: 'podcasts',
  [prismic.ResourceType.Tutorial]: 'tutorials',
  [prismic.ResourceType.Video]: 'videos',
  [prismic.ResourceType.Webinar]: 'webinars',
  [prismic.ResourceType.Whitepaper]: 'whitepapers',
}[type]);

const resourceCardCss = ".column.sc-resource-card-h{--image-height:176px;display:flex;flex-direction:column;height:100%}.column.sc-resource-card-h:hover img.sc-resource-card,.column.sc-resource-card-h:active img.sc-resource-card,.column.sc-resource-card-h:focus img.sc-resource-card{transform:scale(1.05)}.column.sc-resource-card-h img.sc-resource-card{display:block}.column.sc-resource-card-h .contents-wrapper.sc-resource-card{display:flex;flex-direction:column;height:100%}.column.sc-resource-card-h .image-wrapper.sc-resource-card{display:block;margin-block-end:var(--space-5);height:var(--image-height);overflow:hidden}.column.sc-resource-card-h .image-wrapper.sc-resource-card img.sc-resource-card{display:block;height:var(--image-height);object-fit:cover;transition:transform 200ms cubic-bezier(0.32, 0.72, 0, 1)}.column.sc-resource-card-h .content.sc-resource-card{display:flex;flex-grow:1;flex-direction:column}.column.sc-resource-card-h .content.sc-resource-card .meta.sc-resource-card{display:flex;overflow:hidden;margin-block-end:var(--space-3)}.column.sc-resource-card-h .content.sc-resource-card .meta.sc-resource-card .type.sc-resource-card{margin-inline-end:var(--space-4)}.column.sc-resource-card-h .content.sc-resource-card .title.sc-resource-card{color:#010610}.column.sc-resource-card-h .content.sc-resource-card .description.sc-resource-card{color:var(--c-indigo-80);margin-block-start:var(--space-2)}.row.sc-resource-card-h{--image-height:100%}.row.sc-resource-card-h .contents-wrapper.sc-resource-card{display:flex}.row.sc-resource-card-h .image-wrapper.sc-resource-card{flex-basis:60%;min-height:var(--image-height)}.row.sc-resource-card-h .image-wrapper.sc-resource-card img.sc-resource-card{height:100%;object-fit:cover}.row.sc-resource-card-h .content.sc-resource-card{flex-basis:40%;margin-inline-start:var(--space-9)}.row.sc-resource-card-h .content.sc-resource-card .meta.sc-resource-card{margin-block-start:0;margin-block-end:40px}.row.sc-resource-card-h .content.sc-resource-card .description.sc-resource-card{margin-block-start:var(--space-4)}@media screen and (max-width: 767px){.row.sc-resource-card-h .contents-wrapper.sc-resource-card{flex-direction:column}.row.sc-resource-card-h .content.sc-resource-card{margin-inline-start:0}.row.sc-resource-card-h .content.sc-resource-card .meta.sc-resource-card{display:flex;margin-block-start:var(--space-5);margin-block-end:var(--space-3);overflow:hidden}.row.sc-resource-card-h .content.sc-resource-card .meta.sc-resource-card .type.sc-resource-card{margin-inline-end:var(--space-4)}}.description.sc-resource-card{margin-block-end:0}.author.sc-resource-card{flex-grow:1;display:flex;align-items:flex-end}.author.sc-resource-card resource-author-item.sc-resource-card{margin-block-start:46px;justify-self:flex-end}";

var __classPrivateFieldGet = (undefined && undefined.__classPrivateFieldGet) || function (receiver, privateMap) {
  if (!privateMap.has(receiver)) {
    throw new TypeError("attempted to get private field on non-instance");
  }
  return privateMap.get(receiver);
};
var __classPrivateFieldSet = (undefined && undefined.__classPrivateFieldSet) || function (receiver, privateMap, value) {
  if (!privateMap.has(receiver)) {
    throw new TypeError("attempted to set private field on non-instance");
  }
  privateMap.set(receiver, value);
  return value;
};
var _url, _sameSite, _defaults;
const ResourceCard = class {
  constructor(hostRef) {
    index.registerInstance(this, hostRef);
    this.row = false;
    this.headingLevel = 4;
    this.type = true;
    this.tags = true;
    this.author = true;
    this.description = true;
    _url.set(this, void 0);
    _sameSite.set(this, void 0);
    _defaults.set(this, {
      routing: {
        includeType: true,
        base: ''
      }
    });
    this.SameSiteCard = () => {
      const { CardContents } = this;
      return (index.h("a", Object.assign({ class: "contents-wrapper" }, index$1.href(__classPrivateFieldGet(this, _url), this.routing.router)), index.h(CardContents, null)));
    };
    this.ExternalCard = () => {
      const { CardContents } = this;
      return (index.h("a", { class: "contents-wrapper", href: __classPrivateFieldGet(this, _url), target: "_blank", rel: "noopener" }, index.h(CardContents, null)));
    };
    this.CardContents = () => {
      const { title, description, type, tags, doc: { data: { hero_image } } } = this.prismicData;
      const hasDescriptors = this.type || (tags && this.tags);
      const authors = prismic.getAuthorsForPrismicDoc(this.prismicData.doc);
      const hasAuthors = this.author && authors.length > 0;
      return [
        index.h("div", { class: "image-wrapper" }, index.h(PrismicResponsiveImage.PrismicResponsiveImage, { image: hero_image })),
        index.h("div", { class: "content" }, hasDescriptors
          ? index.h("div", { class: "meta" }, this.type
            ? index.h(Heading.Heading, { class: "type | ui-theme--editorial", level: 6 }, type)
            : null, tags && this.tags
            ? index.h("resource-meta", { class: "ui-theme--editorial", tags: tags })
            : null)
          : null, index.h(Heading.Heading, { class: "title | ui-theme--editorial", level: this.headingLevel }, title), this.description
          ? index.h(Paragraph.Paragraph, { class: "description" }, description)
          : null, hasAuthors
          ? index.h("div", { class: "author" }, index.h("resource-author-item", { author: authors[0] }))
          : null)
      ];
    };
  }
  componentWillLoad() {
    if (!this.prismicData)
      return;
    __classPrivateFieldSet(this, _sameSite, !tools.isString(this.routing));
    if (__classPrivateFieldGet(this, _sameSite))
      this.routing = Object.assign(__classPrivateFieldGet(this, _defaults).routing, this.routing);
    __classPrivateFieldSet(this, _url, this.getUrl(this.prismicData.id));
  }
  getUrl(uid) {
    if (!__classPrivateFieldGet(this, _sameSite))
      return this.routing;
    const { base, includeType } = this.routing;
    const type = resourceTypeToPath(this.prismicData.type);
    if (includeType) {
      return `${base}/${type}/${uid}`;
    }
    else {
      return `${base}/${uid}`;
    }
  }
  render() {
    if (!this.prismicData)
      return;
    const { SameSiteCard, ExternalCard } = this;
    return (index.h(index.Host, { class: {
        'row': this.row,
        'column': !this.row
      } }, __classPrivateFieldGet(this, _sameSite) ? index.h(SameSiteCard, null)
      : index.h(ExternalCard, null)));
  }
};
_url = new WeakMap(), _sameSite = new WeakMap(), _defaults = new WeakMap();
ResourceCard.style = resourceCardCss;

exports.resource_card = ResourceCard;
