ds-one 0.2.5-alpha.1 → 0.2.5-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["0-face/device.js", "0-face/i18n.js", "0-face/preferences.js", "0-face/pricing.js", "../node_modules/signal-polyfill/dist/index.js", "../node_modules/@lit-labs/signals/src/lib/signal-watcher.ts", "../node_modules/lit-html/src/directive.ts", "../node_modules/lit-html/src/lit-html.ts", "../node_modules/lit-html/src/directive-helpers.ts", "../node_modules/lit-html/src/async-directive.ts", "../node_modules/@lit-labs/signals/src/lib/watch.ts", "../node_modules/@lit-labs/signals/src/lib/html-tag.ts", "../node_modules/@lit-labs/signals/src/index.ts", "0-face/theme.js", "../node_modules/@lit/reactive-element/src/css-tag.ts", "../node_modules/@lit/reactive-element/src/reactive-element.ts", "../node_modules/lit-element/src/lit-element.ts", "2-core/ds-button.js", "../node_modules/lit-html/src/directives/unsafe-html.ts", "2-core/ds-icon.js", "2-core/ds-cycle.js", "2-core/ds-text.js", "2-core/ds-tooltip.js", "2-core/ds-date.js", "3-unit/ds-list.js", "3-unit/ds-row.js", "3-unit/ds-table.js", "4-page/ds-grid.js", "4-page/ds-layout.js"],
4
- "sourcesContent": ["// 2025-04-23-device.ts\n// Device detection and context utilities\n/**\n * Comprehensive mobile device detection\n * Combines user agent detection, touch capability, and viewport size\n */\nexport function detectMobileDevice() {\n if (typeof navigator === \"undefined\" || typeof window === \"undefined\") {\n return false;\n }\n const nav = navigator;\n const win = window;\n const ua = (nav && (nav.userAgent || nav.vendor)) || (win && win.opera) || \"\";\n // User agent based detection\n const uaMatchesMobile = /Mobile|Android|iP(ad|hone|od)|IEMobile|BlackBerry|Kindle|Silk-Accelerated|(hpw|web)OS|Opera M(obi|ini)|Windows Phone|Phone|Tablet/i.test(ua);\n // Touch capability detection\n const touchPoints = (nav && nav.maxTouchPoints) || 0;\n const isTouchCapable = touchPoints > 1;\n // Viewport detection\n const narrowViewport = win\n ? Math.min(win.innerWidth || 0, win.innerHeight || 0) <= 820\n : false;\n return uaMatchesMobile || (isTouchCapable && narrowViewport);\n}\n/**\n * Get detailed device information\n */\nexport function getDeviceInfo() {\n const isMobile = detectMobileDevice();\n const nav = navigator;\n const win = window;\n const touchPoints = (nav && nav.maxTouchPoints) || 0;\n const isTouchCapable = touchPoints > 1;\n // Use clientWidth instead of innerWidth to exclude scrollbars\n const screenWidth = typeof document !== \"undefined\"\n ? document.documentElement.clientWidth\n : win?.innerWidth || 0;\n const screenHeight = typeof document !== \"undefined\"\n ? document.documentElement.clientHeight\n : win?.innerHeight || 0;\n const isTablet = isMobile && Math.min(screenWidth, screenHeight) >= 600;\n return {\n isMobile,\n isTablet,\n isDesktop: !isMobile,\n isTouchCapable,\n deviceType: isMobile ? (isTablet ? \"tablet\" : \"mobile\") : \"desktop\",\n userAgent: (nav && (nav.userAgent || nav.vendor)) || \"\",\n screenWidth,\n screenHeight,\n };\n}\n/**\n * Initialize device detection and log to console\n */\nexport function initDeviceDetection() {\n const deviceInfo = getDeviceInfo();\n // Calculate and set scaling factor for mobile\n if (deviceInfo.isMobile && typeof document !== \"undefined\") {\n // Design width: 280px (14 columns \u00D7 20px)\n const designWidth = 280;\n const actualWidth = deviceInfo.screenWidth;\n const scalingFactor = actualWidth / designWidth;\n // Set CSS custom property for scaling\n document.documentElement.style.setProperty(\"--scaling-factor-mobile\", scalingFactor.toFixed(3));\n console.log(`[DS one] Mobile device detected - ${deviceInfo.deviceType} (${deviceInfo.screenWidth}x${deviceInfo.screenHeight}), scaling factor: ${scalingFactor.toFixed(2)}`);\n }\n else {\n // Desktop - no scaling\n if (typeof document !== \"undefined\") {\n document.documentElement.style.setProperty(\"--scaling-factor-mobile\", \"1\");\n }\n console.log(`[DS one] Desktop device detected (${deviceInfo.screenWidth}x${deviceInfo.screenHeight})`);\n }\n // Log additional details in development mode\n if (typeof window !== \"undefined\" && window.DS_ONE_DEBUG) {\n console.log(\"[DS one] Device Info:\", {\n type: deviceInfo.deviceType,\n isMobile: deviceInfo.isMobile,\n isTablet: deviceInfo.isTablet,\n isDesktop: deviceInfo.isDesktop,\n isTouchCapable: deviceInfo.isTouchCapable,\n viewport: `${deviceInfo.screenWidth}x${deviceInfo.screenHeight}`,\n userAgent: deviceInfo.userAgent,\n });\n }\n return deviceInfo;\n}\n// Auto-initialize when module loads\nif (typeof window !== \"undefined\") {\n // Wait for DOM to be ready\n if (document.readyState === \"loading\") {\n document.addEventListener(\"DOMContentLoaded\", () => {\n initDeviceDetection();\n });\n }\n else {\n // DOM is already ready\n initDeviceDetection();\n }\n // Recalculate on resize (debounced)\n let resizeTimeout;\n window.addEventListener(\"resize\", () => {\n clearTimeout(resizeTimeout);\n resizeTimeout = setTimeout(() => {\n initDeviceDetection();\n }, 100);\n });\n}\n", "// Bundled translations (keys.json may not exist - will use external translations if not available)\n// This is a fallback for when external translations aren't loaded\nlet translationKeys = {};\n// Primary language list \u2013 prioritise the 10 requested languages when cycling\nconst LANGUAGE_PRIORITY_ORDER = [\n \"da\",\n \"nb\",\n \"sv\",\n \"pt\",\n \"es\",\n \"zh\",\n \"ko\",\n \"ja\",\n \"en\",\n \"de\",\n];\nconst LANGUAGE_PRIORITY_LOOKUP = new Map(LANGUAGE_PRIORITY_ORDER.map((code, index) => [code, index]));\n// Fallback language names if Intl.DisplayNames is not available\nconst FALLBACK_LANGUAGE_NAMES = {\n da: \"Danish\",\n \"da-dk\": \"Danish\",\n nb: \"Norwegian\",\n \"nb-no\": \"Norwegian\",\n sv: \"Swedish\",\n \"sv-se\": \"Swedish\",\n de: \"German\",\n \"de-de\": \"German\",\n en: \"English\",\n \"en-us\": \"English\",\n pt: \"Portuguese\",\n \"pt-pt\": \"Portuguese\",\n \"pt-br\": \"Portuguese (Brazil)\",\n es: \"Spanish\",\n \"es-es\": \"Spanish\",\n \"es-mx\": \"Spanish (Mexico)\",\n zh: \"Chinese\",\n \"zh-hans\": \"Chinese (Simplified)\",\n \"zh-hant\": \"Chinese (Traditional)\",\n ja: \"Japanese\",\n \"ja-jp\": \"Japanese\",\n ko: \"Korean\",\n \"ko-kr\": \"Korean\",\n};\nconst DISPLAY_NAME_CACHE = new Map();\nlet displayNameFallbackWarningShown = false;\n// CDN Loader: Automatically detects and loads translation JSON files\n// for CDN users who want to use external translations\nconst DEFAULT_TRANSLATION_FILE = \"./translations.json\";\nlet loadAttempted = false;\nfunction normalizeCandidate(path) {\n if (!path) {\n return null;\n }\n const trimmed = path.trim();\n if (!trimmed) {\n return null;\n }\n if (trimmed.startsWith(\"./\") ||\n trimmed.startsWith(\"../\") ||\n trimmed.startsWith(\"/\") ||\n /^https?:\\/\\//i.test(trimmed)) {\n return trimmed;\n }\n return `./${trimmed}`;\n}\nfunction findAttributeCandidate() {\n if (typeof document === \"undefined\") {\n return null;\n }\n const scriptWithAttribute = document.querySelector(\"script[data-ds-one-translations]\");\n const scriptCandidate = scriptWithAttribute?.getAttribute(\"data-ds-one-translations\");\n if (scriptCandidate) {\n return scriptCandidate;\n }\n const metaCandidate = document\n .querySelector('meta[name=\"ds-one:translations\"]')\n ?.getAttribute(\"content\");\n if (metaCandidate) {\n return metaCandidate;\n }\n const linkCandidate = document\n .querySelector('link[rel=\"ds-one-translations\"]')\n ?.getAttribute(\"href\");\n if (linkCandidate) {\n return linkCandidate;\n }\n return null;\n}\nfunction resolveTranslationSources() {\n const candidates = [];\n const windowCandidate = typeof window !== \"undefined\" ? window.DS_ONE_TRANSLATIONS_FILE : null;\n const attributeCandidate = findAttributeCandidate();\n // Only use explicitly configured paths, or the single default\n const windowNormalized = normalizeCandidate(windowCandidate ?? \"\");\n if (windowNormalized) {\n candidates.push(windowNormalized);\n }\n const attrNormalized = normalizeCandidate(attributeCandidate ?? \"\");\n if (attrNormalized && !candidates.includes(attrNormalized)) {\n candidates.push(attrNormalized);\n }\n // Only try default if no explicit path was configured\n if (candidates.length === 0) {\n candidates.push(DEFAULT_TRANSLATION_FILE);\n }\n return candidates;\n}\nfunction validateTranslationMap(candidate) {\n if (!candidate || typeof candidate !== \"object\") {\n return false;\n }\n return Object.values(candidate).every((entry) => entry && typeof entry === \"object\");\n}\nasync function fetchTranslationFile(source) {\n try {\n const response = await fetch(source);\n if (!response.ok) {\n // 404 is expected if no translations file exists - don't log as error\n return null;\n }\n const translations = await response.json();\n if (!validateTranslationMap(translations)) {\n console.warn(`[DS one] Invalid translation format in ${source}. Expected object with language codes as keys.`);\n return null;\n }\n const languages = Object.keys(translations);\n if (languages.length === 0) {\n console.warn(`[DS one] No languages found in ${source}`);\n return null;\n }\n return translations;\n }\n catch {\n // Silently fail - file likely doesn't exist or isn't valid JSON\n return null;\n }\n}\n/**\n * Attempts to load translations from a JSON file in the same directory\n */\nasync function loadExternalTranslations() {\n // Only attempt once\n if (loadAttempted) {\n return false;\n }\n loadAttempted = true;\n if (typeof window === \"undefined\") {\n return false;\n }\n // Check if translations are already loaded (e.g., by the application)\n if (window.DS_ONE_TRANSLATIONS &&\n Object.keys(window.DS_ONE_TRANSLATIONS).length > 0) {\n console.log(`[DS one] Translations already loaded (${Object.keys(window.DS_ONE_TRANSLATIONS).length} languages), skipping auto-load`);\n return true;\n }\n const sources = resolveTranslationSources();\n for (const source of sources) {\n const translations = await fetchTranslationFile(source);\n if (!translations) {\n continue;\n }\n window.DS_ONE_TRANSLATIONS = translations;\n const languages = Object.keys(translations);\n console.log(`[DS one] External translations loaded from ${source}: ${languages.length} language(s) \u2013 ${languages.join(\", \")}`);\n window.dispatchEvent(new CustomEvent(\"translations-ready\"));\n return true;\n }\n console.info(`[DS one] No external translations found at ${sources[0] ?? DEFAULT_TRANSLATION_FILE}. Using bundled translations.`);\n return false;\n}\n// Get translation data - prioritize external, fall back to bundled\nfunction getTranslationData() {\n // Check for externally loaded translations first (CDN usage)\n if (typeof window !== \"undefined\" && window.DS_ONE_TRANSLATIONS) {\n return window.DS_ONE_TRANSLATIONS;\n }\n // Fall back to bundled translations\n return translationKeys;\n}\n// Cached translation data - use getter to always get fresh data\nlet translationData = getTranslationData();\nconst notionStore = new Map();\nconst defaultLanguage = \"en\";\nfunction extractPrimarySubtag(code) {\n if (!code) {\n return \"\";\n }\n return code.toLowerCase().split(/[-_]/)[0] ?? \"\";\n}\nfunction getLanguagePriority(code) {\n const primary = extractPrimarySubtag(code);\n const priority = LANGUAGE_PRIORITY_LOOKUP.get(primary);\n if (typeof priority === \"number\") {\n return priority;\n }\n return LANGUAGE_PRIORITY_ORDER.length;\n}\nfunction sortLanguageCodes(codes) {\n return [...codes].sort((a, b) => {\n const priorityA = getLanguagePriority(a);\n const priorityB = getLanguagePriority(b);\n if (priorityA !== priorityB) {\n return priorityA - priorityB;\n }\n return a.localeCompare(b);\n });\n}\nfunction getDisplayNameForLocale(locale, code) {\n const normalizedLocale = locale?.replace(\"_\", \"-\");\n if (!normalizedLocale) {\n return undefined;\n }\n try {\n let displayNames = DISPLAY_NAME_CACHE.get(normalizedLocale);\n if (!displayNames) {\n displayNames = new Intl.DisplayNames([normalizedLocale], {\n type: \"language\",\n });\n DISPLAY_NAME_CACHE.set(normalizedLocale, displayNames);\n }\n const cleanedCode = code.replace(\"_\", \"-\");\n // Try full tag first\n const fullMatch = displayNames.of(cleanedCode);\n if (fullMatch && fullMatch !== cleanedCode) {\n return fullMatch;\n }\n // Then the primary subtag\n const baseMatch = displayNames.of(extractPrimarySubtag(cleanedCode));\n if (baseMatch) {\n return baseMatch;\n }\n }\n catch (error) {\n // Intl.DisplayNames may not be supported; fall back gracefully\n if (!displayNameFallbackWarningShown) {\n console.info(\"[DS one] Intl.DisplayNames is not available, using fallback language names.\");\n displayNameFallbackWarningShown = true;\n }\n }\n return undefined;\n}\nfunction getFallbackDisplayName(code) {\n const normalized = code.toLowerCase().replace(\"_\", \"-\");\n const direct = FALLBACK_LANGUAGE_NAMES[normalized];\n if (direct) {\n return direct;\n }\n const primary = extractPrimarySubtag(normalized);\n return FALLBACK_LANGUAGE_NAMES[primary];\n}\nexport function getLanguageDisplayName(code, options = {}) {\n if (!code) {\n return \"\";\n }\n const localesToTry = [];\n if (options.locale) {\n localesToTry.push(options.locale);\n }\n if (typeof navigator !== \"undefined\") {\n if (Array.isArray(navigator.languages)) {\n localesToTry.push(...navigator.languages);\n }\n if (navigator.language) {\n localesToTry.push(navigator.language);\n }\n }\n localesToTry.push(defaultLanguage);\n localesToTry.push(\"en\");\n const tried = new Set();\n for (const locale of localesToTry) {\n if (!locale || tried.has(locale)) {\n continue;\n }\n tried.add(locale);\n const displayName = getDisplayNameForLocale(locale, code);\n if (displayName) {\n return displayName;\n }\n }\n const fallback = getFallbackDisplayName(code);\n if (fallback) {\n return fallback;\n }\n // Fall back to the primary subtag in uppercase\n const primary = extractPrimarySubtag(code);\n return primary ? primary.toUpperCase() : code;\n}\nconst BROWSER_LANGUAGE_PREFERENCES = {\n da: \"da\",\n \"da-dk\": \"da\",\n no: \"nb\",\n nb: \"nb\",\n \"nb-no\": \"nb\",\n nn: \"nn\",\n \"nn-no\": \"nn\",\n sv: \"sv\",\n \"sv-se\": \"sv\",\n pt: \"pt\",\n \"pt-pt\": \"pt\",\n \"pt-br\": \"pt\",\n es: \"es\",\n \"es-es\": \"es\",\n \"es-mx\": \"es\",\n zh: \"zh\",\n \"zh-cn\": \"zh\",\n \"zh-hans\": \"zh\",\n \"zh-tw\": \"zh\",\n \"zh-hant\": \"zh\",\n ko: \"ko\",\n \"ko-kr\": \"ko\",\n ja: \"ja\",\n \"ja-jp\": \"ja\",\n en: \"en\",\n \"en-us\": \"en\",\n \"en-gb\": \"en\",\n de: \"de\",\n \"de-de\": \"de\",\n};\nfunction resolvePreferredLanguage(languageTag) {\n if (!languageTag) {\n return null;\n }\n const normalized = languageTag.toLowerCase().replace(\"_\", \"-\");\n const directMatch = BROWSER_LANGUAGE_PREFERENCES[normalized];\n if (directMatch) {\n return directMatch;\n }\n const primary = extractPrimarySubtag(normalized);\n const primaryMatch = BROWSER_LANGUAGE_PREFERENCES[primary];\n if (primaryMatch) {\n return primaryMatch;\n }\n return languageTag;\n}\n// Helper function to get browser language\nexport function getBrowserLanguage() {\n if (typeof navigator === \"undefined\") {\n return defaultLanguage;\n }\n const browserLang = navigator.language;\n if (browserLang) {\n const resolved = resolvePreferredLanguage(browserLang);\n if (resolved) {\n return resolved;\n }\n }\n if (Array.isArray(navigator.languages)) {\n for (const candidate of navigator.languages) {\n const resolved = resolvePreferredLanguage(candidate);\n if (resolved) {\n return resolved;\n }\n }\n }\n return defaultLanguage;\n}\n// Get stored language from localStorage\nconst storedLanguage = typeof window !== \"undefined\"\n ? (window.localStorage?.getItem(\"ds-one:language\") ?? undefined)\n : undefined;\n// Create a reactive signal for the current language (Portfolio pattern)\nexport const currentLanguage = {\n value: localStorage.getItem(\"language\") || getBrowserLanguage(),\n set: function (lang) {\n this.value = lang;\n localStorage.setItem(\"language\", lang);\n window.dispatchEvent(new CustomEvent(\"language-changed\", {\n detail: { language: lang },\n bubbles: true,\n composed: true,\n }));\n },\n};\n// Auto-load translations when this module is imported (for CDN bundle)\nif (typeof window !== \"undefined\") {\n // Wait a bit to ensure the DOM is ready\n if (document.readyState === \"loading\") {\n document.addEventListener(\"DOMContentLoaded\", () => {\n loadExternalTranslations();\n });\n }\n else {\n // DOM is already ready\n loadExternalTranslations();\n }\n}\n// Listen for external translations being loaded\nif (typeof window !== \"undefined\") {\n window.addEventListener(\"translations-ready\", () => {\n // Refresh translation data from external source\n translationData = getTranslationData();\n // Dispatch that translations are loaded\n window.dispatchEvent(new CustomEvent(\"translations-loaded\"));\n window.notionDataLoaded = true;\n // Dispatch language-changed to update all components\n const currentLang = currentLanguage.value;\n window.dispatchEvent(new CustomEvent(\"language-changed\", {\n detail: { language: currentLang },\n bubbles: true,\n composed: true,\n }));\n });\n}\n// Initialize translations on module load\n// Use setTimeout to give other parts of the app time to set up event listeners first\nsetTimeout(() => {\n // Since we directly imported the data, just dispatch the events\n window.dispatchEvent(new CustomEvent(\"translations-loaded\"));\n window.notionDataLoaded = true;\n // Also dispatch language-changed with the current language\n const currentLang = currentLanguage.value;\n window.dispatchEvent(new CustomEvent(\"language-changed\", {\n detail: { language: currentLang },\n bubbles: true,\n composed: true,\n }));\n}, 100);\n// Get translation by key\nexport function translate(key) {\n const lang = currentLanguage.value;\n // Check if key exists in current language\n if (translationData?.[lang]?.[key]) {\n return translationData[lang][key];\n }\n // Try fallback to English\n if (lang !== defaultLanguage && translationData?.[defaultLanguage]?.[key]) {\n return translationData[defaultLanguage][key];\n }\n console.warn(`[translate] No translation found for key \"${key}\"`);\n return key;\n}\nexport function hasTranslation(key, language = currentLanguage.value) {\n if (!key) {\n return false;\n }\n const langData = translationData?.[language];\n if (langData && Object.prototype.hasOwnProperty.call(langData, key)) {\n return true;\n }\n if (language !== defaultLanguage &&\n translationData?.[defaultLanguage] &&\n Object.prototype.hasOwnProperty.call(translationData[defaultLanguage], key)) {\n return true;\n }\n return false;\n}\n// Get text - synchronous version for components\nexport function getText(key) {\n return translate(key);\n}\n// Get text from translation data (async for compatibility)\nexport async function getNotionText(key, language = currentLanguage.value) {\n if (!key) {\n return null;\n }\n if (!translationData || !translationData[language]) {\n return null;\n }\n const text = translationData[language][key];\n if (text) {\n return text;\n }\n // Fallback to English\n if (language !== defaultLanguage && translationData[defaultLanguage]?.[key]) {\n return translationData[defaultLanguage][key];\n }\n return null;\n}\n// Store Notion text (for dynamic updates)\nexport function setNotionText(key, value, language = currentLanguage.value) {\n if (!key)\n return;\n const bucket = getLanguageBucket(language);\n bucket.set(key, value);\n}\nfunction getLanguageBucket(language) {\n if (!notionStore.has(language)) {\n notionStore.set(language, new Map());\n }\n return notionStore.get(language);\n}\n// Get available languages - dynamically detect from loaded data\nexport function getAvailableLanguages() {\n // Always get fresh translation data\n const currentData = getTranslationData();\n if (currentData && Object.keys(currentData).length > 0) {\n const languages = Object.keys(currentData);\n return Promise.resolve(sortLanguageCodes(languages));\n }\n return Promise.resolve([defaultLanguage]);\n}\n// Synchronous version for immediate use\nexport function getAvailableLanguagesSync() {\n const currentData = getTranslationData();\n if (currentData && Object.keys(currentData).length > 0) {\n return sortLanguageCodes(Object.keys(currentData));\n }\n return [defaultLanguage];\n}\n// Load translations programmatically (for compatibility)\nexport function loadTranslations(language, translations) {\n // Since we have static data, this is mainly for compatibility\n console.log(`Loading additional translations for ${language}:`, Object.keys(translations).length, \"keys\");\n}\n// Set language (Portfolio pattern)\nexport function setLanguage(language) {\n // Update the language in localStorage first\n localStorage.setItem(\"language\", language);\n // Then update the signal - this should trigger effects in components\n // that are subscribed to the signal\n currentLanguage.set(language);\n // Dispatch a custom event so non-signal-based components can update\n window.dispatchEvent(new CustomEvent(\"language-changed\", {\n detail: { language },\n bubbles: true,\n composed: true,\n }));\n}\n", "export function savePreferences(preferences) {\n if (typeof window === \"undefined\") {\n return;\n }\n try {\n const raw = window.localStorage?.getItem(\"ds-one:preferences\");\n const existing = raw ? JSON.parse(raw) : {};\n const next = { ...existing, ...preferences };\n window.localStorage?.setItem(\"ds-one:preferences\", JSON.stringify(next));\n }\n catch (error) {\n console.warn(\"ds-one: unable to persist preferences\", error);\n }\n}\n", "/**\n * Currency label utilities for regional price display\n *\n * Note: This module provides currency symbols/labels based on language and region.\n * Consider moving this functionality into i18n.ts as it's region/locale-related.\n * Actual price values will be stored in a database or managed via Stripe.\n */\n// Simple price label mapping based on language/country\nconst PRICE_LABELS = {\n da: \"kr.\",\n nb: \"kr.\",\n sv: \"kr.\",\n de: \"\u20AC\",\n en: \"$\",\n pt: \"\u20AC\",\n es: \"\u20AC\",\n zh: \"\u00A5\",\n ja: \"\u00A5\",\n ko: \"\u20A9\",\n};\nexport function getPriceLabel(options) {\n const { language, country } = options;\n // If country is provided, try to map it to a currency\n if (country) {\n const countryUpper = country.toUpperCase();\n // Add country-specific mappings if needed\n if (countryUpper === \"US\" || countryUpper === \"USA\") {\n return \"$\";\n }\n if (countryUpper === \"GB\" || countryUpper === \"UK\") {\n return \"\u00A3\";\n }\n if (countryUpper === \"JP\" || countryUpper === \"JPN\") {\n return \"\u00A5\";\n }\n if (countryUpper === \"CN\" || countryUpper === \"CHN\") {\n return \"\u00A5\";\n }\n if (countryUpper === \"KR\" || countryUpper === \"KOR\") {\n return \"\u20A9\";\n }\n }\n // Fall back to language-based mapping\n const primaryLang = language.toLowerCase().split(/[-_]/)[0];\n return PRICE_LABELS[primaryLang] || \"$\";\n}\n", "var __defProp = Object.defineProperty;\nvar __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;\nvar __publicField = (obj, key, value) => {\n __defNormalProp(obj, typeof key !== \"symbol\" ? key + \"\" : key, value);\n return value;\n};\nvar __accessCheck = (obj, member, msg) => {\n if (!member.has(obj))\n throw TypeError(\"Cannot \" + msg);\n};\nvar __privateIn = (member, obj) => {\n if (Object(obj) !== obj)\n throw TypeError('Cannot use the \"in\" operator on this value');\n return member.has(obj);\n};\nvar __privateAdd = (obj, member, value) => {\n if (member.has(obj))\n throw TypeError(\"Cannot add the same private member more than once\");\n member instanceof WeakSet ? member.add(obj) : member.set(obj, value);\n};\nvar __privateMethod = (obj, member, method) => {\n __accessCheck(obj, member, \"access private method\");\n return method;\n};\n/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\nfunction defaultEquals(a, b) {\n return Object.is(a, b);\n}\n/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\nlet activeConsumer = null;\nlet inNotificationPhase = false;\nlet epoch = 1;\nconst SIGNAL = /* @__PURE__ */ Symbol(\"SIGNAL\");\nfunction setActiveConsumer(consumer) {\n const prev = activeConsumer;\n activeConsumer = consumer;\n return prev;\n}\nfunction getActiveConsumer() {\n return activeConsumer;\n}\nfunction isInNotificationPhase() {\n return inNotificationPhase;\n}\nconst REACTIVE_NODE = {\n version: 0,\n lastCleanEpoch: 0,\n dirty: false,\n producerNode: void 0,\n producerLastReadVersion: void 0,\n producerIndexOfThis: void 0,\n nextProducerIndex: 0,\n liveConsumerNode: void 0,\n liveConsumerIndexOfThis: void 0,\n consumerAllowSignalWrites: false,\n consumerIsAlwaysLive: false,\n producerMustRecompute: () => false,\n producerRecomputeValue: () => {\n },\n consumerMarkedDirty: () => {\n },\n consumerOnSignalRead: () => {\n }\n};\nfunction producerAccessed(node) {\n if (inNotificationPhase) {\n throw new Error(\n typeof ngDevMode !== \"undefined\" && ngDevMode ? `Assertion error: signal read during notification phase` : \"\"\n );\n }\n if (activeConsumer === null) {\n return;\n }\n activeConsumer.consumerOnSignalRead(node);\n const idx = activeConsumer.nextProducerIndex++;\n assertConsumerNode(activeConsumer);\n if (idx < activeConsumer.producerNode.length && activeConsumer.producerNode[idx] !== node) {\n if (consumerIsLive(activeConsumer)) {\n const staleProducer = activeConsumer.producerNode[idx];\n producerRemoveLiveConsumerAtIndex(staleProducer, activeConsumer.producerIndexOfThis[idx]);\n }\n }\n if (activeConsumer.producerNode[idx] !== node) {\n activeConsumer.producerNode[idx] = node;\n activeConsumer.producerIndexOfThis[idx] = consumerIsLive(activeConsumer) ? producerAddLiveConsumer(node, activeConsumer, idx) : 0;\n }\n activeConsumer.producerLastReadVersion[idx] = node.version;\n}\nfunction producerIncrementEpoch() {\n epoch++;\n}\nfunction producerUpdateValueVersion(node) {\n if (!node.dirty && node.lastCleanEpoch === epoch) {\n return;\n }\n if (!node.producerMustRecompute(node) && !consumerPollProducersForChange(node)) {\n node.dirty = false;\n node.lastCleanEpoch = epoch;\n return;\n }\n node.producerRecomputeValue(node);\n node.dirty = false;\n node.lastCleanEpoch = epoch;\n}\nfunction producerNotifyConsumers(node) {\n if (node.liveConsumerNode === void 0) {\n return;\n }\n const prev = inNotificationPhase;\n inNotificationPhase = true;\n try {\n for (const consumer of node.liveConsumerNode) {\n if (!consumer.dirty) {\n consumerMarkDirty(consumer);\n }\n }\n } finally {\n inNotificationPhase = prev;\n }\n}\nfunction producerUpdatesAllowed() {\n return (activeConsumer == null ? void 0 : activeConsumer.consumerAllowSignalWrites) !== false;\n}\nfunction consumerMarkDirty(node) {\n var _a;\n node.dirty = true;\n producerNotifyConsumers(node);\n (_a = node.consumerMarkedDirty) == null ? void 0 : _a.call(node.wrapper ?? node);\n}\nfunction consumerBeforeComputation(node) {\n node && (node.nextProducerIndex = 0);\n return setActiveConsumer(node);\n}\nfunction consumerAfterComputation(node, prevConsumer) {\n setActiveConsumer(prevConsumer);\n if (!node || node.producerNode === void 0 || node.producerIndexOfThis === void 0 || node.producerLastReadVersion === void 0) {\n return;\n }\n if (consumerIsLive(node)) {\n for (let i = node.nextProducerIndex; i < node.producerNode.length; i++) {\n producerRemoveLiveConsumerAtIndex(node.producerNode[i], node.producerIndexOfThis[i]);\n }\n }\n while (node.producerNode.length > node.nextProducerIndex) {\n node.producerNode.pop();\n node.producerLastReadVersion.pop();\n node.producerIndexOfThis.pop();\n }\n}\nfunction consumerPollProducersForChange(node) {\n assertConsumerNode(node);\n for (let i = 0; i < node.producerNode.length; i++) {\n const producer = node.producerNode[i];\n const seenVersion = node.producerLastReadVersion[i];\n if (seenVersion !== producer.version) {\n return true;\n }\n producerUpdateValueVersion(producer);\n if (seenVersion !== producer.version) {\n return true;\n }\n }\n return false;\n}\nfunction producerAddLiveConsumer(node, consumer, indexOfThis) {\n var _a;\n assertProducerNode(node);\n assertConsumerNode(node);\n if (node.liveConsumerNode.length === 0) {\n (_a = node.watched) == null ? void 0 : _a.call(node.wrapper);\n for (let i = 0; i < node.producerNode.length; i++) {\n node.producerIndexOfThis[i] = producerAddLiveConsumer(node.producerNode[i], node, i);\n }\n }\n node.liveConsumerIndexOfThis.push(indexOfThis);\n return node.liveConsumerNode.push(consumer) - 1;\n}\nfunction producerRemoveLiveConsumerAtIndex(node, idx) {\n var _a;\n assertProducerNode(node);\n assertConsumerNode(node);\n if (typeof ngDevMode !== \"undefined\" && ngDevMode && idx >= node.liveConsumerNode.length) {\n throw new Error(\n `Assertion error: active consumer index ${idx} is out of bounds of ${node.liveConsumerNode.length} consumers)`\n );\n }\n if (node.liveConsumerNode.length === 1) {\n (_a = node.unwatched) == null ? void 0 : _a.call(node.wrapper);\n for (let i = 0; i < node.producerNode.length; i++) {\n producerRemoveLiveConsumerAtIndex(node.producerNode[i], node.producerIndexOfThis[i]);\n }\n }\n const lastIdx = node.liveConsumerNode.length - 1;\n node.liveConsumerNode[idx] = node.liveConsumerNode[lastIdx];\n node.liveConsumerIndexOfThis[idx] = node.liveConsumerIndexOfThis[lastIdx];\n node.liveConsumerNode.length--;\n node.liveConsumerIndexOfThis.length--;\n if (idx < node.liveConsumerNode.length) {\n const idxProducer = node.liveConsumerIndexOfThis[idx];\n const consumer = node.liveConsumerNode[idx];\n assertConsumerNode(consumer);\n consumer.producerIndexOfThis[idxProducer] = idx;\n }\n}\nfunction consumerIsLive(node) {\n var _a;\n return node.consumerIsAlwaysLive || (((_a = node == null ? void 0 : node.liveConsumerNode) == null ? void 0 : _a.length) ?? 0) > 0;\n}\nfunction assertConsumerNode(node) {\n node.producerNode ?? (node.producerNode = []);\n node.producerIndexOfThis ?? (node.producerIndexOfThis = []);\n node.producerLastReadVersion ?? (node.producerLastReadVersion = []);\n}\nfunction assertProducerNode(node) {\n node.liveConsumerNode ?? (node.liveConsumerNode = []);\n node.liveConsumerIndexOfThis ?? (node.liveConsumerIndexOfThis = []);\n}\n/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\nfunction computedGet(node) {\n producerUpdateValueVersion(node);\n producerAccessed(node);\n if (node.value === ERRORED) {\n throw node.error;\n }\n return node.value;\n}\nfunction createComputed(computation) {\n const node = Object.create(COMPUTED_NODE);\n node.computation = computation;\n const computed = () => computedGet(node);\n computed[SIGNAL] = node;\n return computed;\n}\nconst UNSET = /* @__PURE__ */ Symbol(\"UNSET\");\nconst COMPUTING = /* @__PURE__ */ Symbol(\"COMPUTING\");\nconst ERRORED = /* @__PURE__ */ Symbol(\"ERRORED\");\nconst COMPUTED_NODE = /* @__PURE__ */ (() => {\n return {\n ...REACTIVE_NODE,\n value: UNSET,\n dirty: true,\n error: null,\n equal: defaultEquals,\n producerMustRecompute(node) {\n return node.value === UNSET || node.value === COMPUTING;\n },\n producerRecomputeValue(node) {\n if (node.value === COMPUTING) {\n throw new Error(\"Detected cycle in computations.\");\n }\n const oldValue = node.value;\n node.value = COMPUTING;\n const prevConsumer = consumerBeforeComputation(node);\n let newValue;\n let wasEqual = false;\n try {\n newValue = node.computation.call(node.wrapper);\n const oldOk = oldValue !== UNSET && oldValue !== ERRORED;\n wasEqual = oldOk && node.equal.call(node.wrapper, oldValue, newValue);\n } catch (err) {\n newValue = ERRORED;\n node.error = err;\n } finally {\n consumerAfterComputation(node, prevConsumer);\n }\n if (wasEqual) {\n node.value = oldValue;\n return;\n }\n node.value = newValue;\n node.version++;\n }\n };\n})();\n/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\nfunction defaultThrowError() {\n throw new Error();\n}\nlet throwInvalidWriteToSignalErrorFn = defaultThrowError;\nfunction throwInvalidWriteToSignalError() {\n throwInvalidWriteToSignalErrorFn();\n}\n/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\nfunction createSignal(initialValue) {\n const node = Object.create(SIGNAL_NODE);\n node.value = initialValue;\n const getter = () => {\n producerAccessed(node);\n return node.value;\n };\n getter[SIGNAL] = node;\n return getter;\n}\nfunction signalGetFn() {\n producerAccessed(this);\n return this.value;\n}\nfunction signalSetFn(node, newValue) {\n if (!producerUpdatesAllowed()) {\n throwInvalidWriteToSignalError();\n }\n if (!node.equal.call(node.wrapper, node.value, newValue)) {\n node.value = newValue;\n signalValueChanged(node);\n }\n}\nconst SIGNAL_NODE = /* @__PURE__ */ (() => {\n return {\n ...REACTIVE_NODE,\n equal: defaultEquals,\n value: void 0\n };\n})();\nfunction signalValueChanged(node) {\n node.version++;\n producerIncrementEpoch();\n producerNotifyConsumers(node);\n}\n/**\n * @license\n * Copyright 2024 Bloomberg Finance L.P.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nconst NODE = Symbol(\"node\");\nvar Signal;\n((Signal2) => {\n var _a, _brand, brand_fn, _b, _brand2, brand_fn2;\n class State {\n constructor(initialValue, options = {}) {\n __privateAdd(this, _brand);\n __publicField(this, _a);\n const ref = createSignal(initialValue);\n const node = ref[SIGNAL];\n this[NODE] = node;\n node.wrapper = this;\n if (options) {\n const equals = options.equals;\n if (equals) {\n node.equal = equals;\n }\n node.watched = options[Signal2.subtle.watched];\n node.unwatched = options[Signal2.subtle.unwatched];\n }\n }\n get() {\n if (!(0, Signal2.isState)(this))\n throw new TypeError(\"Wrong receiver type for Signal.State.prototype.get\");\n return signalGetFn.call(this[NODE]);\n }\n set(newValue) {\n if (!(0, Signal2.isState)(this))\n throw new TypeError(\"Wrong receiver type for Signal.State.prototype.set\");\n if (isInNotificationPhase()) {\n throw new Error(\"Writes to signals not permitted during Watcher callback\");\n }\n const ref = this[NODE];\n signalSetFn(ref, newValue);\n }\n }\n _a = NODE;\n _brand = new WeakSet();\n brand_fn = function() {\n };\n Signal2.isState = (s) => typeof s === \"object\" && __privateIn(_brand, s);\n Signal2.State = State;\n class Computed {\n // Create a Signal which evaluates to the value returned by the callback.\n // Callback is called with this signal as the parameter.\n constructor(computation, options) {\n __privateAdd(this, _brand2);\n __publicField(this, _b);\n const ref = createComputed(computation);\n const node = ref[SIGNAL];\n node.consumerAllowSignalWrites = true;\n this[NODE] = node;\n node.wrapper = this;\n if (options) {\n const equals = options.equals;\n if (equals) {\n node.equal = equals;\n }\n node.watched = options[Signal2.subtle.watched];\n node.unwatched = options[Signal2.subtle.unwatched];\n }\n }\n get() {\n if (!(0, Signal2.isComputed)(this))\n throw new TypeError(\"Wrong receiver type for Signal.Computed.prototype.get\");\n return computedGet(this[NODE]);\n }\n }\n _b = NODE;\n _brand2 = new WeakSet();\n brand_fn2 = function() {\n };\n Signal2.isComputed = (c) => typeof c === \"object\" && __privateIn(_brand2, c);\n Signal2.Computed = Computed;\n ((subtle2) => {\n var _a2, _brand3, brand_fn3, _assertSignals, assertSignals_fn;\n function untrack(cb) {\n let output;\n let prevActiveConsumer = null;\n try {\n prevActiveConsumer = setActiveConsumer(null);\n output = cb();\n } finally {\n setActiveConsumer(prevActiveConsumer);\n }\n return output;\n }\n subtle2.untrack = untrack;\n function introspectSources(sink) {\n var _a3;\n if (!(0, Signal2.isComputed)(sink) && !(0, Signal2.isWatcher)(sink)) {\n throw new TypeError(\"Called introspectSources without a Computed or Watcher argument\");\n }\n return ((_a3 = sink[NODE].producerNode) == null ? void 0 : _a3.map((n) => n.wrapper)) ?? [];\n }\n subtle2.introspectSources = introspectSources;\n function introspectSinks(signal) {\n var _a3;\n if (!(0, Signal2.isComputed)(signal) && !(0, Signal2.isState)(signal)) {\n throw new TypeError(\"Called introspectSinks without a Signal argument\");\n }\n return ((_a3 = signal[NODE].liveConsumerNode) == null ? void 0 : _a3.map((n) => n.wrapper)) ?? [];\n }\n subtle2.introspectSinks = introspectSinks;\n function hasSinks(signal) {\n if (!(0, Signal2.isComputed)(signal) && !(0, Signal2.isState)(signal)) {\n throw new TypeError(\"Called hasSinks without a Signal argument\");\n }\n const liveConsumerNode = signal[NODE].liveConsumerNode;\n if (!liveConsumerNode)\n return false;\n return liveConsumerNode.length > 0;\n }\n subtle2.hasSinks = hasSinks;\n function hasSources(signal) {\n if (!(0, Signal2.isComputed)(signal) && !(0, Signal2.isWatcher)(signal)) {\n throw new TypeError(\"Called hasSources without a Computed or Watcher argument\");\n }\n const producerNode = signal[NODE].producerNode;\n if (!producerNode)\n return false;\n return producerNode.length > 0;\n }\n subtle2.hasSources = hasSources;\n class Watcher {\n // When a (recursive) source of Watcher is written to, call this callback,\n // if it hasn't already been called since the last `watch` call.\n // No signals may be read or written during the notify.\n constructor(notify) {\n __privateAdd(this, _brand3);\n __privateAdd(this, _assertSignals);\n __publicField(this, _a2);\n let node = Object.create(REACTIVE_NODE);\n node.wrapper = this;\n node.consumerMarkedDirty = notify;\n node.consumerIsAlwaysLive = true;\n node.consumerAllowSignalWrites = false;\n node.producerNode = [];\n this[NODE] = node;\n }\n // Add these signals to the Watcher's set, and set the watcher to run its\n // notify callback next time any signal in the set (or one of its dependencies) changes.\n // Can be called with no arguments just to reset the \"notified\" state, so that\n // the notify callback will be invoked again.\n watch(...signals) {\n if (!(0, Signal2.isWatcher)(this)) {\n throw new TypeError(\"Called unwatch without Watcher receiver\");\n }\n __privateMethod(this, _assertSignals, assertSignals_fn).call(this, signals);\n const node = this[NODE];\n node.dirty = false;\n const prev = setActiveConsumer(node);\n for (const signal of signals) {\n producerAccessed(signal[NODE]);\n }\n setActiveConsumer(prev);\n }\n // Remove these signals from the watched set (e.g., for an effect which is disposed)\n unwatch(...signals) {\n if (!(0, Signal2.isWatcher)(this)) {\n throw new TypeError(\"Called unwatch without Watcher receiver\");\n }\n __privateMethod(this, _assertSignals, assertSignals_fn).call(this, signals);\n const node = this[NODE];\n assertConsumerNode(node);\n for (let i = node.producerNode.length - 1; i >= 0; i--) {\n if (signals.includes(node.producerNode[i].wrapper)) {\n producerRemoveLiveConsumerAtIndex(node.producerNode[i], node.producerIndexOfThis[i]);\n const lastIdx = node.producerNode.length - 1;\n node.producerNode[i] = node.producerNode[lastIdx];\n node.producerIndexOfThis[i] = node.producerIndexOfThis[lastIdx];\n node.producerNode.length--;\n node.producerIndexOfThis.length--;\n node.nextProducerIndex--;\n if (i < node.producerNode.length) {\n const idxConsumer = node.producerIndexOfThis[i];\n const producer = node.producerNode[i];\n assertProducerNode(producer);\n producer.liveConsumerIndexOfThis[idxConsumer] = i;\n }\n }\n }\n }\n // Returns the set of computeds in the Watcher's set which are still yet\n // to be re-evaluated\n getPending() {\n if (!(0, Signal2.isWatcher)(this)) {\n throw new TypeError(\"Called getPending without Watcher receiver\");\n }\n const node = this[NODE];\n return node.producerNode.filter((n) => n.dirty).map((n) => n.wrapper);\n }\n }\n _a2 = NODE;\n _brand3 = new WeakSet();\n brand_fn3 = function() {\n };\n _assertSignals = new WeakSet();\n assertSignals_fn = function(signals) {\n for (const signal of signals) {\n if (!(0, Signal2.isComputed)(signal) && !(0, Signal2.isState)(signal)) {\n throw new TypeError(\"Called watch/unwatch without a Computed or State argument\");\n }\n }\n };\n Signal2.isWatcher = (w) => __privateIn(_brand3, w);\n subtle2.Watcher = Watcher;\n function currentComputed() {\n var _a3;\n return (_a3 = getActiveConsumer()) == null ? void 0 : _a3.wrapper;\n }\n subtle2.currentComputed = currentComputed;\n subtle2.watched = Symbol(\"watched\");\n subtle2.unwatched = Symbol(\"unwatched\");\n })(Signal2.subtle || (Signal2.subtle = {}));\n})(Signal || (Signal = {}));\nexport {\n Signal\n};\n", "/**\n * @license\n * Copyright 2023 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport type {PropertyDeclaration, PropertyValueMap, ReactiveElement} from 'lit';\nimport {Signal} from 'signal-polyfill';\nimport {WatchDirective} from './watch.js';\n\ntype ReactiveElementConstructor = abstract new (\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ...args: any[]\n) => ReactiveElement;\n\nexport interface SignalWatcher extends ReactiveElement {\n _updateWatchDirective(d: WatchDirective<unknown>): void;\n _clearWatchDirective(d: WatchDirective<unknown>): void;\n}\n\ninterface SignalWatcherInterface extends SignalWatcher {}\ninterface SignalWatcherInternal extends SignalWatcher {\n __forcingUpdate: boolean;\n}\n\nconst signalWatcherBrand: unique symbol = Symbol('SignalWatcherBrand');\n\n// Memory management: We need to ensure that we don't leak memory by creating a\n// reference cycle between an element and its watcher, which then it kept alive\n// by the signals it watches. To avoid this, we break the cycle by using a\n// WeakMap to store the watcher for each element, and a FinalizationRegistry to\n// clean up the watcher when the element is garbage collected.\n\nconst elementFinalizationRegistry = new FinalizationRegistry<{\n watcher: Signal.subtle.Watcher;\n signal: Signal.Computed<void>;\n}>(({watcher, signal}) => {\n watcher.unwatch(signal);\n});\n\nconst elementForWatcher = new WeakMap<\n Signal.subtle.Watcher,\n SignalWatcherInternal\n>();\n\n/**\n * Adds the ability for a LitElement or other ReactiveElement class to\n * watch for access to signals during the update lifecycle and trigger a new\n * update when signals values change.\n */\nexport function SignalWatcher<T extends ReactiveElementConstructor>(\n Base: T\n): T {\n // Only apply the mixin once\n if ((Base as typeof SignalWatcher)[signalWatcherBrand] === true) {\n console.warn(\n 'SignalWatcher should not be applied to the same class more than once.'\n );\n return Base;\n }\n\n abstract class SignalWatcher extends Base implements SignalWatcherInterface {\n static [signalWatcherBrand]: true;\n\n private __watcher?: Signal.subtle.Watcher;\n\n private __watch() {\n if (this.__watcher !== undefined) {\n return;\n }\n // We create a fresh computed instead of just re-using the existing one\n // because of https://github.com/proposal-signals/signal-polyfill/issues/27\n this.__performUpdateSignal = new Signal.Computed(() => {\n this.__forceUpdateSignal.get();\n super.performUpdate();\n });\n const watcher = (this.__watcher = new Signal.subtle.Watcher(function (\n this: Signal.subtle.Watcher\n ) {\n // All top-level references in this function body must either be `this`\n // (the watcher) or a module global to prevent this closure from keeping\n // the enclosing scopes alive, which would keep the element alive. So\n // The only two references are `this` and `elementForWatcher`.\n const el = elementForWatcher.get(this);\n if (el === undefined) {\n // The element was garbage collected, so we can stop watching.\n return;\n }\n if (el.__forcingUpdate === false) {\n el.requestUpdate();\n }\n this.watch();\n }));\n elementForWatcher.set(watcher, this as unknown as SignalWatcherInternal);\n elementFinalizationRegistry.register(this, {\n watcher,\n signal: this.__performUpdateSignal,\n });\n watcher.watch(this.__performUpdateSignal);\n }\n\n private __unwatch() {\n if (this.__watcher === undefined) {\n return;\n }\n this.__watcher.unwatch(this.__performUpdateSignal!);\n this.__performUpdateSignal = undefined;\n this.__watcher = undefined;\n }\n\n /**\n * Used to force an uncached read of the __performUpdateSignal when we need\n * to read the current value during an update.\n *\n * If https://github.com/tc39/proposal-signals/issues/151 is resolved, we\n * won't need this.\n */\n private __forceUpdateSignal = new Signal.State(0);\n\n /*\n * This field is used within the watcher to determine if the watcher\n * notification was triggered by our performUpdate() override. Because we\n * force a fresh read of the __performUpdateSignal by changing value of the\n * __forceUpdate signal, the watcher will be notified. But we're already\n * performing an update, so we don't want to enqueue another one.\n */\n // @ts-expect-error This field is accessed in a watcher function with a\n // different `this` context, so TypeScript can't see the access.\n private __forcingUpdate = false;\n\n /**\n * A computed signal that wraps performUpdate() so that all signals that are\n * accessed during the update lifecycle are tracked.\n *\n * __forceUpdateSignal is used to force an uncached read of this signal\n * because updates may easily depend on non-signal values, so we must always\n * re-run it.\n */\n private __performUpdateSignal?: Signal.Computed<void>;\n\n /**\n * Whether or not the next update should perform a full render, or if only\n * pending watches should be committed.\n *\n * If requestUpdate() was called only because of watch() directive updates,\n * then we can just commit those directives without a full render. If\n * requestUpdate() was called for any other reason, we need to perform a\n * full render, and don't need to separately commit the watch() directives.\n *\n * This is set to `true` initially, and whenever requestUpdate() is called\n * outside of a watch() directive update. It is set to `false` when\n * update() is called, so that a requestUpdate() is required to do another\n * full render.\n */\n private __doFullRender = true;\n\n /**\n * Set of watch directives that have been updated since the last update.\n * These will be committed in update() to ensure that the latest value is\n * rendered and that all updates are batched.\n */\n private __pendingWatches = new Set<WatchDirective<unknown>>();\n\n protected override performUpdate() {\n if (!this.isUpdatePending) {\n // super.performUpdate() performs this check, so we bail early so that\n // we don't read the __performUpdateSignal when it's not going to access\n // any signals. This keeps the last signals read as the sources so that\n // we'll get notified of changes to them.\n return;\n }\n // Always enable watching before an update, even if disconnected, so that\n // we can track signals that are accessed during the update.\n this.__watch();\n // Force an uncached read of __performUpdateSignal\n this.__forcingUpdate = true;\n this.__forceUpdateSignal.set(this.__forceUpdateSignal.get() + 1);\n this.__forcingUpdate = false;\n // Always read from the signal to ensure that it's tracked\n this.__performUpdateSignal!.get();\n }\n\n protected override update(\n changedProperties: PropertyValueMap<this> | Map<PropertyKey, unknown>\n ): void {\n // We need a try block because both super.update() and\n // WatchDirective.commit() can throw, and we need to ensure that post-\n // update cleanup happens.\n try {\n if (this.__doFullRender) {\n // Force future updates to not perform full renders by default.\n this.__doFullRender = false;\n super.update(changedProperties);\n } else {\n // For a partial render, just commit the pending watches.\n // TODO (justinfagnani): Should we access each signal in a separate\n // try block?\n this.__pendingWatches.forEach((d) => d.commit());\n }\n } finally {\n // If we didn't call super.update(), we need to set this to false\n this.isUpdatePending = false;\n this.__pendingWatches.clear();\n }\n }\n\n override requestUpdate(\n name?: PropertyKey | undefined,\n oldValue?: unknown,\n options?: PropertyDeclaration<unknown, unknown> | undefined\n ): void {\n this.__doFullRender = true;\n super.requestUpdate(name, oldValue, options);\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n // Because we might have missed some signal updates while disconnected,\n // we force a full render on the next update.\n this.requestUpdate();\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n // Clean up the watcher earlier than the FinalizationRegistry will, to\n // avoid memory pressure from signals holding references to the element\n // via the watcher.\n //\n // This means that while disconnected, regular reactive property updates\n // will trigger a re-render, but signal updates will not. To ensure that\n // current signal usage is still correctly tracked, we re-enable watching\n // in performUpdate() even while disconnected. From that point on, a\n // disconnected element will be retained by the signals it accesses during\n // the update lifecycle.\n //\n // We use queueMicrotask() to ensure that this cleanup does not happen\n // because of moves in the DOM within the same task, such as removing an\n // element with .remove() and then adding it back later with .append()\n // in the same task. For example, repeat() works this way.\n queueMicrotask(() => {\n if (this.isConnected === false) {\n this.__unwatch();\n }\n });\n }\n\n /**\n * Enqueues an update caused by a signal change observed by a watch()\n * directive.\n *\n * Note: the method is not part of the public API and is subject to change.\n * In particular, it may be removed if the watch() directive is updated to\n * work with standalone lit-html templates.\n *\n * @internal\n */\n _updateWatchDirective(d: WatchDirective<unknown>): void {\n this.__pendingWatches.add(d);\n // requestUpdate() will set __doFullRender to true, so remember the\n // current value and restore it after calling requestUpdate().\n const shouldRender = this.__doFullRender;\n this.requestUpdate();\n this.__doFullRender = shouldRender;\n }\n\n /**\n * Clears a watch() directive from the set of pending watches.\n *\n * Note: the method is not part of the public API and is subject to change.\n *\n * @internal\n */\n _clearWatchDirective(d: WatchDirective<unknown>): void {\n this.__pendingWatches.delete(d);\n }\n }\n return SignalWatcher;\n}\n", "/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {Disconnectable, Part} from './lit-html.js';\n\nexport {\n AttributePart,\n BooleanAttributePart,\n ChildPart,\n ElementPart,\n EventPart,\n Part,\n PropertyPart,\n} from './lit-html.js';\n\nexport interface DirectiveClass {\n new (part: PartInfo): Directive;\n}\n\n/**\n * This utility type extracts the signature of a directive class's render()\n * method so we can use it for the type of the generated directive function.\n */\nexport type DirectiveParameters<C extends Directive> = Parameters<C['render']>;\n\n/**\n * A generated directive function doesn't evaluate the directive, but just\n * returns a DirectiveResult object that captures the arguments.\n */\nexport interface DirectiveResult<C extends DirectiveClass = DirectiveClass> {\n /**\n * This property needs to remain unminified.\n * @internal\n */\n ['_$litDirective$']: C;\n /** @internal */\n values: DirectiveParameters<InstanceType<C>>;\n}\n\nexport const PartType = {\n ATTRIBUTE: 1,\n CHILD: 2,\n PROPERTY: 3,\n BOOLEAN_ATTRIBUTE: 4,\n EVENT: 5,\n ELEMENT: 6,\n} as const;\n\nexport type PartType = (typeof PartType)[keyof typeof PartType];\n\nexport interface ChildPartInfo {\n readonly type: typeof PartType.CHILD;\n}\n\nexport interface AttributePartInfo {\n readonly type:\n | typeof PartType.ATTRIBUTE\n | typeof PartType.PROPERTY\n | typeof PartType.BOOLEAN_ATTRIBUTE\n | typeof PartType.EVENT;\n readonly strings?: ReadonlyArray<string>;\n readonly name: string;\n readonly tagName: string;\n}\n\nexport interface ElementPartInfo {\n readonly type: typeof PartType.ELEMENT;\n}\n\n/**\n * Information about the part a directive is bound to.\n *\n * This is useful for checking that a directive is attached to a valid part,\n * such as with directive that can only be used on attribute bindings.\n */\nexport type PartInfo = ChildPartInfo | AttributePartInfo | ElementPartInfo;\n\n/**\n * Creates a user-facing directive function from a Directive class. This\n * function has the same parameters as the directive's render() method.\n */\nexport const directive =\n <C extends DirectiveClass>(c: C) =>\n (...values: DirectiveParameters<InstanceType<C>>): DirectiveResult<C> => ({\n // This property needs to remain unminified.\n ['_$litDirective$']: c,\n values,\n });\n\n/**\n * Base class for creating custom directives. Users should extend this class,\n * implement `render` and/or `update`, and then pass their subclass to\n * `directive`.\n */\nexport abstract class Directive implements Disconnectable {\n //@internal\n __part!: Part;\n //@internal\n __attributeIndex: number | undefined;\n //@internal\n __directive?: Directive;\n\n //@internal\n _$parent!: Disconnectable;\n\n // These will only exist on the AsyncDirective subclass\n //@internal\n _$disconnectableChildren?: Set<Disconnectable>;\n // This property needs to remain unminified.\n //@internal\n ['_$notifyDirectiveConnectionChanged']?(isConnected: boolean): void;\n\n constructor(_partInfo: PartInfo) {}\n\n // See comment in Disconnectable interface for why this is a getter\n get _$isConnected() {\n return this._$parent._$isConnected;\n }\n\n /** @internal */\n _$initialize(\n part: Part,\n parent: Disconnectable,\n attributeIndex: number | undefined\n ) {\n this.__part = part;\n this._$parent = parent;\n this.__attributeIndex = attributeIndex;\n }\n /** @internal */\n _$resolve(part: Part, props: Array<unknown>): unknown {\n return this.update(part, props);\n }\n\n abstract render(...props: Array<unknown>): unknown;\n\n update(_part: Part, props: Array<unknown>): unknown {\n return this.render(...props);\n }\n}\n", "/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n// IMPORTANT: these imports must be type-only\nimport type {Directive, DirectiveResult, PartInfo} from './directive.js';\nimport type {TrustedHTML, TrustedTypesWindow} from 'trusted-types/lib/index.js';\n\nconst DEV_MODE = true;\nconst ENABLE_EXTRA_SECURITY_HOOKS = true;\nconst ENABLE_SHADYDOM_NOPATCH = true;\nconst NODE_MODE = false;\n\n// Allows minifiers to rename references to globalThis\nconst global = globalThis;\n\n/**\n * Contains types that are part of the unstable debug API.\n *\n * Everything in this API is not stable and may change or be removed in the future,\n * even on patch releases.\n */\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport namespace LitUnstable {\n /**\n * When Lit is running in dev mode and `window.emitLitDebugLogEvents` is true,\n * we will emit 'lit-debug' events to window, with live details about the update and render\n * lifecycle. These can be useful for writing debug tooling and visualizations.\n *\n * Please be aware that running with window.emitLitDebugLogEvents has performance overhead,\n * making certain operations that are normally very cheap (like a no-op render) much slower,\n * because we must copy data and dispatch events.\n */\n // eslint-disable-next-line @typescript-eslint/no-namespace\n export namespace DebugLog {\n export type Entry =\n | TemplatePrep\n | TemplateInstantiated\n | TemplateInstantiatedAndUpdated\n | TemplateUpdating\n | BeginRender\n | EndRender\n | CommitPartEntry\n | SetPartValue;\n export interface TemplatePrep {\n kind: 'template prep';\n template: Template;\n strings: TemplateStringsArray;\n clonableTemplate: HTMLTemplateElement;\n parts: TemplatePart[];\n }\n export interface BeginRender {\n kind: 'begin render';\n id: number;\n value: unknown;\n container: HTMLElement | DocumentFragment;\n options: RenderOptions | undefined;\n part: ChildPart | undefined;\n }\n export interface EndRender {\n kind: 'end render';\n id: number;\n value: unknown;\n container: HTMLElement | DocumentFragment;\n options: RenderOptions | undefined;\n part: ChildPart;\n }\n export interface TemplateInstantiated {\n kind: 'template instantiated';\n template: Template | CompiledTemplate;\n instance: TemplateInstance;\n options: RenderOptions | undefined;\n fragment: Node;\n parts: Array<Part | undefined>;\n values: unknown[];\n }\n export interface TemplateInstantiatedAndUpdated {\n kind: 'template instantiated and updated';\n template: Template | CompiledTemplate;\n instance: TemplateInstance;\n options: RenderOptions | undefined;\n fragment: Node;\n parts: Array<Part | undefined>;\n values: unknown[];\n }\n export interface TemplateUpdating {\n kind: 'template updating';\n template: Template | CompiledTemplate;\n instance: TemplateInstance;\n options: RenderOptions | undefined;\n parts: Array<Part | undefined>;\n values: unknown[];\n }\n export interface SetPartValue {\n kind: 'set part';\n part: Part;\n value: unknown;\n valueIndex: number;\n values: unknown[];\n templateInstance: TemplateInstance;\n }\n\n export type CommitPartEntry =\n | CommitNothingToChildEntry\n | CommitText\n | CommitNode\n | CommitAttribute\n | CommitProperty\n | CommitBooleanAttribute\n | CommitEventListener\n | CommitToElementBinding;\n\n export interface CommitNothingToChildEntry {\n kind: 'commit nothing to child';\n start: ChildNode;\n end: ChildNode | null;\n parent: Disconnectable | undefined;\n options: RenderOptions | undefined;\n }\n\n export interface CommitText {\n kind: 'commit text';\n node: Text;\n value: unknown;\n options: RenderOptions | undefined;\n }\n\n export interface CommitNode {\n kind: 'commit node';\n start: Node;\n parent: Disconnectable | undefined;\n value: Node;\n options: RenderOptions | undefined;\n }\n\n export interface CommitAttribute {\n kind: 'commit attribute';\n element: Element;\n name: string;\n value: unknown;\n options: RenderOptions | undefined;\n }\n\n export interface CommitProperty {\n kind: 'commit property';\n element: Element;\n name: string;\n value: unknown;\n options: RenderOptions | undefined;\n }\n\n export interface CommitBooleanAttribute {\n kind: 'commit boolean attribute';\n element: Element;\n name: string;\n value: boolean;\n options: RenderOptions | undefined;\n }\n\n export interface CommitEventListener {\n kind: 'commit event listener';\n element: Element;\n name: string;\n value: unknown;\n oldListener: unknown;\n options: RenderOptions | undefined;\n // True if we're removing the old event listener (e.g. because settings changed, or value is nothing)\n removeListener: boolean;\n // True if we're adding a new event listener (e.g. because first render, or settings changed)\n addListener: boolean;\n }\n\n export interface CommitToElementBinding {\n kind: 'commit to element binding';\n element: Element;\n value: unknown;\n options: RenderOptions | undefined;\n }\n }\n}\n\ninterface DebugLoggingWindow {\n // Even in dev mode, we generally don't want to emit these events, as that's\n // another level of cost, so only emit them when DEV_MODE is true _and_ when\n // window.emitLitDebugEvents is true.\n emitLitDebugLogEvents?: boolean;\n}\n\n/**\n * Useful for visualizing and logging insights into what the Lit template system is doing.\n *\n * Compiled out of prod mode builds.\n */\nconst debugLogEvent = DEV_MODE\n ? (event: LitUnstable.DebugLog.Entry) => {\n const shouldEmit = (global as unknown as DebugLoggingWindow)\n .emitLitDebugLogEvents;\n if (!shouldEmit) {\n return;\n }\n global.dispatchEvent(\n new CustomEvent<LitUnstable.DebugLog.Entry>('lit-debug', {\n detail: event,\n })\n );\n }\n : undefined;\n// Used for connecting beginRender and endRender events when there are nested\n// renders when errors are thrown preventing an endRender event from being\n// called.\nlet debugLogRenderId = 0;\n\nlet issueWarning: (code: string, warning: string) => void;\n\nif (DEV_MODE) {\n global.litIssuedWarnings ??= new Set();\n\n /**\n * Issue a warning if we haven't already, based either on `code` or `warning`.\n * Warnings are disabled automatically only by `warning`; disabling via `code`\n * can be done by users.\n */\n issueWarning = (code: string, warning: string) => {\n warning += code\n ? ` See https://lit.dev/msg/${code} for more information.`\n : '';\n if (\n !global.litIssuedWarnings!.has(warning) &&\n !global.litIssuedWarnings!.has(code)\n ) {\n console.warn(warning);\n global.litIssuedWarnings!.add(warning);\n }\n };\n\n queueMicrotask(() => {\n issueWarning(\n 'dev-mode',\n `Lit is in dev mode. Not recommended for production!`\n );\n });\n}\n\nconst wrap =\n ENABLE_SHADYDOM_NOPATCH &&\n global.ShadyDOM?.inUse &&\n global.ShadyDOM?.noPatch === true\n ? (global.ShadyDOM!.wrap as <T extends Node>(node: T) => T)\n : <T extends Node>(node: T) => node;\n\nconst trustedTypes = (global as unknown as TrustedTypesWindow).trustedTypes;\n\n/**\n * Our TrustedTypePolicy for HTML which is declared using the html template\n * tag function.\n *\n * That HTML is a developer-authored constant, and is parsed with innerHTML\n * before any untrusted expressions have been mixed in. Therefor it is\n * considered safe by construction.\n */\nconst policy = trustedTypes\n ? trustedTypes.createPolicy('lit-html', {\n createHTML: (s) => s,\n })\n : undefined;\n\n/**\n * Used to sanitize any value before it is written into the DOM. This can be\n * used to implement a security policy of allowed and disallowed values in\n * order to prevent XSS attacks.\n *\n * One way of using this callback would be to check attributes and properties\n * against a list of high risk fields, and require that values written to such\n * fields be instances of a class which is safe by construction. Closure's Safe\n * HTML Types is one implementation of this technique (\n * https://github.com/google/safe-html-types/blob/master/doc/safehtml-types.md).\n * The TrustedTypes polyfill in API-only mode could also be used as a basis\n * for this technique (https://github.com/WICG/trusted-types).\n *\n * @param node The HTML node (usually either a #text node or an Element) that\n * is being written to. Note that this is just an exemplar node, the write\n * may take place against another instance of the same class of node.\n * @param name The name of an attribute or property (for example, 'href').\n * @param type Indicates whether the write that's about to be performed will\n * be to a property or a node.\n * @return A function that will sanitize this class of writes.\n */\nexport type SanitizerFactory = (\n node: Node,\n name: string,\n type: 'property' | 'attribute'\n) => ValueSanitizer;\n\n/**\n * A function which can sanitize values that will be written to a specific kind\n * of DOM sink.\n *\n * See SanitizerFactory.\n *\n * @param value The value to sanitize. Will be the actual value passed into\n * the lit-html template literal, so this could be of any type.\n * @return The value to write to the DOM. Usually the same as the input value,\n * unless sanitization is needed.\n */\nexport type ValueSanitizer = (value: unknown) => unknown;\n\nconst identityFunction: ValueSanitizer = (value: unknown) => value;\nconst noopSanitizer: SanitizerFactory = (\n _node: Node,\n _name: string,\n _type: 'property' | 'attribute'\n) => identityFunction;\n\n/** Sets the global sanitizer factory. */\nconst setSanitizer = (newSanitizer: SanitizerFactory) => {\n if (!ENABLE_EXTRA_SECURITY_HOOKS) {\n return;\n }\n if (sanitizerFactoryInternal !== noopSanitizer) {\n throw new Error(\n `Attempted to overwrite existing lit-html security policy.` +\n ` setSanitizeDOMValueFactory should be called at most once.`\n );\n }\n sanitizerFactoryInternal = newSanitizer;\n};\n\n/**\n * Only used in internal tests, not a part of the public API.\n */\nconst _testOnlyClearSanitizerFactoryDoNotCallOrElse = () => {\n sanitizerFactoryInternal = noopSanitizer;\n};\n\nconst createSanitizer: SanitizerFactory = (node, name, type) => {\n return sanitizerFactoryInternal(node, name, type);\n};\n\n// Added to an attribute name to mark the attribute as bound so we can find\n// it easily.\nconst boundAttributeSuffix = '$lit$';\n\n// This marker is used in many syntactic positions in HTML, so it must be\n// a valid element name and attribute name. We don't support dynamic names (yet)\n// but this at least ensures that the parse tree is closer to the template\n// intention.\nconst marker = `lit$${Math.random().toFixed(9).slice(2)}$`;\n\n// String used to tell if a comment is a marker comment\nconst markerMatch = '?' + marker;\n\n// Text used to insert a comment marker node. We use processing instruction\n// syntax because it's slightly smaller, but parses as a comment node.\nconst nodeMarker = `<${markerMatch}>`;\n\nconst d =\n NODE_MODE && global.document === undefined\n ? ({\n createTreeWalker() {\n return {};\n },\n } as unknown as Document)\n : document;\n\n// Creates a dynamic marker. We never have to search for these in the DOM.\nconst createMarker = () => d.createComment('');\n\n// https://tc39.github.io/ecma262/#sec-typeof-operator\ntype Primitive = null | undefined | boolean | number | string | symbol | bigint;\nconst isPrimitive = (value: unknown): value is Primitive =>\n value === null || (typeof value != 'object' && typeof value != 'function');\nconst isArray = Array.isArray;\nconst isIterable = (value: unknown): value is Iterable<unknown> =>\n isArray(value) ||\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n typeof (value as any)?.[Symbol.iterator] === 'function';\n\nconst SPACE_CHAR = `[ \\t\\n\\f\\r]`;\nconst ATTR_VALUE_CHAR = `[^ \\t\\n\\f\\r\"'\\`<>=]`;\nconst NAME_CHAR = `[^\\\\s\"'>=/]`;\n\n// These regexes represent the five parsing states that we care about in the\n// Template's HTML scanner. They match the *end* of the state they're named\n// after.\n// Depending on the match, we transition to a new state. If there's no match,\n// we stay in the same state.\n// Note that the regexes are stateful. We utilize lastIndex and sync it\n// across the multiple regexes used. In addition to the five regexes below\n// we also dynamically create a regex to find the matching end tags for raw\n// text elements.\n\n/**\n * End of text is: `<` followed by:\n * (comment start) or (tag) or (dynamic tag binding)\n */\nconst textEndRegex = /<(?:(!--|\\/[^a-zA-Z])|(\\/?[a-zA-Z][^>\\s]*)|(\\/?$))/g;\nconst COMMENT_START = 1;\nconst TAG_NAME = 2;\nconst DYNAMIC_TAG_NAME = 3;\n\nconst commentEndRegex = /-->/g;\n/**\n * Comments not started with <!--, like </{, can be ended by a single `>`\n */\nconst comment2EndRegex = />/g;\n\n/**\n * The tagEnd regex matches the end of the \"inside an opening\" tag syntax\n * position. It either matches a `>`, an attribute-like sequence, or the end\n * of the string after a space (attribute-name position ending).\n *\n * See attributes in the HTML spec:\n * https://www.w3.org/TR/html5/syntax.html#elements-attributes\n *\n * \" \\t\\n\\f\\r\" are HTML space characters:\n * https://infra.spec.whatwg.org/#ascii-whitespace\n *\n * So an attribute is:\n * * The name: any character except a whitespace character, (\"), ('), \">\",\n * \"=\", or \"/\". Note: this is different from the HTML spec which also excludes control characters.\n * * Followed by zero or more space characters\n * * Followed by \"=\"\n * * Followed by zero or more space characters\n * * Followed by:\n * * Any character except space, ('), (\"), \"<\", \">\", \"=\", (`), or\n * * (\") then any non-(\"), or\n * * (') then any non-(')\n */\nconst tagEndRegex = new RegExp(\n `>|${SPACE_CHAR}(?:(${NAME_CHAR}+)(${SPACE_CHAR}*=${SPACE_CHAR}*(?:${ATTR_VALUE_CHAR}|(\"|')|))|$)`,\n 'g'\n);\nconst ENTIRE_MATCH = 0;\nconst ATTRIBUTE_NAME = 1;\nconst SPACES_AND_EQUALS = 2;\nconst QUOTE_CHAR = 3;\n\nconst singleQuoteAttrEndRegex = /'/g;\nconst doubleQuoteAttrEndRegex = /\"/g;\n/**\n * Matches the raw text elements.\n *\n * Comments are not parsed within raw text elements, so we need to search their\n * text content for marker strings.\n */\nconst rawTextElement = /^(?:script|style|textarea|title)$/i;\n\n/** TemplateResult types */\nconst HTML_RESULT = 1;\nconst SVG_RESULT = 2;\nconst MATHML_RESULT = 3;\n\ntype ResultType = typeof HTML_RESULT | typeof SVG_RESULT | typeof MATHML_RESULT;\n\n// TemplatePart types\n// IMPORTANT: these must match the values in PartType\nconst ATTRIBUTE_PART = 1;\nconst CHILD_PART = 2;\nconst PROPERTY_PART = 3;\nconst BOOLEAN_ATTRIBUTE_PART = 4;\nconst EVENT_PART = 5;\nconst ELEMENT_PART = 6;\nconst COMMENT_PART = 7;\n\n/**\n * The return type of the template tag functions, {@linkcode html} and\n * {@linkcode svg} when it hasn't been compiled by @lit-labs/compiler.\n *\n * A `TemplateResult` object holds all the information about a template\n * expression required to render it: the template strings, expression values,\n * and type of template (html or svg).\n *\n * `TemplateResult` objects do not create any DOM on their own. To create or\n * update DOM you need to render the `TemplateResult`. See\n * [Rendering](https://lit.dev/docs/components/rendering) for more information.\n *\n */\nexport type UncompiledTemplateResult<T extends ResultType = ResultType> = {\n // This property needs to remain unminified.\n ['_$litType$']: T;\n strings: TemplateStringsArray;\n values: unknown[];\n};\n\n/**\n * This is a template result that may be either uncompiled or compiled.\n *\n * In the future, TemplateResult will be this type. If you want to explicitly\n * note that a template result is potentially compiled, you can reference this\n * type and it will continue to behave the same through the next major version\n * of Lit. This can be useful for code that wants to prepare for the next\n * major version of Lit.\n */\nexport type MaybeCompiledTemplateResult<T extends ResultType = ResultType> =\n | UncompiledTemplateResult<T>\n | CompiledTemplateResult;\n\n/**\n * The return type of the template tag functions, {@linkcode html} and\n * {@linkcode svg}.\n *\n * A `TemplateResult` object holds all the information about a template\n * expression required to render it: the template strings, expression values,\n * and type of template (html or svg).\n *\n * `TemplateResult` objects do not create any DOM on their own. To create or\n * update DOM you need to render the `TemplateResult`. See\n * [Rendering](https://lit.dev/docs/components/rendering) for more information.\n *\n * In Lit 4, this type will be an alias of\n * MaybeCompiledTemplateResult, so that code will get type errors if it assumes\n * that Lit templates are not compiled. When deliberately working with only\n * one, use either {@linkcode CompiledTemplateResult} or\n * {@linkcode UncompiledTemplateResult} explicitly.\n */\nexport type TemplateResult<T extends ResultType = ResultType> =\n UncompiledTemplateResult<T>;\n\nexport type HTMLTemplateResult = TemplateResult<typeof HTML_RESULT>;\n\nexport type SVGTemplateResult = TemplateResult<typeof SVG_RESULT>;\n\nexport type MathMLTemplateResult = TemplateResult<typeof MATHML_RESULT>;\n\n/**\n * A TemplateResult that has been compiled by @lit-labs/compiler, skipping the\n * prepare step.\n */\nexport interface CompiledTemplateResult {\n // This is a factory in order to make template initialization lazy\n // and allow ShadyRenderOptions scope to be passed in.\n // This property needs to remain unminified.\n ['_$litType$']: CompiledTemplate;\n values: unknown[];\n}\n\nexport interface CompiledTemplate extends Omit<Template, 'el'> {\n // el is overridden to be optional. We initialize it on first render\n el?: HTMLTemplateElement;\n\n // The prepared HTML string to create a template element from.\n // The type is a TemplateStringsArray to guarantee that the value came from\n // source code, preventing a JSON injection attack.\n h: TemplateStringsArray;\n}\n\n/**\n * Generates a template literal tag function that returns a TemplateResult with\n * the given result type.\n */\nconst tag =\n <T extends ResultType>(type: T) =>\n (strings: TemplateStringsArray, ...values: unknown[]): TemplateResult<T> => {\n // Warn against templates octal escape sequences\n // We do this here rather than in render so that the warning is closer to the\n // template definition.\n if (DEV_MODE && strings.some((s) => s === undefined)) {\n console.warn(\n 'Some template strings are undefined.\\n' +\n 'This is probably caused by illegal octal escape sequences.'\n );\n }\n if (DEV_MODE) {\n // Import static-html.js results in a circular dependency which g3 doesn't\n // handle. Instead we know that static values must have the field\n // `_$litStatic$`.\n if (\n values.some((val) => (val as {_$litStatic$: unknown})?.['_$litStatic$'])\n ) {\n issueWarning(\n '',\n `Static values 'literal' or 'unsafeStatic' cannot be used as values to non-static templates.\\n` +\n `Please use the static 'html' tag function. See https://lit.dev/docs/templates/expressions/#static-expressions`\n );\n }\n }\n return {\n // This property needs to remain unminified.\n ['_$litType$']: type,\n strings,\n values,\n };\n };\n\n/**\n * Interprets a template literal as an HTML template that can efficiently\n * render to and update a container.\n *\n * ```ts\n * const header = (title: string) => html`<h1>${title}</h1>`;\n * ```\n *\n * The `html` tag returns a description of the DOM to render as a value. It is\n * lazy, meaning no work is done until the template is rendered. When rendering,\n * if a template comes from the same expression as a previously rendered result,\n * it's efficiently updated instead of replaced.\n */\nexport const html = tag(HTML_RESULT);\n\n/**\n * Interprets a template literal as an SVG fragment that can efficiently render\n * to and update a container.\n *\n * ```ts\n * const rect = svg`<rect width=\"10\" height=\"10\"></rect>`;\n *\n * const myImage = html`\n * <svg viewBox=\"0 0 10 10\" xmlns=\"http://www.w3.org/2000/svg\">\n * ${rect}\n * </svg>`;\n * ```\n *\n * The `svg` *tag function* should only be used for SVG fragments, or elements\n * that would be contained **inside** an `<svg>` HTML element. A common error is\n * placing an `<svg>` *element* in a template tagged with the `svg` tag\n * function. The `<svg>` element is an HTML element and should be used within a\n * template tagged with the {@linkcode html} tag function.\n *\n * In LitElement usage, it's invalid to return an SVG fragment from the\n * `render()` method, as the SVG fragment will be contained within the element's\n * shadow root and thus not be properly contained within an `<svg>` HTML\n * element.\n */\nexport const svg = tag(SVG_RESULT);\n\n/**\n * Interprets a template literal as MathML fragment that can efficiently render\n * to and update a container.\n *\n * ```ts\n * const num = mathml`<mn>1</mn>`;\n *\n * const eq = html`\n * <math>\n * ${num}\n * </math>`;\n * ```\n *\n * The `mathml` *tag function* should only be used for MathML fragments, or\n * elements that would be contained **inside** a `<math>` HTML element. A common\n * error is placing a `<math>` *element* in a template tagged with the `mathml`\n * tag function. The `<math>` element is an HTML element and should be used\n * within a template tagged with the {@linkcode html} tag function.\n *\n * In LitElement usage, it's invalid to return an MathML fragment from the\n * `render()` method, as the MathML fragment will be contained within the\n * element's shadow root and thus not be properly contained within a `<math>`\n * HTML element.\n */\nexport const mathml = tag(MATHML_RESULT);\n\n/**\n * A sentinel value that signals that a value was handled by a directive and\n * should not be written to the DOM.\n */\nexport const noChange = Symbol.for('lit-noChange');\n\n/**\n * A sentinel value that signals a ChildPart to fully clear its content.\n *\n * ```ts\n * const button = html`${\n * user.isAdmin\n * ? html`<button>DELETE</button>`\n * : nothing\n * }`;\n * ```\n *\n * Prefer using `nothing` over other falsy values as it provides a consistent\n * behavior between various expression binding contexts.\n *\n * In child expressions, `undefined`, `null`, `''`, and `nothing` all behave the\n * same and render no nodes. In attribute expressions, `nothing` _removes_ the\n * attribute, while `undefined` and `null` will render an empty string. In\n * property expressions `nothing` becomes `undefined`.\n */\nexport const nothing = Symbol.for('lit-nothing');\n\n/**\n * The cache of prepared templates, keyed by the tagged TemplateStringsArray\n * and _not_ accounting for the specific template tag used. This means that\n * template tags cannot be dynamic - they must statically be one of html, svg,\n * or attr. This restriction simplifies the cache lookup, which is on the hot\n * path for rendering.\n */\nconst templateCache = new WeakMap<TemplateStringsArray, Template>();\n\n/**\n * Object specifying options for controlling lit-html rendering. Note that\n * while `render` may be called multiple times on the same `container` (and\n * `renderBefore` reference node) to efficiently update the rendered content,\n * only the options passed in during the first render are respected during\n * the lifetime of renders to that unique `container` + `renderBefore`\n * combination.\n */\nexport interface RenderOptions {\n /**\n * An object to use as the `this` value for event listeners. It's often\n * useful to set this to the host component rendering a template.\n */\n host?: object;\n /**\n * A DOM node before which to render content in the container.\n */\n renderBefore?: ChildNode | null;\n /**\n * Node used for cloning the template (`importNode` will be called on this\n * node). This controls the `ownerDocument` of the rendered DOM, along with\n * any inherited context. Defaults to the global `document`.\n */\n creationScope?: {importNode(node: Node, deep?: boolean): Node};\n /**\n * The initial connected state for the top-level part being rendered. If no\n * `isConnected` option is set, `AsyncDirective`s will be connected by\n * default. Set to `false` if the initial render occurs in a disconnected tree\n * and `AsyncDirective`s should see `isConnected === false` for their initial\n * render. The `part.setConnected()` method must be used subsequent to initial\n * render to change the connected state of the part.\n */\n isConnected?: boolean;\n}\n\nconst walker = d.createTreeWalker(\n d,\n 129 /* NodeFilter.SHOW_{ELEMENT|COMMENT} */\n);\n\nlet sanitizerFactoryInternal: SanitizerFactory = noopSanitizer;\n\n//\n// Classes only below here, const variable declarations only above here...\n//\n// Keeping variable declarations and classes together improves minification.\n// Interfaces and type aliases can be interleaved freely.\n//\n\n// Type for classes that have a `_directive` or `_directives[]` field, used by\n// `resolveDirective`\nexport interface DirectiveParent {\n _$parent?: DirectiveParent;\n _$isConnected: boolean;\n __directive?: Directive;\n __directives?: Array<Directive | undefined>;\n}\n\nfunction trustFromTemplateString(\n tsa: TemplateStringsArray,\n stringFromTSA: string\n): TrustedHTML {\n // A security check to prevent spoofing of Lit template results.\n // In the future, we may be able to replace this with Array.isTemplateObject,\n // though we might need to make that check inside of the html and svg\n // functions, because precompiled templates don't come in as\n // TemplateStringArray objects.\n if (!isArray(tsa) || !tsa.hasOwnProperty('raw')) {\n let message = 'invalid template strings array';\n if (DEV_MODE) {\n message = `\n Internal Error: expected template strings to be an array\n with a 'raw' field. Faking a template strings array by\n calling html or svg like an ordinary function is effectively\n the same as calling unsafeHtml and can lead to major security\n issues, e.g. opening your code up to XSS attacks.\n If you're using the html or svg tagged template functions normally\n and still seeing this error, please file a bug at\n https://github.com/lit/lit/issues/new?template=bug_report.md\n and include information about your build tooling, if any.\n `\n .trim()\n .replace(/\\n */g, '\\n');\n }\n throw new Error(message);\n }\n return policy !== undefined\n ? policy.createHTML(stringFromTSA)\n : (stringFromTSA as unknown as TrustedHTML);\n}\n\n/**\n * Returns an HTML string for the given TemplateStringsArray and result type\n * (HTML or SVG), along with the case-sensitive bound attribute names in\n * template order. The HTML contains comment markers denoting the `ChildPart`s\n * and suffixes on bound attributes denoting the `AttributeParts`.\n *\n * @param strings template strings array\n * @param type HTML or SVG\n * @return Array containing `[html, attrNames]` (array returned for terseness,\n * to avoid object fields since this code is shared with non-minified SSR\n * code)\n */\nconst getTemplateHtml = (\n strings: TemplateStringsArray,\n type: ResultType\n): [TrustedHTML, Array<string>] => {\n // Insert makers into the template HTML to represent the position of\n // bindings. The following code scans the template strings to determine the\n // syntactic position of the bindings. They can be in text position, where\n // we insert an HTML comment, attribute value position, where we insert a\n // sentinel string and re-write the attribute name, or inside a tag where\n // we insert the sentinel string.\n const l = strings.length - 1;\n // Stores the case-sensitive bound attribute names in the order of their\n // parts. ElementParts are also reflected in this array as undefined\n // rather than a string, to disambiguate from attribute bindings.\n const attrNames: Array<string> = [];\n let html =\n type === SVG_RESULT ? '<svg>' : type === MATHML_RESULT ? '<math>' : '';\n\n // When we're inside a raw text tag (not it's text content), the regex\n // will still be tagRegex so we can find attributes, but will switch to\n // this regex when the tag ends.\n let rawTextEndRegex: RegExp | undefined;\n\n // The current parsing state, represented as a reference to one of the\n // regexes\n let regex = textEndRegex;\n\n for (let i = 0; i < l; i++) {\n const s = strings[i];\n // The index of the end of the last attribute name. When this is\n // positive at end of a string, it means we're in an attribute value\n // position and need to rewrite the attribute name.\n // We also use a special value of -2 to indicate that we encountered\n // the end of a string in attribute name position.\n let attrNameEndIndex = -1;\n let attrName: string | undefined;\n let lastIndex = 0;\n let match!: RegExpExecArray | null;\n\n // The conditions in this loop handle the current parse state, and the\n // assignments to the `regex` variable are the state transitions.\n while (lastIndex < s.length) {\n // Make sure we start searching from where we previously left off\n regex.lastIndex = lastIndex;\n match = regex.exec(s);\n if (match === null) {\n break;\n }\n lastIndex = regex.lastIndex;\n if (regex === textEndRegex) {\n if (match[COMMENT_START] === '!--') {\n regex = commentEndRegex;\n } else if (match[COMMENT_START] !== undefined) {\n // We started a weird comment, like </{\n regex = comment2EndRegex;\n } else if (match[TAG_NAME] !== undefined) {\n if (rawTextElement.test(match[TAG_NAME])) {\n // Record if we encounter a raw-text element. We'll switch to\n // this regex at the end of the tag.\n rawTextEndRegex = new RegExp(`</${match[TAG_NAME]}`, 'g');\n }\n regex = tagEndRegex;\n } else if (match[DYNAMIC_TAG_NAME] !== undefined) {\n if (DEV_MODE) {\n throw new Error(\n 'Bindings in tag names are not supported. Please use static templates instead. ' +\n 'See https://lit.dev/docs/templates/expressions/#static-expressions'\n );\n }\n regex = tagEndRegex;\n }\n } else if (regex === tagEndRegex) {\n if (match[ENTIRE_MATCH] === '>') {\n // End of a tag. If we had started a raw-text element, use that\n // regex\n regex = rawTextEndRegex ?? textEndRegex;\n // We may be ending an unquoted attribute value, so make sure we\n // clear any pending attrNameEndIndex\n attrNameEndIndex = -1;\n } else if (match[ATTRIBUTE_NAME] === undefined) {\n // Attribute name position\n attrNameEndIndex = -2;\n } else {\n attrNameEndIndex = regex.lastIndex - match[SPACES_AND_EQUALS].length;\n attrName = match[ATTRIBUTE_NAME];\n regex =\n match[QUOTE_CHAR] === undefined\n ? tagEndRegex\n : match[QUOTE_CHAR] === '\"'\n ? doubleQuoteAttrEndRegex\n : singleQuoteAttrEndRegex;\n }\n } else if (\n regex === doubleQuoteAttrEndRegex ||\n regex === singleQuoteAttrEndRegex\n ) {\n regex = tagEndRegex;\n } else if (regex === commentEndRegex || regex === comment2EndRegex) {\n regex = textEndRegex;\n } else {\n // Not one of the five state regexes, so it must be the dynamically\n // created raw text regex and we're at the close of that element.\n regex = tagEndRegex;\n rawTextEndRegex = undefined;\n }\n }\n\n if (DEV_MODE) {\n // If we have a attrNameEndIndex, which indicates that we should\n // rewrite the attribute name, assert that we're in a valid attribute\n // position - either in a tag, or a quoted attribute value.\n console.assert(\n attrNameEndIndex === -1 ||\n regex === tagEndRegex ||\n regex === singleQuoteAttrEndRegex ||\n regex === doubleQuoteAttrEndRegex,\n 'unexpected parse state B'\n );\n }\n\n // We have four cases:\n // 1. We're in text position, and not in a raw text element\n // (regex === textEndRegex): insert a comment marker.\n // 2. We have a non-negative attrNameEndIndex which means we need to\n // rewrite the attribute name to add a bound attribute suffix.\n // 3. We're at the non-first binding in a multi-binding attribute, use a\n // plain marker.\n // 4. We're somewhere else inside the tag. If we're in attribute name\n // position (attrNameEndIndex === -2), add a sequential suffix to\n // generate a unique attribute name.\n\n // Detect a binding next to self-closing tag end and insert a space to\n // separate the marker from the tag end:\n const end =\n regex === tagEndRegex && strings[i + 1].startsWith('/>') ? ' ' : '';\n html +=\n regex === textEndRegex\n ? s + nodeMarker\n : attrNameEndIndex >= 0\n ? (attrNames.push(attrName!),\n s.slice(0, attrNameEndIndex) +\n boundAttributeSuffix +\n s.slice(attrNameEndIndex)) +\n marker +\n end\n : s + marker + (attrNameEndIndex === -2 ? i : end);\n }\n\n const htmlResult: string | TrustedHTML =\n html +\n (strings[l] || '<?>') +\n (type === SVG_RESULT ? '</svg>' : type === MATHML_RESULT ? '</math>' : '');\n\n // Returned as an array for terseness\n return [trustFromTemplateString(strings, htmlResult), attrNames];\n};\n\n/** @internal */\nexport type {Template};\nclass Template {\n /** @internal */\n el!: HTMLTemplateElement;\n\n parts: Array<TemplatePart> = [];\n\n constructor(\n // This property needs to remain unminified.\n {strings, ['_$litType$']: type}: UncompiledTemplateResult,\n options?: RenderOptions\n ) {\n let node: Node | null;\n let nodeIndex = 0;\n let attrNameIndex = 0;\n const partCount = strings.length - 1;\n const parts = this.parts;\n\n // Create template element\n const [html, attrNames] = getTemplateHtml(strings, type);\n this.el = Template.createElement(html, options);\n walker.currentNode = this.el.content;\n\n // Re-parent SVG or MathML nodes into template root\n if (type === SVG_RESULT || type === MATHML_RESULT) {\n const wrapper = this.el.content.firstChild!;\n wrapper.replaceWith(...wrapper.childNodes);\n }\n\n // Walk the template to find binding markers and create TemplateParts\n while ((node = walker.nextNode()) !== null && parts.length < partCount) {\n if (node.nodeType === 1) {\n if (DEV_MODE) {\n const tag = (node as Element).localName;\n // Warn if `textarea` includes an expression and throw if `template`\n // does since these are not supported. We do this by checking\n // innerHTML for anything that looks like a marker. This catches\n // cases like bindings in textarea there markers turn into text nodes.\n if (\n /^(?:textarea|template)$/i!.test(tag) &&\n (node as Element).innerHTML.includes(marker)\n ) {\n const m =\n `Expressions are not supported inside \\`${tag}\\` ` +\n `elements. See https://lit.dev/msg/expression-in-${tag} for more ` +\n `information.`;\n if (tag === 'template') {\n throw new Error(m);\n } else issueWarning('', m);\n }\n }\n // TODO (justinfagnani): for attempted dynamic tag names, we don't\n // increment the bindingIndex, and it'll be off by 1 in the element\n // and off by two after it.\n if ((node as Element).hasAttributes()) {\n for (const name of (node as Element).getAttributeNames()) {\n if (name.endsWith(boundAttributeSuffix)) {\n const realName = attrNames[attrNameIndex++];\n const value = (node as Element).getAttribute(name)!;\n const statics = value.split(marker);\n const m = /([.?@])?(.*)/.exec(realName)!;\n parts.push({\n type: ATTRIBUTE_PART,\n index: nodeIndex,\n name: m[2],\n strings: statics,\n ctor:\n m[1] === '.'\n ? PropertyPart\n : m[1] === '?'\n ? BooleanAttributePart\n : m[1] === '@'\n ? EventPart\n : AttributePart,\n });\n (node as Element).removeAttribute(name);\n } else if (name.startsWith(marker)) {\n parts.push({\n type: ELEMENT_PART,\n index: nodeIndex,\n });\n (node as Element).removeAttribute(name);\n }\n }\n }\n // TODO (justinfagnani): benchmark the regex against testing for each\n // of the 3 raw text element names.\n if (rawTextElement.test((node as Element).tagName)) {\n // For raw text elements we need to split the text content on\n // markers, create a Text node for each segment, and create\n // a TemplatePart for each marker.\n const strings = (node as Element).textContent!.split(marker);\n const lastIndex = strings.length - 1;\n if (lastIndex > 0) {\n (node as Element).textContent = trustedTypes\n ? (trustedTypes.emptyScript as unknown as '')\n : '';\n // Generate a new text node for each literal section\n // These nodes are also used as the markers for child parts\n for (let i = 0; i < lastIndex; i++) {\n (node as Element).append(strings[i], createMarker());\n // Walk past the marker node we just added\n walker.nextNode();\n parts.push({type: CHILD_PART, index: ++nodeIndex});\n }\n // Note because this marker is added after the walker's current\n // node, it will be walked to in the outer loop (and ignored), so\n // we don't need to adjust nodeIndex here\n (node as Element).append(strings[lastIndex], createMarker());\n }\n }\n } else if (node.nodeType === 8) {\n const data = (node as Comment).data;\n if (data === markerMatch) {\n parts.push({type: CHILD_PART, index: nodeIndex});\n } else {\n let i = -1;\n while ((i = (node as Comment).data.indexOf(marker, i + 1)) !== -1) {\n // Comment node has a binding marker inside, make an inactive part\n // The binding won't work, but subsequent bindings will\n parts.push({type: COMMENT_PART, index: nodeIndex});\n // Move to the end of the match\n i += marker.length - 1;\n }\n }\n }\n nodeIndex++;\n }\n\n if (DEV_MODE) {\n // If there was a duplicate attribute on a tag, then when the tag is\n // parsed into an element the attribute gets de-duplicated. We can detect\n // this mismatch if we haven't precisely consumed every attribute name\n // when preparing the template. This works because `attrNames` is built\n // from the template string and `attrNameIndex` comes from processing the\n // resulting DOM.\n if (attrNames.length !== attrNameIndex) {\n throw new Error(\n `Detected duplicate attribute bindings. This occurs if your template ` +\n `has duplicate attributes on an element tag. For example ` +\n `\"<input ?disabled=\\${true} ?disabled=\\${false}>\" contains a ` +\n `duplicate \"disabled\" attribute. The error was detected in ` +\n `the following template: \\n` +\n '`' +\n strings.join('${...}') +\n '`'\n );\n }\n }\n\n // We could set walker.currentNode to another node here to prevent a memory\n // leak, but every time we prepare a template, we immediately render it\n // and re-use the walker in new TemplateInstance._clone().\n debugLogEvent &&\n debugLogEvent({\n kind: 'template prep',\n template: this,\n clonableTemplate: this.el,\n parts: this.parts,\n strings,\n });\n }\n\n // Overridden via `litHtmlPolyfillSupport` to provide platform support.\n /** @nocollapse */\n static createElement(html: TrustedHTML, _options?: RenderOptions) {\n const el = d.createElement('template');\n el.innerHTML = html as unknown as string;\n return el;\n }\n}\n\nexport interface Disconnectable {\n _$parent?: Disconnectable;\n _$disconnectableChildren?: Set<Disconnectable>;\n // Rather than hold connection state on instances, Disconnectables recursively\n // fetch the connection state from the RootPart they are connected in via\n // getters up the Disconnectable tree via _$parent references. This pushes the\n // cost of tracking the isConnected state to `AsyncDirectives`, and avoids\n // needing to pass all Disconnectables (parts, template instances, and\n // directives) their connection state each time it changes, which would be\n // costly for trees that have no AsyncDirectives.\n _$isConnected: boolean;\n}\n\nfunction resolveDirective(\n part: ChildPart | AttributePart | ElementPart,\n value: unknown,\n parent: DirectiveParent = part,\n attributeIndex?: number\n): unknown {\n // Bail early if the value is explicitly noChange. Note, this means any\n // nested directive is still attached and is not run.\n if (value === noChange) {\n return value;\n }\n let currentDirective =\n attributeIndex !== undefined\n ? (parent as AttributePart).__directives?.[attributeIndex]\n : (parent as ChildPart | ElementPart | Directive).__directive;\n const nextDirectiveConstructor = isPrimitive(value)\n ? undefined\n : // This property needs to remain unminified.\n (value as DirectiveResult)['_$litDirective$'];\n if (currentDirective?.constructor !== nextDirectiveConstructor) {\n // This property needs to remain unminified.\n currentDirective?.['_$notifyDirectiveConnectionChanged']?.(false);\n if (nextDirectiveConstructor === undefined) {\n currentDirective = undefined;\n } else {\n currentDirective = new nextDirectiveConstructor(part as PartInfo);\n currentDirective._$initialize(part, parent, attributeIndex);\n }\n if (attributeIndex !== undefined) {\n ((parent as AttributePart).__directives ??= [])[attributeIndex] =\n currentDirective;\n } else {\n (parent as ChildPart | Directive).__directive = currentDirective;\n }\n }\n if (currentDirective !== undefined) {\n value = resolveDirective(\n part,\n currentDirective._$resolve(part, (value as DirectiveResult).values),\n currentDirective,\n attributeIndex\n );\n }\n return value;\n}\n\nexport type {TemplateInstance};\n/**\n * An updateable instance of a Template. Holds references to the Parts used to\n * update the template instance.\n */\nclass TemplateInstance implements Disconnectable {\n _$template: Template;\n _$parts: Array<Part | undefined> = [];\n\n /** @internal */\n _$parent: ChildPart;\n /** @internal */\n _$disconnectableChildren?: Set<Disconnectable> = undefined;\n\n constructor(template: Template, parent: ChildPart) {\n this._$template = template;\n this._$parent = parent;\n }\n\n // Called by ChildPart parentNode getter\n get parentNode() {\n return this._$parent.parentNode;\n }\n\n // See comment in Disconnectable interface for why this is a getter\n get _$isConnected() {\n return this._$parent._$isConnected;\n }\n\n // This method is separate from the constructor because we need to return a\n // DocumentFragment and we don't want to hold onto it with an instance field.\n _clone(options: RenderOptions | undefined) {\n const {\n el: {content},\n parts: parts,\n } = this._$template;\n const fragment = (options?.creationScope ?? d).importNode(content, true);\n walker.currentNode = fragment;\n\n let node = walker.nextNode()!;\n let nodeIndex = 0;\n let partIndex = 0;\n let templatePart = parts[0];\n\n while (templatePart !== undefined) {\n if (nodeIndex === templatePart.index) {\n let part: Part | undefined;\n if (templatePart.type === CHILD_PART) {\n part = new ChildPart(\n node as HTMLElement,\n node.nextSibling,\n this,\n options\n );\n } else if (templatePart.type === ATTRIBUTE_PART) {\n part = new templatePart.ctor(\n node as HTMLElement,\n templatePart.name,\n templatePart.strings,\n this,\n options\n );\n } else if (templatePart.type === ELEMENT_PART) {\n part = new ElementPart(node as HTMLElement, this, options);\n }\n this._$parts.push(part);\n templatePart = parts[++partIndex];\n }\n if (nodeIndex !== templatePart?.index) {\n node = walker.nextNode()!;\n nodeIndex++;\n }\n }\n // We need to set the currentNode away from the cloned tree so that we\n // don't hold onto the tree even if the tree is detached and should be\n // freed.\n walker.currentNode = d;\n return fragment;\n }\n\n _update(values: Array<unknown>) {\n let i = 0;\n for (const part of this._$parts) {\n if (part !== undefined) {\n debugLogEvent &&\n debugLogEvent({\n kind: 'set part',\n part,\n value: values[i],\n valueIndex: i,\n values,\n templateInstance: this,\n });\n if ((part as AttributePart).strings !== undefined) {\n (part as AttributePart)._$setValue(values, part as AttributePart, i);\n // The number of values the part consumes is part.strings.length - 1\n // since values are in between template spans. We increment i by 1\n // later in the loop, so increment it by part.strings.length - 2 here\n i += (part as AttributePart).strings!.length - 2;\n } else {\n part._$setValue(values[i]);\n }\n }\n i++;\n }\n }\n}\n\n/*\n * Parts\n */\ntype AttributeTemplatePart = {\n readonly type: typeof ATTRIBUTE_PART;\n readonly index: number;\n readonly name: string;\n readonly ctor: typeof AttributePart;\n readonly strings: ReadonlyArray<string>;\n};\ntype ChildTemplatePart = {\n readonly type: typeof CHILD_PART;\n readonly index: number;\n};\ntype ElementTemplatePart = {\n readonly type: typeof ELEMENT_PART;\n readonly index: number;\n};\ntype CommentTemplatePart = {\n readonly type: typeof COMMENT_PART;\n readonly index: number;\n};\n\n/**\n * A TemplatePart represents a dynamic part in a template, before the template\n * is instantiated. When a template is instantiated Parts are created from\n * TemplateParts.\n */\ntype TemplatePart =\n | ChildTemplatePart\n | AttributeTemplatePart\n | ElementTemplatePart\n | CommentTemplatePart;\n\nexport type Part =\n | ChildPart\n | AttributePart\n | PropertyPart\n | BooleanAttributePart\n | ElementPart\n | EventPart;\n\nexport type {ChildPart};\nclass ChildPart implements Disconnectable {\n readonly type = CHILD_PART;\n readonly options: RenderOptions | undefined;\n _$committedValue: unknown = nothing;\n /** @internal */\n __directive?: Directive;\n /** @internal */\n _$startNode: ChildNode;\n /** @internal */\n _$endNode: ChildNode | null;\n private _textSanitizer: ValueSanitizer | undefined;\n /** @internal */\n _$parent: Disconnectable | undefined;\n /**\n * Connection state for RootParts only (i.e. ChildPart without _$parent\n * returned from top-level `render`). This field is unused otherwise. The\n * intention would be clearer if we made `RootPart` a subclass of `ChildPart`\n * with this field (and a different _$isConnected getter), but the subclass\n * caused a perf regression, possibly due to making call sites polymorphic.\n * @internal\n */\n __isConnected: boolean;\n\n // See comment in Disconnectable interface for why this is a getter\n get _$isConnected() {\n // ChildParts that are not at the root should always be created with a\n // parent; only RootChildNode's won't, so they return the local isConnected\n // state\n return this._$parent?._$isConnected ?? this.__isConnected;\n }\n\n // The following fields will be patched onto ChildParts when required by\n // AsyncDirective\n /** @internal */\n _$disconnectableChildren?: Set<Disconnectable> = undefined;\n /** @internal */\n _$notifyConnectionChanged?(\n isConnected: boolean,\n removeFromParent?: boolean,\n from?: number\n ): void;\n /** @internal */\n _$reparentDisconnectables?(parent: Disconnectable): void;\n\n constructor(\n startNode: ChildNode,\n endNode: ChildNode | null,\n parent: TemplateInstance | ChildPart | undefined,\n options: RenderOptions | undefined\n ) {\n this._$startNode = startNode;\n this._$endNode = endNode;\n this._$parent = parent;\n this.options = options;\n // Note __isConnected is only ever accessed on RootParts (i.e. when there is\n // no _$parent); the value on a non-root-part is \"don't care\", but checking\n // for parent would be more code\n this.__isConnected = options?.isConnected ?? true;\n if (ENABLE_EXTRA_SECURITY_HOOKS) {\n // Explicitly initialize for consistent class shape.\n this._textSanitizer = undefined;\n }\n }\n\n /**\n * The parent node into which the part renders its content.\n *\n * A ChildPart's content consists of a range of adjacent child nodes of\n * `.parentNode`, possibly bordered by 'marker nodes' (`.startNode` and\n * `.endNode`).\n *\n * - If both `.startNode` and `.endNode` are non-null, then the part's content\n * consists of all siblings between `.startNode` and `.endNode`, exclusively.\n *\n * - If `.startNode` is non-null but `.endNode` is null, then the part's\n * content consists of all siblings following `.startNode`, up to and\n * including the last child of `.parentNode`. If `.endNode` is non-null, then\n * `.startNode` will always be non-null.\n *\n * - If both `.endNode` and `.startNode` are null, then the part's content\n * consists of all child nodes of `.parentNode`.\n */\n get parentNode(): Node {\n let parentNode: Node = wrap(this._$startNode).parentNode!;\n const parent = this._$parent;\n if (\n parent !== undefined &&\n parentNode?.nodeType === 11 /* Node.DOCUMENT_FRAGMENT */\n ) {\n // If the parentNode is a DocumentFragment, it may be because the DOM is\n // still in the cloned fragment during initial render; if so, get the real\n // parentNode the part will be committed into by asking the parent.\n parentNode = (parent as ChildPart | TemplateInstance).parentNode;\n }\n return parentNode;\n }\n\n /**\n * The part's leading marker node, if any. See `.parentNode` for more\n * information.\n */\n get startNode(): Node | null {\n return this._$startNode;\n }\n\n /**\n * The part's trailing marker node, if any. See `.parentNode` for more\n * information.\n */\n get endNode(): Node | null {\n return this._$endNode;\n }\n\n _$setValue(value: unknown, directiveParent: DirectiveParent = this): void {\n if (DEV_MODE && this.parentNode === null) {\n throw new Error(\n `This \\`ChildPart\\` has no \\`parentNode\\` and therefore cannot accept a value. This likely means the element containing the part was manipulated in an unsupported way outside of Lit's control such that the part's marker nodes were ejected from DOM. For example, setting the element's \\`innerHTML\\` or \\`textContent\\` can do this.`\n );\n }\n value = resolveDirective(this, value, directiveParent);\n if (isPrimitive(value)) {\n // Non-rendering child values. It's important that these do not render\n // empty text nodes to avoid issues with preventing default <slot>\n // fallback content.\n if (value === nothing || value == null || value === '') {\n if (this._$committedValue !== nothing) {\n debugLogEvent &&\n debugLogEvent({\n kind: 'commit nothing to child',\n start: this._$startNode,\n end: this._$endNode,\n parent: this._$parent,\n options: this.options,\n });\n this._$clear();\n }\n this._$committedValue = nothing;\n } else if (value !== this._$committedValue && value !== noChange) {\n this._commitText(value);\n }\n // This property needs to remain unminified.\n } else if ((value as TemplateResult)['_$litType$'] !== undefined) {\n this._commitTemplateResult(value as TemplateResult);\n } else if ((value as Node).nodeType !== undefined) {\n if (DEV_MODE && this.options?.host === value) {\n this._commitText(\n `[probable mistake: rendered a template's host in itself ` +\n `(commonly caused by writing \\${this} in a template]`\n );\n console.warn(\n `Attempted to render the template host`,\n value,\n `inside itself. This is almost always a mistake, and in dev mode `,\n `we render some warning text. In production however, we'll `,\n `render it, which will usually result in an error, and sometimes `,\n `in the element disappearing from the DOM.`\n );\n return;\n }\n this._commitNode(value as Node);\n } else if (isIterable(value)) {\n this._commitIterable(value);\n } else {\n // Fallback, will render the string representation\n this._commitText(value);\n }\n }\n\n private _insert<T extends Node>(node: T) {\n return wrap(wrap(this._$startNode).parentNode!).insertBefore(\n node,\n this._$endNode\n );\n }\n\n private _commitNode(value: Node): void {\n if (this._$committedValue !== value) {\n this._$clear();\n if (\n ENABLE_EXTRA_SECURITY_HOOKS &&\n sanitizerFactoryInternal !== noopSanitizer\n ) {\n const parentNodeName = this._$startNode.parentNode?.nodeName;\n if (parentNodeName === 'STYLE' || parentNodeName === 'SCRIPT') {\n let message = 'Forbidden';\n if (DEV_MODE) {\n if (parentNodeName === 'STYLE') {\n message =\n `Lit does not support binding inside style nodes. ` +\n `This is a security risk, as style injection attacks can ` +\n `exfiltrate data and spoof UIs. ` +\n `Consider instead using css\\`...\\` literals ` +\n `to compose styles, and do dynamic styling with ` +\n `css custom properties, ::parts, <slot>s, ` +\n `and by mutating the DOM rather than stylesheets.`;\n } else {\n message =\n `Lit does not support binding inside script nodes. ` +\n `This is a security risk, as it could allow arbitrary ` +\n `code execution.`;\n }\n }\n throw new Error(message);\n }\n }\n debugLogEvent &&\n debugLogEvent({\n kind: 'commit node',\n start: this._$startNode,\n parent: this._$parent,\n value: value,\n options: this.options,\n });\n this._$committedValue = this._insert(value);\n }\n }\n\n private _commitText(value: unknown): void {\n // If the committed value is a primitive it means we called _commitText on\n // the previous render, and we know that this._$startNode.nextSibling is a\n // Text node. We can now just replace the text content (.data) of the node.\n if (\n this._$committedValue !== nothing &&\n isPrimitive(this._$committedValue)\n ) {\n const node = wrap(this._$startNode).nextSibling as Text;\n if (ENABLE_EXTRA_SECURITY_HOOKS) {\n if (this._textSanitizer === undefined) {\n this._textSanitizer = createSanitizer(node, 'data', 'property');\n }\n value = this._textSanitizer(value);\n }\n debugLogEvent &&\n debugLogEvent({\n kind: 'commit text',\n node,\n value,\n options: this.options,\n });\n (node as Text).data = value as string;\n } else {\n if (ENABLE_EXTRA_SECURITY_HOOKS) {\n const textNode = d.createTextNode('');\n this._commitNode(textNode);\n // When setting text content, for security purposes it matters a lot\n // what the parent is. For example, <style> and <script> need to be\n // handled with care, while <span> does not. So first we need to put a\n // text node into the document, then we can sanitize its content.\n if (this._textSanitizer === undefined) {\n this._textSanitizer = createSanitizer(textNode, 'data', 'property');\n }\n value = this._textSanitizer(value);\n debugLogEvent &&\n debugLogEvent({\n kind: 'commit text',\n node: textNode,\n value,\n options: this.options,\n });\n textNode.data = value as string;\n } else {\n this._commitNode(d.createTextNode(value as string));\n debugLogEvent &&\n debugLogEvent({\n kind: 'commit text',\n node: wrap(this._$startNode).nextSibling as Text,\n value,\n options: this.options,\n });\n }\n }\n this._$committedValue = value;\n }\n\n private _commitTemplateResult(\n result: TemplateResult | CompiledTemplateResult\n ): void {\n // This property needs to remain unminified.\n const {values, ['_$litType$']: type} = result;\n // If $litType$ is a number, result is a plain TemplateResult and we get\n // the template from the template cache. If not, result is a\n // CompiledTemplateResult and _$litType$ is a CompiledTemplate and we need\n // to create the <template> element the first time we see it.\n const template: Template | CompiledTemplate =\n typeof type === 'number'\n ? this._$getTemplate(result as UncompiledTemplateResult)\n : (type.el === undefined &&\n (type.el = Template.createElement(\n trustFromTemplateString(type.h, type.h[0]),\n this.options\n )),\n type);\n\n if ((this._$committedValue as TemplateInstance)?._$template === template) {\n debugLogEvent &&\n debugLogEvent({\n kind: 'template updating',\n template,\n instance: this._$committedValue as TemplateInstance,\n parts: (this._$committedValue as TemplateInstance)._$parts,\n options: this.options,\n values,\n });\n (this._$committedValue as TemplateInstance)._update(values);\n } else {\n const instance = new TemplateInstance(template as Template, this);\n const fragment = instance._clone(this.options);\n debugLogEvent &&\n debugLogEvent({\n kind: 'template instantiated',\n template,\n instance,\n parts: instance._$parts,\n options: this.options,\n fragment,\n values,\n });\n instance._update(values);\n debugLogEvent &&\n debugLogEvent({\n kind: 'template instantiated and updated',\n template,\n instance,\n parts: instance._$parts,\n options: this.options,\n fragment,\n values,\n });\n this._commitNode(fragment);\n this._$committedValue = instance;\n }\n }\n\n // Overridden via `litHtmlPolyfillSupport` to provide platform support.\n /** @internal */\n _$getTemplate(result: UncompiledTemplateResult) {\n let template = templateCache.get(result.strings);\n if (template === undefined) {\n templateCache.set(result.strings, (template = new Template(result)));\n }\n return template;\n }\n\n private _commitIterable(value: Iterable<unknown>): void {\n // For an Iterable, we create a new InstancePart per item, then set its\n // value to the item. This is a little bit of overhead for every item in\n // an Iterable, but it lets us recurse easily and efficiently update Arrays\n // of TemplateResults that will be commonly returned from expressions like:\n // array.map((i) => html`${i}`), by reusing existing TemplateInstances.\n\n // If value is an array, then the previous render was of an\n // iterable and value will contain the ChildParts from the previous\n // render. If value is not an array, clear this part and make a new\n // array for ChildParts.\n if (!isArray(this._$committedValue)) {\n this._$committedValue = [];\n this._$clear();\n }\n\n // Lets us keep track of how many items we stamped so we can clear leftover\n // items from a previous render\n const itemParts = this._$committedValue as ChildPart[];\n let partIndex = 0;\n let itemPart: ChildPart | undefined;\n\n for (const item of value) {\n if (partIndex === itemParts.length) {\n // If no existing part, create a new one\n // TODO (justinfagnani): test perf impact of always creating two parts\n // instead of sharing parts between nodes\n // https://github.com/lit/lit/issues/1266\n itemParts.push(\n (itemPart = new ChildPart(\n this._insert(createMarker()),\n this._insert(createMarker()),\n this,\n this.options\n ))\n );\n } else {\n // Reuse an existing part\n itemPart = itemParts[partIndex];\n }\n itemPart._$setValue(item);\n partIndex++;\n }\n\n if (partIndex < itemParts.length) {\n // itemParts always have end nodes\n this._$clear(\n itemPart && wrap(itemPart._$endNode!).nextSibling,\n partIndex\n );\n // Truncate the parts array so _value reflects the current state\n itemParts.length = partIndex;\n }\n }\n\n /**\n * Removes the nodes contained within this Part from the DOM.\n *\n * @param start Start node to clear from, for clearing a subset of the part's\n * DOM (used when truncating iterables)\n * @param from When `start` is specified, the index within the iterable from\n * which ChildParts are being removed, used for disconnecting directives\n * in those Parts.\n *\n * @internal\n */\n _$clear(\n start: ChildNode | null = wrap(this._$startNode).nextSibling,\n from?: number\n ) {\n this._$notifyConnectionChanged?.(false, true, from);\n while (start !== this._$endNode) {\n // The non-null assertion is safe because if _$startNode.nextSibling is\n // null, then _$endNode is also null, and we would not have entered this\n // loop.\n const n = wrap(start!).nextSibling;\n wrap(start!).remove();\n start = n;\n }\n }\n\n /**\n * Implementation of RootPart's `isConnected`. Note that this method\n * should only be called on `RootPart`s (the `ChildPart` returned from a\n * top-level `render()` call). It has no effect on non-root ChildParts.\n * @param isConnected Whether to set\n * @internal\n */\n setConnected(isConnected: boolean) {\n if (this._$parent === undefined) {\n this.__isConnected = isConnected;\n this._$notifyConnectionChanged?.(isConnected);\n } else if (DEV_MODE) {\n throw new Error(\n 'part.setConnected() may only be called on a ' +\n 'RootPart returned from render().'\n );\n }\n }\n}\n\n/**\n * A top-level `ChildPart` returned from `render` that manages the connected\n * state of `AsyncDirective`s created throughout the tree below it.\n */\nexport interface RootPart extends ChildPart {\n /**\n * Sets the connection state for `AsyncDirective`s contained within this root\n * ChildPart.\n *\n * lit-html does not automatically monitor the connectedness of DOM rendered;\n * as such, it is the responsibility of the caller to `render` to ensure that\n * `part.setConnected(false)` is called before the part object is potentially\n * discarded, to ensure that `AsyncDirective`s have a chance to dispose of\n * any resources being held. If a `RootPart` that was previously\n * disconnected is subsequently re-connected (and its `AsyncDirective`s should\n * re-connect), `setConnected(true)` should be called.\n *\n * @param isConnected Whether directives within this tree should be connected\n * or not\n */\n setConnected(isConnected: boolean): void;\n}\n\nexport type {AttributePart};\nclass AttributePart implements Disconnectable {\n readonly type:\n | typeof ATTRIBUTE_PART\n | typeof PROPERTY_PART\n | typeof BOOLEAN_ATTRIBUTE_PART\n | typeof EVENT_PART = ATTRIBUTE_PART;\n readonly element: HTMLElement;\n readonly name: string;\n readonly options: RenderOptions | undefined;\n\n /**\n * If this attribute part represents an interpolation, this contains the\n * static strings of the interpolation. For single-value, complete bindings,\n * this is undefined.\n */\n readonly strings?: ReadonlyArray<string>;\n /** @internal */\n _$committedValue: unknown | Array<unknown> = nothing;\n /** @internal */\n __directives?: Array<Directive | undefined>;\n /** @internal */\n _$parent: Disconnectable;\n /** @internal */\n _$disconnectableChildren?: Set<Disconnectable> = undefined;\n\n protected _sanitizer: ValueSanitizer | undefined;\n\n get tagName() {\n return this.element.tagName;\n }\n\n // See comment in Disconnectable interface for why this is a getter\n get _$isConnected() {\n return this._$parent._$isConnected;\n }\n\n constructor(\n element: HTMLElement,\n name: string,\n strings: ReadonlyArray<string>,\n parent: Disconnectable,\n options: RenderOptions | undefined\n ) {\n this.element = element;\n this.name = name;\n this._$parent = parent;\n this.options = options;\n if (strings.length > 2 || strings[0] !== '' || strings[1] !== '') {\n this._$committedValue = new Array(strings.length - 1).fill(new String());\n this.strings = strings;\n } else {\n this._$committedValue = nothing;\n }\n if (ENABLE_EXTRA_SECURITY_HOOKS) {\n this._sanitizer = undefined;\n }\n }\n\n /**\n * Sets the value of this part by resolving the value from possibly multiple\n * values and static strings and committing it to the DOM.\n * If this part is single-valued, `this._strings` will be undefined, and the\n * method will be called with a single value argument. If this part is\n * multi-value, `this._strings` will be defined, and the method is called\n * with the value array of the part's owning TemplateInstance, and an offset\n * into the value array from which the values should be read.\n * This method is overloaded this way to eliminate short-lived array slices\n * of the template instance values, and allow a fast-path for single-valued\n * parts.\n *\n * @param value The part value, or an array of values for multi-valued parts\n * @param valueIndex the index to start reading values from. `undefined` for\n * single-valued parts\n * @param noCommit causes the part to not commit its value to the DOM. Used\n * in hydration to prime attribute parts with their first-rendered value,\n * but not set the attribute, and in SSR to no-op the DOM operation and\n * capture the value for serialization.\n *\n * @internal\n */\n _$setValue(\n value: unknown | Array<unknown>,\n directiveParent: DirectiveParent = this,\n valueIndex?: number,\n noCommit?: boolean\n ) {\n const strings = this.strings;\n\n // Whether any of the values has changed, for dirty-checking\n let change = false;\n\n if (strings === undefined) {\n // Single-value binding case\n value = resolveDirective(this, value, directiveParent, 0);\n change =\n !isPrimitive(value) ||\n (value !== this._$committedValue && value !== noChange);\n if (change) {\n this._$committedValue = value;\n }\n } else {\n // Interpolation case\n const values = value as Array<unknown>;\n value = strings[0];\n\n let i, v;\n for (i = 0; i < strings.length - 1; i++) {\n v = resolveDirective(this, values[valueIndex! + i], directiveParent, i);\n\n if (v === noChange) {\n // If the user-provided value is `noChange`, use the previous value\n v = (this._$committedValue as Array<unknown>)[i];\n }\n change ||=\n !isPrimitive(v) || v !== (this._$committedValue as Array<unknown>)[i];\n if (v === nothing) {\n value = nothing;\n } else if (value !== nothing) {\n value += (v ?? '') + strings[i + 1];\n }\n // We always record each value, even if one is `nothing`, for future\n // change detection.\n (this._$committedValue as Array<unknown>)[i] = v;\n }\n }\n if (change && !noCommit) {\n this._commitValue(value);\n }\n }\n\n /** @internal */\n _commitValue(value: unknown) {\n if (value === nothing) {\n (wrap(this.element) as Element).removeAttribute(this.name);\n } else {\n if (ENABLE_EXTRA_SECURITY_HOOKS) {\n if (this._sanitizer === undefined) {\n this._sanitizer = sanitizerFactoryInternal(\n this.element,\n this.name,\n 'attribute'\n );\n }\n value = this._sanitizer(value ?? '');\n }\n debugLogEvent &&\n debugLogEvent({\n kind: 'commit attribute',\n element: this.element,\n name: this.name,\n value,\n options: this.options,\n });\n (wrap(this.element) as Element).setAttribute(\n this.name,\n (value ?? '') as string\n );\n }\n }\n}\n\nexport type {PropertyPart};\nclass PropertyPart extends AttributePart {\n override readonly type = PROPERTY_PART;\n\n /** @internal */\n override _commitValue(value: unknown) {\n if (ENABLE_EXTRA_SECURITY_HOOKS) {\n if (this._sanitizer === undefined) {\n this._sanitizer = sanitizerFactoryInternal(\n this.element,\n this.name,\n 'property'\n );\n }\n value = this._sanitizer(value);\n }\n debugLogEvent &&\n debugLogEvent({\n kind: 'commit property',\n element: this.element,\n name: this.name,\n value,\n options: this.options,\n });\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (this.element as any)[this.name] = value === nothing ? undefined : value;\n }\n}\n\nexport type {BooleanAttributePart};\nclass BooleanAttributePart extends AttributePart {\n override readonly type = BOOLEAN_ATTRIBUTE_PART;\n\n /** @internal */\n override _commitValue(value: unknown) {\n debugLogEvent &&\n debugLogEvent({\n kind: 'commit boolean attribute',\n element: this.element,\n name: this.name,\n value: !!(value && value !== nothing),\n options: this.options,\n });\n (wrap(this.element) as Element).toggleAttribute(\n this.name,\n !!value && value !== nothing\n );\n }\n}\n\ntype EventListenerWithOptions = EventListenerOrEventListenerObject &\n Partial<AddEventListenerOptions>;\n\n/**\n * An AttributePart that manages an event listener via add/removeEventListener.\n *\n * This part works by adding itself as the event listener on an element, then\n * delegating to the value passed to it. This reduces the number of calls to\n * add/removeEventListener if the listener changes frequently, such as when an\n * inline function is used as a listener.\n *\n * Because event options are passed when adding listeners, we must take case\n * to add and remove the part as a listener when the event options change.\n */\nexport type {EventPart};\nclass EventPart extends AttributePart {\n override readonly type = EVENT_PART;\n\n constructor(\n element: HTMLElement,\n name: string,\n strings: ReadonlyArray<string>,\n parent: Disconnectable,\n options: RenderOptions | undefined\n ) {\n super(element, name, strings, parent, options);\n\n if (DEV_MODE && this.strings !== undefined) {\n throw new Error(\n `A \\`<${element.localName}>\\` has a \\`@${name}=...\\` listener with ` +\n 'invalid content. Event listeners in templates must have exactly ' +\n 'one expression and no surrounding text.'\n );\n }\n }\n\n // EventPart does not use the base _$setValue/_resolveValue implementation\n // since the dirty checking is more complex\n /** @internal */\n override _$setValue(\n newListener: unknown,\n directiveParent: DirectiveParent = this\n ) {\n newListener =\n resolveDirective(this, newListener, directiveParent, 0) ?? nothing;\n if (newListener === noChange) {\n return;\n }\n const oldListener = this._$committedValue;\n\n // If the new value is nothing or any options change we have to remove the\n // part as a listener.\n const shouldRemoveListener =\n (newListener === nothing && oldListener !== nothing) ||\n (newListener as EventListenerWithOptions).capture !==\n (oldListener as EventListenerWithOptions).capture ||\n (newListener as EventListenerWithOptions).once !==\n (oldListener as EventListenerWithOptions).once ||\n (newListener as EventListenerWithOptions).passive !==\n (oldListener as EventListenerWithOptions).passive;\n\n // If the new value is not nothing and we removed the listener, we have\n // to add the part as a listener.\n const shouldAddListener =\n newListener !== nothing &&\n (oldListener === nothing || shouldRemoveListener);\n\n debugLogEvent &&\n debugLogEvent({\n kind: 'commit event listener',\n element: this.element,\n name: this.name,\n value: newListener,\n options: this.options,\n removeListener: shouldRemoveListener,\n addListener: shouldAddListener,\n oldListener,\n });\n if (shouldRemoveListener) {\n this.element.removeEventListener(\n this.name,\n this,\n oldListener as EventListenerWithOptions\n );\n }\n if (shouldAddListener) {\n this.element.addEventListener(\n this.name,\n this,\n newListener as EventListenerWithOptions\n );\n }\n this._$committedValue = newListener;\n }\n\n handleEvent(event: Event) {\n if (typeof this._$committedValue === 'function') {\n this._$committedValue.call(this.options?.host ?? this.element, event);\n } else {\n (this._$committedValue as EventListenerObject).handleEvent(event);\n }\n }\n}\n\nexport type {ElementPart};\nclass ElementPart implements Disconnectable {\n readonly type = ELEMENT_PART;\n\n /** @internal */\n __directive?: Directive;\n\n // This is to ensure that every Part has a _$committedValue\n _$committedValue: undefined;\n\n /** @internal */\n _$parent!: Disconnectable;\n\n /** @internal */\n _$disconnectableChildren?: Set<Disconnectable> = undefined;\n\n options: RenderOptions | undefined;\n\n constructor(\n public element: Element,\n parent: Disconnectable,\n options: RenderOptions | undefined\n ) {\n this._$parent = parent;\n this.options = options;\n }\n\n // See comment in Disconnectable interface for why this is a getter\n get _$isConnected() {\n return this._$parent._$isConnected;\n }\n\n _$setValue(value: unknown): void {\n debugLogEvent &&\n debugLogEvent({\n kind: 'commit to element binding',\n element: this.element,\n value,\n options: this.options,\n });\n resolveDirective(this, value);\n }\n}\n\n/**\n * END USERS SHOULD NOT RELY ON THIS OBJECT.\n *\n * Private exports for use by other Lit packages, not intended for use by\n * external users.\n *\n * We currently do not make a mangled rollup build of the lit-ssr code. In order\n * to keep a number of (otherwise private) top-level exports mangled in the\n * client side code, we export a _$LH object containing those members (or\n * helper methods for accessing private fields of those members), and then\n * re-export them for use in lit-ssr. This keeps lit-ssr agnostic to whether the\n * client-side code is being used in `dev` mode or `prod` mode.\n *\n * This has a unique name, to disambiguate it from private exports in\n * lit-element, which re-exports all of lit-html.\n *\n * @private\n */\nexport const _$LH = {\n // Used in lit-ssr\n _boundAttributeSuffix: boundAttributeSuffix,\n _marker: marker,\n _markerMatch: markerMatch,\n _HTML_RESULT: HTML_RESULT,\n _getTemplateHtml: getTemplateHtml,\n // Used in tests and private-ssr-support\n _TemplateInstance: TemplateInstance,\n _isIterable: isIterable,\n _resolveDirective: resolveDirective,\n _ChildPart: ChildPart,\n _AttributePart: AttributePart,\n _BooleanAttributePart: BooleanAttributePart,\n _EventPart: EventPart,\n _PropertyPart: PropertyPart,\n _ElementPart: ElementPart,\n};\n\n// Apply polyfills if available\nconst polyfillSupport = DEV_MODE\n ? global.litHtmlPolyfillSupportDevMode\n : global.litHtmlPolyfillSupport;\npolyfillSupport?.(Template, ChildPart);\n\n// IMPORTANT: do not change the property name or the assignment expression.\n// This line will be used in regexes to search for lit-html usage.\n(global.litHtmlVersions ??= []).push('3.3.1');\nif (DEV_MODE && global.litHtmlVersions.length > 1) {\n queueMicrotask(() => {\n issueWarning!(\n 'multiple-versions',\n `Multiple versions of Lit loaded. ` +\n `Loading multiple versions is not recommended.`\n );\n });\n}\n\n/**\n * Renders a value, usually a lit-html TemplateResult, to the container.\n *\n * This example renders the text \"Hello, Zoe!\" inside a paragraph tag, appending\n * it to the container `document.body`.\n *\n * ```js\n * import {html, render} from 'lit';\n *\n * const name = \"Zoe\";\n * render(html`<p>Hello, ${name}!</p>`, document.body);\n * ```\n *\n * @param value Any [renderable\n * value](https://lit.dev/docs/templates/expressions/#child-expressions),\n * typically a {@linkcode TemplateResult} created by evaluating a template tag\n * like {@linkcode html} or {@linkcode svg}.\n * @param container A DOM container to render to. The first render will append\n * the rendered value to the container, and subsequent renders will\n * efficiently update the rendered value if the same result type was\n * previously rendered there.\n * @param options See {@linkcode RenderOptions} for options documentation.\n * @see\n * {@link https://lit.dev/docs/libraries/standalone-templates/#rendering-lit-html-templates| Rendering Lit HTML Templates}\n */\nexport const render = (\n value: unknown,\n container: HTMLElement | DocumentFragment,\n options?: RenderOptions\n): RootPart => {\n if (DEV_MODE && container == null) {\n // Give a clearer error message than\n // Uncaught TypeError: Cannot read properties of null (reading\n // '_$litPart$')\n // which reads like an internal Lit error.\n throw new TypeError(`The container to render into may not be ${container}`);\n }\n const renderId = DEV_MODE ? debugLogRenderId++ : 0;\n const partOwnerNode = options?.renderBefore ?? container;\n // This property needs to remain unminified.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let part: ChildPart = (partOwnerNode as any)['_$litPart$'];\n debugLogEvent &&\n debugLogEvent({\n kind: 'begin render',\n id: renderId,\n value,\n container,\n options,\n part,\n });\n if (part === undefined) {\n const endNode = options?.renderBefore ?? null;\n // This property needs to remain unminified.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (partOwnerNode as any)['_$litPart$'] = part = new ChildPart(\n container.insertBefore(createMarker(), endNode),\n endNode,\n undefined,\n options ?? {}\n );\n }\n part._$setValue(value);\n debugLogEvent &&\n debugLogEvent({\n kind: 'end render',\n id: renderId,\n value,\n container,\n options,\n part,\n });\n return part as RootPart;\n};\n\nif (ENABLE_EXTRA_SECURITY_HOOKS) {\n render.setSanitizer = setSanitizer;\n render.createSanitizer = createSanitizer;\n if (DEV_MODE) {\n render._testOnlyClearSanitizerFactoryDoNotCallOrElse =\n _testOnlyClearSanitizerFactoryDoNotCallOrElse;\n }\n}\n", "/**\n * @license\n * Copyright 2020 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {\n _$LH,\n Part,\n DirectiveParent,\n CompiledTemplateResult,\n MaybeCompiledTemplateResult,\n UncompiledTemplateResult,\n} from './lit-html.js';\nimport {\n DirectiveResult,\n DirectiveClass,\n PartInfo,\n AttributePartInfo,\n} from './directive.js';\ntype Primitive = null | undefined | boolean | number | string | symbol | bigint;\n\nconst {_ChildPart: ChildPart} = _$LH;\n\ntype ChildPart = InstanceType<typeof ChildPart>;\n\nconst ENABLE_SHADYDOM_NOPATCH = true;\n\nconst wrap =\n ENABLE_SHADYDOM_NOPATCH &&\n window.ShadyDOM?.inUse &&\n window.ShadyDOM?.noPatch === true\n ? window.ShadyDOM!.wrap\n : (node: Node) => node;\n\n/**\n * Tests if a value is a primitive value.\n *\n * See https://tc39.github.io/ecma262/#sec-typeof-operator\n */\nexport const isPrimitive = (value: unknown): value is Primitive =>\n value === null || (typeof value != 'object' && typeof value != 'function');\n\nexport const TemplateResultType = {\n HTML: 1,\n SVG: 2,\n MATHML: 3,\n} as const;\n\nexport type TemplateResultType =\n (typeof TemplateResultType)[keyof typeof TemplateResultType];\n\ntype IsTemplateResult = {\n (val: unknown): val is MaybeCompiledTemplateResult;\n <T extends TemplateResultType>(\n val: unknown,\n type: T\n ): val is UncompiledTemplateResult<T>;\n};\n\n/**\n * Tests if a value is a TemplateResult or a CompiledTemplateResult.\n */\nexport const isTemplateResult: IsTemplateResult = (\n value: unknown,\n type?: TemplateResultType\n): value is UncompiledTemplateResult =>\n type === undefined\n ? // This property needs to remain unminified.\n (value as UncompiledTemplateResult)?.['_$litType$'] !== undefined\n : (value as UncompiledTemplateResult)?.['_$litType$'] === type;\n\n/**\n * Tests if a value is a CompiledTemplateResult.\n */\nexport const isCompiledTemplateResult = (\n value: unknown\n): value is CompiledTemplateResult => {\n return (value as CompiledTemplateResult)?.['_$litType$']?.h != null;\n};\n\n/**\n * Tests if a value is a DirectiveResult.\n */\nexport const isDirectiveResult = (value: unknown): value is DirectiveResult =>\n // This property needs to remain unminified.\n (value as DirectiveResult)?.['_$litDirective$'] !== undefined;\n\n/**\n * Retrieves the Directive class for a DirectiveResult\n */\nexport const getDirectiveClass = (value: unknown): DirectiveClass | undefined =>\n // This property needs to remain unminified.\n (value as DirectiveResult)?.['_$litDirective$'];\n\n/**\n * Tests whether a part has only a single-expression with no strings to\n * interpolate between.\n *\n * Only AttributePart and PropertyPart can have multiple expressions.\n * Multi-expression parts have a `strings` property and single-expression\n * parts do not.\n */\nexport const isSingleExpression = (part: PartInfo) =>\n (part as AttributePartInfo).strings === undefined;\n\nconst createMarker = () => document.createComment('');\n\n/**\n * Inserts a ChildPart into the given container ChildPart's DOM, either at the\n * end of the container ChildPart, or before the optional `refPart`.\n *\n * This does not add the part to the containerPart's committed value. That must\n * be done by callers.\n *\n * @param containerPart Part within which to add the new ChildPart\n * @param refPart Part before which to add the new ChildPart; when omitted the\n * part added to the end of the `containerPart`\n * @param part Part to insert, or undefined to create a new part\n */\nexport const insertPart = (\n containerPart: ChildPart,\n refPart?: ChildPart,\n part?: ChildPart\n): ChildPart => {\n const container = wrap(containerPart._$startNode).parentNode!;\n\n const refNode =\n refPart === undefined ? containerPart._$endNode : refPart._$startNode;\n\n if (part === undefined) {\n const startNode = wrap(container).insertBefore(createMarker(), refNode);\n const endNode = wrap(container).insertBefore(createMarker(), refNode);\n part = new ChildPart(\n startNode,\n endNode,\n containerPart,\n containerPart.options\n );\n } else {\n const endNode = wrap(part._$endNode!).nextSibling;\n const oldParent = part._$parent;\n const parentChanged = oldParent !== containerPart;\n if (parentChanged) {\n part._$reparentDisconnectables?.(containerPart);\n // Note that although `_$reparentDisconnectables` updates the part's\n // `_$parent` reference after unlinking from its current parent, that\n // method only exists if Disconnectables are present, so we need to\n // unconditionally set it here\n part._$parent = containerPart;\n // Since the _$isConnected getter is somewhat costly, only\n // read it once we know the subtree has directives that need\n // to be notified\n let newConnectionState;\n if (\n part._$notifyConnectionChanged !== undefined &&\n (newConnectionState = containerPart._$isConnected) !==\n oldParent!._$isConnected\n ) {\n part._$notifyConnectionChanged(newConnectionState);\n }\n }\n if (endNode !== refNode || parentChanged) {\n let start: Node | null = part._$startNode;\n while (start !== endNode) {\n const n: Node | null = wrap(start!).nextSibling;\n wrap(container).insertBefore(start!, refNode);\n start = n;\n }\n }\n }\n\n return part;\n};\n\n/**\n * Sets the value of a Part.\n *\n * Note that this should only be used to set/update the value of user-created\n * parts (i.e. those created using `insertPart`); it should not be used\n * by directives to set the value of the directive's container part. Directives\n * should return a value from `update`/`render` to update their part state.\n *\n * For directives that require setting their part value asynchronously, they\n * should extend `AsyncDirective` and call `this.setValue()`.\n *\n * @param part Part to set\n * @param value Value to set\n * @param index For `AttributePart`s, the index to set\n * @param directiveParent Used internally; should not be set by user\n */\nexport const setChildPartValue = <T extends ChildPart>(\n part: T,\n value: unknown,\n directiveParent: DirectiveParent = part\n): T => {\n part._$setValue(value, directiveParent);\n return part;\n};\n\n// A sentinel value that can never appear as a part value except when set by\n// live(). Used to force a dirty-check to fail and cause a re-render.\nconst RESET_VALUE = {};\n\n/**\n * Sets the committed value of a ChildPart directly without triggering the\n * commit stage of the part.\n *\n * This is useful in cases where a directive needs to update the part such\n * that the next update detects a value change or not. When value is omitted,\n * the next update will be guaranteed to be detected as a change.\n *\n * @param part\n * @param value\n */\nexport const setCommittedValue = (part: Part, value: unknown = RESET_VALUE) =>\n (part._$committedValue = value);\n\n/**\n * Returns the committed value of a ChildPart.\n *\n * The committed value is used for change detection and efficient updates of\n * the part. It can differ from the value set by the template or directive in\n * cases where the template value is transformed before being committed.\n *\n * - `TemplateResult`s are committed as a `TemplateInstance`\n * - Iterables are committed as `Array<ChildPart>`\n * - All other types are committed as the template value or value returned or\n * set by a directive.\n *\n * @param part\n */\nexport const getCommittedValue = (part: ChildPart) => part._$committedValue;\n\n/**\n * Removes a ChildPart from the DOM, including any of its content and markers.\n *\n * Note: The only difference between this and clearPart() is that this also\n * removes the part's start node. This means that the ChildPart must own its\n * start node, ie it must be a marker node specifically for this part and not an\n * anchor from surrounding content.\n *\n * @param part The Part to remove\n */\nexport const removePart = (part: ChildPart) => {\n part._$clear();\n part._$startNode.remove();\n};\n\nexport const clearPart = (part: ChildPart) => {\n part._$clear();\n};\n", "/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/**\n * Overview:\n *\n * This module is designed to add support for an async `setValue` API and\n * `disconnected` callback to directives with the least impact on the core\n * runtime or payload when that feature is not used.\n *\n * The strategy is to introduce a `AsyncDirective` subclass of\n * `Directive` that climbs the \"parent\" tree in its constructor to note which\n * branches of lit-html's \"logical tree\" of data structures contain such\n * directives and thus need to be crawled when a subtree is being cleared (or\n * manually disconnected) in order to run the `disconnected` callback.\n *\n * The \"nodes\" of the logical tree include Parts, TemplateInstances (for when a\n * TemplateResult is committed to a value of a ChildPart), and Directives; these\n * all implement a common interface called `DisconnectableChild`. Each has a\n * `_$parent` reference which is set during construction in the core code, and a\n * `_$disconnectableChildren` field which is initially undefined.\n *\n * The sparse tree created by means of the `AsyncDirective` constructor\n * crawling up the `_$parent` tree and placing a `_$disconnectableChildren` Set\n * on each parent that includes each child that contains a\n * `AsyncDirective` directly or transitively via its children. In order to\n * notify connection state changes and disconnect (or reconnect) a tree, the\n * `_$notifyConnectionChanged` API is patched onto ChildParts as a directive\n * climbs the parent tree, which is called by the core when clearing a part if\n * it exists. When called, that method iterates over the sparse tree of\n * Set<DisconnectableChildren> built up by AsyncDirectives, and calls\n * `_$notifyDirectiveConnectionChanged` on any directives that are encountered\n * in that tree, running the required callbacks.\n *\n * A given \"logical tree\" of lit-html data-structures might look like this:\n *\n * ChildPart(N1) _$dC=[D2,T3]\n * ._directive\n * AsyncDirective(D2)\n * ._value // user value was TemplateResult\n * TemplateInstance(T3) _$dC=[A4,A6,N10,N12]\n * ._$parts[]\n * AttributePart(A4) _$dC=[D5]\n * ._directives[]\n * AsyncDirective(D5)\n * AttributePart(A6) _$dC=[D7,D8]\n * ._directives[]\n * AsyncDirective(D7)\n * Directive(D8) _$dC=[D9]\n * ._directive\n * AsyncDirective(D9)\n * ChildPart(N10) _$dC=[D11]\n * ._directive\n * AsyncDirective(D11)\n * ._value\n * string\n * ChildPart(N12) _$dC=[D13,N14,N16]\n * ._directive\n * AsyncDirective(D13)\n * ._value // user value was iterable\n * Array<ChildPart>\n * ChildPart(N14) _$dC=[D15]\n * ._value\n * string\n * ChildPart(N16) _$dC=[D17,T18]\n * ._directive\n * AsyncDirective(D17)\n * ._value // user value was TemplateResult\n * TemplateInstance(T18) _$dC=[A19,A21,N25]\n * ._$parts[]\n * AttributePart(A19) _$dC=[D20]\n * ._directives[]\n * AsyncDirective(D20)\n * AttributePart(A21) _$dC=[22,23]\n * ._directives[]\n * AsyncDirective(D22)\n * Directive(D23) _$dC=[D24]\n * ._directive\n * AsyncDirective(D24)\n * ChildPart(N25) _$dC=[D26]\n * ._directive\n * AsyncDirective(D26)\n * ._value\n * string\n *\n * Example 1: The directive in ChildPart(N12) updates and returns `nothing`. The\n * ChildPart will _clear() itself, and so we need to disconnect the \"value\" of\n * the ChildPart (but not its directive). In this case, when `_clear()` calls\n * `_$notifyConnectionChanged()`, we don't iterate all of the\n * _$disconnectableChildren, rather we do a value-specific disconnection: i.e.\n * since the _value was an Array<ChildPart> (because an iterable had been\n * committed), we iterate the array of ChildParts (N14, N16) and run\n * `setConnected` on them (which does recurse down the full tree of\n * `_$disconnectableChildren` below it, and also removes N14 and N16 from N12's\n * `_$disconnectableChildren`). Once the values have been disconnected, we then\n * check whether the ChildPart(N12)'s list of `_$disconnectableChildren` is empty\n * (and would remove it from its parent TemplateInstance(T3) if so), but since\n * it would still contain its directive D13, it stays in the disconnectable\n * tree.\n *\n * Example 2: In the course of Example 1, `setConnected` will reach\n * ChildPart(N16); in this case the entire part is being disconnected, so we\n * simply iterate all of N16's `_$disconnectableChildren` (D17,T18) and\n * recursively run `setConnected` on them. Note that we only remove children\n * from `_$disconnectableChildren` for the top-level values being disconnected\n * on a clear; doing this bookkeeping lower in the tree is wasteful since it's\n * all being thrown away.\n *\n * Example 3: If the LitElement containing the entire tree above becomes\n * disconnected, it will run `childPart.setConnected()` (which calls\n * `childPart._$notifyConnectionChanged()` if it exists); in this case, we\n * recursively run `setConnected()` over the entire tree, without removing any\n * children from `_$disconnectableChildren`, since this tree is required to\n * re-connect the tree, which does the same operation, simply passing\n * `isConnected: true` down the tree, signaling which callback to run.\n */\n\nimport {AttributePart, ChildPart, Disconnectable, Part} from './lit-html.js';\nimport {isSingleExpression} from './directive-helpers.js';\nimport {Directive, PartInfo, PartType} from './directive.js';\nexport * from './directive.js';\n\nconst DEV_MODE = true;\n\n/**\n * Recursively walks down the tree of Parts/TemplateInstances/Directives to set\n * the connected state of directives and run `disconnected`/ `reconnected`\n * callbacks.\n *\n * @return True if there were children to disconnect; false otherwise\n */\nconst notifyChildrenConnectedChanged = (\n parent: Disconnectable,\n isConnected: boolean\n): boolean => {\n const children = parent._$disconnectableChildren;\n if (children === undefined) {\n return false;\n }\n for (const obj of children) {\n // The existence of `_$notifyDirectiveConnectionChanged` is used as a \"brand\" to\n // disambiguate AsyncDirectives from other DisconnectableChildren\n // (as opposed to using an instanceof check to know when to call it); the\n // redundancy of \"Directive\" in the API name is to avoid conflicting with\n // `_$notifyConnectionChanged`, which exists `ChildParts` which are also in\n // this list\n // Disconnect Directive (and any nested directives contained within)\n // This property needs to remain unminified.\n (obj as AsyncDirective)['_$notifyDirectiveConnectionChanged']?.(\n isConnected,\n false\n );\n // Disconnect Part/TemplateInstance\n notifyChildrenConnectedChanged(obj, isConnected);\n }\n return true;\n};\n\n/**\n * Removes the given child from its parent list of disconnectable children, and\n * if the parent list becomes empty as a result, removes the parent from its\n * parent, and so forth up the tree when that causes subsequent parent lists to\n * become empty.\n */\nconst removeDisconnectableFromParent = (obj: Disconnectable) => {\n let parent, children;\n do {\n if ((parent = obj._$parent) === undefined) {\n break;\n }\n children = parent._$disconnectableChildren!;\n children.delete(obj);\n obj = parent;\n } while (children?.size === 0);\n};\n\nconst addDisconnectableToParent = (obj: Disconnectable) => {\n // Climb the parent tree, creating a sparse tree of children needing\n // disconnection\n for (let parent; (parent = obj._$parent); obj = parent) {\n let children = parent._$disconnectableChildren;\n if (children === undefined) {\n parent._$disconnectableChildren = children = new Set();\n } else if (children.has(obj)) {\n // Once we've reached a parent that already contains this child, we\n // can short-circuit\n break;\n }\n children.add(obj);\n installDisconnectAPI(parent);\n }\n};\n\n/**\n * Changes the parent reference of the ChildPart, and updates the sparse tree of\n * Disconnectable children accordingly.\n *\n * Note, this method will be patched onto ChildPart instances and called from\n * the core code when parts are moved between different parents.\n */\nfunction reparentDisconnectables(this: ChildPart, newParent: Disconnectable) {\n if (this._$disconnectableChildren !== undefined) {\n removeDisconnectableFromParent(this);\n this._$parent = newParent;\n addDisconnectableToParent(this);\n } else {\n this._$parent = newParent;\n }\n}\n\n/**\n * Sets the connected state on any directives contained within the committed\n * value of this part (i.e. within a TemplateInstance or iterable of\n * ChildParts) and runs their `disconnected`/`reconnected`s, as well as within\n * any directives stored on the ChildPart (when `valueOnly` is false).\n *\n * `isClearingValue` should be passed as `true` on a top-level part that is\n * clearing itself, and not as a result of recursively disconnecting directives\n * as part of a `clear` operation higher up the tree. This both ensures that any\n * directive on this ChildPart that produced a value that caused the clear\n * operation is not disconnected, and also serves as a performance optimization\n * to avoid needless bookkeeping when a subtree is going away; when clearing a\n * subtree, only the top-most part need to remove itself from the parent.\n *\n * `fromPartIndex` is passed only in the case of a partial `_clear` running as a\n * result of truncating an iterable.\n *\n * Note, this method will be patched onto ChildPart instances and called from the\n * core code when parts are cleared or the connection state is changed by the\n * user.\n */\nfunction notifyChildPartConnectedChanged(\n this: ChildPart,\n isConnected: boolean,\n isClearingValue = false,\n fromPartIndex = 0\n) {\n const value = this._$committedValue;\n const children = this._$disconnectableChildren;\n if (children === undefined || children.size === 0) {\n return;\n }\n if (isClearingValue) {\n if (Array.isArray(value)) {\n // Iterable case: Any ChildParts created by the iterable should be\n // disconnected and removed from this ChildPart's disconnectable\n // children (starting at `fromPartIndex` in the case of truncation)\n for (let i = fromPartIndex; i < value.length; i++) {\n notifyChildrenConnectedChanged(value[i], false);\n removeDisconnectableFromParent(value[i]);\n }\n } else if (value != null) {\n // TemplateInstance case: If the value has disconnectable children (will\n // only be in the case that it is a TemplateInstance), we disconnect it\n // and remove it from this ChildPart's disconnectable children\n notifyChildrenConnectedChanged(value as Disconnectable, false);\n removeDisconnectableFromParent(value as Disconnectable);\n }\n } else {\n notifyChildrenConnectedChanged(this, isConnected);\n }\n}\n\n/**\n * Patches disconnection API onto ChildParts.\n */\nconst installDisconnectAPI = (obj: Disconnectable) => {\n if ((obj as ChildPart).type == PartType.CHILD) {\n (obj as ChildPart)._$notifyConnectionChanged ??=\n notifyChildPartConnectedChanged;\n (obj as ChildPart)._$reparentDisconnectables ??= reparentDisconnectables;\n }\n};\n\n/**\n * An abstract `Directive` base class whose `disconnected` method will be\n * called when the part containing the directive is cleared as a result of\n * re-rendering, or when the user calls `part.setConnected(false)` on\n * a part that was previously rendered containing the directive (as happens\n * when e.g. a LitElement disconnects from the DOM).\n *\n * If `part.setConnected(true)` is subsequently called on a\n * containing part, the directive's `reconnected` method will be called prior\n * to its next `update`/`render` callbacks. When implementing `disconnected`,\n * `reconnected` should also be implemented to be compatible with reconnection.\n *\n * Note that updates may occur while the directive is disconnected. As such,\n * directives should generally check the `this.isConnected` flag during\n * render/update to determine whether it is safe to subscribe to resources\n * that may prevent garbage collection.\n */\nexport abstract class AsyncDirective extends Directive {\n // As opposed to other Disconnectables, AsyncDirectives always get notified\n // when the RootPart connection changes, so the public `isConnected`\n // is a locally stored variable initialized via its part's getter and synced\n // via `_$notifyDirectiveConnectionChanged`. This is cheaper than using\n // the _$isConnected getter, which has to look back up the tree each time.\n /**\n * The connection state for this Directive.\n */\n isConnected!: boolean;\n\n // @internal\n override _$disconnectableChildren?: Set<Disconnectable> = undefined;\n /**\n * Initialize the part with internal fields\n * @param part\n * @param parent\n * @param attributeIndex\n */\n override _$initialize(\n part: Part,\n parent: Disconnectable,\n attributeIndex: number | undefined\n ) {\n super._$initialize(part, parent, attributeIndex);\n addDisconnectableToParent(this);\n this.isConnected = part._$isConnected;\n }\n // This property needs to remain unminified.\n /**\n * Called from the core code when a directive is going away from a part (in\n * which case `shouldRemoveFromParent` should be true), and from the\n * `setChildrenConnected` helper function when recursively changing the\n * connection state of a tree (in which case `shouldRemoveFromParent` should\n * be false).\n *\n * @param isConnected\n * @param isClearingDirective - True when the directive itself is being\n * removed; false when the tree is being disconnected\n * @internal\n */\n override ['_$notifyDirectiveConnectionChanged'](\n isConnected: boolean,\n isClearingDirective = true\n ) {\n if (isConnected !== this.isConnected) {\n this.isConnected = isConnected;\n if (isConnected) {\n this.reconnected?.();\n } else {\n this.disconnected?.();\n }\n }\n if (isClearingDirective) {\n notifyChildrenConnectedChanged(this, isConnected);\n removeDisconnectableFromParent(this);\n }\n }\n\n /**\n * Sets the value of the directive's Part outside the normal `update`/`render`\n * lifecycle of a directive.\n *\n * This method should not be called synchronously from a directive's `update`\n * or `render`.\n *\n * @param directive The directive to update\n * @param value The value to set\n */\n setValue(value: unknown) {\n if (isSingleExpression(this.__part as unknown as PartInfo)) {\n this.__part._$setValue(value, this);\n } else {\n // this.__attributeIndex will be defined in this case, but\n // assert it in dev mode\n if (DEV_MODE && this.__attributeIndex === undefined) {\n throw new Error(`Expected this.__attributeIndex to be a number`);\n }\n const newValues = [...(this.__part._$committedValue as Array<unknown>)];\n newValues[this.__attributeIndex!] = value;\n (this.__part as AttributePart)._$setValue(newValues, this, 0);\n }\n }\n\n /**\n * User callbacks for implementing logic to release any resources/subscriptions\n * that may have been retained by this directive. Since directives may also be\n * re-connected, `reconnected` should also be implemented to restore the\n * working state of the directive prior to the next render.\n */\n protected disconnected() {}\n protected reconnected() {}\n}\n", "/**\n * @license\n * Copyright 2023 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {DirectiveResult, Part, directive} from 'lit/directive.js';\nimport {AsyncDirective} from 'lit/async-directive.js';\nimport {Signal} from 'signal-polyfill';\nimport {SignalWatcher} from './signal-watcher.js';\n\nexport class WatchDirective<T> extends AsyncDirective {\n private __host?: SignalWatcher;\n\n private __signal?: Signal.State<T> | Signal.Computed<T>;\n\n private __watcher?: Signal.subtle.Watcher;\n\n // We have to wrap the signal in a computed to work around a bug in the\n // signal-polyfill: https://github.com/proposal-signals/signal-polyfill/issues/27\n private __computed?: Signal.Computed<T | undefined>;\n\n private __watch() {\n if (this.__watcher !== undefined) {\n return;\n }\n this.__computed = new Signal.Computed(() => {\n return this.__signal?.get();\n });\n const watcher = (this.__watcher = new Signal.subtle.Watcher(() => {\n // TODO: If we're not running inside a SignalWatcher, we can commit to\n // the DOM independently.\n this.__host?._updateWatchDirective(this as WatchDirective<unknown>);\n watcher.watch();\n }));\n watcher.watch(this.__computed);\n }\n\n private __unwatch() {\n if (this.__watcher !== undefined) {\n this.__watcher.unwatch(this.__computed!);\n this.__computed = undefined;\n this.__watcher = undefined;\n this.__host?._clearWatchDirective(this as WatchDirective<unknown>);\n }\n }\n\n commit() {\n this.setValue(Signal.subtle.untrack(() => this.__computed?.get()));\n }\n\n render(signal: Signal.State<T> | Signal.Computed<T>): T {\n // This would only be called if render is called directly, like in SSR.\n return Signal.subtle.untrack(() => signal.get());\n }\n\n override update(\n part: Part,\n [signal]: [signal: Signal.State<T> | Signal.Computed<T>]\n ) {\n this.__host ??= part.options?.host as SignalWatcher;\n if (signal !== this.__signal && this.__signal !== undefined) {\n // Unwatch the old signal\n this.__unwatch();\n }\n this.__signal = signal;\n this.__watch();\n\n // We use untrack() so that the signal access is not tracked by the watcher\n // created by SignalWatcher. This means that an can use both SignalWatcher\n // and watch() and a signal update won't trigger a full element update if\n // it's only passed to watch() and not otherwise accessed by the element.\n return Signal.subtle.untrack(() => this.__computed!.get());\n }\n\n protected override disconnected(): void {\n this.__unwatch();\n }\n\n protected override reconnected(): void {\n this.__watch();\n }\n}\n\nexport type WatchDirectiveFunction = <T>(\n signal: Signal.State<T> | Signal.Computed<T>\n) => DirectiveResult<typeof WatchDirective<T>>;\n\n/**\n * Renders a signal and subscribes to it, updating the part when the signal\n * changes.\n *\n * watch() can only be used in a reactive element that applies the\n * SignalWatcher mixin.\n */\nexport const watch = directive(WatchDirective) as WatchDirectiveFunction;\n", "/**\n * @license\n * Copyright 2023 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\nimport {\n html as coreHtml,\n svg as coreSvg,\n type TemplateResult,\n} from 'lit/html.js';\n\nimport {watch} from './watch.js';\nimport {Signal} from 'signal-polyfill';\n\n/**\n * Wraps a lit-html template tag function (`html` or `svg`) to add support for\n * automatically wrapping Signal instances in the `watch()` directive.\n */\nexport const withWatch =\n (coreTag: typeof coreHtml | typeof coreSvg) =>\n (strings: TemplateStringsArray, ...values: unknown[]): TemplateResult => {\n // TODO (justinfagnani): use an alternative to instanceof when\n // one is available. See https://github.com/preactjs/signals/issues/402\n return coreTag(\n strings,\n ...values.map((v) =>\n v instanceof Signal.State || v instanceof Signal.Computed ? watch(v) : v\n )\n );\n };\n\n/**\n * Interprets a template literal as an HTML template that can efficiently\n * render to and update a container.\n *\n * Includes signal watching support from `withWatch()`.\n */\nexport const html = withWatch(coreHtml);\n\n/**\n * Interprets a template literal as an SVG template that can efficiently\n * render to and update a container.\n *\n * Includes signal watching support from `withWatch()`.\n */\nexport const svg = withWatch(coreSvg);\n", "/**\n * @license\n * Copyright 2023 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {Signal} from 'signal-polyfill';\n\nexport * from 'signal-polyfill';\nexport * from './lib/signal-watcher.js';\nexport * from './lib/watch.js';\nexport * from './lib/html-tag.js';\n\nexport const State = Signal.State;\nexport const Computed = Signal.Computed;\n\nexport const signal = <T>(value: T, options?: Signal.Options<T>) =>\n new Signal.State(value, options);\nexport const computed = <T>(callback: () => T, options?: Signal.Options<T>) =>\n new Signal.Computed<T>(callback, options);\n", "import { signal } from \"@lit-labs/signals\";\nfunction getInitialTheme() {\n if (typeof window === \"undefined\") {\n return \"light\";\n }\n const storedTheme = window.localStorage?.getItem(\"ds-one:theme\");\n if (storedTheme === \"light\" || storedTheme === \"dark\") {\n return storedTheme;\n }\n // Check system preference\n const prefersDark = window.matchMedia(\"(prefers-color-scheme: dark)\").matches;\n return prefersDark ? \"dark\" : \"light\";\n}\nexport const currentTheme = signal(getInitialTheme());\nexport function setTheme(theme) {\n if (theme === currentTheme.get()) {\n return;\n }\n currentTheme.set(theme);\n if (typeof window !== \"undefined\") {\n try {\n window.localStorage?.setItem(\"ds-one:theme\", theme);\n }\n catch (error) {\n console.warn(\"ds-one: unable to persist theme preference\", error);\n }\n const root = window.document?.documentElement;\n if (root) {\n root.classList.remove(\"light-theme\", \"dark-theme\");\n root.classList.add(`${theme}-theme`);\n }\n window.dispatchEvent(new CustomEvent(\"theme-changed\", { detail: { theme } }));\n }\n}\n// Initialize theme on load\nif (typeof window !== \"undefined\") {\n const theme = currentTheme.get();\n const root = window.document?.documentElement;\n if (root) {\n root.classList.remove(\"light-theme\", \"dark-theme\");\n root.classList.add(`${theme}-theme`);\n }\n}\n", "/**\n * @license\n * Copyright 2019 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nconst NODE_MODE = false;\n\n// Allows minifiers to rename references to globalThis\nconst global = globalThis;\n\n/**\n * Whether the current browser supports `adoptedStyleSheets`.\n */\nexport const supportsAdoptingStyleSheets: boolean =\n global.ShadowRoot &&\n (global.ShadyCSS === undefined || global.ShadyCSS.nativeShadow) &&\n 'adoptedStyleSheets' in Document.prototype &&\n 'replace' in CSSStyleSheet.prototype;\n\n/**\n * A CSSResult or native CSSStyleSheet.\n *\n * In browsers that support constructible CSS style sheets, CSSStyleSheet\n * object can be used for styling along side CSSResult from the `css`\n * template tag.\n */\nexport type CSSResultOrNative = CSSResult | CSSStyleSheet;\n\nexport type CSSResultArray = Array<CSSResultOrNative | CSSResultArray>;\n\n/**\n * A single CSSResult, CSSStyleSheet, or an array or nested arrays of those.\n */\nexport type CSSResultGroup = CSSResultOrNative | CSSResultArray;\n\nconst constructionToken = Symbol();\n\nconst cssTagCache = new WeakMap<TemplateStringsArray, CSSStyleSheet>();\n\n/**\n * A container for a string of CSS text, that may be used to create a CSSStyleSheet.\n *\n * CSSResult is the return value of `css`-tagged template literals and\n * `unsafeCSS()`. In order to ensure that CSSResults are only created via the\n * `css` tag and `unsafeCSS()`, CSSResult cannot be constructed directly.\n */\nexport class CSSResult {\n // This property needs to remain unminified.\n ['_$cssResult$'] = true;\n readonly cssText: string;\n private _styleSheet?: CSSStyleSheet;\n private _strings: TemplateStringsArray | undefined;\n\n private constructor(\n cssText: string,\n strings: TemplateStringsArray | undefined,\n safeToken: symbol\n ) {\n if (safeToken !== constructionToken) {\n throw new Error(\n 'CSSResult is not constructable. Use `unsafeCSS` or `css` instead.'\n );\n }\n this.cssText = cssText;\n this._strings = strings;\n }\n\n // This is a getter so that it's lazy. In practice, this means stylesheets\n // are not created until the first element instance is made.\n get styleSheet(): CSSStyleSheet | undefined {\n // If `supportsAdoptingStyleSheets` is true then we assume CSSStyleSheet is\n // constructable.\n let styleSheet = this._styleSheet;\n const strings = this._strings;\n if (supportsAdoptingStyleSheets && styleSheet === undefined) {\n const cacheable = strings !== undefined && strings.length === 1;\n if (cacheable) {\n styleSheet = cssTagCache.get(strings);\n }\n if (styleSheet === undefined) {\n (this._styleSheet = styleSheet = new CSSStyleSheet()).replaceSync(\n this.cssText\n );\n if (cacheable) {\n cssTagCache.set(strings, styleSheet);\n }\n }\n }\n return styleSheet;\n }\n\n toString(): string {\n return this.cssText;\n }\n}\n\ntype ConstructableCSSResult = CSSResult & {\n new (\n cssText: string,\n strings: TemplateStringsArray | undefined,\n safeToken: symbol\n ): CSSResult;\n};\n\nconst textFromCSSResult = (value: CSSResultGroup | number) => {\n // This property needs to remain unminified.\n if ((value as CSSResult)['_$cssResult$'] === true) {\n return (value as CSSResult).cssText;\n } else if (typeof value === 'number') {\n return value;\n } else {\n throw new Error(\n `Value passed to 'css' function must be a 'css' function result: ` +\n `${value}. Use 'unsafeCSS' to pass non-literal values, but take care ` +\n `to ensure page security.`\n );\n }\n};\n\n/**\n * Wrap a value for interpolation in a {@linkcode css} tagged template literal.\n *\n * This is unsafe because untrusted CSS text can be used to phone home\n * or exfiltrate data to an attacker controlled site. Take care to only use\n * this with trusted input.\n */\nexport const unsafeCSS = (value: unknown) =>\n new (CSSResult as ConstructableCSSResult)(\n typeof value === 'string' ? value : String(value),\n undefined,\n constructionToken\n );\n\n/**\n * A template literal tag which can be used with LitElement's\n * {@linkcode LitElement.styles} property to set element styles.\n *\n * For security reasons, only literal string values and number may be used in\n * embedded expressions. To incorporate non-literal values {@linkcode unsafeCSS}\n * may be used inside an expression.\n */\nexport const css = (\n strings: TemplateStringsArray,\n ...values: (CSSResultGroup | number)[]\n): CSSResult => {\n const cssText =\n strings.length === 1\n ? strings[0]\n : values.reduce(\n (acc, v, idx) => acc + textFromCSSResult(v) + strings[idx + 1],\n strings[0]\n );\n return new (CSSResult as ConstructableCSSResult)(\n cssText,\n strings,\n constructionToken\n );\n};\n\n/**\n * Applies the given styles to a `shadowRoot`. When Shadow DOM is\n * available but `adoptedStyleSheets` is not, styles are appended to the\n * `shadowRoot` to [mimic the native feature](https://developer.mozilla.org/en-US/docs/Web/API/ShadowRoot/adoptedStyleSheets).\n * Note, when shimming is used, any styles that are subsequently placed into\n * the shadowRoot should be placed *before* any shimmed adopted styles. This\n * will match spec behavior that gives adopted sheets precedence over styles in\n * shadowRoot.\n */\nexport const adoptStyles = (\n renderRoot: ShadowRoot,\n styles: Array<CSSResultOrNative>\n) => {\n if (supportsAdoptingStyleSheets) {\n (renderRoot as ShadowRoot).adoptedStyleSheets = styles.map((s) =>\n s instanceof CSSStyleSheet ? s : s.styleSheet!\n );\n } else {\n for (const s of styles) {\n const style = document.createElement('style');\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const nonce = (global as any)['litNonce'];\n if (nonce !== undefined) {\n style.setAttribute('nonce', nonce);\n }\n style.textContent = (s as CSSResult).cssText;\n renderRoot.appendChild(style);\n }\n }\n};\n\nconst cssResultFromStyleSheet = (sheet: CSSStyleSheet) => {\n let cssText = '';\n for (const rule of sheet.cssRules) {\n cssText += rule.cssText;\n }\n return unsafeCSS(cssText);\n};\n\nexport const getCompatibleStyle =\n supportsAdoptingStyleSheets ||\n (NODE_MODE && global.CSSStyleSheet === undefined)\n ? (s: CSSResultOrNative) => s\n : (s: CSSResultOrNative) =>\n s instanceof CSSStyleSheet ? cssResultFromStyleSheet(s) : s;\n", "/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/**\n * Use this module if you want to create your own base class extending\n * {@link ReactiveElement}.\n * @packageDocumentation\n */\n\nimport {\n getCompatibleStyle,\n adoptStyles,\n CSSResultGroup,\n CSSResultOrNative,\n} from './css-tag.js';\nimport type {\n ReactiveController,\n ReactiveControllerHost,\n} from './reactive-controller.js';\n\n// In the Node build, this import will be injected by Rollup:\n// import {HTMLElement, customElements} from '@lit-labs/ssr-dom-shim';\n\nexport * from './css-tag.js';\nexport type {\n ReactiveController,\n ReactiveControllerHost,\n} from './reactive-controller.js';\n\n/**\n * Removes the `readonly` modifier from properties in the union K.\n *\n * This is a safer way to cast a value to a type with a mutable version of a\n * readonly field, than casting to an interface with the field re-declared\n * because it preserves the type of all the fields and warns on typos.\n */\ntype Mutable<T, K extends keyof T> = Omit<T, K> & {\n -readonly [P in keyof Pick<T, K>]: P extends K ? T[P] : never;\n};\n\n// TODO (justinfagnani): Add `hasOwn` here when we ship ES2022\nconst {\n is,\n defineProperty,\n getOwnPropertyDescriptor,\n getOwnPropertyNames,\n getOwnPropertySymbols,\n getPrototypeOf,\n} = Object;\n\nconst NODE_MODE = false;\n\n// Lets a minifier replace globalThis references with a minified name\nconst global = globalThis;\n\nif (NODE_MODE) {\n global.customElements ??= customElements;\n}\n\nconst DEV_MODE = true;\n\nlet issueWarning: (code: string, warning: string) => void;\n\nconst trustedTypes = (global as unknown as {trustedTypes?: {emptyScript: ''}})\n .trustedTypes;\n\n// Temporary workaround for https://crbug.com/993268\n// Currently, any attribute starting with \"on\" is considered to be a\n// TrustedScript source. Such boolean attributes must be set to the equivalent\n// trusted emptyScript value.\nconst emptyStringForBooleanAttribute = trustedTypes\n ? (trustedTypes.emptyScript as unknown as '')\n : '';\n\nconst polyfillSupport = DEV_MODE\n ? global.reactiveElementPolyfillSupportDevMode\n : global.reactiveElementPolyfillSupport;\n\nif (DEV_MODE) {\n // Ensure warnings are issued only 1x, even if multiple versions of Lit\n // are loaded.\n global.litIssuedWarnings ??= new Set();\n\n /**\n * Issue a warning if we haven't already, based either on `code` or `warning`.\n * Warnings are disabled automatically only by `warning`; disabling via `code`\n * can be done by users.\n */\n issueWarning = (code: string, warning: string) => {\n warning += ` See https://lit.dev/msg/${code} for more information.`;\n if (\n !global.litIssuedWarnings!.has(warning) &&\n !global.litIssuedWarnings!.has(code)\n ) {\n console.warn(warning);\n global.litIssuedWarnings!.add(warning);\n }\n };\n\n queueMicrotask(() => {\n issueWarning(\n 'dev-mode',\n `Lit is in dev mode. Not recommended for production!`\n );\n\n // Issue polyfill support warning.\n if (global.ShadyDOM?.inUse && polyfillSupport === undefined) {\n issueWarning(\n 'polyfill-support-missing',\n `Shadow DOM is being polyfilled via \\`ShadyDOM\\` but ` +\n `the \\`polyfill-support\\` module has not been loaded.`\n );\n }\n });\n}\n\n/**\n * Contains types that are part of the unstable debug API.\n *\n * Everything in this API is not stable and may change or be removed in the future,\n * even on patch releases.\n */\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport namespace ReactiveUnstable {\n /**\n * When Lit is running in dev mode and `window.emitLitDebugLogEvents` is true,\n * we will emit 'lit-debug' events to window, with live details about the update and render\n * lifecycle. These can be useful for writing debug tooling and visualizations.\n *\n * Please be aware that running with window.emitLitDebugLogEvents has performance overhead,\n * making certain operations that are normally very cheap (like a no-op render) much slower,\n * because we must copy data and dispatch events.\n */\n // eslint-disable-next-line @typescript-eslint/no-namespace\n export namespace DebugLog {\n export type Entry = Update;\n export interface Update {\n kind: 'update';\n }\n }\n}\n\ninterface DebugLoggingWindow {\n // Even in dev mode, we generally don't want to emit these events, as that's\n // another level of cost, so only emit them when DEV_MODE is true _and_ when\n // window.emitLitDebugEvents is true.\n emitLitDebugLogEvents?: boolean;\n}\n\n/**\n * Useful for visualizing and logging insights into what the Lit template system is doing.\n *\n * Compiled out of prod mode builds.\n */\nconst debugLogEvent = DEV_MODE\n ? (event: ReactiveUnstable.DebugLog.Entry) => {\n const shouldEmit = (global as unknown as DebugLoggingWindow)\n .emitLitDebugLogEvents;\n if (!shouldEmit) {\n return;\n }\n global.dispatchEvent(\n new CustomEvent<ReactiveUnstable.DebugLog.Entry>('lit-debug', {\n detail: event,\n })\n );\n }\n : undefined;\n\n/*\n * When using Closure Compiler, JSCompiler_renameProperty(property, object) is\n * replaced at compile time by the munged name for object[property]. We cannot\n * alias this function, so we have to use a small shim that has the same\n * behavior when not compiling.\n */\n/*@__INLINE__*/\nconst JSCompiler_renameProperty = <P extends PropertyKey>(\n prop: P,\n _obj: unknown\n): P => prop;\n\n/**\n * Converts property values to and from attribute values.\n */\nexport interface ComplexAttributeConverter<Type = unknown, TypeHint = unknown> {\n /**\n * Called to convert an attribute value to a property\n * value.\n */\n fromAttribute?(value: string | null, type?: TypeHint): Type;\n\n /**\n * Called to convert a property value to an attribute\n * value.\n *\n * It returns unknown instead of string, to be compatible with\n * https://github.com/WICG/trusted-types (and similar efforts).\n */\n toAttribute?(value: Type, type?: TypeHint): unknown;\n}\n\ntype AttributeConverter<Type = unknown, TypeHint = unknown> =\n | ComplexAttributeConverter<Type>\n | ((value: string | null, type?: TypeHint) => Type);\n\n/**\n * Defines options for a property accessor.\n */\nexport interface PropertyDeclaration<Type = unknown, TypeHint = unknown> {\n /**\n * When set to `true`, indicates the property is internal private state. The\n * property should not be set by users. When using TypeScript, this property\n * should be marked as `private` or `protected`, and it is also a common\n * practice to use a leading `_` in the name. The property is not added to\n * `observedAttributes`.\n */\n readonly state?: boolean;\n\n /**\n * Indicates how and whether the property becomes an observed attribute.\n * If the value is `false`, the property is not added to `observedAttributes`.\n * If true or absent, the lowercased property name is observed (e.g. `fooBar`\n * becomes `foobar`). If a string, the string value is observed (e.g\n * `attribute: 'foo-bar'`).\n */\n readonly attribute?: boolean | string;\n\n /**\n * Indicates the type of the property. This is used only as a hint for the\n * `converter` to determine how to convert the attribute\n * to/from a property.\n */\n readonly type?: TypeHint;\n\n /**\n * Indicates how to convert the attribute to/from a property. If this value\n * is a function, it is used to convert the attribute value a the property\n * value. If it's an object, it can have keys for `fromAttribute` and\n * `toAttribute`. If no `toAttribute` function is provided and\n * `reflect` is set to `true`, the property value is set directly to the\n * attribute. A default `converter` is used if none is provided; it supports\n * `Boolean`, `String`, `Number`, `Object`, and `Array`. Note,\n * when a property changes and the converter is used to update the attribute,\n * the property is never updated again as a result of the attribute changing,\n * and vice versa.\n */\n readonly converter?: AttributeConverter<Type, TypeHint>;\n\n /**\n * Indicates if the property should reflect to an attribute.\n * If `true`, when the property is set, the attribute is set using the\n * attribute name determined according to the rules for the `attribute`\n * property option and the value of the property converted using the rules\n * from the `converter` property option.\n */\n readonly reflect?: boolean;\n\n /**\n * A function that indicates if a property should be considered changed when\n * it is set. The function should take the `newValue` and `oldValue` and\n * return `true` if an update should be requested.\n */\n hasChanged?(value: Type, oldValue: Type): boolean;\n\n /**\n * Indicates whether an accessor will be created for this property. By\n * default, an accessor will be generated for this property that requests an\n * update when set. If this flag is `true`, no accessor will be created, and\n * it will be the user's responsibility to call\n * `this.requestUpdate(propertyName, oldValue)` to request an update when\n * the property changes.\n */\n readonly noAccessor?: boolean;\n\n /**\n * Whether this property is wrapping accessors. This is set by `@property`\n * to control the initial value change and reflection logic.\n *\n * @internal\n */\n wrapped?: boolean;\n\n /**\n * When `true`, uses the initial value of the property as the default value,\n * which changes how attributes are handled:\n * - The initial value does *not* reflect, even if the `reflect` option is `true`.\n * Subsequent changes to the property will reflect, even if they are equal to the\n * default value.\n * - When the attribute is removed, the property is set to the default value\n * - The initial value will not trigger an old value in the `changedProperties` map\n * argument to update lifecycle methods.\n *\n * When set, properties must be initialized, either with a field initializer, or an\n * assignment in the constructor. Not initializing the property may lead to\n * improper handling of subsequent property assignments.\n *\n * While this behavior is opt-in, most properties that reflect to attributes should\n * use `useDefault: true` so that their initial values do not reflect.\n */\n useDefault?: boolean;\n}\n\n/**\n * Map of properties to PropertyDeclaration options. For each property an\n * accessor is made, and the property is processed according to the\n * PropertyDeclaration options.\n */\nexport interface PropertyDeclarations {\n readonly [key: string]: PropertyDeclaration;\n}\n\ntype PropertyDeclarationMap = Map<PropertyKey, PropertyDeclaration>;\n\ntype AttributeMap = Map<string, PropertyKey>;\n\n/**\n * A Map of property keys to values.\n *\n * Takes an optional type parameter T, which when specified as a non-any,\n * non-unknown type, will make the Map more strongly-typed, associating the map\n * keys with their corresponding value type on T.\n *\n * Use `PropertyValues<this>` when overriding ReactiveElement.update() and\n * other lifecycle methods in order to get stronger type-checking on keys\n * and values.\n */\n// This type is conditional so that if the parameter T is not specified, or\n// is `any`, the type will include `Map<PropertyKey, unknown>`. Since T is not\n// given in the uses of PropertyValues in this file, all uses here fallback to\n// meaning `Map<PropertyKey, unknown>`, but if a developer uses\n// `PropertyValues<this>` (or any other value for T) they will get a\n// strongly-typed Map type.\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type PropertyValues<T = any> = T extends object\n ? PropertyValueMap<T>\n : Map<PropertyKey, unknown>;\n\n/**\n * Do not use, instead prefer {@linkcode PropertyValues}.\n */\n// This type must be exported such that JavaScript generated by the Google\n// Closure Compiler can import a type reference.\nexport interface PropertyValueMap<T> extends Map<PropertyKey, unknown> {\n get<K extends keyof T>(k: K): T[K] | undefined;\n set<K extends keyof T>(key: K, value: T[K]): this;\n has<K extends keyof T>(k: K): boolean;\n delete<K extends keyof T>(k: K): boolean;\n}\n\nexport const defaultConverter: ComplexAttributeConverter = {\n toAttribute(value: unknown, type?: unknown): unknown {\n switch (type) {\n case Boolean:\n value = value ? emptyStringForBooleanAttribute : null;\n break;\n case Object:\n case Array:\n // if the value is `null` or `undefined` pass this through\n // to allow removing/no change behavior.\n value = value == null ? value : JSON.stringify(value);\n break;\n }\n return value;\n },\n\n fromAttribute(value: string | null, type?: unknown) {\n let fromValue: unknown = value;\n switch (type) {\n case Boolean:\n fromValue = value !== null;\n break;\n case Number:\n fromValue = value === null ? null : Number(value);\n break;\n case Object:\n case Array:\n // Do *not* generate exception when invalid JSON is set as elements\n // don't normally complain on being mis-configured.\n // TODO(sorvell): Do generate exception in *dev mode*.\n try {\n // Assert to adhere to Bazel's \"must type assert JSON parse\" rule.\n fromValue = JSON.parse(value!) as unknown;\n } catch (e) {\n fromValue = null;\n }\n break;\n }\n return fromValue;\n },\n};\n\nexport interface HasChanged {\n (value: unknown, old: unknown): boolean;\n}\n\n/**\n * Change function that returns true if `value` is different from `oldValue`.\n * This method is used as the default for a property's `hasChanged` function.\n */\nexport const notEqual: HasChanged = (value: unknown, old: unknown): boolean =>\n !is(value, old);\n\nconst defaultPropertyDeclaration: PropertyDeclaration = {\n attribute: true,\n type: String,\n converter: defaultConverter,\n reflect: false,\n useDefault: false,\n hasChanged: notEqual,\n};\n\n/**\n * A string representing one of the supported dev mode warning categories.\n */\nexport type WarningKind =\n | 'change-in-update'\n | 'migration'\n | 'async-perform-update';\n\nexport type Initializer = (element: ReactiveElement) => void;\n\n// Temporary, until google3 is on TypeScript 5.2\ndeclare global {\n interface SymbolConstructor {\n readonly metadata: unique symbol;\n }\n}\n\n// Ensure metadata is enabled. TypeScript does not polyfill\n// Symbol.metadata, so we must ensure that it exists.\n(Symbol as {metadata: symbol}).metadata ??= Symbol('metadata');\n\ndeclare global {\n // This is public global API, do not change!\n // eslint-disable-next-line no-var\n var litPropertyMetadata: WeakMap<\n object,\n Map<PropertyKey, PropertyDeclaration>\n >;\n}\n\n// Map from a class's metadata object to property options\n// Note that we must use nullish-coalescing assignment so that we only use one\n// map even if we load multiple version of this module.\nglobal.litPropertyMetadata ??= new WeakMap<\n object,\n Map<PropertyKey, PropertyDeclaration>\n>();\n\n/**\n * Base element class which manages element properties and attributes. When\n * properties change, the `update` method is asynchronously called. This method\n * should be supplied by subclasses to render updates as desired.\n * @noInheritDoc\n */\nexport abstract class ReactiveElement\n // In the Node build, this `extends` clause will be substituted with\n // `(globalThis.HTMLElement ?? HTMLElement)`.\n //\n // This way, we will first prefer any global `HTMLElement` polyfill that the\n // user has assigned, and then fall back to the `HTMLElement` shim which has\n // been imported (see note at the top of this file about how this import is\n // generated by Rollup). Note that the `HTMLElement` variable has been\n // shadowed by this import, so it no longer refers to the global.\n extends HTMLElement\n implements ReactiveControllerHost\n{\n // Note: these are patched in only in DEV_MODE.\n /**\n * Read or set all the enabled warning categories for this class.\n *\n * This property is only used in development builds.\n *\n * @nocollapse\n * @category dev-mode\n */\n static enabledWarnings?: WarningKind[];\n\n /**\n * Enable the given warning category for this class.\n *\n * This method only exists in development builds, so it should be accessed\n * with a guard like:\n *\n * ```ts\n * // Enable for all ReactiveElement subclasses\n * ReactiveElement.enableWarning?.('migration');\n *\n * // Enable for only MyElement and subclasses\n * MyElement.enableWarning?.('migration');\n * ```\n *\n * @nocollapse\n * @category dev-mode\n */\n static enableWarning?: (warningKind: WarningKind) => void;\n\n /**\n * Disable the given warning category for this class.\n *\n * This method only exists in development builds, so it should be accessed\n * with a guard like:\n *\n * ```ts\n * // Disable for all ReactiveElement subclasses\n * ReactiveElement.disableWarning?.('migration');\n *\n * // Disable for only MyElement and subclasses\n * MyElement.disableWarning?.('migration');\n * ```\n *\n * @nocollapse\n * @category dev-mode\n */\n static disableWarning?: (warningKind: WarningKind) => void;\n\n /**\n * Adds an initializer function to the class that is called during instance\n * construction.\n *\n * This is useful for code that runs against a `ReactiveElement`\n * subclass, such as a decorator, that needs to do work for each\n * instance, such as setting up a `ReactiveController`.\n *\n * ```ts\n * const myDecorator = (target: typeof ReactiveElement, key: string) => {\n * target.addInitializer((instance: ReactiveElement) => {\n * // This is run during construction of the element\n * new MyController(instance);\n * });\n * }\n * ```\n *\n * Decorating a field will then cause each instance to run an initializer\n * that adds a controller:\n *\n * ```ts\n * class MyElement extends LitElement {\n * @myDecorator foo;\n * }\n * ```\n *\n * Initializers are stored per-constructor. Adding an initializer to a\n * subclass does not add it to a superclass. Since initializers are run in\n * constructors, initializers will run in order of the class hierarchy,\n * starting with superclasses and progressing to the instance's class.\n *\n * @nocollapse\n */\n static addInitializer(initializer: Initializer) {\n this.__prepare();\n (this._initializers ??= []).push(initializer);\n }\n\n static _initializers?: Initializer[];\n\n /*\n * Due to closure compiler ES6 compilation bugs, @nocollapse is required on\n * all static methods and properties with initializers. Reference:\n * - https://github.com/google/closure-compiler/issues/1776\n */\n\n /**\n * Maps attribute names to properties; for example `foobar` attribute to\n * `fooBar` property. Created lazily on user subclasses when finalizing the\n * class.\n * @nocollapse\n */\n private static __attributeToPropertyMap: AttributeMap;\n\n /**\n * Marks class as having been finalized, which includes creating properties\n * from `static properties`, but does *not* include all properties created\n * from decorators.\n * @nocollapse\n */\n protected static finalized: true | undefined;\n\n /**\n * Memoized list of all element properties, including any superclass\n * properties. Created lazily on user subclasses when finalizing the class.\n *\n * @nocollapse\n * @category properties\n */\n static elementProperties: PropertyDeclarationMap;\n\n /**\n * User-supplied object that maps property names to `PropertyDeclaration`\n * objects containing options for configuring reactive properties. When\n * a reactive property is set the element will update and render.\n *\n * By default properties are public fields, and as such, they should be\n * considered as primarily settable by element users, either via attribute or\n * the property itself.\n *\n * Generally, properties that are changed by the element should be private or\n * protected fields and should use the `state: true` option. Properties\n * marked as `state` do not reflect from the corresponding attribute\n *\n * However, sometimes element code does need to set a public property. This\n * should typically only be done in response to user interaction, and an event\n * should be fired informing the user; for example, a checkbox sets its\n * `checked` property when clicked and fires a `changed` event. Mutating\n * public properties should typically not be done for non-primitive (object or\n * array) properties. In other cases when an element needs to manage state, a\n * private property set with the `state: true` option should be used. When\n * needed, state properties can be initialized via public properties to\n * facilitate complex interactions.\n * @nocollapse\n * @category properties\n */\n static properties: PropertyDeclarations;\n\n /**\n * Memoized list of all element styles.\n * Created lazily on user subclasses when finalizing the class.\n * @nocollapse\n * @category styles\n */\n static elementStyles: Array<CSSResultOrNative> = [];\n\n /**\n * Array of styles to apply to the element. The styles should be defined\n * using the {@linkcode css} tag function, via constructible stylesheets, or\n * imported from native CSS module scripts.\n *\n * Note on Content Security Policy:\n *\n * Element styles are implemented with `<style>` tags when the browser doesn't\n * support adopted StyleSheets. To use such `<style>` tags with the style-src\n * CSP directive, the style-src value must either include 'unsafe-inline' or\n * `nonce-<base64-value>` with `<base64-value>` replaced be a server-generated\n * nonce.\n *\n * To provide a nonce to use on generated `<style>` elements, set\n * `window.litNonce` to a server-generated nonce in your page's HTML, before\n * loading application code:\n *\n * ```html\n * <script>\n * // Generated and unique per request:\n * window.litNonce = 'a1b2c3d4';\n * </script>\n * ```\n * @nocollapse\n * @category styles\n */\n static styles?: CSSResultGroup;\n\n /**\n * Returns a list of attributes corresponding to the registered properties.\n * @nocollapse\n * @category attributes\n */\n static get observedAttributes() {\n // Ensure we've created all properties\n this.finalize();\n // this.__attributeToPropertyMap is only undefined after finalize() in\n // ReactiveElement itself. ReactiveElement.observedAttributes is only\n // accessed with ReactiveElement as the receiver when a subclass or mixin\n // calls super.observedAttributes\n return (\n this.__attributeToPropertyMap && [...this.__attributeToPropertyMap.keys()]\n );\n }\n\n private __instanceProperties?: PropertyValues = undefined;\n\n /**\n * Creates a property accessor on the element prototype if one does not exist\n * and stores a {@linkcode PropertyDeclaration} for the property with the\n * given options. The property setter calls the property's `hasChanged`\n * property option or uses a strict identity check to determine whether or not\n * to request an update.\n *\n * This method may be overridden to customize properties; however,\n * when doing so, it's important to call `super.createProperty` to ensure\n * the property is setup correctly. This method calls\n * `getPropertyDescriptor` internally to get a descriptor to install.\n * To customize what properties do when they are get or set, override\n * `getPropertyDescriptor`. To customize the options for a property,\n * implement `createProperty` like this:\n *\n * ```ts\n * static createProperty(name, options) {\n * options = Object.assign(options, {myOption: true});\n * super.createProperty(name, options);\n * }\n * ```\n *\n * @nocollapse\n * @category properties\n */\n static createProperty(\n name: PropertyKey,\n options: PropertyDeclaration = defaultPropertyDeclaration\n ) {\n // If this is a state property, force the attribute to false.\n if (options.state) {\n (options as Mutable<PropertyDeclaration, 'attribute'>).attribute = false;\n }\n this.__prepare();\n // Whether this property is wrapping accessors.\n // Helps control the initial value change and reflection logic.\n if (this.prototype.hasOwnProperty(name)) {\n options = Object.create(options);\n options.wrapped = true;\n }\n this.elementProperties.set(name, options);\n if (!options.noAccessor) {\n const key = DEV_MODE\n ? // Use Symbol.for in dev mode to make it easier to maintain state\n // when doing HMR.\n Symbol.for(`${String(name)} (@property() cache)`)\n : Symbol();\n const descriptor = this.getPropertyDescriptor(name, key, options);\n if (descriptor !== undefined) {\n defineProperty(this.prototype, name, descriptor);\n }\n }\n }\n\n /**\n * Returns a property descriptor to be defined on the given named property.\n * If no descriptor is returned, the property will not become an accessor.\n * For example,\n *\n * ```ts\n * class MyElement extends LitElement {\n * static getPropertyDescriptor(name, key, options) {\n * const defaultDescriptor =\n * super.getPropertyDescriptor(name, key, options);\n * const setter = defaultDescriptor.set;\n * return {\n * get: defaultDescriptor.get,\n * set(value) {\n * setter.call(this, value);\n * // custom action.\n * },\n * configurable: true,\n * enumerable: true\n * }\n * }\n * }\n * ```\n *\n * @nocollapse\n * @category properties\n */\n protected static getPropertyDescriptor(\n name: PropertyKey,\n key: string | symbol,\n options: PropertyDeclaration\n ): PropertyDescriptor | undefined {\n const {get, set} = getOwnPropertyDescriptor(this.prototype, name) ?? {\n get(this: ReactiveElement) {\n return this[key as keyof typeof this];\n },\n set(this: ReactiveElement, v: unknown) {\n (this as unknown as Record<string | symbol, unknown>)[key] = v;\n },\n };\n if (DEV_MODE && get == null) {\n if ('value' in (getOwnPropertyDescriptor(this.prototype, name) ?? {})) {\n throw new Error(\n `Field ${JSON.stringify(String(name))} on ` +\n `${this.name} was declared as a reactive property ` +\n `but it's actually declared as a value on the prototype. ` +\n `Usually this is due to using @property or @state on a method.`\n );\n }\n issueWarning(\n 'reactive-property-without-getter',\n `Field ${JSON.stringify(String(name))} on ` +\n `${this.name} was declared as a reactive property ` +\n `but it does not have a getter. This will be an error in a ` +\n `future version of Lit.`\n );\n }\n return {\n get,\n set(this: ReactiveElement, value: unknown) {\n const oldValue = get?.call(this);\n set?.call(this, value);\n this.requestUpdate(name, oldValue, options);\n },\n configurable: true,\n enumerable: true,\n };\n }\n\n /**\n * Returns the property options associated with the given property.\n * These options are defined with a `PropertyDeclaration` via the `properties`\n * object or the `@property` decorator and are registered in\n * `createProperty(...)`.\n *\n * Note, this method should be considered \"final\" and not overridden. To\n * customize the options for a given property, override\n * {@linkcode createProperty}.\n *\n * @nocollapse\n * @final\n * @category properties\n */\n static getPropertyOptions(name: PropertyKey) {\n return this.elementProperties.get(name) ?? defaultPropertyDeclaration;\n }\n\n // Temporary, until google3 is on TypeScript 5.2\n declare static [Symbol.metadata]: object & Record<PropertyKey, unknown>;\n\n /**\n * Initializes static own properties of the class used in bookkeeping\n * for element properties, initializers, etc.\n *\n * Can be called multiple times by code that needs to ensure these\n * properties exist before using them.\n *\n * This method ensures the superclass is finalized so that inherited\n * property metadata can be copied down.\n * @nocollapse\n */\n private static __prepare() {\n if (\n this.hasOwnProperty(JSCompiler_renameProperty('elementProperties', this))\n ) {\n // Already prepared\n return;\n }\n // Finalize any superclasses\n const superCtor = getPrototypeOf(this) as typeof ReactiveElement;\n superCtor.finalize();\n\n // Create own set of initializers for this class if any exist on the\n // superclass and copy them down. Note, for a small perf boost, avoid\n // creating initializers unless needed.\n if (superCtor._initializers !== undefined) {\n this._initializers = [...superCtor._initializers];\n }\n // Initialize elementProperties from the superclass\n this.elementProperties = new Map(superCtor.elementProperties);\n }\n\n /**\n * Finishes setting up the class so that it's ready to be registered\n * as a custom element and instantiated.\n *\n * This method is called by the ReactiveElement.observedAttributes getter.\n * If you override the observedAttributes getter, you must either call\n * super.observedAttributes to trigger finalization, or call finalize()\n * yourself.\n *\n * @nocollapse\n */\n protected static finalize() {\n if (this.hasOwnProperty(JSCompiler_renameProperty('finalized', this))) {\n return;\n }\n this.finalized = true;\n this.__prepare();\n\n // Create properties from the static properties block:\n if (this.hasOwnProperty(JSCompiler_renameProperty('properties', this))) {\n const props = this.properties;\n const propKeys = [\n ...getOwnPropertyNames(props),\n ...getOwnPropertySymbols(props),\n ] as Array<keyof typeof props>;\n for (const p of propKeys) {\n this.createProperty(p, props[p]);\n }\n }\n\n // Create properties from standard decorator metadata:\n const metadata = this[Symbol.metadata];\n if (metadata !== null) {\n const properties = litPropertyMetadata.get(metadata);\n if (properties !== undefined) {\n for (const [p, options] of properties) {\n this.elementProperties.set(p, options);\n }\n }\n }\n\n // Create the attribute-to-property map\n this.__attributeToPropertyMap = new Map();\n for (const [p, options] of this.elementProperties) {\n const attr = this.__attributeNameForProperty(p, options);\n if (attr !== undefined) {\n this.__attributeToPropertyMap.set(attr, p);\n }\n }\n\n this.elementStyles = this.finalizeStyles(this.styles);\n\n if (DEV_MODE) {\n if (this.hasOwnProperty('createProperty')) {\n issueWarning(\n 'no-override-create-property',\n 'Overriding ReactiveElement.createProperty() is deprecated. ' +\n 'The override will not be called with standard decorators'\n );\n }\n if (this.hasOwnProperty('getPropertyDescriptor')) {\n issueWarning(\n 'no-override-get-property-descriptor',\n 'Overriding ReactiveElement.getPropertyDescriptor() is deprecated. ' +\n 'The override will not be called with standard decorators'\n );\n }\n }\n }\n\n /**\n * Options used when calling `attachShadow`. Set this property to customize\n * the options for the shadowRoot; for example, to create a closed\n * shadowRoot: `{mode: 'closed'}`.\n *\n * Note, these options are used in `createRenderRoot`. If this method\n * is customized, options should be respected if possible.\n * @nocollapse\n * @category rendering\n */\n static shadowRootOptions: ShadowRootInit = {mode: 'open'};\n\n /**\n * Takes the styles the user supplied via the `static styles` property and\n * returns the array of styles to apply to the element.\n * Override this method to integrate into a style management system.\n *\n * Styles are deduplicated preserving the _last_ instance in the list. This\n * is a performance optimization to avoid duplicated styles that can occur\n * especially when composing via subclassing. The last item is kept to try\n * to preserve the cascade order with the assumption that it's most important\n * that last added styles override previous styles.\n *\n * @nocollapse\n * @category styles\n */\n protected static finalizeStyles(\n styles?: CSSResultGroup\n ): Array<CSSResultOrNative> {\n const elementStyles = [];\n if (Array.isArray(styles)) {\n // Dedupe the flattened array in reverse order to preserve the last items.\n // Casting to Array<unknown> works around TS error that\n // appears to come from trying to flatten a type CSSResultArray.\n const set = new Set((styles as Array<unknown>).flat(Infinity).reverse());\n // Then preserve original order by adding the set items in reverse order.\n for (const s of set) {\n elementStyles.unshift(getCompatibleStyle(s as CSSResultOrNative));\n }\n } else if (styles !== undefined) {\n elementStyles.push(getCompatibleStyle(styles));\n }\n return elementStyles;\n }\n\n /**\n * Node or ShadowRoot into which element DOM should be rendered. Defaults\n * to an open shadowRoot.\n * @category rendering\n */\n readonly renderRoot!: HTMLElement | DocumentFragment;\n\n /**\n * Returns the property name for the given attribute `name`.\n * @nocollapse\n */\n private static __attributeNameForProperty(\n name: PropertyKey,\n options: PropertyDeclaration\n ) {\n const attribute = options.attribute;\n return attribute === false\n ? undefined\n : typeof attribute === 'string'\n ? attribute\n : typeof name === 'string'\n ? name.toLowerCase()\n : undefined;\n }\n\n // Initialize to an unresolved Promise so we can make sure the element has\n // connected before first update.\n private __updatePromise!: Promise<boolean>;\n\n /**\n * True if there is a pending update as a result of calling `requestUpdate()`.\n * Should only be read.\n * @category updates\n */\n isUpdatePending = false;\n\n /**\n * Is set to `true` after the first update. The element code cannot assume\n * that `renderRoot` exists before the element `hasUpdated`.\n * @category updates\n */\n hasUpdated = false;\n\n /**\n * Map with keys for any properties that have changed since the last\n * update cycle with previous values.\n *\n * @internal\n */\n _$changedProperties!: PropertyValues;\n\n /**\n * Records property default values when the\n * `useDefault` option is used.\n */\n private __defaultValues?: Map<PropertyKey, unknown>;\n\n /**\n * Properties that should be reflected when updated.\n */\n private __reflectingProperties?: Set<PropertyKey>;\n\n /**\n * Name of currently reflecting property\n */\n private __reflectingProperty: PropertyKey | null = null;\n\n /**\n * Set of controllers.\n */\n private __controllers?: Set<ReactiveController>;\n\n constructor() {\n super();\n this.__initialize();\n }\n\n /**\n * Internal only override point for customizing work done when elements\n * are constructed.\n */\n private __initialize() {\n this.__updatePromise = new Promise<boolean>(\n (res) => (this.enableUpdating = res)\n );\n this._$changedProperties = new Map();\n // This enqueues a microtask that must run before the first update, so it\n // must be called before requestUpdate()\n this.__saveInstanceProperties();\n // ensures first update will be caught by an early access of\n // `updateComplete`\n this.requestUpdate();\n (this.constructor as typeof ReactiveElement)._initializers?.forEach((i) =>\n i(this)\n );\n }\n\n /**\n * Registers a `ReactiveController` to participate in the element's reactive\n * update cycle. The element automatically calls into any registered\n * controllers during its lifecycle callbacks.\n *\n * If the element is connected when `addController()` is called, the\n * controller's `hostConnected()` callback will be immediately called.\n * @category controllers\n */\n addController(controller: ReactiveController) {\n (this.__controllers ??= new Set()).add(controller);\n // If a controller is added after the element has been connected,\n // call hostConnected. Note, re-using existence of `renderRoot` here\n // (which is set in connectedCallback) to avoid the need to track a\n // first connected state.\n if (this.renderRoot !== undefined && this.isConnected) {\n controller.hostConnected?.();\n }\n }\n\n /**\n * Removes a `ReactiveController` from the element.\n * @category controllers\n */\n removeController(controller: ReactiveController) {\n this.__controllers?.delete(controller);\n }\n\n /**\n * Fixes any properties set on the instance before upgrade time.\n * Otherwise these would shadow the accessor and break these properties.\n * The properties are stored in a Map which is played back after the\n * constructor runs.\n */\n private __saveInstanceProperties() {\n const instanceProperties = new Map<PropertyKey, unknown>();\n const elementProperties = (this.constructor as typeof ReactiveElement)\n .elementProperties;\n for (const p of elementProperties.keys() as IterableIterator<keyof this>) {\n if (this.hasOwnProperty(p)) {\n instanceProperties.set(p, this[p]);\n delete this[p];\n }\n }\n if (instanceProperties.size > 0) {\n this.__instanceProperties = instanceProperties;\n }\n }\n\n /**\n * Returns the node into which the element should render and by default\n * creates and returns an open shadowRoot. Implement to customize where the\n * element's DOM is rendered. For example, to render into the element's\n * childNodes, return `this`.\n *\n * @return Returns a node into which to render.\n * @category rendering\n */\n protected createRenderRoot(): HTMLElement | DocumentFragment {\n const renderRoot =\n this.shadowRoot ??\n this.attachShadow(\n (this.constructor as typeof ReactiveElement).shadowRootOptions\n );\n adoptStyles(\n renderRoot,\n (this.constructor as typeof ReactiveElement).elementStyles\n );\n return renderRoot;\n }\n\n /**\n * On first connection, creates the element's renderRoot, sets up\n * element styling, and enables updating.\n * @category lifecycle\n */\n connectedCallback() {\n // Create renderRoot before controllers `hostConnected`\n (this as Mutable<typeof this, 'renderRoot'>).renderRoot ??=\n this.createRenderRoot();\n this.enableUpdating(true);\n this.__controllers?.forEach((c) => c.hostConnected?.());\n }\n\n /**\n * Note, this method should be considered final and not overridden. It is\n * overridden on the element instance with a function that triggers the first\n * update.\n * @category updates\n */\n protected enableUpdating(_requestedUpdate: boolean) {}\n\n /**\n * Allows for `super.disconnectedCallback()` in extensions while\n * reserving the possibility of making non-breaking feature additions\n * when disconnecting at some point in the future.\n * @category lifecycle\n */\n disconnectedCallback() {\n this.__controllers?.forEach((c) => c.hostDisconnected?.());\n }\n\n /**\n * Synchronizes property values when attributes change.\n *\n * Specifically, when an attribute is set, the corresponding property is set.\n * You should rarely need to implement this callback. If this method is\n * overridden, `super.attributeChangedCallback(name, _old, value)` must be\n * called.\n *\n * See [responding to attribute changes](https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_custom_elements#responding_to_attribute_changes)\n * on MDN for more information about the `attributeChangedCallback`.\n * @category attributes\n */\n attributeChangedCallback(\n name: string,\n _old: string | null,\n value: string | null\n ) {\n this._$attributeToProperty(name, value);\n }\n\n private __propertyToAttribute(name: PropertyKey, value: unknown) {\n const elemProperties: PropertyDeclarationMap = (\n this.constructor as typeof ReactiveElement\n ).elementProperties;\n const options = elemProperties.get(name)!;\n const attr = (\n this.constructor as typeof ReactiveElement\n ).__attributeNameForProperty(name, options);\n if (attr !== undefined && options.reflect === true) {\n const converter =\n (options.converter as ComplexAttributeConverter)?.toAttribute !==\n undefined\n ? (options.converter as ComplexAttributeConverter)\n : defaultConverter;\n const attrValue = converter.toAttribute!(value, options.type);\n if (\n DEV_MODE &&\n (this.constructor as typeof ReactiveElement).enabledWarnings!.includes(\n 'migration'\n ) &&\n attrValue === undefined\n ) {\n issueWarning(\n 'undefined-attribute-value',\n `The attribute value for the ${name as string} property is ` +\n `undefined on element ${this.localName}. The attribute will be ` +\n `removed, but in the previous version of \\`ReactiveElement\\`, ` +\n `the attribute would not have changed.`\n );\n }\n // Track if the property is being reflected to avoid\n // setting the property again via `attributeChangedCallback`. Note:\n // 1. this takes advantage of the fact that the callback is synchronous.\n // 2. will behave incorrectly if multiple attributes are in the reaction\n // stack at time of calling. However, since we process attributes\n // in `update` this should not be possible (or an extreme corner case\n // that we'd like to discover).\n // mark state reflecting\n this.__reflectingProperty = name;\n if (attrValue == null) {\n this.removeAttribute(attr);\n } else {\n this.setAttribute(attr, attrValue as string);\n }\n // mark state not reflecting\n this.__reflectingProperty = null;\n }\n }\n\n /** @internal */\n _$attributeToProperty(name: string, value: string | null) {\n const ctor = this.constructor as typeof ReactiveElement;\n // Note, hint this as an `AttributeMap` so closure clearly understands\n // the type; it has issues with tracking types through statics\n const propName = (ctor.__attributeToPropertyMap as AttributeMap).get(name);\n // Use tracking info to avoid reflecting a property value to an attribute\n // if it was just set because the attribute changed.\n if (propName !== undefined && this.__reflectingProperty !== propName) {\n const options = ctor.getPropertyOptions(propName);\n const converter =\n typeof options.converter === 'function'\n ? {fromAttribute: options.converter}\n : options.converter?.fromAttribute !== undefined\n ? options.converter\n : defaultConverter;\n // mark state reflecting\n this.__reflectingProperty = propName;\n const convertedValue = converter.fromAttribute!(value, options.type);\n this[propName as keyof this] =\n convertedValue ??\n this.__defaultValues?.get(propName) ??\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (convertedValue as any);\n // mark state not reflecting\n this.__reflectingProperty = null;\n }\n }\n\n /**\n * Requests an update which is processed asynchronously. This should be called\n * when an element should update based on some state not triggered by setting\n * a reactive property. In this case, pass no arguments. It should also be\n * called when manually implementing a property setter. In this case, pass the\n * property `name` and `oldValue` to ensure that any configured property\n * options are honored.\n *\n * @param name name of requesting property\n * @param oldValue old value of requesting property\n * @param options property options to use instead of the previously\n * configured options\n * @category updates\n */\n requestUpdate(\n name?: PropertyKey,\n oldValue?: unknown,\n options?: PropertyDeclaration\n ): void {\n // If we have a property key, perform property update steps.\n if (name !== undefined) {\n if (DEV_MODE && (name as unknown) instanceof Event) {\n issueWarning(\n ``,\n `The requestUpdate() method was called with an Event as the property name. This is probably a mistake caused by binding this.requestUpdate as an event listener. Instead bind a function that will call it with no arguments: () => this.requestUpdate()`\n );\n }\n const ctor = this.constructor as typeof ReactiveElement;\n const newValue = this[name as keyof this];\n options ??= ctor.getPropertyOptions(name);\n const changed =\n (options.hasChanged ?? notEqual)(newValue, oldValue) ||\n // When there is no change, check a corner case that can occur when\n // 1. there's a initial value which was not reflected\n // 2. the property is subsequently set to this value.\n // For example, `prop: {useDefault: true, reflect: true}`\n // and el.prop = 'foo'. This should be considered a change if the\n // attribute is not set because we will now reflect the property to the attribute.\n (options.useDefault &&\n options.reflect &&\n newValue === this.__defaultValues?.get(name) &&\n !this.hasAttribute(ctor.__attributeNameForProperty(name, options)!));\n if (changed) {\n this._$changeProperty(name, oldValue, options);\n } else {\n // Abort the request if the property should not be considered changed.\n return;\n }\n }\n if (this.isUpdatePending === false) {\n this.__updatePromise = this.__enqueueUpdate();\n }\n }\n\n /**\n * @internal\n */\n _$changeProperty(\n name: PropertyKey,\n oldValue: unknown,\n {useDefault, reflect, wrapped}: PropertyDeclaration,\n initializeValue?: unknown\n ) {\n // Record default value when useDefault is used. This allows us to\n // restore this value when the attribute is removed.\n if (useDefault && !(this.__defaultValues ??= new Map()).has(name)) {\n this.__defaultValues.set(\n name,\n initializeValue ?? oldValue ?? this[name as keyof this]\n );\n // if this is not wrapping an accessor, it must be an initial setting\n // and in this case we do not want to record the change or reflect.\n if (wrapped !== true || initializeValue !== undefined) {\n return;\n }\n }\n // TODO (justinfagnani): Create a benchmark of Map.has() + Map.set(\n // vs just Map.set()\n if (!this._$changedProperties.has(name)) {\n // On the initial change, the old value should be `undefined`, except\n // with `useDefault`\n if (!this.hasUpdated && !useDefault) {\n oldValue = undefined;\n }\n this._$changedProperties.set(name, oldValue);\n }\n // Add to reflecting properties set.\n // Note, it's important that every change has a chance to add the\n // property to `__reflectingProperties`. This ensures setting\n // attribute + property reflects correctly.\n if (reflect === true && this.__reflectingProperty !== name) {\n (this.__reflectingProperties ??= new Set<PropertyKey>()).add(name);\n }\n }\n\n /**\n * Sets up the element to asynchronously update.\n */\n private async __enqueueUpdate() {\n this.isUpdatePending = true;\n try {\n // Ensure any previous update has resolved before updating.\n // This `await` also ensures that property changes are batched.\n await this.__updatePromise;\n } catch (e) {\n // Refire any previous errors async so they do not disrupt the update\n // cycle. Errors are refired so developers have a chance to observe\n // them, and this can be done by implementing\n // `window.onunhandledrejection`.\n Promise.reject(e);\n }\n const result = this.scheduleUpdate();\n // If `scheduleUpdate` returns a Promise, we await it. This is done to\n // enable coordinating updates with a scheduler. Note, the result is\n // checked to avoid delaying an additional microtask unless we need to.\n if (result != null) {\n await result;\n }\n return !this.isUpdatePending;\n }\n\n /**\n * Schedules an element update. You can override this method to change the\n * timing of updates by returning a Promise. The update will await the\n * returned Promise, and you should resolve the Promise to allow the update\n * to proceed. If this method is overridden, `super.scheduleUpdate()`\n * must be called.\n *\n * For instance, to schedule updates to occur just before the next frame:\n *\n * ```ts\n * override protected async scheduleUpdate(): Promise<unknown> {\n * await new Promise((resolve) => requestAnimationFrame(() => resolve()));\n * super.scheduleUpdate();\n * }\n * ```\n * @category updates\n */\n protected scheduleUpdate(): void | Promise<unknown> {\n const result = this.performUpdate();\n if (\n DEV_MODE &&\n (this.constructor as typeof ReactiveElement).enabledWarnings!.includes(\n 'async-perform-update'\n ) &&\n typeof (result as unknown as Promise<unknown> | undefined)?.then ===\n 'function'\n ) {\n issueWarning(\n 'async-perform-update',\n `Element ${this.localName} returned a Promise from performUpdate(). ` +\n `This behavior is deprecated and will be removed in a future ` +\n `version of ReactiveElement.`\n );\n }\n return result;\n }\n\n /**\n * Performs an element update. Note, if an exception is thrown during the\n * update, `firstUpdated` and `updated` will not be called.\n *\n * Call `performUpdate()` to immediately process a pending update. This should\n * generally not be needed, but it can be done in rare cases when you need to\n * update synchronously.\n *\n * @category updates\n */\n protected performUpdate(): void {\n // Abort any update if one is not pending when this is called.\n // This can happen if `performUpdate` is called early to \"flush\"\n // the update.\n if (!this.isUpdatePending) {\n return;\n }\n debugLogEvent?.({kind: 'update'});\n if (!this.hasUpdated) {\n // Create renderRoot before first update. This occurs in `connectedCallback`\n // but is done here to support out of tree calls to `enableUpdating`/`performUpdate`.\n (this as Mutable<typeof this, 'renderRoot'>).renderRoot ??=\n this.createRenderRoot();\n if (DEV_MODE) {\n // Produce warning if any reactive properties on the prototype are\n // shadowed by class fields. Instance fields set before upgrade are\n // deleted by this point, so any own property is caused by class field\n // initialization in the constructor.\n const ctor = this.constructor as typeof ReactiveElement;\n const shadowedProperties = [...ctor.elementProperties.keys()].filter(\n (p) => this.hasOwnProperty(p) && p in getPrototypeOf(this)\n );\n if (shadowedProperties.length) {\n throw new Error(\n `The following properties on element ${this.localName} will not ` +\n `trigger updates as expected because they are set using class ` +\n `fields: ${shadowedProperties.join(', ')}. ` +\n `Native class fields and some compiled output will overwrite ` +\n `accessors used for detecting changes. See ` +\n `https://lit.dev/msg/class-field-shadowing ` +\n `for more information.`\n );\n }\n }\n // Mixin instance properties once, if they exist.\n if (this.__instanceProperties) {\n // TODO (justinfagnani): should we use the stored value? Could a new value\n // have been set since we stored the own property value?\n for (const [p, value] of this.__instanceProperties) {\n this[p as keyof this] = value as this[keyof this];\n }\n this.__instanceProperties = undefined;\n }\n // Trigger initial value reflection and populate the initial\n // `changedProperties` map, but only for the case of properties created\n // via `createProperty` on accessors, which will not have already\n // populated the `changedProperties` map since they are not set.\n // We can't know if these accessors had initializers, so we just set\n // them anyway - a difference from experimental decorators on fields and\n // standard decorators on auto-accessors.\n // For context see:\n // https://github.com/lit/lit/pull/4183#issuecomment-1711959635\n const elementProperties = (this.constructor as typeof ReactiveElement)\n .elementProperties;\n if (elementProperties.size > 0) {\n for (const [p, options] of elementProperties) {\n const {wrapped} = options;\n const value = this[p as keyof this];\n if (\n wrapped === true &&\n !this._$changedProperties.has(p) &&\n value !== undefined\n ) {\n this._$changeProperty(p, undefined, options, value);\n }\n }\n }\n }\n let shouldUpdate = false;\n const changedProperties = this._$changedProperties;\n try {\n shouldUpdate = this.shouldUpdate(changedProperties);\n if (shouldUpdate) {\n this.willUpdate(changedProperties);\n this.__controllers?.forEach((c) => c.hostUpdate?.());\n this.update(changedProperties);\n } else {\n this.__markUpdated();\n }\n } catch (e) {\n // Prevent `firstUpdated` and `updated` from running when there's an\n // update exception.\n shouldUpdate = false;\n // Ensure element can accept additional updates after an exception.\n this.__markUpdated();\n throw e;\n }\n // The update is no longer considered pending and further updates are now allowed.\n if (shouldUpdate) {\n this._$didUpdate(changedProperties);\n }\n }\n\n /**\n * Invoked before `update()` to compute values needed during the update.\n *\n * Implement `willUpdate` to compute property values that depend on other\n * properties and are used in the rest of the update process.\n *\n * ```ts\n * willUpdate(changedProperties) {\n * // only need to check changed properties for an expensive computation.\n * if (changedProperties.has('firstName') || changedProperties.has('lastName')) {\n * this.sha = computeSHA(`${this.firstName} ${this.lastName}`);\n * }\n * }\n *\n * render() {\n * return html`SHA: ${this.sha}`;\n * }\n * ```\n *\n * @category updates\n */\n protected willUpdate(_changedProperties: PropertyValues): void {}\n\n // Note, this is an override point for polyfill-support.\n // @internal\n _$didUpdate(changedProperties: PropertyValues) {\n this.__controllers?.forEach((c) => c.hostUpdated?.());\n if (!this.hasUpdated) {\n this.hasUpdated = true;\n this.firstUpdated(changedProperties);\n }\n this.updated(changedProperties);\n if (\n DEV_MODE &&\n this.isUpdatePending &&\n (this.constructor as typeof ReactiveElement).enabledWarnings!.includes(\n 'change-in-update'\n )\n ) {\n issueWarning(\n 'change-in-update',\n `Element ${this.localName} scheduled an update ` +\n `(generally because a property was set) ` +\n `after an update completed, causing a new update to be scheduled. ` +\n `This is inefficient and should be avoided unless the next update ` +\n `can only be scheduled as a side effect of the previous update.`\n );\n }\n }\n\n private __markUpdated() {\n this._$changedProperties = new Map();\n this.isUpdatePending = false;\n }\n\n /**\n * Returns a Promise that resolves when the element has completed updating.\n * The Promise value is a boolean that is `true` if the element completed the\n * update without triggering another update. The Promise result is `false` if\n * a property was set inside `updated()`. If the Promise is rejected, an\n * exception was thrown during the update.\n *\n * To await additional asynchronous work, override the `getUpdateComplete`\n * method. For example, it is sometimes useful to await a rendered element\n * before fulfilling this Promise. To do this, first await\n * `super.getUpdateComplete()`, then any subsequent state.\n *\n * @return A promise of a boolean that resolves to true if the update completed\n * without triggering another update.\n * @category updates\n */\n get updateComplete(): Promise<boolean> {\n return this.getUpdateComplete();\n }\n\n /**\n * Override point for the `updateComplete` promise.\n *\n * It is not safe to override the `updateComplete` getter directly due to a\n * limitation in TypeScript which means it is not possible to call a\n * superclass getter (e.g. `super.updateComplete.then(...)`) when the target\n * language is ES5 (https://github.com/microsoft/TypeScript/issues/338).\n * This method should be overridden instead. For example:\n *\n * ```ts\n * class MyElement extends LitElement {\n * override async getUpdateComplete() {\n * const result = await super.getUpdateComplete();\n * await this._myChild.updateComplete;\n * return result;\n * }\n * }\n * ```\n *\n * @return A promise of a boolean that resolves to true if the update completed\n * without triggering another update.\n * @category updates\n */\n protected getUpdateComplete(): Promise<boolean> {\n return this.__updatePromise;\n }\n\n /**\n * Controls whether or not `update()` should be called when the element requests\n * an update. By default, this method always returns `true`, but this can be\n * customized to control when to update.\n *\n * @param _changedProperties Map of changed properties with old values\n * @category updates\n */\n protected shouldUpdate(_changedProperties: PropertyValues): boolean {\n return true;\n }\n\n /**\n * Updates the element. This method reflects property values to attributes.\n * It can be overridden to render and keep updated element DOM.\n * Setting properties inside this method will *not* trigger\n * another update.\n *\n * @param _changedProperties Map of changed properties with old values\n * @category updates\n */\n protected update(_changedProperties: PropertyValues) {\n // The forEach() expression will only run when __reflectingProperties is\n // defined, and it returns undefined, setting __reflectingProperties to\n // undefined\n this.__reflectingProperties &&= this.__reflectingProperties.forEach((p) =>\n this.__propertyToAttribute(p, this[p as keyof this])\n ) as undefined;\n this.__markUpdated();\n }\n\n /**\n * Invoked whenever the element is updated. Implement to perform\n * post-updating tasks via DOM APIs, for example, focusing an element.\n *\n * Setting properties inside this method will trigger the element to update\n * again after this update cycle completes.\n *\n * @param _changedProperties Map of changed properties with old values\n * @category updates\n */\n protected updated(_changedProperties: PropertyValues) {}\n\n /**\n * Invoked when the element is first updated. Implement to perform one time\n * work on the element after update.\n *\n * ```ts\n * firstUpdated() {\n * this.renderRoot.getElementById('my-text-area').focus();\n * }\n * ```\n *\n * Setting properties inside this method will trigger the element to update\n * again after this update cycle completes.\n *\n * @param _changedProperties Map of changed properties with old values\n * @category updates\n */\n protected firstUpdated(_changedProperties: PropertyValues) {}\n}\n// Assigned here to work around a jscompiler bug with static fields\n// when compiling to ES5.\n// https://github.com/google/closure-compiler/issues/3177\n(ReactiveElement as unknown as Record<string, unknown>)[\n JSCompiler_renameProperty('elementProperties', ReactiveElement)\n] = new Map();\n(ReactiveElement as unknown as Record<string, unknown>)[\n JSCompiler_renameProperty('finalized', ReactiveElement)\n] = new Map();\n\n// Apply polyfills if available\npolyfillSupport?.({ReactiveElement});\n\n// Dev mode warnings...\nif (DEV_MODE) {\n // Default warning set.\n ReactiveElement.enabledWarnings = [\n 'change-in-update',\n 'async-perform-update',\n ];\n const ensureOwnWarnings = function (ctor: typeof ReactiveElement) {\n if (\n !ctor.hasOwnProperty(JSCompiler_renameProperty('enabledWarnings', ctor))\n ) {\n ctor.enabledWarnings = ctor.enabledWarnings!.slice();\n }\n };\n ReactiveElement.enableWarning = function (\n this: typeof ReactiveElement,\n warning: WarningKind\n ) {\n ensureOwnWarnings(this);\n if (!this.enabledWarnings!.includes(warning)) {\n this.enabledWarnings!.push(warning);\n }\n };\n ReactiveElement.disableWarning = function (\n this: typeof ReactiveElement,\n warning: WarningKind\n ) {\n ensureOwnWarnings(this);\n const i = this.enabledWarnings!.indexOf(warning);\n if (i >= 0) {\n this.enabledWarnings!.splice(i, 1);\n }\n };\n}\n\n// IMPORTANT: do not change the property name or the assignment expression.\n// This line will be used in regexes to search for ReactiveElement usage.\n(global.reactiveElementVersions ??= []).push('2.1.1');\nif (DEV_MODE && global.reactiveElementVersions.length > 1) {\n queueMicrotask(() => {\n issueWarning!(\n 'multiple-versions',\n `Multiple versions of Lit loaded. Loading multiple versions ` +\n `is not recommended.`\n );\n });\n}\n", "/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/**\n * The main LitElement module, which defines the {@linkcode LitElement} base\n * class and related APIs.\n *\n * LitElement components can define a template and a set of observed\n * properties. Changing an observed property triggers a re-render of the\n * element.\n *\n * Import {@linkcode LitElement} and {@linkcode html} from this module to\n * create a component:\n *\n * ```js\n * import {LitElement, html} from 'lit-element';\n *\n * class MyElement extends LitElement {\n *\n * // Declare observed properties\n * static get properties() {\n * return {\n * adjective: {}\n * }\n * }\n *\n * constructor() {\n * this.adjective = 'awesome';\n * }\n *\n * // Define the element's template\n * render() {\n * return html`<p>your ${adjective} template here</p>`;\n * }\n * }\n *\n * customElements.define('my-element', MyElement);\n * ```\n *\n * `LitElement` extends {@linkcode ReactiveElement} and adds lit-html\n * templating. The `ReactiveElement` class is provided for users that want to\n * build their own custom element base classes that don't use lit-html.\n *\n * @packageDocumentation\n */\nimport {PropertyValues, ReactiveElement} from '@lit/reactive-element';\nimport {render, RenderOptions, noChange, RootPart} from 'lit-html';\nexport * from '@lit/reactive-element';\nexport * from 'lit-html';\n\nimport {LitUnstable} from 'lit-html';\nimport {ReactiveUnstable} from '@lit/reactive-element';\n\n/**\n * Contains types that are part of the unstable debug API.\n *\n * Everything in this API is not stable and may change or be removed in the future,\n * even on patch releases.\n */\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport namespace Unstable {\n /**\n * When Lit is running in dev mode and `window.emitLitDebugLogEvents` is true,\n * we will emit 'lit-debug' events to window, with live details about the update and render\n * lifecycle. These can be useful for writing debug tooling and visualizations.\n *\n * Please be aware that running with window.emitLitDebugLogEvents has performance overhead,\n * making certain operations that are normally very cheap (like a no-op render) much slower,\n * because we must copy data and dispatch events.\n */\n // eslint-disable-next-line @typescript-eslint/no-namespace\n export namespace DebugLog {\n export type Entry =\n | LitUnstable.DebugLog.Entry\n | ReactiveUnstable.DebugLog.Entry;\n }\n}\n/*\n * When using Closure Compiler, JSCompiler_renameProperty(property, object) is\n * replaced at compile time by the munged name for object[property]. We cannot\n * alias this function, so we have to use a small shim that has the same\n * behavior when not compiling.\n */\n/*@__INLINE__*/\nconst JSCompiler_renameProperty = <P extends PropertyKey>(\n prop: P,\n _obj: unknown\n): P => prop;\n\nconst DEV_MODE = true;\n// Allows minifiers to rename references to globalThis\nconst global = globalThis;\n\nlet issueWarning: (code: string, warning: string) => void;\n\nif (DEV_MODE) {\n // Ensure warnings are issued only 1x, even if multiple versions of Lit\n // are loaded.\n global.litIssuedWarnings ??= new Set();\n\n /**\n * Issue a warning if we haven't already, based either on `code` or `warning`.\n * Warnings are disabled automatically only by `warning`; disabling via `code`\n * can be done by users.\n */\n issueWarning = (code: string, warning: string) => {\n warning += ` See https://lit.dev/msg/${code} for more information.`;\n if (\n !global.litIssuedWarnings!.has(warning) &&\n !global.litIssuedWarnings!.has(code)\n ) {\n console.warn(warning);\n global.litIssuedWarnings!.add(warning);\n }\n };\n}\n\n/**\n * Base element class that manages element properties and attributes, and\n * renders a lit-html template.\n *\n * To define a component, subclass `LitElement` and implement a\n * `render` method to provide the component's template. Define properties\n * using the {@linkcode LitElement.properties properties} property or the\n * {@linkcode property} decorator.\n */\nexport class LitElement extends ReactiveElement {\n // This property needs to remain unminified.\n static ['_$litElement$'] = true;\n\n /**\n * @category rendering\n */\n readonly renderOptions: RenderOptions = {host: this};\n\n private __childPart: RootPart | undefined = undefined;\n\n /**\n * @category rendering\n */\n protected override createRenderRoot() {\n const renderRoot = super.createRenderRoot();\n // When adoptedStyleSheets are shimmed, they are inserted into the\n // shadowRoot by createRenderRoot. Adjust the renderBefore node so that\n // any styles in Lit content render before adoptedStyleSheets. This is\n // important so that adoptedStyleSheets have precedence over styles in\n // the shadowRoot.\n this.renderOptions.renderBefore ??= renderRoot!.firstChild as ChildNode;\n return renderRoot;\n }\n\n /**\n * Updates the element. This method reflects property values to attributes\n * and calls `render` to render DOM via lit-html. Setting properties inside\n * this method will *not* trigger another update.\n * @param changedProperties Map of changed properties with old values\n * @category updates\n */\n protected override update(changedProperties: PropertyValues) {\n // Setting properties in `render` should not trigger an update. Since\n // updates are allowed after super.update, it's important to call `render`\n // before that.\n const value = this.render();\n if (!this.hasUpdated) {\n this.renderOptions.isConnected = this.isConnected;\n }\n super.update(changedProperties);\n this.__childPart = render(value, this.renderRoot, this.renderOptions);\n }\n\n /**\n * Invoked when the component is added to the document's DOM.\n *\n * In `connectedCallback()` you should setup tasks that should only occur when\n * the element is connected to the document. The most common of these is\n * adding event listeners to nodes external to the element, like a keydown\n * event handler added to the window.\n *\n * ```ts\n * connectedCallback() {\n * super.connectedCallback();\n * addEventListener('keydown', this._handleKeydown);\n * }\n * ```\n *\n * Typically, anything done in `connectedCallback()` should be undone when the\n * element is disconnected, in `disconnectedCallback()`.\n *\n * @category lifecycle\n */\n override connectedCallback() {\n super.connectedCallback();\n this.__childPart?.setConnected(true);\n }\n\n /**\n * Invoked when the component is removed from the document's DOM.\n *\n * This callback is the main signal to the element that it may no longer be\n * used. `disconnectedCallback()` should ensure that nothing is holding a\n * reference to the element (such as event listeners added to nodes external\n * to the element), so that it is free to be garbage collected.\n *\n * ```ts\n * disconnectedCallback() {\n * super.disconnectedCallback();\n * window.removeEventListener('keydown', this._handleKeydown);\n * }\n * ```\n *\n * An element may be re-connected after being disconnected.\n *\n * @category lifecycle\n */\n override disconnectedCallback() {\n super.disconnectedCallback();\n this.__childPart?.setConnected(false);\n }\n\n /**\n * Invoked on each update to perform rendering tasks. This method may return\n * any value renderable by lit-html's `ChildPart` - typically a\n * `TemplateResult`. Setting properties inside this method will *not* trigger\n * the element to update.\n * @category rendering\n */\n protected render(): unknown {\n return noChange;\n }\n}\n\n/**\n * Ensure this class is marked as `finalized` as an optimization ensuring\n * it will not needlessly try to `finalize`.\n *\n * Note this property name is a string to prevent breaking Closure JS Compiler\n * optimizations. See @lit/reactive-element for more information.\n */\n(LitElement as unknown as Record<string, unknown>)[\n JSCompiler_renameProperty('finalized', LitElement)\n] = true;\n\n// Install hydration if available\nglobal.litElementHydrateSupport?.({LitElement});\n\n// Apply polyfills if available\nconst polyfillSupport = DEV_MODE\n ? global.litElementPolyfillSupportDevMode\n : global.litElementPolyfillSupport;\npolyfillSupport?.({LitElement});\n\n/**\n * END USERS SHOULD NOT RELY ON THIS OBJECT.\n *\n * Private exports for use by other Lit packages, not intended for use by\n * external users.\n *\n * We currently do not make a mangled rollup build of the lit-ssr code. In order\n * to keep a number of (otherwise private) top-level exports mangled in the\n * client side code, we export a _$LE object containing those members (or\n * helper methods for accessing private fields of those members), and then\n * re-export them for use in lit-ssr. This keeps lit-ssr agnostic to whether the\n * client-side code is being used in `dev` mode or `prod` mode.\n *\n * This has a unique name, to disambiguate it from private exports in\n * lit-html, since this module re-exports all of lit-html.\n *\n * @private\n */\nexport const _$LE = {\n _$attributeToProperty: (\n el: LitElement,\n name: string,\n value: string | null\n ) => {\n // eslint-disable-next-line\n (el as any)._$attributeToProperty(name, value);\n },\n // eslint-disable-next-line\n _$changedProperties: (el: LitElement) => (el as any)._$changedProperties,\n};\n\n// IMPORTANT: do not change the property name or the assignment expression.\n// This line will be used in regexes to search for LitElement usage.\n(global.litElementVersions ??= []).push('4.2.1');\nif (DEV_MODE && global.litElementVersions.length > 1) {\n queueMicrotask(() => {\n issueWarning!(\n 'multiple-versions',\n `Multiple versions of Lit loaded. Loading multiple versions ` +\n `is not recommended.`\n );\n });\n}\n", "// ds-button.ts\n// Core button component\nimport { LitElement, html, css } from \"lit\";\nimport { getText } from \"../0-face/i18n\";\nexport class Button extends LitElement {\n constructor() {\n super();\n this._handleLanguageChange = () => {\n this._updateText();\n };\n this.variant = \"title\";\n this.disabled = false;\n this.bold = false;\n this[\"no-background\"] = false;\n this.blank = false;\n this.notionKey = null;\n this.key = \"\";\n this.fallback = \"\";\n this.language = \"en-US\";\n this.defaultText = \"\";\n this.href = \"\";\n this._loading = false;\n this._notionText = null;\n }\n connectedCallback() {\n super.connectedCallback();\n this._updateText();\n // Listen for language changes\n window.addEventListener(\"language-changed\", this._handleLanguageChange);\n }\n disconnectedCallback() {\n super.disconnectedCallback();\n window.removeEventListener(\"language-changed\", this._handleLanguageChange);\n }\n updated(changedProps) {\n super.updated(changedProps);\n if (changedProps.has(\"key\") || changedProps.has(\"defaultText\")) {\n this._updateText();\n }\n }\n /**\n * Update text from translations (synchronous like Portfolio)\n */\n _updateText() {\n if (this.key) {\n this._notionText = getText(this.key);\n }\n else {\n this._notionText = this.defaultText || this.fallback || null;\n }\n this.requestUpdate();\n }\n render() {\n return html `\n <button\n class=${this.variant}\n ?disabled=${this.disabled}\n ?bold=${this.bold}\n ?no-background=${this[\"no-background\"]}\n @click=${this._handleClick}\n >\n ${this._notionText ? this._notionText : html `<slot></slot>`}\n </button>\n `;\n }\n _handleClick(e) {\n // Prevent any action if disabled and stop event propagation\n if (this.disabled) {\n e.preventDefault();\n e.stopPropagation();\n return;\n }\n // If href is provided, navigate to the URL and do not bubble further\n if (this.href) {\n e.preventDefault();\n e.stopPropagation();\n if (this.blank) {\n window.open(this.href, \"_blank\", \"noopener,noreferrer\");\n }\n else {\n window.location.href = this.href;\n }\n return;\n }\n // Otherwise, rely on the native 'click' event bubbling from the inner\n // <button> through the shadow boundary to consumers of <ds-button>.\n // Do not re-dispatch a synthetic 'click' here to avoid duplicate events.\n }\n}\nButton.properties = {\n variant: { type: String, reflect: true },\n disabled: { type: Boolean, reflect: true },\n bold: { type: Boolean, reflect: true },\n \"no-background\": {\n type: Boolean,\n reflect: true,\n attribute: \"no-background\",\n },\n blank: { type: Boolean, reflect: true },\n notionKey: { type: String, attribute: \"notion-key\" },\n key: { type: String },\n fallback: { type: String },\n language: { type: String },\n defaultText: { type: String, attribute: \"default-text\" },\n href: { type: String },\n _loading: { type: Boolean, state: true },\n _notionText: { type: String, state: true },\n};\nButton.styles = css `\n button {\n max-height: calc(var(--08) * var(--scaling-factor));\n border: none;\n cursor: pointer;\n font-size: calc(var(--type-size-default) * var(--scaling-factor));\n padding: 0 calc(1px * var(--scaling-factor));\n color: var(--button-text-color);\n font-family: var(--typeface);\n }\n\n button.title {\n background-color: var(--button-background-color-secondary);\n color: var(--button-text-color);\n }\n\n button.primary {\n background-color: var(--accent-color);\n color: var(--button-text-color);\n text-decoration-line: none;\n font-family: var(--typeface);\n }\n\n button.secondary {\n background-color: var(--button-background-color-secondary);\n color: var(--button-text-color);\n font-family: var(--typeface);\n }\n\n button[bold] {\n font-weight: var(--type-weight-bold);\n font-family: var(--typeface-medium);\n }\n\n button[no-background] {\n background-color: transparent;\n max-height: var(--1);\n padding: 0;\n color: var(--button-color, var(--button-text-color-secondary));\n }\n\n button[no-background][bold] {\n font-weight: var(--type-weight-bold);\n font-family: var(--typeface-medium);\n color: var(--button-color, var(--button-text-color-secondary));\n }\n\n .loading {\n opacity: 0.7;\n }\n `;\ncustomElements.define(\"ds-button\", Button);\n", "/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {nothing, TemplateResult, noChange} from '../lit-html.js';\nimport {directive, Directive, PartInfo, PartType} from '../directive.js';\n\nconst HTML_RESULT = 1;\n\nexport class UnsafeHTMLDirective extends Directive {\n static directiveName = 'unsafeHTML';\n static resultType = HTML_RESULT;\n\n private _value: unknown = nothing;\n private _templateResult?: TemplateResult;\n\n constructor(partInfo: PartInfo) {\n super(partInfo);\n if (partInfo.type !== PartType.CHILD) {\n throw new Error(\n `${\n (this.constructor as typeof UnsafeHTMLDirective).directiveName\n }() can only be used in child bindings`\n );\n }\n }\n\n render(value: string | typeof nothing | typeof noChange | undefined | null) {\n if (value === nothing || value == null) {\n this._templateResult = undefined;\n return (this._value = value);\n }\n if (value === noChange) {\n return value;\n }\n if (typeof value != 'string') {\n throw new Error(\n `${\n (this.constructor as typeof UnsafeHTMLDirective).directiveName\n }() called with a non-string value`\n );\n }\n if (value === this._value) {\n return this._templateResult;\n }\n this._value = value;\n const strings = [value] as unknown as TemplateStringsArray;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (strings as any).raw = strings;\n // WARNING: impersonating a TemplateResult like this is extremely\n // dangerous. Third-party directives should not do this.\n return (this._templateResult = {\n // Cast to a known set of integers that satisfy ResultType so that we\n // don't have to export ResultType and possibly encourage this pattern.\n // This property needs to remain unminified.\n ['_$litType$']: (this.constructor as typeof UnsafeHTMLDirective)\n .resultType as 1 | 2,\n strings,\n values: [],\n });\n }\n}\n\n/**\n * Renders the result as HTML, rather than text.\n *\n * The values `undefined`, `null`, and `nothing`, will all result in no content\n * (empty string) being rendered.\n *\n * Note, this is unsafe to use with any user-provided input that hasn't been\n * sanitized or escaped, as it may lead to cross-site-scripting\n * vulnerabilities.\n */\nexport const unsafeHTML = directive(UnsafeHTMLDirective);\n", "import { LitElement, html, css } from \"lit\";\nimport { unsafeHTML } from \"lit/directives/unsafe-html.js\";\nexport class Icon extends LitElement {\n get type() {\n return this._type;\n }\n set type(val) {\n const oldVal = this._type;\n this._type = val;\n this.requestUpdate(\"type\", oldVal);\n }\n constructor() {\n super();\n this._type = \"\";\n this.size = \"1em\";\n this.color = \"currentColor\";\n this.background = \"transparent\";\n console.log(\"Icon constructor\", this._type);\n }\n connectedCallback() {\n super.connectedCallback();\n console.log(\"Icon connected\", this._type);\n }\n renderIcon() {\n console.log(\"renderIcon called with type:\", this._type);\n if (!this._type || this._type === \"\") {\n console.log(\"No type specified, rendering default slot\");\n return html `<div class=\"icon-container\"><slot></slot></div>`;\n }\n // First, try to render an SVG whose file name matches `type`\n const svgFromSet = Icon.iconNameToSvgMap[this._type.toLowerCase()];\n if (svgFromSet) {\n return html `<div class=\"icon-container\">${unsafeHTML(svgFromSet)}</div>`;\n }\n switch (this._type.toLowerCase()) {\n case \"close\":\n console.log(\"Rendering close icon\");\n return html `\n <div class=\"icon-container\">\n <svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n d=\"M18.3 5.71a.996.996 0 00-1.41 0L12 10.59 7.11 5.7A.996.996 0 105.7 7.11L10.59 12 5.7 16.89a.996.996 0 101.41 1.41L12 13.41l4.89 4.89a.996.996 0 101.41-1.41L13.41 12l4.89-4.89c.38-.38.38-1.02 0-1.4z\"\n />\n </svg>\n </div>\n `;\n case \"page\":\n console.log(\"Rendering page icon\");\n return html `\n <div class=\"icon-container\">\n <svg viewBox=\"0 0 17 17\" xmlns=\"http://www.w3.org/2000/svg\">\n <rect\n width=\"16\"\n height=\"16\"\n transform=\"translate(0.799988 0.678772)\"\n fill=\"var(--accent-color)\"\n />\n <path\n d=\"M13.7956 2.38385V14.9737H3.80438V2.38385H13.7956ZM4.7243 14.0538H12.8757V3.30377H4.7243V14.0538ZM8.67841 8.53619V9.45612H5.92938V8.53619H8.67841ZM10.8259 6.60455V7.52448H5.92938V6.60455H10.8259ZM10.8259 4.67194V5.59283H5.92938V4.67194H10.8259Z\"\n fill=\"#2A2A2A\"\n />\n </svg>\n </div>\n `;\n case \"note\":\n console.log(\"Rendering note icon\");\n return html `\n <div class=\"icon-container\">\n <svg viewBox=\"0 0 17 17\" xmlns=\"http://www.w3.org/2000/svg\">\n <rect\n width=\"16\"\n height=\"16\"\n transform=\"translate(0.799988 0.678772)\"\n fill=\"var(--accent-color, #CCFF4D)\"\n />\n <path\n d=\"M14.7653 3.99225V13.3653H2.83466V3.99225H14.7653ZM3.83466 12.3653H13.7653V4.99225H3.83466V12.3653Z\"\n fill=\"#2A2A2A\"\n />\n <path\n d=\"M8.8064 7.75881V8.67873H4.51343V7.75881H8.8064ZM10.7527 5.75881V6.67873H4.51343V5.75881H10.7527Z\"\n fill=\"#2A2A2A\"\n />\n </svg>\n </div>\n `;\n case \"default\":\n console.log(\"Rendering default icon\");\n return html `\n <div class=\"icon-container\">\n <svg\n width=\"17\"\n height=\"16\"\n viewBox=\"0 0 17 16\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <rect\n width=\"16\"\n height=\"16\"\n transform=\"translate(0.799988)\"\n fill=\"var(--accent-color, #CCFF4D)\"\n />\n <path\n d=\"M9.95899 15V6.81H7.05999V5.77H14.093V6.81H11.194V15H9.95899Z\"\n fill=\"#2A2A2A\"\n />\n <path\n fill-rule=\"evenodd\"\n clip-rule=\"evenodd\"\n d=\"M5.89999 0V5.10001H0.799988V0H5.89999Z\"\n fill=\"#2A2A2A\"\n />\n </svg>\n </div>\n `;\n case \"big\":\n console.log(\"Rendering big icon\");\n return html `\n <div class=\"icon-container\">\n <svg\n width=\"17\"\n height=\"16\"\n viewBox=\"0 0 17 16\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <g clip-path=\"url(#clip0_3141_3351)\">\n <rect\n width=\"16\"\n height=\"16\"\n transform=\"translate(0.799988)\"\n fill=\"var(--accent-color, #CCFF4D)\"\n />\n <path\n d=\"M13.959 12.615V4.425H11.06V3.385H16.802V4.425H15.194V12.615H13.959Z\"\n fill=\"#2A2A2A\"\n />\n <path\n fill-rule=\"evenodd\"\n clip-rule=\"evenodd\"\n d=\"M9.79999 3.5V12.5H0.799988V3.5H9.79999Z\"\n fill=\"#2A2A2A\"\n />\n </g>\n <defs>\n <clipPath id=\"clip0_3141_3351\">\n <rect\n width=\"16\"\n height=\"16\"\n fill=\"white\"\n transform=\"translate(0.799988)\"\n />\n </clipPath>\n </defs>\n </svg>\n </div>\n `;\n case \"gallery\":\n console.log(\"Rendering gallery icon\");\n return html `\n <div class=\"icon-container\">\n <svg\n width=\"17\"\n height=\"16\"\n viewBox=\"0 0 17 16\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <g clip-path=\"url(#clip0_3144_2504)\">\n <rect\n width=\"16\"\n height=\"16\"\n transform=\"translate(0.799988)\"\n fill=\"var(--accent-color, #CCFF4D)\"\n />\n <path\n fill-rule=\"evenodd\"\n clip-rule=\"evenodd\"\n d=\"M0.799988 16V0H16.8L0.799988 16ZM1.50604 0.769531V1.80957H4.40546V10H5.63983V1.80957H8.53925V0.769531H1.50604Z\"\n fill=\"#2A2A2A\"\n />\n </g>\n <defs>\n <clipPath id=\"clip0_3144_2504\">\n <rect\n width=\"16\"\n height=\"16\"\n fill=\"white\"\n transform=\"translate(0.799988)\"\n />\n </clipPath>\n </defs>\n </svg>\n </div>\n `;\n case \"check\":\n console.log(\"Rendering check icon\");\n return html `\n <div class=\"icon-container\">\n <svg\n viewBox=\"0 0 17 17\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <rect\n width=\"16\"\n height=\"16\"\n transform=\"translate(0.799988 0.678772)\"\n fill=\"var(--accent-color)\"\n />\n <path\n d=\"M7.48658 11.8747L13.2431 6.12674L12.5361 5.41788L7.48845 10.4734L5.06409 8.04082L4.35706 8.73597L7.48658 11.8747Z\"\n fill=\"#2A2A2A\"\n />\n </svg>\n </div>\n `;\n default:\n console.log(`Unknown icon type: ${this._type}, rendering default slot`);\n return html `<div class=\"icon-container\"><slot></slot></div>`;\n }\n }\n updated(changedProperties) {\n console.log(\"Icon updated\", changedProperties);\n this.style.setProperty(\"--icon-size\", this.size);\n this.style.setProperty(\"--icon-color\", this.color);\n this.style.setProperty(\"--icon-background\", this.background);\n }\n render() {\n console.log(\"Icon render\", this._type);\n return this.renderIcon();\n }\n}\nIcon.properties = {\n type: { type: String, reflect: true },\n};\nIcon.styles = css `\n :host {\n display: inline-flex;\n justify-content: center;\n align-items: center;\n width: calc(16px * var(--scaling-factor));\n height: calc(16px * var(--scaling-factor));\n }\n\n svg {\n width: 100%;\n height: 100%;\n fill: var(--icon-color, currentColor);\n }\n\n path {\n fill: var(--icon-color, currentColor);\n }\n\n .icon-container {\n display: flex;\n justify-content: center;\n align-items: center;\n width: calc(16px * var(--scaling-factor));\n height: calc(16px * var(--scaling-factor));\n }\n\n /* Notes style color variable for future implementation */\n :host {\n --notes-style-color: #ffb6b9;\n }\n `;\n// Load all SVGs from `x Icon/` as raw strings at build time (Vite)\n// The keys will be the file base names (without extension), lowercased.\nIcon.iconNameToSvgMap = (() => {\n try {\n // Note: folder name contains a space, keep it exact.\n const modules = import.meta.glob(\"../x Icon/*.svg\", {\n as: \"raw\",\n eager: true,\n });\n const map = {};\n for (const [path, content] of Object.entries(modules)) {\n const fileName = path.split(\"/\").pop() ?? \"\";\n const baseName = fileName.replace(/\\.svg$/i, \"\").toLowerCase();\n if (baseName) {\n map[baseName] = content;\n }\n }\n return map;\n }\n catch (err) {\n // If not running under Vite (or during tests), gracefully degrade.\n console.warn(\"Icon: failed to glob SVGs from x Icon/; falling back only to inline switch icons.\", err);\n return {};\n }\n})();\ncustomElements.define(\"ds-icon\", Icon);\n// Add this line to help with debugging\nconsole.log(\"Icon component registered with custom elements registry\");\n", "import { LitElement, html, css } from \"lit\";\nimport { translate, currentLanguage, getAvailableLanguagesSync, getLanguageDisplayName, setLanguage, } from \"../0-face/i18n\";\nimport { currentTheme, setTheme } from \"../0-face/theme\";\nimport { savePreferences } from \"../0-face/preferences\";\nimport \"./ds-button\";\nimport \"./ds-icon\";\n// Accent color utilities\nconst saveAccentColor = (color) => {\n localStorage.setItem(\"accentColor\", color);\n};\nconst getAccentColor = () => {\n return localStorage.getItem(\"accentColor\") || \"--blue\"; // Default color if none set\n};\nconst applyAccentColor = () => {\n const color = getAccentColor();\n document.documentElement.style.setProperty(\"--accent-color\", `var(${color})`);\n};\n// Notes style medium utilities\nconst saveNotesStyleMedium = (style) => {\n localStorage.setItem(\"notesStyleMedium\", style);\n};\nconst getNotesStyleMedium = () => {\n return localStorage.getItem(\"notesStyleMedium\") || \"note\"; // Default to note\n};\n// Note behavior utilities\nconst savePageStyle = (style) => {\n localStorage.setItem(\"pageStyle\", style);\n};\nconst getPageStyle = () => {\n return localStorage.getItem(\"pageStyle\") || \"note\"; // Default to note\n};\n// App width utilities removed\n// Use a regular class with proper TypeScript type declarations and JSDoc comments\nexport class Cycle extends LitElement {\n // Define reactive properties using Lit's property system\n static get properties() {\n return {\n type: { type: String },\n values: { type: Array },\n label: { type: String },\n currentValue: { type: String, state: true }, // Make this a private state property\n translationsReady: { type: Boolean, state: true }, // Track if translations are loaded\n disabled: { type: Boolean, state: true },\n variant: { type: String },\n };\n }\n constructor() {\n super();\n // Initialize properties with default values\n this.type = \"\";\n this.values = [];\n this.label = \"\";\n this.currentValue = \"\";\n this.translationsReady = false;\n this.disabled = false;\n this.variant = \"\";\n // Bind event handlers to this instance for proper cleanup\n this.boundHandlers = {\n translationsLoaded: this.handleTranslationsLoaded.bind(this),\n languageChanged: this.handleLanguageChanged.bind(this),\n handleLanguageChanged: this.handleLanguageChanged.bind(this),\n handleThemeChanged: this.handleThemeChanged.bind(this),\n handleAccentColorChanged: this.handleAccentColorChanged.bind(this),\n handleNoteBehaviorChanged: this.handleNoteBehaviorChanged.bind(this),\n };\n }\n connectedCallback() {\n super.connectedCallback();\n // Add event listeners\n window.addEventListener(\"translations-loaded\", this.boundHandlers.translationsLoaded);\n window.addEventListener(\"language-changed\", this.boundHandlers.languageChanged);\n window.addEventListener(\"theme-changed\", this.boundHandlers.handleThemeChanged);\n window.addEventListener(\"accent-color-changed\", this.boundHandlers.handleAccentColorChanged);\n window.addEventListener(\"page-style-changed\", this.boundHandlers.handleNoteBehaviorChanged);\n // Initialize the component\n this.initializeValues();\n }\n async initializeValues() {\n if (this.type === \"language\") {\n // Dynamically get available languages from translation data\n const availableLanguages = getAvailableLanguagesSync();\n this.values = availableLanguages;\n this.currentValue = currentLanguage.value;\n // Set label\n this.label = this.getLabel();\n }\n else if (this.type === \"theme\") {\n // Set up theme cycling\n this.values = [\"light\", \"dark\"];\n // Set initial value based on current theme\n const currentThemeValue = currentTheme.get();\n this.currentValue = currentThemeValue;\n // Set label\n this.label = this.getLabel();\n }\n else if (this.type === \"accent-color\") {\n // Set up accent color cycling\n this.values = [\n \"--light-green\",\n \"--green\",\n \"--light-blue\",\n \"--blue\",\n \"--pink\",\n \"--red\",\n \"--orange\",\n \"--yellow\",\n ];\n // Set initial value based on current accent color\n const currentAccentColor = getAccentColor();\n this.currentValue = currentAccentColor;\n // Apply the accent color to ensure it's active\n applyAccentColor();\n // Set label\n this.label = this.getLabel();\n }\n else if (this.type === \"notes-style-medium\") {\n // Set up notes style medium cycling\n this.values = [\"default\", \"big\", \"gallery\"];\n // Set initial value based on current notes style medium\n const currentNotesStyle = getNotesStyleMedium();\n this.currentValue = currentNotesStyle;\n // Check if this should be disabled based on note behavior\n const currentPageStyle = getPageStyle();\n this.disabled = currentPageStyle === \"note\";\n // Set label\n this.label = this.getLabel();\n }\n else if (this.type === \"page-style\") {\n // Set up page style cycling\n this.values = [\"note\", \"page\"];\n // Set initial value based on current page style\n const currentPageStyle = getPageStyle();\n this.currentValue = currentPageStyle;\n // Set label\n this.label = this.getLabel();\n }\n else if (this.type === \"icon-only\") {\n // Set up icon-only cycling (no label)\n this.values = [\"note\", \"page\"];\n // Set initial value\n this.currentValue = this.values[0];\n // No label for icon-only type\n this.label = \"\";\n }\n // Request update to re-render with new values\n this.requestUpdate();\n }\n ensureThemeInitialized() {\n // Ensure theme is properly initialized\n const savedTheme = localStorage.getItem(\"theme\");\n if (!savedTheme) {\n const prefersDark = window.matchMedia(\"(prefers-color-scheme: dark)\").matches;\n const defaultTheme = prefersDark ? \"dark\" : \"light\";\n localStorage.setItem(\"theme\", defaultTheme);\n document.documentElement.classList.add(`${defaultTheme}-theme`);\n }\n }\n attributeChangedCallback(name, oldValue, newValue) {\n super.attributeChangedCallback(name, oldValue, newValue);\n if (name === \"type\" && oldValue !== newValue) {\n // Type changed, reinitialize values\n this.initializeValues();\n }\n }\n async setupInitialValue() {\n if (this.type === \"language\") {\n // Get current language\n const currentLang = currentLanguage.value;\n this.currentValue = currentLang;\n // Update label\n this.label = this.getLabel();\n }\n else if (this.type === \"theme\") {\n // Get current theme\n const currentThemeValue = currentTheme.get();\n this.currentValue = currentThemeValue;\n // Update label\n this.label = this.getLabel();\n }\n else if (this.type === \"accent-color\") {\n // Get current accent color\n const currentAccentColor = getAccentColor();\n this.currentValue = currentAccentColor;\n // Apply the accent color to ensure it's active\n applyAccentColor();\n // Update label\n this.label = this.getLabel();\n }\n else if (this.type === \"notes-style-medium\") {\n // Get current notes style medium\n const currentNotesStyle = getNotesStyleMedium();\n this.currentValue = currentNotesStyle;\n // Check if this should be disabled based on note behavior\n const currentPageStyle = getPageStyle();\n this.disabled = currentPageStyle === \"note\";\n // Update label\n this.label = this.getLabel();\n }\n else if (this.type === \"page-style\") {\n // Get current page style\n const currentPageStyle = getPageStyle();\n this.currentValue = currentPageStyle;\n // Update label\n this.label = this.getLabel();\n }\n else if (this.type === \"icon-only\") {\n // Get current page style for icon-only\n const currentPageStyle = getPageStyle();\n this.currentValue = currentPageStyle;\n // Update label\n this.label = \"\";\n }\n this.requestUpdate();\n }\n handleSettingsChanges() {\n // Handle any settings changes that might affect this component\n this.setupInitialValue();\n }\n disconnectedCallback() {\n super.disconnectedCallback();\n // Remove event listeners\n window.removeEventListener(\"translations-loaded\", this.boundHandlers.translationsLoaded);\n window.removeEventListener(\"language-changed\", this.boundHandlers.languageChanged);\n window.removeEventListener(\"theme-changed\", this.boundHandlers.handleThemeChanged);\n window.removeEventListener(\"accent-color-changed\", this.boundHandlers.handleAccentColorChanged);\n window.removeEventListener(\"page-style-changed\", this.boundHandlers.handleNoteBehaviorChanged);\n }\n handleButtonClick(e) {\n e.preventDefault();\n e.stopPropagation();\n // Don't handle clicks if disabled\n if (this.disabled) {\n return;\n }\n if (this.type === \"language\") {\n // Cycle through available languages\n const currentIndex = this.values.indexOf(this.currentValue);\n const nextIndex = (currentIndex + 1) % this.values.length;\n const newLanguage = this.values[nextIndex];\n // Update current value\n this.currentValue = newLanguage;\n // Set the new language with view transition like Portfolio\n if (document.startViewTransition) {\n document.startViewTransition(() => {\n setLanguage(newLanguage);\n });\n }\n else {\n setLanguage(newLanguage);\n }\n // Save preferences\n savePreferences({ language: newLanguage });\n // Dispatch language change event\n window.dispatchEvent(new CustomEvent(\"language-changed\", {\n detail: { language: newLanguage },\n }));\n }\n else if (this.type === \"theme\") {\n // Cycle through themes\n const currentIndex = this.values.indexOf(this.currentValue);\n const nextIndex = (currentIndex + 1) % this.values.length;\n const newTheme = this.values[nextIndex];\n // Update current value\n this.currentValue = newTheme;\n // Set the new theme using the shared helper\n setTheme(newTheme);\n // Save preferences\n savePreferences({ theme: newTheme });\n // Theme helper already emits the change event, so no manual dispatch here\n }\n else if (this.type === \"accent-color\") {\n // Cycle through accent colors\n const currentIndex = this.values.indexOf(this.currentValue);\n const nextIndex = (currentIndex + 1) % this.values.length;\n const newColor = this.values[nextIndex];\n // Update current value\n this.currentValue = newColor;\n // Save the new accent color\n saveAccentColor(newColor);\n // Apply the new accent color\n applyAccentColor();\n // Save preferences\n savePreferences({ accentColor: newColor });\n // Dispatch accent color change event\n window.dispatchEvent(new CustomEvent(\"accent-color-changed\", {\n detail: { color: newColor },\n }));\n }\n else if (this.type === \"notes-style-medium\") {\n // Cycle through notes style medium options\n const currentIndex = this.values.indexOf(this.currentValue);\n const nextIndex = (currentIndex + 1) % this.values.length;\n const newStyle = this.values[nextIndex];\n // Update current value\n this.currentValue = newStyle;\n // Save the new notes style medium\n saveNotesStyleMedium(newStyle);\n // Save preferences\n savePreferences({ notesStyleMedium: newStyle });\n // Dispatch notes style medium change event\n window.dispatchEvent(new CustomEvent(\"notes-style-medium-changed\", {\n detail: { style: newStyle },\n }));\n }\n else if (this.type === \"page-style\") {\n // Cycle through note behavior options\n const currentIndex = this.values.indexOf(this.currentValue);\n const nextIndex = (currentIndex + 1) % this.values.length;\n const newBehavior = this.values[nextIndex];\n // Update current value\n this.currentValue = newBehavior;\n // Save the new note behavior\n savePageStyle(newBehavior);\n // Save preferences\n savePreferences({ pageStyle: newBehavior });\n // Dispatch note behavior change event\n window.dispatchEvent(new CustomEvent(\"page-style-changed\", {\n detail: { behavior: newBehavior },\n }));\n }\n else if (this.type === \"icon-only\") {\n // Cycle through icon-only options (note/page)\n const currentIndex = this.values.indexOf(this.currentValue);\n const nextIndex = (currentIndex + 1) % this.values.length;\n const newIconOnlyValue = this.values[nextIndex];\n // Update current value\n this.currentValue = newIconOnlyValue;\n // Save the new page style\n savePageStyle(newIconOnlyValue);\n // Save preferences\n savePreferences({ pageStyle: newIconOnlyValue });\n // No label update for icon-only type\n this.label = \"\";\n // Dispatch page style change event\n window.dispatchEvent(new CustomEvent(\"page-style-changed\", {\n detail: { behavior: newIconOnlyValue },\n }));\n }\n // Update label\n this.label = this.getLabel();\n // Request update to re-render\n this.requestUpdate();\n }\n getValueDisplay(value) {\n if (this.type === \"language\") {\n return getLanguageDisplayName(value, {\n locale: currentLanguage.value,\n });\n }\n else if (this.type === \"theme\") {\n // Try to get translated theme name\n if (this.translationsReady) {\n const translatedName = translate(`themes.${value}`);\n if (translatedName && translatedName !== `themes.${value}`) {\n return translatedName;\n }\n }\n // Fall back to the theme value itself\n return value;\n }\n else if (this.type === \"accent-color\") {\n // Get color name from CSS variable\n return this.getColorName(value);\n }\n else if (this.type === \"notes-style-medium\") {\n // Return SVG icon for notes style medium\n return this.getNotesStyleIcon(value);\n }\n else if (this.type === \"page-style\") {\n // Return translated text for note behavior\n if (this.translationsReady) {\n const translatedText = translate(value === \"note\" ? \"note\" : \"page\");\n if (translatedText &&\n translatedText !== (value === \"note\" ? \"note\" : \"page\")) {\n return translatedText;\n }\n }\n return value;\n }\n else if (this.type === \"icon-only\") {\n // Return SVG icon for icon-only type (note/page icons)\n if (value === \"note\") {\n return html `<ds-icon type=\"note\"></ds-icon>`;\n }\n else if (value === \"page\") {\n return html `<ds-icon type=\"page\"></ds-icon>`;\n }\n return html `<span>${value}</span>`;\n }\n return value;\n }\n getColorName(colorVar) {\n // Map CSS variables to language keys\n const colorMap = {\n \"--red\": \"red\",\n \"--orange\": \"orange\",\n \"--yellow\": \"yellow\",\n \"--light-green\": \"lightGreen\",\n \"--green\": \"green\",\n \"--light-blue\": \"lightBlue\",\n \"--blue\": \"blue\",\n \"--pink\": \"pink\",\n };\n const languageKey = colorMap[colorVar];\n if (languageKey && this.translationsReady) {\n const translatedName = translate(languageKey);\n if (translatedName && translatedName !== languageKey) {\n return translatedName;\n }\n }\n // Fallback to simple name conversion\n return colorVar.replace(\"--\", \"\").replace(\"-\", \" \");\n }\n getNotesStyleIcon(style) {\n if (style === \"page\") {\n return html `<ds-icon type=\"page\"></ds-icon>`;\n }\n else if (style === \"note\") {\n return html `<ds-icon type=\"note\"></ds-icon>`;\n }\n else if (style === \"default\") {\n return html `<ds-icon type=\"default\"></ds-icon>`;\n }\n else if (style === \"big\") {\n return html `<ds-icon type=\"big\"></ds-icon>`;\n }\n else if (style === \"gallery\") {\n return html `<ds-icon type=\"gallery\"></ds-icon>`;\n }\n return html `<span>${style}</span>`;\n }\n getLabel() {\n if (this.type === \"language\") {\n // Try to get translated label\n if (this.translationsReady) {\n const translatedLabel = translate(\"language\");\n if (translatedLabel && translatedLabel !== \"language\") {\n return translatedLabel;\n }\n }\n // Fall back to English\n return \"Language\";\n }\n else if (this.type === \"theme\") {\n // Try to get translated label\n if (this.translationsReady) {\n const translatedLabel = translate(\"theme\");\n if (translatedLabel && translatedLabel !== \"theme\") {\n return translatedLabel;\n }\n }\n // Fall back to English\n return \"Theme\";\n }\n else if (this.type === \"accent-color\") {\n // Try to get translated label\n if (this.translationsReady) {\n const translatedLabel = translate(\"accentColor\");\n if (translatedLabel && translatedLabel !== \"accentColor\") {\n return translatedLabel;\n }\n }\n // Fall back to English\n return \"Accent Color\";\n }\n else if (this.type === \"notes-style-medium\") {\n // Try to get translated label\n if (this.translationsReady) {\n const translatedLabel = translate(\"notesStyle\");\n if (translatedLabel && translatedLabel !== \"notesStyle\") {\n return translatedLabel;\n }\n }\n // Fall back to English\n return \"Notes Style\";\n }\n else if (this.type === \"page-style\") {\n // Try to get translated label\n if (this.translationsReady) {\n const translatedLabel = translate(\"clickingItem\");\n if (translatedLabel && translatedLabel !== \"clickingItem\") {\n return translatedLabel;\n }\n }\n // Fall back to English\n return \"Clic\";\n }\n else if (this.type === \"icon-only\") {\n // No label for icon-only type\n return \"\";\n }\n return this.label;\n }\n render() {\n return html `\n <div class=\"cycle-container\">\n ${this.type !== \"icon-only\"\n ? html `<span class=\"cycle-label\">${this.label}</span>`\n : \"\"}\n <div\n style=\"display: flex; align-items: center; ${this.type === \"icon-only\"\n ? \"justify-content: center;\"\n : \"\"}\"\n >\n <ds-button\n variant=${this.variant ||\n (this.type === \"language\" || this.type === \"theme\"\n ? \"secondary\"\n : \"primary\")}\n ?disabled=${this.disabled}\n @click=${this.handleButtonClick}\n >\n ${this.type === \"notes-style-medium\" || this.type === \"icon-only\"\n ? html `<span\n style=\"display: inline-flex; align-items: center; gap: var(--025)\"\n >${this.getValueDisplay(this.currentValue)}</span\n >`\n : html `<span>${this.getValueDisplay(this.currentValue)}</span>`}\n </ds-button>\n ${this.type === \"accent-color\"\n ? html `\n <div\n class=\"color-preview\"\n style=\"background-color: var(${this.currentValue})\"\n ></div>\n `\n : \"\"}\n </div>\n </div>\n `;\n }\n async waitForTranslations() {\n return new Promise((resolve) => {\n if (this.translationsReady) {\n resolve();\n return;\n }\n const handleTranslationsLoaded = () => {\n this.translationsReady = true;\n resolve();\n };\n window.addEventListener(\"translations-loaded\", handleTranslationsLoaded, {\n once: true,\n });\n // Timeout after 5 seconds\n setTimeout(() => {\n this.translationsReady = true;\n resolve();\n }, 5000);\n });\n }\n handleTranslationsLoaded() {\n this.translationsReady = true;\n // Refresh language values if this is a language cycle\n if (this.type === \"language\") {\n const availableLanguages = getAvailableLanguagesSync();\n this.values = availableLanguages;\n }\n this.setupInitialValue();\n }\n handleLanguageChanged() {\n this.setupInitialValue();\n }\n handleThemeChanged() {\n this.setupInitialValue();\n }\n handleAccentColorChanged() {\n this.setupInitialValue();\n }\n handleNoteBehaviorChanged() {\n this.setupInitialValue();\n }\n}\nCycle.styles = css `\n .cycle-container {\n display: flex;\n justify-content: space-between;\n gap: var(--025);\n width: 100%;\n }\n\n .cycle-label {\n color: var(--text-color-primary);\n }\n `;\ncustomElements.define(\"ds-cycle\", Cycle);\n", "import { LitElement, html, css } from \"lit\";\nimport { getText } from \"../0-face/i18n\";\n/**\n * A component for displaying text from translations\n *\n * @element ds-text\n * @prop {string} key - The translation key to use\n * @prop {string} defaultValue - Default value if translation is not found\n * @prop {string} fallback - Optional fallback text if translation is not found (deprecated, use defaultValue)\n */\nexport class Text extends LitElement {\n static get properties() {\n return {\n key: { type: String, reflect: true },\n defaultValue: { type: String, reflect: true, attribute: \"default-value\" },\n fallback: { type: String, reflect: true }, // Kept for backward compatibility\n _text: { type: String, state: true },\n };\n }\n constructor() {\n super();\n this.key = \"\";\n this.defaultValue = \"\";\n this.fallback = \"\";\n this._text = \"\";\n // Create bound event handlers for proper cleanup\n this.boundHandlers = {\n languageChanged: (() => {\n console.log(\"Language changed event received in ds-text\");\n this._loadText();\n }),\n };\n }\n connectedCallback() {\n super.connectedCallback();\n this._loadText();\n // Listen for language changes\n window.addEventListener(\"language-changed\", this.boundHandlers.languageChanged);\n // Also listen for translations loaded event\n window.addEventListener(\"translations-loaded\", this.boundHandlers.languageChanged);\n // Listen for language changes via events instead of signals\n // The currentLanguage signal changes will trigger the language-changed event\n }\n disconnectedCallback() {\n super.disconnectedCallback();\n window.removeEventListener(\"language-changed\", this.boundHandlers.languageChanged);\n window.removeEventListener(\"translations-loaded\", this.boundHandlers.languageChanged);\n }\n updated(changedProperties) {\n super.updated(changedProperties);\n if (changedProperties.has(\"key\") || changedProperties.has(\"defaultValue\")) {\n this._loadText();\n }\n }\n _loadText() {\n if (!this.key) {\n this._text = this.defaultValue || this.fallback || \"\";\n return;\n }\n try {\n const text = getText(this.key);\n this._text = text || this.defaultValue || this.fallback || this.key;\n }\n catch (error) {\n console.error(\"Error loading text for key:\", this.key, error);\n this._text = this.defaultValue || this.fallback || this.key;\n }\n this.requestUpdate();\n }\n render() {\n return html `<span>${this._text || this.defaultValue || this.key}</span>`;\n }\n}\nText.styles = css `\n :host {\n display: inline;\n }\n\n .loading {\n opacity: 0.6;\n }\n `;\ncustomElements.define(\"ds-text\", Text);\n", "import { LitElement, html, css } from \"lit\";\nimport { translate, getNotionText } from \"../0-face/i18n\";\nexport class Tooltip extends LitElement {\n constructor() {\n super();\n this.key = \"\";\n this.defaultValue = \"\";\n this._text = \"\";\n this._visible = false;\n this.boundWindowHandlers = {\n languageChanged: (() => {\n this._loadText();\n }),\n translationsLoaded: (() => {\n this._loadText();\n }),\n };\n this.boundHostHandlers = {\n mouseenter: (() => {\n this._visible = true;\n this.requestUpdate();\n }),\n mouseleave: (() => {\n this._visible = false;\n this.requestUpdate();\n }),\n focusin: (() => {\n this._visible = true;\n this.requestUpdate();\n }),\n focusout: (() => {\n this._visible = false;\n this.requestUpdate();\n }),\n };\n }\n connectedCallback() {\n super.connectedCallback();\n this._loadText();\n window.addEventListener(\"language-changed\", this.boundWindowHandlers.languageChanged);\n window.addEventListener(\"translations-loaded\", this.boundWindowHandlers.translationsLoaded);\n this.addEventListener(\"mouseenter\", this.boundHostHandlers.mouseenter);\n this.addEventListener(\"mouseleave\", this.boundHostHandlers.mouseleave);\n this.addEventListener(\"focusin\", this.boundHostHandlers.focusin);\n this.addEventListener(\"focusout\", this.boundHostHandlers.focusout);\n }\n disconnectedCallback() {\n super.disconnectedCallback();\n window.removeEventListener(\"language-changed\", this.boundWindowHandlers.languageChanged);\n window.removeEventListener(\"translations-loaded\", this.boundWindowHandlers.translationsLoaded);\n this.removeEventListener(\"mouseenter\", this.boundHostHandlers.mouseenter);\n this.removeEventListener(\"mouseleave\", this.boundHostHandlers.mouseleave);\n this.removeEventListener(\"focusin\", this.boundHostHandlers.focusin);\n this.removeEventListener(\"focusout\", this.boundHostHandlers.focusout);\n }\n updated(changed) {\n if (changed.has(\"key\") || changed.has(\"defaultValue\")) {\n this._loadText();\n }\n }\n async _loadText() {\n if (!this.key) {\n this._text = this.defaultValue || \"\";\n this.requestUpdate();\n return;\n }\n try {\n const notionText = await getNotionText(this.key);\n if (notionText) {\n this._text = notionText;\n this.requestUpdate();\n return;\n }\n const t = translate(this.key);\n this._text = t && t !== this.key ? t : this.defaultValue || this.key;\n }\n catch (err) {\n console.error(\"ds-tooltip: error loading text for key\", this.key, err);\n this._text = this.defaultValue || this.key;\n }\n this.requestUpdate();\n }\n render() {\n const bubbleClasses = [\"bubble\", this._visible ? \"visible\" : \"\"].join(\" \");\n return html `\n <span class=\"slot-wrapper\"><slot></slot></span>\n ${this._text\n ? html `<div class=\"${bubbleClasses}\">${this._text}</div>`\n : null}\n `;\n }\n}\nTooltip.properties = {\n key: { type: String, reflect: true },\n defaultValue: { type: String, reflect: true, attribute: \"default-value\" },\n _text: { state: true },\n _visible: { state: true },\n};\nTooltip.styles = css `\n :host {\n position: relative;\n display: inline-block;\n }\n\n .slot-wrapper {\n display: inline-flex;\n align-items: center;\n }\n\n .bubble {\n display: flex;\n align-items: center;\n justify-content: center;\n position: absolute;\n left: 50%;\n bottom: 100%;\n transform: translate(-50%, calc(-2px * var(--scaling-factor)));\n z-index: 1000;\n pointer-events: none;\n height: calc(var(--08) * var(--scaling-factor));\n opacity: 0;\n transition:\n opacity 120ms ease,\n transform 120ms ease;\n background-color: light-dark(var(--black), var(--white));\n color: light-dark(var(--white), var(--black));\n border-radius: 0;\n font-size: var(--type-size-default);\n padding: 0px calc(1px * var(--scaling-factor));\n font-family: var(\n --typeface,\n -apple-system,\n BlinkMacSystemFont,\n \"Segoe UI\",\n Roboto,\n sans-serif\n );\n font-weight: 500;\n white-space: nowrap;\n min-width: max-content;\n }\n\n .bubble.visible {\n opacity: 1;\n }\n `;\ncustomElements.define(\"ds-tooltip\", Tooltip);\n", "import { LitElement, html, css } from \"lit\";\n/**\n * A component for displaying the current year\n *\n * @element ds-date\n */\nexport class DateComponent extends LitElement {\n render() {\n const year = new Date().getFullYear();\n return html `<span>${year}</span>`;\n }\n}\nDateComponent.styles = css `\n :host {\n display: inline;\n font-family: var(--typeface, var(--typeface-regular));\n font-size: inherit;\n color: inherit;\n }\n `;\ncustomElements.define(\"ds-date\", DateComponent);\n", "import { LitElement, html, css } from \"lit\";\nexport class List extends LitElement {\n render() {\n return html `<slot></slot>`;\n }\n}\nList.styles = css `\n :host {\n display: flex;\n flex-direction: column;\n gap: 0;\n width: 100%;\n }\n `;\ncustomElements.define(\"ds-list\", List);\n", "import { LitElement, html, css } from \"lit\";\nexport class Row extends LitElement {\n constructor() {\n super();\n this.type = \"fill\";\n }\n render() {\n return html `<slot></slot>`;\n }\n}\nRow.properties = {\n type: { type: String, reflect: true },\n};\nRow.styles = css `\n :host {\n display: flex;\n align-items: end;\n width: calc(240px * var(--scaling-factor));\n }\n\n :host([type=\"fill\"]) {\n justify-content: space-between;\n height: calc(var(--1) * var(--scaling-factor));\n }\n\n :host([type=\"centered\"]) {\n justify-content: center;\n height: calc(var(--1) * var(--scaling-factor));\n gap: calc(var(--025) * var(--scaling-factor));\n }\n `;\ncustomElements.define(\"ds-row\", Row);\n", "// ds-table.ts\n// Data table component\nimport { LitElement, html, css } from \"lit\";\nexport class DsTable extends LitElement {\n constructor() {\n super();\n this.data = [];\n this.columns = [\"Product\", \"Users\", \"Retention\"];\n this.showStatus = true;\n }\n render() {\n return html `\n <div class=\"table-container\">\n <div class=\"table-header\">\n \n <div class=\"header-cell product-cell\">Product</div>\n <div class=\"header-cell users-cell\">Users</div>\n <div class=\"header-cell retention-cell\">Retention</div>\n ${this.showStatus ? html `<div class=\"header-cell\">Status</div>` : \"\"}\n </div>\n <div class=\"table-body\">\n ${this.data.map((row, rowIndex) => html `\n <div class=\"data-cell product-cell\">${row.product}</div>\n <div class=\"data-cell users-cell\">${row.users}</div>\n <div class=\"data-cell retention-cell\">${row.retention}</div>\n ${this.showStatus\n ? html `<div class=\"data-cell status-cell\">\n ${row.status || \"Pending\"}\n </div>`\n : \"\"}\n `)}\n </div>\n </div>\n `;\n }\n}\nDsTable.properties = {\n data: { type: Array },\n columns: { type: Array },\n showStatus: { type: Boolean, attribute: \"show-status\" },\n};\nDsTable.styles = css `\n :host {\n display: block;\n width: 100%;\n }\n\n .table-container {\n display: flex;\n flex-direction: column;\n width: 100%;\n }\n\n .table-header {\n display: grid;\n grid-template-columns: 160px 80px 80px 80px;\n height: 20px;\n width: 400px;\n }\n\n .table-body {\n display: grid;\n grid-template-columns: 160px 80px 80px 80px;\n border: 1px solid var(--black);\n width: 400px;\n }\n\n .header-cell {\n height: 20px;\n display: flex;\n align-items: center;\n justify-content: left;\n padding: 0 2px;\n font-family: var(--typeface);\n font-size: var(--type-size-default);\n font-weight: var(--type-weight-default);\n line-height: var(--type-lineheight-default);\n color: var(--black);\n letter-spacing: -0.26px;\n }\n\n .data-cell {\n height: 20px;\n margin-top: -1px;\n display: flex;\n align-items: center;\n justify-content: left;\n \n outline: 1px solid var(--black);\n\n font-family: var(--typeface);\n font-size: var(--type-size-default);\n font-weight: var(--type-weight-default);\n line-height: var(--type-lineheight-default);\n color: var(--black);\n letter-spacing: -0.26px;\n }\n\n .status-cell {\n background-color: var(--light-green);\n }\n\n .product-cell {\n text-align: left;\n justify-content: flex-start;\n }\n\n .users-cell,\n .retention-cell {\n text-align: center;\n }\n\n .status-cell {\n text-align: center;\n }\n\n /* Responsive adjustments */\n @media (max-width: 480px) {\n .table-header,\n .table-body {\n width: 100%;\n grid-template-columns: 1fr 60px 60px 60px;\n }\n }\n `;\ncustomElements.define(\"ds-table\", DsTable);\n", "// ds-grid.ts\n// Simple grid layout component\nimport { LitElement, html, css } from \"lit\";\nimport { detectMobileDevice } from \"../0-face/device\";\nexport class Grid extends LitElement {\n constructor() {\n super(...arguments);\n this._isMobile = false;\n }\n connectedCallback() {\n super.connectedCallback();\n this._isMobile = detectMobileDevice();\n console.log(`[ds-grid] Mobile device: ${this._isMobile}`);\n // Apply mobile class immediately\n if (this._isMobile) {\n this.classList.add(\"mobile\");\n console.log(`[ds-grid] Mobile class added`);\n }\n // Calculate mobile grid dimensions to fit screen\n if (this._isMobile && typeof window !== \"undefined\") {\n const screenWidth = window.innerWidth;\n const columns = 14;\n const gap = 0.5;\n // Calculate column size accounting for gaps between columns\n // Total width = (columns * columnSize) + ((columns - 1) * gap)\n // Therefore: columnSize = (screenWidth - ((columns - 1) * gap)) / columns\n const totalGapWidth = (columns - 1) * gap;\n const columnSize = (screenWidth - totalGapWidth) / columns;\n console.log(`[ds-grid] Mobile grid: ${columns} columns \u00D7 ${columnSize.toFixed(2)}px + ${totalGapWidth}px gaps = ${screenWidth}px`);\n // Set custom property for this grid instance\n this.style.setProperty(\"--mobile-column-size\", `${columnSize}px`);\n this.style.setProperty(\"--mobile-gap\", `${gap}px`);\n }\n }\n updated() {\n // Apply mobile class if detected as mobile device\n if (this._isMobile) {\n this.classList.add(\"mobile\");\n }\n else {\n this.classList.remove(\"mobile\");\n }\n }\n render() {\n return html ``;\n }\n}\nGrid.properties = {\n align: { type: String },\n _isMobile: { type: Boolean, state: true },\n};\nGrid.styles = css `\n :host {\n margin-top: 0.5px !important;\n margin-left: 0.5px !important;\n display: grid;\n width: 1440px;\n height: 100%;\n grid-template-columns: repeat(auto-fill, 19px);\n grid-template-rows: repeat(auto-fill, 19px);\n gap: 1px;\n row-rule: calc(1px * var(--scaling-factor)) solid\n light-dark(rgb(147, 147, 147), rgb(147, 147, 147));\n column-rule: calc(1px * var(--scaling-factor)) solid\n light-dark(rgb(147, 147, 147), rgb(147, 147, 147));\n outline:\n 1px solid light-dark(rgb(147, 147, 147)),\n rgb(147, 147, 147);\n position: fixed;\n top: 0;\n left: 50%;\n transform: translateX(-50%);\n pointer-events: none;\n z-index: 300;\n }\n\n /* DO NOT CHANGE THIS GRID CODE FOR MOBILE. ITS PERFECT FOR MOBILE. */\n :host(.mobile) {\n outline: calc(2px * var(--scaling-factor)) solid rgba(251, 255, 0, 0.9);\n width: calc(100% - calc(1px * var(--scaling-factor)));\n max-width: 100vw;\n margin-left: 0 !important;\n margin-top: 0 !important;\n box-sizing: border-box;\n position: fixed;\n top: calc(0.5px * var(--scaling-factor));\n left: 50%;\n transform: translateX(-50%);\n pointer-events: none;\n z-index: 300;\n gap: calc(1px * var(--scaling-factor));\n grid-template-columns: repeat(14, calc(19px * var(--scaling-factor)));\n grid-template-rows: repeat(auto-fill, calc(19px * var(--scaling-factor)));\n }\n\n :host([align=\"left\"]) {\n left: 0;\n transform: none;\n }\n\n :host([align=\"center\"]) {\n left: 50%;\n transform: translateX(-50%);\n }\n\n :host([align=\"right\"]) {\n left: auto;\n right: 0;\n transform: none;\n }\n `;\ncustomElements.define(\"ds-grid\", Grid);\n", "// ds-layout.ts\n// Simple grid layout component with debug mode\nimport { LitElement, html, css } from \"lit\";\nexport class Layout extends LitElement {\n render() {\n const isDebug = this.debug || this.mode === \"debug\";\n const isCompany = this.mode === \"company\";\n return html `\n <slot></slot>\n ${isDebug\n ? html `\n <div class=\"debug-overlay\">\n ${isCompany\n ? html `\n <div class=\"debug-area debug-header\">header</div>\n <div class=\"debug-area debug-content\">content</div>\n <div class=\"debug-area debug-footer\">footer</div>\n `\n : html `\n <div class=\"debug-area debug-square\">square</div>\n <div class=\"debug-area debug-title\">title</div>\n <div class=\"debug-area debug-header\">header</div>\n <div class=\"debug-area debug-projects\">projects</div>\n <div class=\"debug-area debug-bio\">bio</div>\n <div class=\"debug-area debug-nav\">nav</div>\n <div class=\"debug-area debug-footer\">footer</div>\n `}\n </div>\n `\n : \"\"}\n `;\n }\n}\nLayout.properties = {\n mode: { type: String },\n align: { type: String },\n debug: { type: Boolean },\n};\nLayout.styles = css `\n :host {\n display: grid;\n grid-template-columns: 120px 480px 40px;\n grid-template-rows: 120px 120px 60px 180px 60px 120px 60px 20px 120px 120px;\n grid-template-areas:\n \"square . .\"\n \". title .\"\n \". header .\"\n \". projects .\"\n \". . .\"\n \". bio .\"\n \". . .\"\n \". nav .\"\n \". . .\"\n \". footer .\"\n \". . .\";\n min-height: 600px;\n background-color: rgba(165, 165, 165, 0.03);\n position: relative;\n width: 100%;\n max-width: 640px;\n margin: 0 auto;\n }\n\n :host([mode=\"company\"]) {\n grid-template-columns: auto 400px auto;\n grid-template-rows: 80px 20px 20px 120px 20px 120px;\n grid-template-areas:\n \". . .\"\n \". header .\"\n \". . .\"\n \". content .\"\n \". . .\"\n \". footer .\";\n gap: 0;\n max-width: 100%;\n }\n\n :host([align=\"left\"]) {\n margin: 0;\n justify-self: start;\n }\n\n :host([align=\"center\"]) {\n margin: 0 auto;\n justify-self: center;\n }\n\n :host([align=\"right\"]) {\n margin: 0 0 0 auto;\n justify-self: end;\n }\n\n .debug-overlay {\n position: absolute;\n margin-left: -1px;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n pointer-events: none;\n z-index: 1000;\n display: grid;\n font-size: 18px;\n font-weight: bold;\n grid-template-columns: 120px 480px;\n grid-template-rows: 120px 120px 60px 180px 60px 120px 60px 20px 120px 120px;\n grid-template-areas:\n \"square .\"\n \". title\"\n \". header\"\n \". projects\"\n \". .\"\n \". bio\"\n \". .\"\n \". nav\"\n \". .\"\n \". footer\"\n \". .\";\n }\n\n :host([mode=\"company\"]) .debug-overlay {\n grid-template-columns: auto 400px auto;\n grid-template-rows: 80px 20px 20px 120px 20px 120px;\n grid-template-areas:\n \". . .\"\n \". header .\"\n \". . .\"\n \". content .\"\n \". . .\"\n \". footer .\";\n gap: 0;\n }\n\n .debug-area {\n display: flex;\n align-items: center;\n justify-content: center;\n font-size: 10px;\n font-weight: var(--type-weight-default);\n font-family: var(--typeface);\n color: var(--black);\n border: 1px solid red;\n opacity: 1;\n }\n\n .debug-square {\n grid-area: square;\n }\n\n .debug-title {\n grid-area: title;\n }\n\n .debug-header {\n grid-area: header;\n border-color: #0000ff;\n }\n\n .debug-projects {\n grid-area: projects;\n border-color: #ffff00;\n }\n\n .debug-bio {\n grid-area: bio;\n border-color: #ff00ff;\n }\n\n .debug-nav {\n grid-area: nav;\n border-color: #00ffff;\n }\n\n .debug-footer {\n grid-area: footer;\n border-color: #ffa500;\n }\n\n .debug-content {\n grid-area: content;\n border-color: rgba(71, 231, 71, 0.63);\n }\n `;\ncustomElements.define(\"ds-layout\", Layout);\n"],
5
- "mappings": "AAMO,SAASA,IAAqB,CACjC,GAAI,OAAO,UAAc,KAAe,OAAO,OAAW,IACtD,MAAO,GAEX,IAAMC,EAAM,UACNC,EAAM,OACNC,EAAMF,IAAQA,EAAI,WAAaA,EAAI,SAAaC,GAAOA,EAAI,OAAU,GAErEE,EAAkB,qIAAqI,KAAKD,CAAE,EAG9JE,GADeJ,GAAOA,EAAI,gBAAmB,GACd,EAE/BK,EAAiBJ,EACjB,KAAK,IAAIA,EAAI,YAAc,EAAGA,EAAI,aAAe,CAAC,GAAK,IACvD,GACN,OAAOE,GAAoBC,GAAkBC,CACjD,CAIO,SAASC,IAAgB,CAC5B,IAAMC,EAAWR,GAAmB,EAC9BC,EAAM,UACNC,EAAM,OAENG,GADeJ,GAAOA,EAAI,gBAAmB,GACd,EAE/BQ,EAAc,OAAO,SAAa,IAClC,SAAS,gBAAgB,YACzBP,GAAK,YAAc,EACnBQ,EAAe,OAAO,SAAa,IACnC,SAAS,gBAAgB,aAC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AA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAiJhB,eAAe,OAAO,YAAaD,EAAM",
4
+ "sourcesContent": ["// 2025-04-23-device.ts\n// Device detection and context utilities\n/**\n * Comprehensive mobile device detection\n * Combines user agent detection, touch capability, and viewport size\n */\nexport function detectMobileDevice() {\n if (typeof navigator === \"undefined\" || typeof window === \"undefined\") {\n return false;\n }\n const nav = navigator;\n const win = window;\n const ua = (nav && (nav.userAgent || nav.vendor)) || (win && win.opera) || \"\";\n // User agent based detection\n const uaMatchesMobile = /Mobile|Android|iP(ad|hone|od)|IEMobile|BlackBerry|Kindle|Silk-Accelerated|(hpw|web)OS|Opera M(obi|ini)|Windows Phone|Phone|Tablet/i.test(ua);\n // Touch capability detection\n const touchPoints = (nav && nav.maxTouchPoints) || 0;\n const isTouchCapable = touchPoints > 1;\n // Viewport detection\n const narrowViewport = win\n ? Math.min(win.innerWidth || 0, win.innerHeight || 0) <= 820\n : false;\n return uaMatchesMobile || (isTouchCapable && narrowViewport);\n}\n/**\n * Get detailed device information\n */\nexport function getDeviceInfo() {\n const isMobile = detectMobileDevice();\n const nav = navigator;\n const win = window;\n const touchPoints = (nav && nav.maxTouchPoints) || 0;\n const isTouchCapable = touchPoints > 1;\n // Use clientWidth instead of innerWidth to exclude scrollbars\n const screenWidth = typeof document !== \"undefined\"\n ? document.documentElement.clientWidth\n : win?.innerWidth || 0;\n const screenHeight = typeof document !== \"undefined\"\n ? document.documentElement.clientHeight\n : win?.innerHeight || 0;\n const isTablet = isMobile && Math.min(screenWidth, screenHeight) >= 600;\n return {\n isMobile,\n isTablet,\n isDesktop: !isMobile,\n isTouchCapable,\n deviceType: isMobile ? (isTablet ? \"tablet\" : \"mobile\") : \"desktop\",\n userAgent: (nav && (nav.userAgent || nav.vendor)) || \"\",\n screenWidth,\n screenHeight,\n };\n}\n/**\n * Initialize device detection and log to console\n */\nexport function initDeviceDetection() {\n const deviceInfo = getDeviceInfo();\n // Calculate and set scaling factor for mobile\n if (deviceInfo.isMobile && typeof document !== \"undefined\") {\n // Design width: 280px (14 columns \u00D7 20px)\n const designWidth = 280;\n const actualWidth = deviceInfo.screenWidth;\n const scalingFactor = actualWidth / designWidth;\n // Set CSS custom property for scaling\n document.documentElement.style.setProperty(\"--scaling-factor-mobile\", scalingFactor.toFixed(3));\n console.log(`[DS one] Mobile device detected - ${deviceInfo.deviceType} (${deviceInfo.screenWidth}x${deviceInfo.screenHeight}), scaling factor: ${scalingFactor.toFixed(2)}`);\n }\n else {\n // Desktop - no scaling\n if (typeof document !== \"undefined\") {\n document.documentElement.style.setProperty(\"--scaling-factor-mobile\", \"1\");\n }\n console.log(`[DS one] Desktop device detected (${deviceInfo.screenWidth}x${deviceInfo.screenHeight})`);\n }\n // Log additional details in development mode\n if (typeof window !== \"undefined\" && window.DS_ONE_DEBUG) {\n console.log(\"[DS one] Device Info:\", {\n type: deviceInfo.deviceType,\n isMobile: deviceInfo.isMobile,\n isTablet: deviceInfo.isTablet,\n isDesktop: deviceInfo.isDesktop,\n isTouchCapable: deviceInfo.isTouchCapable,\n viewport: `${deviceInfo.screenWidth}x${deviceInfo.screenHeight}`,\n userAgent: deviceInfo.userAgent,\n });\n }\n return deviceInfo;\n}\n// Auto-initialize when module loads\nif (typeof window !== \"undefined\") {\n // Wait for DOM to be ready\n if (document.readyState === \"loading\") {\n document.addEventListener(\"DOMContentLoaded\", () => {\n initDeviceDetection();\n });\n }\n else {\n // DOM is already ready\n initDeviceDetection();\n }\n // Recalculate on resize (debounced)\n let resizeTimeout;\n window.addEventListener(\"resize\", () => {\n clearTimeout(resizeTimeout);\n resizeTimeout = setTimeout(() => {\n initDeviceDetection();\n }, 100);\n });\n}\n", "// Bundled translations (keys.json may not exist - will use external translations if not available)\n// This is a fallback for when external translations aren't loaded\nlet translationKeys = {};\n// Primary language list \u2013 prioritise the 10 requested languages when cycling\nconst LANGUAGE_PRIORITY_ORDER = [\n \"da\",\n \"nb\",\n \"sv\",\n \"pt\",\n \"es\",\n \"zh\",\n \"ko\",\n \"ja\",\n \"en\",\n \"de\",\n];\nconst LANGUAGE_PRIORITY_LOOKUP = new Map(LANGUAGE_PRIORITY_ORDER.map((code, index) => [code, index]));\n// Fallback language names if Intl.DisplayNames is not available\nconst FALLBACK_LANGUAGE_NAMES = {\n da: \"Danish\",\n \"da-dk\": \"Danish\",\n nb: \"Norwegian\",\n \"nb-no\": \"Norwegian\",\n sv: \"Swedish\",\n \"sv-se\": \"Swedish\",\n de: \"German\",\n \"de-de\": \"German\",\n en: \"English\",\n \"en-us\": \"English\",\n pt: \"Portuguese\",\n \"pt-pt\": \"Portuguese\",\n \"pt-br\": \"Portuguese (Brazil)\",\n es: \"Spanish\",\n \"es-es\": \"Spanish\",\n \"es-mx\": \"Spanish (Mexico)\",\n zh: \"Chinese\",\n \"zh-hans\": \"Chinese (Simplified)\",\n \"zh-hant\": \"Chinese (Traditional)\",\n ja: \"Japanese\",\n \"ja-jp\": \"Japanese\",\n ko: \"Korean\",\n \"ko-kr\": \"Korean\",\n};\nconst DISPLAY_NAME_CACHE = new Map();\nlet displayNameFallbackWarningShown = false;\n// CDN Loader: Automatically detects and loads translation JSON files\n// for CDN users who want to use external translations\nconst DEFAULT_TRANSLATION_FILE = \"./translations.json\";\nlet loadAttempted = false;\nfunction normalizeCandidate(path) {\n if (!path) {\n return null;\n }\n const trimmed = path.trim();\n if (!trimmed) {\n return null;\n }\n if (trimmed.startsWith(\"./\") ||\n trimmed.startsWith(\"../\") ||\n trimmed.startsWith(\"/\") ||\n /^https?:\\/\\//i.test(trimmed)) {\n return trimmed;\n }\n return `./${trimmed}`;\n}\nfunction findAttributeCandidate() {\n if (typeof document === \"undefined\") {\n return null;\n }\n const scriptWithAttribute = document.querySelector(\"script[data-ds-one-translations]\");\n const scriptCandidate = scriptWithAttribute?.getAttribute(\"data-ds-one-translations\");\n if (scriptCandidate) {\n return scriptCandidate;\n }\n const metaCandidate = document\n .querySelector('meta[name=\"ds-one:translations\"]')\n ?.getAttribute(\"content\");\n if (metaCandidate) {\n return metaCandidate;\n }\n const linkCandidate = document\n .querySelector('link[rel=\"ds-one-translations\"]')\n ?.getAttribute(\"href\");\n if (linkCandidate) {\n return linkCandidate;\n }\n return null;\n}\nfunction resolveTranslationSources() {\n const candidates = [];\n const windowCandidate = typeof window !== \"undefined\" ? window.DS_ONE_TRANSLATIONS_FILE : null;\n const attributeCandidate = findAttributeCandidate();\n // Only use explicitly configured paths, or the single default\n const windowNormalized = normalizeCandidate(windowCandidate ?? \"\");\n if (windowNormalized) {\n candidates.push(windowNormalized);\n }\n const attrNormalized = normalizeCandidate(attributeCandidate ?? \"\");\n if (attrNormalized && !candidates.includes(attrNormalized)) {\n candidates.push(attrNormalized);\n }\n // Only try default if no explicit path was configured\n if (candidates.length === 0) {\n candidates.push(DEFAULT_TRANSLATION_FILE);\n }\n return candidates;\n}\nfunction validateTranslationMap(candidate) {\n if (!candidate || typeof candidate !== \"object\") {\n return false;\n }\n return Object.values(candidate).every((entry) => entry && typeof entry === \"object\");\n}\nasync function fetchTranslationFile(source) {\n try {\n const response = await fetch(source);\n if (!response.ok) {\n // 404 is expected if no translations file exists - don't log as error\n return null;\n }\n const translations = await response.json();\n if (!validateTranslationMap(translations)) {\n console.warn(`[DS one] Invalid translation format in ${source}. Expected object with language codes as keys.`);\n return null;\n }\n const languages = Object.keys(translations);\n if (languages.length === 0) {\n console.warn(`[DS one] No languages found in ${source}`);\n return null;\n }\n return translations;\n }\n catch {\n // Silently fail - file likely doesn't exist or isn't valid JSON\n return null;\n }\n}\n/**\n * Attempts to load translations from a JSON file in the same directory\n */\nasync function loadExternalTranslations() {\n // Only attempt once\n if (loadAttempted) {\n return false;\n }\n loadAttempted = true;\n if (typeof window === \"undefined\") {\n return false;\n }\n // Check if translations are already loaded (e.g., by the application)\n if (window.DS_ONE_TRANSLATIONS &&\n Object.keys(window.DS_ONE_TRANSLATIONS).length > 0) {\n console.log(`[DS one] Translations already loaded (${Object.keys(window.DS_ONE_TRANSLATIONS).length} languages), skipping auto-load`);\n return true;\n }\n const sources = resolveTranslationSources();\n for (const source of sources) {\n const translations = await fetchTranslationFile(source);\n if (!translations) {\n continue;\n }\n window.DS_ONE_TRANSLATIONS = translations;\n const languages = Object.keys(translations);\n console.log(`[DS one] External translations loaded from ${source}: ${languages.length} language(s) \u2013 ${languages.join(\", \")}`);\n window.dispatchEvent(new CustomEvent(\"translations-ready\"));\n return true;\n }\n console.info(`[DS one] No external translations found at ${sources[0] ?? DEFAULT_TRANSLATION_FILE}. Using bundled translations.`);\n return false;\n}\n// Get translation data - prioritize external, fall back to bundled\nfunction getTranslationData() {\n // Check for externally loaded translations first (CDN usage)\n if (typeof window !== \"undefined\" && window.DS_ONE_TRANSLATIONS) {\n return window.DS_ONE_TRANSLATIONS;\n }\n // Fall back to bundled translations\n return translationKeys;\n}\n// Cached translation data - use getter to always get fresh data\nlet translationData = getTranslationData();\nconst notionStore = new Map();\nconst defaultLanguage = \"en\";\nfunction extractPrimarySubtag(code) {\n if (!code) {\n return \"\";\n }\n return code.toLowerCase().split(/[-_]/)[0] ?? \"\";\n}\nfunction getLanguagePriority(code) {\n const primary = extractPrimarySubtag(code);\n const priority = LANGUAGE_PRIORITY_LOOKUP.get(primary);\n if (typeof priority === \"number\") {\n return priority;\n }\n return LANGUAGE_PRIORITY_ORDER.length;\n}\nfunction sortLanguageCodes(codes) {\n return [...codes].sort((a, b) => {\n const priorityA = getLanguagePriority(a);\n const priorityB = getLanguagePriority(b);\n if (priorityA !== priorityB) {\n return priorityA - priorityB;\n }\n return a.localeCompare(b);\n });\n}\nfunction getDisplayNameForLocale(locale, code) {\n const normalizedLocale = locale?.replace(\"_\", \"-\");\n if (!normalizedLocale) {\n return undefined;\n }\n try {\n let displayNames = DISPLAY_NAME_CACHE.get(normalizedLocale);\n if (!displayNames) {\n displayNames = new Intl.DisplayNames([normalizedLocale], {\n type: \"language\",\n });\n DISPLAY_NAME_CACHE.set(normalizedLocale, displayNames);\n }\n const cleanedCode = code.replace(\"_\", \"-\");\n // Try full tag first\n const fullMatch = displayNames.of(cleanedCode);\n if (fullMatch && fullMatch !== cleanedCode) {\n return fullMatch;\n }\n // Then the primary subtag\n const baseMatch = displayNames.of(extractPrimarySubtag(cleanedCode));\n if (baseMatch) {\n return baseMatch;\n }\n }\n catch (error) {\n // Intl.DisplayNames may not be supported; fall back gracefully\n if (!displayNameFallbackWarningShown) {\n console.info(\"[DS one] Intl.DisplayNames is not available, using fallback language names.\");\n displayNameFallbackWarningShown = true;\n }\n }\n return undefined;\n}\nfunction getFallbackDisplayName(code) {\n const normalized = code.toLowerCase().replace(\"_\", \"-\");\n const direct = FALLBACK_LANGUAGE_NAMES[normalized];\n if (direct) {\n return direct;\n }\n const primary = extractPrimarySubtag(normalized);\n return FALLBACK_LANGUAGE_NAMES[primary];\n}\nexport function getLanguageDisplayName(code, options = {}) {\n if (!code) {\n return \"\";\n }\n const localesToTry = [];\n if (options.locale) {\n localesToTry.push(options.locale);\n }\n if (typeof navigator !== \"undefined\") {\n if (Array.isArray(navigator.languages)) {\n localesToTry.push(...navigator.languages);\n }\n if (navigator.language) {\n localesToTry.push(navigator.language);\n }\n }\n localesToTry.push(defaultLanguage);\n localesToTry.push(\"en\");\n const tried = new Set();\n for (const locale of localesToTry) {\n if (!locale || tried.has(locale)) {\n continue;\n }\n tried.add(locale);\n const displayName = getDisplayNameForLocale(locale, code);\n if (displayName) {\n return displayName;\n }\n }\n const fallback = getFallbackDisplayName(code);\n if (fallback) {\n return fallback;\n }\n // Fall back to the primary subtag in uppercase\n const primary = extractPrimarySubtag(code);\n return primary ? primary.toUpperCase() : code;\n}\nconst BROWSER_LANGUAGE_PREFERENCES = {\n da: \"da\",\n \"da-dk\": \"da\",\n no: \"nb\",\n nb: \"nb\",\n \"nb-no\": \"nb\",\n nn: \"nn\",\n \"nn-no\": \"nn\",\n sv: \"sv\",\n \"sv-se\": \"sv\",\n pt: \"pt\",\n \"pt-pt\": \"pt\",\n \"pt-br\": \"pt\",\n es: \"es\",\n \"es-es\": \"es\",\n \"es-mx\": \"es\",\n zh: \"zh\",\n \"zh-cn\": \"zh\",\n \"zh-hans\": \"zh\",\n \"zh-tw\": \"zh\",\n \"zh-hant\": \"zh\",\n ko: \"ko\",\n \"ko-kr\": \"ko\",\n ja: \"ja\",\n \"ja-jp\": \"ja\",\n en: \"en\",\n \"en-us\": \"en\",\n \"en-gb\": \"en\",\n de: \"de\",\n \"de-de\": \"de\",\n};\nfunction resolvePreferredLanguage(languageTag) {\n if (!languageTag) {\n return null;\n }\n const normalized = languageTag.toLowerCase().replace(\"_\", \"-\");\n const directMatch = BROWSER_LANGUAGE_PREFERENCES[normalized];\n if (directMatch) {\n return directMatch;\n }\n const primary = extractPrimarySubtag(normalized);\n const primaryMatch = BROWSER_LANGUAGE_PREFERENCES[primary];\n if (primaryMatch) {\n return primaryMatch;\n }\n return languageTag;\n}\n// Helper function to get browser language\nexport function getBrowserLanguage() {\n if (typeof navigator === \"undefined\") {\n return defaultLanguage;\n }\n const browserLang = navigator.language;\n if (browserLang) {\n const resolved = resolvePreferredLanguage(browserLang);\n if (resolved) {\n return resolved;\n }\n }\n if (Array.isArray(navigator.languages)) {\n for (const candidate of navigator.languages) {\n const resolved = resolvePreferredLanguage(candidate);\n if (resolved) {\n return resolved;\n }\n }\n }\n return defaultLanguage;\n}\n// Get stored language from localStorage\nconst storedLanguage = typeof window !== \"undefined\"\n ? (window.localStorage?.getItem(\"ds-one:language\") ?? undefined)\n : undefined;\n// Create a reactive signal for the current language (Portfolio pattern)\nexport const currentLanguage = {\n value: localStorage.getItem(\"language\") || getBrowserLanguage(),\n set: function (lang) {\n this.value = lang;\n localStorage.setItem(\"language\", lang);\n window.dispatchEvent(new CustomEvent(\"language-changed\", {\n detail: { language: lang },\n bubbles: true,\n composed: true,\n }));\n },\n};\n// Auto-load translations when this module is imported (for CDN bundle)\nif (typeof window !== \"undefined\") {\n // Wait a bit to ensure the DOM is ready\n if (document.readyState === \"loading\") {\n document.addEventListener(\"DOMContentLoaded\", () => {\n loadExternalTranslations();\n });\n }\n else {\n // DOM is already ready\n loadExternalTranslations();\n }\n}\n// Listen for external translations being loaded\nif (typeof window !== \"undefined\") {\n window.addEventListener(\"translations-ready\", () => {\n // Refresh translation data from external source\n translationData = getTranslationData();\n // Dispatch that translations are loaded\n window.dispatchEvent(new CustomEvent(\"translations-loaded\"));\n window.notionDataLoaded = true;\n // Dispatch language-changed to update all components\n const currentLang = currentLanguage.value;\n window.dispatchEvent(new CustomEvent(\"language-changed\", {\n detail: { language: currentLang },\n bubbles: true,\n composed: true,\n }));\n });\n}\n// Initialize translations on module load\n// Use setTimeout to give other parts of the app time to set up event listeners first\nsetTimeout(() => {\n // Since we directly imported the data, just dispatch the events\n window.dispatchEvent(new CustomEvent(\"translations-loaded\"));\n window.notionDataLoaded = true;\n // Also dispatch language-changed with the current language\n const currentLang = currentLanguage.value;\n window.dispatchEvent(new CustomEvent(\"language-changed\", {\n detail: { language: currentLang },\n bubbles: true,\n composed: true,\n }));\n}, 100);\n// Get translation by key\nexport function translate(key) {\n const lang = currentLanguage.value;\n // Check if key exists in current language\n if (translationData?.[lang]?.[key]) {\n return translationData[lang][key];\n }\n // Try fallback to English\n if (lang !== defaultLanguage && translationData?.[defaultLanguage]?.[key]) {\n return translationData[defaultLanguage][key];\n }\n console.warn(`[translate] No translation found for key \"${key}\"`);\n return key;\n}\nexport function hasTranslation(key, language = currentLanguage.value) {\n if (!key) {\n return false;\n }\n const langData = translationData?.[language];\n if (langData && Object.prototype.hasOwnProperty.call(langData, key)) {\n return true;\n }\n if (language !== defaultLanguage &&\n translationData?.[defaultLanguage] &&\n Object.prototype.hasOwnProperty.call(translationData[defaultLanguage], key)) {\n return true;\n }\n return false;\n}\n// Get text - synchronous version for components\nexport function getText(key) {\n return translate(key);\n}\n// Get text from translation data (async for compatibility)\nexport async function getNotionText(key, language = currentLanguage.value) {\n if (!key) {\n return null;\n }\n if (!translationData || !translationData[language]) {\n return null;\n }\n const text = translationData[language][key];\n if (text) {\n return text;\n }\n // Fallback to English\n if (language !== defaultLanguage && translationData[defaultLanguage]?.[key]) {\n return translationData[defaultLanguage][key];\n }\n return null;\n}\n// Store Notion text (for dynamic updates)\nexport function setNotionText(key, value, language = currentLanguage.value) {\n if (!key)\n return;\n const bucket = getLanguageBucket(language);\n bucket.set(key, value);\n}\nfunction getLanguageBucket(language) {\n if (!notionStore.has(language)) {\n notionStore.set(language, new Map());\n }\n return notionStore.get(language);\n}\n// Get available languages - dynamically detect from loaded data\nexport function getAvailableLanguages() {\n // Always get fresh translation data\n const currentData = getTranslationData();\n if (currentData && Object.keys(currentData).length > 0) {\n const languages = Object.keys(currentData);\n return Promise.resolve(sortLanguageCodes(languages));\n }\n return Promise.resolve([defaultLanguage]);\n}\n// Synchronous version for immediate use\nexport function getAvailableLanguagesSync() {\n const currentData = getTranslationData();\n if (currentData && Object.keys(currentData).length > 0) {\n return sortLanguageCodes(Object.keys(currentData));\n }\n return [defaultLanguage];\n}\n// Load translations programmatically (for compatibility)\nexport function loadTranslations(language, translations) {\n // Since we have static data, this is mainly for compatibility\n console.log(`Loading additional translations for ${language}:`, Object.keys(translations).length, \"keys\");\n}\n// Set language (Portfolio pattern)\nexport function setLanguage(language) {\n // Update the language in localStorage first\n localStorage.setItem(\"language\", language);\n // Then update the signal - this should trigger effects in components\n // that are subscribed to the signal\n currentLanguage.set(language);\n // Dispatch a custom event so non-signal-based components can update\n window.dispatchEvent(new CustomEvent(\"language-changed\", {\n detail: { language },\n bubbles: true,\n composed: true,\n }));\n}\n", "export function savePreferences(preferences) {\n if (typeof window === \"undefined\") {\n return;\n }\n try {\n const raw = window.localStorage?.getItem(\"ds-one:preferences\");\n const existing = raw ? JSON.parse(raw) : {};\n const next = { ...existing, ...preferences };\n window.localStorage?.setItem(\"ds-one:preferences\", JSON.stringify(next));\n }\n catch (error) {\n console.warn(\"ds-one: unable to persist preferences\", error);\n }\n}\n", "/**\n * Currency label utilities for regional price display\n *\n * Note: This module provides currency symbols/labels based on language and region.\n * Consider moving this functionality into i18n.ts as it's region/locale-related.\n * Actual price values will be stored in a database or managed via Stripe.\n */\n// Simple price label mapping based on language/country\nconst PRICE_LABELS = {\n da: \"kr.\",\n nb: \"kr.\",\n sv: \"kr.\",\n de: \"\u20AC\",\n en: \"$\",\n pt: \"\u20AC\",\n es: \"\u20AC\",\n zh: \"\u00A5\",\n ja: \"\u00A5\",\n ko: \"\u20A9\",\n};\nexport function getPriceLabel(options) {\n const { language, country } = options;\n // If country is provided, try to map it to a currency\n if (country) {\n const countryUpper = country.toUpperCase();\n // Add country-specific mappings if needed\n if (countryUpper === \"US\" || countryUpper === \"USA\") {\n return \"$\";\n }\n if (countryUpper === \"GB\" || countryUpper === \"UK\") {\n return \"\u00A3\";\n }\n if (countryUpper === \"JP\" || countryUpper === \"JPN\") {\n return \"\u00A5\";\n }\n if (countryUpper === \"CN\" || countryUpper === \"CHN\") {\n return \"\u00A5\";\n }\n if (countryUpper === \"KR\" || countryUpper === \"KOR\") {\n return \"\u20A9\";\n }\n }\n // Fall back to language-based mapping\n const primaryLang = language.toLowerCase().split(/[-_]/)[0];\n return PRICE_LABELS[primaryLang] || \"$\";\n}\n", "var __defProp = Object.defineProperty;\nvar __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;\nvar __publicField = (obj, key, value) => {\n __defNormalProp(obj, typeof key !== \"symbol\" ? key + \"\" : key, value);\n return value;\n};\nvar __accessCheck = (obj, member, msg) => {\n if (!member.has(obj))\n throw TypeError(\"Cannot \" + msg);\n};\nvar __privateIn = (member, obj) => {\n if (Object(obj) !== obj)\n throw TypeError('Cannot use the \"in\" operator on this value');\n return member.has(obj);\n};\nvar __privateAdd = (obj, member, value) => {\n if (member.has(obj))\n throw TypeError(\"Cannot add the same private member more than once\");\n member instanceof WeakSet ? member.add(obj) : member.set(obj, value);\n};\nvar __privateMethod = (obj, member, method) => {\n __accessCheck(obj, member, \"access private method\");\n return method;\n};\n/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\nfunction defaultEquals(a, b) {\n return Object.is(a, b);\n}\n/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\nlet activeConsumer = null;\nlet inNotificationPhase = false;\nlet epoch = 1;\nconst SIGNAL = /* @__PURE__ */ Symbol(\"SIGNAL\");\nfunction setActiveConsumer(consumer) {\n const prev = activeConsumer;\n activeConsumer = consumer;\n return prev;\n}\nfunction getActiveConsumer() {\n return activeConsumer;\n}\nfunction isInNotificationPhase() {\n return inNotificationPhase;\n}\nconst REACTIVE_NODE = {\n version: 0,\n lastCleanEpoch: 0,\n dirty: false,\n producerNode: void 0,\n producerLastReadVersion: void 0,\n producerIndexOfThis: void 0,\n nextProducerIndex: 0,\n liveConsumerNode: void 0,\n liveConsumerIndexOfThis: void 0,\n consumerAllowSignalWrites: false,\n consumerIsAlwaysLive: false,\n producerMustRecompute: () => false,\n producerRecomputeValue: () => {\n },\n consumerMarkedDirty: () => {\n },\n consumerOnSignalRead: () => {\n }\n};\nfunction producerAccessed(node) {\n if (inNotificationPhase) {\n throw new Error(\n typeof ngDevMode !== \"undefined\" && ngDevMode ? `Assertion error: signal read during notification phase` : \"\"\n );\n }\n if (activeConsumer === null) {\n return;\n }\n activeConsumer.consumerOnSignalRead(node);\n const idx = activeConsumer.nextProducerIndex++;\n assertConsumerNode(activeConsumer);\n if (idx < activeConsumer.producerNode.length && activeConsumer.producerNode[idx] !== node) {\n if (consumerIsLive(activeConsumer)) {\n const staleProducer = activeConsumer.producerNode[idx];\n producerRemoveLiveConsumerAtIndex(staleProducer, activeConsumer.producerIndexOfThis[idx]);\n }\n }\n if (activeConsumer.producerNode[idx] !== node) {\n activeConsumer.producerNode[idx] = node;\n activeConsumer.producerIndexOfThis[idx] = consumerIsLive(activeConsumer) ? producerAddLiveConsumer(node, activeConsumer, idx) : 0;\n }\n activeConsumer.producerLastReadVersion[idx] = node.version;\n}\nfunction producerIncrementEpoch() {\n epoch++;\n}\nfunction producerUpdateValueVersion(node) {\n if (!node.dirty && node.lastCleanEpoch === epoch) {\n return;\n }\n if (!node.producerMustRecompute(node) && !consumerPollProducersForChange(node)) {\n node.dirty = false;\n node.lastCleanEpoch = epoch;\n return;\n }\n node.producerRecomputeValue(node);\n node.dirty = false;\n node.lastCleanEpoch = epoch;\n}\nfunction producerNotifyConsumers(node) {\n if (node.liveConsumerNode === void 0) {\n return;\n }\n const prev = inNotificationPhase;\n inNotificationPhase = true;\n try {\n for (const consumer of node.liveConsumerNode) {\n if (!consumer.dirty) {\n consumerMarkDirty(consumer);\n }\n }\n } finally {\n inNotificationPhase = prev;\n }\n}\nfunction producerUpdatesAllowed() {\n return (activeConsumer == null ? void 0 : activeConsumer.consumerAllowSignalWrites) !== false;\n}\nfunction consumerMarkDirty(node) {\n var _a;\n node.dirty = true;\n producerNotifyConsumers(node);\n (_a = node.consumerMarkedDirty) == null ? void 0 : _a.call(node.wrapper ?? node);\n}\nfunction consumerBeforeComputation(node) {\n node && (node.nextProducerIndex = 0);\n return setActiveConsumer(node);\n}\nfunction consumerAfterComputation(node, prevConsumer) {\n setActiveConsumer(prevConsumer);\n if (!node || node.producerNode === void 0 || node.producerIndexOfThis === void 0 || node.producerLastReadVersion === void 0) {\n return;\n }\n if (consumerIsLive(node)) {\n for (let i = node.nextProducerIndex; i < node.producerNode.length; i++) {\n producerRemoveLiveConsumerAtIndex(node.producerNode[i], node.producerIndexOfThis[i]);\n }\n }\n while (node.producerNode.length > node.nextProducerIndex) {\n node.producerNode.pop();\n node.producerLastReadVersion.pop();\n node.producerIndexOfThis.pop();\n }\n}\nfunction consumerPollProducersForChange(node) {\n assertConsumerNode(node);\n for (let i = 0; i < node.producerNode.length; i++) {\n const producer = node.producerNode[i];\n const seenVersion = node.producerLastReadVersion[i];\n if (seenVersion !== producer.version) {\n return true;\n }\n producerUpdateValueVersion(producer);\n if (seenVersion !== producer.version) {\n return true;\n }\n }\n return false;\n}\nfunction producerAddLiveConsumer(node, consumer, indexOfThis) {\n var _a;\n assertProducerNode(node);\n assertConsumerNode(node);\n if (node.liveConsumerNode.length === 0) {\n (_a = node.watched) == null ? void 0 : _a.call(node.wrapper);\n for (let i = 0; i < node.producerNode.length; i++) {\n node.producerIndexOfThis[i] = producerAddLiveConsumer(node.producerNode[i], node, i);\n }\n }\n node.liveConsumerIndexOfThis.push(indexOfThis);\n return node.liveConsumerNode.push(consumer) - 1;\n}\nfunction producerRemoveLiveConsumerAtIndex(node, idx) {\n var _a;\n assertProducerNode(node);\n assertConsumerNode(node);\n if (typeof ngDevMode !== \"undefined\" && ngDevMode && idx >= node.liveConsumerNode.length) {\n throw new Error(\n `Assertion error: active consumer index ${idx} is out of bounds of ${node.liveConsumerNode.length} consumers)`\n );\n }\n if (node.liveConsumerNode.length === 1) {\n (_a = node.unwatched) == null ? void 0 : _a.call(node.wrapper);\n for (let i = 0; i < node.producerNode.length; i++) {\n producerRemoveLiveConsumerAtIndex(node.producerNode[i], node.producerIndexOfThis[i]);\n }\n }\n const lastIdx = node.liveConsumerNode.length - 1;\n node.liveConsumerNode[idx] = node.liveConsumerNode[lastIdx];\n node.liveConsumerIndexOfThis[idx] = node.liveConsumerIndexOfThis[lastIdx];\n node.liveConsumerNode.length--;\n node.liveConsumerIndexOfThis.length--;\n if (idx < node.liveConsumerNode.length) {\n const idxProducer = node.liveConsumerIndexOfThis[idx];\n const consumer = node.liveConsumerNode[idx];\n assertConsumerNode(consumer);\n consumer.producerIndexOfThis[idxProducer] = idx;\n }\n}\nfunction consumerIsLive(node) {\n var _a;\n return node.consumerIsAlwaysLive || (((_a = node == null ? void 0 : node.liveConsumerNode) == null ? void 0 : _a.length) ?? 0) > 0;\n}\nfunction assertConsumerNode(node) {\n node.producerNode ?? (node.producerNode = []);\n node.producerIndexOfThis ?? (node.producerIndexOfThis = []);\n node.producerLastReadVersion ?? (node.producerLastReadVersion = []);\n}\nfunction assertProducerNode(node) {\n node.liveConsumerNode ?? (node.liveConsumerNode = []);\n node.liveConsumerIndexOfThis ?? (node.liveConsumerIndexOfThis = []);\n}\n/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\nfunction computedGet(node) {\n producerUpdateValueVersion(node);\n producerAccessed(node);\n if (node.value === ERRORED) {\n throw node.error;\n }\n return node.value;\n}\nfunction createComputed(computation) {\n const node = Object.create(COMPUTED_NODE);\n node.computation = computation;\n const computed = () => computedGet(node);\n computed[SIGNAL] = node;\n return computed;\n}\nconst UNSET = /* @__PURE__ */ Symbol(\"UNSET\");\nconst COMPUTING = /* @__PURE__ */ Symbol(\"COMPUTING\");\nconst ERRORED = /* @__PURE__ */ Symbol(\"ERRORED\");\nconst COMPUTED_NODE = /* @__PURE__ */ (() => {\n return {\n ...REACTIVE_NODE,\n value: UNSET,\n dirty: true,\n error: null,\n equal: defaultEquals,\n producerMustRecompute(node) {\n return node.value === UNSET || node.value === COMPUTING;\n },\n producerRecomputeValue(node) {\n if (node.value === COMPUTING) {\n throw new Error(\"Detected cycle in computations.\");\n }\n const oldValue = node.value;\n node.value = COMPUTING;\n const prevConsumer = consumerBeforeComputation(node);\n let newValue;\n let wasEqual = false;\n try {\n newValue = node.computation.call(node.wrapper);\n const oldOk = oldValue !== UNSET && oldValue !== ERRORED;\n wasEqual = oldOk && node.equal.call(node.wrapper, oldValue, newValue);\n } catch (err) {\n newValue = ERRORED;\n node.error = err;\n } finally {\n consumerAfterComputation(node, prevConsumer);\n }\n if (wasEqual) {\n node.value = oldValue;\n return;\n }\n node.value = newValue;\n node.version++;\n }\n };\n})();\n/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\nfunction defaultThrowError() {\n throw new Error();\n}\nlet throwInvalidWriteToSignalErrorFn = defaultThrowError;\nfunction throwInvalidWriteToSignalError() {\n throwInvalidWriteToSignalErrorFn();\n}\n/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\nfunction createSignal(initialValue) {\n const node = Object.create(SIGNAL_NODE);\n node.value = initialValue;\n const getter = () => {\n producerAccessed(node);\n return node.value;\n };\n getter[SIGNAL] = node;\n return getter;\n}\nfunction signalGetFn() {\n producerAccessed(this);\n return this.value;\n}\nfunction signalSetFn(node, newValue) {\n if (!producerUpdatesAllowed()) {\n throwInvalidWriteToSignalError();\n }\n if (!node.equal.call(node.wrapper, node.value, newValue)) {\n node.value = newValue;\n signalValueChanged(node);\n }\n}\nconst SIGNAL_NODE = /* @__PURE__ */ (() => {\n return {\n ...REACTIVE_NODE,\n equal: defaultEquals,\n value: void 0\n };\n})();\nfunction signalValueChanged(node) {\n node.version++;\n producerIncrementEpoch();\n producerNotifyConsumers(node);\n}\n/**\n * @license\n * Copyright 2024 Bloomberg Finance L.P.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nconst NODE = Symbol(\"node\");\nvar Signal;\n((Signal2) => {\n var _a, _brand, brand_fn, _b, _brand2, brand_fn2;\n class State {\n constructor(initialValue, options = {}) {\n __privateAdd(this, _brand);\n __publicField(this, _a);\n const ref = createSignal(initialValue);\n const node = ref[SIGNAL];\n this[NODE] = node;\n node.wrapper = this;\n if (options) {\n const equals = options.equals;\n if (equals) {\n node.equal = equals;\n }\n node.watched = options[Signal2.subtle.watched];\n node.unwatched = options[Signal2.subtle.unwatched];\n }\n }\n get() {\n if (!(0, Signal2.isState)(this))\n throw new TypeError(\"Wrong receiver type for Signal.State.prototype.get\");\n return signalGetFn.call(this[NODE]);\n }\n set(newValue) {\n if (!(0, Signal2.isState)(this))\n throw new TypeError(\"Wrong receiver type for Signal.State.prototype.set\");\n if (isInNotificationPhase()) {\n throw new Error(\"Writes to signals not permitted during Watcher callback\");\n }\n const ref = this[NODE];\n signalSetFn(ref, newValue);\n }\n }\n _a = NODE;\n _brand = new WeakSet();\n brand_fn = function() {\n };\n Signal2.isState = (s) => typeof s === \"object\" && __privateIn(_brand, s);\n Signal2.State = State;\n class Computed {\n // Create a Signal which evaluates to the value returned by the callback.\n // Callback is called with this signal as the parameter.\n constructor(computation, options) {\n __privateAdd(this, _brand2);\n __publicField(this, _b);\n const ref = createComputed(computation);\n const node = ref[SIGNAL];\n node.consumerAllowSignalWrites = true;\n this[NODE] = node;\n node.wrapper = this;\n if (options) {\n const equals = options.equals;\n if (equals) {\n node.equal = equals;\n }\n node.watched = options[Signal2.subtle.watched];\n node.unwatched = options[Signal2.subtle.unwatched];\n }\n }\n get() {\n if (!(0, Signal2.isComputed)(this))\n throw new TypeError(\"Wrong receiver type for Signal.Computed.prototype.get\");\n return computedGet(this[NODE]);\n }\n }\n _b = NODE;\n _brand2 = new WeakSet();\n brand_fn2 = function() {\n };\n Signal2.isComputed = (c) => typeof c === \"object\" && __privateIn(_brand2, c);\n Signal2.Computed = Computed;\n ((subtle2) => {\n var _a2, _brand3, brand_fn3, _assertSignals, assertSignals_fn;\n function untrack(cb) {\n let output;\n let prevActiveConsumer = null;\n try {\n prevActiveConsumer = setActiveConsumer(null);\n output = cb();\n } finally {\n setActiveConsumer(prevActiveConsumer);\n }\n return output;\n }\n subtle2.untrack = untrack;\n function introspectSources(sink) {\n var _a3;\n if (!(0, Signal2.isComputed)(sink) && !(0, Signal2.isWatcher)(sink)) {\n throw new TypeError(\"Called introspectSources without a Computed or Watcher argument\");\n }\n return ((_a3 = sink[NODE].producerNode) == null ? void 0 : _a3.map((n) => n.wrapper)) ?? [];\n }\n subtle2.introspectSources = introspectSources;\n function introspectSinks(signal) {\n var _a3;\n if (!(0, Signal2.isComputed)(signal) && !(0, Signal2.isState)(signal)) {\n throw new TypeError(\"Called introspectSinks without a Signal argument\");\n }\n return ((_a3 = signal[NODE].liveConsumerNode) == null ? void 0 : _a3.map((n) => n.wrapper)) ?? [];\n }\n subtle2.introspectSinks = introspectSinks;\n function hasSinks(signal) {\n if (!(0, Signal2.isComputed)(signal) && !(0, Signal2.isState)(signal)) {\n throw new TypeError(\"Called hasSinks without a Signal argument\");\n }\n const liveConsumerNode = signal[NODE].liveConsumerNode;\n if (!liveConsumerNode)\n return false;\n return liveConsumerNode.length > 0;\n }\n subtle2.hasSinks = hasSinks;\n function hasSources(signal) {\n if (!(0, Signal2.isComputed)(signal) && !(0, Signal2.isWatcher)(signal)) {\n throw new TypeError(\"Called hasSources without a Computed or Watcher argument\");\n }\n const producerNode = signal[NODE].producerNode;\n if (!producerNode)\n return false;\n return producerNode.length > 0;\n }\n subtle2.hasSources = hasSources;\n class Watcher {\n // When a (recursive) source of Watcher is written to, call this callback,\n // if it hasn't already been called since the last `watch` call.\n // No signals may be read or written during the notify.\n constructor(notify) {\n __privateAdd(this, _brand3);\n __privateAdd(this, _assertSignals);\n __publicField(this, _a2);\n let node = Object.create(REACTIVE_NODE);\n node.wrapper = this;\n node.consumerMarkedDirty = notify;\n node.consumerIsAlwaysLive = true;\n node.consumerAllowSignalWrites = false;\n node.producerNode = [];\n this[NODE] = node;\n }\n // Add these signals to the Watcher's set, and set the watcher to run its\n // notify callback next time any signal in the set (or one of its dependencies) changes.\n // Can be called with no arguments just to reset the \"notified\" state, so that\n // the notify callback will be invoked again.\n watch(...signals) {\n if (!(0, Signal2.isWatcher)(this)) {\n throw new TypeError(\"Called unwatch without Watcher receiver\");\n }\n __privateMethod(this, _assertSignals, assertSignals_fn).call(this, signals);\n const node = this[NODE];\n node.dirty = false;\n const prev = setActiveConsumer(node);\n for (const signal of signals) {\n producerAccessed(signal[NODE]);\n }\n setActiveConsumer(prev);\n }\n // Remove these signals from the watched set (e.g., for an effect which is disposed)\n unwatch(...signals) {\n if (!(0, Signal2.isWatcher)(this)) {\n throw new TypeError(\"Called unwatch without Watcher receiver\");\n }\n __privateMethod(this, _assertSignals, assertSignals_fn).call(this, signals);\n const node = this[NODE];\n assertConsumerNode(node);\n for (let i = node.producerNode.length - 1; i >= 0; i--) {\n if (signals.includes(node.producerNode[i].wrapper)) {\n producerRemoveLiveConsumerAtIndex(node.producerNode[i], node.producerIndexOfThis[i]);\n const lastIdx = node.producerNode.length - 1;\n node.producerNode[i] = node.producerNode[lastIdx];\n node.producerIndexOfThis[i] = node.producerIndexOfThis[lastIdx];\n node.producerNode.length--;\n node.producerIndexOfThis.length--;\n node.nextProducerIndex--;\n if (i < node.producerNode.length) {\n const idxConsumer = node.producerIndexOfThis[i];\n const producer = node.producerNode[i];\n assertProducerNode(producer);\n producer.liveConsumerIndexOfThis[idxConsumer] = i;\n }\n }\n }\n }\n // Returns the set of computeds in the Watcher's set which are still yet\n // to be re-evaluated\n getPending() {\n if (!(0, Signal2.isWatcher)(this)) {\n throw new TypeError(\"Called getPending without Watcher receiver\");\n }\n const node = this[NODE];\n return node.producerNode.filter((n) => n.dirty).map((n) => n.wrapper);\n }\n }\n _a2 = NODE;\n _brand3 = new WeakSet();\n brand_fn3 = function() {\n };\n _assertSignals = new WeakSet();\n assertSignals_fn = function(signals) {\n for (const signal of signals) {\n if (!(0, Signal2.isComputed)(signal) && !(0, Signal2.isState)(signal)) {\n throw new TypeError(\"Called watch/unwatch without a Computed or State argument\");\n }\n }\n };\n Signal2.isWatcher = (w) => __privateIn(_brand3, w);\n subtle2.Watcher = Watcher;\n function currentComputed() {\n var _a3;\n return (_a3 = getActiveConsumer()) == null ? void 0 : _a3.wrapper;\n }\n subtle2.currentComputed = currentComputed;\n subtle2.watched = Symbol(\"watched\");\n subtle2.unwatched = Symbol(\"unwatched\");\n })(Signal2.subtle || (Signal2.subtle = {}));\n})(Signal || (Signal = {}));\nexport {\n Signal\n};\n", "/**\n * @license\n * Copyright 2023 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport type {PropertyDeclaration, PropertyValueMap, ReactiveElement} from 'lit';\nimport {Signal} from 'signal-polyfill';\nimport {WatchDirective} from './watch.js';\n\ntype ReactiveElementConstructor = abstract new (\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ...args: any[]\n) => ReactiveElement;\n\nexport interface SignalWatcher extends ReactiveElement {\n _updateWatchDirective(d: WatchDirective<unknown>): void;\n _clearWatchDirective(d: WatchDirective<unknown>): void;\n}\n\ninterface SignalWatcherInterface extends SignalWatcher {}\ninterface SignalWatcherInternal extends SignalWatcher {\n __forcingUpdate: boolean;\n}\n\nconst signalWatcherBrand: unique symbol = Symbol('SignalWatcherBrand');\n\n// Memory management: We need to ensure that we don't leak memory by creating a\n// reference cycle between an element and its watcher, which then it kept alive\n// by the signals it watches. To avoid this, we break the cycle by using a\n// WeakMap to store the watcher for each element, and a FinalizationRegistry to\n// clean up the watcher when the element is garbage collected.\n\nconst elementFinalizationRegistry = new FinalizationRegistry<{\n watcher: Signal.subtle.Watcher;\n signal: Signal.Computed<void>;\n}>(({watcher, signal}) => {\n watcher.unwatch(signal);\n});\n\nconst elementForWatcher = new WeakMap<\n Signal.subtle.Watcher,\n SignalWatcherInternal\n>();\n\n/**\n * Adds the ability for a LitElement or other ReactiveElement class to\n * watch for access to signals during the update lifecycle and trigger a new\n * update when signals values change.\n */\nexport function SignalWatcher<T extends ReactiveElementConstructor>(\n Base: T\n): T {\n // Only apply the mixin once\n if ((Base as typeof SignalWatcher)[signalWatcherBrand] === true) {\n console.warn(\n 'SignalWatcher should not be applied to the same class more than once.'\n );\n return Base;\n }\n\n abstract class SignalWatcher extends Base implements SignalWatcherInterface {\n static [signalWatcherBrand]: true;\n\n private __watcher?: Signal.subtle.Watcher;\n\n private __watch() {\n if (this.__watcher !== undefined) {\n return;\n }\n // We create a fresh computed instead of just re-using the existing one\n // because of https://github.com/proposal-signals/signal-polyfill/issues/27\n this.__performUpdateSignal = new Signal.Computed(() => {\n this.__forceUpdateSignal.get();\n super.performUpdate();\n });\n const watcher = (this.__watcher = new Signal.subtle.Watcher(function (\n this: Signal.subtle.Watcher\n ) {\n // All top-level references in this function body must either be `this`\n // (the watcher) or a module global to prevent this closure from keeping\n // the enclosing scopes alive, which would keep the element alive. So\n // The only two references are `this` and `elementForWatcher`.\n const el = elementForWatcher.get(this);\n if (el === undefined) {\n // The element was garbage collected, so we can stop watching.\n return;\n }\n if (el.__forcingUpdate === false) {\n el.requestUpdate();\n }\n this.watch();\n }));\n elementForWatcher.set(watcher, this as unknown as SignalWatcherInternal);\n elementFinalizationRegistry.register(this, {\n watcher,\n signal: this.__performUpdateSignal,\n });\n watcher.watch(this.__performUpdateSignal);\n }\n\n private __unwatch() {\n if (this.__watcher === undefined) {\n return;\n }\n this.__watcher.unwatch(this.__performUpdateSignal!);\n this.__performUpdateSignal = undefined;\n this.__watcher = undefined;\n }\n\n /**\n * Used to force an uncached read of the __performUpdateSignal when we need\n * to read the current value during an update.\n *\n * If https://github.com/tc39/proposal-signals/issues/151 is resolved, we\n * won't need this.\n */\n private __forceUpdateSignal = new Signal.State(0);\n\n /*\n * This field is used within the watcher to determine if the watcher\n * notification was triggered by our performUpdate() override. Because we\n * force a fresh read of the __performUpdateSignal by changing value of the\n * __forceUpdate signal, the watcher will be notified. But we're already\n * performing an update, so we don't want to enqueue another one.\n */\n // @ts-expect-error This field is accessed in a watcher function with a\n // different `this` context, so TypeScript can't see the access.\n private __forcingUpdate = false;\n\n /**\n * A computed signal that wraps performUpdate() so that all signals that are\n * accessed during the update lifecycle are tracked.\n *\n * __forceUpdateSignal is used to force an uncached read of this signal\n * because updates may easily depend on non-signal values, so we must always\n * re-run it.\n */\n private __performUpdateSignal?: Signal.Computed<void>;\n\n /**\n * Whether or not the next update should perform a full render, or if only\n * pending watches should be committed.\n *\n * If requestUpdate() was called only because of watch() directive updates,\n * then we can just commit those directives without a full render. If\n * requestUpdate() was called for any other reason, we need to perform a\n * full render, and don't need to separately commit the watch() directives.\n *\n * This is set to `true` initially, and whenever requestUpdate() is called\n * outside of a watch() directive update. It is set to `false` when\n * update() is called, so that a requestUpdate() is required to do another\n * full render.\n */\n private __doFullRender = true;\n\n /**\n * Set of watch directives that have been updated since the last update.\n * These will be committed in update() to ensure that the latest value is\n * rendered and that all updates are batched.\n */\n private __pendingWatches = new Set<WatchDirective<unknown>>();\n\n protected override performUpdate() {\n if (!this.isUpdatePending) {\n // super.performUpdate() performs this check, so we bail early so that\n // we don't read the __performUpdateSignal when it's not going to access\n // any signals. This keeps the last signals read as the sources so that\n // we'll get notified of changes to them.\n return;\n }\n // Always enable watching before an update, even if disconnected, so that\n // we can track signals that are accessed during the update.\n this.__watch();\n // Force an uncached read of __performUpdateSignal\n this.__forcingUpdate = true;\n this.__forceUpdateSignal.set(this.__forceUpdateSignal.get() + 1);\n this.__forcingUpdate = false;\n // Always read from the signal to ensure that it's tracked\n this.__performUpdateSignal!.get();\n }\n\n protected override update(\n changedProperties: PropertyValueMap<this> | Map<PropertyKey, unknown>\n ): void {\n // We need a try block because both super.update() and\n // WatchDirective.commit() can throw, and we need to ensure that post-\n // update cleanup happens.\n try {\n if (this.__doFullRender) {\n // Force future updates to not perform full renders by default.\n this.__doFullRender = false;\n super.update(changedProperties);\n } else {\n // For a partial render, just commit the pending watches.\n // TODO (justinfagnani): Should we access each signal in a separate\n // try block?\n this.__pendingWatches.forEach((d) => d.commit());\n }\n } finally {\n // If we didn't call super.update(), we need to set this to false\n this.isUpdatePending = false;\n this.__pendingWatches.clear();\n }\n }\n\n override requestUpdate(\n name?: PropertyKey | undefined,\n oldValue?: unknown,\n options?: PropertyDeclaration<unknown, unknown> | undefined\n ): void {\n this.__doFullRender = true;\n super.requestUpdate(name, oldValue, options);\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n // Because we might have missed some signal updates while disconnected,\n // we force a full render on the next update.\n this.requestUpdate();\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n // Clean up the watcher earlier than the FinalizationRegistry will, to\n // avoid memory pressure from signals holding references to the element\n // via the watcher.\n //\n // This means that while disconnected, regular reactive property updates\n // will trigger a re-render, but signal updates will not. To ensure that\n // current signal usage is still correctly tracked, we re-enable watching\n // in performUpdate() even while disconnected. From that point on, a\n // disconnected element will be retained by the signals it accesses during\n // the update lifecycle.\n //\n // We use queueMicrotask() to ensure that this cleanup does not happen\n // because of moves in the DOM within the same task, such as removing an\n // element with .remove() and then adding it back later with .append()\n // in the same task. For example, repeat() works this way.\n queueMicrotask(() => {\n if (this.isConnected === false) {\n this.__unwatch();\n }\n });\n }\n\n /**\n * Enqueues an update caused by a signal change observed by a watch()\n * directive.\n *\n * Note: the method is not part of the public API and is subject to change.\n * In particular, it may be removed if the watch() directive is updated to\n * work with standalone lit-html templates.\n *\n * @internal\n */\n _updateWatchDirective(d: WatchDirective<unknown>): void {\n this.__pendingWatches.add(d);\n // requestUpdate() will set __doFullRender to true, so remember the\n // current value and restore it after calling requestUpdate().\n const shouldRender = this.__doFullRender;\n this.requestUpdate();\n this.__doFullRender = shouldRender;\n }\n\n /**\n * Clears a watch() directive from the set of pending watches.\n *\n * Note: the method is not part of the public API and is subject to change.\n *\n * @internal\n */\n _clearWatchDirective(d: WatchDirective<unknown>): void {\n this.__pendingWatches.delete(d);\n }\n }\n return SignalWatcher;\n}\n", "/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {Disconnectable, Part} from './lit-html.js';\n\nexport {\n AttributePart,\n BooleanAttributePart,\n ChildPart,\n ElementPart,\n EventPart,\n Part,\n PropertyPart,\n} from './lit-html.js';\n\nexport interface DirectiveClass {\n new (part: PartInfo): Directive;\n}\n\n/**\n * This utility type extracts the signature of a directive class's render()\n * method so we can use it for the type of the generated directive function.\n */\nexport type DirectiveParameters<C extends Directive> = Parameters<C['render']>;\n\n/**\n * A generated directive function doesn't evaluate the directive, but just\n * returns a DirectiveResult object that captures the arguments.\n */\nexport interface DirectiveResult<C extends DirectiveClass = DirectiveClass> {\n /**\n * This property needs to remain unminified.\n * @internal\n */\n ['_$litDirective$']: C;\n /** @internal */\n values: DirectiveParameters<InstanceType<C>>;\n}\n\nexport const PartType = {\n ATTRIBUTE: 1,\n CHILD: 2,\n PROPERTY: 3,\n BOOLEAN_ATTRIBUTE: 4,\n EVENT: 5,\n ELEMENT: 6,\n} as const;\n\nexport type PartType = (typeof PartType)[keyof typeof PartType];\n\nexport interface ChildPartInfo {\n readonly type: typeof PartType.CHILD;\n}\n\nexport interface AttributePartInfo {\n readonly type:\n | typeof PartType.ATTRIBUTE\n | typeof PartType.PROPERTY\n | typeof PartType.BOOLEAN_ATTRIBUTE\n | typeof PartType.EVENT;\n readonly strings?: ReadonlyArray<string>;\n readonly name: string;\n readonly tagName: string;\n}\n\nexport interface ElementPartInfo {\n readonly type: typeof PartType.ELEMENT;\n}\n\n/**\n * Information about the part a directive is bound to.\n *\n * This is useful for checking that a directive is attached to a valid part,\n * such as with directive that can only be used on attribute bindings.\n */\nexport type PartInfo = ChildPartInfo | AttributePartInfo | ElementPartInfo;\n\n/**\n * Creates a user-facing directive function from a Directive class. This\n * function has the same parameters as the directive's render() method.\n */\nexport const directive =\n <C extends DirectiveClass>(c: C) =>\n (...values: DirectiveParameters<InstanceType<C>>): DirectiveResult<C> => ({\n // This property needs to remain unminified.\n ['_$litDirective$']: c,\n values,\n });\n\n/**\n * Base class for creating custom directives. Users should extend this class,\n * implement `render` and/or `update`, and then pass their subclass to\n * `directive`.\n */\nexport abstract class Directive implements Disconnectable {\n //@internal\n __part!: Part;\n //@internal\n __attributeIndex: number | undefined;\n //@internal\n __directive?: Directive;\n\n //@internal\n _$parent!: Disconnectable;\n\n // These will only exist on the AsyncDirective subclass\n //@internal\n _$disconnectableChildren?: Set<Disconnectable>;\n // This property needs to remain unminified.\n //@internal\n ['_$notifyDirectiveConnectionChanged']?(isConnected: boolean): void;\n\n constructor(_partInfo: PartInfo) {}\n\n // See comment in Disconnectable interface for why this is a getter\n get _$isConnected() {\n return this._$parent._$isConnected;\n }\n\n /** @internal */\n _$initialize(\n part: Part,\n parent: Disconnectable,\n attributeIndex: number | undefined\n ) {\n this.__part = part;\n this._$parent = parent;\n this.__attributeIndex = attributeIndex;\n }\n /** @internal */\n _$resolve(part: Part, props: Array<unknown>): unknown {\n return this.update(part, props);\n }\n\n abstract render(...props: Array<unknown>): unknown;\n\n update(_part: Part, props: Array<unknown>): unknown {\n return this.render(...props);\n }\n}\n", "/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n// IMPORTANT: these imports must be type-only\nimport type {Directive, DirectiveResult, PartInfo} from './directive.js';\nimport type {TrustedHTML, TrustedTypesWindow} from 'trusted-types/lib/index.js';\n\nconst DEV_MODE = true;\nconst ENABLE_EXTRA_SECURITY_HOOKS = true;\nconst ENABLE_SHADYDOM_NOPATCH = true;\nconst NODE_MODE = false;\n\n// Allows minifiers to rename references to globalThis\nconst global = globalThis;\n\n/**\n * Contains types that are part of the unstable debug API.\n *\n * Everything in this API is not stable and may change or be removed in the future,\n * even on patch releases.\n */\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport namespace LitUnstable {\n /**\n * When Lit is running in dev mode and `window.emitLitDebugLogEvents` is true,\n * we will emit 'lit-debug' events to window, with live details about the update and render\n * lifecycle. These can be useful for writing debug tooling and visualizations.\n *\n * Please be aware that running with window.emitLitDebugLogEvents has performance overhead,\n * making certain operations that are normally very cheap (like a no-op render) much slower,\n * because we must copy data and dispatch events.\n */\n // eslint-disable-next-line @typescript-eslint/no-namespace\n export namespace DebugLog {\n export type Entry =\n | TemplatePrep\n | TemplateInstantiated\n | TemplateInstantiatedAndUpdated\n | TemplateUpdating\n | BeginRender\n | EndRender\n | CommitPartEntry\n | SetPartValue;\n export interface TemplatePrep {\n kind: 'template prep';\n template: Template;\n strings: TemplateStringsArray;\n clonableTemplate: HTMLTemplateElement;\n parts: TemplatePart[];\n }\n export interface BeginRender {\n kind: 'begin render';\n id: number;\n value: unknown;\n container: HTMLElement | DocumentFragment;\n options: RenderOptions | undefined;\n part: ChildPart | undefined;\n }\n export interface EndRender {\n kind: 'end render';\n id: number;\n value: unknown;\n container: HTMLElement | DocumentFragment;\n options: RenderOptions | undefined;\n part: ChildPart;\n }\n export interface TemplateInstantiated {\n kind: 'template instantiated';\n template: Template | CompiledTemplate;\n instance: TemplateInstance;\n options: RenderOptions | undefined;\n fragment: Node;\n parts: Array<Part | undefined>;\n values: unknown[];\n }\n export interface TemplateInstantiatedAndUpdated {\n kind: 'template instantiated and updated';\n template: Template | CompiledTemplate;\n instance: TemplateInstance;\n options: RenderOptions | undefined;\n fragment: Node;\n parts: Array<Part | undefined>;\n values: unknown[];\n }\n export interface TemplateUpdating {\n kind: 'template updating';\n template: Template | CompiledTemplate;\n instance: TemplateInstance;\n options: RenderOptions | undefined;\n parts: Array<Part | undefined>;\n values: unknown[];\n }\n export interface SetPartValue {\n kind: 'set part';\n part: Part;\n value: unknown;\n valueIndex: number;\n values: unknown[];\n templateInstance: TemplateInstance;\n }\n\n export type CommitPartEntry =\n | CommitNothingToChildEntry\n | CommitText\n | CommitNode\n | CommitAttribute\n | CommitProperty\n | CommitBooleanAttribute\n | CommitEventListener\n | CommitToElementBinding;\n\n export interface CommitNothingToChildEntry {\n kind: 'commit nothing to child';\n start: ChildNode;\n end: ChildNode | null;\n parent: Disconnectable | undefined;\n options: RenderOptions | undefined;\n }\n\n export interface CommitText {\n kind: 'commit text';\n node: Text;\n value: unknown;\n options: RenderOptions | undefined;\n }\n\n export interface CommitNode {\n kind: 'commit node';\n start: Node;\n parent: Disconnectable | undefined;\n value: Node;\n options: RenderOptions | undefined;\n }\n\n export interface CommitAttribute {\n kind: 'commit attribute';\n element: Element;\n name: string;\n value: unknown;\n options: RenderOptions | undefined;\n }\n\n export interface CommitProperty {\n kind: 'commit property';\n element: Element;\n name: string;\n value: unknown;\n options: RenderOptions | undefined;\n }\n\n export interface CommitBooleanAttribute {\n kind: 'commit boolean attribute';\n element: Element;\n name: string;\n value: boolean;\n options: RenderOptions | undefined;\n }\n\n export interface CommitEventListener {\n kind: 'commit event listener';\n element: Element;\n name: string;\n value: unknown;\n oldListener: unknown;\n options: RenderOptions | undefined;\n // True if we're removing the old event listener (e.g. because settings changed, or value is nothing)\n removeListener: boolean;\n // True if we're adding a new event listener (e.g. because first render, or settings changed)\n addListener: boolean;\n }\n\n export interface CommitToElementBinding {\n kind: 'commit to element binding';\n element: Element;\n value: unknown;\n options: RenderOptions | undefined;\n }\n }\n}\n\ninterface DebugLoggingWindow {\n // Even in dev mode, we generally don't want to emit these events, as that's\n // another level of cost, so only emit them when DEV_MODE is true _and_ when\n // window.emitLitDebugEvents is true.\n emitLitDebugLogEvents?: boolean;\n}\n\n/**\n * Useful for visualizing and logging insights into what the Lit template system is doing.\n *\n * Compiled out of prod mode builds.\n */\nconst debugLogEvent = DEV_MODE\n ? (event: LitUnstable.DebugLog.Entry) => {\n const shouldEmit = (global as unknown as DebugLoggingWindow)\n .emitLitDebugLogEvents;\n if (!shouldEmit) {\n return;\n }\n global.dispatchEvent(\n new CustomEvent<LitUnstable.DebugLog.Entry>('lit-debug', {\n detail: event,\n })\n );\n }\n : undefined;\n// Used for connecting beginRender and endRender events when there are nested\n// renders when errors are thrown preventing an endRender event from being\n// called.\nlet debugLogRenderId = 0;\n\nlet issueWarning: (code: string, warning: string) => void;\n\nif (DEV_MODE) {\n global.litIssuedWarnings ??= new Set();\n\n /**\n * Issue a warning if we haven't already, based either on `code` or `warning`.\n * Warnings are disabled automatically only by `warning`; disabling via `code`\n * can be done by users.\n */\n issueWarning = (code: string, warning: string) => {\n warning += code\n ? ` See https://lit.dev/msg/${code} for more information.`\n : '';\n if (\n !global.litIssuedWarnings!.has(warning) &&\n !global.litIssuedWarnings!.has(code)\n ) {\n console.warn(warning);\n global.litIssuedWarnings!.add(warning);\n }\n };\n\n queueMicrotask(() => {\n issueWarning(\n 'dev-mode',\n `Lit is in dev mode. Not recommended for production!`\n );\n });\n}\n\nconst wrap =\n ENABLE_SHADYDOM_NOPATCH &&\n global.ShadyDOM?.inUse &&\n global.ShadyDOM?.noPatch === true\n ? (global.ShadyDOM!.wrap as <T extends Node>(node: T) => T)\n : <T extends Node>(node: T) => node;\n\nconst trustedTypes = (global as unknown as TrustedTypesWindow).trustedTypes;\n\n/**\n * Our TrustedTypePolicy for HTML which is declared using the html template\n * tag function.\n *\n * That HTML is a developer-authored constant, and is parsed with innerHTML\n * before any untrusted expressions have been mixed in. Therefor it is\n * considered safe by construction.\n */\nconst policy = trustedTypes\n ? trustedTypes.createPolicy('lit-html', {\n createHTML: (s) => s,\n })\n : undefined;\n\n/**\n * Used to sanitize any value before it is written into the DOM. This can be\n * used to implement a security policy of allowed and disallowed values in\n * order to prevent XSS attacks.\n *\n * One way of using this callback would be to check attributes and properties\n * against a list of high risk fields, and require that values written to such\n * fields be instances of a class which is safe by construction. Closure's Safe\n * HTML Types is one implementation of this technique (\n * https://github.com/google/safe-html-types/blob/master/doc/safehtml-types.md).\n * The TrustedTypes polyfill in API-only mode could also be used as a basis\n * for this technique (https://github.com/WICG/trusted-types).\n *\n * @param node The HTML node (usually either a #text node or an Element) that\n * is being written to. Note that this is just an exemplar node, the write\n * may take place against another instance of the same class of node.\n * @param name The name of an attribute or property (for example, 'href').\n * @param type Indicates whether the write that's about to be performed will\n * be to a property or a node.\n * @return A function that will sanitize this class of writes.\n */\nexport type SanitizerFactory = (\n node: Node,\n name: string,\n type: 'property' | 'attribute'\n) => ValueSanitizer;\n\n/**\n * A function which can sanitize values that will be written to a specific kind\n * of DOM sink.\n *\n * See SanitizerFactory.\n *\n * @param value The value to sanitize. Will be the actual value passed into\n * the lit-html template literal, so this could be of any type.\n * @return The value to write to the DOM. Usually the same as the input value,\n * unless sanitization is needed.\n */\nexport type ValueSanitizer = (value: unknown) => unknown;\n\nconst identityFunction: ValueSanitizer = (value: unknown) => value;\nconst noopSanitizer: SanitizerFactory = (\n _node: Node,\n _name: string,\n _type: 'property' | 'attribute'\n) => identityFunction;\n\n/** Sets the global sanitizer factory. */\nconst setSanitizer = (newSanitizer: SanitizerFactory) => {\n if (!ENABLE_EXTRA_SECURITY_HOOKS) {\n return;\n }\n if (sanitizerFactoryInternal !== noopSanitizer) {\n throw new Error(\n `Attempted to overwrite existing lit-html security policy.` +\n ` setSanitizeDOMValueFactory should be called at most once.`\n );\n }\n sanitizerFactoryInternal = newSanitizer;\n};\n\n/**\n * Only used in internal tests, not a part of the public API.\n */\nconst _testOnlyClearSanitizerFactoryDoNotCallOrElse = () => {\n sanitizerFactoryInternal = noopSanitizer;\n};\n\nconst createSanitizer: SanitizerFactory = (node, name, type) => {\n return sanitizerFactoryInternal(node, name, type);\n};\n\n// Added to an attribute name to mark the attribute as bound so we can find\n// it easily.\nconst boundAttributeSuffix = '$lit$';\n\n// This marker is used in many syntactic positions in HTML, so it must be\n// a valid element name and attribute name. We don't support dynamic names (yet)\n// but this at least ensures that the parse tree is closer to the template\n// intention.\nconst marker = `lit$${Math.random().toFixed(9).slice(2)}$`;\n\n// String used to tell if a comment is a marker comment\nconst markerMatch = '?' + marker;\n\n// Text used to insert a comment marker node. We use processing instruction\n// syntax because it's slightly smaller, but parses as a comment node.\nconst nodeMarker = `<${markerMatch}>`;\n\nconst d =\n NODE_MODE && global.document === undefined\n ? ({\n createTreeWalker() {\n return {};\n },\n } as unknown as Document)\n : document;\n\n// Creates a dynamic marker. We never have to search for these in the DOM.\nconst createMarker = () => d.createComment('');\n\n// https://tc39.github.io/ecma262/#sec-typeof-operator\ntype Primitive = null | undefined | boolean | number | string | symbol | bigint;\nconst isPrimitive = (value: unknown): value is Primitive =>\n value === null || (typeof value != 'object' && typeof value != 'function');\nconst isArray = Array.isArray;\nconst isIterable = (value: unknown): value is Iterable<unknown> =>\n isArray(value) ||\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n typeof (value as any)?.[Symbol.iterator] === 'function';\n\nconst SPACE_CHAR = `[ \\t\\n\\f\\r]`;\nconst ATTR_VALUE_CHAR = `[^ \\t\\n\\f\\r\"'\\`<>=]`;\nconst NAME_CHAR = `[^\\\\s\"'>=/]`;\n\n// These regexes represent the five parsing states that we care about in the\n// Template's HTML scanner. They match the *end* of the state they're named\n// after.\n// Depending on the match, we transition to a new state. If there's no match,\n// we stay in the same state.\n// Note that the regexes are stateful. We utilize lastIndex and sync it\n// across the multiple regexes used. In addition to the five regexes below\n// we also dynamically create a regex to find the matching end tags for raw\n// text elements.\n\n/**\n * End of text is: `<` followed by:\n * (comment start) or (tag) or (dynamic tag binding)\n */\nconst textEndRegex = /<(?:(!--|\\/[^a-zA-Z])|(\\/?[a-zA-Z][^>\\s]*)|(\\/?$))/g;\nconst COMMENT_START = 1;\nconst TAG_NAME = 2;\nconst DYNAMIC_TAG_NAME = 3;\n\nconst commentEndRegex = /-->/g;\n/**\n * Comments not started with <!--, like </{, can be ended by a single `>`\n */\nconst comment2EndRegex = />/g;\n\n/**\n * The tagEnd regex matches the end of the \"inside an opening\" tag syntax\n * position. It either matches a `>`, an attribute-like sequence, or the end\n * of the string after a space (attribute-name position ending).\n *\n * See attributes in the HTML spec:\n * https://www.w3.org/TR/html5/syntax.html#elements-attributes\n *\n * \" \\t\\n\\f\\r\" are HTML space characters:\n * https://infra.spec.whatwg.org/#ascii-whitespace\n *\n * So an attribute is:\n * * The name: any character except a whitespace character, (\"), ('), \">\",\n * \"=\", or \"/\". Note: this is different from the HTML spec which also excludes control characters.\n * * Followed by zero or more space characters\n * * Followed by \"=\"\n * * Followed by zero or more space characters\n * * Followed by:\n * * Any character except space, ('), (\"), \"<\", \">\", \"=\", (`), or\n * * (\") then any non-(\"), or\n * * (') then any non-(')\n */\nconst tagEndRegex = new RegExp(\n `>|${SPACE_CHAR}(?:(${NAME_CHAR}+)(${SPACE_CHAR}*=${SPACE_CHAR}*(?:${ATTR_VALUE_CHAR}|(\"|')|))|$)`,\n 'g'\n);\nconst ENTIRE_MATCH = 0;\nconst ATTRIBUTE_NAME = 1;\nconst SPACES_AND_EQUALS = 2;\nconst QUOTE_CHAR = 3;\n\nconst singleQuoteAttrEndRegex = /'/g;\nconst doubleQuoteAttrEndRegex = /\"/g;\n/**\n * Matches the raw text elements.\n *\n * Comments are not parsed within raw text elements, so we need to search their\n * text content for marker strings.\n */\nconst rawTextElement = /^(?:script|style|textarea|title)$/i;\n\n/** TemplateResult types */\nconst HTML_RESULT = 1;\nconst SVG_RESULT = 2;\nconst MATHML_RESULT = 3;\n\ntype ResultType = typeof HTML_RESULT | typeof SVG_RESULT | typeof MATHML_RESULT;\n\n// TemplatePart types\n// IMPORTANT: these must match the values in PartType\nconst ATTRIBUTE_PART = 1;\nconst CHILD_PART = 2;\nconst PROPERTY_PART = 3;\nconst BOOLEAN_ATTRIBUTE_PART = 4;\nconst EVENT_PART = 5;\nconst ELEMENT_PART = 6;\nconst COMMENT_PART = 7;\n\n/**\n * The return type of the template tag functions, {@linkcode html} and\n * {@linkcode svg} when it hasn't been compiled by @lit-labs/compiler.\n *\n * A `TemplateResult` object holds all the information about a template\n * expression required to render it: the template strings, expression values,\n * and type of template (html or svg).\n *\n * `TemplateResult` objects do not create any DOM on their own. To create or\n * update DOM you need to render the `TemplateResult`. See\n * [Rendering](https://lit.dev/docs/components/rendering) for more information.\n *\n */\nexport type UncompiledTemplateResult<T extends ResultType = ResultType> = {\n // This property needs to remain unminified.\n ['_$litType$']: T;\n strings: TemplateStringsArray;\n values: unknown[];\n};\n\n/**\n * This is a template result that may be either uncompiled or compiled.\n *\n * In the future, TemplateResult will be this type. If you want to explicitly\n * note that a template result is potentially compiled, you can reference this\n * type and it will continue to behave the same through the next major version\n * of Lit. This can be useful for code that wants to prepare for the next\n * major version of Lit.\n */\nexport type MaybeCompiledTemplateResult<T extends ResultType = ResultType> =\n | UncompiledTemplateResult<T>\n | CompiledTemplateResult;\n\n/**\n * The return type of the template tag functions, {@linkcode html} and\n * {@linkcode svg}.\n *\n * A `TemplateResult` object holds all the information about a template\n * expression required to render it: the template strings, expression values,\n * and type of template (html or svg).\n *\n * `TemplateResult` objects do not create any DOM on their own. To create or\n * update DOM you need to render the `TemplateResult`. See\n * [Rendering](https://lit.dev/docs/components/rendering) for more information.\n *\n * In Lit 4, this type will be an alias of\n * MaybeCompiledTemplateResult, so that code will get type errors if it assumes\n * that Lit templates are not compiled. When deliberately working with only\n * one, use either {@linkcode CompiledTemplateResult} or\n * {@linkcode UncompiledTemplateResult} explicitly.\n */\nexport type TemplateResult<T extends ResultType = ResultType> =\n UncompiledTemplateResult<T>;\n\nexport type HTMLTemplateResult = TemplateResult<typeof HTML_RESULT>;\n\nexport type SVGTemplateResult = TemplateResult<typeof SVG_RESULT>;\n\nexport type MathMLTemplateResult = TemplateResult<typeof MATHML_RESULT>;\n\n/**\n * A TemplateResult that has been compiled by @lit-labs/compiler, skipping the\n * prepare step.\n */\nexport interface CompiledTemplateResult {\n // This is a factory in order to make template initialization lazy\n // and allow ShadyRenderOptions scope to be passed in.\n // This property needs to remain unminified.\n ['_$litType$']: CompiledTemplate;\n values: unknown[];\n}\n\nexport interface CompiledTemplate extends Omit<Template, 'el'> {\n // el is overridden to be optional. We initialize it on first render\n el?: HTMLTemplateElement;\n\n // The prepared HTML string to create a template element from.\n // The type is a TemplateStringsArray to guarantee that the value came from\n // source code, preventing a JSON injection attack.\n h: TemplateStringsArray;\n}\n\n/**\n * Generates a template literal tag function that returns a TemplateResult with\n * the given result type.\n */\nconst tag =\n <T extends ResultType>(type: T) =>\n (strings: TemplateStringsArray, ...values: unknown[]): TemplateResult<T> => {\n // Warn against templates octal escape sequences\n // We do this here rather than in render so that the warning is closer to the\n // template definition.\n if (DEV_MODE && strings.some((s) => s === undefined)) {\n console.warn(\n 'Some template strings are undefined.\\n' +\n 'This is probably caused by illegal octal escape sequences.'\n );\n }\n if (DEV_MODE) {\n // Import static-html.js results in a circular dependency which g3 doesn't\n // handle. Instead we know that static values must have the field\n // `_$litStatic$`.\n if (\n values.some((val) => (val as {_$litStatic$: unknown})?.['_$litStatic$'])\n ) {\n issueWarning(\n '',\n `Static values 'literal' or 'unsafeStatic' cannot be used as values to non-static templates.\\n` +\n `Please use the static 'html' tag function. See https://lit.dev/docs/templates/expressions/#static-expressions`\n );\n }\n }\n return {\n // This property needs to remain unminified.\n ['_$litType$']: type,\n strings,\n values,\n };\n };\n\n/**\n * Interprets a template literal as an HTML template that can efficiently\n * render to and update a container.\n *\n * ```ts\n * const header = (title: string) => html`<h1>${title}</h1>`;\n * ```\n *\n * The `html` tag returns a description of the DOM to render as a value. It is\n * lazy, meaning no work is done until the template is rendered. When rendering,\n * if a template comes from the same expression as a previously rendered result,\n * it's efficiently updated instead of replaced.\n */\nexport const html = tag(HTML_RESULT);\n\n/**\n * Interprets a template literal as an SVG fragment that can efficiently render\n * to and update a container.\n *\n * ```ts\n * const rect = svg`<rect width=\"10\" height=\"10\"></rect>`;\n *\n * const myImage = html`\n * <svg viewBox=\"0 0 10 10\" xmlns=\"http://www.w3.org/2000/svg\">\n * ${rect}\n * </svg>`;\n * ```\n *\n * The `svg` *tag function* should only be used for SVG fragments, or elements\n * that would be contained **inside** an `<svg>` HTML element. A common error is\n * placing an `<svg>` *element* in a template tagged with the `svg` tag\n * function. The `<svg>` element is an HTML element and should be used within a\n * template tagged with the {@linkcode html} tag function.\n *\n * In LitElement usage, it's invalid to return an SVG fragment from the\n * `render()` method, as the SVG fragment will be contained within the element's\n * shadow root and thus not be properly contained within an `<svg>` HTML\n * element.\n */\nexport const svg = tag(SVG_RESULT);\n\n/**\n * Interprets a template literal as MathML fragment that can efficiently render\n * to and update a container.\n *\n * ```ts\n * const num = mathml`<mn>1</mn>`;\n *\n * const eq = html`\n * <math>\n * ${num}\n * </math>`;\n * ```\n *\n * The `mathml` *tag function* should only be used for MathML fragments, or\n * elements that would be contained **inside** a `<math>` HTML element. A common\n * error is placing a `<math>` *element* in a template tagged with the `mathml`\n * tag function. The `<math>` element is an HTML element and should be used\n * within a template tagged with the {@linkcode html} tag function.\n *\n * In LitElement usage, it's invalid to return an MathML fragment from the\n * `render()` method, as the MathML fragment will be contained within the\n * element's shadow root and thus not be properly contained within a `<math>`\n * HTML element.\n */\nexport const mathml = tag(MATHML_RESULT);\n\n/**\n * A sentinel value that signals that a value was handled by a directive and\n * should not be written to the DOM.\n */\nexport const noChange = Symbol.for('lit-noChange');\n\n/**\n * A sentinel value that signals a ChildPart to fully clear its content.\n *\n * ```ts\n * const button = html`${\n * user.isAdmin\n * ? html`<button>DELETE</button>`\n * : nothing\n * }`;\n * ```\n *\n * Prefer using `nothing` over other falsy values as it provides a consistent\n * behavior between various expression binding contexts.\n *\n * In child expressions, `undefined`, `null`, `''`, and `nothing` all behave the\n * same and render no nodes. In attribute expressions, `nothing` _removes_ the\n * attribute, while `undefined` and `null` will render an empty string. In\n * property expressions `nothing` becomes `undefined`.\n */\nexport const nothing = Symbol.for('lit-nothing');\n\n/**\n * The cache of prepared templates, keyed by the tagged TemplateStringsArray\n * and _not_ accounting for the specific template tag used. This means that\n * template tags cannot be dynamic - they must statically be one of html, svg,\n * or attr. This restriction simplifies the cache lookup, which is on the hot\n * path for rendering.\n */\nconst templateCache = new WeakMap<TemplateStringsArray, Template>();\n\n/**\n * Object specifying options for controlling lit-html rendering. Note that\n * while `render` may be called multiple times on the same `container` (and\n * `renderBefore` reference node) to efficiently update the rendered content,\n * only the options passed in during the first render are respected during\n * the lifetime of renders to that unique `container` + `renderBefore`\n * combination.\n */\nexport interface RenderOptions {\n /**\n * An object to use as the `this` value for event listeners. It's often\n * useful to set this to the host component rendering a template.\n */\n host?: object;\n /**\n * A DOM node before which to render content in the container.\n */\n renderBefore?: ChildNode | null;\n /**\n * Node used for cloning the template (`importNode` will be called on this\n * node). This controls the `ownerDocument` of the rendered DOM, along with\n * any inherited context. Defaults to the global `document`.\n */\n creationScope?: {importNode(node: Node, deep?: boolean): Node};\n /**\n * The initial connected state for the top-level part being rendered. If no\n * `isConnected` option is set, `AsyncDirective`s will be connected by\n * default. Set to `false` if the initial render occurs in a disconnected tree\n * and `AsyncDirective`s should see `isConnected === false` for their initial\n * render. The `part.setConnected()` method must be used subsequent to initial\n * render to change the connected state of the part.\n */\n isConnected?: boolean;\n}\n\nconst walker = d.createTreeWalker(\n d,\n 129 /* NodeFilter.SHOW_{ELEMENT|COMMENT} */\n);\n\nlet sanitizerFactoryInternal: SanitizerFactory = noopSanitizer;\n\n//\n// Classes only below here, const variable declarations only above here...\n//\n// Keeping variable declarations and classes together improves minification.\n// Interfaces and type aliases can be interleaved freely.\n//\n\n// Type for classes that have a `_directive` or `_directives[]` field, used by\n// `resolveDirective`\nexport interface DirectiveParent {\n _$parent?: DirectiveParent;\n _$isConnected: boolean;\n __directive?: Directive;\n __directives?: Array<Directive | undefined>;\n}\n\nfunction trustFromTemplateString(\n tsa: TemplateStringsArray,\n stringFromTSA: string\n): TrustedHTML {\n // A security check to prevent spoofing of Lit template results.\n // In the future, we may be able to replace this with Array.isTemplateObject,\n // though we might need to make that check inside of the html and svg\n // functions, because precompiled templates don't come in as\n // TemplateStringArray objects.\n if (!isArray(tsa) || !tsa.hasOwnProperty('raw')) {\n let message = 'invalid template strings array';\n if (DEV_MODE) {\n message = `\n Internal Error: expected template strings to be an array\n with a 'raw' field. Faking a template strings array by\n calling html or svg like an ordinary function is effectively\n the same as calling unsafeHtml and can lead to major security\n issues, e.g. opening your code up to XSS attacks.\n If you're using the html or svg tagged template functions normally\n and still seeing this error, please file a bug at\n https://github.com/lit/lit/issues/new?template=bug_report.md\n and include information about your build tooling, if any.\n `\n .trim()\n .replace(/\\n */g, '\\n');\n }\n throw new Error(message);\n }\n return policy !== undefined\n ? policy.createHTML(stringFromTSA)\n : (stringFromTSA as unknown as TrustedHTML);\n}\n\n/**\n * Returns an HTML string for the given TemplateStringsArray and result type\n * (HTML or SVG), along with the case-sensitive bound attribute names in\n * template order. The HTML contains comment markers denoting the `ChildPart`s\n * and suffixes on bound attributes denoting the `AttributeParts`.\n *\n * @param strings template strings array\n * @param type HTML or SVG\n * @return Array containing `[html, attrNames]` (array returned for terseness,\n * to avoid object fields since this code is shared with non-minified SSR\n * code)\n */\nconst getTemplateHtml = (\n strings: TemplateStringsArray,\n type: ResultType\n): [TrustedHTML, Array<string>] => {\n // Insert makers into the template HTML to represent the position of\n // bindings. The following code scans the template strings to determine the\n // syntactic position of the bindings. They can be in text position, where\n // we insert an HTML comment, attribute value position, where we insert a\n // sentinel string and re-write the attribute name, or inside a tag where\n // we insert the sentinel string.\n const l = strings.length - 1;\n // Stores the case-sensitive bound attribute names in the order of their\n // parts. ElementParts are also reflected in this array as undefined\n // rather than a string, to disambiguate from attribute bindings.\n const attrNames: Array<string> = [];\n let html =\n type === SVG_RESULT ? '<svg>' : type === MATHML_RESULT ? '<math>' : '';\n\n // When we're inside a raw text tag (not it's text content), the regex\n // will still be tagRegex so we can find attributes, but will switch to\n // this regex when the tag ends.\n let rawTextEndRegex: RegExp | undefined;\n\n // The current parsing state, represented as a reference to one of the\n // regexes\n let regex = textEndRegex;\n\n for (let i = 0; i < l; i++) {\n const s = strings[i];\n // The index of the end of the last attribute name. When this is\n // positive at end of a string, it means we're in an attribute value\n // position and need to rewrite the attribute name.\n // We also use a special value of -2 to indicate that we encountered\n // the end of a string in attribute name position.\n let attrNameEndIndex = -1;\n let attrName: string | undefined;\n let lastIndex = 0;\n let match!: RegExpExecArray | null;\n\n // The conditions in this loop handle the current parse state, and the\n // assignments to the `regex` variable are the state transitions.\n while (lastIndex < s.length) {\n // Make sure we start searching from where we previously left off\n regex.lastIndex = lastIndex;\n match = regex.exec(s);\n if (match === null) {\n break;\n }\n lastIndex = regex.lastIndex;\n if (regex === textEndRegex) {\n if (match[COMMENT_START] === '!--') {\n regex = commentEndRegex;\n } else if (match[COMMENT_START] !== undefined) {\n // We started a weird comment, like </{\n regex = comment2EndRegex;\n } else if (match[TAG_NAME] !== undefined) {\n if (rawTextElement.test(match[TAG_NAME])) {\n // Record if we encounter a raw-text element. We'll switch to\n // this regex at the end of the tag.\n rawTextEndRegex = new RegExp(`</${match[TAG_NAME]}`, 'g');\n }\n regex = tagEndRegex;\n } else if (match[DYNAMIC_TAG_NAME] !== undefined) {\n if (DEV_MODE) {\n throw new Error(\n 'Bindings in tag names are not supported. Please use static templates instead. ' +\n 'See https://lit.dev/docs/templates/expressions/#static-expressions'\n );\n }\n regex = tagEndRegex;\n }\n } else if (regex === tagEndRegex) {\n if (match[ENTIRE_MATCH] === '>') {\n // End of a tag. If we had started a raw-text element, use that\n // regex\n regex = rawTextEndRegex ?? textEndRegex;\n // We may be ending an unquoted attribute value, so make sure we\n // clear any pending attrNameEndIndex\n attrNameEndIndex = -1;\n } else if (match[ATTRIBUTE_NAME] === undefined) {\n // Attribute name position\n attrNameEndIndex = -2;\n } else {\n attrNameEndIndex = regex.lastIndex - match[SPACES_AND_EQUALS].length;\n attrName = match[ATTRIBUTE_NAME];\n regex =\n match[QUOTE_CHAR] === undefined\n ? tagEndRegex\n : match[QUOTE_CHAR] === '\"'\n ? doubleQuoteAttrEndRegex\n : singleQuoteAttrEndRegex;\n }\n } else if (\n regex === doubleQuoteAttrEndRegex ||\n regex === singleQuoteAttrEndRegex\n ) {\n regex = tagEndRegex;\n } else if (regex === commentEndRegex || regex === comment2EndRegex) {\n regex = textEndRegex;\n } else {\n // Not one of the five state regexes, so it must be the dynamically\n // created raw text regex and we're at the close of that element.\n regex = tagEndRegex;\n rawTextEndRegex = undefined;\n }\n }\n\n if (DEV_MODE) {\n // If we have a attrNameEndIndex, which indicates that we should\n // rewrite the attribute name, assert that we're in a valid attribute\n // position - either in a tag, or a quoted attribute value.\n console.assert(\n attrNameEndIndex === -1 ||\n regex === tagEndRegex ||\n regex === singleQuoteAttrEndRegex ||\n regex === doubleQuoteAttrEndRegex,\n 'unexpected parse state B'\n );\n }\n\n // We have four cases:\n // 1. We're in text position, and not in a raw text element\n // (regex === textEndRegex): insert a comment marker.\n // 2. We have a non-negative attrNameEndIndex which means we need to\n // rewrite the attribute name to add a bound attribute suffix.\n // 3. We're at the non-first binding in a multi-binding attribute, use a\n // plain marker.\n // 4. We're somewhere else inside the tag. If we're in attribute name\n // position (attrNameEndIndex === -2), add a sequential suffix to\n // generate a unique attribute name.\n\n // Detect a binding next to self-closing tag end and insert a space to\n // separate the marker from the tag end:\n const end =\n regex === tagEndRegex && strings[i + 1].startsWith('/>') ? ' ' : '';\n html +=\n regex === textEndRegex\n ? s + nodeMarker\n : attrNameEndIndex >= 0\n ? (attrNames.push(attrName!),\n s.slice(0, attrNameEndIndex) +\n boundAttributeSuffix +\n s.slice(attrNameEndIndex)) +\n marker +\n end\n : s + marker + (attrNameEndIndex === -2 ? i : end);\n }\n\n const htmlResult: string | TrustedHTML =\n html +\n (strings[l] || '<?>') +\n (type === SVG_RESULT ? '</svg>' : type === MATHML_RESULT ? '</math>' : '');\n\n // Returned as an array for terseness\n return [trustFromTemplateString(strings, htmlResult), attrNames];\n};\n\n/** @internal */\nexport type {Template};\nclass Template {\n /** @internal */\n el!: HTMLTemplateElement;\n\n parts: Array<TemplatePart> = [];\n\n constructor(\n // This property needs to remain unminified.\n {strings, ['_$litType$']: type}: UncompiledTemplateResult,\n options?: RenderOptions\n ) {\n let node: Node | null;\n let nodeIndex = 0;\n let attrNameIndex = 0;\n const partCount = strings.length - 1;\n const parts = this.parts;\n\n // Create template element\n const [html, attrNames] = getTemplateHtml(strings, type);\n this.el = Template.createElement(html, options);\n walker.currentNode = this.el.content;\n\n // Re-parent SVG or MathML nodes into template root\n if (type === SVG_RESULT || type === MATHML_RESULT) {\n const wrapper = this.el.content.firstChild!;\n wrapper.replaceWith(...wrapper.childNodes);\n }\n\n // Walk the template to find binding markers and create TemplateParts\n while ((node = walker.nextNode()) !== null && parts.length < partCount) {\n if (node.nodeType === 1) {\n if (DEV_MODE) {\n const tag = (node as Element).localName;\n // Warn if `textarea` includes an expression and throw if `template`\n // does since these are not supported. We do this by checking\n // innerHTML for anything that looks like a marker. This catches\n // cases like bindings in textarea there markers turn into text nodes.\n if (\n /^(?:textarea|template)$/i!.test(tag) &&\n (node as Element).innerHTML.includes(marker)\n ) {\n const m =\n `Expressions are not supported inside \\`${tag}\\` ` +\n `elements. See https://lit.dev/msg/expression-in-${tag} for more ` +\n `information.`;\n if (tag === 'template') {\n throw new Error(m);\n } else issueWarning('', m);\n }\n }\n // TODO (justinfagnani): for attempted dynamic tag names, we don't\n // increment the bindingIndex, and it'll be off by 1 in the element\n // and off by two after it.\n if ((node as Element).hasAttributes()) {\n for (const name of (node as Element).getAttributeNames()) {\n if (name.endsWith(boundAttributeSuffix)) {\n const realName = attrNames[attrNameIndex++];\n const value = (node as Element).getAttribute(name)!;\n const statics = value.split(marker);\n const m = /([.?@])?(.*)/.exec(realName)!;\n parts.push({\n type: ATTRIBUTE_PART,\n index: nodeIndex,\n name: m[2],\n strings: statics,\n ctor:\n m[1] === '.'\n ? PropertyPart\n : m[1] === '?'\n ? BooleanAttributePart\n : m[1] === '@'\n ? EventPart\n : AttributePart,\n });\n (node as Element).removeAttribute(name);\n } else if (name.startsWith(marker)) {\n parts.push({\n type: ELEMENT_PART,\n index: nodeIndex,\n });\n (node as Element).removeAttribute(name);\n }\n }\n }\n // TODO (justinfagnani): benchmark the regex against testing for each\n // of the 3 raw text element names.\n if (rawTextElement.test((node as Element).tagName)) {\n // For raw text elements we need to split the text content on\n // markers, create a Text node for each segment, and create\n // a TemplatePart for each marker.\n const strings = (node as Element).textContent!.split(marker);\n const lastIndex = strings.length - 1;\n if (lastIndex > 0) {\n (node as Element).textContent = trustedTypes\n ? (trustedTypes.emptyScript as unknown as '')\n : '';\n // Generate a new text node for each literal section\n // These nodes are also used as the markers for child parts\n for (let i = 0; i < lastIndex; i++) {\n (node as Element).append(strings[i], createMarker());\n // Walk past the marker node we just added\n walker.nextNode();\n parts.push({type: CHILD_PART, index: ++nodeIndex});\n }\n // Note because this marker is added after the walker's current\n // node, it will be walked to in the outer loop (and ignored), so\n // we don't need to adjust nodeIndex here\n (node as Element).append(strings[lastIndex], createMarker());\n }\n }\n } else if (node.nodeType === 8) {\n const data = (node as Comment).data;\n if (data === markerMatch) {\n parts.push({type: CHILD_PART, index: nodeIndex});\n } else {\n let i = -1;\n while ((i = (node as Comment).data.indexOf(marker, i + 1)) !== -1) {\n // Comment node has a binding marker inside, make an inactive part\n // The binding won't work, but subsequent bindings will\n parts.push({type: COMMENT_PART, index: nodeIndex});\n // Move to the end of the match\n i += marker.length - 1;\n }\n }\n }\n nodeIndex++;\n }\n\n if (DEV_MODE) {\n // If there was a duplicate attribute on a tag, then when the tag is\n // parsed into an element the attribute gets de-duplicated. We can detect\n // this mismatch if we haven't precisely consumed every attribute name\n // when preparing the template. This works because `attrNames` is built\n // from the template string and `attrNameIndex` comes from processing the\n // resulting DOM.\n if (attrNames.length !== attrNameIndex) {\n throw new Error(\n `Detected duplicate attribute bindings. This occurs if your template ` +\n `has duplicate attributes on an element tag. For example ` +\n `\"<input ?disabled=\\${true} ?disabled=\\${false}>\" contains a ` +\n `duplicate \"disabled\" attribute. The error was detected in ` +\n `the following template: \\n` +\n '`' +\n strings.join('${...}') +\n '`'\n );\n }\n }\n\n // We could set walker.currentNode to another node here to prevent a memory\n // leak, but every time we prepare a template, we immediately render it\n // and re-use the walker in new TemplateInstance._clone().\n debugLogEvent &&\n debugLogEvent({\n kind: 'template prep',\n template: this,\n clonableTemplate: this.el,\n parts: this.parts,\n strings,\n });\n }\n\n // Overridden via `litHtmlPolyfillSupport` to provide platform support.\n /** @nocollapse */\n static createElement(html: TrustedHTML, _options?: RenderOptions) {\n const el = d.createElement('template');\n el.innerHTML = html as unknown as string;\n return el;\n }\n}\n\nexport interface Disconnectable {\n _$parent?: Disconnectable;\n _$disconnectableChildren?: Set<Disconnectable>;\n // Rather than hold connection state on instances, Disconnectables recursively\n // fetch the connection state from the RootPart they are connected in via\n // getters up the Disconnectable tree via _$parent references. This pushes the\n // cost of tracking the isConnected state to `AsyncDirectives`, and avoids\n // needing to pass all Disconnectables (parts, template instances, and\n // directives) their connection state each time it changes, which would be\n // costly for trees that have no AsyncDirectives.\n _$isConnected: boolean;\n}\n\nfunction resolveDirective(\n part: ChildPart | AttributePart | ElementPart,\n value: unknown,\n parent: DirectiveParent = part,\n attributeIndex?: number\n): unknown {\n // Bail early if the value is explicitly noChange. Note, this means any\n // nested directive is still attached and is not run.\n if (value === noChange) {\n return value;\n }\n let currentDirective =\n attributeIndex !== undefined\n ? (parent as AttributePart).__directives?.[attributeIndex]\n : (parent as ChildPart | ElementPart | Directive).__directive;\n const nextDirectiveConstructor = isPrimitive(value)\n ? undefined\n : // This property needs to remain unminified.\n (value as DirectiveResult)['_$litDirective$'];\n if (currentDirective?.constructor !== nextDirectiveConstructor) {\n // This property needs to remain unminified.\n currentDirective?.['_$notifyDirectiveConnectionChanged']?.(false);\n if (nextDirectiveConstructor === undefined) {\n currentDirective = undefined;\n } else {\n currentDirective = new nextDirectiveConstructor(part as PartInfo);\n currentDirective._$initialize(part, parent, attributeIndex);\n }\n if (attributeIndex !== undefined) {\n ((parent as AttributePart).__directives ??= [])[attributeIndex] =\n currentDirective;\n } else {\n (parent as ChildPart | Directive).__directive = currentDirective;\n }\n }\n if (currentDirective !== undefined) {\n value = resolveDirective(\n part,\n currentDirective._$resolve(part, (value as DirectiveResult).values),\n currentDirective,\n attributeIndex\n );\n }\n return value;\n}\n\nexport type {TemplateInstance};\n/**\n * An updateable instance of a Template. Holds references to the Parts used to\n * update the template instance.\n */\nclass TemplateInstance implements Disconnectable {\n _$template: Template;\n _$parts: Array<Part | undefined> = [];\n\n /** @internal */\n _$parent: ChildPart;\n /** @internal */\n _$disconnectableChildren?: Set<Disconnectable> = undefined;\n\n constructor(template: Template, parent: ChildPart) {\n this._$template = template;\n this._$parent = parent;\n }\n\n // Called by ChildPart parentNode getter\n get parentNode() {\n return this._$parent.parentNode;\n }\n\n // See comment in Disconnectable interface for why this is a getter\n get _$isConnected() {\n return this._$parent._$isConnected;\n }\n\n // This method is separate from the constructor because we need to return a\n // DocumentFragment and we don't want to hold onto it with an instance field.\n _clone(options: RenderOptions | undefined) {\n const {\n el: {content},\n parts: parts,\n } = this._$template;\n const fragment = (options?.creationScope ?? d).importNode(content, true);\n walker.currentNode = fragment;\n\n let node = walker.nextNode()!;\n let nodeIndex = 0;\n let partIndex = 0;\n let templatePart = parts[0];\n\n while (templatePart !== undefined) {\n if (nodeIndex === templatePart.index) {\n let part: Part | undefined;\n if (templatePart.type === CHILD_PART) {\n part = new ChildPart(\n node as HTMLElement,\n node.nextSibling,\n this,\n options\n );\n } else if (templatePart.type === ATTRIBUTE_PART) {\n part = new templatePart.ctor(\n node as HTMLElement,\n templatePart.name,\n templatePart.strings,\n this,\n options\n );\n } else if (templatePart.type === ELEMENT_PART) {\n part = new ElementPart(node as HTMLElement, this, options);\n }\n this._$parts.push(part);\n templatePart = parts[++partIndex];\n }\n if (nodeIndex !== templatePart?.index) {\n node = walker.nextNode()!;\n nodeIndex++;\n }\n }\n // We need to set the currentNode away from the cloned tree so that we\n // don't hold onto the tree even if the tree is detached and should be\n // freed.\n walker.currentNode = d;\n return fragment;\n }\n\n _update(values: Array<unknown>) {\n let i = 0;\n for (const part of this._$parts) {\n if (part !== undefined) {\n debugLogEvent &&\n debugLogEvent({\n kind: 'set part',\n part,\n value: values[i],\n valueIndex: i,\n values,\n templateInstance: this,\n });\n if ((part as AttributePart).strings !== undefined) {\n (part as AttributePart)._$setValue(values, part as AttributePart, i);\n // The number of values the part consumes is part.strings.length - 1\n // since values are in between template spans. We increment i by 1\n // later in the loop, so increment it by part.strings.length - 2 here\n i += (part as AttributePart).strings!.length - 2;\n } else {\n part._$setValue(values[i]);\n }\n }\n i++;\n }\n }\n}\n\n/*\n * Parts\n */\ntype AttributeTemplatePart = {\n readonly type: typeof ATTRIBUTE_PART;\n readonly index: number;\n readonly name: string;\n readonly ctor: typeof AttributePart;\n readonly strings: ReadonlyArray<string>;\n};\ntype ChildTemplatePart = {\n readonly type: typeof CHILD_PART;\n readonly index: number;\n};\ntype ElementTemplatePart = {\n readonly type: typeof ELEMENT_PART;\n readonly index: number;\n};\ntype CommentTemplatePart = {\n readonly type: typeof COMMENT_PART;\n readonly index: number;\n};\n\n/**\n * A TemplatePart represents a dynamic part in a template, before the template\n * is instantiated. When a template is instantiated Parts are created from\n * TemplateParts.\n */\ntype TemplatePart =\n | ChildTemplatePart\n | AttributeTemplatePart\n | ElementTemplatePart\n | CommentTemplatePart;\n\nexport type Part =\n | ChildPart\n | AttributePart\n | PropertyPart\n | BooleanAttributePart\n | ElementPart\n | EventPart;\n\nexport type {ChildPart};\nclass ChildPart implements Disconnectable {\n readonly type = CHILD_PART;\n readonly options: RenderOptions | undefined;\n _$committedValue: unknown = nothing;\n /** @internal */\n __directive?: Directive;\n /** @internal */\n _$startNode: ChildNode;\n /** @internal */\n _$endNode: ChildNode | null;\n private _textSanitizer: ValueSanitizer | undefined;\n /** @internal */\n _$parent: Disconnectable | undefined;\n /**\n * Connection state for RootParts only (i.e. ChildPart without _$parent\n * returned from top-level `render`). This field is unused otherwise. The\n * intention would be clearer if we made `RootPart` a subclass of `ChildPart`\n * with this field (and a different _$isConnected getter), but the subclass\n * caused a perf regression, possibly due to making call sites polymorphic.\n * @internal\n */\n __isConnected: boolean;\n\n // See comment in Disconnectable interface for why this is a getter\n get _$isConnected() {\n // ChildParts that are not at the root should always be created with a\n // parent; only RootChildNode's won't, so they return the local isConnected\n // state\n return this._$parent?._$isConnected ?? this.__isConnected;\n }\n\n // The following fields will be patched onto ChildParts when required by\n // AsyncDirective\n /** @internal */\n _$disconnectableChildren?: Set<Disconnectable> = undefined;\n /** @internal */\n _$notifyConnectionChanged?(\n isConnected: boolean,\n removeFromParent?: boolean,\n from?: number\n ): void;\n /** @internal */\n _$reparentDisconnectables?(parent: Disconnectable): void;\n\n constructor(\n startNode: ChildNode,\n endNode: ChildNode | null,\n parent: TemplateInstance | ChildPart | undefined,\n options: RenderOptions | undefined\n ) {\n this._$startNode = startNode;\n this._$endNode = endNode;\n this._$parent = parent;\n this.options = options;\n // Note __isConnected is only ever accessed on RootParts (i.e. when there is\n // no _$parent); the value on a non-root-part is \"don't care\", but checking\n // for parent would be more code\n this.__isConnected = options?.isConnected ?? true;\n if (ENABLE_EXTRA_SECURITY_HOOKS) {\n // Explicitly initialize for consistent class shape.\n this._textSanitizer = undefined;\n }\n }\n\n /**\n * The parent node into which the part renders its content.\n *\n * A ChildPart's content consists of a range of adjacent child nodes of\n * `.parentNode`, possibly bordered by 'marker nodes' (`.startNode` and\n * `.endNode`).\n *\n * - If both `.startNode` and `.endNode` are non-null, then the part's content\n * consists of all siblings between `.startNode` and `.endNode`, exclusively.\n *\n * - If `.startNode` is non-null but `.endNode` is null, then the part's\n * content consists of all siblings following `.startNode`, up to and\n * including the last child of `.parentNode`. If `.endNode` is non-null, then\n * `.startNode` will always be non-null.\n *\n * - If both `.endNode` and `.startNode` are null, then the part's content\n * consists of all child nodes of `.parentNode`.\n */\n get parentNode(): Node {\n let parentNode: Node = wrap(this._$startNode).parentNode!;\n const parent = this._$parent;\n if (\n parent !== undefined &&\n parentNode?.nodeType === 11 /* Node.DOCUMENT_FRAGMENT */\n ) {\n // If the parentNode is a DocumentFragment, it may be because the DOM is\n // still in the cloned fragment during initial render; if so, get the real\n // parentNode the part will be committed into by asking the parent.\n parentNode = (parent as ChildPart | TemplateInstance).parentNode;\n }\n return parentNode;\n }\n\n /**\n * The part's leading marker node, if any. See `.parentNode` for more\n * information.\n */\n get startNode(): Node | null {\n return this._$startNode;\n }\n\n /**\n * The part's trailing marker node, if any. See `.parentNode` for more\n * information.\n */\n get endNode(): Node | null {\n return this._$endNode;\n }\n\n _$setValue(value: unknown, directiveParent: DirectiveParent = this): void {\n if (DEV_MODE && this.parentNode === null) {\n throw new Error(\n `This \\`ChildPart\\` has no \\`parentNode\\` and therefore cannot accept a value. This likely means the element containing the part was manipulated in an unsupported way outside of Lit's control such that the part's marker nodes were ejected from DOM. For example, setting the element's \\`innerHTML\\` or \\`textContent\\` can do this.`\n );\n }\n value = resolveDirective(this, value, directiveParent);\n if (isPrimitive(value)) {\n // Non-rendering child values. It's important that these do not render\n // empty text nodes to avoid issues with preventing default <slot>\n // fallback content.\n if (value === nothing || value == null || value === '') {\n if (this._$committedValue !== nothing) {\n debugLogEvent &&\n debugLogEvent({\n kind: 'commit nothing to child',\n start: this._$startNode,\n end: this._$endNode,\n parent: this._$parent,\n options: this.options,\n });\n this._$clear();\n }\n this._$committedValue = nothing;\n } else if (value !== this._$committedValue && value !== noChange) {\n this._commitText(value);\n }\n // This property needs to remain unminified.\n } else if ((value as TemplateResult)['_$litType$'] !== undefined) {\n this._commitTemplateResult(value as TemplateResult);\n } else if ((value as Node).nodeType !== undefined) {\n if (DEV_MODE && this.options?.host === value) {\n this._commitText(\n `[probable mistake: rendered a template's host in itself ` +\n `(commonly caused by writing \\${this} in a template]`\n );\n console.warn(\n `Attempted to render the template host`,\n value,\n `inside itself. This is almost always a mistake, and in dev mode `,\n `we render some warning text. In production however, we'll `,\n `render it, which will usually result in an error, and sometimes `,\n `in the element disappearing from the DOM.`\n );\n return;\n }\n this._commitNode(value as Node);\n } else if (isIterable(value)) {\n this._commitIterable(value);\n } else {\n // Fallback, will render the string representation\n this._commitText(value);\n }\n }\n\n private _insert<T extends Node>(node: T) {\n return wrap(wrap(this._$startNode).parentNode!).insertBefore(\n node,\n this._$endNode\n );\n }\n\n private _commitNode(value: Node): void {\n if (this._$committedValue !== value) {\n this._$clear();\n if (\n ENABLE_EXTRA_SECURITY_HOOKS &&\n sanitizerFactoryInternal !== noopSanitizer\n ) {\n const parentNodeName = this._$startNode.parentNode?.nodeName;\n if (parentNodeName === 'STYLE' || parentNodeName === 'SCRIPT') {\n let message = 'Forbidden';\n if (DEV_MODE) {\n if (parentNodeName === 'STYLE') {\n message =\n `Lit does not support binding inside style nodes. ` +\n `This is a security risk, as style injection attacks can ` +\n `exfiltrate data and spoof UIs. ` +\n `Consider instead using css\\`...\\` literals ` +\n `to compose styles, and do dynamic styling with ` +\n `css custom properties, ::parts, <slot>s, ` +\n `and by mutating the DOM rather than stylesheets.`;\n } else {\n message =\n `Lit does not support binding inside script nodes. ` +\n `This is a security risk, as it could allow arbitrary ` +\n `code execution.`;\n }\n }\n throw new Error(message);\n }\n }\n debugLogEvent &&\n debugLogEvent({\n kind: 'commit node',\n start: this._$startNode,\n parent: this._$parent,\n value: value,\n options: this.options,\n });\n this._$committedValue = this._insert(value);\n }\n }\n\n private _commitText(value: unknown): void {\n // If the committed value is a primitive it means we called _commitText on\n // the previous render, and we know that this._$startNode.nextSibling is a\n // Text node. We can now just replace the text content (.data) of the node.\n if (\n this._$committedValue !== nothing &&\n isPrimitive(this._$committedValue)\n ) {\n const node = wrap(this._$startNode).nextSibling as Text;\n if (ENABLE_EXTRA_SECURITY_HOOKS) {\n if (this._textSanitizer === undefined) {\n this._textSanitizer = createSanitizer(node, 'data', 'property');\n }\n value = this._textSanitizer(value);\n }\n debugLogEvent &&\n debugLogEvent({\n kind: 'commit text',\n node,\n value,\n options: this.options,\n });\n (node as Text).data = value as string;\n } else {\n if (ENABLE_EXTRA_SECURITY_HOOKS) {\n const textNode = d.createTextNode('');\n this._commitNode(textNode);\n // When setting text content, for security purposes it matters a lot\n // what the parent is. For example, <style> and <script> need to be\n // handled with care, while <span> does not. So first we need to put a\n // text node into the document, then we can sanitize its content.\n if (this._textSanitizer === undefined) {\n this._textSanitizer = createSanitizer(textNode, 'data', 'property');\n }\n value = this._textSanitizer(value);\n debugLogEvent &&\n debugLogEvent({\n kind: 'commit text',\n node: textNode,\n value,\n options: this.options,\n });\n textNode.data = value as string;\n } else {\n this._commitNode(d.createTextNode(value as string));\n debugLogEvent &&\n debugLogEvent({\n kind: 'commit text',\n node: wrap(this._$startNode).nextSibling as Text,\n value,\n options: this.options,\n });\n }\n }\n this._$committedValue = value;\n }\n\n private _commitTemplateResult(\n result: TemplateResult | CompiledTemplateResult\n ): void {\n // This property needs to remain unminified.\n const {values, ['_$litType$']: type} = result;\n // If $litType$ is a number, result is a plain TemplateResult and we get\n // the template from the template cache. If not, result is a\n // CompiledTemplateResult and _$litType$ is a CompiledTemplate and we need\n // to create the <template> element the first time we see it.\n const template: Template | CompiledTemplate =\n typeof type === 'number'\n ? this._$getTemplate(result as UncompiledTemplateResult)\n : (type.el === undefined &&\n (type.el = Template.createElement(\n trustFromTemplateString(type.h, type.h[0]),\n this.options\n )),\n type);\n\n if ((this._$committedValue as TemplateInstance)?._$template === template) {\n debugLogEvent &&\n debugLogEvent({\n kind: 'template updating',\n template,\n instance: this._$committedValue as TemplateInstance,\n parts: (this._$committedValue as TemplateInstance)._$parts,\n options: this.options,\n values,\n });\n (this._$committedValue as TemplateInstance)._update(values);\n } else {\n const instance = new TemplateInstance(template as Template, this);\n const fragment = instance._clone(this.options);\n debugLogEvent &&\n debugLogEvent({\n kind: 'template instantiated',\n template,\n instance,\n parts: instance._$parts,\n options: this.options,\n fragment,\n values,\n });\n instance._update(values);\n debugLogEvent &&\n debugLogEvent({\n kind: 'template instantiated and updated',\n template,\n instance,\n parts: instance._$parts,\n options: this.options,\n fragment,\n values,\n });\n this._commitNode(fragment);\n this._$committedValue = instance;\n }\n }\n\n // Overridden via `litHtmlPolyfillSupport` to provide platform support.\n /** @internal */\n _$getTemplate(result: UncompiledTemplateResult) {\n let template = templateCache.get(result.strings);\n if (template === undefined) {\n templateCache.set(result.strings, (template = new Template(result)));\n }\n return template;\n }\n\n private _commitIterable(value: Iterable<unknown>): void {\n // For an Iterable, we create a new InstancePart per item, then set its\n // value to the item. This is a little bit of overhead for every item in\n // an Iterable, but it lets us recurse easily and efficiently update Arrays\n // of TemplateResults that will be commonly returned from expressions like:\n // array.map((i) => html`${i}`), by reusing existing TemplateInstances.\n\n // If value is an array, then the previous render was of an\n // iterable and value will contain the ChildParts from the previous\n // render. If value is not an array, clear this part and make a new\n // array for ChildParts.\n if (!isArray(this._$committedValue)) {\n this._$committedValue = [];\n this._$clear();\n }\n\n // Lets us keep track of how many items we stamped so we can clear leftover\n // items from a previous render\n const itemParts = this._$committedValue as ChildPart[];\n let partIndex = 0;\n let itemPart: ChildPart | undefined;\n\n for (const item of value) {\n if (partIndex === itemParts.length) {\n // If no existing part, create a new one\n // TODO (justinfagnani): test perf impact of always creating two parts\n // instead of sharing parts between nodes\n // https://github.com/lit/lit/issues/1266\n itemParts.push(\n (itemPart = new ChildPart(\n this._insert(createMarker()),\n this._insert(createMarker()),\n this,\n this.options\n ))\n );\n } else {\n // Reuse an existing part\n itemPart = itemParts[partIndex];\n }\n itemPart._$setValue(item);\n partIndex++;\n }\n\n if (partIndex < itemParts.length) {\n // itemParts always have end nodes\n this._$clear(\n itemPart && wrap(itemPart._$endNode!).nextSibling,\n partIndex\n );\n // Truncate the parts array so _value reflects the current state\n itemParts.length = partIndex;\n }\n }\n\n /**\n * Removes the nodes contained within this Part from the DOM.\n *\n * @param start Start node to clear from, for clearing a subset of the part's\n * DOM (used when truncating iterables)\n * @param from When `start` is specified, the index within the iterable from\n * which ChildParts are being removed, used for disconnecting directives\n * in those Parts.\n *\n * @internal\n */\n _$clear(\n start: ChildNode | null = wrap(this._$startNode).nextSibling,\n from?: number\n ) {\n this._$notifyConnectionChanged?.(false, true, from);\n while (start !== this._$endNode) {\n // The non-null assertion is safe because if _$startNode.nextSibling is\n // null, then _$endNode is also null, and we would not have entered this\n // loop.\n const n = wrap(start!).nextSibling;\n wrap(start!).remove();\n start = n;\n }\n }\n\n /**\n * Implementation of RootPart's `isConnected`. Note that this method\n * should only be called on `RootPart`s (the `ChildPart` returned from a\n * top-level `render()` call). It has no effect on non-root ChildParts.\n * @param isConnected Whether to set\n * @internal\n */\n setConnected(isConnected: boolean) {\n if (this._$parent === undefined) {\n this.__isConnected = isConnected;\n this._$notifyConnectionChanged?.(isConnected);\n } else if (DEV_MODE) {\n throw new Error(\n 'part.setConnected() may only be called on a ' +\n 'RootPart returned from render().'\n );\n }\n }\n}\n\n/**\n * A top-level `ChildPart` returned from `render` that manages the connected\n * state of `AsyncDirective`s created throughout the tree below it.\n */\nexport interface RootPart extends ChildPart {\n /**\n * Sets the connection state for `AsyncDirective`s contained within this root\n * ChildPart.\n *\n * lit-html does not automatically monitor the connectedness of DOM rendered;\n * as such, it is the responsibility of the caller to `render` to ensure that\n * `part.setConnected(false)` is called before the part object is potentially\n * discarded, to ensure that `AsyncDirective`s have a chance to dispose of\n * any resources being held. If a `RootPart` that was previously\n * disconnected is subsequently re-connected (and its `AsyncDirective`s should\n * re-connect), `setConnected(true)` should be called.\n *\n * @param isConnected Whether directives within this tree should be connected\n * or not\n */\n setConnected(isConnected: boolean): void;\n}\n\nexport type {AttributePart};\nclass AttributePart implements Disconnectable {\n readonly type:\n | typeof ATTRIBUTE_PART\n | typeof PROPERTY_PART\n | typeof BOOLEAN_ATTRIBUTE_PART\n | typeof EVENT_PART = ATTRIBUTE_PART;\n readonly element: HTMLElement;\n readonly name: string;\n readonly options: RenderOptions | undefined;\n\n /**\n * If this attribute part represents an interpolation, this contains the\n * static strings of the interpolation. For single-value, complete bindings,\n * this is undefined.\n */\n readonly strings?: ReadonlyArray<string>;\n /** @internal */\n _$committedValue: unknown | Array<unknown> = nothing;\n /** @internal */\n __directives?: Array<Directive | undefined>;\n /** @internal */\n _$parent: Disconnectable;\n /** @internal */\n _$disconnectableChildren?: Set<Disconnectable> = undefined;\n\n protected _sanitizer: ValueSanitizer | undefined;\n\n get tagName() {\n return this.element.tagName;\n }\n\n // See comment in Disconnectable interface for why this is a getter\n get _$isConnected() {\n return this._$parent._$isConnected;\n }\n\n constructor(\n element: HTMLElement,\n name: string,\n strings: ReadonlyArray<string>,\n parent: Disconnectable,\n options: RenderOptions | undefined\n ) {\n this.element = element;\n this.name = name;\n this._$parent = parent;\n this.options = options;\n if (strings.length > 2 || strings[0] !== '' || strings[1] !== '') {\n this._$committedValue = new Array(strings.length - 1).fill(new String());\n this.strings = strings;\n } else {\n this._$committedValue = nothing;\n }\n if (ENABLE_EXTRA_SECURITY_HOOKS) {\n this._sanitizer = undefined;\n }\n }\n\n /**\n * Sets the value of this part by resolving the value from possibly multiple\n * values and static strings and committing it to the DOM.\n * If this part is single-valued, `this._strings` will be undefined, and the\n * method will be called with a single value argument. If this part is\n * multi-value, `this._strings` will be defined, and the method is called\n * with the value array of the part's owning TemplateInstance, and an offset\n * into the value array from which the values should be read.\n * This method is overloaded this way to eliminate short-lived array slices\n * of the template instance values, and allow a fast-path for single-valued\n * parts.\n *\n * @param value The part value, or an array of values for multi-valued parts\n * @param valueIndex the index to start reading values from. `undefined` for\n * single-valued parts\n * @param noCommit causes the part to not commit its value to the DOM. Used\n * in hydration to prime attribute parts with their first-rendered value,\n * but not set the attribute, and in SSR to no-op the DOM operation and\n * capture the value for serialization.\n *\n * @internal\n */\n _$setValue(\n value: unknown | Array<unknown>,\n directiveParent: DirectiveParent = this,\n valueIndex?: number,\n noCommit?: boolean\n ) {\n const strings = this.strings;\n\n // Whether any of the values has changed, for dirty-checking\n let change = false;\n\n if (strings === undefined) {\n // Single-value binding case\n value = resolveDirective(this, value, directiveParent, 0);\n change =\n !isPrimitive(value) ||\n (value !== this._$committedValue && value !== noChange);\n if (change) {\n this._$committedValue = value;\n }\n } else {\n // Interpolation case\n const values = value as Array<unknown>;\n value = strings[0];\n\n let i, v;\n for (i = 0; i < strings.length - 1; i++) {\n v = resolveDirective(this, values[valueIndex! + i], directiveParent, i);\n\n if (v === noChange) {\n // If the user-provided value is `noChange`, use the previous value\n v = (this._$committedValue as Array<unknown>)[i];\n }\n change ||=\n !isPrimitive(v) || v !== (this._$committedValue as Array<unknown>)[i];\n if (v === nothing) {\n value = nothing;\n } else if (value !== nothing) {\n value += (v ?? '') + strings[i + 1];\n }\n // We always record each value, even if one is `nothing`, for future\n // change detection.\n (this._$committedValue as Array<unknown>)[i] = v;\n }\n }\n if (change && !noCommit) {\n this._commitValue(value);\n }\n }\n\n /** @internal */\n _commitValue(value: unknown) {\n if (value === nothing) {\n (wrap(this.element) as Element).removeAttribute(this.name);\n } else {\n if (ENABLE_EXTRA_SECURITY_HOOKS) {\n if (this._sanitizer === undefined) {\n this._sanitizer = sanitizerFactoryInternal(\n this.element,\n this.name,\n 'attribute'\n );\n }\n value = this._sanitizer(value ?? '');\n }\n debugLogEvent &&\n debugLogEvent({\n kind: 'commit attribute',\n element: this.element,\n name: this.name,\n value,\n options: this.options,\n });\n (wrap(this.element) as Element).setAttribute(\n this.name,\n (value ?? '') as string\n );\n }\n }\n}\n\nexport type {PropertyPart};\nclass PropertyPart extends AttributePart {\n override readonly type = PROPERTY_PART;\n\n /** @internal */\n override _commitValue(value: unknown) {\n if (ENABLE_EXTRA_SECURITY_HOOKS) {\n if (this._sanitizer === undefined) {\n this._sanitizer = sanitizerFactoryInternal(\n this.element,\n this.name,\n 'property'\n );\n }\n value = this._sanitizer(value);\n }\n debugLogEvent &&\n debugLogEvent({\n kind: 'commit property',\n element: this.element,\n name: this.name,\n value,\n options: this.options,\n });\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (this.element as any)[this.name] = value === nothing ? undefined : value;\n }\n}\n\nexport type {BooleanAttributePart};\nclass BooleanAttributePart extends AttributePart {\n override readonly type = BOOLEAN_ATTRIBUTE_PART;\n\n /** @internal */\n override _commitValue(value: unknown) {\n debugLogEvent &&\n debugLogEvent({\n kind: 'commit boolean attribute',\n element: this.element,\n name: this.name,\n value: !!(value && value !== nothing),\n options: this.options,\n });\n (wrap(this.element) as Element).toggleAttribute(\n this.name,\n !!value && value !== nothing\n );\n }\n}\n\ntype EventListenerWithOptions = EventListenerOrEventListenerObject &\n Partial<AddEventListenerOptions>;\n\n/**\n * An AttributePart that manages an event listener via add/removeEventListener.\n *\n * This part works by adding itself as the event listener on an element, then\n * delegating to the value passed to it. This reduces the number of calls to\n * add/removeEventListener if the listener changes frequently, such as when an\n * inline function is used as a listener.\n *\n * Because event options are passed when adding listeners, we must take case\n * to add and remove the part as a listener when the event options change.\n */\nexport type {EventPart};\nclass EventPart extends AttributePart {\n override readonly type = EVENT_PART;\n\n constructor(\n element: HTMLElement,\n name: string,\n strings: ReadonlyArray<string>,\n parent: Disconnectable,\n options: RenderOptions | undefined\n ) {\n super(element, name, strings, parent, options);\n\n if (DEV_MODE && this.strings !== undefined) {\n throw new Error(\n `A \\`<${element.localName}>\\` has a \\`@${name}=...\\` listener with ` +\n 'invalid content. Event listeners in templates must have exactly ' +\n 'one expression and no surrounding text.'\n );\n }\n }\n\n // EventPart does not use the base _$setValue/_resolveValue implementation\n // since the dirty checking is more complex\n /** @internal */\n override _$setValue(\n newListener: unknown,\n directiveParent: DirectiveParent = this\n ) {\n newListener =\n resolveDirective(this, newListener, directiveParent, 0) ?? nothing;\n if (newListener === noChange) {\n return;\n }\n const oldListener = this._$committedValue;\n\n // If the new value is nothing or any options change we have to remove the\n // part as a listener.\n const shouldRemoveListener =\n (newListener === nothing && oldListener !== nothing) ||\n (newListener as EventListenerWithOptions).capture !==\n (oldListener as EventListenerWithOptions).capture ||\n (newListener as EventListenerWithOptions).once !==\n (oldListener as EventListenerWithOptions).once ||\n (newListener as EventListenerWithOptions).passive !==\n (oldListener as EventListenerWithOptions).passive;\n\n // If the new value is not nothing and we removed the listener, we have\n // to add the part as a listener.\n const shouldAddListener =\n newListener !== nothing &&\n (oldListener === nothing || shouldRemoveListener);\n\n debugLogEvent &&\n debugLogEvent({\n kind: 'commit event listener',\n element: this.element,\n name: this.name,\n value: newListener,\n options: this.options,\n removeListener: shouldRemoveListener,\n addListener: shouldAddListener,\n oldListener,\n });\n if (shouldRemoveListener) {\n this.element.removeEventListener(\n this.name,\n this,\n oldListener as EventListenerWithOptions\n );\n }\n if (shouldAddListener) {\n this.element.addEventListener(\n this.name,\n this,\n newListener as EventListenerWithOptions\n );\n }\n this._$committedValue = newListener;\n }\n\n handleEvent(event: Event) {\n if (typeof this._$committedValue === 'function') {\n this._$committedValue.call(this.options?.host ?? this.element, event);\n } else {\n (this._$committedValue as EventListenerObject).handleEvent(event);\n }\n }\n}\n\nexport type {ElementPart};\nclass ElementPart implements Disconnectable {\n readonly type = ELEMENT_PART;\n\n /** @internal */\n __directive?: Directive;\n\n // This is to ensure that every Part has a _$committedValue\n _$committedValue: undefined;\n\n /** @internal */\n _$parent!: Disconnectable;\n\n /** @internal */\n _$disconnectableChildren?: Set<Disconnectable> = undefined;\n\n options: RenderOptions | undefined;\n\n constructor(\n public element: Element,\n parent: Disconnectable,\n options: RenderOptions | undefined\n ) {\n this._$parent = parent;\n this.options = options;\n }\n\n // See comment in Disconnectable interface for why this is a getter\n get _$isConnected() {\n return this._$parent._$isConnected;\n }\n\n _$setValue(value: unknown): void {\n debugLogEvent &&\n debugLogEvent({\n kind: 'commit to element binding',\n element: this.element,\n value,\n options: this.options,\n });\n resolveDirective(this, value);\n }\n}\n\n/**\n * END USERS SHOULD NOT RELY ON THIS OBJECT.\n *\n * Private exports for use by other Lit packages, not intended for use by\n * external users.\n *\n * We currently do not make a mangled rollup build of the lit-ssr code. In order\n * to keep a number of (otherwise private) top-level exports mangled in the\n * client side code, we export a _$LH object containing those members (or\n * helper methods for accessing private fields of those members), and then\n * re-export them for use in lit-ssr. This keeps lit-ssr agnostic to whether the\n * client-side code is being used in `dev` mode or `prod` mode.\n *\n * This has a unique name, to disambiguate it from private exports in\n * lit-element, which re-exports all of lit-html.\n *\n * @private\n */\nexport const _$LH = {\n // Used in lit-ssr\n _boundAttributeSuffix: boundAttributeSuffix,\n _marker: marker,\n _markerMatch: markerMatch,\n _HTML_RESULT: HTML_RESULT,\n _getTemplateHtml: getTemplateHtml,\n // Used in tests and private-ssr-support\n _TemplateInstance: TemplateInstance,\n _isIterable: isIterable,\n _resolveDirective: resolveDirective,\n _ChildPart: ChildPart,\n _AttributePart: AttributePart,\n _BooleanAttributePart: BooleanAttributePart,\n _EventPart: EventPart,\n _PropertyPart: PropertyPart,\n _ElementPart: ElementPart,\n};\n\n// Apply polyfills if available\nconst polyfillSupport = DEV_MODE\n ? global.litHtmlPolyfillSupportDevMode\n : global.litHtmlPolyfillSupport;\npolyfillSupport?.(Template, ChildPart);\n\n// IMPORTANT: do not change the property name or the assignment expression.\n// This line will be used in regexes to search for lit-html usage.\n(global.litHtmlVersions ??= []).push('3.3.1');\nif (DEV_MODE && global.litHtmlVersions.length > 1) {\n queueMicrotask(() => {\n issueWarning!(\n 'multiple-versions',\n `Multiple versions of Lit loaded. ` +\n `Loading multiple versions is not recommended.`\n );\n });\n}\n\n/**\n * Renders a value, usually a lit-html TemplateResult, to the container.\n *\n * This example renders the text \"Hello, Zoe!\" inside a paragraph tag, appending\n * it to the container `document.body`.\n *\n * ```js\n * import {html, render} from 'lit';\n *\n * const name = \"Zoe\";\n * render(html`<p>Hello, ${name}!</p>`, document.body);\n * ```\n *\n * @param value Any [renderable\n * value](https://lit.dev/docs/templates/expressions/#child-expressions),\n * typically a {@linkcode TemplateResult} created by evaluating a template tag\n * like {@linkcode html} or {@linkcode svg}.\n * @param container A DOM container to render to. The first render will append\n * the rendered value to the container, and subsequent renders will\n * efficiently update the rendered value if the same result type was\n * previously rendered there.\n * @param options See {@linkcode RenderOptions} for options documentation.\n * @see\n * {@link https://lit.dev/docs/libraries/standalone-templates/#rendering-lit-html-templates| Rendering Lit HTML Templates}\n */\nexport const render = (\n value: unknown,\n container: HTMLElement | DocumentFragment,\n options?: RenderOptions\n): RootPart => {\n if (DEV_MODE && container == null) {\n // Give a clearer error message than\n // Uncaught TypeError: Cannot read properties of null (reading\n // '_$litPart$')\n // which reads like an internal Lit error.\n throw new TypeError(`The container to render into may not be ${container}`);\n }\n const renderId = DEV_MODE ? debugLogRenderId++ : 0;\n const partOwnerNode = options?.renderBefore ?? container;\n // This property needs to remain unminified.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let part: ChildPart = (partOwnerNode as any)['_$litPart$'];\n debugLogEvent &&\n debugLogEvent({\n kind: 'begin render',\n id: renderId,\n value,\n container,\n options,\n part,\n });\n if (part === undefined) {\n const endNode = options?.renderBefore ?? null;\n // This property needs to remain unminified.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (partOwnerNode as any)['_$litPart$'] = part = new ChildPart(\n container.insertBefore(createMarker(), endNode),\n endNode,\n undefined,\n options ?? {}\n );\n }\n part._$setValue(value);\n debugLogEvent &&\n debugLogEvent({\n kind: 'end render',\n id: renderId,\n value,\n container,\n options,\n part,\n });\n return part as RootPart;\n};\n\nif (ENABLE_EXTRA_SECURITY_HOOKS) {\n render.setSanitizer = setSanitizer;\n render.createSanitizer = createSanitizer;\n if (DEV_MODE) {\n render._testOnlyClearSanitizerFactoryDoNotCallOrElse =\n _testOnlyClearSanitizerFactoryDoNotCallOrElse;\n }\n}\n", "/**\n * @license\n * Copyright 2020 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {\n _$LH,\n Part,\n DirectiveParent,\n CompiledTemplateResult,\n MaybeCompiledTemplateResult,\n UncompiledTemplateResult,\n} from './lit-html.js';\nimport {\n DirectiveResult,\n DirectiveClass,\n PartInfo,\n AttributePartInfo,\n} from './directive.js';\ntype Primitive = null | undefined | boolean | number | string | symbol | bigint;\n\nconst {_ChildPart: ChildPart} = _$LH;\n\ntype ChildPart = InstanceType<typeof ChildPart>;\n\nconst ENABLE_SHADYDOM_NOPATCH = true;\n\nconst wrap =\n ENABLE_SHADYDOM_NOPATCH &&\n window.ShadyDOM?.inUse &&\n window.ShadyDOM?.noPatch === true\n ? window.ShadyDOM!.wrap\n : (node: Node) => node;\n\n/**\n * Tests if a value is a primitive value.\n *\n * See https://tc39.github.io/ecma262/#sec-typeof-operator\n */\nexport const isPrimitive = (value: unknown): value is Primitive =>\n value === null || (typeof value != 'object' && typeof value != 'function');\n\nexport const TemplateResultType = {\n HTML: 1,\n SVG: 2,\n MATHML: 3,\n} as const;\n\nexport type TemplateResultType =\n (typeof TemplateResultType)[keyof typeof TemplateResultType];\n\ntype IsTemplateResult = {\n (val: unknown): val is MaybeCompiledTemplateResult;\n <T extends TemplateResultType>(\n val: unknown,\n type: T\n ): val is UncompiledTemplateResult<T>;\n};\n\n/**\n * Tests if a value is a TemplateResult or a CompiledTemplateResult.\n */\nexport const isTemplateResult: IsTemplateResult = (\n value: unknown,\n type?: TemplateResultType\n): value is UncompiledTemplateResult =>\n type === undefined\n ? // This property needs to remain unminified.\n (value as UncompiledTemplateResult)?.['_$litType$'] !== undefined\n : (value as UncompiledTemplateResult)?.['_$litType$'] === type;\n\n/**\n * Tests if a value is a CompiledTemplateResult.\n */\nexport const isCompiledTemplateResult = (\n value: unknown\n): value is CompiledTemplateResult => {\n return (value as CompiledTemplateResult)?.['_$litType$']?.h != null;\n};\n\n/**\n * Tests if a value is a DirectiveResult.\n */\nexport const isDirectiveResult = (value: unknown): value is DirectiveResult =>\n // This property needs to remain unminified.\n (value as DirectiveResult)?.['_$litDirective$'] !== undefined;\n\n/**\n * Retrieves the Directive class for a DirectiveResult\n */\nexport const getDirectiveClass = (value: unknown): DirectiveClass | undefined =>\n // This property needs to remain unminified.\n (value as DirectiveResult)?.['_$litDirective$'];\n\n/**\n * Tests whether a part has only a single-expression with no strings to\n * interpolate between.\n *\n * Only AttributePart and PropertyPart can have multiple expressions.\n * Multi-expression parts have a `strings` property and single-expression\n * parts do not.\n */\nexport const isSingleExpression = (part: PartInfo) =>\n (part as AttributePartInfo).strings === undefined;\n\nconst createMarker = () => document.createComment('');\n\n/**\n * Inserts a ChildPart into the given container ChildPart's DOM, either at the\n * end of the container ChildPart, or before the optional `refPart`.\n *\n * This does not add the part to the containerPart's committed value. That must\n * be done by callers.\n *\n * @param containerPart Part within which to add the new ChildPart\n * @param refPart Part before which to add the new ChildPart; when omitted the\n * part added to the end of the `containerPart`\n * @param part Part to insert, or undefined to create a new part\n */\nexport const insertPart = (\n containerPart: ChildPart,\n refPart?: ChildPart,\n part?: ChildPart\n): ChildPart => {\n const container = wrap(containerPart._$startNode).parentNode!;\n\n const refNode =\n refPart === undefined ? containerPart._$endNode : refPart._$startNode;\n\n if (part === undefined) {\n const startNode = wrap(container).insertBefore(createMarker(), refNode);\n const endNode = wrap(container).insertBefore(createMarker(), refNode);\n part = new ChildPart(\n startNode,\n endNode,\n containerPart,\n containerPart.options\n );\n } else {\n const endNode = wrap(part._$endNode!).nextSibling;\n const oldParent = part._$parent;\n const parentChanged = oldParent !== containerPart;\n if (parentChanged) {\n part._$reparentDisconnectables?.(containerPart);\n // Note that although `_$reparentDisconnectables` updates the part's\n // `_$parent` reference after unlinking from its current parent, that\n // method only exists if Disconnectables are present, so we need to\n // unconditionally set it here\n part._$parent = containerPart;\n // Since the _$isConnected getter is somewhat costly, only\n // read it once we know the subtree has directives that need\n // to be notified\n let newConnectionState;\n if (\n part._$notifyConnectionChanged !== undefined &&\n (newConnectionState = containerPart._$isConnected) !==\n oldParent!._$isConnected\n ) {\n part._$notifyConnectionChanged(newConnectionState);\n }\n }\n if (endNode !== refNode || parentChanged) {\n let start: Node | null = part._$startNode;\n while (start !== endNode) {\n const n: Node | null = wrap(start!).nextSibling;\n wrap(container).insertBefore(start!, refNode);\n start = n;\n }\n }\n }\n\n return part;\n};\n\n/**\n * Sets the value of a Part.\n *\n * Note that this should only be used to set/update the value of user-created\n * parts (i.e. those created using `insertPart`); it should not be used\n * by directives to set the value of the directive's container part. Directives\n * should return a value from `update`/`render` to update their part state.\n *\n * For directives that require setting their part value asynchronously, they\n * should extend `AsyncDirective` and call `this.setValue()`.\n *\n * @param part Part to set\n * @param value Value to set\n * @param index For `AttributePart`s, the index to set\n * @param directiveParent Used internally; should not be set by user\n */\nexport const setChildPartValue = <T extends ChildPart>(\n part: T,\n value: unknown,\n directiveParent: DirectiveParent = part\n): T => {\n part._$setValue(value, directiveParent);\n return part;\n};\n\n// A sentinel value that can never appear as a part value except when set by\n// live(). Used to force a dirty-check to fail and cause a re-render.\nconst RESET_VALUE = {};\n\n/**\n * Sets the committed value of a ChildPart directly without triggering the\n * commit stage of the part.\n *\n * This is useful in cases where a directive needs to update the part such\n * that the next update detects a value change or not. When value is omitted,\n * the next update will be guaranteed to be detected as a change.\n *\n * @param part\n * @param value\n */\nexport const setCommittedValue = (part: Part, value: unknown = RESET_VALUE) =>\n (part._$committedValue = value);\n\n/**\n * Returns the committed value of a ChildPart.\n *\n * The committed value is used for change detection and efficient updates of\n * the part. It can differ from the value set by the template or directive in\n * cases where the template value is transformed before being committed.\n *\n * - `TemplateResult`s are committed as a `TemplateInstance`\n * - Iterables are committed as `Array<ChildPart>`\n * - All other types are committed as the template value or value returned or\n * set by a directive.\n *\n * @param part\n */\nexport const getCommittedValue = (part: ChildPart) => part._$committedValue;\n\n/**\n * Removes a ChildPart from the DOM, including any of its content and markers.\n *\n * Note: The only difference between this and clearPart() is that this also\n * removes the part's start node. This means that the ChildPart must own its\n * start node, ie it must be a marker node specifically for this part and not an\n * anchor from surrounding content.\n *\n * @param part The Part to remove\n */\nexport const removePart = (part: ChildPart) => {\n part._$clear();\n part._$startNode.remove();\n};\n\nexport const clearPart = (part: ChildPart) => {\n part._$clear();\n};\n", "/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/**\n * Overview:\n *\n * This module is designed to add support for an async `setValue` API and\n * `disconnected` callback to directives with the least impact on the core\n * runtime or payload when that feature is not used.\n *\n * The strategy is to introduce a `AsyncDirective` subclass of\n * `Directive` that climbs the \"parent\" tree in its constructor to note which\n * branches of lit-html's \"logical tree\" of data structures contain such\n * directives and thus need to be crawled when a subtree is being cleared (or\n * manually disconnected) in order to run the `disconnected` callback.\n *\n * The \"nodes\" of the logical tree include Parts, TemplateInstances (for when a\n * TemplateResult is committed to a value of a ChildPart), and Directives; these\n * all implement a common interface called `DisconnectableChild`. Each has a\n * `_$parent` reference which is set during construction in the core code, and a\n * `_$disconnectableChildren` field which is initially undefined.\n *\n * The sparse tree created by means of the `AsyncDirective` constructor\n * crawling up the `_$parent` tree and placing a `_$disconnectableChildren` Set\n * on each parent that includes each child that contains a\n * `AsyncDirective` directly or transitively via its children. In order to\n * notify connection state changes and disconnect (or reconnect) a tree, the\n * `_$notifyConnectionChanged` API is patched onto ChildParts as a directive\n * climbs the parent tree, which is called by the core when clearing a part if\n * it exists. When called, that method iterates over the sparse tree of\n * Set<DisconnectableChildren> built up by AsyncDirectives, and calls\n * `_$notifyDirectiveConnectionChanged` on any directives that are encountered\n * in that tree, running the required callbacks.\n *\n * A given \"logical tree\" of lit-html data-structures might look like this:\n *\n * ChildPart(N1) _$dC=[D2,T3]\n * ._directive\n * AsyncDirective(D2)\n * ._value // user value was TemplateResult\n * TemplateInstance(T3) _$dC=[A4,A6,N10,N12]\n * ._$parts[]\n * AttributePart(A4) _$dC=[D5]\n * ._directives[]\n * AsyncDirective(D5)\n * AttributePart(A6) _$dC=[D7,D8]\n * ._directives[]\n * AsyncDirective(D7)\n * Directive(D8) _$dC=[D9]\n * ._directive\n * AsyncDirective(D9)\n * ChildPart(N10) _$dC=[D11]\n * ._directive\n * AsyncDirective(D11)\n * ._value\n * string\n * ChildPart(N12) _$dC=[D13,N14,N16]\n * ._directive\n * AsyncDirective(D13)\n * ._value // user value was iterable\n * Array<ChildPart>\n * ChildPart(N14) _$dC=[D15]\n * ._value\n * string\n * ChildPart(N16) _$dC=[D17,T18]\n * ._directive\n * AsyncDirective(D17)\n * ._value // user value was TemplateResult\n * TemplateInstance(T18) _$dC=[A19,A21,N25]\n * ._$parts[]\n * AttributePart(A19) _$dC=[D20]\n * ._directives[]\n * AsyncDirective(D20)\n * AttributePart(A21) _$dC=[22,23]\n * ._directives[]\n * AsyncDirective(D22)\n * Directive(D23) _$dC=[D24]\n * ._directive\n * AsyncDirective(D24)\n * ChildPart(N25) _$dC=[D26]\n * ._directive\n * AsyncDirective(D26)\n * ._value\n * string\n *\n * Example 1: The directive in ChildPart(N12) updates and returns `nothing`. The\n * ChildPart will _clear() itself, and so we need to disconnect the \"value\" of\n * the ChildPart (but not its directive). In this case, when `_clear()` calls\n * `_$notifyConnectionChanged()`, we don't iterate all of the\n * _$disconnectableChildren, rather we do a value-specific disconnection: i.e.\n * since the _value was an Array<ChildPart> (because an iterable had been\n * committed), we iterate the array of ChildParts (N14, N16) and run\n * `setConnected` on them (which does recurse down the full tree of\n * `_$disconnectableChildren` below it, and also removes N14 and N16 from N12's\n * `_$disconnectableChildren`). Once the values have been disconnected, we then\n * check whether the ChildPart(N12)'s list of `_$disconnectableChildren` is empty\n * (and would remove it from its parent TemplateInstance(T3) if so), but since\n * it would still contain its directive D13, it stays in the disconnectable\n * tree.\n *\n * Example 2: In the course of Example 1, `setConnected` will reach\n * ChildPart(N16); in this case the entire part is being disconnected, so we\n * simply iterate all of N16's `_$disconnectableChildren` (D17,T18) and\n * recursively run `setConnected` on them. Note that we only remove children\n * from `_$disconnectableChildren` for the top-level values being disconnected\n * on a clear; doing this bookkeeping lower in the tree is wasteful since it's\n * all being thrown away.\n *\n * Example 3: If the LitElement containing the entire tree above becomes\n * disconnected, it will run `childPart.setConnected()` (which calls\n * `childPart._$notifyConnectionChanged()` if it exists); in this case, we\n * recursively run `setConnected()` over the entire tree, without removing any\n * children from `_$disconnectableChildren`, since this tree is required to\n * re-connect the tree, which does the same operation, simply passing\n * `isConnected: true` down the tree, signaling which callback to run.\n */\n\nimport {AttributePart, ChildPart, Disconnectable, Part} from './lit-html.js';\nimport {isSingleExpression} from './directive-helpers.js';\nimport {Directive, PartInfo, PartType} from './directive.js';\nexport * from './directive.js';\n\nconst DEV_MODE = true;\n\n/**\n * Recursively walks down the tree of Parts/TemplateInstances/Directives to set\n * the connected state of directives and run `disconnected`/ `reconnected`\n * callbacks.\n *\n * @return True if there were children to disconnect; false otherwise\n */\nconst notifyChildrenConnectedChanged = (\n parent: Disconnectable,\n isConnected: boolean\n): boolean => {\n const children = parent._$disconnectableChildren;\n if (children === undefined) {\n return false;\n }\n for (const obj of children) {\n // The existence of `_$notifyDirectiveConnectionChanged` is used as a \"brand\" to\n // disambiguate AsyncDirectives from other DisconnectableChildren\n // (as opposed to using an instanceof check to know when to call it); the\n // redundancy of \"Directive\" in the API name is to avoid conflicting with\n // `_$notifyConnectionChanged`, which exists `ChildParts` which are also in\n // this list\n // Disconnect Directive (and any nested directives contained within)\n // This property needs to remain unminified.\n (obj as AsyncDirective)['_$notifyDirectiveConnectionChanged']?.(\n isConnected,\n false\n );\n // Disconnect Part/TemplateInstance\n notifyChildrenConnectedChanged(obj, isConnected);\n }\n return true;\n};\n\n/**\n * Removes the given child from its parent list of disconnectable children, and\n * if the parent list becomes empty as a result, removes the parent from its\n * parent, and so forth up the tree when that causes subsequent parent lists to\n * become empty.\n */\nconst removeDisconnectableFromParent = (obj: Disconnectable) => {\n let parent, children;\n do {\n if ((parent = obj._$parent) === undefined) {\n break;\n }\n children = parent._$disconnectableChildren!;\n children.delete(obj);\n obj = parent;\n } while (children?.size === 0);\n};\n\nconst addDisconnectableToParent = (obj: Disconnectable) => {\n // Climb the parent tree, creating a sparse tree of children needing\n // disconnection\n for (let parent; (parent = obj._$parent); obj = parent) {\n let children = parent._$disconnectableChildren;\n if (children === undefined) {\n parent._$disconnectableChildren = children = new Set();\n } else if (children.has(obj)) {\n // Once we've reached a parent that already contains this child, we\n // can short-circuit\n break;\n }\n children.add(obj);\n installDisconnectAPI(parent);\n }\n};\n\n/**\n * Changes the parent reference of the ChildPart, and updates the sparse tree of\n * Disconnectable children accordingly.\n *\n * Note, this method will be patched onto ChildPart instances and called from\n * the core code when parts are moved between different parents.\n */\nfunction reparentDisconnectables(this: ChildPart, newParent: Disconnectable) {\n if (this._$disconnectableChildren !== undefined) {\n removeDisconnectableFromParent(this);\n this._$parent = newParent;\n addDisconnectableToParent(this);\n } else {\n this._$parent = newParent;\n }\n}\n\n/**\n * Sets the connected state on any directives contained within the committed\n * value of this part (i.e. within a TemplateInstance or iterable of\n * ChildParts) and runs their `disconnected`/`reconnected`s, as well as within\n * any directives stored on the ChildPart (when `valueOnly` is false).\n *\n * `isClearingValue` should be passed as `true` on a top-level part that is\n * clearing itself, and not as a result of recursively disconnecting directives\n * as part of a `clear` operation higher up the tree. This both ensures that any\n * directive on this ChildPart that produced a value that caused the clear\n * operation is not disconnected, and also serves as a performance optimization\n * to avoid needless bookkeeping when a subtree is going away; when clearing a\n * subtree, only the top-most part need to remove itself from the parent.\n *\n * `fromPartIndex` is passed only in the case of a partial `_clear` running as a\n * result of truncating an iterable.\n *\n * Note, this method will be patched onto ChildPart instances and called from the\n * core code when parts are cleared or the connection state is changed by the\n * user.\n */\nfunction notifyChildPartConnectedChanged(\n this: ChildPart,\n isConnected: boolean,\n isClearingValue = false,\n fromPartIndex = 0\n) {\n const value = this._$committedValue;\n const children = this._$disconnectableChildren;\n if (children === undefined || children.size === 0) {\n return;\n }\n if (isClearingValue) {\n if (Array.isArray(value)) {\n // Iterable case: Any ChildParts created by the iterable should be\n // disconnected and removed from this ChildPart's disconnectable\n // children (starting at `fromPartIndex` in the case of truncation)\n for (let i = fromPartIndex; i < value.length; i++) {\n notifyChildrenConnectedChanged(value[i], false);\n removeDisconnectableFromParent(value[i]);\n }\n } else if (value != null) {\n // TemplateInstance case: If the value has disconnectable children (will\n // only be in the case that it is a TemplateInstance), we disconnect it\n // and remove it from this ChildPart's disconnectable children\n notifyChildrenConnectedChanged(value as Disconnectable, false);\n removeDisconnectableFromParent(value as Disconnectable);\n }\n } else {\n notifyChildrenConnectedChanged(this, isConnected);\n }\n}\n\n/**\n * Patches disconnection API onto ChildParts.\n */\nconst installDisconnectAPI = (obj: Disconnectable) => {\n if ((obj as ChildPart).type == PartType.CHILD) {\n (obj as ChildPart)._$notifyConnectionChanged ??=\n notifyChildPartConnectedChanged;\n (obj as ChildPart)._$reparentDisconnectables ??= reparentDisconnectables;\n }\n};\n\n/**\n * An abstract `Directive` base class whose `disconnected` method will be\n * called when the part containing the directive is cleared as a result of\n * re-rendering, or when the user calls `part.setConnected(false)` on\n * a part that was previously rendered containing the directive (as happens\n * when e.g. a LitElement disconnects from the DOM).\n *\n * If `part.setConnected(true)` is subsequently called on a\n * containing part, the directive's `reconnected` method will be called prior\n * to its next `update`/`render` callbacks. When implementing `disconnected`,\n * `reconnected` should also be implemented to be compatible with reconnection.\n *\n * Note that updates may occur while the directive is disconnected. As such,\n * directives should generally check the `this.isConnected` flag during\n * render/update to determine whether it is safe to subscribe to resources\n * that may prevent garbage collection.\n */\nexport abstract class AsyncDirective extends Directive {\n // As opposed to other Disconnectables, AsyncDirectives always get notified\n // when the RootPart connection changes, so the public `isConnected`\n // is a locally stored variable initialized via its part's getter and synced\n // via `_$notifyDirectiveConnectionChanged`. This is cheaper than using\n // the _$isConnected getter, which has to look back up the tree each time.\n /**\n * The connection state for this Directive.\n */\n isConnected!: boolean;\n\n // @internal\n override _$disconnectableChildren?: Set<Disconnectable> = undefined;\n /**\n * Initialize the part with internal fields\n * @param part\n * @param parent\n * @param attributeIndex\n */\n override _$initialize(\n part: Part,\n parent: Disconnectable,\n attributeIndex: number | undefined\n ) {\n super._$initialize(part, parent, attributeIndex);\n addDisconnectableToParent(this);\n this.isConnected = part._$isConnected;\n }\n // This property needs to remain unminified.\n /**\n * Called from the core code when a directive is going away from a part (in\n * which case `shouldRemoveFromParent` should be true), and from the\n * `setChildrenConnected` helper function when recursively changing the\n * connection state of a tree (in which case `shouldRemoveFromParent` should\n * be false).\n *\n * @param isConnected\n * @param isClearingDirective - True when the directive itself is being\n * removed; false when the tree is being disconnected\n * @internal\n */\n override ['_$notifyDirectiveConnectionChanged'](\n isConnected: boolean,\n isClearingDirective = true\n ) {\n if (isConnected !== this.isConnected) {\n this.isConnected = isConnected;\n if (isConnected) {\n this.reconnected?.();\n } else {\n this.disconnected?.();\n }\n }\n if (isClearingDirective) {\n notifyChildrenConnectedChanged(this, isConnected);\n removeDisconnectableFromParent(this);\n }\n }\n\n /**\n * Sets the value of the directive's Part outside the normal `update`/`render`\n * lifecycle of a directive.\n *\n * This method should not be called synchronously from a directive's `update`\n * or `render`.\n *\n * @param directive The directive to update\n * @param value The value to set\n */\n setValue(value: unknown) {\n if (isSingleExpression(this.__part as unknown as PartInfo)) {\n this.__part._$setValue(value, this);\n } else {\n // this.__attributeIndex will be defined in this case, but\n // assert it in dev mode\n if (DEV_MODE && this.__attributeIndex === undefined) {\n throw new Error(`Expected this.__attributeIndex to be a number`);\n }\n const newValues = [...(this.__part._$committedValue as Array<unknown>)];\n newValues[this.__attributeIndex!] = value;\n (this.__part as AttributePart)._$setValue(newValues, this, 0);\n }\n }\n\n /**\n * User callbacks for implementing logic to release any resources/subscriptions\n * that may have been retained by this directive. Since directives may also be\n * re-connected, `reconnected` should also be implemented to restore the\n * working state of the directive prior to the next render.\n */\n protected disconnected() {}\n protected reconnected() {}\n}\n", "/**\n * @license\n * Copyright 2023 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {DirectiveResult, Part, directive} from 'lit/directive.js';\nimport {AsyncDirective} from 'lit/async-directive.js';\nimport {Signal} from 'signal-polyfill';\nimport {SignalWatcher} from './signal-watcher.js';\n\nexport class WatchDirective<T> extends AsyncDirective {\n private __host?: SignalWatcher;\n\n private __signal?: Signal.State<T> | Signal.Computed<T>;\n\n private __watcher?: Signal.subtle.Watcher;\n\n // We have to wrap the signal in a computed to work around a bug in the\n // signal-polyfill: https://github.com/proposal-signals/signal-polyfill/issues/27\n private __computed?: Signal.Computed<T | undefined>;\n\n private __watch() {\n if (this.__watcher !== undefined) {\n return;\n }\n this.__computed = new Signal.Computed(() => {\n return this.__signal?.get();\n });\n const watcher = (this.__watcher = new Signal.subtle.Watcher(() => {\n // TODO: If we're not running inside a SignalWatcher, we can commit to\n // the DOM independently.\n this.__host?._updateWatchDirective(this as WatchDirective<unknown>);\n watcher.watch();\n }));\n watcher.watch(this.__computed);\n }\n\n private __unwatch() {\n if (this.__watcher !== undefined) {\n this.__watcher.unwatch(this.__computed!);\n this.__computed = undefined;\n this.__watcher = undefined;\n this.__host?._clearWatchDirective(this as WatchDirective<unknown>);\n }\n }\n\n commit() {\n this.setValue(Signal.subtle.untrack(() => this.__computed?.get()));\n }\n\n render(signal: Signal.State<T> | Signal.Computed<T>): T {\n // This would only be called if render is called directly, like in SSR.\n return Signal.subtle.untrack(() => signal.get());\n }\n\n override update(\n part: Part,\n [signal]: [signal: Signal.State<T> | Signal.Computed<T>]\n ) {\n this.__host ??= part.options?.host as SignalWatcher;\n if (signal !== this.__signal && this.__signal !== undefined) {\n // Unwatch the old signal\n this.__unwatch();\n }\n this.__signal = signal;\n this.__watch();\n\n // We use untrack() so that the signal access is not tracked by the watcher\n // created by SignalWatcher. This means that an can use both SignalWatcher\n // and watch() and a signal update won't trigger a full element update if\n // it's only passed to watch() and not otherwise accessed by the element.\n return Signal.subtle.untrack(() => this.__computed!.get());\n }\n\n protected override disconnected(): void {\n this.__unwatch();\n }\n\n protected override reconnected(): void {\n this.__watch();\n }\n}\n\nexport type WatchDirectiveFunction = <T>(\n signal: Signal.State<T> | Signal.Computed<T>\n) => DirectiveResult<typeof WatchDirective<T>>;\n\n/**\n * Renders a signal and subscribes to it, updating the part when the signal\n * changes.\n *\n * watch() can only be used in a reactive element that applies the\n * SignalWatcher mixin.\n */\nexport const watch = directive(WatchDirective) as WatchDirectiveFunction;\n", "/**\n * @license\n * Copyright 2023 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\nimport {\n html as coreHtml,\n svg as coreSvg,\n type TemplateResult,\n} from 'lit/html.js';\n\nimport {watch} from './watch.js';\nimport {Signal} from 'signal-polyfill';\n\n/**\n * Wraps a lit-html template tag function (`html` or `svg`) to add support for\n * automatically wrapping Signal instances in the `watch()` directive.\n */\nexport const withWatch =\n (coreTag: typeof coreHtml | typeof coreSvg) =>\n (strings: TemplateStringsArray, ...values: unknown[]): TemplateResult => {\n // TODO (justinfagnani): use an alternative to instanceof when\n // one is available. See https://github.com/preactjs/signals/issues/402\n return coreTag(\n strings,\n ...values.map((v) =>\n v instanceof Signal.State || v instanceof Signal.Computed ? watch(v) : v\n )\n );\n };\n\n/**\n * Interprets a template literal as an HTML template that can efficiently\n * render to and update a container.\n *\n * Includes signal watching support from `withWatch()`.\n */\nexport const html = withWatch(coreHtml);\n\n/**\n * Interprets a template literal as an SVG template that can efficiently\n * render to and update a container.\n *\n * Includes signal watching support from `withWatch()`.\n */\nexport const svg = withWatch(coreSvg);\n", "/**\n * @license\n * Copyright 2023 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {Signal} from 'signal-polyfill';\n\nexport * from 'signal-polyfill';\nexport * from './lib/signal-watcher.js';\nexport * from './lib/watch.js';\nexport * from './lib/html-tag.js';\n\nexport const State = Signal.State;\nexport const Computed = Signal.Computed;\n\nexport const signal = <T>(value: T, options?: Signal.Options<T>) =>\n new Signal.State(value, options);\nexport const computed = <T>(callback: () => T, options?: Signal.Options<T>) =>\n new Signal.Computed<T>(callback, options);\n", "import { signal } from \"@lit-labs/signals\";\nfunction getInitialTheme() {\n if (typeof window === \"undefined\") {\n return \"light\";\n }\n const storedTheme = window.localStorage?.getItem(\"ds-one:theme\");\n if (storedTheme === \"light\" || storedTheme === \"dark\") {\n return storedTheme;\n }\n // Check system preference\n const prefersDark = window.matchMedia(\"(prefers-color-scheme: dark)\").matches;\n return prefersDark ? \"dark\" : \"light\";\n}\nexport const currentTheme = signal(getInitialTheme());\nexport function setTheme(theme) {\n if (theme === currentTheme.get()) {\n return;\n }\n currentTheme.set(theme);\n if (typeof window !== \"undefined\") {\n try {\n window.localStorage?.setItem(\"ds-one:theme\", theme);\n }\n catch (error) {\n console.warn(\"ds-one: unable to persist theme preference\", error);\n }\n const root = window.document?.documentElement;\n if (root) {\n root.classList.remove(\"light-theme\", \"dark-theme\");\n root.classList.add(`${theme}-theme`);\n }\n window.dispatchEvent(new CustomEvent(\"theme-changed\", { detail: { theme } }));\n }\n}\n// Initialize theme on load\nif (typeof window !== \"undefined\") {\n const theme = currentTheme.get();\n const root = window.document?.documentElement;\n if (root) {\n root.classList.remove(\"light-theme\", \"dark-theme\");\n root.classList.add(`${theme}-theme`);\n }\n}\n", "/**\n * @license\n * Copyright 2019 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nconst NODE_MODE = false;\n\n// Allows minifiers to rename references to globalThis\nconst global = globalThis;\n\n/**\n * Whether the current browser supports `adoptedStyleSheets`.\n */\nexport const supportsAdoptingStyleSheets: boolean =\n global.ShadowRoot &&\n (global.ShadyCSS === undefined || global.ShadyCSS.nativeShadow) &&\n 'adoptedStyleSheets' in Document.prototype &&\n 'replace' in CSSStyleSheet.prototype;\n\n/**\n * A CSSResult or native CSSStyleSheet.\n *\n * In browsers that support constructible CSS style sheets, CSSStyleSheet\n * object can be used for styling along side CSSResult from the `css`\n * template tag.\n */\nexport type CSSResultOrNative = CSSResult | CSSStyleSheet;\n\nexport type CSSResultArray = Array<CSSResultOrNative | CSSResultArray>;\n\n/**\n * A single CSSResult, CSSStyleSheet, or an array or nested arrays of those.\n */\nexport type CSSResultGroup = CSSResultOrNative | CSSResultArray;\n\nconst constructionToken = Symbol();\n\nconst cssTagCache = new WeakMap<TemplateStringsArray, CSSStyleSheet>();\n\n/**\n * A container for a string of CSS text, that may be used to create a CSSStyleSheet.\n *\n * CSSResult is the return value of `css`-tagged template literals and\n * `unsafeCSS()`. In order to ensure that CSSResults are only created via the\n * `css` tag and `unsafeCSS()`, CSSResult cannot be constructed directly.\n */\nexport class CSSResult {\n // This property needs to remain unminified.\n ['_$cssResult$'] = true;\n readonly cssText: string;\n private _styleSheet?: CSSStyleSheet;\n private _strings: TemplateStringsArray | undefined;\n\n private constructor(\n cssText: string,\n strings: TemplateStringsArray | undefined,\n safeToken: symbol\n ) {\n if (safeToken !== constructionToken) {\n throw new Error(\n 'CSSResult is not constructable. Use `unsafeCSS` or `css` instead.'\n );\n }\n this.cssText = cssText;\n this._strings = strings;\n }\n\n // This is a getter so that it's lazy. In practice, this means stylesheets\n // are not created until the first element instance is made.\n get styleSheet(): CSSStyleSheet | undefined {\n // If `supportsAdoptingStyleSheets` is true then we assume CSSStyleSheet is\n // constructable.\n let styleSheet = this._styleSheet;\n const strings = this._strings;\n if (supportsAdoptingStyleSheets && styleSheet === undefined) {\n const cacheable = strings !== undefined && strings.length === 1;\n if (cacheable) {\n styleSheet = cssTagCache.get(strings);\n }\n if (styleSheet === undefined) {\n (this._styleSheet = styleSheet = new CSSStyleSheet()).replaceSync(\n this.cssText\n );\n if (cacheable) {\n cssTagCache.set(strings, styleSheet);\n }\n }\n }\n return styleSheet;\n }\n\n toString(): string {\n return this.cssText;\n }\n}\n\ntype ConstructableCSSResult = CSSResult & {\n new (\n cssText: string,\n strings: TemplateStringsArray | undefined,\n safeToken: symbol\n ): CSSResult;\n};\n\nconst textFromCSSResult = (value: CSSResultGroup | number) => {\n // This property needs to remain unminified.\n if ((value as CSSResult)['_$cssResult$'] === true) {\n return (value as CSSResult).cssText;\n } else if (typeof value === 'number') {\n return value;\n } else {\n throw new Error(\n `Value passed to 'css' function must be a 'css' function result: ` +\n `${value}. Use 'unsafeCSS' to pass non-literal values, but take care ` +\n `to ensure page security.`\n );\n }\n};\n\n/**\n * Wrap a value for interpolation in a {@linkcode css} tagged template literal.\n *\n * This is unsafe because untrusted CSS text can be used to phone home\n * or exfiltrate data to an attacker controlled site. Take care to only use\n * this with trusted input.\n */\nexport const unsafeCSS = (value: unknown) =>\n new (CSSResult as ConstructableCSSResult)(\n typeof value === 'string' ? value : String(value),\n undefined,\n constructionToken\n );\n\n/**\n * A template literal tag which can be used with LitElement's\n * {@linkcode LitElement.styles} property to set element styles.\n *\n * For security reasons, only literal string values and number may be used in\n * embedded expressions. To incorporate non-literal values {@linkcode unsafeCSS}\n * may be used inside an expression.\n */\nexport const css = (\n strings: TemplateStringsArray,\n ...values: (CSSResultGroup | number)[]\n): CSSResult => {\n const cssText =\n strings.length === 1\n ? strings[0]\n : values.reduce(\n (acc, v, idx) => acc + textFromCSSResult(v) + strings[idx + 1],\n strings[0]\n );\n return new (CSSResult as ConstructableCSSResult)(\n cssText,\n strings,\n constructionToken\n );\n};\n\n/**\n * Applies the given styles to a `shadowRoot`. When Shadow DOM is\n * available but `adoptedStyleSheets` is not, styles are appended to the\n * `shadowRoot` to [mimic the native feature](https://developer.mozilla.org/en-US/docs/Web/API/ShadowRoot/adoptedStyleSheets).\n * Note, when shimming is used, any styles that are subsequently placed into\n * the shadowRoot should be placed *before* any shimmed adopted styles. This\n * will match spec behavior that gives adopted sheets precedence over styles in\n * shadowRoot.\n */\nexport const adoptStyles = (\n renderRoot: ShadowRoot,\n styles: Array<CSSResultOrNative>\n) => {\n if (supportsAdoptingStyleSheets) {\n (renderRoot as ShadowRoot).adoptedStyleSheets = styles.map((s) =>\n s instanceof CSSStyleSheet ? s : s.styleSheet!\n );\n } else {\n for (const s of styles) {\n const style = document.createElement('style');\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const nonce = (global as any)['litNonce'];\n if (nonce !== undefined) {\n style.setAttribute('nonce', nonce);\n }\n style.textContent = (s as CSSResult).cssText;\n renderRoot.appendChild(style);\n }\n }\n};\n\nconst cssResultFromStyleSheet = (sheet: CSSStyleSheet) => {\n let cssText = '';\n for (const rule of sheet.cssRules) {\n cssText += rule.cssText;\n }\n return unsafeCSS(cssText);\n};\n\nexport const getCompatibleStyle =\n supportsAdoptingStyleSheets ||\n (NODE_MODE && global.CSSStyleSheet === undefined)\n ? (s: CSSResultOrNative) => s\n : (s: CSSResultOrNative) =>\n s instanceof CSSStyleSheet ? cssResultFromStyleSheet(s) : s;\n", "/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/**\n * Use this module if you want to create your own base class extending\n * {@link ReactiveElement}.\n * @packageDocumentation\n */\n\nimport {\n getCompatibleStyle,\n adoptStyles,\n CSSResultGroup,\n CSSResultOrNative,\n} from './css-tag.js';\nimport type {\n ReactiveController,\n ReactiveControllerHost,\n} from './reactive-controller.js';\n\n// In the Node build, this import will be injected by Rollup:\n// import {HTMLElement, customElements} from '@lit-labs/ssr-dom-shim';\n\nexport * from './css-tag.js';\nexport type {\n ReactiveController,\n ReactiveControllerHost,\n} from './reactive-controller.js';\n\n/**\n * Removes the `readonly` modifier from properties in the union K.\n *\n * This is a safer way to cast a value to a type with a mutable version of a\n * readonly field, than casting to an interface with the field re-declared\n * because it preserves the type of all the fields and warns on typos.\n */\ntype Mutable<T, K extends keyof T> = Omit<T, K> & {\n -readonly [P in keyof Pick<T, K>]: P extends K ? T[P] : never;\n};\n\n// TODO (justinfagnani): Add `hasOwn` here when we ship ES2022\nconst {\n is,\n defineProperty,\n getOwnPropertyDescriptor,\n getOwnPropertyNames,\n getOwnPropertySymbols,\n getPrototypeOf,\n} = Object;\n\nconst NODE_MODE = false;\n\n// Lets a minifier replace globalThis references with a minified name\nconst global = globalThis;\n\nif (NODE_MODE) {\n global.customElements ??= customElements;\n}\n\nconst DEV_MODE = true;\n\nlet issueWarning: (code: string, warning: string) => void;\n\nconst trustedTypes = (global as unknown as {trustedTypes?: {emptyScript: ''}})\n .trustedTypes;\n\n// Temporary workaround for https://crbug.com/993268\n// Currently, any attribute starting with \"on\" is considered to be a\n// TrustedScript source. Such boolean attributes must be set to the equivalent\n// trusted emptyScript value.\nconst emptyStringForBooleanAttribute = trustedTypes\n ? (trustedTypes.emptyScript as unknown as '')\n : '';\n\nconst polyfillSupport = DEV_MODE\n ? global.reactiveElementPolyfillSupportDevMode\n : global.reactiveElementPolyfillSupport;\n\nif (DEV_MODE) {\n // Ensure warnings are issued only 1x, even if multiple versions of Lit\n // are loaded.\n global.litIssuedWarnings ??= new Set();\n\n /**\n * Issue a warning if we haven't already, based either on `code` or `warning`.\n * Warnings are disabled automatically only by `warning`; disabling via `code`\n * can be done by users.\n */\n issueWarning = (code: string, warning: string) => {\n warning += ` See https://lit.dev/msg/${code} for more information.`;\n if (\n !global.litIssuedWarnings!.has(warning) &&\n !global.litIssuedWarnings!.has(code)\n ) {\n console.warn(warning);\n global.litIssuedWarnings!.add(warning);\n }\n };\n\n queueMicrotask(() => {\n issueWarning(\n 'dev-mode',\n `Lit is in dev mode. Not recommended for production!`\n );\n\n // Issue polyfill support warning.\n if (global.ShadyDOM?.inUse && polyfillSupport === undefined) {\n issueWarning(\n 'polyfill-support-missing',\n `Shadow DOM is being polyfilled via \\`ShadyDOM\\` but ` +\n `the \\`polyfill-support\\` module has not been loaded.`\n );\n }\n });\n}\n\n/**\n * Contains types that are part of the unstable debug API.\n *\n * Everything in this API is not stable and may change or be removed in the future,\n * even on patch releases.\n */\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport namespace ReactiveUnstable {\n /**\n * When Lit is running in dev mode and `window.emitLitDebugLogEvents` is true,\n * we will emit 'lit-debug' events to window, with live details about the update and render\n * lifecycle. These can be useful for writing debug tooling and visualizations.\n *\n * Please be aware that running with window.emitLitDebugLogEvents has performance overhead,\n * making certain operations that are normally very cheap (like a no-op render) much slower,\n * because we must copy data and dispatch events.\n */\n // eslint-disable-next-line @typescript-eslint/no-namespace\n export namespace DebugLog {\n export type Entry = Update;\n export interface Update {\n kind: 'update';\n }\n }\n}\n\ninterface DebugLoggingWindow {\n // Even in dev mode, we generally don't want to emit these events, as that's\n // another level of cost, so only emit them when DEV_MODE is true _and_ when\n // window.emitLitDebugEvents is true.\n emitLitDebugLogEvents?: boolean;\n}\n\n/**\n * Useful for visualizing and logging insights into what the Lit template system is doing.\n *\n * Compiled out of prod mode builds.\n */\nconst debugLogEvent = DEV_MODE\n ? (event: ReactiveUnstable.DebugLog.Entry) => {\n const shouldEmit = (global as unknown as DebugLoggingWindow)\n .emitLitDebugLogEvents;\n if (!shouldEmit) {\n return;\n }\n global.dispatchEvent(\n new CustomEvent<ReactiveUnstable.DebugLog.Entry>('lit-debug', {\n detail: event,\n })\n );\n }\n : undefined;\n\n/*\n * When using Closure Compiler, JSCompiler_renameProperty(property, object) is\n * replaced at compile time by the munged name for object[property]. We cannot\n * alias this function, so we have to use a small shim that has the same\n * behavior when not compiling.\n */\n/*@__INLINE__*/\nconst JSCompiler_renameProperty = <P extends PropertyKey>(\n prop: P,\n _obj: unknown\n): P => prop;\n\n/**\n * Converts property values to and from attribute values.\n */\nexport interface ComplexAttributeConverter<Type = unknown, TypeHint = unknown> {\n /**\n * Called to convert an attribute value to a property\n * value.\n */\n fromAttribute?(value: string | null, type?: TypeHint): Type;\n\n /**\n * Called to convert a property value to an attribute\n * value.\n *\n * It returns unknown instead of string, to be compatible with\n * https://github.com/WICG/trusted-types (and similar efforts).\n */\n toAttribute?(value: Type, type?: TypeHint): unknown;\n}\n\ntype AttributeConverter<Type = unknown, TypeHint = unknown> =\n | ComplexAttributeConverter<Type>\n | ((value: string | null, type?: TypeHint) => Type);\n\n/**\n * Defines options for a property accessor.\n */\nexport interface PropertyDeclaration<Type = unknown, TypeHint = unknown> {\n /**\n * When set to `true`, indicates the property is internal private state. The\n * property should not be set by users. When using TypeScript, this property\n * should be marked as `private` or `protected`, and it is also a common\n * practice to use a leading `_` in the name. The property is not added to\n * `observedAttributes`.\n */\n readonly state?: boolean;\n\n /**\n * Indicates how and whether the property becomes an observed attribute.\n * If the value is `false`, the property is not added to `observedAttributes`.\n * If true or absent, the lowercased property name is observed (e.g. `fooBar`\n * becomes `foobar`). If a string, the string value is observed (e.g\n * `attribute: 'foo-bar'`).\n */\n readonly attribute?: boolean | string;\n\n /**\n * Indicates the type of the property. This is used only as a hint for the\n * `converter` to determine how to convert the attribute\n * to/from a property.\n */\n readonly type?: TypeHint;\n\n /**\n * Indicates how to convert the attribute to/from a property. If this value\n * is a function, it is used to convert the attribute value a the property\n * value. If it's an object, it can have keys for `fromAttribute` and\n * `toAttribute`. If no `toAttribute` function is provided and\n * `reflect` is set to `true`, the property value is set directly to the\n * attribute. A default `converter` is used if none is provided; it supports\n * `Boolean`, `String`, `Number`, `Object`, and `Array`. Note,\n * when a property changes and the converter is used to update the attribute,\n * the property is never updated again as a result of the attribute changing,\n * and vice versa.\n */\n readonly converter?: AttributeConverter<Type, TypeHint>;\n\n /**\n * Indicates if the property should reflect to an attribute.\n * If `true`, when the property is set, the attribute is set using the\n * attribute name determined according to the rules for the `attribute`\n * property option and the value of the property converted using the rules\n * from the `converter` property option.\n */\n readonly reflect?: boolean;\n\n /**\n * A function that indicates if a property should be considered changed when\n * it is set. The function should take the `newValue` and `oldValue` and\n * return `true` if an update should be requested.\n */\n hasChanged?(value: Type, oldValue: Type): boolean;\n\n /**\n * Indicates whether an accessor will be created for this property. By\n * default, an accessor will be generated for this property that requests an\n * update when set. If this flag is `true`, no accessor will be created, and\n * it will be the user's responsibility to call\n * `this.requestUpdate(propertyName, oldValue)` to request an update when\n * the property changes.\n */\n readonly noAccessor?: boolean;\n\n /**\n * Whether this property is wrapping accessors. This is set by `@property`\n * to control the initial value change and reflection logic.\n *\n * @internal\n */\n wrapped?: boolean;\n\n /**\n * When `true`, uses the initial value of the property as the default value,\n * which changes how attributes are handled:\n * - The initial value does *not* reflect, even if the `reflect` option is `true`.\n * Subsequent changes to the property will reflect, even if they are equal to the\n * default value.\n * - When the attribute is removed, the property is set to the default value\n * - The initial value will not trigger an old value in the `changedProperties` map\n * argument to update lifecycle methods.\n *\n * When set, properties must be initialized, either with a field initializer, or an\n * assignment in the constructor. Not initializing the property may lead to\n * improper handling of subsequent property assignments.\n *\n * While this behavior is opt-in, most properties that reflect to attributes should\n * use `useDefault: true` so that their initial values do not reflect.\n */\n useDefault?: boolean;\n}\n\n/**\n * Map of properties to PropertyDeclaration options. For each property an\n * accessor is made, and the property is processed according to the\n * PropertyDeclaration options.\n */\nexport interface PropertyDeclarations {\n readonly [key: string]: PropertyDeclaration;\n}\n\ntype PropertyDeclarationMap = Map<PropertyKey, PropertyDeclaration>;\n\ntype AttributeMap = Map<string, PropertyKey>;\n\n/**\n * A Map of property keys to values.\n *\n * Takes an optional type parameter T, which when specified as a non-any,\n * non-unknown type, will make the Map more strongly-typed, associating the map\n * keys with their corresponding value type on T.\n *\n * Use `PropertyValues<this>` when overriding ReactiveElement.update() and\n * other lifecycle methods in order to get stronger type-checking on keys\n * and values.\n */\n// This type is conditional so that if the parameter T is not specified, or\n// is `any`, the type will include `Map<PropertyKey, unknown>`. Since T is not\n// given in the uses of PropertyValues in this file, all uses here fallback to\n// meaning `Map<PropertyKey, unknown>`, but if a developer uses\n// `PropertyValues<this>` (or any other value for T) they will get a\n// strongly-typed Map type.\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type PropertyValues<T = any> = T extends object\n ? PropertyValueMap<T>\n : Map<PropertyKey, unknown>;\n\n/**\n * Do not use, instead prefer {@linkcode PropertyValues}.\n */\n// This type must be exported such that JavaScript generated by the Google\n// Closure Compiler can import a type reference.\nexport interface PropertyValueMap<T> extends Map<PropertyKey, unknown> {\n get<K extends keyof T>(k: K): T[K] | undefined;\n set<K extends keyof T>(key: K, value: T[K]): this;\n has<K extends keyof T>(k: K): boolean;\n delete<K extends keyof T>(k: K): boolean;\n}\n\nexport const defaultConverter: ComplexAttributeConverter = {\n toAttribute(value: unknown, type?: unknown): unknown {\n switch (type) {\n case Boolean:\n value = value ? emptyStringForBooleanAttribute : null;\n break;\n case Object:\n case Array:\n // if the value is `null` or `undefined` pass this through\n // to allow removing/no change behavior.\n value = value == null ? value : JSON.stringify(value);\n break;\n }\n return value;\n },\n\n fromAttribute(value: string | null, type?: unknown) {\n let fromValue: unknown = value;\n switch (type) {\n case Boolean:\n fromValue = value !== null;\n break;\n case Number:\n fromValue = value === null ? null : Number(value);\n break;\n case Object:\n case Array:\n // Do *not* generate exception when invalid JSON is set as elements\n // don't normally complain on being mis-configured.\n // TODO(sorvell): Do generate exception in *dev mode*.\n try {\n // Assert to adhere to Bazel's \"must type assert JSON parse\" rule.\n fromValue = JSON.parse(value!) as unknown;\n } catch (e) {\n fromValue = null;\n }\n break;\n }\n return fromValue;\n },\n};\n\nexport interface HasChanged {\n (value: unknown, old: unknown): boolean;\n}\n\n/**\n * Change function that returns true if `value` is different from `oldValue`.\n * This method is used as the default for a property's `hasChanged` function.\n */\nexport const notEqual: HasChanged = (value: unknown, old: unknown): boolean =>\n !is(value, old);\n\nconst defaultPropertyDeclaration: PropertyDeclaration = {\n attribute: true,\n type: String,\n converter: defaultConverter,\n reflect: false,\n useDefault: false,\n hasChanged: notEqual,\n};\n\n/**\n * A string representing one of the supported dev mode warning categories.\n */\nexport type WarningKind =\n | 'change-in-update'\n | 'migration'\n | 'async-perform-update';\n\nexport type Initializer = (element: ReactiveElement) => void;\n\n// Temporary, until google3 is on TypeScript 5.2\ndeclare global {\n interface SymbolConstructor {\n readonly metadata: unique symbol;\n }\n}\n\n// Ensure metadata is enabled. TypeScript does not polyfill\n// Symbol.metadata, so we must ensure that it exists.\n(Symbol as {metadata: symbol}).metadata ??= Symbol('metadata');\n\ndeclare global {\n // This is public global API, do not change!\n // eslint-disable-next-line no-var\n var litPropertyMetadata: WeakMap<\n object,\n Map<PropertyKey, PropertyDeclaration>\n >;\n}\n\n// Map from a class's metadata object to property options\n// Note that we must use nullish-coalescing assignment so that we only use one\n// map even if we load multiple version of this module.\nglobal.litPropertyMetadata ??= new WeakMap<\n object,\n Map<PropertyKey, PropertyDeclaration>\n>();\n\n/**\n * Base element class which manages element properties and attributes. When\n * properties change, the `update` method is asynchronously called. This method\n * should be supplied by subclasses to render updates as desired.\n * @noInheritDoc\n */\nexport abstract class ReactiveElement\n // In the Node build, this `extends` clause will be substituted with\n // `(globalThis.HTMLElement ?? HTMLElement)`.\n //\n // This way, we will first prefer any global `HTMLElement` polyfill that the\n // user has assigned, and then fall back to the `HTMLElement` shim which has\n // been imported (see note at the top of this file about how this import is\n // generated by Rollup). Note that the `HTMLElement` variable has been\n // shadowed by this import, so it no longer refers to the global.\n extends HTMLElement\n implements ReactiveControllerHost\n{\n // Note: these are patched in only in DEV_MODE.\n /**\n * Read or set all the enabled warning categories for this class.\n *\n * This property is only used in development builds.\n *\n * @nocollapse\n * @category dev-mode\n */\n static enabledWarnings?: WarningKind[];\n\n /**\n * Enable the given warning category for this class.\n *\n * This method only exists in development builds, so it should be accessed\n * with a guard like:\n *\n * ```ts\n * // Enable for all ReactiveElement subclasses\n * ReactiveElement.enableWarning?.('migration');\n *\n * // Enable for only MyElement and subclasses\n * MyElement.enableWarning?.('migration');\n * ```\n *\n * @nocollapse\n * @category dev-mode\n */\n static enableWarning?: (warningKind: WarningKind) => void;\n\n /**\n * Disable the given warning category for this class.\n *\n * This method only exists in development builds, so it should be accessed\n * with a guard like:\n *\n * ```ts\n * // Disable for all ReactiveElement subclasses\n * ReactiveElement.disableWarning?.('migration');\n *\n * // Disable for only MyElement and subclasses\n * MyElement.disableWarning?.('migration');\n * ```\n *\n * @nocollapse\n * @category dev-mode\n */\n static disableWarning?: (warningKind: WarningKind) => void;\n\n /**\n * Adds an initializer function to the class that is called during instance\n * construction.\n *\n * This is useful for code that runs against a `ReactiveElement`\n * subclass, such as a decorator, that needs to do work for each\n * instance, such as setting up a `ReactiveController`.\n *\n * ```ts\n * const myDecorator = (target: typeof ReactiveElement, key: string) => {\n * target.addInitializer((instance: ReactiveElement) => {\n * // This is run during construction of the element\n * new MyController(instance);\n * });\n * }\n * ```\n *\n * Decorating a field will then cause each instance to run an initializer\n * that adds a controller:\n *\n * ```ts\n * class MyElement extends LitElement {\n * @myDecorator foo;\n * }\n * ```\n *\n * Initializers are stored per-constructor. Adding an initializer to a\n * subclass does not add it to a superclass. Since initializers are run in\n * constructors, initializers will run in order of the class hierarchy,\n * starting with superclasses and progressing to the instance's class.\n *\n * @nocollapse\n */\n static addInitializer(initializer: Initializer) {\n this.__prepare();\n (this._initializers ??= []).push(initializer);\n }\n\n static _initializers?: Initializer[];\n\n /*\n * Due to closure compiler ES6 compilation bugs, @nocollapse is required on\n * all static methods and properties with initializers. Reference:\n * - https://github.com/google/closure-compiler/issues/1776\n */\n\n /**\n * Maps attribute names to properties; for example `foobar` attribute to\n * `fooBar` property. Created lazily on user subclasses when finalizing the\n * class.\n * @nocollapse\n */\n private static __attributeToPropertyMap: AttributeMap;\n\n /**\n * Marks class as having been finalized, which includes creating properties\n * from `static properties`, but does *not* include all properties created\n * from decorators.\n * @nocollapse\n */\n protected static finalized: true | undefined;\n\n /**\n * Memoized list of all element properties, including any superclass\n * properties. Created lazily on user subclasses when finalizing the class.\n *\n * @nocollapse\n * @category properties\n */\n static elementProperties: PropertyDeclarationMap;\n\n /**\n * User-supplied object that maps property names to `PropertyDeclaration`\n * objects containing options for configuring reactive properties. When\n * a reactive property is set the element will update and render.\n *\n * By default properties are public fields, and as such, they should be\n * considered as primarily settable by element users, either via attribute or\n * the property itself.\n *\n * Generally, properties that are changed by the element should be private or\n * protected fields and should use the `state: true` option. Properties\n * marked as `state` do not reflect from the corresponding attribute\n *\n * However, sometimes element code does need to set a public property. This\n * should typically only be done in response to user interaction, and an event\n * should be fired informing the user; for example, a checkbox sets its\n * `checked` property when clicked and fires a `changed` event. Mutating\n * public properties should typically not be done for non-primitive (object or\n * array) properties. In other cases when an element needs to manage state, a\n * private property set with the `state: true` option should be used. When\n * needed, state properties can be initialized via public properties to\n * facilitate complex interactions.\n * @nocollapse\n * @category properties\n */\n static properties: PropertyDeclarations;\n\n /**\n * Memoized list of all element styles.\n * Created lazily on user subclasses when finalizing the class.\n * @nocollapse\n * @category styles\n */\n static elementStyles: Array<CSSResultOrNative> = [];\n\n /**\n * Array of styles to apply to the element. The styles should be defined\n * using the {@linkcode css} tag function, via constructible stylesheets, or\n * imported from native CSS module scripts.\n *\n * Note on Content Security Policy:\n *\n * Element styles are implemented with `<style>` tags when the browser doesn't\n * support adopted StyleSheets. To use such `<style>` tags with the style-src\n * CSP directive, the style-src value must either include 'unsafe-inline' or\n * `nonce-<base64-value>` with `<base64-value>` replaced be a server-generated\n * nonce.\n *\n * To provide a nonce to use on generated `<style>` elements, set\n * `window.litNonce` to a server-generated nonce in your page's HTML, before\n * loading application code:\n *\n * ```html\n * <script>\n * // Generated and unique per request:\n * window.litNonce = 'a1b2c3d4';\n * </script>\n * ```\n * @nocollapse\n * @category styles\n */\n static styles?: CSSResultGroup;\n\n /**\n * Returns a list of attributes corresponding to the registered properties.\n * @nocollapse\n * @category attributes\n */\n static get observedAttributes() {\n // Ensure we've created all properties\n this.finalize();\n // this.__attributeToPropertyMap is only undefined after finalize() in\n // ReactiveElement itself. ReactiveElement.observedAttributes is only\n // accessed with ReactiveElement as the receiver when a subclass or mixin\n // calls super.observedAttributes\n return (\n this.__attributeToPropertyMap && [...this.__attributeToPropertyMap.keys()]\n );\n }\n\n private __instanceProperties?: PropertyValues = undefined;\n\n /**\n * Creates a property accessor on the element prototype if one does not exist\n * and stores a {@linkcode PropertyDeclaration} for the property with the\n * given options. The property setter calls the property's `hasChanged`\n * property option or uses a strict identity check to determine whether or not\n * to request an update.\n *\n * This method may be overridden to customize properties; however,\n * when doing so, it's important to call `super.createProperty` to ensure\n * the property is setup correctly. This method calls\n * `getPropertyDescriptor` internally to get a descriptor to install.\n * To customize what properties do when they are get or set, override\n * `getPropertyDescriptor`. To customize the options for a property,\n * implement `createProperty` like this:\n *\n * ```ts\n * static createProperty(name, options) {\n * options = Object.assign(options, {myOption: true});\n * super.createProperty(name, options);\n * }\n * ```\n *\n * @nocollapse\n * @category properties\n */\n static createProperty(\n name: PropertyKey,\n options: PropertyDeclaration = defaultPropertyDeclaration\n ) {\n // If this is a state property, force the attribute to false.\n if (options.state) {\n (options as Mutable<PropertyDeclaration, 'attribute'>).attribute = false;\n }\n this.__prepare();\n // Whether this property is wrapping accessors.\n // Helps control the initial value change and reflection logic.\n if (this.prototype.hasOwnProperty(name)) {\n options = Object.create(options);\n options.wrapped = true;\n }\n this.elementProperties.set(name, options);\n if (!options.noAccessor) {\n const key = DEV_MODE\n ? // Use Symbol.for in dev mode to make it easier to maintain state\n // when doing HMR.\n Symbol.for(`${String(name)} (@property() cache)`)\n : Symbol();\n const descriptor = this.getPropertyDescriptor(name, key, options);\n if (descriptor !== undefined) {\n defineProperty(this.prototype, name, descriptor);\n }\n }\n }\n\n /**\n * Returns a property descriptor to be defined on the given named property.\n * If no descriptor is returned, the property will not become an accessor.\n * For example,\n *\n * ```ts\n * class MyElement extends LitElement {\n * static getPropertyDescriptor(name, key, options) {\n * const defaultDescriptor =\n * super.getPropertyDescriptor(name, key, options);\n * const setter = defaultDescriptor.set;\n * return {\n * get: defaultDescriptor.get,\n * set(value) {\n * setter.call(this, value);\n * // custom action.\n * },\n * configurable: true,\n * enumerable: true\n * }\n * }\n * }\n * ```\n *\n * @nocollapse\n * @category properties\n */\n protected static getPropertyDescriptor(\n name: PropertyKey,\n key: string | symbol,\n options: PropertyDeclaration\n ): PropertyDescriptor | undefined {\n const {get, set} = getOwnPropertyDescriptor(this.prototype, name) ?? {\n get(this: ReactiveElement) {\n return this[key as keyof typeof this];\n },\n set(this: ReactiveElement, v: unknown) {\n (this as unknown as Record<string | symbol, unknown>)[key] = v;\n },\n };\n if (DEV_MODE && get == null) {\n if ('value' in (getOwnPropertyDescriptor(this.prototype, name) ?? {})) {\n throw new Error(\n `Field ${JSON.stringify(String(name))} on ` +\n `${this.name} was declared as a reactive property ` +\n `but it's actually declared as a value on the prototype. ` +\n `Usually this is due to using @property or @state on a method.`\n );\n }\n issueWarning(\n 'reactive-property-without-getter',\n `Field ${JSON.stringify(String(name))} on ` +\n `${this.name} was declared as a reactive property ` +\n `but it does not have a getter. This will be an error in a ` +\n `future version of Lit.`\n );\n }\n return {\n get,\n set(this: ReactiveElement, value: unknown) {\n const oldValue = get?.call(this);\n set?.call(this, value);\n this.requestUpdate(name, oldValue, options);\n },\n configurable: true,\n enumerable: true,\n };\n }\n\n /**\n * Returns the property options associated with the given property.\n * These options are defined with a `PropertyDeclaration` via the `properties`\n * object or the `@property` decorator and are registered in\n * `createProperty(...)`.\n *\n * Note, this method should be considered \"final\" and not overridden. To\n * customize the options for a given property, override\n * {@linkcode createProperty}.\n *\n * @nocollapse\n * @final\n * @category properties\n */\n static getPropertyOptions(name: PropertyKey) {\n return this.elementProperties.get(name) ?? defaultPropertyDeclaration;\n }\n\n // Temporary, until google3 is on TypeScript 5.2\n declare static [Symbol.metadata]: object & Record<PropertyKey, unknown>;\n\n /**\n * Initializes static own properties of the class used in bookkeeping\n * for element properties, initializers, etc.\n *\n * Can be called multiple times by code that needs to ensure these\n * properties exist before using them.\n *\n * This method ensures the superclass is finalized so that inherited\n * property metadata can be copied down.\n * @nocollapse\n */\n private static __prepare() {\n if (\n this.hasOwnProperty(JSCompiler_renameProperty('elementProperties', this))\n ) {\n // Already prepared\n return;\n }\n // Finalize any superclasses\n const superCtor = getPrototypeOf(this) as typeof ReactiveElement;\n superCtor.finalize();\n\n // Create own set of initializers for this class if any exist on the\n // superclass and copy them down. Note, for a small perf boost, avoid\n // creating initializers unless needed.\n if (superCtor._initializers !== undefined) {\n this._initializers = [...superCtor._initializers];\n }\n // Initialize elementProperties from the superclass\n this.elementProperties = new Map(superCtor.elementProperties);\n }\n\n /**\n * Finishes setting up the class so that it's ready to be registered\n * as a custom element and instantiated.\n *\n * This method is called by the ReactiveElement.observedAttributes getter.\n * If you override the observedAttributes getter, you must either call\n * super.observedAttributes to trigger finalization, or call finalize()\n * yourself.\n *\n * @nocollapse\n */\n protected static finalize() {\n if (this.hasOwnProperty(JSCompiler_renameProperty('finalized', this))) {\n return;\n }\n this.finalized = true;\n this.__prepare();\n\n // Create properties from the static properties block:\n if (this.hasOwnProperty(JSCompiler_renameProperty('properties', this))) {\n const props = this.properties;\n const propKeys = [\n ...getOwnPropertyNames(props),\n ...getOwnPropertySymbols(props),\n ] as Array<keyof typeof props>;\n for (const p of propKeys) {\n this.createProperty(p, props[p]);\n }\n }\n\n // Create properties from standard decorator metadata:\n const metadata = this[Symbol.metadata];\n if (metadata !== null) {\n const properties = litPropertyMetadata.get(metadata);\n if (properties !== undefined) {\n for (const [p, options] of properties) {\n this.elementProperties.set(p, options);\n }\n }\n }\n\n // Create the attribute-to-property map\n this.__attributeToPropertyMap = new Map();\n for (const [p, options] of this.elementProperties) {\n const attr = this.__attributeNameForProperty(p, options);\n if (attr !== undefined) {\n this.__attributeToPropertyMap.set(attr, p);\n }\n }\n\n this.elementStyles = this.finalizeStyles(this.styles);\n\n if (DEV_MODE) {\n if (this.hasOwnProperty('createProperty')) {\n issueWarning(\n 'no-override-create-property',\n 'Overriding ReactiveElement.createProperty() is deprecated. ' +\n 'The override will not be called with standard decorators'\n );\n }\n if (this.hasOwnProperty('getPropertyDescriptor')) {\n issueWarning(\n 'no-override-get-property-descriptor',\n 'Overriding ReactiveElement.getPropertyDescriptor() is deprecated. ' +\n 'The override will not be called with standard decorators'\n );\n }\n }\n }\n\n /**\n * Options used when calling `attachShadow`. Set this property to customize\n * the options for the shadowRoot; for example, to create a closed\n * shadowRoot: `{mode: 'closed'}`.\n *\n * Note, these options are used in `createRenderRoot`. If this method\n * is customized, options should be respected if possible.\n * @nocollapse\n * @category rendering\n */\n static shadowRootOptions: ShadowRootInit = {mode: 'open'};\n\n /**\n * Takes the styles the user supplied via the `static styles` property and\n * returns the array of styles to apply to the element.\n * Override this method to integrate into a style management system.\n *\n * Styles are deduplicated preserving the _last_ instance in the list. This\n * is a performance optimization to avoid duplicated styles that can occur\n * especially when composing via subclassing. The last item is kept to try\n * to preserve the cascade order with the assumption that it's most important\n * that last added styles override previous styles.\n *\n * @nocollapse\n * @category styles\n */\n protected static finalizeStyles(\n styles?: CSSResultGroup\n ): Array<CSSResultOrNative> {\n const elementStyles = [];\n if (Array.isArray(styles)) {\n // Dedupe the flattened array in reverse order to preserve the last items.\n // Casting to Array<unknown> works around TS error that\n // appears to come from trying to flatten a type CSSResultArray.\n const set = new Set((styles as Array<unknown>).flat(Infinity).reverse());\n // Then preserve original order by adding the set items in reverse order.\n for (const s of set) {\n elementStyles.unshift(getCompatibleStyle(s as CSSResultOrNative));\n }\n } else if (styles !== undefined) {\n elementStyles.push(getCompatibleStyle(styles));\n }\n return elementStyles;\n }\n\n /**\n * Node or ShadowRoot into which element DOM should be rendered. Defaults\n * to an open shadowRoot.\n * @category rendering\n */\n readonly renderRoot!: HTMLElement | DocumentFragment;\n\n /**\n * Returns the property name for the given attribute `name`.\n * @nocollapse\n */\n private static __attributeNameForProperty(\n name: PropertyKey,\n options: PropertyDeclaration\n ) {\n const attribute = options.attribute;\n return attribute === false\n ? undefined\n : typeof attribute === 'string'\n ? attribute\n : typeof name === 'string'\n ? name.toLowerCase()\n : undefined;\n }\n\n // Initialize to an unresolved Promise so we can make sure the element has\n // connected before first update.\n private __updatePromise!: Promise<boolean>;\n\n /**\n * True if there is a pending update as a result of calling `requestUpdate()`.\n * Should only be read.\n * @category updates\n */\n isUpdatePending = false;\n\n /**\n * Is set to `true` after the first update. The element code cannot assume\n * that `renderRoot` exists before the element `hasUpdated`.\n * @category updates\n */\n hasUpdated = false;\n\n /**\n * Map with keys for any properties that have changed since the last\n * update cycle with previous values.\n *\n * @internal\n */\n _$changedProperties!: PropertyValues;\n\n /**\n * Records property default values when the\n * `useDefault` option is used.\n */\n private __defaultValues?: Map<PropertyKey, unknown>;\n\n /**\n * Properties that should be reflected when updated.\n */\n private __reflectingProperties?: Set<PropertyKey>;\n\n /**\n * Name of currently reflecting property\n */\n private __reflectingProperty: PropertyKey | null = null;\n\n /**\n * Set of controllers.\n */\n private __controllers?: Set<ReactiveController>;\n\n constructor() {\n super();\n this.__initialize();\n }\n\n /**\n * Internal only override point for customizing work done when elements\n * are constructed.\n */\n private __initialize() {\n this.__updatePromise = new Promise<boolean>(\n (res) => (this.enableUpdating = res)\n );\n this._$changedProperties = new Map();\n // This enqueues a microtask that must run before the first update, so it\n // must be called before requestUpdate()\n this.__saveInstanceProperties();\n // ensures first update will be caught by an early access of\n // `updateComplete`\n this.requestUpdate();\n (this.constructor as typeof ReactiveElement)._initializers?.forEach((i) =>\n i(this)\n );\n }\n\n /**\n * Registers a `ReactiveController` to participate in the element's reactive\n * update cycle. The element automatically calls into any registered\n * controllers during its lifecycle callbacks.\n *\n * If the element is connected when `addController()` is called, the\n * controller's `hostConnected()` callback will be immediately called.\n * @category controllers\n */\n addController(controller: ReactiveController) {\n (this.__controllers ??= new Set()).add(controller);\n // If a controller is added after the element has been connected,\n // call hostConnected. Note, re-using existence of `renderRoot` here\n // (which is set in connectedCallback) to avoid the need to track a\n // first connected state.\n if (this.renderRoot !== undefined && this.isConnected) {\n controller.hostConnected?.();\n }\n }\n\n /**\n * Removes a `ReactiveController` from the element.\n * @category controllers\n */\n removeController(controller: ReactiveController) {\n this.__controllers?.delete(controller);\n }\n\n /**\n * Fixes any properties set on the instance before upgrade time.\n * Otherwise these would shadow the accessor and break these properties.\n * The properties are stored in a Map which is played back after the\n * constructor runs.\n */\n private __saveInstanceProperties() {\n const instanceProperties = new Map<PropertyKey, unknown>();\n const elementProperties = (this.constructor as typeof ReactiveElement)\n .elementProperties;\n for (const p of elementProperties.keys() as IterableIterator<keyof this>) {\n if (this.hasOwnProperty(p)) {\n instanceProperties.set(p, this[p]);\n delete this[p];\n }\n }\n if (instanceProperties.size > 0) {\n this.__instanceProperties = instanceProperties;\n }\n }\n\n /**\n * Returns the node into which the element should render and by default\n * creates and returns an open shadowRoot. Implement to customize where the\n * element's DOM is rendered. For example, to render into the element's\n * childNodes, return `this`.\n *\n * @return Returns a node into which to render.\n * @category rendering\n */\n protected createRenderRoot(): HTMLElement | DocumentFragment {\n const renderRoot =\n this.shadowRoot ??\n this.attachShadow(\n (this.constructor as typeof ReactiveElement).shadowRootOptions\n );\n adoptStyles(\n renderRoot,\n (this.constructor as typeof ReactiveElement).elementStyles\n );\n return renderRoot;\n }\n\n /**\n * On first connection, creates the element's renderRoot, sets up\n * element styling, and enables updating.\n * @category lifecycle\n */\n connectedCallback() {\n // Create renderRoot before controllers `hostConnected`\n (this as Mutable<typeof this, 'renderRoot'>).renderRoot ??=\n this.createRenderRoot();\n this.enableUpdating(true);\n this.__controllers?.forEach((c) => c.hostConnected?.());\n }\n\n /**\n * Note, this method should be considered final and not overridden. It is\n * overridden on the element instance with a function that triggers the first\n * update.\n * @category updates\n */\n protected enableUpdating(_requestedUpdate: boolean) {}\n\n /**\n * Allows for `super.disconnectedCallback()` in extensions while\n * reserving the possibility of making non-breaking feature additions\n * when disconnecting at some point in the future.\n * @category lifecycle\n */\n disconnectedCallback() {\n this.__controllers?.forEach((c) => c.hostDisconnected?.());\n }\n\n /**\n * Synchronizes property values when attributes change.\n *\n * Specifically, when an attribute is set, the corresponding property is set.\n * You should rarely need to implement this callback. If this method is\n * overridden, `super.attributeChangedCallback(name, _old, value)` must be\n * called.\n *\n * See [responding to attribute changes](https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_custom_elements#responding_to_attribute_changes)\n * on MDN for more information about the `attributeChangedCallback`.\n * @category attributes\n */\n attributeChangedCallback(\n name: string,\n _old: string | null,\n value: string | null\n ) {\n this._$attributeToProperty(name, value);\n }\n\n private __propertyToAttribute(name: PropertyKey, value: unknown) {\n const elemProperties: PropertyDeclarationMap = (\n this.constructor as typeof ReactiveElement\n ).elementProperties;\n const options = elemProperties.get(name)!;\n const attr = (\n this.constructor as typeof ReactiveElement\n ).__attributeNameForProperty(name, options);\n if (attr !== undefined && options.reflect === true) {\n const converter =\n (options.converter as ComplexAttributeConverter)?.toAttribute !==\n undefined\n ? (options.converter as ComplexAttributeConverter)\n : defaultConverter;\n const attrValue = converter.toAttribute!(value, options.type);\n if (\n DEV_MODE &&\n (this.constructor as typeof ReactiveElement).enabledWarnings!.includes(\n 'migration'\n ) &&\n attrValue === undefined\n ) {\n issueWarning(\n 'undefined-attribute-value',\n `The attribute value for the ${name as string} property is ` +\n `undefined on element ${this.localName}. The attribute will be ` +\n `removed, but in the previous version of \\`ReactiveElement\\`, ` +\n `the attribute would not have changed.`\n );\n }\n // Track if the property is being reflected to avoid\n // setting the property again via `attributeChangedCallback`. Note:\n // 1. this takes advantage of the fact that the callback is synchronous.\n // 2. will behave incorrectly if multiple attributes are in the reaction\n // stack at time of calling. However, since we process attributes\n // in `update` this should not be possible (or an extreme corner case\n // that we'd like to discover).\n // mark state reflecting\n this.__reflectingProperty = name;\n if (attrValue == null) {\n this.removeAttribute(attr);\n } else {\n this.setAttribute(attr, attrValue as string);\n }\n // mark state not reflecting\n this.__reflectingProperty = null;\n }\n }\n\n /** @internal */\n _$attributeToProperty(name: string, value: string | null) {\n const ctor = this.constructor as typeof ReactiveElement;\n // Note, hint this as an `AttributeMap` so closure clearly understands\n // the type; it has issues with tracking types through statics\n const propName = (ctor.__attributeToPropertyMap as AttributeMap).get(name);\n // Use tracking info to avoid reflecting a property value to an attribute\n // if it was just set because the attribute changed.\n if (propName !== undefined && this.__reflectingProperty !== propName) {\n const options = ctor.getPropertyOptions(propName);\n const converter =\n typeof options.converter === 'function'\n ? {fromAttribute: options.converter}\n : options.converter?.fromAttribute !== undefined\n ? options.converter\n : defaultConverter;\n // mark state reflecting\n this.__reflectingProperty = propName;\n const convertedValue = converter.fromAttribute!(value, options.type);\n this[propName as keyof this] =\n convertedValue ??\n this.__defaultValues?.get(propName) ??\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (convertedValue as any);\n // mark state not reflecting\n this.__reflectingProperty = null;\n }\n }\n\n /**\n * Requests an update which is processed asynchronously. This should be called\n * when an element should update based on some state not triggered by setting\n * a reactive property. In this case, pass no arguments. It should also be\n * called when manually implementing a property setter. In this case, pass the\n * property `name` and `oldValue` to ensure that any configured property\n * options are honored.\n *\n * @param name name of requesting property\n * @param oldValue old value of requesting property\n * @param options property options to use instead of the previously\n * configured options\n * @category updates\n */\n requestUpdate(\n name?: PropertyKey,\n oldValue?: unknown,\n options?: PropertyDeclaration\n ): void {\n // If we have a property key, perform property update steps.\n if (name !== undefined) {\n if (DEV_MODE && (name as unknown) instanceof Event) {\n issueWarning(\n ``,\n `The requestUpdate() method was called with an Event as the property name. This is probably a mistake caused by binding this.requestUpdate as an event listener. Instead bind a function that will call it with no arguments: () => this.requestUpdate()`\n );\n }\n const ctor = this.constructor as typeof ReactiveElement;\n const newValue = this[name as keyof this];\n options ??= ctor.getPropertyOptions(name);\n const changed =\n (options.hasChanged ?? notEqual)(newValue, oldValue) ||\n // When there is no change, check a corner case that can occur when\n // 1. there's a initial value which was not reflected\n // 2. the property is subsequently set to this value.\n // For example, `prop: {useDefault: true, reflect: true}`\n // and el.prop = 'foo'. This should be considered a change if the\n // attribute is not set because we will now reflect the property to the attribute.\n (options.useDefault &&\n options.reflect &&\n newValue === this.__defaultValues?.get(name) &&\n !this.hasAttribute(ctor.__attributeNameForProperty(name, options)!));\n if (changed) {\n this._$changeProperty(name, oldValue, options);\n } else {\n // Abort the request if the property should not be considered changed.\n return;\n }\n }\n if (this.isUpdatePending === false) {\n this.__updatePromise = this.__enqueueUpdate();\n }\n }\n\n /**\n * @internal\n */\n _$changeProperty(\n name: PropertyKey,\n oldValue: unknown,\n {useDefault, reflect, wrapped}: PropertyDeclaration,\n initializeValue?: unknown\n ) {\n // Record default value when useDefault is used. This allows us to\n // restore this value when the attribute is removed.\n if (useDefault && !(this.__defaultValues ??= new Map()).has(name)) {\n this.__defaultValues.set(\n name,\n initializeValue ?? oldValue ?? this[name as keyof this]\n );\n // if this is not wrapping an accessor, it must be an initial setting\n // and in this case we do not want to record the change or reflect.\n if (wrapped !== true || initializeValue !== undefined) {\n return;\n }\n }\n // TODO (justinfagnani): Create a benchmark of Map.has() + Map.set(\n // vs just Map.set()\n if (!this._$changedProperties.has(name)) {\n // On the initial change, the old value should be `undefined`, except\n // with `useDefault`\n if (!this.hasUpdated && !useDefault) {\n oldValue = undefined;\n }\n this._$changedProperties.set(name, oldValue);\n }\n // Add to reflecting properties set.\n // Note, it's important that every change has a chance to add the\n // property to `__reflectingProperties`. This ensures setting\n // attribute + property reflects correctly.\n if (reflect === true && this.__reflectingProperty !== name) {\n (this.__reflectingProperties ??= new Set<PropertyKey>()).add(name);\n }\n }\n\n /**\n * Sets up the element to asynchronously update.\n */\n private async __enqueueUpdate() {\n this.isUpdatePending = true;\n try {\n // Ensure any previous update has resolved before updating.\n // This `await` also ensures that property changes are batched.\n await this.__updatePromise;\n } catch (e) {\n // Refire any previous errors async so they do not disrupt the update\n // cycle. Errors are refired so developers have a chance to observe\n // them, and this can be done by implementing\n // `window.onunhandledrejection`.\n Promise.reject(e);\n }\n const result = this.scheduleUpdate();\n // If `scheduleUpdate` returns a Promise, we await it. This is done to\n // enable coordinating updates with a scheduler. Note, the result is\n // checked to avoid delaying an additional microtask unless we need to.\n if (result != null) {\n await result;\n }\n return !this.isUpdatePending;\n }\n\n /**\n * Schedules an element update. You can override this method to change the\n * timing of updates by returning a Promise. The update will await the\n * returned Promise, and you should resolve the Promise to allow the update\n * to proceed. If this method is overridden, `super.scheduleUpdate()`\n * must be called.\n *\n * For instance, to schedule updates to occur just before the next frame:\n *\n * ```ts\n * override protected async scheduleUpdate(): Promise<unknown> {\n * await new Promise((resolve) => requestAnimationFrame(() => resolve()));\n * super.scheduleUpdate();\n * }\n * ```\n * @category updates\n */\n protected scheduleUpdate(): void | Promise<unknown> {\n const result = this.performUpdate();\n if (\n DEV_MODE &&\n (this.constructor as typeof ReactiveElement).enabledWarnings!.includes(\n 'async-perform-update'\n ) &&\n typeof (result as unknown as Promise<unknown> | undefined)?.then ===\n 'function'\n ) {\n issueWarning(\n 'async-perform-update',\n `Element ${this.localName} returned a Promise from performUpdate(). ` +\n `This behavior is deprecated and will be removed in a future ` +\n `version of ReactiveElement.`\n );\n }\n return result;\n }\n\n /**\n * Performs an element update. Note, if an exception is thrown during the\n * update, `firstUpdated` and `updated` will not be called.\n *\n * Call `performUpdate()` to immediately process a pending update. This should\n * generally not be needed, but it can be done in rare cases when you need to\n * update synchronously.\n *\n * @category updates\n */\n protected performUpdate(): void {\n // Abort any update if one is not pending when this is called.\n // This can happen if `performUpdate` is called early to \"flush\"\n // the update.\n if (!this.isUpdatePending) {\n return;\n }\n debugLogEvent?.({kind: 'update'});\n if (!this.hasUpdated) {\n // Create renderRoot before first update. This occurs in `connectedCallback`\n // but is done here to support out of tree calls to `enableUpdating`/`performUpdate`.\n (this as Mutable<typeof this, 'renderRoot'>).renderRoot ??=\n this.createRenderRoot();\n if (DEV_MODE) {\n // Produce warning if any reactive properties on the prototype are\n // shadowed by class fields. Instance fields set before upgrade are\n // deleted by this point, so any own property is caused by class field\n // initialization in the constructor.\n const ctor = this.constructor as typeof ReactiveElement;\n const shadowedProperties = [...ctor.elementProperties.keys()].filter(\n (p) => this.hasOwnProperty(p) && p in getPrototypeOf(this)\n );\n if (shadowedProperties.length) {\n throw new Error(\n `The following properties on element ${this.localName} will not ` +\n `trigger updates as expected because they are set using class ` +\n `fields: ${shadowedProperties.join(', ')}. ` +\n `Native class fields and some compiled output will overwrite ` +\n `accessors used for detecting changes. See ` +\n `https://lit.dev/msg/class-field-shadowing ` +\n `for more information.`\n );\n }\n }\n // Mixin instance properties once, if they exist.\n if (this.__instanceProperties) {\n // TODO (justinfagnani): should we use the stored value? Could a new value\n // have been set since we stored the own property value?\n for (const [p, value] of this.__instanceProperties) {\n this[p as keyof this] = value as this[keyof this];\n }\n this.__instanceProperties = undefined;\n }\n // Trigger initial value reflection and populate the initial\n // `changedProperties` map, but only for the case of properties created\n // via `createProperty` on accessors, which will not have already\n // populated the `changedProperties` map since they are not set.\n // We can't know if these accessors had initializers, so we just set\n // them anyway - a difference from experimental decorators on fields and\n // standard decorators on auto-accessors.\n // For context see:\n // https://github.com/lit/lit/pull/4183#issuecomment-1711959635\n const elementProperties = (this.constructor as typeof ReactiveElement)\n .elementProperties;\n if (elementProperties.size > 0) {\n for (const [p, options] of elementProperties) {\n const {wrapped} = options;\n const value = this[p as keyof this];\n if (\n wrapped === true &&\n !this._$changedProperties.has(p) &&\n value !== undefined\n ) {\n this._$changeProperty(p, undefined, options, value);\n }\n }\n }\n }\n let shouldUpdate = false;\n const changedProperties = this._$changedProperties;\n try {\n shouldUpdate = this.shouldUpdate(changedProperties);\n if (shouldUpdate) {\n this.willUpdate(changedProperties);\n this.__controllers?.forEach((c) => c.hostUpdate?.());\n this.update(changedProperties);\n } else {\n this.__markUpdated();\n }\n } catch (e) {\n // Prevent `firstUpdated` and `updated` from running when there's an\n // update exception.\n shouldUpdate = false;\n // Ensure element can accept additional updates after an exception.\n this.__markUpdated();\n throw e;\n }\n // The update is no longer considered pending and further updates are now allowed.\n if (shouldUpdate) {\n this._$didUpdate(changedProperties);\n }\n }\n\n /**\n * Invoked before `update()` to compute values needed during the update.\n *\n * Implement `willUpdate` to compute property values that depend on other\n * properties and are used in the rest of the update process.\n *\n * ```ts\n * willUpdate(changedProperties) {\n * // only need to check changed properties for an expensive computation.\n * if (changedProperties.has('firstName') || changedProperties.has('lastName')) {\n * this.sha = computeSHA(`${this.firstName} ${this.lastName}`);\n * }\n * }\n *\n * render() {\n * return html`SHA: ${this.sha}`;\n * }\n * ```\n *\n * @category updates\n */\n protected willUpdate(_changedProperties: PropertyValues): void {}\n\n // Note, this is an override point for polyfill-support.\n // @internal\n _$didUpdate(changedProperties: PropertyValues) {\n this.__controllers?.forEach((c) => c.hostUpdated?.());\n if (!this.hasUpdated) {\n this.hasUpdated = true;\n this.firstUpdated(changedProperties);\n }\n this.updated(changedProperties);\n if (\n DEV_MODE &&\n this.isUpdatePending &&\n (this.constructor as typeof ReactiveElement).enabledWarnings!.includes(\n 'change-in-update'\n )\n ) {\n issueWarning(\n 'change-in-update',\n `Element ${this.localName} scheduled an update ` +\n `(generally because a property was set) ` +\n `after an update completed, causing a new update to be scheduled. ` +\n `This is inefficient and should be avoided unless the next update ` +\n `can only be scheduled as a side effect of the previous update.`\n );\n }\n }\n\n private __markUpdated() {\n this._$changedProperties = new Map();\n this.isUpdatePending = false;\n }\n\n /**\n * Returns a Promise that resolves when the element has completed updating.\n * The Promise value is a boolean that is `true` if the element completed the\n * update without triggering another update. The Promise result is `false` if\n * a property was set inside `updated()`. If the Promise is rejected, an\n * exception was thrown during the update.\n *\n * To await additional asynchronous work, override the `getUpdateComplete`\n * method. For example, it is sometimes useful to await a rendered element\n * before fulfilling this Promise. To do this, first await\n * `super.getUpdateComplete()`, then any subsequent state.\n *\n * @return A promise of a boolean that resolves to true if the update completed\n * without triggering another update.\n * @category updates\n */\n get updateComplete(): Promise<boolean> {\n return this.getUpdateComplete();\n }\n\n /**\n * Override point for the `updateComplete` promise.\n *\n * It is not safe to override the `updateComplete` getter directly due to a\n * limitation in TypeScript which means it is not possible to call a\n * superclass getter (e.g. `super.updateComplete.then(...)`) when the target\n * language is ES5 (https://github.com/microsoft/TypeScript/issues/338).\n * This method should be overridden instead. For example:\n *\n * ```ts\n * class MyElement extends LitElement {\n * override async getUpdateComplete() {\n * const result = await super.getUpdateComplete();\n * await this._myChild.updateComplete;\n * return result;\n * }\n * }\n * ```\n *\n * @return A promise of a boolean that resolves to true if the update completed\n * without triggering another update.\n * @category updates\n */\n protected getUpdateComplete(): Promise<boolean> {\n return this.__updatePromise;\n }\n\n /**\n * Controls whether or not `update()` should be called when the element requests\n * an update. By default, this method always returns `true`, but this can be\n * customized to control when to update.\n *\n * @param _changedProperties Map of changed properties with old values\n * @category updates\n */\n protected shouldUpdate(_changedProperties: PropertyValues): boolean {\n return true;\n }\n\n /**\n * Updates the element. This method reflects property values to attributes.\n * It can be overridden to render and keep updated element DOM.\n * Setting properties inside this method will *not* trigger\n * another update.\n *\n * @param _changedProperties Map of changed properties with old values\n * @category updates\n */\n protected update(_changedProperties: PropertyValues) {\n // The forEach() expression will only run when __reflectingProperties is\n // defined, and it returns undefined, setting __reflectingProperties to\n // undefined\n this.__reflectingProperties &&= this.__reflectingProperties.forEach((p) =>\n this.__propertyToAttribute(p, this[p as keyof this])\n ) as undefined;\n this.__markUpdated();\n }\n\n /**\n * Invoked whenever the element is updated. Implement to perform\n * post-updating tasks via DOM APIs, for example, focusing an element.\n *\n * Setting properties inside this method will trigger the element to update\n * again after this update cycle completes.\n *\n * @param _changedProperties Map of changed properties with old values\n * @category updates\n */\n protected updated(_changedProperties: PropertyValues) {}\n\n /**\n * Invoked when the element is first updated. Implement to perform one time\n * work on the element after update.\n *\n * ```ts\n * firstUpdated() {\n * this.renderRoot.getElementById('my-text-area').focus();\n * }\n * ```\n *\n * Setting properties inside this method will trigger the element to update\n * again after this update cycle completes.\n *\n * @param _changedProperties Map of changed properties with old values\n * @category updates\n */\n protected firstUpdated(_changedProperties: PropertyValues) {}\n}\n// Assigned here to work around a jscompiler bug with static fields\n// when compiling to ES5.\n// https://github.com/google/closure-compiler/issues/3177\n(ReactiveElement as unknown as Record<string, unknown>)[\n JSCompiler_renameProperty('elementProperties', ReactiveElement)\n] = new Map();\n(ReactiveElement as unknown as Record<string, unknown>)[\n JSCompiler_renameProperty('finalized', ReactiveElement)\n] = new Map();\n\n// Apply polyfills if available\npolyfillSupport?.({ReactiveElement});\n\n// Dev mode warnings...\nif (DEV_MODE) {\n // Default warning set.\n ReactiveElement.enabledWarnings = [\n 'change-in-update',\n 'async-perform-update',\n ];\n const ensureOwnWarnings = function (ctor: typeof ReactiveElement) {\n if (\n !ctor.hasOwnProperty(JSCompiler_renameProperty('enabledWarnings', ctor))\n ) {\n ctor.enabledWarnings = ctor.enabledWarnings!.slice();\n }\n };\n ReactiveElement.enableWarning = function (\n this: typeof ReactiveElement,\n warning: WarningKind\n ) {\n ensureOwnWarnings(this);\n if (!this.enabledWarnings!.includes(warning)) {\n this.enabledWarnings!.push(warning);\n }\n };\n ReactiveElement.disableWarning = function (\n this: typeof ReactiveElement,\n warning: WarningKind\n ) {\n ensureOwnWarnings(this);\n const i = this.enabledWarnings!.indexOf(warning);\n if (i >= 0) {\n this.enabledWarnings!.splice(i, 1);\n }\n };\n}\n\n// IMPORTANT: do not change the property name or the assignment expression.\n// This line will be used in regexes to search for ReactiveElement usage.\n(global.reactiveElementVersions ??= []).push('2.1.1');\nif (DEV_MODE && global.reactiveElementVersions.length > 1) {\n queueMicrotask(() => {\n issueWarning!(\n 'multiple-versions',\n `Multiple versions of Lit loaded. Loading multiple versions ` +\n `is not recommended.`\n );\n });\n}\n", "/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/**\n * The main LitElement module, which defines the {@linkcode LitElement} base\n * class and related APIs.\n *\n * LitElement components can define a template and a set of observed\n * properties. Changing an observed property triggers a re-render of the\n * element.\n *\n * Import {@linkcode LitElement} and {@linkcode html} from this module to\n * create a component:\n *\n * ```js\n * import {LitElement, html} from 'lit-element';\n *\n * class MyElement extends LitElement {\n *\n * // Declare observed properties\n * static get properties() {\n * return {\n * adjective: {}\n * }\n * }\n *\n * constructor() {\n * this.adjective = 'awesome';\n * }\n *\n * // Define the element's template\n * render() {\n * return html`<p>your ${adjective} template here</p>`;\n * }\n * }\n *\n * customElements.define('my-element', MyElement);\n * ```\n *\n * `LitElement` extends {@linkcode ReactiveElement} and adds lit-html\n * templating. The `ReactiveElement` class is provided for users that want to\n * build their own custom element base classes that don't use lit-html.\n *\n * @packageDocumentation\n */\nimport {PropertyValues, ReactiveElement} from '@lit/reactive-element';\nimport {render, RenderOptions, noChange, RootPart} from 'lit-html';\nexport * from '@lit/reactive-element';\nexport * from 'lit-html';\n\nimport {LitUnstable} from 'lit-html';\nimport {ReactiveUnstable} from '@lit/reactive-element';\n\n/**\n * Contains types that are part of the unstable debug API.\n *\n * Everything in this API is not stable and may change or be removed in the future,\n * even on patch releases.\n */\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport namespace Unstable {\n /**\n * When Lit is running in dev mode and `window.emitLitDebugLogEvents` is true,\n * we will emit 'lit-debug' events to window, with live details about the update and render\n * lifecycle. These can be useful for writing debug tooling and visualizations.\n *\n * Please be aware that running with window.emitLitDebugLogEvents has performance overhead,\n * making certain operations that are normally very cheap (like a no-op render) much slower,\n * because we must copy data and dispatch events.\n */\n // eslint-disable-next-line @typescript-eslint/no-namespace\n export namespace DebugLog {\n export type Entry =\n | LitUnstable.DebugLog.Entry\n | ReactiveUnstable.DebugLog.Entry;\n }\n}\n/*\n * When using Closure Compiler, JSCompiler_renameProperty(property, object) is\n * replaced at compile time by the munged name for object[property]. We cannot\n * alias this function, so we have to use a small shim that has the same\n * behavior when not compiling.\n */\n/*@__INLINE__*/\nconst JSCompiler_renameProperty = <P extends PropertyKey>(\n prop: P,\n _obj: unknown\n): P => prop;\n\nconst DEV_MODE = true;\n// Allows minifiers to rename references to globalThis\nconst global = globalThis;\n\nlet issueWarning: (code: string, warning: string) => void;\n\nif (DEV_MODE) {\n // Ensure warnings are issued only 1x, even if multiple versions of Lit\n // are loaded.\n global.litIssuedWarnings ??= new Set();\n\n /**\n * Issue a warning if we haven't already, based either on `code` or `warning`.\n * Warnings are disabled automatically only by `warning`; disabling via `code`\n * can be done by users.\n */\n issueWarning = (code: string, warning: string) => {\n warning += ` See https://lit.dev/msg/${code} for more information.`;\n if (\n !global.litIssuedWarnings!.has(warning) &&\n !global.litIssuedWarnings!.has(code)\n ) {\n console.warn(warning);\n global.litIssuedWarnings!.add(warning);\n }\n };\n}\n\n/**\n * Base element class that manages element properties and attributes, and\n * renders a lit-html template.\n *\n * To define a component, subclass `LitElement` and implement a\n * `render` method to provide the component's template. Define properties\n * using the {@linkcode LitElement.properties properties} property or the\n * {@linkcode property} decorator.\n */\nexport class LitElement extends ReactiveElement {\n // This property needs to remain unminified.\n static ['_$litElement$'] = true;\n\n /**\n * @category rendering\n */\n readonly renderOptions: RenderOptions = {host: this};\n\n private __childPart: RootPart | undefined = undefined;\n\n /**\n * @category rendering\n */\n protected override createRenderRoot() {\n const renderRoot = super.createRenderRoot();\n // When adoptedStyleSheets are shimmed, they are inserted into the\n // shadowRoot by createRenderRoot. Adjust the renderBefore node so that\n // any styles in Lit content render before adoptedStyleSheets. This is\n // important so that adoptedStyleSheets have precedence over styles in\n // the shadowRoot.\n this.renderOptions.renderBefore ??= renderRoot!.firstChild as ChildNode;\n return renderRoot;\n }\n\n /**\n * Updates the element. This method reflects property values to attributes\n * and calls `render` to render DOM via lit-html. Setting properties inside\n * this method will *not* trigger another update.\n * @param changedProperties Map of changed properties with old values\n * @category updates\n */\n protected override update(changedProperties: PropertyValues) {\n // Setting properties in `render` should not trigger an update. Since\n // updates are allowed after super.update, it's important to call `render`\n // before that.\n const value = this.render();\n if (!this.hasUpdated) {\n this.renderOptions.isConnected = this.isConnected;\n }\n super.update(changedProperties);\n this.__childPart = render(value, this.renderRoot, this.renderOptions);\n }\n\n /**\n * Invoked when the component is added to the document's DOM.\n *\n * In `connectedCallback()` you should setup tasks that should only occur when\n * the element is connected to the document. The most common of these is\n * adding event listeners to nodes external to the element, like a keydown\n * event handler added to the window.\n *\n * ```ts\n * connectedCallback() {\n * super.connectedCallback();\n * addEventListener('keydown', this._handleKeydown);\n * }\n * ```\n *\n * Typically, anything done in `connectedCallback()` should be undone when the\n * element is disconnected, in `disconnectedCallback()`.\n *\n * @category lifecycle\n */\n override connectedCallback() {\n super.connectedCallback();\n this.__childPart?.setConnected(true);\n }\n\n /**\n * Invoked when the component is removed from the document's DOM.\n *\n * This callback is the main signal to the element that it may no longer be\n * used. `disconnectedCallback()` should ensure that nothing is holding a\n * reference to the element (such as event listeners added to nodes external\n * to the element), so that it is free to be garbage collected.\n *\n * ```ts\n * disconnectedCallback() {\n * super.disconnectedCallback();\n * window.removeEventListener('keydown', this._handleKeydown);\n * }\n * ```\n *\n * An element may be re-connected after being disconnected.\n *\n * @category lifecycle\n */\n override disconnectedCallback() {\n super.disconnectedCallback();\n this.__childPart?.setConnected(false);\n }\n\n /**\n * Invoked on each update to perform rendering tasks. This method may return\n * any value renderable by lit-html's `ChildPart` - typically a\n * `TemplateResult`. Setting properties inside this method will *not* trigger\n * the element to update.\n * @category rendering\n */\n protected render(): unknown {\n return noChange;\n }\n}\n\n/**\n * Ensure this class is marked as `finalized` as an optimization ensuring\n * it will not needlessly try to `finalize`.\n *\n * Note this property name is a string to prevent breaking Closure JS Compiler\n * optimizations. See @lit/reactive-element for more information.\n */\n(LitElement as unknown as Record<string, unknown>)[\n JSCompiler_renameProperty('finalized', LitElement)\n] = true;\n\n// Install hydration if available\nglobal.litElementHydrateSupport?.({LitElement});\n\n// Apply polyfills if available\nconst polyfillSupport = DEV_MODE\n ? global.litElementPolyfillSupportDevMode\n : global.litElementPolyfillSupport;\npolyfillSupport?.({LitElement});\n\n/**\n * END USERS SHOULD NOT RELY ON THIS OBJECT.\n *\n * Private exports for use by other Lit packages, not intended for use by\n * external users.\n *\n * We currently do not make a mangled rollup build of the lit-ssr code. In order\n * to keep a number of (otherwise private) top-level exports mangled in the\n * client side code, we export a _$LE object containing those members (or\n * helper methods for accessing private fields of those members), and then\n * re-export them for use in lit-ssr. This keeps lit-ssr agnostic to whether the\n * client-side code is being used in `dev` mode or `prod` mode.\n *\n * This has a unique name, to disambiguate it from private exports in\n * lit-html, since this module re-exports all of lit-html.\n *\n * @private\n */\nexport const _$LE = {\n _$attributeToProperty: (\n el: LitElement,\n name: string,\n value: string | null\n ) => {\n // eslint-disable-next-line\n (el as any)._$attributeToProperty(name, value);\n },\n // eslint-disable-next-line\n _$changedProperties: (el: LitElement) => (el as any)._$changedProperties,\n};\n\n// IMPORTANT: do not change the property name or the assignment expression.\n// This line will be used in regexes to search for LitElement usage.\n(global.litElementVersions ??= []).push('4.2.1');\nif (DEV_MODE && global.litElementVersions.length > 1) {\n queueMicrotask(() => {\n issueWarning!(\n 'multiple-versions',\n `Multiple versions of Lit loaded. Loading multiple versions ` +\n `is not recommended.`\n );\n });\n}\n", "// ds-button.ts\n// Core button component\nimport { LitElement, html, css } from \"lit\";\nimport { getText } from \"../0-face/i18n\";\nexport class Button extends LitElement {\n constructor() {\n super();\n this._handleLanguageChange = () => {\n this._updateText();\n };\n this.variant = \"title\";\n this.disabled = false;\n this.bold = false;\n this[\"no-background\"] = false;\n this.blank = false;\n this.notionKey = null;\n this.key = \"\";\n this.fallback = \"\";\n this.language = \"en-US\";\n this.defaultText = \"\";\n this.href = \"\";\n this._loading = false;\n this._notionText = null;\n }\n connectedCallback() {\n super.connectedCallback();\n this._updateText();\n // Listen for language changes\n window.addEventListener(\"language-changed\", this._handleLanguageChange);\n }\n disconnectedCallback() {\n super.disconnectedCallback();\n window.removeEventListener(\"language-changed\", this._handleLanguageChange);\n }\n updated(changedProps) {\n super.updated(changedProps);\n if (changedProps.has(\"key\") || changedProps.has(\"defaultText\")) {\n this._updateText();\n }\n }\n /**\n * Update text from translations (synchronous like Portfolio)\n */\n _updateText() {\n if (this.key) {\n this._notionText = getText(this.key);\n }\n else {\n this._notionText = this.defaultText || this.fallback || null;\n }\n this.requestUpdate();\n }\n render() {\n return html `\n <button\n class=${this.variant}\n ?disabled=${this.disabled}\n ?bold=${this.bold}\n ?no-background=${this[\"no-background\"]}\n @click=${this._handleClick}\n >\n ${this._notionText ? this._notionText : html `<slot></slot>`}\n </button>\n `;\n }\n _handleClick(e) {\n // Prevent any action if disabled and stop event propagation\n if (this.disabled) {\n e.preventDefault();\n e.stopPropagation();\n return;\n }\n // If href is provided, navigate to the URL and do not bubble further\n if (this.href) {\n e.preventDefault();\n e.stopPropagation();\n if (this.blank) {\n window.open(this.href, \"_blank\", \"noopener,noreferrer\");\n }\n else {\n window.location.href = this.href;\n }\n return;\n }\n // Otherwise, rely on the native 'click' event bubbling from the inner\n // <button> through the shadow boundary to consumers of <ds-button>.\n // Do not re-dispatch a synthetic 'click' here to avoid duplicate events.\n }\n}\nButton.properties = {\n variant: { type: String, reflect: true },\n disabled: { type: Boolean, reflect: true },\n bold: { type: Boolean, reflect: true },\n \"no-background\": {\n type: Boolean,\n reflect: true,\n attribute: \"no-background\",\n },\n blank: { type: Boolean, reflect: true },\n notionKey: { type: String, attribute: \"notion-key\" },\n key: { type: String },\n fallback: { type: String },\n language: { type: String },\n defaultText: { type: String, attribute: \"default-text\" },\n href: { type: String },\n _loading: { type: Boolean, state: true },\n _notionText: { type: String, state: true },\n};\nButton.styles = css `\n button {\n max-height: calc(var(--08) * var(--scaling-factor));\n border: none;\n cursor: pointer;\n font-size: calc(var(--type-size-default) * var(--scaling-factor));\n padding: 0 calc(1px * var(--scaling-factor));\n color: var(--button-text-color);\n font-family: var(--typeface);\n }\n\n button.title {\n background-color: var(--button-background-color-secondary);\n color: var(--button-text-color);\n }\n\n button.primary {\n background-color: var(--accent-color);\n color: var(--button-text-color);\n text-decoration-line: none;\n font-family: var(--typeface);\n }\n\n button.secondary {\n background-color: var(--button-background-color-secondary);\n color: var(--button-text-color);\n font-family: var(--typeface);\n }\n\n button[bold] {\n font-weight: var(--type-weight-bold);\n font-family: var(--typeface-medium);\n }\n\n button[no-background] {\n background-color: transparent;\n max-height: var(--1);\n padding: 0;\n color: var(--button-color, var(--button-text-color-secondary));\n }\n\n button[no-background][bold] {\n font-weight: var(--type-weight-bold);\n font-family: var(--typeface-medium);\n color: var(--button-color, var(--button-text-color-secondary));\n }\n\n .loading {\n opacity: 0.7;\n }\n `;\ncustomElements.define(\"ds-button\", Button);\n", "/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {nothing, TemplateResult, noChange} from '../lit-html.js';\nimport {directive, Directive, PartInfo, PartType} from '../directive.js';\n\nconst HTML_RESULT = 1;\n\nexport class UnsafeHTMLDirective extends Directive {\n static directiveName = 'unsafeHTML';\n static resultType = HTML_RESULT;\n\n private _value: unknown = nothing;\n private _templateResult?: TemplateResult;\n\n constructor(partInfo: PartInfo) {\n super(partInfo);\n if (partInfo.type !== PartType.CHILD) {\n throw new Error(\n `${\n (this.constructor as typeof UnsafeHTMLDirective).directiveName\n }() can only be used in child bindings`\n );\n }\n }\n\n render(value: string | typeof nothing | typeof noChange | undefined | null) {\n if (value === nothing || value == null) {\n this._templateResult = undefined;\n return (this._value = value);\n }\n if (value === noChange) {\n return value;\n }\n if (typeof value != 'string') {\n throw new Error(\n `${\n (this.constructor as typeof UnsafeHTMLDirective).directiveName\n }() called with a non-string value`\n );\n }\n if (value === this._value) {\n return this._templateResult;\n }\n this._value = value;\n const strings = [value] as unknown as TemplateStringsArray;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (strings as any).raw = strings;\n // WARNING: impersonating a TemplateResult like this is extremely\n // dangerous. Third-party directives should not do this.\n return (this._templateResult = {\n // Cast to a known set of integers that satisfy ResultType so that we\n // don't have to export ResultType and possibly encourage this pattern.\n // This property needs to remain unminified.\n ['_$litType$']: (this.constructor as typeof UnsafeHTMLDirective)\n .resultType as 1 | 2,\n strings,\n values: [],\n });\n }\n}\n\n/**\n * Renders the result as HTML, rather than text.\n *\n * The values `undefined`, `null`, and `nothing`, will all result in no content\n * (empty string) being rendered.\n *\n * Note, this is unsafe to use with any user-provided input that hasn't been\n * sanitized or escaped, as it may lead to cross-site-scripting\n * vulnerabilities.\n */\nexport const unsafeHTML = directive(UnsafeHTMLDirective);\n", "import { LitElement, html, css } from \"lit\";\nimport { unsafeHTML } from \"lit/directives/unsafe-html.js\";\nexport class Icon extends LitElement {\n get type() {\n return this._type;\n }\n set type(val) {\n const oldVal = this._type;\n this._type = val;\n this.requestUpdate(\"type\", oldVal);\n }\n constructor() {\n super();\n this._type = \"\";\n this.size = \"1em\";\n this.color = \"currentColor\";\n this.background = \"transparent\";\n console.log(\"Icon constructor\", this._type);\n }\n connectedCallback() {\n super.connectedCallback();\n console.log(\"Icon connected\", this._type);\n }\n renderIcon() {\n console.log(\"renderIcon called with type:\", this._type);\n if (!this._type || this._type === \"\") {\n console.log(\"No type specified, rendering default slot\");\n return html `<div class=\"icon-container\"><slot></slot></div>`;\n }\n // First, try to render an SVG whose file name matches `type`\n const svgFromSet = Icon.iconNameToSvgMap[this._type.toLowerCase()];\n if (svgFromSet) {\n return html `<div class=\"icon-container\">${unsafeHTML(svgFromSet)}</div>`;\n }\n switch (this._type.toLowerCase()) {\n case \"close\":\n console.log(\"Rendering close icon\");\n return html `\n <div class=\"icon-container\">\n <svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n d=\"M18.3 5.71a.996.996 0 00-1.41 0L12 10.59 7.11 5.7A.996.996 0 105.7 7.11L10.59 12 5.7 16.89a.996.996 0 101.41 1.41L12 13.41l4.89 4.89a.996.996 0 101.41-1.41L13.41 12l4.89-4.89c.38-.38.38-1.02 0-1.4z\"\n />\n </svg>\n </div>\n `;\n case \"page\":\n console.log(\"Rendering page icon\");\n return html `\n <div class=\"icon-container\">\n <svg viewBox=\"0 0 17 17\" xmlns=\"http://www.w3.org/2000/svg\">\n <rect\n width=\"16\"\n height=\"16\"\n transform=\"translate(0.799988 0.678772)\"\n fill=\"var(--accent-color)\"\n />\n <path\n d=\"M13.7956 2.38385V14.9737H3.80438V2.38385H13.7956ZM4.7243 14.0538H12.8757V3.30377H4.7243V14.0538ZM8.67841 8.53619V9.45612H5.92938V8.53619H8.67841ZM10.8259 6.60455V7.52448H5.92938V6.60455H10.8259ZM10.8259 4.67194V5.59283H5.92938V4.67194H10.8259Z\"\n fill=\"#2A2A2A\"\n />\n </svg>\n </div>\n `;\n case \"note\":\n console.log(\"Rendering note icon\");\n return html `\n <div class=\"icon-container\">\n <svg viewBox=\"0 0 17 17\" xmlns=\"http://www.w3.org/2000/svg\">\n <rect\n width=\"16\"\n height=\"16\"\n transform=\"translate(0.799988 0.678772)\"\n fill=\"var(--accent-color, #CCFF4D)\"\n />\n <path\n d=\"M14.7653 3.99225V13.3653H2.83466V3.99225H14.7653ZM3.83466 12.3653H13.7653V4.99225H3.83466V12.3653Z\"\n fill=\"#2A2A2A\"\n />\n <path\n d=\"M8.8064 7.75881V8.67873H4.51343V7.75881H8.8064ZM10.7527 5.75881V6.67873H4.51343V5.75881H10.7527Z\"\n fill=\"#2A2A2A\"\n />\n </svg>\n </div>\n `;\n case \"default\":\n console.log(\"Rendering default icon\");\n return html `\n <div class=\"icon-container\">\n <svg\n width=\"17\"\n height=\"16\"\n viewBox=\"0 0 17 16\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <rect\n width=\"16\"\n height=\"16\"\n transform=\"translate(0.799988)\"\n fill=\"var(--accent-color, #CCFF4D)\"\n />\n <path\n d=\"M9.95899 15V6.81H7.05999V5.77H14.093V6.81H11.194V15H9.95899Z\"\n fill=\"#2A2A2A\"\n />\n <path\n fill-rule=\"evenodd\"\n clip-rule=\"evenodd\"\n d=\"M5.89999 0V5.10001H0.799988V0H5.89999Z\"\n fill=\"#2A2A2A\"\n />\n </svg>\n </div>\n `;\n case \"big\":\n console.log(\"Rendering big icon\");\n return html `\n <div class=\"icon-container\">\n <svg\n width=\"17\"\n height=\"16\"\n viewBox=\"0 0 17 16\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <g clip-path=\"url(#clip0_3141_3351)\">\n <rect\n width=\"16\"\n height=\"16\"\n transform=\"translate(0.799988)\"\n fill=\"var(--accent-color, #CCFF4D)\"\n />\n <path\n d=\"M13.959 12.615V4.425H11.06V3.385H16.802V4.425H15.194V12.615H13.959Z\"\n fill=\"#2A2A2A\"\n />\n <path\n fill-rule=\"evenodd\"\n clip-rule=\"evenodd\"\n d=\"M9.79999 3.5V12.5H0.799988V3.5H9.79999Z\"\n fill=\"#2A2A2A\"\n />\n </g>\n <defs>\n <clipPath id=\"clip0_3141_3351\">\n <rect\n width=\"16\"\n height=\"16\"\n fill=\"white\"\n transform=\"translate(0.799988)\"\n />\n </clipPath>\n </defs>\n </svg>\n </div>\n `;\n case \"gallery\":\n console.log(\"Rendering gallery icon\");\n return html `\n <div class=\"icon-container\">\n <svg\n width=\"17\"\n height=\"16\"\n viewBox=\"0 0 17 16\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <g clip-path=\"url(#clip0_3144_2504)\">\n <rect\n width=\"16\"\n height=\"16\"\n transform=\"translate(0.799988)\"\n fill=\"var(--accent-color, #CCFF4D)\"\n />\n <path\n fill-rule=\"evenodd\"\n clip-rule=\"evenodd\"\n d=\"M0.799988 16V0H16.8L0.799988 16ZM1.50604 0.769531V1.80957H4.40546V10H5.63983V1.80957H8.53925V0.769531H1.50604Z\"\n fill=\"#2A2A2A\"\n />\n </g>\n <defs>\n <clipPath id=\"clip0_3144_2504\">\n <rect\n width=\"16\"\n height=\"16\"\n fill=\"white\"\n transform=\"translate(0.799988)\"\n />\n </clipPath>\n </defs>\n </svg>\n </div>\n `;\n case \"check\":\n console.log(\"Rendering check icon\");\n return html `\n <div class=\"icon-container\">\n <svg\n viewBox=\"0 0 17 17\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <rect\n width=\"16\"\n height=\"16\"\n transform=\"translate(0.799988 0.678772)\"\n fill=\"var(--accent-color)\"\n />\n <path\n d=\"M7.48658 11.8747L13.2431 6.12674L12.5361 5.41788L7.48845 10.4734L5.06409 8.04082L4.35706 8.73597L7.48658 11.8747Z\"\n fill=\"#2A2A2A\"\n />\n </svg>\n </div>\n `;\n default:\n console.log(`Unknown icon type: ${this._type}, rendering default slot`);\n return html `<div class=\"icon-container\"><slot></slot></div>`;\n }\n }\n updated(changedProperties) {\n console.log(\"Icon updated\", changedProperties);\n this.style.setProperty(\"--icon-size\", this.size);\n this.style.setProperty(\"--icon-color\", this.color);\n this.style.setProperty(\"--icon-background\", this.background);\n }\n render() {\n console.log(\"Icon render\", this._type);\n return this.renderIcon();\n }\n}\nIcon.properties = {\n type: { type: String, reflect: true },\n};\nIcon.styles = css `\n :host {\n display: inline-flex;\n justify-content: center;\n align-items: center;\n width: calc(16px * var(--scaling-factor));\n height: calc(16px * var(--scaling-factor));\n }\n\n svg {\n width: 100%;\n height: 100%;\n fill: var(--icon-color, currentColor);\n }\n\n path {\n fill: var(--icon-color, currentColor);\n }\n\n .icon-container {\n display: flex;\n justify-content: center;\n align-items: center;\n width: calc(16px * var(--scaling-factor));\n height: calc(16px * var(--scaling-factor));\n }\n\n /* Notes style color variable for future implementation */\n :host {\n --notes-style-color: #ffb6b9;\n }\n `;\n// Load all SVGs from `x Icon/` as raw strings at build time (Vite)\n// The keys will be the file base names (without extension), lowercased.\nIcon.iconNameToSvgMap = (() => {\n try {\n // Note: folder name contains a space, keep it exact.\n const modules = import.meta.glob(\"../x Icon/*.svg\", {\n as: \"raw\",\n eager: true,\n });\n const map = {};\n for (const [path, content] of Object.entries(modules)) {\n const fileName = path.split(\"/\").pop() ?? \"\";\n const baseName = fileName.replace(/\\.svg$/i, \"\").toLowerCase();\n if (baseName) {\n map[baseName] = content;\n }\n }\n return map;\n }\n catch (err) {\n // If not running under Vite (or during tests), gracefully degrade.\n console.warn(\"Icon: failed to glob SVGs from x Icon/; falling back only to inline switch icons.\", err);\n return {};\n }\n})();\ncustomElements.define(\"ds-icon\", Icon);\n// Add this line to help with debugging\nconsole.log(\"Icon component registered with custom elements registry\");\n", "import { LitElement, html, css } from \"lit\";\nimport { translate, currentLanguage, getAvailableLanguagesSync, getLanguageDisplayName, setLanguage, } from \"../0-face/i18n\";\nimport { currentTheme, setTheme } from \"../0-face/theme\";\nimport { savePreferences } from \"../0-face/preferences\";\nimport \"./ds-button\";\nimport \"./ds-icon\";\n// Accent color utilities\nconst saveAccentColor = (color) => {\n localStorage.setItem(\"accentColor\", color);\n};\nconst getAccentColor = () => {\n return localStorage.getItem(\"accentColor\") || \"--blue\"; // Default color if none set\n};\nconst applyAccentColor = () => {\n const color = getAccentColor();\n document.documentElement.style.setProperty(\"--accent-color\", `var(${color})`);\n};\n// Notes style medium utilities\nconst saveNotesStyleMedium = (style) => {\n localStorage.setItem(\"notesStyleMedium\", style);\n};\nconst getNotesStyleMedium = () => {\n return localStorage.getItem(\"notesStyleMedium\") || \"note\"; // Default to note\n};\n// Note behavior utilities\nconst savePageStyle = (style) => {\n localStorage.setItem(\"pageStyle\", style);\n};\nconst getPageStyle = () => {\n return localStorage.getItem(\"pageStyle\") || \"note\"; // Default to note\n};\n// App width utilities removed\n// Use a regular class with proper TypeScript type declarations and JSDoc comments\nexport class Cycle extends LitElement {\n // Define reactive properties using Lit's property system\n static get properties() {\n return {\n type: { type: String },\n values: { type: Array },\n label: { type: String },\n currentValue: { type: String, state: true }, // Make this a private state property\n translationsReady: { type: Boolean, state: true }, // Track if translations are loaded\n disabled: { type: Boolean, state: true },\n variant: { type: String },\n };\n }\n constructor() {\n super();\n // Initialize properties with default values\n this.type = \"\";\n this.values = [];\n this.label = \"\";\n this.currentValue = \"\";\n this.translationsReady = false;\n this.disabled = false;\n this.variant = \"\";\n // Bind event handlers to this instance for proper cleanup\n this.boundHandlers = {\n translationsLoaded: this.handleTranslationsLoaded.bind(this),\n languageChanged: this.handleLanguageChanged.bind(this),\n handleLanguageChanged: this.handleLanguageChanged.bind(this),\n handleThemeChanged: this.handleThemeChanged.bind(this),\n handleAccentColorChanged: this.handleAccentColorChanged.bind(this),\n handleNoteBehaviorChanged: this.handleNoteBehaviorChanged.bind(this),\n };\n }\n connectedCallback() {\n super.connectedCallback();\n // Add event listeners\n window.addEventListener(\"translations-loaded\", this.boundHandlers.translationsLoaded);\n window.addEventListener(\"language-changed\", this.boundHandlers.languageChanged);\n window.addEventListener(\"theme-changed\", this.boundHandlers.handleThemeChanged);\n window.addEventListener(\"accent-color-changed\", this.boundHandlers.handleAccentColorChanged);\n window.addEventListener(\"page-style-changed\", this.boundHandlers.handleNoteBehaviorChanged);\n // Initialize the component\n this.initializeValues();\n }\n async initializeValues() {\n if (this.type === \"language\") {\n // Dynamically get available languages from translation data\n const availableLanguages = getAvailableLanguagesSync();\n this.values = availableLanguages;\n this.currentValue = currentLanguage.value;\n // Set label\n this.label = this.getLabel();\n }\n else if (this.type === \"theme\") {\n // Set up theme cycling\n this.values = [\"light\", \"dark\"];\n // Set initial value based on current theme\n const currentThemeValue = currentTheme.get();\n this.currentValue = currentThemeValue;\n // Set label\n this.label = this.getLabel();\n }\n else if (this.type === \"accent-color\") {\n // Set up accent color cycling\n this.values = [\n \"--light-green\",\n \"--green\",\n \"--light-blue\",\n \"--blue\",\n \"--pink\",\n \"--red\",\n \"--orange\",\n \"--yellow\",\n ];\n // Set initial value based on current accent color\n const currentAccentColor = getAccentColor();\n this.currentValue = currentAccentColor;\n // Apply the accent color to ensure it's active\n applyAccentColor();\n // Set label\n this.label = this.getLabel();\n }\n else if (this.type === \"notes-style-medium\") {\n // Set up notes style medium cycling\n this.values = [\"default\", \"big\", \"gallery\"];\n // Set initial value based on current notes style medium\n const currentNotesStyle = getNotesStyleMedium();\n this.currentValue = currentNotesStyle;\n // Check if this should be disabled based on note behavior\n const currentPageStyle = getPageStyle();\n this.disabled = currentPageStyle === \"note\";\n // Set label\n this.label = this.getLabel();\n }\n else if (this.type === \"page-style\") {\n // Set up page style cycling\n this.values = [\"note\", \"page\"];\n // Set initial value based on current page style\n const currentPageStyle = getPageStyle();\n this.currentValue = currentPageStyle;\n // Set label\n this.label = this.getLabel();\n }\n else if (this.type === \"icon-only\") {\n // Set up icon-only cycling (no label)\n this.values = [\"note\", \"page\"];\n // Set initial value\n this.currentValue = this.values[0];\n // No label for icon-only type\n this.label = \"\";\n }\n // Request update to re-render with new values\n this.requestUpdate();\n }\n ensureThemeInitialized() {\n // Ensure theme is properly initialized\n const savedTheme = localStorage.getItem(\"theme\");\n if (!savedTheme) {\n const prefersDark = window.matchMedia(\"(prefers-color-scheme: dark)\").matches;\n const defaultTheme = prefersDark ? \"dark\" : \"light\";\n localStorage.setItem(\"theme\", defaultTheme);\n document.documentElement.classList.add(`${defaultTheme}-theme`);\n }\n }\n attributeChangedCallback(name, oldValue, newValue) {\n super.attributeChangedCallback(name, oldValue, newValue);\n if (name === \"type\" && oldValue !== newValue) {\n // Type changed, reinitialize values\n this.initializeValues();\n }\n }\n async setupInitialValue() {\n if (this.type === \"language\") {\n // Get current language\n const currentLang = currentLanguage.value;\n this.currentValue = currentLang;\n // Update label\n this.label = this.getLabel();\n }\n else if (this.type === \"theme\") {\n // Get current theme\n const currentThemeValue = currentTheme.get();\n this.currentValue = currentThemeValue;\n // Update label\n this.label = this.getLabel();\n }\n else if (this.type === \"accent-color\") {\n // Get current accent color\n const currentAccentColor = getAccentColor();\n this.currentValue = currentAccentColor;\n // Apply the accent color to ensure it's active\n applyAccentColor();\n // Update label\n this.label = this.getLabel();\n }\n else if (this.type === \"notes-style-medium\") {\n // Get current notes style medium\n const currentNotesStyle = getNotesStyleMedium();\n this.currentValue = currentNotesStyle;\n // Check if this should be disabled based on note behavior\n const currentPageStyle = getPageStyle();\n this.disabled = currentPageStyle === \"note\";\n // Update label\n this.label = this.getLabel();\n }\n else if (this.type === \"page-style\") {\n // Get current page style\n const currentPageStyle = getPageStyle();\n this.currentValue = currentPageStyle;\n // Update label\n this.label = this.getLabel();\n }\n else if (this.type === \"icon-only\") {\n // Get current page style for icon-only\n const currentPageStyle = getPageStyle();\n this.currentValue = currentPageStyle;\n // Update label\n this.label = \"\";\n }\n this.requestUpdate();\n }\n handleSettingsChanges() {\n // Handle any settings changes that might affect this component\n this.setupInitialValue();\n }\n disconnectedCallback() {\n super.disconnectedCallback();\n // Remove event listeners\n window.removeEventListener(\"translations-loaded\", this.boundHandlers.translationsLoaded);\n window.removeEventListener(\"language-changed\", this.boundHandlers.languageChanged);\n window.removeEventListener(\"theme-changed\", this.boundHandlers.handleThemeChanged);\n window.removeEventListener(\"accent-color-changed\", this.boundHandlers.handleAccentColorChanged);\n window.removeEventListener(\"page-style-changed\", this.boundHandlers.handleNoteBehaviorChanged);\n }\n handleButtonClick(e) {\n e.preventDefault();\n e.stopPropagation();\n // Don't handle clicks if disabled\n if (this.disabled) {\n return;\n }\n if (this.type === \"language\") {\n // Cycle through available languages\n const currentIndex = this.values.indexOf(this.currentValue);\n const nextIndex = (currentIndex + 1) % this.values.length;\n const newLanguage = this.values[nextIndex];\n // Update current value\n this.currentValue = newLanguage;\n // Set the new language with view transition like Portfolio\n if (document.startViewTransition) {\n document.startViewTransition(() => {\n setLanguage(newLanguage);\n });\n }\n else {\n setLanguage(newLanguage);\n }\n // Save preferences\n savePreferences({ language: newLanguage });\n // Dispatch language change event\n window.dispatchEvent(new CustomEvent(\"language-changed\", {\n detail: { language: newLanguage },\n }));\n }\n else if (this.type === \"theme\") {\n // Cycle through themes\n const currentIndex = this.values.indexOf(this.currentValue);\n const nextIndex = (currentIndex + 1) % this.values.length;\n const newTheme = this.values[nextIndex];\n // Update current value\n this.currentValue = newTheme;\n // Set the new theme using the shared helper\n setTheme(newTheme);\n // Save preferences\n savePreferences({ theme: newTheme });\n // Theme helper already emits the change event, so no manual dispatch here\n }\n else if (this.type === \"accent-color\") {\n // Cycle through accent colors\n const currentIndex = this.values.indexOf(this.currentValue);\n const nextIndex = (currentIndex + 1) % this.values.length;\n const newColor = this.values[nextIndex];\n // Update current value\n this.currentValue = newColor;\n // Save the new accent color\n saveAccentColor(newColor);\n // Apply the new accent color\n applyAccentColor();\n // Save preferences\n savePreferences({ accentColor: newColor });\n // Dispatch accent color change event\n window.dispatchEvent(new CustomEvent(\"accent-color-changed\", {\n detail: { color: newColor },\n }));\n }\n else if (this.type === \"notes-style-medium\") {\n // Cycle through notes style medium options\n const currentIndex = this.values.indexOf(this.currentValue);\n const nextIndex = (currentIndex + 1) % this.values.length;\n const newStyle = this.values[nextIndex];\n // Update current value\n this.currentValue = newStyle;\n // Save the new notes style medium\n saveNotesStyleMedium(newStyle);\n // Save preferences\n savePreferences({ notesStyleMedium: newStyle });\n // Dispatch notes style medium change event\n window.dispatchEvent(new CustomEvent(\"notes-style-medium-changed\", {\n detail: { style: newStyle },\n }));\n }\n else if (this.type === \"page-style\") {\n // Cycle through note behavior options\n const currentIndex = this.values.indexOf(this.currentValue);\n const nextIndex = (currentIndex + 1) % this.values.length;\n const newBehavior = this.values[nextIndex];\n // Update current value\n this.currentValue = newBehavior;\n // Save the new note behavior\n savePageStyle(newBehavior);\n // Save preferences\n savePreferences({ pageStyle: newBehavior });\n // Dispatch note behavior change event\n window.dispatchEvent(new CustomEvent(\"page-style-changed\", {\n detail: { behavior: newBehavior },\n }));\n }\n else if (this.type === \"icon-only\") {\n // Cycle through icon-only options (note/page)\n const currentIndex = this.values.indexOf(this.currentValue);\n const nextIndex = (currentIndex + 1) % this.values.length;\n const newIconOnlyValue = this.values[nextIndex];\n // Update current value\n this.currentValue = newIconOnlyValue;\n // Save the new page style\n savePageStyle(newIconOnlyValue);\n // Save preferences\n savePreferences({ pageStyle: newIconOnlyValue });\n // No label update for icon-only type\n this.label = \"\";\n // Dispatch page style change event\n window.dispatchEvent(new CustomEvent(\"page-style-changed\", {\n detail: { behavior: newIconOnlyValue },\n }));\n }\n // Update label\n this.label = this.getLabel();\n // Request update to re-render\n this.requestUpdate();\n }\n getValueDisplay(value) {\n if (this.type === \"language\") {\n return getLanguageDisplayName(value, {\n locale: currentLanguage.value,\n });\n }\n else if (this.type === \"theme\") {\n // Try to get translated theme name\n if (this.translationsReady) {\n const translatedName = translate(`themes.${value}`);\n if (translatedName && translatedName !== `themes.${value}`) {\n return translatedName;\n }\n }\n // Fall back to the theme value itself\n return value;\n }\n else if (this.type === \"accent-color\") {\n // Get color name from CSS variable\n return this.getColorName(value);\n }\n else if (this.type === \"notes-style-medium\") {\n // Return SVG icon for notes style medium\n return this.getNotesStyleIcon(value);\n }\n else if (this.type === \"page-style\") {\n // Return translated text for note behavior\n if (this.translationsReady) {\n const translatedText = translate(value === \"note\" ? \"note\" : \"page\");\n if (translatedText &&\n translatedText !== (value === \"note\" ? \"note\" : \"page\")) {\n return translatedText;\n }\n }\n return value;\n }\n else if (this.type === \"icon-only\") {\n // Return SVG icon for icon-only type (note/page icons)\n if (value === \"note\") {\n return html `<ds-icon type=\"note\"></ds-icon>`;\n }\n else if (value === \"page\") {\n return html `<ds-icon type=\"page\"></ds-icon>`;\n }\n return html `<span>${value}</span>`;\n }\n return value;\n }\n getColorName(colorVar) {\n // Map CSS variables to language keys\n const colorMap = {\n \"--red\": \"red\",\n \"--orange\": \"orange\",\n \"--yellow\": \"yellow\",\n \"--light-green\": \"lightGreen\",\n \"--green\": \"green\",\n \"--light-blue\": \"lightBlue\",\n \"--blue\": \"blue\",\n \"--pink\": \"pink\",\n };\n const languageKey = colorMap[colorVar];\n if (languageKey && this.translationsReady) {\n const translatedName = translate(languageKey);\n if (translatedName && translatedName !== languageKey) {\n return translatedName;\n }\n }\n // Fallback to simple name conversion\n return colorVar.replace(\"--\", \"\").replace(\"-\", \" \");\n }\n getNotesStyleIcon(style) {\n if (style === \"page\") {\n return html `<ds-icon type=\"page\"></ds-icon>`;\n }\n else if (style === \"note\") {\n return html `<ds-icon type=\"note\"></ds-icon>`;\n }\n else if (style === \"default\") {\n return html `<ds-icon type=\"default\"></ds-icon>`;\n }\n else if (style === \"big\") {\n return html `<ds-icon type=\"big\"></ds-icon>`;\n }\n else if (style === \"gallery\") {\n return html `<ds-icon type=\"gallery\"></ds-icon>`;\n }\n return html `<span>${style}</span>`;\n }\n getLabel() {\n if (this.type === \"language\") {\n // Try to get translated label\n if (this.translationsReady) {\n const translatedLabel = translate(\"language\");\n if (translatedLabel && translatedLabel !== \"language\") {\n return translatedLabel;\n }\n }\n // Fall back to English\n return \"Language\";\n }\n else if (this.type === \"theme\") {\n // Try to get translated label\n if (this.translationsReady) {\n const translatedLabel = translate(\"theme\");\n if (translatedLabel && translatedLabel !== \"theme\") {\n return translatedLabel;\n }\n }\n // Fall back to English\n return \"Theme\";\n }\n else if (this.type === \"accent-color\") {\n // Try to get translated label\n if (this.translationsReady) {\n const translatedLabel = translate(\"accentColor\");\n if (translatedLabel && translatedLabel !== \"accentColor\") {\n return translatedLabel;\n }\n }\n // Fall back to English\n return \"Accent Color\";\n }\n else if (this.type === \"notes-style-medium\") {\n // Try to get translated label\n if (this.translationsReady) {\n const translatedLabel = translate(\"notesStyle\");\n if (translatedLabel && translatedLabel !== \"notesStyle\") {\n return translatedLabel;\n }\n }\n // Fall back to English\n return \"Notes Style\";\n }\n else if (this.type === \"page-style\") {\n // Try to get translated label\n if (this.translationsReady) {\n const translatedLabel = translate(\"clickingItem\");\n if (translatedLabel && translatedLabel !== \"clickingItem\") {\n return translatedLabel;\n }\n }\n // Fall back to English\n return \"Clic\";\n }\n else if (this.type === \"icon-only\") {\n // No label for icon-only type\n return \"\";\n }\n return this.label;\n }\n render() {\n return html `\n <div class=\"cycle-container\">\n ${this.type !== \"icon-only\"\n ? html `<span class=\"cycle-label\">${this.label}</span>`\n : \"\"}\n <div\n style=\"display: flex; align-items: center; ${this.type === \"icon-only\"\n ? \"justify-content: center;\"\n : \"\"}\"\n >\n <ds-button\n variant=${this.variant ||\n (this.type === \"language\" || this.type === \"theme\"\n ? \"secondary\"\n : \"primary\")}\n ?disabled=${this.disabled}\n @click=${this.handleButtonClick}\n >\n ${this.type === \"notes-style-medium\" || this.type === \"icon-only\"\n ? html `<span\n style=\"display: inline-flex; align-items: center; gap: var(--025)\"\n >${this.getValueDisplay(this.currentValue)}</span\n >`\n : html `<span>${this.getValueDisplay(this.currentValue)}</span>`}\n </ds-button>\n ${this.type === \"accent-color\"\n ? html `\n <div\n class=\"color-preview\"\n style=\"background-color: var(${this.currentValue})\"\n ></div>\n `\n : \"\"}\n </div>\n </div>\n `;\n }\n async waitForTranslations() {\n return new Promise((resolve) => {\n if (this.translationsReady) {\n resolve();\n return;\n }\n const handleTranslationsLoaded = () => {\n this.translationsReady = true;\n resolve();\n };\n window.addEventListener(\"translations-loaded\", handleTranslationsLoaded, {\n once: true,\n });\n // Timeout after 5 seconds\n setTimeout(() => {\n this.translationsReady = true;\n resolve();\n }, 5000);\n });\n }\n handleTranslationsLoaded() {\n this.translationsReady = true;\n // Refresh language values if this is a language cycle\n if (this.type === \"language\") {\n const availableLanguages = getAvailableLanguagesSync();\n this.values = availableLanguages;\n }\n this.setupInitialValue();\n }\n handleLanguageChanged() {\n this.setupInitialValue();\n }\n handleThemeChanged() {\n this.setupInitialValue();\n }\n handleAccentColorChanged() {\n this.setupInitialValue();\n }\n handleNoteBehaviorChanged() {\n this.setupInitialValue();\n }\n}\nCycle.styles = css `\n .cycle-container {\n display: flex;\n justify-content: space-between;\n gap: var(--025);\n width: 100%;\n }\n\n .cycle-label {\n color: var(--text-color-primary);\n }\n `;\ncustomElements.define(\"ds-cycle\", Cycle);\n", "import { LitElement, html, css } from \"lit\";\nimport { getText } from \"../0-face/i18n\";\n/**\n * A component for displaying text from translations\n *\n * @element ds-text\n * @prop {string} key - The translation key to use\n * @prop {string} defaultValue - Default value if translation is not found\n * @prop {string} fallback - Optional fallback text if translation is not found (deprecated, use defaultValue)\n */\nexport class Text extends LitElement {\n static get properties() {\n return {\n key: { type: String, reflect: true },\n defaultValue: { type: String, reflect: true, attribute: \"default-value\" },\n fallback: { type: String, reflect: true }, // Kept for backward compatibility\n _text: { type: String, state: true },\n };\n }\n constructor() {\n super();\n this.key = \"\";\n this.defaultValue = \"\";\n this.fallback = \"\";\n this._text = \"\";\n // Create bound event handlers for proper cleanup\n this.boundHandlers = {\n languageChanged: (() => {\n console.log(\"Language changed event received in ds-text\");\n this._loadText();\n }),\n };\n }\n connectedCallback() {\n super.connectedCallback();\n this._loadText();\n // Listen for language changes\n window.addEventListener(\"language-changed\", this.boundHandlers.languageChanged);\n // Also listen for translations loaded event\n window.addEventListener(\"translations-loaded\", this.boundHandlers.languageChanged);\n // Listen for language changes via events instead of signals\n // The currentLanguage signal changes will trigger the language-changed event\n }\n disconnectedCallback() {\n super.disconnectedCallback();\n window.removeEventListener(\"language-changed\", this.boundHandlers.languageChanged);\n window.removeEventListener(\"translations-loaded\", this.boundHandlers.languageChanged);\n }\n updated(changedProperties) {\n super.updated(changedProperties);\n if (changedProperties.has(\"key\") || changedProperties.has(\"defaultValue\")) {\n this._loadText();\n }\n }\n _loadText() {\n if (!this.key) {\n this._text = this.defaultValue || this.fallback || \"\";\n return;\n }\n try {\n const text = getText(this.key);\n this._text = text || this.defaultValue || this.fallback || this.key;\n }\n catch (error) {\n console.error(\"Error loading text for key:\", this.key, error);\n this._text = this.defaultValue || this.fallback || this.key;\n }\n this.requestUpdate();\n }\n render() {\n return html `<span>${this._text || this.defaultValue || this.key}</span>`;\n }\n}\nText.styles = css `\n :host {\n display: inline;\n }\n\n .loading {\n opacity: 0.6;\n }\n `;\ncustomElements.define(\"ds-text\", Text);\n", "import { LitElement, html, css } from \"lit\";\nimport { translate, getNotionText } from \"../0-face/i18n\";\nexport class Tooltip extends LitElement {\n constructor() {\n super();\n this.key = \"\";\n this.defaultValue = \"\";\n this._text = \"\";\n this._visible = false;\n this.boundWindowHandlers = {\n languageChanged: (() => {\n this._loadText();\n }),\n translationsLoaded: (() => {\n this._loadText();\n }),\n };\n this.boundHostHandlers = {\n mouseenter: (() => {\n this._visible = true;\n this.requestUpdate();\n }),\n mouseleave: (() => {\n this._visible = false;\n this.requestUpdate();\n }),\n focusin: (() => {\n this._visible = true;\n this.requestUpdate();\n }),\n focusout: (() => {\n this._visible = false;\n this.requestUpdate();\n }),\n };\n }\n connectedCallback() {\n super.connectedCallback();\n this._loadText();\n window.addEventListener(\"language-changed\", this.boundWindowHandlers.languageChanged);\n window.addEventListener(\"translations-loaded\", this.boundWindowHandlers.translationsLoaded);\n this.addEventListener(\"mouseenter\", this.boundHostHandlers.mouseenter);\n this.addEventListener(\"mouseleave\", this.boundHostHandlers.mouseleave);\n this.addEventListener(\"focusin\", this.boundHostHandlers.focusin);\n this.addEventListener(\"focusout\", this.boundHostHandlers.focusout);\n }\n disconnectedCallback() {\n super.disconnectedCallback();\n window.removeEventListener(\"language-changed\", this.boundWindowHandlers.languageChanged);\n window.removeEventListener(\"translations-loaded\", this.boundWindowHandlers.translationsLoaded);\n this.removeEventListener(\"mouseenter\", this.boundHostHandlers.mouseenter);\n this.removeEventListener(\"mouseleave\", this.boundHostHandlers.mouseleave);\n this.removeEventListener(\"focusin\", this.boundHostHandlers.focusin);\n this.removeEventListener(\"focusout\", this.boundHostHandlers.focusout);\n }\n updated(changed) {\n if (changed.has(\"key\") || changed.has(\"defaultValue\")) {\n this._loadText();\n }\n }\n async _loadText() {\n if (!this.key) {\n this._text = this.defaultValue || \"\";\n this.requestUpdate();\n return;\n }\n try {\n const notionText = await getNotionText(this.key);\n if (notionText) {\n this._text = notionText;\n this.requestUpdate();\n return;\n }\n const t = translate(this.key);\n this._text = t && t !== this.key ? t : this.defaultValue || this.key;\n }\n catch (err) {\n console.error(\"ds-tooltip: error loading text for key\", this.key, err);\n this._text = this.defaultValue || this.key;\n }\n this.requestUpdate();\n }\n render() {\n const bubbleClasses = [\"bubble\", this._visible ? \"visible\" : \"\"].join(\" \");\n return html `\n <span class=\"slot-wrapper\"><slot></slot></span>\n ${this._text\n ? html `<div class=\"${bubbleClasses}\">${this._text}</div>`\n : null}\n `;\n }\n}\nTooltip.properties = {\n key: { type: String, reflect: true },\n defaultValue: { type: String, reflect: true, attribute: \"default-value\" },\n _text: { state: true },\n _visible: { state: true },\n};\nTooltip.styles = css `\n :host {\n position: relative;\n display: inline-block;\n }\n\n .slot-wrapper {\n display: inline-flex;\n align-items: center;\n }\n\n .bubble {\n display: flex;\n align-items: center;\n justify-content: center;\n position: absolute;\n left: 50%;\n bottom: 100%;\n transform: translate(-50%, calc(-2px * var(--scaling-factor)));\n z-index: 1000;\n pointer-events: none;\n height: calc(var(--08) * var(--scaling-factor));\n opacity: 0;\n transition:\n opacity 120ms ease,\n transform 120ms ease;\n background-color: light-dark(var(--black), var(--white));\n color: light-dark(var(--white), var(--black));\n border-radius: 0;\n font-size: var(--type-size-default);\n padding: 0px calc(1px * var(--scaling-factor));\n font-family: var(\n --typeface,\n -apple-system,\n BlinkMacSystemFont,\n \"Segoe UI\",\n Roboto,\n sans-serif\n );\n font-weight: 500;\n white-space: nowrap;\n min-width: max-content;\n }\n\n .bubble.visible {\n opacity: 1;\n }\n `;\ncustomElements.define(\"ds-tooltip\", Tooltip);\n", "import { LitElement, html, css } from \"lit\";\n/**\n * A component for displaying the current year\n *\n * @element ds-date\n */\nexport class DateComponent extends LitElement {\n render() {\n const year = new Date().getFullYear();\n return html `<span>${year}</span>`;\n }\n}\nDateComponent.styles = css `\n :host {\n display: inline;\n font-family: var(--typeface, var(--typeface-regular));\n font-size: inherit;\n color: inherit;\n }\n `;\ncustomElements.define(\"ds-date\", DateComponent);\n", "// ds-banner.ts\n// Unit component that\n// can be used to show a list of items consiting of compoentnts from core\nimport { LitElement, html, css } from \"lit\";\nexport class List extends LitElement {\n render() {\n return html `<slot></slot>`;\n }\n}\nList.styles = css `\n :host {\n display: flex;\n flex-direction: column;\n gap: 0;\n width: 100%;\n }\n `;\ncustomElements.define(\"ds-list\", List);\n", "import { LitElement, html, css } from \"lit\";\nexport class Row extends LitElement {\n constructor() {\n super();\n this.type = \"fill\";\n }\n render() {\n return html `<slot></slot>`;\n }\n}\nRow.properties = {\n type: { type: String, reflect: true },\n};\nRow.styles = css `\n :host {\n display: flex;\n align-items: end;\n width: calc(240px * var(--scaling-factor));\n }\n\n :host([type=\"fill\"]) {\n justify-content: space-between;\n height: calc(var(--1) * var(--scaling-factor));\n }\n\n :host([type=\"centered\"]) {\n justify-content: center;\n height: calc(var(--1) * var(--scaling-factor));\n gap: calc(var(--025) * var(--scaling-factor));\n }\n `;\ncustomElements.define(\"ds-row\", Row);\n", "// ds-table.ts\n// Data table component\nimport { LitElement, html, css } from \"lit\";\nexport class DsTable extends LitElement {\n constructor() {\n super();\n this.data = [];\n this.columns = [\"Product\", \"Users\", \"Retention\"];\n this.showStatus = true;\n }\n render() {\n return html `\n <div class=\"table-container\">\n <div class=\"table-header\">\n \n <div class=\"header-cell product-cell\">Product</div>\n <div class=\"header-cell users-cell\">Users</div>\n <div class=\"header-cell retention-cell\">Retention</div>\n ${this.showStatus ? html `<div class=\"header-cell\">Status</div>` : \"\"}\n </div>\n <div class=\"table-body\">\n ${this.data.map((row, rowIndex) => html `\n <div class=\"data-cell product-cell\">${row.product}</div>\n <div class=\"data-cell users-cell\">${row.users}</div>\n <div class=\"data-cell retention-cell\">${row.retention}</div>\n ${this.showStatus\n ? html `<div class=\"data-cell status-cell\">\n ${row.status || \"Pending\"}\n </div>`\n : \"\"}\n `)}\n </div>\n </div>\n `;\n }\n}\nDsTable.properties = {\n data: { type: Array },\n columns: { type: Array },\n showStatus: { type: Boolean, attribute: \"show-status\" },\n};\nDsTable.styles = css `\n :host {\n display: block;\n width: 100%;\n }\n\n .table-container {\n display: flex;\n flex-direction: column;\n width: 100%;\n }\n\n .table-header {\n display: grid;\n grid-template-columns: 160px 80px 80px 80px;\n height: 20px;\n width: 400px;\n }\n\n .table-body {\n display: grid;\n grid-template-columns: 160px 80px 80px 80px;\n border: 1px solid var(--black);\n width: 400px;\n }\n\n .header-cell {\n height: 20px;\n display: flex;\n align-items: center;\n justify-content: left;\n padding: 0 2px;\n font-family: var(--typeface);\n font-size: var(--type-size-default);\n font-weight: var(--type-weight-default);\n line-height: var(--type-lineheight-default);\n color: var(--black);\n letter-spacing: -0.26px;\n }\n\n .data-cell {\n height: 20px;\n margin-top: -1px;\n display: flex;\n align-items: center;\n justify-content: left;\n \n outline: 1px solid var(--black);\n\n font-family: var(--typeface);\n font-size: var(--type-size-default);\n font-weight: var(--type-weight-default);\n line-height: var(--type-lineheight-default);\n color: var(--black);\n letter-spacing: -0.26px;\n }\n\n .status-cell {\n background-color: var(--light-green);\n }\n\n .product-cell {\n text-align: left;\n justify-content: flex-start;\n }\n\n .users-cell,\n .retention-cell {\n text-align: center;\n }\n\n .status-cell {\n text-align: center;\n }\n\n /* Responsive adjustments */\n @media (max-width: 480px) {\n .table-header,\n .table-body {\n width: 100%;\n grid-template-columns: 1fr 60px 60px 60px;\n }\n }\n `;\ncustomElements.define(\"ds-table\", DsTable);\n", "// ds-grid.ts\n// Simple grid layout component\nimport { LitElement, html, css } from \"lit\";\nimport { detectMobileDevice } from \"../0-face/device\";\nexport class Grid extends LitElement {\n constructor() {\n super(...arguments);\n this._isMobile = false;\n }\n connectedCallback() {\n super.connectedCallback();\n this._isMobile = detectMobileDevice();\n console.log(`[ds-grid] Mobile device: ${this._isMobile}`);\n // Apply mobile class immediately\n if (this._isMobile) {\n this.classList.add(\"mobile\");\n console.log(`[ds-grid] Mobile class added`);\n }\n // Calculate mobile grid dimensions to fit screen\n if (this._isMobile && typeof window !== \"undefined\") {\n const screenWidth = window.innerWidth;\n const columns = 14;\n const gap = 0.5;\n // Calculate column size accounting for gaps between columns\n // Total width = (columns * columnSize) + ((columns - 1) * gap)\n // Therefore: columnSize = (screenWidth - ((columns - 1) * gap)) / columns\n const totalGapWidth = (columns - 1) * gap;\n const columnSize = (screenWidth - totalGapWidth) / columns;\n console.log(`[ds-grid] Mobile grid: ${columns} columns \u00D7 ${columnSize.toFixed(2)}px + ${totalGapWidth}px gaps = ${screenWidth}px`);\n // Set custom property for this grid instance\n this.style.setProperty(\"--mobile-column-size\", `${columnSize}px`);\n this.style.setProperty(\"--mobile-gap\", `${gap}px`);\n }\n }\n updated() {\n // Apply mobile class if detected as mobile device\n if (this._isMobile) {\n this.classList.add(\"mobile\");\n }\n else {\n this.classList.remove(\"mobile\");\n }\n }\n render() {\n return html ``;\n }\n}\nGrid.properties = {\n align: { type: String },\n _isMobile: { type: Boolean, state: true },\n};\nGrid.styles = css `\n :host {\n margin-top: 0.5px !important;\n margin-left: 0.5px !important;\n display: grid;\n width: 1440px;\n height: 100%;\n grid-template-columns: repeat(auto-fill, 19px);\n grid-template-rows: repeat(auto-fill, 19px);\n gap: 1px;\n row-rule: calc(1px * var(--scaling-factor)) solid\n light-dark(rgb(147, 147, 147), rgb(147, 147, 147));\n column-rule: calc(1px * var(--scaling-factor)) solid\n light-dark(rgb(147, 147, 147), rgb(147, 147, 147));\n outline:\n 1px solid light-dark(rgb(147, 147, 147)),\n rgb(147, 147, 147);\n position: fixed;\n top: 0;\n left: 50%;\n transform: translateX(-50%);\n pointer-events: none;\n z-index: 300;\n }\n\n /* DO NOT CHANGE THIS GRID CODE FOR MOBILE. ITS PERFECT FOR MOBILE. */\n :host(.mobile) {\n outline: calc(2px * var(--scaling-factor)) solid rgba(251, 255, 0, 0.9);\n width: calc(100% - calc(1px * var(--scaling-factor)));\n max-width: 100vw;\n margin-left: 0 !important;\n margin-top: 0 !important;\n box-sizing: border-box;\n position: fixed;\n top: calc(0.5px * var(--scaling-factor));\n left: 50%;\n transform: translateX(-50%);\n pointer-events: none;\n z-index: 300;\n gap: calc(1px * var(--scaling-factor));\n grid-template-columns: repeat(14, calc(19px * var(--scaling-factor)));\n grid-template-rows: repeat(auto-fill, calc(19px * var(--scaling-factor)));\n }\n\n :host([align=\"left\"]) {\n left: 0;\n transform: none;\n }\n\n :host([align=\"center\"]) {\n left: 50%;\n transform: translateX(-50%);\n }\n\n :host([align=\"right\"]) {\n left: auto;\n right: 0;\n transform: none;\n }\n `;\ncustomElements.define(\"ds-grid\", Grid);\n", "// ds-layout.ts\n// Simple grid layout component with debug mode\nimport { LitElement, html, css } from \"lit\";\nexport class Layout extends LitElement {\n render() {\n const isDebug = this.debug || this.mode === \"debug\";\n const isCompany = this.mode === \"company\";\n return html `\n <slot></slot>\n ${isDebug\n ? html `\n <div class=\"debug-overlay\">\n ${isCompany\n ? html `\n <div class=\"debug-area debug-header\">header</div>\n <div class=\"debug-area debug-content\">content</div>\n <div class=\"debug-area debug-footer\">footer</div>\n `\n : html `\n <div class=\"debug-area debug-square\">square</div>\n <div class=\"debug-area debug-title\">title</div>\n <div class=\"debug-area debug-header\">header</div>\n <div class=\"debug-area debug-projects\">projects</div>\n <div class=\"debug-area debug-bio\">bio</div>\n <div class=\"debug-area debug-nav\">nav</div>\n <div class=\"debug-area debug-footer\">footer</div>\n `}\n </div>\n `\n : \"\"}\n `;\n }\n}\nLayout.properties = {\n mode: { type: String },\n align: { type: String },\n debug: { type: Boolean },\n};\nLayout.styles = css `\n :host {\n display: grid;\n grid-template-columns: 120px 480px 40px;\n grid-template-rows: 120px 120px 60px 180px 60px 120px 60px 20px 120px 120px;\n grid-template-areas:\n \"square . .\"\n \". title .\"\n \". header .\"\n \". projects .\"\n \". . .\"\n \". bio .\"\n \". . .\"\n \". nav .\"\n \". . .\"\n \". footer .\"\n \". . .\";\n min-height: 600px;\n background-color: rgba(165, 165, 165, 0.03);\n position: relative;\n width: 100%;\n max-width: 640px;\n margin: 0 auto;\n }\n\n :host([mode=\"company\"]) {\n grid-template-columns: auto 400px auto;\n grid-template-rows: 80px 20px 20px 120px 20px 120px;\n grid-template-areas:\n \". . .\"\n \". header .\"\n \". . .\"\n \". content .\"\n \". . .\"\n \". footer .\";\n gap: 0;\n max-width: 100%;\n }\n\n :host([align=\"left\"]) {\n margin: 0;\n justify-self: start;\n }\n\n :host([align=\"center\"]) {\n margin: 0 auto;\n justify-self: center;\n }\n\n :host([align=\"right\"]) {\n margin: 0 0 0 auto;\n justify-self: end;\n }\n\n .debug-overlay {\n position: absolute;\n margin-left: -1px;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n pointer-events: none;\n z-index: 1000;\n display: grid;\n font-size: 18px;\n font-weight: bold;\n grid-template-columns: 120px 480px;\n grid-template-rows: 120px 120px 60px 180px 60px 120px 60px 20px 120px 120px;\n grid-template-areas:\n \"square .\"\n \". title\"\n \". header\"\n \". projects\"\n \". .\"\n \". bio\"\n \". .\"\n \". nav\"\n \". .\"\n \". footer\"\n \". .\";\n }\n\n :host([mode=\"company\"]) .debug-overlay {\n grid-template-columns: auto 400px auto;\n grid-template-rows: 80px 20px 20px 120px 20px 120px;\n grid-template-areas:\n \". . .\"\n \". header .\"\n \". . .\"\n \". content .\"\n \". . .\"\n \". footer .\";\n gap: 0;\n }\n\n .debug-area {\n display: flex;\n align-items: center;\n justify-content: center;\n font-size: 10px;\n font-weight: var(--type-weight-default);\n font-family: var(--typeface);\n color: var(--black);\n border: 1px solid red;\n opacity: 1;\n }\n\n .debug-square {\n grid-area: square;\n }\n\n .debug-title {\n grid-area: title;\n }\n\n .debug-header {\n grid-area: header;\n border-color: #0000ff;\n }\n\n .debug-projects {\n grid-area: projects;\n border-color: #ffff00;\n }\n\n .debug-bio {\n grid-area: bio;\n border-color: #ff00ff;\n }\n\n .debug-nav {\n grid-area: nav;\n border-color: #00ffff;\n }\n\n .debug-footer {\n grid-area: footer;\n border-color: #ffa500;\n }\n\n .debug-content {\n grid-area: content;\n border-color: rgba(71, 231, 71, 0.63);\n }\n `;\ncustomElements.define(\"ds-layout\", Layout);\n"],
5
+ "mappings": "AAMO,SAASA,IAAqB,CACjC,GAAI,OAAO,UAAc,KAAe,OAAO,OAAW,IACtD,MAAO,GAEX,IAAMC,EAAM,UACNC,EAAM,OACNC,EAAMF,IAAQA,EAAI,WAAaA,EAAI,SAAaC,GAAOA,EAAI,OAAU,GAErEE,EAAkB,qIAAqI,KAAKD,CAAE,EAG9JE,GADeJ,GAAOA,EAAI,gBAAmB,GACd,EAE/BK,EAAiBJ,EACjB,KAAK,IAAIA,EAAI,YAAc,EAAGA,EAAI,aAAe,CAAC,GAAK,IACvD,GACN,OAAOE,GAAoBC,GAAkBC,CACjD,CAIO,SAASC,IAAgB,CAC5B,IAAMC,EAAWR,GAAmB,EAC9BC,EAAM,UACNC,EAAM,OAENG,GADeJ,GAAOA,EAAI,gBAAmB,GACd,EAE/BQ,EAAc,OAAO,SAAa,IAClC,SAAS,gBAAgB,YACzBP,GAAK,YAAc,EACnBQ,EAAe,OAAO,SAAa,IACnC,SAAS,gBAAgB,aACzBR,GAAK,aAAe,EACpBS,EAAWH,GAAY,KAAK,IAAIC,EAAaC,CAAY,GAAK,IACpE,MAAO,CACH,SAAAF,EACA,SAAAG,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AAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAiJhB,eAAe,OAAO,YAAaD,EAAM",
6
6
  "names": ["detectMobileDevice", "nav", "win", "ua", "uaMatchesMobile", "isTouchCapable", "narrowViewport", "getDeviceInfo", "isMobile", "screenWidth", "screenHeight", "isTablet", "initDeviceDetection", "deviceInfo", "scalingFactor", "resizeTimeout", "translationKeys", "LANGUAGE_PRIORITY_ORDER", "LANGUAGE_PRIORITY_LOOKUP", "code", "index", "FALLBACK_LANGUAGE_NAMES", "DISPLAY_NAME_CACHE", "displayNameFallbackWarningShown", "DEFAULT_TRANSLATION_FILE", "loadAttempted", "normalizeCandidate", "path", "trimmed", "findAttributeCandidate", "scriptCandidate", "metaCandidate", "linkCandidate", "resolveTranslationSources", "candidates", "windowCandidate", "attributeCandidate", "windowNormalized", "attrNormalized", "validateTranslationMap", "candidate", "entry", "fetchTranslationFile", "source", "response", "translations", "loadExternalTranslations", "sources", "languages", "getTranslationData", "translationData", "notionStore", "defaultLanguage", "extractPrimarySubtag", "getLanguagePriority", "primary", "priority", "sortLanguageCodes", "codes", "a", "b", "priorityA", "priorityB", "getDisplayNameForLocale", "locale", "normalizedLocale", "displayNames", "cleanedCode", "fullMatch", "baseMatch", "getFallbackDisplayName", "normalized", "direct", "getLanguageDisplayName", "options", "localesToTry", "tried", "displayName", "fallback", "BROWSER_LANGUAGE_PREFERENCES", "resolvePreferredLanguage", "languageTag", "directMatch", "primaryMatch", "getBrowserLanguage", "browserLang", "resolved", "storedLanguage", "currentLanguage", "lang", "currentLang", "translate", "key", "hasTranslation", "language", "langData", "getText", "getNotionText", "text", "setNotionText", "value", "getLanguageBucket", "getAvailableLanguages", "currentData", "getAvailableLanguagesSync", "loadTranslations", "setLanguage", "savePreferences", "preferences", "raw", "next", "error", "PRICE_LABELS", "getPriceLabel", "options", "language", "country", "countryUpper", "primaryLang", "__defProp", "__defNormalProp", "obj", "key", "value", "__publicField", "__accessCheck", "member", "msg", "__privateIn", "__privateAdd", "__privateMethod", "method", "defaultEquals", "a", "b", "activeConsumer", "inNotificationPhase", "epoch", "SIGNAL", "setActiveConsumer", "consumer", "prev", "getActiveConsumer", "isInNotificationPhase", "REACTIVE_NODE", "producerAccessed", "node", "idx", "assertConsumerNode", "consumerIsLive", "staleProducer", "producerRemoveLiveConsumerAtIndex", "producerAddLiveConsumer", "producerIncrementEpoch", "producerUpdateValueVersion", "consumerPollProducersForChange", "producerNotifyConsumers", "consumerMarkDirty", "producerUpdatesAllowed", "_a", "consumerBeforeComputation", "consumerAfterComputation", "prevConsumer", "i", "producer", "seenVersion", "indexOfThis", "assertProducerNode", "lastIdx", "idxProducer", "computedGet", "ERRORED", "createComputed", "computation", "COMPUTED_NODE", "computed", "UNSET", "COMPUTING", "oldValue", "newValue", "wasEqual", "err", "defaultThrowError", "throwInvalidWriteToSignalErrorFn", "throwInvalidWriteToSignalError", "createSignal", "initialValue", "SIGNAL_NODE", "getter", "signalGetFn", "signalSetFn", "signalValueChanged", "NODE", "Signal", "Signal2", "_brand", "brand_fn", "_b", "_brand2", "brand_fn2", "State", "options", "equals", "ref", "s", "Computed", "c", "subtle2", "_a2", "_brand3", "brand_fn3", "_assertSignals", "assertSignals_fn", "untrack", "cb", "output", "prevActiveConsumer", "introspectSources", "sink", "_a3", "n", "introspectSinks", "signal", "hasSinks", "liveConsumerNode", "hasSources", "producerNode", "Watcher", "notify", "signals", "idxConsumer", "w", "currentComputed", "signalWatcherBrand", "Symbol", "elementFinalizationRegistry", "FinalizationRegistry", "watcher", "signal", "unwatch", "PartType", "ATTRIBUTE", "CHILD", "PROPERTY", "BOOLEAN_ATTRIBUTE", "EVENT", "ELEMENT", "directive", "c", "values", "_$litDirective$", "Directive", "_partInfo", "_$isConnected", "this", "_$parent", "part", "parent", "attributeIndex", "__part", "__attributeIndex", "props", "update", "_part", "render", "global", "globalThis", "trustedTypes", "policy", "createPolicy", "createHTML", "s", "boundAttributeSuffix", "marker", "Math", "random", "toFixed", "slice", "markerMatch", "nodeMarker", "d", "document", "createMarker", "createComment", "isPrimitive", "value", "isArray", "Array", "isIterable", "Symbol", "iterator", "SPACE_CHAR", "textEndRegex", "commentEndRegex", "comment2EndRegex", "tagEndRegex", "RegExp", "singleQuoteAttrEndRegex", "doubleQuoteAttrEndRegex", "rawTextElement", "tag", "type", "strings", "values", "_$litType$", "html", "svg", "mathml", "noChange", "for", "nothing", "templateCache", "WeakMap", "walker", "createTreeWalker", "trustFromTemplateString", "tsa", "stringFromTSA", "hasOwnProperty", "Error", "getTemplateHtml", "l", "length", "attrNames", "rawTextEndRegex", "regex", "i", "attrName", "match", "attrNameEndIndex", "lastIndex", "exec", "test", "end", "startsWith", "push", "Template", "constructor", "options", "node", "this", "parts", "nodeIndex", "attrNameIndex", "partCount", "el", "createElement", "currentNode", "content", "wrapper", "firstChild", "replaceWith", "childNodes", "nextNode", "nodeType", "hasAttributes", "name", "getAttributeNames", "endsWith", "realName", "statics", "getAttribute", "split", "m", "index", "ctor", "PropertyPart", "BooleanAttributePart", "EventPart", "AttributePart", "removeAttribute", "tagName", "textContent", "emptyScript", "append", "data", "indexOf", "_options", "innerHTML", "resolveDirective", "part", "parent", "attributeIndex", "currentDirective", "__directives", "__directive", "nextDirectiveConstructor", "_$initialize", "_$resolve", "TemplateInstance", "template", "_$parts", "_$disconnectableChildren", "_$template", "_$parent", "parentNode", "_$isConnected", "fragment", "creationScope", "importNode", "partIndex", "templatePart", "ChildPart", "nextSibling", "ElementPart", "_$setValue", "__isConnected", "startNode", "endNode", "_$committedValue", "_$startNode", "_$endNode", "isConnected", "directiveParent", "_$clear", "_commitText", "_commitTemplateResult", "_commitNode", "_commitIterable", "insertBefore", "_insert", "createTextNode", "result", "_$getTemplate", "h", "_update", "instance", "_clone", "get", "set", "itemParts", "itemPart", "item", "start", "from", "_$notifyConnectionChanged", "n", "remove", "element", "fill", "String", "valueIndex", "noCommit", "change", "v", "_commitValue", "setAttribute", "toggleAttribute", "super", "newListener", "oldListener", "shouldRemoveListener", "capture", "once", "passive", "shouldAddListener", "removeEventListener", "addEventListener", "event", "call", "host", "handleEvent", "_$LH", "_boundAttributeSuffix", "_marker", "_markerMatch", "_HTML_RESULT", "_getTemplateHtml", "_TemplateInstance", "_isIterable", "_resolveDirective", "_ChildPart", "_AttributePart", "_BooleanAttributePart", "_EventPart", "_PropertyPart", "_ElementPart", "polyfillSupport", "litHtmlPolyfillSupport", "litHtmlVersions", "render", "container", "partOwnerNode", "renderBefore", "_ChildPart", "ChildPart", "_$LH", "isSingleExpression", "part", "strings", "notifyChildrenConnectedChanged", "parent", "isConnected", "children", "_$disconnectableChildren", "obj", "removeDisconnectableFromParent", "_$parent", "delete", "size", "addDisconnectableToParent", "Set", "has", "add", "installDisconnectAPI", "reparentDisconnectables", "newParent", "this", "notifyChildPartConnectedChanged", "isClearingValue", "fromPartIndex", "value", "_$committedValue", "Array", "isArray", "i", "length", "type", "PartType", "CHILD", "_$notifyConnectionChanged", "_$reparentDisconnectables", "AsyncDirective", "Directive", "constructor", "part", "attributeIndex", "super", "_$initialize", "_$isConnected", "isClearingDirective", "reconnected", "disconnected", "isSingleExpression", "__part", "_$setValue", "newValues", "__attributeIndex", "WatchDirective", "AsyncDirective", "__watch", "this", "__watcher", "__computed", "Signal", "Computed", "i", "__signal", "_a", "get", "watcher", "subtle", "Watcher", "t", "__host", "_updateWatchDirective", "watch", "__unwatch", "unwatch", "_clearWatchDirective", "commit", "setValue", "untrack", "signal", "part", "_b", "options", "host", "disconnected", "reconnected", "directive", "withWatch", "coreTag", "strings", "values", "map", "v", "Signal", "State", "Computed", "watch", "html", "coreHtml", "svg", "coreSvg", "State", "Signal", "Computed", "signal", "value", "options", "getInitialTheme", "storedTheme", "currentTheme", "r", "setTheme", "theme", "error", "root", "global", "globalThis", "supportsAdoptingStyleSheets", "ShadowRoot", "ShadyCSS", "nativeShadow", "Document", "prototype", "CSSStyleSheet", "constructionToken", "Symbol", "cssTagCache", "WeakMap", "CSSResult", "cssText", "strings", "safeToken", "this", "Error", "_strings", "styleSheet", "_styleSheet", "cacheable", "length", "get", "replaceSync", "set", "toString", "unsafeCSS", "value", "String", "css", "values", "reduce", "acc", "v", "idx", "adoptStyles", "renderRoot", "styles", "adoptedStyleSheets", "map", "s", "style", "document", "createElement", "nonce", "setAttribute", "textContent", "appendChild", "getCompatibleStyle", "sheet", "rule", "cssRules", "is", "defineProperty", "getOwnPropertyDescriptor", "getOwnPropertyNames", "getOwnPropertySymbols", "getPrototypeOf", "Object", "global", "globalThis", "trustedTypes", "emptyStringForBooleanAttribute", "emptyScript", "polyfillSupport", "reactiveElementPolyfillSupport", "JSCompiler_renameProperty", "prop", "_obj", "defaultConverter", "value", "type", "Boolean", "Array", "JSON", "stringify", "fromValue", "Number", "parse", "e", "notEqual", "old", "defaultPropertyDeclaration", "attribute", "String", "converter", "reflect", "useDefault", "hasChanged", "Symbol", "metadata", "litPropertyMetadata", "WeakMap", "ReactiveElement", "HTMLElement", "initializer", "this", "__prepare", "_initializers", "push", "observedAttributes", "finalize", "__attributeToPropertyMap", "keys", "name", "options", "state", "prototype", "hasOwnProperty", "create", "wrapped", "elementProperties", "set", "noAccessor", "key", "descriptor", "getPropertyDescriptor", "get", "v", "oldValue", "call", "requestUpdate", "configurable", "enumerable", "superCtor", "Map", "finalized", "props", "properties", "propKeys", "p", "createProperty", "attr", "__attributeNameForProperty", "elementStyles", "finalizeStyles", "styles", "isArray", "Set", "flat", "Infinity", "reverse", "s", "unshift", "getCompatibleStyle", "toLowerCase", "constructor", "super", "__instanceProperties", "isUpdatePending", "hasUpdated", "__reflectingProperty", "__initialize", "__updatePromise", "Promise", "res", "enableUpdating", "_$changedProperties", "__saveInstanceProperties", "forEach", "i", "controller", "__controllers", "add", "renderRoot", "isConnected", "hostConnected", "delete", "instanceProperties", "size", "createRenderRoot", "shadowRoot", "attachShadow", "shadowRootOptions", "adoptStyles", "connectedCallback", "c", "_requestedUpdate", "disconnectedCallback", "hostDisconnected", "_old", "_$attributeToProperty", "attrValue", "toAttribute", "removeAttribute", "setAttribute", "ctor", "propName", "getPropertyOptions", "fromAttribute", "convertedValue", "__defaultValues", "newValue", "hasAttribute", "_$changeProperty", "__enqueueUpdate", "initializeValue", "has", "__reflectingProperties", "reject", "result", "scheduleUpdate", "performUpdate", "shouldUpdate", "changedProperties", "willUpdate", "hostUpdate", "update", "__markUpdated", "_$didUpdate", "_changedProperties", "hostUpdated", "firstUpdated", "updated", "updateComplete", "getUpdateComplete", "__propertyToAttribute", "mode", "reactiveElementVersions", "global", "globalThis", "LitElement", "ReactiveElement", "constructor", "this", "renderOptions", "host", "__childPart", "createRenderRoot", "renderRoot", "super", "renderBefore", "firstChild", "changedProperties", "value", "render", "hasUpdated", "isConnected", "update", "connectedCallback", "setConnected", "disconnectedCallback", "noChange", "litElementHydrateSupport", "polyfillSupport", "litElementPolyfillSupport", "global", "litElementVersions", "push", "Button", "i", "changedProps", "getText", "x", "UnsafeHTMLDirective", "Directive", "partInfo", "super", "this", "_value", "nothing", "type", "PartType", "CHILD", "Error", "constructor", "directiveName", "value", "_templateResult", "noChange", "strings", "raw", "_$litType$", "resultType", "values", "unsafeHTML", "directive", "Icon", "_Icon", "i", "val", "oldVal", "x", "svgFromSet", "o", "changedProperties", "modules", "map", "path", "content", "baseName", "err", "saveAccentColor", "color", "getAccentColor", "applyAccentColor", "saveNotesStyleMedium", "style", "getNotesStyleMedium", "savePageStyle", "getPageStyle", "Cycle", "i", "availableLanguages", "getAvailableLanguagesSync", "currentLanguage", "currentThemeValue", "currentTheme", "currentAccentColor", "currentNotesStyle", "currentPageStyle", "defaultTheme", "name", "oldValue", "newValue", "currentLang", "nextIndex", "newLanguage", "setLanguage", "savePreferences", "newTheme", "setTheme", "newColor", "newStyle", "newBehavior", "newIconOnlyValue", "value", "getLanguageDisplayName", "translatedName", "translate", "translatedText", "x", "colorVar", "languageKey", "translatedLabel", "resolve", "handleTranslationsLoaded", "Text", "i", "changedProperties", "text", "getText", "error", "x", "Tooltip", "i", "changed", "notionText", "getNotionText", "t", "translate", "err", "bubbleClasses", "x", "DateComponent", "i", "year", "x", "List", "i", "x", "Row", "i", "x", "DsTable", "i", "x", "row", "rowIndex", "Grid", "i", "detectMobileDevice", "screenWidth", "columns", "gap", "totalGapWidth", "columnSize", "x", "Layout", "i", "isDebug", "isCompany", "x"]
7
7
  }