import { r as registerInstance, h, H as Host } from './index-0861cb0b.js';
import './common-d52c7ecc.js';
import './IntersectionHelper-215713b2.js';
import { H as Heading } from './Heading-1dc7d8ed.js';
import { P as Paragraph } from './Paragraph-47cc160b.js';
import './_commonjsHelpers-84ca41fa.js';
import { h as href } from './index-72bb483f.js';
import { P as PrismicResponsiveImage } from './PrismicResponsiveImage-a4cbbeb6.js';
import './prismic-javascript.min-a79c0430.js';
import { R as ResourceType, g as getAuthorsForPrismicDoc } from './prismic-330a0e03.js';
import { i as isString } from './tools-803eb4f0.js';

const resourceTypeToPath = (type) => ({
  [ResourceType.Article]: 'articles',
  [ResourceType.Blog]: 'blogs',
  [ResourceType.Book]: 'books',
  [ResourceType.CaseStudy]: 'case-studies',
  [ResourceType.Course]: 'courses',
  [ResourceType.CustomerInterview]: 'customer-interviews',
  [ResourceType.Doc]: 'docs',
  [ResourceType.Guide]: 'guides',
  [ResourceType.Learning]: 'learning',
  [ResourceType.Podcast]: 'podcasts',
  [ResourceType.Tutorial]: 'tutorials',
  [ResourceType.Video]: 'videos',
  [ResourceType.Webinar]: 'webinars',
  [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) {
    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 (h("a", Object.assign({ class: "contents-wrapper" }, href(__classPrivateFieldGet(this, _url), this.routing.router)), h(CardContents, null)));
    };
    this.ExternalCard = () => {
      const { CardContents } = this;
      return (h("a", { class: "contents-wrapper", href: __classPrivateFieldGet(this, _url), target: "_blank", rel: "noopener" }, 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 = getAuthorsForPrismicDoc(this.prismicData.doc);
      const hasAuthors = this.author && authors.length > 0;
      return [
        h("div", { class: "image-wrapper" }, h(PrismicResponsiveImage, { image: hero_image })),
        h("div", { class: "content" }, hasDescriptors
          ? h("div", { class: "meta" }, this.type
            ? h(Heading, { class: "type | ui-theme--editorial", level: 6 }, type)
            : null, tags && this.tags
            ? h("resource-meta", { class: "ui-theme--editorial", tags: tags })
            : null)
          : null, h(Heading, { class: "title | ui-theme--editorial", level: this.headingLevel }, title), this.description
          ? h(Paragraph, { class: "description" }, description)
          : null, hasAuthors
          ? h("div", { class: "author" }, h("resource-author-item", { author: authors[0] }))
          : null)
      ];
    };
  }
  componentWillLoad() {
    if (!this.prismicData)
      return;
    __classPrivateFieldSet(this, _sameSite, !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 (h(Host, { class: {
        'row': this.row,
        'column': !this.row
      } }, __classPrivateFieldGet(this, _sameSite) ? h(SameSiteCard, null)
      : h(ExternalCard, null)));
  }
};
_url = new WeakMap(), _sameSite = new WeakMap(), _defaults = new WeakMap();
ResourceCard.style = resourceCardCss;

export { ResourceCard as resource_card };
