{"version":3,"file":"attachResolvedThemes.js","names":["resolvedTheme: ThemeRegistrationResolved | undefined"],"sources":["../../../src/highlighter/themes/attachResolvedThemes.ts"],"sourcesContent":["import type {\n  DiffsHighlighter,\n  DiffsThemeNames,\n  ThemeRegistrationResolved,\n} from '../../types';\nimport { AttachedThemes, ResolvedThemes } from './constants';\n\nexport function attachResolvedThemes(\n  themes:\n    | DiffsThemeNames\n    | ThemeRegistrationResolved\n    | (DiffsThemeNames | ThemeRegistrationResolved)[],\n  highlighter: DiffsHighlighter\n): void {\n  themes = Array.isArray(themes) ? themes : [themes];\n  for (let themeRef of themes) {\n    let resolvedTheme: ThemeRegistrationResolved | undefined;\n    if (typeof themeRef === 'string') {\n      resolvedTheme = ResolvedThemes.get(themeRef);\n      if (resolvedTheme == null) {\n        throw new Error(\n          `loadResolvedThemes: ${themeRef} is not resolved, you must resolve it before calling loadResolvedThemes`\n        );\n      }\n    } else {\n      resolvedTheme = themeRef;\n      themeRef = themeRef.name;\n      if (!ResolvedThemes.has(themeRef)) {\n        ResolvedThemes.set(themeRef, resolvedTheme);\n      }\n    }\n    if (AttachedThemes.has(themeRef)) continue;\n    AttachedThemes.add(themeRef);\n    highlighter.loadThemeSync(resolvedTheme);\n  }\n}\n"],"mappings":";;;AAOA,SAAgB,qBACd,QAIA,aACM;AACN,UAAS,MAAM,QAAQ,OAAO,GAAG,SAAS,CAAC,OAAO;AAClD,MAAK,IAAI,YAAY,QAAQ;EAC3B,IAAIA;AACJ,MAAI,OAAO,aAAa,UAAU;AAChC,mBAAgB,eAAe,IAAI,SAAS;AAC5C,OAAI,iBAAiB,KACnB,OAAM,IAAI,MACR,uBAAuB,SAAS,yEACjC;SAEE;AACL,mBAAgB;AAChB,cAAW,SAAS;AACpB,OAAI,CAAC,eAAe,IAAI,SAAS,CAC/B,gBAAe,IAAI,UAAU,cAAc;;AAG/C,MAAI,eAAe,IAAI,SAAS,CAAE;AAClC,iBAAe,IAAI,SAAS;AAC5B,cAAY,cAAc,cAAc"}