{
  "version": 3,
  "sources": ["../../src/document/components/chrome/localization/includedLocales.ts", "../../src/utils/getFirstObjectEntry.ts"],
  "sourcesContent": ["import type { VekterEngine } from \"document/VekterEngine.ts\"\nimport type { CanvasTree } from \"document/models/CanvasTree/index.ts\"\nimport type { CanvasNode } from \"document/models/CanvasTree/nodes/CanvasNode.ts\"\nimport type { IncludedLocales, WithLocaleConfig } from \"document/models/CanvasTree/traits/WithLocaleConfig.ts\"\nimport { withLocaleConfig } from \"document/models/CanvasTree/traits/WithLocaleConfig.ts\"\nimport type { LocaleId } from \"document/models/CanvasTree/traits/WithLocales.ts\"\nimport { defaultLocaleId } from \"document/models/CanvasTree/traits/WithLocales.ts\"\nimport { isShallowSetEqual } from \"utils/isShallowEqual.ts\"\nimport { isArray } from \"utils/typeChecks.ts\"\n\n/**\n * Toggle the locale visibility of a node.\n */\nexport function toggleLocaleInclusion(engine: VekterEngine, node: CanvasNode & WithLocaleConfig, localeId: LocaleId) {\n\tengine.scheduler.process(() => {\n\t\tconst nonDefaultLocaleIds = engine.tree.root.locales?.map(locale => locale.id) ?? []\n\t\tconst allLocaleIds = new Set([defaultLocaleId, ...nonDefaultLocaleIds])\n\t\tconst mutableIncludedLocaleIds = new Set(node.includedLocales ?? allLocaleIds)\n\n\t\tconst shouldExclude = mutableIncludedLocaleIds.has(localeId)\n\n\t\tif (shouldExclude) {\n\t\t\tmutableIncludedLocaleIds.delete(localeId)\n\t\t} else {\n\t\t\tmutableIncludedLocaleIds.add(localeId)\n\t\t}\n\n\t\tif (isShallowSetEqual(allLocaleIds, mutableIncludedLocaleIds)) {\n\t\t\tnode.set({ includedLocales: undefined })\n\t\t} else {\n\t\t\tnode.set({ includedLocales: Array.from(mutableIncludedLocaleIds) })\n\t\t}\n\n\t\t// By removing the group from the expanded state overrides it uses the default collapsed\n\t\t// state which depend on whether the group is excluded in the active locale.\n\t\tconst expandedSourceGroups = new Map(engine.stores.localizationStore.expandedSourceGroups)\n\t\texpandedSourceGroups.delete(node.id)\n\t\tengine.stores.localizationStore.expandedSourceGroups = expandedSourceGroups\n\t})\n}\n\n/**\n * Get the IDs of the locales the node is visible in.\n *\n * Using this helper ensures the base language locale's ID is always included.\n * This is because it should not be possible to hide a node in the base\n * language.\n */\nexport function getIncludedLocales(tree: CanvasTree, node: CanvasNode | null | undefined): IncludedLocales {\n\tif (!withLocaleConfig(tree, node)) return\n\n\t// TODO: When `defaultLocaleOverride` support is added, modify this check\n\t// to ensure the default locale or override is always included.\n\tif (node.includedLocales && !node.includedLocales.includes(defaultLocaleId)) {\n\t\treturn [defaultLocaleId, ...node.includedLocales]\n\t}\n\n\treturn node.includedLocales\n}\n\n/**\n * Returns `true` if the node is visible in a given locale.\n */\nexport function isIncludedInLocale(tree: CanvasTree, node: CanvasNode, localeId: LocaleId): boolean {\n\tconst includedLocales = getIncludedLocales(tree, node)\n\tif (!isArray(includedLocales)) return true\n\n\treturn includedLocales.includes(localeId)\n}\n", "/** Returns the first entry of the object. */\nexport function getFirstObjectEntry<T extends Record<string, unknown>>(object: T): [keyof T, T[keyof T]] | undefined {\n\tfor (const key in object) {\n\t\treturn [key, object[key]]\n\t}\n\treturn undefined\n}\n"],
  "mappings": ";;;;;;;;;;;;;;AAaO,SAAS,sBAAsB,QAAsB,MAAqC,UAAoB;AACpH,SAAO,UAAU,QAAQ,MAAM;AAC9B,UAAM,sBAAsB,OAAO,KAAK,KAAK,SAAS,IAAI,YAAU,OAAO,EAAE,KAAK,CAAC;AACnF,UAAM,eAAe,oBAAI,IAAI,CAAC,iBAAiB,GAAG,mBAAmB,CAAC;AACtE,UAAM,2BAA2B,IAAI,IAAI,KAAK,mBAAmB,YAAY;AAE7E,UAAM,gBAAgB,yBAAyB,IAAI,QAAQ;AAE3D,QAAI,eAAe;AAClB,+BAAyB,OAAO,QAAQ;AAAA,IACzC,OAAO;AACN,+BAAyB,IAAI,QAAQ;AAAA,IACtC;AAEA,QAAI,kBAAkB,cAAc,wBAAwB,GAAG;AAC9D,WAAK,I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