{"version":3,"file":"virtual_main.js","sources":["theme-11/virtual:init-settings","theme-11/virtual:theme","theme-11/discourse/api-initializers/theme-initializer.gjs","theme-11/virtual:main"],"sourcesContent":["import { registerSettings } from \"discourse/lib/theme-settings-store\";\n\nregisterSettings(11, {});\n","import { getObjectForTheme } from \"discourse/lib/theme-settings-store\";\n\nexport const settings = getObjectForTheme(11);\n\nexport function themePrefix(key) {\n  return `theme_translations.11.${key}`;\n}\n","import { apiInitializer } from \"discourse/lib/api\";\n\nexport default apiInitializer((api) => {\n  const THEMED_IFRAME_PATTERNS = [\n    \"https://slowtwitch.com\",\n    \"https://shop.slowtwitch.com/\",\n  ];\n\n  const selector = THEMED_IFRAME_PATTERNS\n    .map((p) => `iframe[src*=\"${p}\"]`)\n    .join(\", \");\n\n  function detectDiscourseTheme() {\n    const root = document.documentElement;\n    const colorScheme = getComputedStyle(root)\n      .getPropertyValue(\"color-scheme\")\n      .trim();\n    const prefersDark = window.matchMedia(\n      \"(prefers-color-scheme: dark)\"\n    ).matches;\n    return colorScheme === \"dark\" || prefersDark ? \"dark\" : \"light\";\n  }\n\n  function sendThemeToIframe(iframe) {\n    if (!iframe || !iframe.contentWindow) return;\n    const theme = detectDiscourseTheme();\n    iframe.contentWindow.postMessage({ type: \"stSetTheme\", theme }, \"*\");\n    iframe.style.opacity = \"1\";\n  }\n\n  function setupIframe(iframe) {\n    if (iframe.dataset.stThemeInitialized) return;\n    iframe.dataset.stThemeInitialized = \"true\";\n\n    iframe.addEventListener(\"load\", () => sendThemeToIframe(iframe));\n\n    window\n      .matchMedia(\"(prefers-color-scheme: dark)\")\n      .addEventListener(\"change\", () => sendThemeToIframe(iframe));\n  }\n\n  function handleThemedIframes() {\n    document.querySelectorAll(selector).forEach((iframe) => setupIframe(iframe));\n  }\n\n  api.onPageChange(() => {\n    handleThemedIframes();\n\n    const container = document.querySelector(\"#main-outlet\");\n    if (container && !container.stThemeObserver) {\n      const observer = new MutationObserver(() => handleThemedIframes());\n      observer.observe(container, { childList: true, subtree: true });\n      container.stThemeObserver = observer;\n    }\n  });\n});","import \"virtual:init-settings\";\n\nconst themeCompatModules = {};\nimport * as Mod1 from \"./discourse/api-initializers/theme-initializer\";\nthemeCompatModules[\"discourse/api-initializers/theme-initializer\"] = Mod1;\n\nexport default themeCompatModules;\n"],"names":["registerSettings","getObjectForTheme","themeInitializer","apiInitializer","api","selector","map","p","join","sendThemeToIframe","iframe","contentWindow","theme","root","document","documentElement","colorScheme","getComputedStyle","getPropertyValue","trim","prefersDark","window","matchMedia","matches","detectDiscourseTheme","postMessage","type","style","opacity","handleThemedIframes","querySelectorAll","forEach","dataset","stThemeInitialized","addEventListener","setupIframe","onPageChange","container","querySelector","stThemeObserver","observer","MutationObserver","observe","childList","subtree","themeCompatModules","Mod1"],"mappings":";AAEAA,EAAiB,GAAI,CAAA,GCAGC,EAAkB;ACA1C,IAAAC,EAAeC,EAAgBC,IAC7B,MAKMC,EALyB,CAC7B,yBACA,gCAICC,IAAKC,GAAM,gBAAgBA,OAC3BC,KAAK;AAaR,SAASC,EAAkBC,GACzB,IAAKA,IAAWA,EAAOC,cAAe;AACtC,MAAMC,EAbR,WACE,MAAMC,EAAOC,SAASC,gBAChBC,EAAcC,iBAAiBJ,GAClCK,iBAAiB,gBACjBC,OACGC,EAAcC,OAAOC,WACzB,gCACAC;AACF,MAAuB,SAAhBP,GAA0BI,EAAc,OAAS,OAC1D,CAIgBI;AACdd,EAAOC,cAAcc,YAAY,CAAEC,KAAM,aAAcd,SAAS,KAChEF,EAAOiB,MAAMC,QAAU,GACzB,CAaA,SAASC,IACPf,SAASgB,iBAAiBzB,GAAU0B,QAASrB,GAZ/C,SAAqBA,GACfA,EAAOsB,QAAQC,qBACnBvB,EAAOsB,QAAQC,mBAAqB,OAEpCvB,EAAOwB,iBAAiB,OAAQ,IAAMzB,EAAkBC,IAExDW,OACGC,WAAW,gCACXY,iBAAiB,SAAU,IAAMzB,EAAkBC,IACxD,CAG0DyB,CAAYzB,GACtE,CAEAN,EAAIgC,aAAa,KACfP;AAEA,MAAMQ,EAAYvB,SAASwB,cAAc;AACzC,GAAID,IAAcA,EAAUE,gBAAiB,CAC3C,MAAMC,EAAW,IAAIC,iBAAiB,IAAMZ;AAC5CW,EAASE,QAAQL,EAAW,CAAEM,WAAW,EAAMC,SAAS,IACxDP,EAAUE,gBAAkBC,CAC9B;ACnDC,MAACK,EAAqB,CAAA;AAE3BA,EAAmB,gDAAkDC;"}