{"version":3,"file":"main.Dlj9m0.js","sources":["theme-31/virtual:theme","theme-31/discourse/components/category-header.gjs","theme-31/discourse/api-initializers/init_banners.js","theme-31/virtual:entrypoint:main"],"sourcesContent":["import { getObjectForTheme } from \"discourse/lib/theme-settings-store\";\n\nexport const settings = getObjectForTheme(31);\n\nexport function themePrefix(key) {\n  return `theme_translations.31.${key}`;\n}\n","import Component from \"@glimmer/component\";\nimport { tracked } from \"@glimmer/tracking\";\nimport { on } from \"@ember/modifier\";\nimport { action } from \"@ember/object\";\nimport { service } from \"@ember/service\";\nimport { htmlSafe } from \"@ember/template\";\nimport { and, not, or } from \"truth-helpers\";\nimport CdnImg from \"discourse/components/cdn-img\";\nimport LightDarkImg from \"discourse/components/light-dark-img\";\nimport PluginOutlet from \"discourse/components/plugin-outlet\";\nimport icon from \"discourse/helpers/d-icon\";\nimport lazyHash from \"discourse/helpers/lazy-hash\";\nimport { ajax } from \"discourse/lib/ajax\";\nimport { getURLWithCDN } from \"discourse/lib/get-url\";\n\nexport default class CategoryHeader extends Component {\n  @service siteSettings;\n  @service site;\n  @service router;\n\n  @tracked full_cat_desc;\n  @tracked isCatDescExpanded = false;\n\n  constructor() {\n    super(...arguments);\n    this.getFullCatDesc();\n    this._onPageChanged = this._onPageChanged.bind(this);\n    this.router.on(\"routeDidChange\", this._onPageChanged);\n  }\n\n  willDestroy() {\n    super.willDestroy(...arguments);\n    this.router.off(\"routeDidChange\", this._onPageChanged);\n  }\n\n  // eslint-disable-next-line no-unused-vars\n  async _onPageChanged(transition) {\n    // Make descriptions collapsed\n    this.isCatDescExpanded = false;\n\n    try {\n      let cd = await ajax(`${this.args.category.topic_url}.json`);\n      this.full_cat_desc = cd.post_stream.posts[0].cooked;\n    } catch (e) {\n      // eslint-disable-next-line no-console\n      console.error(e);\n    }\n  }\n\n  get ifParentCategory() {\n    if (this.args.category.parentCategory) {\n      return true;\n    }\n  }\n\n  get showCatDesc() {\n    if (settings.show_category_description) {\n      return true;\n    }\n  }\n\n  get catDesc() {\n    return this.args.category.description;\n  }\n\n  async getFullCatDesc() {\n    try {\n      let cd = await ajax(`${this.args.category.topic_url}.json`);\n      this.full_cat_desc = cd.post_stream.posts[0].cooked;\n    } catch (e) {\n      // eslint-disable-next-line no-console\n      console.error(e);\n    }\n  }\n\n  get showFullCatDesc() {\n    if (settings.show_full_category_description) {\n      return true;\n    }\n  }\n\n  get logoImg() {\n    if (settings.show_category_logo && this.args.category.uploaded_logo) {\n      return this.args.category.uploaded_logo;\n    } else if (\n      settings.show_category_logo &&\n      settings.show_parent_category_logo &&\n      this.args.category.parentCategory &&\n      this.args.category.parentCategory.uploaded_logo\n    ) {\n      return this.args.category.parentCategory.uploaded_logo;\n    } else if (settings.show_site_logo && this.siteSettings.logo_small) {\n      let map = {};\n      map[\"url\"] = this.siteSettings.logo_small;\n      return map;\n    } else {\n      return false;\n    }\n  }\n\n  get darkLogoImg() {\n    if (\n      settings.show_dark_mode_category_logo &&\n      this.args.category.uploaded_logo_dark\n    ) {\n      return this.args.category.uploaded_logo_dark;\n    } else if (\n      settings.show_dark_mode_category_logo &&\n      settings.show_dark_mode_parent_category_logo &&\n      this.args.category.parentCategory &&\n      this.args.category.parentCategory.uploaded_logo_dark\n    ) {\n      return this.args.category.parentCategory.uploaded_logo_dark;\n    }\n\n    return null;\n  }\n\n  get ifParentProtected() {\n    if (\n      this.args.category.parentCategory &&\n      (this.args.category.parentCategory.permission === null ||\n        this.args.category.parentCategory.read_restricted)\n    ) {\n      return true;\n    }\n  }\n\n  get ifProtected() {\n    if (\n      this.args.category.permission === null ||\n      this.args.category.read_restricted\n    ) {\n      return true;\n    }\n  }\n\n  get lockIcon() {\n    return settings.category_lock_icon || \"lock\";\n  }\n\n  get showHeader() {\n    const isException =\n      this.args.category &&\n      settings.hide_category_exceptions\n        .split(\"|\")\n        .includes(String(this.args.category.id));\n    const hideMobile = !settings.show_mobile && this.site.mobileView;\n    const subCat =\n      !settings.show_subcategory_header && this.args.category.parentCategory;\n    const noDesc =\n      !settings.hide_if_no_category_description &&\n      !this.args.category.description_text;\n    const path = window.location.pathname;\n    return (\n      /^\\/c\\//.test(path) && !isException && !noDesc && !subCat && !hideMobile\n    );\n  }\n\n  get getHeaderStyle() {\n    let headerStyle = \"\";\n    if (settings.header_style === \"box\") {\n      headerStyle +=\n        \"border-left: 6px solid #\" + this.args.category.color + \";\";\n    }\n    if (settings.header_style === \"banner\") {\n      headerStyle +=\n        \"background-color: #\" +\n        this.args.category.color +\n        \"; color: #\" +\n        this.args.category.text_color +\n        \";\";\n    }\n    if (settings.show_parent_category_background_image) {\n      if (this.args.category.parentCategory) {\n        if (\n          settings.header_background_image !== \"outside\" &&\n          this.args.category.parentCategory.uploaded_background\n        ) {\n          headerStyle +=\n            \"background-image: url(\" +\n            getURLWithCDN(this.args.category.parentCategory.uploaded_background.url) +\n            \");\";\n        }\n      } else if (this.args.category.uploaded_background) {\n        if (settings.header_background_image !== \"outside\") {\n          headerStyle +=\n            \"background-image: url(\" +\n            getURLWithCDN(this.args.category.uploaded_background.url) +\n            \");\";\n        }\n      }\n    } else {\n      if (this.args.category.uploaded_background) {\n        if (settings.header_background_image !== \"outside\") {\n          headerStyle +=\n            \"background-image: url(\" +\n            getURLWithCDN(this.args.category.uploaded_background.url) +\n            \");\";\n        }\n      }\n    }\n    return headerStyle + \" display: block; margin-bottom: 1em;\";\n  }\n\n  get aboutTopicUrl() {\n    if (settings.show_read_more_link && this.args.category.topic_url) {\n      return this.isCatDescExpanded &&\n        settings.expand_and_collapse_category_description\n        ? settings.read_less_link_text\n        : settings.read_more_link_text;\n    }\n  }\n\n  get inlineReadMore() {\n    return (\n      settings.inline_read_more &&\n      (settings.show_category_description ||\n        settings.show_full_category_description) &&\n      settings.show_read_more_link\n    );\n  }\n\n  @action\n  async expandCategoryDescription() {\n    if (settings.expand_and_collapse_category_description) {\n      this.isCatDescExpanded = !this.isCatDescExpanded;\n    }\n  }\n\n  <template>\n    {{#if this.showHeader}}\n      <div\n        class=\"category-title-header category-banner-{{@category.slug}}\"\n        style={{this.getHeaderStyle}}\n      >\n        <div class=\"category-title-contents\">\n          <div class=\"category-logo aspect-image\">\n            {{#if this.darkLogoImg}}\n              {{#if (and this.logoImg this.darkLogoImg)}}\n                <LightDarkImg\n                  @lightImg={{this.logoImg}}\n                  @darkImg={{this.darkLogoImg}}\n                />\n              {{/if}}\n            {{else if this.logoImg}}\n              <CdnImg\n                @src={{this.logoImg.url}}\n                @width={{this.logoImg.width}}\n                @height={{this.logoImg.height}}\n              />\n            {{/if}}\n          </div>\n          <div\n            class=\"category-title-name\"\n            style={{unless this.logoImg \"padding: 0 !important;\"}}\n          >\n            {{#if this.ifParentCategory}}\n              <a class=\"parent-box-link\" href={{@category.parentCategory.url}}>\n                {{#if this.ifParentProtected}}\n                  {{icon this.lockIcon}}\n                {{/if}}\n                <h1>{{@category.parentCategory.name}}: </h1>\n              </a>\n            {{/if}}\n            {{#if this.ifProtected}}\n              {{icon this.lockIcon}}\n            {{/if}}\n            <h1>{{@category.name}}</h1>\n          </div>\n\n          <div class=\"category-title-description\">\n            {{#if (or this.showCatDesc this.showFullCatDesc)}}\n              <div class=\"cooked\">\n                {{#if this.showFullCatDesc}}\n                  {{htmlSafe this.full_cat_desc}}\n                {{else}}\n                  {{#if this.isCatDescExpanded}}\n                    {{htmlSafe this.full_cat_desc}}\n                  {{else}}\n                    {{htmlSafe this.catDesc}}\n                  {{/if}}\n                {{/if}}\n\n                {{#if this.inlineReadMore}}\n                  <span class=\"category-about-url\">\n                    {{#if\n                      (and\n                        settings.expand_and_collapse_category_description\n                        this.showCatDesc\n                        (not this.showFullCatDesc)\n                      )\n                    }}\n                      {{! template-lint-disable no-invalid-interactive}}\n                      <a\n                        {{on \"click\" this.expandCategoryDescription}}\n                      >{{this.aboutTopicUrl}}</a>\n                    {{else}}\n                      <a href={{@category.topic_url}}>{{this.aboutTopicUrl}}</a>\n                    {{/if}}\n                  </span>\n                {{/if}}\n              </div>\n            {{/if}}\n          </div>\n          <PluginOutlet\n            @name=\"category-header-after-category-title-description\"\n            @outletArgs={{lazyHash category=@category}}\n          />\n        </div>\n\n        {{#unless this.inlineReadMore}}\n          <div class=\"category-about-url\">\n            {{#if\n              (and\n                settings.expand_and_collapse_category_description\n                this.showCatDesc\n                (not this.showFullCatDesc)\n              )\n            }}\n              {{! template-lint-disable no-invalid-interactive}}\n              <a\n                {{on \"click\" this.expandCategoryDescription}}\n              >{{this.aboutTopicUrl}}</a>\n            {{else}}\n              <a href={{@category.topic_url}}>{{this.aboutTopicUrl}}</a>\n            {{/if}}\n          </div>\n        {{/unless}}\n      </div>\n    {{/if}}\n  </template>\n}\n","import { apiInitializer } from \"discourse/lib/api\";\nimport CategoryHeader from \"../components/category-header\";\n\nexport default apiInitializer((api) => {\n  api.renderInOutlet(\"above-category-heading\", CategoryHeader);\n});\n","import * as Mod1 from \"./discourse/api-initializers/init_banners\";\nimport * as Mod2 from \"./discourse/components/category-header\";\nconst compatModules = {\n  \"discourse/api-initializers/init_banners\": Mod1,\n  \"discourse/components/category-header\": Mod2,\n};\nexport { compatModules };\nexport default compatModules;\n"],"names":["settings","getObjectForTheme","CategoryHeader","Component","dt7948","g","this","prototype","service","siteSettings","i","site","router","tracked","full_cat_desc","isCatDescExpanded","constructor","super","arguments","getFullCatDesc","_onPageChanged","bind","on","willDestroy","off","transition","cd","ajax","args","category","topic_url","post_stream","posts","cooked","e","console","error","ifParentCategory","parentCategory","showCatDesc","show_category_description","catDesc","description","showFullCatDesc","show_full_category_description","logoImg","show_category_logo","uploaded_logo","show_parent_category_logo","show_site_logo","logo_small","map","darkLogoImg","show_dark_mode_category_logo","uploaded_logo_dark","show_dark_mode_parent_category_logo","ifParentProtected","permission","read_restricted","ifProtected","lockIcon","category_lock_icon","showHeader","isException","hide_category_exceptions","split","includes","String","id","hideMobile","show_mobile","mobileView","subCat","show_subcategory_header","noDesc","hide_if_no_category_description","description_text","path","window","location","pathname","test","getHeaderStyle","headerStyle","header_style","color","text_color","show_parent_category_background_image","header_background_image","uploaded_background","getURLWithCDN","url","aboutTopicUrl","show_read_more_link","expand_and_collapse_category_description","read_less_link_text","read_more_link_text","inlineReadMore","inline_read_more","expandCategoryDescription","n","action","setComponentTemplate","createTemplateFactory","block","moduleName","scope","and","LightDarkImg","CdnImg","icon","or","htmlSafe","not","PluginOutlet","lazyHash","isStrictMode","init_banners","apiInitializer","api","renderInOutlet","compatModules","Mod2"],"mappings":"q0CAEaA,EAAWC,EAAkB;ACa3B,MAAMC,UAAuBC,SAAAC,OAAAC,EAAAC,KAAAC,0BACzCC,GAAA,CAAAC,QAAAL,OAAAM,EAAAJ,KAAA;OAAAF,OAAAC,EAAAC,KAAAC,kBACAC,GAAA,CAAAG,QAAAP,OAAAM,EAAAJ,KAAA;OAAAF,OAAAC,EAAAC,KAAAC,oBACAC,GAAA,CAAAI,QAAAR,OAAAM,EAAAJ,KAAA;OAAAF,OAAAC,EAAAC,KAAAC,2BAEAM,GAAA,CAAAC,QAAAV,OAAAM,EAAAJ,KAAA;OAAAF,OAAAC,EAAAC,KAAAC,+BACAM,GAAA,WAAA,OAA4B,CAAA,EAAA,CAAAE,QAAAX,OAAAM,EAAAJ,KAAA;AAE7BU,WAAAA,GACEC,SAASC,WACTZ,KAAKa,iBACLb,KAAKc,eAAiBd,KAAKc,eAAeC,KAAKf,MAC/CA,KAAKM,OAAOU,GAAG,iBAAkBhB,KAAKc,eACxC,CAEAG,WAAAA,GACEN,MAAMM,eAAeL,WACrBZ,KAAKM,OAAOY,IAAI,iBAAkBlB,KAAKc,eACzC,CAGA,oBAAMA,CAAeK,GAEnBnB,KAAKS,mBAAoB;AAEzB,IACE,IAAIW,QAAWC,EAAK,GAAGrB,KAAKsB,KAAKC,SAASC;AAC1CxB,KAAKQ,cAAgBY,EAAGK,YAAYC,MAAM,GAAGC,MAC/C,CAAE,MAAOC,GAEPC,QAAQC,MAAMF,EAChB,CACF,CAEA,oBAAIG,GACF,GAAI/B,KAAKsB,KAAKC,SAASS,e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