{"version":3,"file":"main.YqiVkD.js","sources":["theme-13/virtual:theme","theme-13/discourse/components/category-banner.gjs","theme-13/discourse/initializers/discourse-category-banners.js","theme-13/discourse/services/category-banner-presence.js","theme-13/virtual:entrypoint:main"],"sourcesContent":["import { getObjectForTheme } from \"discourse/lib/theme-settings-store\";\n\nexport const settings = getObjectForTheme(13);\n\nexport function themePrefix(key) {\n  return `theme_translations.13.${key}`;\n}\n","import Component from \"@glimmer/component\";\nimport { tracked } from \"@glimmer/tracking\";\nimport { concat } from \"@ember/helper\";\nimport { action } from \"@ember/object\";\nimport didInsert from \"@ember/render-modifiers/modifiers/did-insert\";\nimport didUpdate from \"@ember/render-modifiers/modifiers/did-update\";\nimport willDestroy from \"@ember/render-modifiers/modifiers/will-destroy\";\nimport { service } from \"@ember/service\";\nimport { trustHTML } from \"@ember/template\";\nimport CategoryLogo from \"discourse/components/category-logo\";\nimport HtmlWithLinks from \"discourse/components/html-with-links\";\nimport PluginOutlet from \"discourse/components/plugin-outlet\";\nimport { categoryLinkHTML } from \"discourse/helpers/category-link\";\nimport icon from \"discourse/helpers/d-icon\";\nimport lazyHash from \"discourse/helpers/lazy-hash\";\nimport { decorateHashtags } from \"discourse/lib/hashtag-decorator\";\nimport Category from \"discourse/models/category\";\n\nexport default class DiscourseCategoryBanners extends Component {\n  @service router;\n  @service site;\n  @service categoryBannerPresence;\n\n  @tracked category = null;\n  @tracked keepDuringLoadingRoute = false;\n\n  get categorySlugPathWithID() {\n    return this.router?.currentRoute?.params?.category_slug_path_with_id;\n  }\n\n  get shouldRender() {\n    return (\n      this.categorySlugPathWithID ||\n      (this.keepDuringLoadingRoute &&\n        this.router.currentRoute.name.includes(\"loading\"))\n    );\n  }\n\n  get isVisible() {\n    if (this.categorySlugPathWithID) {\n      return true;\n    } else if (this.router.currentRoute.name.includes(\"loading\")) {\n      return this.keepDuringLoadingRoute;\n    }\n    return false;\n  }\n\n  get safeStyle() {\n    return trustHTML(\n      `--category-banner-background: #${this.category.color}; --category-banner-color: #${this.category.text_color};`\n    );\n  }\n\n  get displayCategoryDescription() {\n    return settings.show_description && this.category.description?.length > 0;\n  }\n\n  get showCategoryIcon() {\n    const hasIcon = this.category.style_type === \"icon\" && this.category.icon;\n    const hasEmoji =\n      this.category.style_type === \"emoji\" && this.category.emoji;\n\n    if (settings.show_category_icon && (hasIcon || hasEmoji)) {\n      return true;\n    } else {\n      return false;\n    }\n  }\n\n  get categoryNameBadge() {\n    return categoryLinkHTML(this.category, {\n      allowUncategorized: true,\n      link: false,\n    });\n  }\n\n  #parseExceptions(exceptionsStr) {\n    return exceptionsStr\n      .split(\"|\")\n      .filter(Boolean)\n      .map((value) => value.toLowerCase());\n  }\n\n  #checkTargetCategory() {\n    if (settings.categories.length === 0) {\n      return true;\n    }\n\n    const currentCategoryId = this.category?.id;\n\n    const activeCategory = settings.categories.find((category) => {\n      return category.category_id[0] === currentCategoryId;\n    });\n\n    if (\n      activeCategory &&\n      (activeCategory.target === \"all\" || activeCategory.target === \"no_sub\")\n    ) {\n      return true;\n    }\n\n    const parentCategoryId = this.category?.parentCategory?.id;\n\n    if (parentCategoryId) {\n      const activeParentCategory = settings.categories.find((category) => {\n        return category.category_id[0] === parentCategoryId;\n      });\n\n      if (\n        activeParentCategory &&\n        (activeParentCategory.target === \"all\" ||\n          activeParentCategory.target === \"only_sub\")\n      ) {\n        return true;\n      }\n    }\n\n    return false;\n  }\n\n  @action\n  decorateDescriptionHashtags(element) {\n    decorateHashtags(element, this.site);\n  }\n\n  @action\n  teardownComponent() {\n    document.body.classList.remove(\"category-header\");\n    this.category = null;\n    this.categoryBannerPresence.setTo(false);\n  }\n\n  @action\n  getCategory() {\n    if (!this.isVisible) {\n      return;\n    }\n\n    if (this.categorySlugPathWithID) {\n      this.category = Category.findBySlugPathWithID(\n        this.categorySlugPathWithID\n      );\n      this.categoryBannerPresence.setTo(true);\n      this.keepDuringLoadingRoute = true;\n    } else {\n      if (!this.router.currentRoute.name.includes(\"loading\")) {\n        return (this.keepDuringLoadingRoute = false);\n      }\n    }\n\n    const exceptions = this.#parseExceptions(settings.exceptions);\n    const isException = exceptions.includes(this.category?.name.toLowerCase());\n    const isTarget = this.#checkTargetCategory();\n    const hideMobile = this.site.mobileView && !settings.show_mobile;\n    const hideSubCategory =\n      this.category?.parentCategory && !settings.show_subcategory;\n    const hasNoCategoryDescription =\n      settings.hide_if_no_description && !this.category?.description_text;\n\n    if (\n      isTarget &&\n      !isException &&\n      !hasNoCategoryDescription &&\n      !hideSubCategory &&\n      !hideMobile\n    ) {\n      document.body.classList.add(\"category-header\");\n    } else {\n      document.body.classList.remove(\"category-header\");\n      this.categoryBannerPresence.setTo(false);\n    }\n  }\n\n  <template>\n    {{#if this.shouldRender}}\n      <div\n        {{didInsert this.getCategory}}\n        {{didUpdate this.getCategory this.isVisible}}\n        {{willDestroy this.teardownComponent}}\n        class=\"category-title-header\n          {{if this.category (concat 'category-banner-' this.category.slug)}}\"\n        style={{if this.category this.safeStyle}}\n      >\n        {{#if this.category}}\n          <div class=\"category-title-contents\">\n            {{#if settings.show_category_logo}}\n              <CategoryLogo @category={{this.category}} />\n            {{/if}}\n            <h1 class=\"category-title\">\n              {{#if this.showCategoryIcon}}\n                {{this.categoryNameBadge}}\n              {{else}}\n                {{#if this.category.read_restricted}}\n                  {{icon \"lock\"}}\n                {{/if}}\n                {{this.category.name}}\n              {{/if}}\n\n              <PluginOutlet\n                @name=\"category-banners-after-title\"\n                @outletArgs={{lazyHash category=this.category}}\n              />\n            </h1>\n\n            {{#if this.displayCategoryDescription}}\n              <div class=\"category-title-description\">\n                <div\n                  class=\"cooked\"\n                  {{didInsert this.decorateDescriptionHashtags}}\n                  {{didUpdate\n                    this.decorateDescriptionHashtags\n                    this.category.description\n                  }}\n                >\n                  <HtmlWithLinks>\n                    {{trustHTML this.category.description}}\n                  </HtmlWithLinks>\n                  <PluginOutlet\n                    @name=\"category-banners-after-description\"\n                    @outletArgs={{lazyHash category=this.category}}\n                  />\n                </div>\n              </div>\n            {{/if}}\n          </div>\n        {{/if}}\n      </div>\n    {{/if}}\n  </template>\n}\n","import { apiInitializer } from \"discourse/lib/api\";\nimport CategoryBanner from \"../components/category-banner\";\n\nexport default apiInitializer((api) => {\n  api.renderInOutlet(settings.plugin_outlet, CategoryBanner);\n});\n","import { tracked } from \"@glimmer/tracking\";\nimport Service from \"@ember/service\";\n\nexport default class CategoryBannerPresence extends Service {\n  @tracked isPresent = false;\n\n  setTo(value) {\n    this.isPresent = value;\n  }\n}\n","import * as Mod1 from \"./discourse/components/category-banner\";\nimport * as Mod2 from \"./discourse/initializers/discourse-category-banners\";\nimport * as Mod3 from \"./discourse/services/category-banner-presence\";\nconst compatModules = {\n  \"discourse/components/category-banner\": Mod1,\n  \"discourse/initializers/discourse-category-banners\": Mod2,\n  \"discourse/services/category-banner-presence\": Mod3,\n};\nexport { compatModules };\nexport default compatModules;\n"],"names":["settings","getObjectForTheme","DiscourseCategoryBanners","Component","dt7948","g","this","prototype","service","router","i","site","categoryBannerPresence","tracked","category","keepDuringLoadingRoute","categorySlugPathWithID","currentRoute","params","category_slug_path_with_id","shouldRender","name","includes","isVisible","safeStyle","trustHTML","color","text_color","displayCategoryDescription","show_description","description","length","showCategoryIcon","hasIcon","style_type","icon","hasEmoji","emoji","show_category_icon","categoryNameBadge","categoryLinkHTML","allowUncategorized","link","parseExceptions","exceptionsStr","split","filter","Boolean","map","value","toLowerCase","checkTargetCategory","categories","currentCategoryId","id","activeCategory","find","category_id","target","parentCategoryId","parentCategory","activeParentCategory","decorateDescriptionHashtags","element","decorateHashtags","n","action","teardownComponent","document","body","classList","remove","setTo","getCategory","Category","findBySlugPathWithID","isException","exceptions","isTarget","hideMobile","mobileView","show_mobile","hideSubCategory","show_subcategory","hasNoCategoryDescription","hide_if_no_description","description_text","add","setComponentTemplate","createTemplateFactory","block","moduleName","scope","concat","didInsert","didUpdate","willDestroy","CategoryLogo","PluginOutlet","lazyHash","HtmlWithLinks","isStrictMode","discourseCategoryBanners","api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