{"version":3,"file":"main.8jq0Ep.js","sources":["theme-439/virtual:theme","theme-439/discourse/components/block-panel-error.gjs","theme-439/discourse/components/block-panel-skeleton.gjs","theme-439/discourse/components/block-panel.gjs","theme-439/discourse/lib/events.js","theme-439/discourse/blocks/block-events.gjs","theme-439/discourse/blocks/block-leaderboard.gjs","theme-439/discourse/blocks/block-resources.gjs","theme-439/discourse/components/category-mark.gjs","theme-439/discourse/lib/space.js","theme-439/discourse/blocks/block-space.gjs","theme-439/discourse/blocks/block-topics.gjs","theme-439/discourse/lib/category-scoped-layout.js","theme-439/discourse/api-initializers/sidebar-discovery-blocks.gjs","theme-439/virtual:entrypoint:main"],"sourcesContent":["import { getObjectForTheme } from \"discourse/lib/theme-settings-store\";\n\nexport const settings = getObjectForTheme(439);\n\nexport function themePrefix(key) {\n  return `theme_translations.439.${key}`;\n}\n","import { themePrefix } from \"virtual:theme\";\nimport DButton from \"discourse/ui-kit/d-button\";\nimport { i18n } from \"discourse-i18n\";\n\n// The failed-load message and retry button of a panel body.\n// @onRetry runs when the button is pressed\nconst BlockPanelError = <template>\n  <div class=\"block-panel-error\">\n    <p class=\"block-panel-error__message\" role=\"alert\">\n      {{i18n (themePrefix \"panel.load_error\")}}\n    </p>\n    <DButton\n      @action={{@onRetry}}\n      @label={{themePrefix \"panel.retry\"}}\n      class=\"btn-small block-panel-error__button\"\n    />\n  </div>\n</template>;\n\nexport default BlockPanelError;\n","import Component from \"@glimmer/component\";\nimport DSkeleton from \"discourse/ui-kit/d-skeleton\";\n\n// Loading placeholder for a panel body. The shape follows core's\n// BlockSkeletonShape (variant, count, width, height) so it can move into a\n// block's `data.skeleton` declaration later. `rows` is a theme extension for\n// composed rows that plain DSkeleton cannot express:\n//   { rows: \"user\", count }  avatar circle + name line + score\n//   { rows: \"link\", count }  icon square + label line + description line\n//   { rows: \"topic\", count } title line + meta line\nexport default class BlockPanelSkeleton extends Component {\n  get rows() {\n    const count = this.args.shape?.count ?? 5;\n    return Array.from({ length: count }, (_, index) => index);\n  }\n\n  <template>\n    <div class=\"block-panel-skeleton\" aria-hidden=\"true\">\n      {{#if (eq @shape.rows \"user\")}}\n        {{#each this.rows as |row|}}\n          <div class=\"block-panel-skeleton__row --user\" data-row={{row}}>\n            <DSkeleton @variant=\"circle\" @size=\"1.75rem\" />\n            <DSkeleton @variant=\"text\" @width=\"55%\" />\n            <DSkeleton @variant=\"text\" @width=\"2.5rem\" />\n          </div>\n        {{/each}}\n      {{else if (eq @shape.rows \"link\")}}\n        {{#each this.rows as |row|}}\n          <div class=\"block-panel-skeleton__row --link\" data-row={{row}}>\n            <DSkeleton @variant=\"rect\" @width=\"1.25rem\" @height=\"1.25rem\" />\n            <div class=\"block-panel-skeleton__lines\">\n              <DSkeleton @variant=\"text\" @width=\"60%\" />\n              <DSkeleton @variant=\"text\" @width=\"85%\" />\n            </div>\n          </div>\n        {{/each}}\n      {{else if (eq @shape.rows \"topic\")}}\n        {{#each this.rows as |row|}}\n          <div class=\"block-panel-skeleton__row --topic\" data-row={{row}}>\n            <div class=\"block-panel-skeleton__lines\">\n              <DSkeleton @variant=\"text\" @width=\"90%\" />\n              <DSkeleton @variant=\"text\" @width=\"40%\" />\n            </div>\n          </div>\n        {{/each}}\n      {{else}}\n        <DSkeleton\n          @variant={{@shape.variant}}\n          @count={{@shape.count}}\n          @width={{@shape.width}}\n          @height={{@shape.height}}\n        />\n      {{/if}}\n    </div>\n  </template>\n}\n\nfunction eq(a, b) {\n  return a === b;\n}\n","import DAsyncContent from \"discourse/ui-kit/d-async-content\";\nimport dIcon from \"discourse/ui-kit/helpers/d-icon\";\nimport BlockPanelError from \"./block-panel-error\";\nimport BlockPanelSkeleton from \"./block-panel-skeleton\";\n\n// Chrome shared by every sidebar panel: header, body, footer. The header and\n// footer render from args and stay visible while data loads; only the body is\n// inside the data boundary, where a reserved-space skeleton replaces the\n// spinner. Sync panels omit @asyncData and yield their content directly.\n//\n// @title, @icon        header, or <:header>\n// @mobile              instance stays visible in the single-column layout\n// @asyncData, @context passed to DAsyncContent; @skeleton shapes the placeholder\n// @onRetry             a failed load shows a message and a retry button\n// <:content as |data|> body; <:empty>; <:error>; <:footer>\nconst BlockPanel = <template>\n  <section class=\"block-panel {{if @mobile '--mobile'}}\" ...attributes>\n    {{#if (has-block \"header\")}}\n      <header class=\"block-panel__header\">\n        {{yield to=\"header\"}}\n      </header>\n    {{else if @title}}\n      <header class=\"block-panel__header\">\n        {{#if @icon}}\n          <span class=\"block-panel__icon\">{{dIcon @icon}}</span>\n        {{/if}}\n        <h3 class=\"block-panel__title\">{{@title}}</h3>\n      </header>\n    {{/if}}\n\n    <div class=\"block-panel__body\">\n      {{#if @asyncData}}\n        <DAsyncContent\n          @asyncData={{@asyncData}}\n          @context={{@context}}\n          @retainWhileReloading={{true}}\n        >\n          <:loading>\n            <div class=\"block-panel__loading\" aria-busy=\"true\">\n              <BlockPanelSkeleton @shape={{@skeleton}} />\n            </div>\n          </:loading>\n          <:content as |data|>\n            {{yield data to=\"content\"}}\n          </:content>\n          <:error as |error InlineError|>\n            {{#if (has-block \"error\")}}\n              {{yield error to=\"error\"}}\n            {{else if @onRetry}}\n              <BlockPanelError @onRetry={{@onRetry}} />\n            {{else}}\n              <InlineError />\n            {{/if}}\n          </:error>\n          <:empty>\n            {{yield to=\"empty\"}}\n          </:empty>\n        </DAsyncContent>\n      {{else}}\n        {{yield null to=\"content\"}}\n      {{/if}}\n    </div>\n\n    {{#if (has-block \"footer\")}}\n      <footer class=\"block-panel__footer\">\n        {{yield to=\"footer\"}}\n      </footer>\n    {{/if}}\n  </section>\n</template>;\n\nexport default BlockPanel;\n","import { ajax } from \"discourse/lib/ajax\";\nimport getURL from \"discourse/lib/get-url\";\nimport I18n from \"discourse-i18n\";\n\n// The server orders by each event's stored date, which for a recurring event\n// can lie before its next occurrence, so fetch a margin and sort here.\nfunction requestLimit(count) {\n  return Math.min(Math.max(count * 5, 15), 100);\n}\n\n// All-day dates come as a bare \"YYYY-MM-DD\"; parsed as is they would be\n// midnight UTC, a day early west of UTC. Parse them as local days instead.\nfunction parse(value) {\n  if (!value) {\n    return null;\n  }\n  const allDay = /^\\d{4}-\\d{2}-\\d{2}$/.test(value);\n  const date = new Date(allDay ? `${value}T00:00:00` : value);\n  return Number.isNaN(date.getTime()) ? null : { date, allDay };\n}\n\n// An all-day event lasts until the end of its last day, a timed one until\n// its end time, or its start time when it has none.\nfunction endOf(start, end) {\n  const last = end ?? start;\n  if (start.allDay) {\n    const date = new Date(last.date);\n    date.setHours(23, 59, 59, 999);\n    return date.getTime();\n  }\n  return last.date.getTime();\n}\n\nfunction occurrences(event) {\n  const rows = event.occurrences?.length ? event.occurrences : [event];\n  return rows\n    .map((row) => {\n      const start = parse(row.starts_at);\n      return start\n        ? {\n            iso: row.starts_at,\n            start,\n            ms: start.date.getTime(),\n            endMs: endOf(start, parse(row.ends_at)),\n          }\n        : null;\n    })\n    .filter(Boolean);\n}\n\nfunction serialize([event, occurrence]) {\n  const { date } = occurrence.start;\n  return {\n    id: event.id,\n    title: event.name?.trim() || event.post?.topic?.title || \"\",\n    iso: occurrence.iso,\n    month: date.toLocaleDateString(I18n.currentBcp47Locale, { month: \"short\" }),\n    day: date.getDate(),\n    url: event.post?.url ? getURL(event.post.url) : null,\n  };\n}\n\nasync function search({ categoryId, count, ...range }) {\n  const result = await ajax(\"/discourse-post-event/events.json\", {\n    data: {\n      category_id: categoryId,\n      include_subcategories: true,\n      include_details: true,\n      limit: requestLimit(count),\n      ...range,\n    },\n  });\n  return result?.events ?? [];\n}\n\nfunction pick(events, choose, compare, count) {\n  return events\n    .map((event) => [event, choose(occurrences(event))])\n    .filter(([, occurrence]) => occurrence)\n    .sort(([, a], [, b]) => compare(a, b))\n    .slice(0, count)\n    .map(serialize);\n}\n\n// Post events of the whole site, or of a category and its subcategories\n// when one is given. The next `count` events that are not over yet; when\n// there are none, the `count` most recent past events instead, flagged with\n// `recent`. Null when there are no events at all, so the panel hides itself.\nexport async function fetchEvents({ categoryId, count }) {\n  const now = Date.now();\n\n  // The server stores an all-day event as midnight UTC of its date, so with\n  // \"now\" as the cutoff today's all-day events would already count as past.\n  // Two days back covers every timezone; the filter below decides what is\n  // still running.\n  const upcoming = pick(\n    await search({\n      categoryId,\n      count,\n      after: new Date(now - 2 * 24 * 60 * 60 * 1000).toISOString(),\n      include_ongoing: true,\n      order: \"asc\",\n    }),\n    (rows) =>\n      rows.filter((row) => row.endMs >= now).sort((a, b) => a.ms - b.ms)[0],\n    (a, b) => a.ms - b.ms,\n    count\n  );\n\n  if (upcoming.length) {\n    return { events: upcoming, recent: false };\n  }\n\n  const recent = pick(\n    await search({ categoryId, count, before: \"now\", order: \"desc\" }),\n    (rows) =>\n      rows.filter((row) => row.endMs < now).sort((a, b) => b.ms - a.ms)[0],\n    (a, b) => b.ms - a.ms,\n    count\n  );\n\n  return recent.length ? { events: recent, recent: true } : null;\n}\n","import Component from \"@glimmer/component\";\nimport { tracked } from \"@glimmer/tracking\";\nimport { themePrefix } from \"virtual:theme\";\nimport { block } from \"discourse/blocks\";\nimport { bind } from \"discourse/lib/decorators\";\nimport getURL from \"discourse/lib/get-url\";\nimport DAsyncContent from \"discourse/ui-kit/d-async-content\";\nimport { i18n } from \"discourse-i18n\";\nimport BlockPanel from \"../components/block-panel\";\nimport BlockPanelError from \"../components/block-panel-error\";\nimport { fetchEvents } from \"../lib/events\";\n\n// The layout selects the events entry for the current category and passes\n// its events category here. Without one the events come from the whole\n// site. With no upcoming events it shows the most recent past ones under\n// @recentTitle. The data loads before the panel exists: nothing renders\n// while loading or when there are no events at all, so an empty panel never\n// flashes, and the panel disappears for good when the events plugin is\n// missing.\n@block(\"theme:discovery-sidebar:events\", {\n  description: \"Upcoming post events of a category\",\n  args: {\n    title: { type: \"string\", required: true },\n    recentTitle: { type: \"string\", required: true },\n    icon: { type: \"string\" },\n    mobile: { type: \"boolean\", default: false },\n    categoryId: { type: \"number\", integer: true, min: 1 },\n    count: { type: \"number\", default: 3 },\n  },\n})\nexport default class BlockEvents extends Component {\n  @tracked unavailable = false;\n  @tracked retryCount = 0;\n\n  titleFor = (data) =>\n    i18n(themePrefix(data.recent ? this.args.recentTitle : this.args.title));\n\n  @bind\n  retry() {\n    this.retryCount++;\n  }\n\n  get eventsUrl() {\n    return getURL(\"/upcoming-events\");\n  }\n\n  get context() {\n    return {\n      categoryId: this.args.categoryId,\n      count: this.args.count,\n      retryCount: this.retryCount,\n    };\n  }\n\n  @bind\n  async fetchEvents({ categoryId, count }) {\n    try {\n      return await fetchEvents({ categoryId, count });\n    } catch (error) {\n      if (error.jqXHR?.status === 403 || error.jqXHR?.status === 404) {\n        if (!this.isDestroying && !this.isDestroyed) {\n          this.unavailable = true;\n        }\n        return null;\n      }\n      throw error;\n    }\n  }\n\n  <template>\n    {{#unless this.unavailable}}\n      <DAsyncContent\n        @asyncData={{this.fetchEvents}}\n        @context={{this.context}}\n        @retainWhileReloading={{true}}\n      >\n        <:loading></:loading>\n        <:empty></:empty>\n        <:content as |data|>\n          <BlockPanel\n            @title={{this.titleFor data}}\n            @icon={{@icon}}\n            @mobile={{@mobile}}\n            class=\"block-events\"\n          >\n            <:content>\n              <ol class=\"block-events__list\">\n                {{#each data.events as |event|}}\n                  <li class=\"block-events__row\">\n                    <a class=\"block-events__link\" href={{event.url}}>\n                      <time class=\"block-events__date\" datetime={{event.iso}}>\n                        <span class=\"block-events__month\">{{event.month}}</span>\n                        <span class=\"block-events__day\">{{event.day}}</span>\n                      </time>\n                      <span class=\"block-events__name\">{{event.title}}</span>\n                    </a>\n                  </li>\n                {{/each}}\n              </ol>\n            </:content>\n            <:footer>\n              <a class=\"block-panel__link\" href={{this.eventsUrl}}>\n                {{i18n (themePrefix \"events.view_all\")}}\n              </a>\n            </:footer>\n          </BlockPanel>\n        </:content>\n        <:error>\n          <BlockPanel\n            @title={{i18n (themePrefix @title)}}\n            @icon={{@icon}}\n            @mobile={{@mobile}}\n            class=\"block-events\"\n          >\n            <:content>\n              <BlockPanelError @onRetry={{this.retry}} />\n            </:content>\n          </BlockPanel>\n        </:error>\n      </DAsyncContent>\n    {{/unless}}\n  </template>\n}\n","import Component from \"@glimmer/component\";\nimport { tracked } from \"@glimmer/tracking\";\nimport { service } from \"@ember/service\";\nimport { themePrefix } from \"virtual:theme\";\nimport { block } from \"discourse/blocks\";\nimport { ajax } from \"discourse/lib/ajax\";\nimport { bind } from \"discourse/lib/decorators\";\nimport getURL from \"discourse/lib/get-url\";\nimport DUserAvatar from \"discourse/ui-kit/d-user-avatar\";\nimport DUserLink from \"discourse/ui-kit/d-user-link\";\nimport dNumber from \"discourse/ui-kit/helpers/d-number\";\nimport { i18n } from \"discourse-i18n\";\nimport BlockPanel from \"../components/block-panel\";\n\n// The layout selects the leaderboard for the current category and passes its\n// id here. A missing id deliberately uses the Gamification plugin's default.\n// Arg names follow its core block (leaderboardId, count, period). Without a\n// title the panel shows the leaderboard's own name; without a period the\n// server ranks over the leaderboard's default period.\n@block(\"theme:discovery-sidebar:leaderboard\", {\n  description: \"Top users of a gamification leaderboard\",\n  args: {\n    title: { type: \"string\" },\n    icon: { type: \"string\" },\n    mobile: { type: \"boolean\", default: false },\n    leaderboardId: { type: \"number\", integer: true, min: 1 },\n    count: { type: \"number\", default: 8 },\n    period: {\n      type: \"string\",\n      enum: [\"all_time\", \"yearly\", \"quarterly\", \"monthly\", \"weekly\", \"daily\"],\n    },\n  },\n})\nexport default class BlockLeaderboard extends Component {\n  @service siteSettings;\n\n  @tracked unavailablePath;\n  @tracked leaderboardName;\n  @tracked retryCount = 0;\n\n  displayName = (user) =>\n    this.siteSettings.prioritize_username_in_ux\n      ? user.username\n      : user.name || user.username;\n\n  get unavailable() {\n    return this.unavailablePath === this.path;\n  }\n\n  get title() {\n    return this.args.title\n      ? i18n(themePrefix(this.args.title))\n      : this.leaderboardName;\n  }\n\n  @bind\n  retry() {\n    this.retryCount++;\n  }\n\n  get path() {\n    const id = this.args.leaderboardId;\n    return id ? `/leaderboard/${id}` : \"/leaderboard\";\n  }\n\n  get leaderboardUrl() {\n    return getURL(this.path);\n  }\n\n  get skeleton() {\n    return { rows: \"user\", count: this.args.count };\n  }\n\n  get context() {\n    return {\n      path: this.path,\n      count: this.args.count,\n      period: this.args.period,\n      retryCount: this.retryCount,\n    };\n  }\n\n  @bind\n  async fetchLeaderboard({ path, count, period }) {\n    try {\n      const data = { user_limit: count };\n      if (period) {\n        data.period = period;\n      }\n      const result = await ajax(path, { data });\n      if (!this.isDestroying && !this.isDestroyed && path === this.path) {\n        this.leaderboardName = result?.leaderboard?.name;\n      }\n      return result?.users?.length ? result : null;\n    } catch (error) {\n      if (error.jqXHR?.status === 403 || error.jqXHR?.status === 404) {\n        if (!this.isDestroying && !this.isDestroyed && path === this.path) {\n          this.unavailablePath = path;\n        }\n        return null;\n      }\n      throw error;\n    }\n  }\n\n  <template>\n    {{#unless this.unavailable}}\n      <BlockPanel\n        @title={{this.title}}\n        @icon={{@icon}}\n        @mobile={{@mobile}}\n        @asyncData={{this.fetchLeaderboard}}\n        @context={{this.context}}\n        @skeleton={{this.skeleton}}\n        @onRetry={{this.retry}}\n        class=\"block-leaderboard\"\n      >\n        <:content as |data|>\n          <ol class=\"block-leaderboard__list\">\n            {{#each data.users as |user|}}\n              <li class=\"block-leaderboard__row\">\n                <span class=\"block-leaderboard__rank\">{{user.position}}</span>\n                <DUserAvatar @user={{user}} @size=\"small\" />\n                <DUserLink @user={{user}} class=\"block-leaderboard__name\">\n                  {{this.displayName user}}\n                </DUserLink>\n                <span class=\"block-leaderboard__score\">\n                  {{dNumber user.total_score}}\n                </span>\n              </li>\n            {{/each}}\n          </ol>\n        </:content>\n        <:empty>\n          <p class=\"block-leaderboard__empty\">\n            {{i18n (themePrefix \"leaderboard.empty\")}}\n          </p>\n        </:empty>\n        <:footer>\n          <a class=\"block-panel__link\" href={{this.leaderboardUrl}}>\n            {{i18n (themePrefix \"leaderboard.view_all\")}}\n          </a>\n        </:footer>\n      </BlockPanel>\n    {{/unless}}\n  </template>\n}\n","import Component from \"@glimmer/component\";\nimport { themePrefix } from \"virtual:theme\";\nimport { block } from \"discourse/blocks\";\nimport getURL from \"discourse/lib/get-url\";\nimport dIcon from \"discourse/ui-kit/helpers/d-icon\";\nimport { i18n } from \"discourse-i18n\";\nimport BlockPanel from \"../components/block-panel\";\n\nfunction isExternal(url) {\n  try {\n    return (\n      new URL(url, window.location.origin).origin !== window.location.origin\n    );\n  } catch {\n    return false;\n  }\n}\n\nfunction normalizeLink(link) {\n  const url = link.url?.trim();\n  if (!link.label?.trim() || !url) {\n    return null;\n  }\n  const external = isExternal(url);\n  return {\n    label: link.label.trim(),\n    description: link.description?.trim() || null,\n    icon: link.icon?.trim() || null,\n    url:\n      /^[a-z][a-z\\d+.-]*:/i.test(url) || url.startsWith(\"//\")\n        ? url\n        : getURL(url.startsWith(\"/\") ? url : `/${url}`),\n    external,\n  };\n}\n\n// The layout selects the resource links for the current category and passes\n// them here. Link fields follow core's link-list block (label, url, icon,\n// description) so the content transfers to it unchanged.\n@block(\"theme:discovery-sidebar:resources\", {\n  description: \"A titled list of resource links\",\n  args: {\n    title: { type: \"string\", required: true },\n    icon: { type: \"string\" },\n    mobile: { type: \"boolean\", default: false },\n    links: { type: \"array\", default: [] },\n  },\n})\nexport default class BlockResources extends Component {\n  get links() {\n    return (this.args.links ?? []).map(normalizeLink).filter(Boolean);\n  }\n\n  <template>\n    {{#if this.links.length}}\n      <BlockPanel\n        @title={{i18n (themePrefix @title)}}\n        @icon={{@icon}}\n        @mobile={{@mobile}}\n        class=\"block-resources\"\n      >\n        <:content>\n          <ul class=\"block-resources__list\">\n            {{#each this.links as |link|}}\n              <li class=\"block-resources__item\">\n                <a\n                  class=\"block-resources__link\"\n                  href={{link.url}}\n                  target={{if link.external \"_blank\"}}\n                  rel={{if link.external \"noopener noreferrer\"}}\n                >\n                  {{#if link.icon}}\n                    <span class=\"block-resources__icon\">{{dIcon\n                        link.icon\n                      }}</span>\n                  {{/if}}\n                  <span class=\"block-resources__text\">\n                    <span class=\"block-resources__label\">{{link.label}}</span>\n                    {{#if link.description}}\n                      <span\n                        class=\"block-resources__description\"\n                      >{{link.description}}</span>\n                    {{/if}}\n                  </span>\n                </a>\n              </li>\n            {{/each}}\n          </ul>\n        </:content>\n      </BlockPanel>\n    {{/if}}\n  </template>\n}\n","import Component from \"@glimmer/component\";\nimport { trustHTML } from \"@ember/template\";\nimport dEmoji from \"discourse/ui-kit/helpers/d-emoji\";\nimport dIcon from \"discourse/ui-kit/helpers/d-icon\";\n\n// The category's visual mark in whatever style the category uses: its emoji,\n// its icon, or a colour square.\nexport default class CategoryMark extends Component {\n  get style() {\n    return trustHTML(`--category-badge-color: #${this.args.category.color}`);\n  }\n\n  <template>\n    <span\n      class=\"category-mark --{{@category.style_type}}\"\n      style={{this.style}}\n      aria-hidden=\"true\"\n    >\n      {{#if (eq @category.style_type \"emoji\")}}\n        {{dEmoji @category.emoji}}\n      {{else if (eq @category.style_type \"icon\")}}\n        {{dIcon @category.icon}}\n      {{else}}\n        <span class=\"category-mark__square\"></span>\n      {{/if}}\n    </span>\n  </template>\n}\n\nfunction eq(a, b) {\n  return a === b;\n}\n","// The space of a category page is its top-level category: a subcategory page\n// belongs to the parent's space. No category means a global list.\nexport function spaceOf(category) {\n  return category?.parentCategory ?? category ?? null;\n}\n","import Component from \"@glimmer/component\";\nimport { service } from \"@ember/service\";\nimport { themePrefix } from \"virtual:theme\";\nimport { block } from \"discourse/blocks\";\nimport { number } from \"discourse/lib/formatter\";\nimport getURL from \"discourse/lib/get-url\";\nimport { i18n } from \"discourse-i18n\";\nimport BlockPanel from \"../components/block-panel\";\nimport CategoryMark from \"../components/category-mark\";\nimport { spaceOf } from \"../lib/space\";\n\n// The current space: the top-level category of the page and all its\n// subcategories, the current one highlighted. On global lists (Latest, Top,\n// tags) the panel lists every top-level category instead, under @title. All\n// content comes from the route and the site's category list, so there is no\n// data setting and no loading state; the args are display choices. The\n// spaces setting decides on which categories the layout renders it and where\n// its \"All spaces\" link goes.\n@block(\"theme:discovery-sidebar:space\", {\n  description: \"The current top-level category and its subcategories\",\n  args: {\n    title: { type: \"string\", required: true },\n    icon: { type: \"string\" },\n    mobile: { type: \"boolean\", default: false },\n    showDescription: { type: \"boolean\", default: true },\n    showTopicCounts: { type: \"boolean\", default: true },\n    allSpacesUrl: {\n      type: \"string\",\n      default: \"/\",\n      enum: [\"/\", \"/latest\", \"/categories\"],\n    },\n  },\n})\nexport default class BlockSpace extends Component {\n  @service discovery;\n  @service site;\n\n  isCurrent = (category) => category.id === this.category?.id;\n\n  get allSpacesUrl() {\n    return getURL(this.args.allSpacesUrl ?? \"/\");\n  }\n\n  get category() {\n    return this.discovery.category;\n  }\n\n  get space() {\n    return spaceOf(this.category);\n  }\n\n  get subcategories() {\n    return this.visible(this.space?.subcategories ?? []);\n  }\n\n  get topLevelCategories() {\n    return this.visible(\n      this.site.categories.filter((c) => !c.parent_category_id)\n    );\n  }\n\n  visible(categories) {\n    return categories.filter((c) => !c.isHidden && !c.isUncategorizedCategory);\n  }\n\n  <template>\n    {{#if this.space}}\n      <BlockPanel @mobile={{@mobile}} class=\"block-space\">\n        <:header>\n          <div\n            class=\"block-space__intro\n              {{if (this.isCurrent this.space) '--current'}}\"\n          >\n            <a\n              class=\"block-space__head\"\n              href={{this.space.url}}\n              aria-current={{if (this.isCurrent this.space) \"page\"}}\n            >\n              <CategoryMark @category={{this.space}} />\n              <span class=\"block-space__name\">{{this.space.displayName}}</span>\n            </a>\n            {{#if @showDescription}}\n              {{#if this.space.descriptionText}}\n                <p\n                  class=\"block-space__description\"\n                >{{this.space.descriptionText}}</p>\n              {{/if}}\n            {{/if}}\n          </div>\n        </:header>\n        <:content>\n          {{#if this.subcategories.length}}\n            <ul class=\"block-space__list\">\n              {{#each this.subcategories as |subcategory|}}\n                <li\n                  class=\"block-space__item\n                    {{if (this.isCurrent subcategory) '--current'}}\"\n                >\n                  <a\n                    class=\"block-space__link\"\n                    href={{subcategory.url}}\n                    aria-current={{if (this.isCurrent subcategory) \"page\"}}\n                  >\n                    <CategoryMark @category={{subcategory}} />\n                    <span\n                      class=\"block-space__name\"\n                    >{{subcategory.displayName}}</span>\n                    {{#if @showTopicCounts}}\n                      <span class=\"block-space__count\">\n                        {{i18n\n                          (themePrefix \"space.topic_count\")\n                          count=subcategory.topic_count\n                          formatted_number=(number subcategory.topic_count)\n                        }}\n                      </span>\n                    {{/if}}\n                  </a>\n                </li>\n              {{/each}}\n            </ul>\n          {{/if}}\n        </:content>\n        <:footer>\n          <a class=\"block-panel__link\" href={{this.allSpacesUrl}}>\n            {{i18n (themePrefix \"space.all_spaces_link\")}}\n          </a>\n        </:footer>\n      </BlockPanel>\n    {{else if this.topLevelCategories.length}}\n      <BlockPanel\n        @title={{i18n (themePrefix @title)}}\n        @icon={{@icon}}\n        @mobile={{@mobile}}\n        class=\"block-space --global\"\n      >\n        <:content>\n          <ul class=\"block-space__list\">\n            {{#each this.topLevelCategories as |category|}}\n              <li class=\"block-space__item\">\n                <a class=\"block-space__link\" href={{category.url}}>\n                  <CategoryMark @category={{category}} />\n                  <span\n                    class=\"block-space__name\"\n                  >{{category.displayName}}</span>\n                  {{#if @showTopicCounts}}\n                    <span class=\"block-space__count\">\n                      {{i18n\n                        (themePrefix \"space.topic_count\")\n                        count=category.totalTopicCount\n                        formatted_number=(number category.totalTopicCount)\n                      }}\n                    </span>\n                  {{/if}}\n                </a>\n              </li>\n            {{/each}}\n          </ul>\n        </:content>\n      </BlockPanel>\n    {{/if}}\n  </template>\n}\n","import Component from \"@glimmer/component\";\nimport { tracked } from \"@glimmer/tracking\";\nimport { service } from \"@ember/service\";\nimport { themePrefix } from \"virtual:theme\";\nimport { block } from \"discourse/blocks\";\nimport TopicLink from \"discourse/components/topic-list/topic-link\";\nimport { bind } from \"discourse/lib/decorators\";\nimport getURL from \"discourse/lib/get-url\";\nimport Category from \"discourse/models/category\";\nimport dCategoryLink from \"discourse/ui-kit/helpers/d-category-link\";\nimport dFormatDate from \"discourse/ui-kit/helpers/d-format-date\";\nimport { i18n } from \"discourse-i18n\";\nimport BlockPanel from \"../components/block-panel\";\nimport { spaceOf } from \"../lib/space\";\n\n// The layout selects the topic list entry for the current category and\n// passes its order and tag here. Topics come from the current top-level\n// category and its subcategories, or from the whole site on global lists, so\n// \"View all\" stays on the same list. Pinned\n// topics are left out: they already sit on top of the main list.\n@block(\"theme:discovery-sidebar:topics\", {\n  description: \"A compact topic list of the current space\",\n  args: {\n    title: { type: \"string\", required: true },\n    icon: { type: \"string\" },\n    mobile: { type: \"boolean\", default: false },\n    order: {\n      type: \"string\",\n      default: \"hot\",\n      enum: [\"hot\", \"activity\", \"created\", \"likes\", \"views\", \"posts\"],\n    },\n    tag: { type: \"string\" },\n    count: { type: \"number\", default: 5 },\n    showCategory: { type: \"boolean\", default: true },\n  },\n})\nexport default class BlockTopics extends Component {\n  @service discovery;\n  @service store;\n\n  @tracked retryCount = 0;\n\n  @bind\n  retry() {\n    this.retryCount++;\n  }\n\n  get space() {\n    return spaceOf(this.discovery.category);\n  }\n\n  get filter() {\n    const { order, tag } = this.args;\n    const space = this.space;\n    const list = order === \"hot\" ? \"hot\" : \"latest\";\n    const categoryPath = space\n      ? `c/${Category.slugFor(space)}/${space.id}`\n      : null;\n    const tagPath = tag ? encodeURIComponent(tag) : null;\n\n    if (categoryPath && tagPath) {\n      return `tags/${categoryPath}/${tagPath}/l/${list}`;\n    }\n    if (tagPath) {\n      return `tag/${tagPath}/l/${list}`;\n    }\n    if (categoryPath) {\n      return `${categoryPath}/l/${list}`;\n    }\n    return list;\n  }\n\n  // hot and activity are the native orders of the hot and latest lists.\n  get params() {\n    const { order } = this.args;\n    return [\"hot\", \"activity\"].includes(order) ? undefined : { order };\n  }\n\n  get viewAllUrl() {\n    const url = getURL(`/${this.filter}`);\n    return this.params ? `${url}?order=${this.params.order}` : url;\n  }\n\n  get skeleton() {\n    return { rows: \"topic\", count: this.args.count };\n  }\n\n  get context() {\n    return {\n      filter: this.filter,\n      params: this.params,\n      count: this.args.count,\n      retryCount: this.retryCount,\n    };\n  }\n\n  @bind\n  async fetchTopics({ filter, params, count }) {\n    const list = await this.store.findFiltered(\"topicList\", { filter, params });\n    const topics =\n      list.topics?.filter((topic) => !topic.pinned).slice(0, count) ?? [];\n    return topics.length ? topics : null;\n  }\n\n  <template>\n    <BlockPanel\n      @title={{i18n (themePrefix @title)}}\n      @icon={{@icon}}\n      @mobile={{@mobile}}\n      @asyncData={{this.fetchTopics}}\n      @context={{this.context}}\n      @skeleton={{this.skeleton}}\n      @onRetry={{this.retry}}\n      class=\"block-topics\"\n    >\n      <:content as |topics|>\n        <ol class=\"block-topics__list\">\n          {{#each topics as |topic|}}\n            <li class=\"block-topics__row\">\n              <TopicLink @topic={{topic}} class=\"block-topics__title\" />\n              <span class=\"block-topics__meta\">\n                {{#if @showCategory}}\n                  {{#if topic.category}}\n                    {{dCategoryLink topic.category}}\n                  {{/if}}\n                {{/if}}\n                <a class=\"block-topics__date\" href={{topic.lastPostUrl}}>\n                  {{dFormatDate topic.bumpedAt format=\"tiny\" noTitle=\"true\"}}\n                </a>\n              </span>\n            </li>\n          {{/each}}\n        </ol>\n      </:content>\n      <:empty>\n        <p class=\"block-topics__empty\">\n          {{i18n (themePrefix \"topics.empty\")}}\n        </p>\n      </:empty>\n      <:footer>\n        <a class=\"block-panel__link\" href={{this.viewAllUrl}}>\n          {{i18n (themePrefix \"topics.view_all\")}}\n        </a>\n      </:footer>\n    </BlockPanel>\n  </template>\n}\n","export function categoryScope(categories) {\n  return {\n    any: [\n      { type: \"outlet-arg\", path: \"category.id\", value: categories },\n      {\n        type: \"outlet-arg\",\n        path: \"category.parent_category_id\",\n        value: categories,\n      },\n    ],\n  };\n}\n\nexport function scopedEntries(entries) {\n  return (entries ?? []).filter((entry) => entry.categories?.length);\n}\n\n// An array makes spreading the optional fallback into a layout concise. An\n// empty result means no layout child is created, so no block renders.\nexport function defaultEntries(entries) {\n  const entry = (entries ?? []).find((item) => !item.categories?.length);\n  return entry ? [entry] : [];\n}\n\nexport function withoutEmptyContainers(entries) {\n  return entries.flatMap((entry) => {\n    if (!entry.children) {\n      return [entry];\n    }\n    const children = withoutEmptyContainers(entry.children);\n    return children.length ? [{ ...entry, children }] : [];\n  });\n}\n","import { settings } from \"virtual:theme\";\nimport BlockGroup from \"discourse/blocks/builtin/block-group\";\nimport BlockHead from \"discourse/blocks/builtin/block-head\";\nimport { apiInitializer } from \"discourse/lib/api\";\nimport BlockEvents from \"../blocks/block-events\";\nimport BlockLeaderboard from \"../blocks/block-leaderboard\";\nimport BlockResources from \"../blocks/block-resources\";\nimport BlockSpace from \"../blocks/block-space\";\nimport BlockTopics from \"../blocks/block-topics\";\nimport {\n  categoryScope,\n  defaultEntries,\n  scopedEntries,\n  withoutEmptyContainers,\n} from \"../lib/category-scoped-layout\";\n\nexport default apiInitializer((api) => {\n  api.renderBlocks(\n    \"sidebar-discovery\",\n    withoutEmptyContainers([\n      {\n        block: BlockGroup,\n        conditions: {\n          not: { type: \"route\", urls: [\"/categories\", \"/categories/**\"] },\n        },\n        children: [\n          {\n            block: BlockHead,\n            id: \"space\",\n            children: [\n              ...scopedEntries(settings.spaces).map((entry) => ({\n                block: BlockSpace,\n                args: {\n                  title: \"space.all_spaces\",\n                  icon: \"compass\",\n                  mobile: false,\n                  showDescription: true,\n                  showTopicCounts: true,\n                  allSpacesUrl: entry.all_spaces_url,\n                },\n                conditions: categoryScope(entry.categories),\n              })),\n              ...defaultEntries(settings.spaces).map((entry) => ({\n                block: BlockSpace,\n                args: {\n                  title: \"space.all_spaces\",\n                  icon: \"compass\",\n                  mobile: false,\n                  showDescription: true,\n                  showTopicCounts: true,\n                  allSpacesUrl: entry.all_spaces_url,\n                },\n              })),\n            ],\n          },\n          {\n            block: BlockHead,\n            id: \"events\",\n            children: [\n              ...scopedEntries(settings.events).map((entry) => ({\n                block: BlockEvents,\n                args: {\n                  title: \"events.title\",\n                  recentTitle: \"events.recent\",\n                  icon: \"calendar\",\n                  mobile: false,\n                  count: 3,\n                  categoryId: entry.events_category?.[0],\n                },\n                conditions: categoryScope(entry.categories),\n              })),\n              ...defaultEntries(settings.events).map((entry) => ({\n                block: BlockEvents,\n                args: {\n                  title: \"events.title\",\n                  recentTitle: \"events.recent\",\n                  icon: \"calendar\",\n                  mobile: false,\n                  count: 3,\n                  categoryId: entry.events_category?.[0],\n                },\n              })),\n            ],\n          },\n          {\n            block: BlockHead,\n            id: \"topics\",\n            children: [\n              ...scopedEntries(settings.topic_lists).map((entry) => ({\n                block: BlockTopics,\n                args: {\n                  title: \"topics.title\",\n                  icon: \"comments\",\n                  mobile: false,\n                  count: 5,\n                  showCategory: true,\n                  order: entry.order,\n                  tag: entry.tag?.[0],\n                },\n                conditions: categoryScope(entry.categories),\n              })),\n              ...defaultEntries(settings.topic_lists).map((entry) => ({\n                block: BlockTopics,\n                args: {\n                  title: \"topics.title\",\n                  icon: \"comments\",\n                  mobile: false,\n                  count: 5,\n                  showCategory: true,\n                  order: entry.order,\n                  tag: entry.tag?.[0],\n                },\n              })),\n            ],\n          },\n          {\n            block: BlockHead,\n            id: \"leaderboard\",\n            children: [\n              ...scopedEntries(settings.leaderboards).map((entry) => ({\n                block: BlockLeaderboard,\n                args: {\n                  icon: \"trophy\",\n                  mobile: false,\n                  count: 8,\n                  leaderboardId: entry.leaderboard_id,\n                },\n                conditions: categoryScope(entry.categories),\n              })),\n              ...defaultEntries(settings.leaderboards).map((entry) => ({\n                block: BlockLeaderboard,\n                args: {\n                  icon: \"trophy\",\n                  mobile: false,\n                  count: 8,\n                  leaderboardId: entry.leaderboard_id,\n                },\n              })),\n            ],\n          },\n          {\n            block: BlockHead,\n            id: \"resources\",\n            children: [\n              ...scopedEntries(settings.resources).map((entry) => ({\n                block: BlockResources,\n                args: {\n                  title: \"resources.title\",\n                  icon: \"book\",\n                  mobile: false,\n                  links: entry.links,\n                },\n                conditions: categoryScope(entry.categories),\n              })),\n              ...defaultEntries(settings.resources).map((entry) => ({\n                block: BlockResources,\n                args: {\n                  title: \"resources.title\",\n                  icon: \"book\",\n                  mobile: false,\n                  links: entry.links,\n                },\n              })),\n            ],\n          },\n        ],\n      },\n    ])\n  );\n});\n","import * as Mod1 from \"./discourse/api-initializers/sidebar-discovery-blocks\";\nimport * as Mod2 from \"./discourse/blocks/block-events\";\nimport * as Mod3 from \"./discourse/blocks/block-leaderboard\";\nimport * as Mod4 from \"./discourse/blocks/block-resources\";\nimport * as Mod5 from \"./discourse/blocks/block-space\";\nimport * as Mod6 from \"./discourse/blocks/block-topics\";\nimport * as Mod7 from \"./discourse/components/block-panel-error\";\nimport * as Mod8 from \"./discourse/components/block-panel-skeleton\";\nimport * as Mod9 from \"./discourse/components/block-panel\";\nimport * as Mod10 from \"./discourse/components/category-mark\";\nimport * as Mod11 from \"./discourse/lib/category-scoped-layout\";\nimport * as Mod12 from \"./discourse/lib/events\";\nimport * as Mod13 from \"./discourse/lib/space\";\nconst compatModules = {\n  \"discourse/api-initializers/sidebar-discovery-blocks\": Mod1,\n  \"discourse/blocks/block-events\": Mod2,\n  \"discourse/blocks/block-leaderboard\": Mod3,\n  \"discourse/blocks/block-resources\": Mod4,\n  \"discourse/blocks/block-space\": Mod5,\n  \"discourse/blocks/block-topics\": Mod6,\n  \"discourse/components/block-panel-error\": Mod7,\n  \"discourse/components/block-panel-skeleton\": Mod8,\n  \"discourse/components/block-panel\": Mod9,\n  \"discourse/components/category-mark\": Mod10,\n  \"discourse/lib/category-scoped-layout\": Mod11,\n  \"discourse/lib/events\": Mod12,\n  \"discourse/lib/space\": Mod13,\n};\nexport { compatModules };\nexport default compatModules;\n"],"names":["settings","getObjectForTheme","themePrefix","key","BlockPanelError","setComponentTemplate","createTemplateFactory","id","block","moduleName","scope","i18n","DButton","isStrictMode","templateOnly","BlockPanelSkeleton","Component","rows","count","this","args","shape","Array","from","length","_","index","eq","DSkeleton","a","b","BlockPanel","dIcon","DAsyncContent","requestLimit","Math","min","max","parse","value","allDay","test","date","Date","Number","isNaN","getTime","endOf","start","end","last","setHours","occurrences","event","map","row","starts_at","iso","ms","endMs","ends_at","filter","Boolean","serialize","occurrence","title","name","trim","post","topic","month","toLocaleDateString","I18n","currentBcp47Locale","day","getDate","url","getURL","async","search","categoryId","range","result","ajax","data","category_id","include_subcategories","include_details","limit","events","pick","choose","compare","sort","slice","fetchEvents","now","upcoming","after","toISOString","include_ongoing","order","recent","before","BlockEvents","dt7948","c","g","prototype","tracked","unavailable","i","retryCount","titleFor","recentTitle","retry","n","bind","eventsUrl","context","error","jqXHR","status","isDestroying","isDestroyed","description","type","required","icon","mobile","default","integer","BlockLeaderboard","service","siteSettings","unavailablePath","leaderboardName","displayName","user","prioritize_username_in_ux","username","path","leaderboardId","leaderboardUrl","skeleton","period","fetchLeaderboard","user_limit","leaderboard","users","DUserAvatar","DUserLink","dNumber","enum","normalizeLink","link","label","external","URL","window","location","origin","isExternal","startsWith","BlockResources","links","CategoryMark","style","trustHTML","category","color","dEmoji","spaceOf","parentCategory","BlockSpace","discovery","site","isCurrent","allSpacesUrl","space","subcategories","visible","topLevelCategories","categories","parent_category_id","isHidden","isUncategorizedCategory","number","showDescription","showTopicCounts","BlockTopics","store","tag","list","categoryPath","Category","slugFor","tagPath","encodeURIComponent","params","includes","undefined","viewAllUrl","fetchTopics","findFiltered","topics","pinned","TopicLink","dCategoryLink","dFormatDate","showCategory","categoryScope","any","scopedEntries","entries","entry","defaultEntries","find","item","withoutEmptyContainers","flatMap","children","sidebarDiscoveryBlocks","apiInitializer","api","renderBlocks","BlockGroup","conditions","not","urls","BlockHead","spaces","all_spaces_url","events_category","topic_lists","leaderboards","leaderboard_id","resources","compatModules","Mod2","Mod3","Mod4","Mod5","Mod6","Mod7","Mod8","Mod9","Mod10","Mod11","Mod12","Mod13"],"mappings":"6pFAEaA,EAAWC,EAAkB;AAEnC,SAASC,EAAYC,GAC1B,MAAO,0BAA0BA,GACnC;ACAA,MAAMC,EAAAC,EAAAC,EAAA,CAAAC,GAAA,KAAAC,MAAA,oYAAAC,WAAA,4B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