@carbonenginejs/runtime-resource 0.1.0 → 0.7.0

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.
Files changed (186) hide show
  1. package/FORMAT-PROVENANCE.md +14 -5
  2. package/README.md +537 -241
  3. package/dist/CjsMotherLode.js +1244 -29
  4. package/dist/CjsMotherLode.js.map +1 -1
  5. package/dist/CjsResMan.js +2537 -272
  6. package/dist/CjsResMan.js.map +1 -1
  7. package/dist/CjsResource.js +218 -18
  8. package/dist/CjsResource.js.map +1 -1
  9. package/dist/format/CjsBlueReader.js +269 -0
  10. package/dist/format/CjsBlueReader.js.map +1 -0
  11. package/dist/format/CjsFormat.js +44 -30
  12. package/dist/format/CjsFormat.js.map +1 -1
  13. package/dist/format/CjsReader.js +18 -0
  14. package/dist/format/CjsReader.js.map +1 -0
  15. package/dist/format/CjsResourceProbe.js +12 -4
  16. package/dist/format/CjsResourceProbe.js.map +1 -1
  17. package/dist/formats/black/CjsBlackFormat.js +12 -6
  18. package/dist/formats/black/CjsBlackFormat.js.map +1 -1
  19. package/dist/formats/black/core/CjsBlackReader.js +27 -148
  20. package/dist/formats/black/core/CjsBlackReader.js.map +1 -1
  21. package/dist/formats/bnk/CjsBnkFormat.js +140 -147
  22. package/dist/formats/bnk/CjsBnkFormat.js.map +1 -1
  23. package/dist/formats/bnk/core/graph.js +140 -0
  24. package/dist/formats/bnk/core/graph.js.map +1 -0
  25. package/dist/formats/bnk/core/helpers.js +58 -3
  26. package/dist/formats/bnk/core/helpers.js.map +1 -1
  27. package/dist/formats/bnk/core/musicNodes.js +521 -0
  28. package/dist/formats/bnk/core/musicNodes.js.map +1 -0
  29. package/dist/formats/bnk/index.js +0 -1
  30. package/dist/formats/bnk/index.js.map +1 -1
  31. package/dist/formats/cmf/CjsCmfFormat.js +14 -8
  32. package/dist/formats/cmf/CjsCmfFormat.js.map +1 -1
  33. package/dist/formats/dds/CjsDdsFormat.js +12 -6
  34. package/dist/formats/dds/CjsDdsFormat.js.map +1 -1
  35. package/dist/formats/fbx/CjsFbxFormat.js +12 -6
  36. package/dist/formats/fbx/CjsFbxFormat.js.map +1 -1
  37. package/dist/formats/flac/CjsFlacFormat.js +10 -4
  38. package/dist/formats/flac/CjsFlacFormat.js.map +1 -1
  39. package/dist/formats/gif/CjsGifFormat.js +11 -5
  40. package/dist/formats/gif/CjsGifFormat.js.map +1 -1
  41. package/dist/formats/gltf/CjsGltfFormat.js +12 -6
  42. package/dist/formats/gltf/CjsGltfFormat.js.map +1 -1
  43. package/dist/formats/jpeg/CjsJpegFormat.js +11 -5
  44. package/dist/formats/jpeg/CjsJpegFormat.js.map +1 -1
  45. package/dist/formats/mp3/CjsMp3Format.js +11 -5
  46. package/dist/formats/mp3/CjsMp3Format.js.map +1 -1
  47. package/dist/formats/mp4/CjsMp4Format.js +10 -4
  48. package/dist/formats/mp4/CjsMp4Format.js.map +1 -1
  49. package/dist/formats/obj/CjsObjFormat.js +12 -6
  50. package/dist/formats/obj/CjsObjFormat.js.map +1 -1
  51. package/dist/formats/ogg/CjsOggFormat.js +9 -3
  52. package/dist/formats/ogg/CjsOggFormat.js.map +1 -1
  53. package/dist/formats/png/CjsPngFormat.js +11 -5
  54. package/dist/formats/png/CjsPngFormat.js.map +1 -1
  55. package/dist/formats/red/CjsRedFormat.js +19 -5
  56. package/dist/formats/red/CjsRedFormat.js.map +1 -1
  57. package/dist/formats/red/core/CjsRedReader.js +63 -70
  58. package/dist/formats/red/core/CjsRedReader.js.map +1 -1
  59. package/dist/formats/red/core/helpers.js +3 -0
  60. package/dist/formats/red/core/helpers.js.map +1 -1
  61. package/dist/formats/stl/CjsStlFormat.js +77 -16
  62. package/dist/formats/stl/CjsStlFormat.js.map +1 -1
  63. package/dist/formats/stl/core/helpers.js +4 -0
  64. package/dist/formats/stl/core/helpers.js.map +1 -1
  65. package/dist/formats/stl/core/stl.js +100 -15
  66. package/dist/formats/stl/core/stl.js.map +1 -1
  67. package/dist/formats/tga/CjsTgaFormat.js +11 -5
  68. package/dist/formats/tga/CjsTgaFormat.js.map +1 -1
  69. package/dist/formats/wav/CjsWavFormat.js +11 -5
  70. package/dist/formats/wav/CjsWavFormat.js.map +1 -1
  71. package/dist/formats/webm/CjsWebmFormat.js +10 -4
  72. package/dist/formats/webm/CjsWebmFormat.js.map +1 -1
  73. package/dist/formats/webp/CjsWebpFormat.js +9 -3
  74. package/dist/formats/webp/CjsWebpFormat.js.map +1 -1
  75. package/dist/formats/wem/CjsWemFormat.js +50 -6
  76. package/dist/formats/wem/CjsWemFormat.js.map +1 -1
  77. package/dist/formats/wem/core/helpers.js +84 -3
  78. package/dist/formats/wem/core/helpers.js.map +1 -1
  79. package/dist/formats/wem/core/ptadpcm.js +77 -0
  80. package/dist/formats/wem/core/ptadpcm.js.map +1 -0
  81. package/dist/formats/wem/core/resolve.js +121 -0
  82. package/dist/formats/wem/core/resolve.js.map +1 -0
  83. package/dist/formats/yaml/CjsYamlFormat.js +11 -5
  84. package/dist/formats/yaml/CjsYamlFormat.js.map +1 -1
  85. package/dist/formats/yaml/core/CjsYamlReader.js +3 -2
  86. package/dist/formats/yaml/core/CjsYamlReader.js.map +1 -1
  87. package/dist/index.js +28 -32
  88. package/dist/index.js.map +1 -1
  89. package/dist/{generated/resources → resources}/AudioGeometryResData.js +2 -2
  90. package/dist/resources/AudioGeometryResData.js.map +1 -0
  91. package/dist/{generated/resources → resources}/GStateBindingCallbackData.js +2 -2
  92. package/dist/resources/GStateBindingCallbackData.js.map +1 -0
  93. package/dist/{generated/resources → resources}/MeshDecalData.js +2 -2
  94. package/dist/resources/MeshDecalData.js.map +1 -0
  95. package/dist/{generated/resources → resources}/MeshDecalLodData.js +2 -2
  96. package/dist/resources/MeshDecalLodData.js.map +1 -0
  97. package/dist/resources/Tr2GrannyIntersectionResult.js +60 -0
  98. package/dist/resources/Tr2GrannyIntersectionResult.js.map +1 -0
  99. package/dist/{generated/resources → resources}/Tr2MaterialArea.js +2 -2
  100. package/dist/resources/Tr2MaterialArea.js.map +1 -0
  101. package/dist/{generated/resources → resources}/Tr2MaterialMesh.js +2 -2
  102. package/dist/resources/Tr2MaterialMesh.js.map +1 -0
  103. package/dist/{generated/resources → resources}/Tr2MaterialRes.js +2 -2
  104. package/dist/resources/Tr2MaterialRes.js.map +1 -0
  105. package/dist/{generated/resources → resources}/Tr2ShaderPermutation.js +2 -2
  106. package/dist/resources/Tr2ShaderPermutation.js.map +1 -0
  107. package/dist/{generated/resources → resources}/Tr2TextureLodManager.js +50 -10
  108. package/dist/resources/Tr2TextureLodManager.js.map +1 -0
  109. package/dist/{generated/resources → resources}/Tr2TextureLodUpdateRequest.js +2 -2
  110. package/dist/resources/Tr2TextureLodUpdateRequest.js.map +1 -0
  111. package/dist/{generated/resources → resources}/Tr2TexturePackChannel.js +2 -2
  112. package/dist/resources/Tr2TexturePackChannel.js.map +1 -0
  113. package/dist/resources/Tr2TexturePipeline.js +68 -0
  114. package/dist/resources/Tr2TexturePipeline.js.map +1 -0
  115. package/dist/{generated/resources → resources}/Tr2TexturePipelineParams.js +2 -2
  116. package/dist/resources/Tr2TexturePipelineParams.js.map +1 -0
  117. package/dist/{generated/resources → resources}/Tr2TexturePipelineStepCompress.js +3 -3
  118. package/dist/resources/Tr2TexturePipelineStepCompress.js.map +1 -0
  119. package/dist/{generated/resources → resources}/Tr2TexturePipelineStepLimitSize.js +2 -2
  120. package/dist/resources/Tr2TexturePipelineStepLimitSize.js.map +1 -0
  121. package/dist/{generated/resources → resources}/Tr2TexturePipelineStepLoad.js +2 -2
  122. package/dist/resources/Tr2TexturePipelineStepLoad.js.map +1 -0
  123. package/dist/{generated/resources → resources}/Tr2TexturePipelineStepPack.js +3 -3
  124. package/dist/resources/Tr2TexturePipelineStepPack.js.map +1 -0
  125. package/dist/{generated/resources → resources}/TriGeometryResAreaData.js +2 -2
  126. package/dist/resources/TriGeometryResAreaData.js.map +1 -0
  127. package/dist/{generated/resources → resources}/TriGeometryResJointData.js +2 -2
  128. package/dist/resources/TriGeometryResJointData.js.map +1 -0
  129. package/dist/{generated/resources → resources}/TriGeometryResLodData.js +2 -2
  130. package/dist/resources/TriGeometryResLodData.js.map +1 -0
  131. package/dist/{generated/resources → resources}/TriGeometryResMeshData.js +2 -2
  132. package/dist/resources/TriGeometryResMeshData.js.map +1 -0
  133. package/dist/{generated/resources → resources}/TriGeometryResSkeletonData.js +2 -2
  134. package/dist/resources/TriGeometryResSkeletonData.js.map +1 -0
  135. package/dist/{generated/resources → resources}/TriJointBinding.js +2 -2
  136. package/dist/resources/TriJointBinding.js.map +1 -0
  137. package/dist/{generated/resources → resources}/TriMorphTargetGeometryConstants.js +2 -2
  138. package/dist/resources/TriMorphTargetGeometryConstants.js.map +1 -0
  139. package/dist/{generated/resources → resources}/TriRtGeometryConstants.js +2 -2
  140. package/dist/resources/TriRtGeometryConstants.js.map +1 -0
  141. package/dist/resources/enums.js.map +1 -0
  142. package/dist/resources/texturePipelineBehavior.js +320 -0
  143. package/dist/resources/texturePipelineBehavior.js.map +1 -0
  144. package/format-notices/bnk/NOTICE +7 -4
  145. package/package.json +51 -51
  146. package/resource-lifecycle.md +262 -70
  147. package/dist/generated/resources/AudioGeometryResData.js.map +0 -1
  148. package/dist/generated/resources/CmfVertexReader.js +0 -46
  149. package/dist/generated/resources/CmfVertexReader.js.map +0 -1
  150. package/dist/generated/resources/GStateBindingCallbackData.js.map +0 -1
  151. package/dist/generated/resources/MeshDecalData.js.map +0 -1
  152. package/dist/generated/resources/MeshDecalLodData.js.map +0 -1
  153. package/dist/generated/resources/Tr2AsyncSave.js +0 -46
  154. package/dist/generated/resources/Tr2AsyncSave.js.map +0 -1
  155. package/dist/generated/resources/Tr2CmfContents.js +0 -37
  156. package/dist/generated/resources/Tr2CmfContents.js.map +0 -1
  157. package/dist/generated/resources/Tr2GrannyIntersectionResult.js +0 -58
  158. package/dist/generated/resources/Tr2GrannyIntersectionResult.js.map +0 -1
  159. package/dist/generated/resources/Tr2LoadPrepareFence.js +0 -37
  160. package/dist/generated/resources/Tr2LoadPrepareFence.js.map +0 -1
  161. package/dist/generated/resources/Tr2MaterialArea.js.map +0 -1
  162. package/dist/generated/resources/Tr2MaterialMesh.js.map +0 -1
  163. package/dist/generated/resources/Tr2MaterialRes.js.map +0 -1
  164. package/dist/generated/resources/Tr2ShaderPermutation.js.map +0 -1
  165. package/dist/generated/resources/Tr2TextureLodManager.js.map +0 -1
  166. package/dist/generated/resources/Tr2TextureLodUpdateRequest.js.map +0 -1
  167. package/dist/generated/resources/Tr2TexturePackChannel.js.map +0 -1
  168. package/dist/generated/resources/Tr2TexturePipeline.js +0 -44
  169. package/dist/generated/resources/Tr2TexturePipeline.js.map +0 -1
  170. package/dist/generated/resources/Tr2TexturePipelineParams.js.map +0 -1
  171. package/dist/generated/resources/Tr2TexturePipelineStepCompress.js.map +0 -1
  172. package/dist/generated/resources/Tr2TexturePipelineStepLimitSize.js.map +0 -1
  173. package/dist/generated/resources/Tr2TexturePipelineStepLoad.js.map +0 -1
  174. package/dist/generated/resources/Tr2TexturePipelineStepPack.js.map +0 -1
  175. package/dist/generated/resources/TriGeometryResAreaData.js.map +0 -1
  176. package/dist/generated/resources/TriGeometryResJointData.js.map +0 -1
  177. package/dist/generated/resources/TriGeometryResLodData.js.map +0 -1
  178. package/dist/generated/resources/TriGeometryResMeshData.js.map +0 -1
  179. package/dist/generated/resources/TriGeometryResSkeletonData.js.map +0 -1
  180. package/dist/generated/resources/TriJointBinding.js.map +0 -1
  181. package/dist/generated/resources/TriMorphTargetGeometryConstants.js.map +0 -1
  182. package/dist/generated/resources/TriRtGeometryConstants.js.map +0 -1
  183. package/dist/generated/resources/enums.js.map +0 -1
  184. package/dist/generated/resources/index.js +0 -32
  185. package/dist/generated/resources/index.js.map +0 -1
  186. /package/dist/{generated/resources → resources}/enums.js +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"CjsMotherLode.js","sources":["../../src/CjsMotherLode.js"],"sourcesContent":["import { normalizeResourcePath } from \"./resourcePath.js\";\n\nexport class CjsMotherLode\n{\n #resources = new Map();\n\n Lookup(path, variant = \"\") {\n return this.#resources.get(GetCacheKey(path, variant)) || null;\n }\n\n Insert(resource, path = resource?.GetPath?.() ?? resource?.path, variant = \"\") {\n const key = GetCacheKey(path, variant);\n this.#resources.set(key, resource);\n return resource;\n }\n\n Delete(path, variant = \"\") {\n return this.#resources.delete(GetCacheKey(path, variant));\n }\n\n DeleteAll(path) {\n const normalizedPath = normalizeResourcePath(path);\n if (!normalizedPath) throw new TypeError(\"CjsMotherLode requires a resource path.\");\n const prefix = `${normalizedPath}\\u0000`;\n let deleted = false;\n for (const key of this.#resources.keys())\n {\n if (key === normalizedPath || key.startsWith(prefix))\n {\n deleted = this.#resources.delete(key) || deleted;\n }\n }\n return deleted;\n }\n\n Clear() {\n this.#resources.clear();\n return this;\n }\n\n Has(path, variant = \"\") {\n return this.#resources.has(GetCacheKey(path, variant));\n }\n\n GetCount() {\n return this.#resources.size;\n }\n\n GetStats() {\n return Object.freeze({\n count: this.#resources.size,\n paths: Object.freeze([ ...new Set(\n [ ...this.#resources.values() ].map(resource => resource?.GetPath?.() ?? resource?.path ?? \"\")\n ) ].filter(Boolean))\n });\n }\n\n Entries() {\n return this.#resources.entries();\n }\n}\n\nfunction GetCacheKey(path, variant = \"\")\n{\n const normalizedPath = normalizeResourcePath(path);\n if (!normalizedPath) throw new TypeError(\"CjsMotherLode requires a resource path.\");\n const normalizedVariant = variant === null || variant === undefined ? \"\" : String(variant);\n return normalizedVariant ? `${normalizedPath}\\u0000${normalizedVariant}` : normalizedPath;\n}\n"],"names":["CjsMotherLode","Map","Lookup","path","variant","get","GetCacheKey","Insert","resource","GetPath","key","set","Delete","delete","DeleteAll","normalizedPath","normalizeResourcePath","TypeError","prefix","deleted","keys","startsWith","Clear","clear","Has","has","GetCount","size","GetStats","Object","freeze","count","paths","Set","values","map","filter","Boolean","Entries","entries","normalizedVariant","undefined","String"],"mappings":";;AAEO,MAAMA,aAAa,CAC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AG,EAAE,GAAGC,MAAM,CAACtC,OAAO,CAAC;EAC1F,OAAOoC,iBAAiB,GAAG,CAAA,EAAGzB,cAAc,SAASyB,iBAAiB,CAAA,CAAE,GAAGzB,cAAc;AAC3F;;;;"}
1
+ {"version":3,"file":"CjsMotherLode.js","sources":["../../src/CjsMotherLode.js"],"sourcesContent":["// Source: blue/include/IMotherLode.h\n// Source: blue/src/MotherLode.h\n// Source: blue/src/MotherLode.cpp\nimport { normalizeResourcePath } from \"./resourcePath.js\";\n\nconst DEFAULT_CACHE_SIZE = 32 * 1024 * 1024;\nconst MAX_SAFE_INTEGER_BIGINT = BigInt(Number.MAX_SAFE_INTEGER);\n\n/**\n * Construction options for {@link CjsMotherLode}.\n *\n * @typedef {object} CjsMotherLodeOptions\n * @property {() => number} [now] Returns a non-negative timestamp for activity diagnostics.\n * @property {number} [cacheSize] Initial recorded-byte budget for explicitly cached entries.\n */\n\n/**\n * Cleanup policy accepted by ownership-removal operations.\n *\n * @typedef {object} CjsMotherLodeMutationOptions\n * @property {false|Function} [cleanup] `false` retains ownership; a function replaces default cleanup.\n * @property {boolean} [destroyAdapters=true] Whether default cleanup destroys adapter allocations.\n * @property {boolean} [releasePayload=true] Whether default cleanup releases the complete CPU payload.\n */\n\n/**\n * Canonical insertion and record-metadata options.\n *\n * @typedef {CjsMotherLodeMutationOptions & object} CjsMotherLodeInsertOptions\n * @property {boolean} [replace=true] Whether an existing different resource may be displaced.\n * @property {string} [variant] Variant used only by the legacy resource-first insertion form.\n * @property {number} [bytes=0] Caller-supplied non-negative safe-integer eviction weight.\n * @property {boolean} [cacheable=true] Whether policy may explicitly admit the entry to the byte cache.\n * @property {boolean} [cached=false] Admit the entry to oldest-first trimming and `ClearCached()`.\n * @property {number} [frame] Explicit non-negative activity frame; otherwise the counter advances.\n * @property {number} [time] Explicit non-negative activity timestamp; otherwise `now()` is called.\n */\n\n/**\n * Exact-owner conditional replacement options.\n *\n * @typedef {CjsMotherLodeInsertOptions & object} CjsMotherLodeConditionalReplaceOptions\n * @property {() => boolean} [commitGuard] Final side-effect-free caller authority check performed immediately before the exact-record comparison.\n */\n\n/**\n * Explicit inactivity-sweep policy for {@link CjsMotherLode#PurgeInactive}.\n * At least one identity or payload limit must be supplied for work to occur.\n * When both frame and time limits exist, reaching either limit is sufficient.\n *\n * @typedef {CjsMotherLodeMutationOptions & object} CjsMotherLodePurgeOptions\n * @property {number} [frame] Current non-negative activity frame; otherwise the registry advances once.\n * @property {number} [time] Current non-negative timestamp in milliseconds; otherwise `now()` is called.\n * @property {number} [maxIdleFrames] Frames after which an unlocked identity is removed and cleaned.\n * @property {number} [maxIdleMilliseconds] Milliseconds after which an unlocked identity is removed and cleaned.\n * @property {number} [payloadMaxIdleFrames] Frames after which an unlocked CPU payload is released.\n * @property {number} [payloadMaxIdleMilliseconds] Milliseconds after which an unlocked CPU payload is released.\n */\n\n/**\n * Immutable result from one explicit inactivity sweep.\n *\n * @typedef {object} CjsMotherLodePurgeResult\n * @property {number} frame Sweep activity frame.\n * @property {number} time Sweep timestamp in milliseconds.\n * @property {number} purged Number of canonical identities removed and cleaned.\n * @property {number} payloadsReleased Number of payloads released while retaining their identities.\n * @property {number} locked Number of locked identities skipped by the sweep.\n * @property {readonly string[]} purgedKeys Canonical identities removed by the sweep.\n * @property {readonly string[]} payloadKeys Canonical identities whose payload lease expired.\n */\n\n/**\n * Immutable result from deterministic recorded-byte cache housekeeping.\n *\n * Only explicitly cached, cacheable, unlocked records contribute to the\n * budget. Zero-byte records do not create pressure and are retained because\n * removing them cannot reduce the recorded byte total.\n *\n * @typedef {object} CjsMotherLodeCacheTrimResult\n * @property {number} cacheSize Configured recorded-byte budget.\n * @property {number} beforeBytes Explicit cached bytes before housekeeping.\n * @property {number} afterBytes Explicit cached bytes after housekeeping.\n * @property {number} evictedBytes Recorded bytes removed successfully.\n * @property {boolean} overBudget Whether retained cached records still exceed the budget.\n * @property {number} evicted Number of complete canonical identities removed.\n * @property {number} failed Number of candidate identities that reported cleanup or purge-state failure.\n * @property {readonly string[]} evictedKeys Canonical identities removed oldest-first.\n * @property {readonly string[]} failedKeys Canonical identities that reported a failure.\n */\n\n/**\n * Activity-update options accepted by {@link CjsMotherLode#KeepAlive}.\n *\n * @typedef {object} CjsMotherLodeActivityOptions\n * @property {number} [frame] Explicit non-negative activity frame; otherwise the counter advances.\n * @property {number} [time] Explicit non-negative activity timestamp; otherwise `now()` is called.\n */\n\n/**\n * Immutable result returned by {@link CjsMotherLode#Insert}.\n *\n * @typedef {object} CjsMotherLodeInsertResult\n * @property {string} key Canonical resolved identity key.\n * @property {object|Function} resource Resource that owns the canonical identity after the call.\n * @property {boolean} inserted Whether the supplied resource was newly registered.\n * @property {boolean} replaced Whether a different registered resource was displaced.\n * @property {object|Function|null} displaced Previous resource returned after successful cleanup or retention.\n */\n\n/**\n * Immutable result from an exact-owner conditional replacement.\n *\n * @typedef {object} CjsMotherLodeConditionalReplaceResult\n * @property {string} key Canonical resolved identity key.\n * @property {boolean} committed Whether the expected owner was replaced.\n * @property {object|Function|null} resource Canonical resource after the compare-and-swap attempt.\n * @property {object|Function|null} displaced Former exact owner when the replacement committed.\n */\n\n/**\n * Immutable diagnostic snapshot returned by {@link CjsMotherLode#GetStats}.\n *\n * @typedef {object} CjsMotherLodeStats\n * @property {number} count Compatibility identity count.\n * @property {number} size Canonical identity count.\n * @property {number} live Number of entries not explicitly classified as cached.\n * @property {number} cached Number of explicitly cached entries.\n * @property {number} locked Number of entries with at least one eviction lock.\n * @property {number} payloads Number of entries currently retaining a CPU payload.\n * @property {number} bytes Total caller-supplied eviction weight.\n * @property {number} cacheBytes Byte estimate for explicitly cached entries.\n * @property {number} cacheSize Configured recorded-byte cache budget.\n * @property {number} activityFrame Highest activity frame observed by this registry.\n * @property {Readonly<Record<string, number>>} states Resource count grouped by state name.\n * @property {readonly string[]} paths Unique resource paths in encounter order.\n */\n\n/**\n * Strong, deterministic JavaScript resource registry.\n *\n * Carbon can move resources between weak live registration and a strong LRU\n * cache. JavaScript ownership cannot reproduce that transition reliably, so\n * entries remain strongly owned until explicit ownership removal or an\n * explicit inactivity/recorded-byte policy evicts them.\n */\nexport class CjsMotherLode\n{\n\n #active = false;\n #activityFrame = 0;\n #cacheSize = DEFAULT_CACHE_SIZE;\n #entries = new Map();\n #nextCacheSequence = 1;\n #now = DefaultNow;\n\n /**\n * Create an active deterministic resource registry.\n *\n * @param {CjsMotherLodeOptions} [options={}] Clock and recorded-byte cache configuration.\n * @throws {TypeError} If options, the clock, or the cache byte budget are invalid.\n */\n constructor(options = {})\n {\n if (!options || typeof options !== \"object\" || Array.isArray(options))\n {\n throw new TypeError(\"CjsMotherLode options must be an object.\");\n }\n if (options.now !== undefined)\n {\n if (typeof options.now !== \"function\")\n {\n throw new TypeError(\"CjsMotherLode now must be a function.\");\n }\n this.#now = options.now;\n }\n if (options.cacheSize !== undefined)\n {\n this.SetCacheSize(options.cacheSize);\n }\n this.Startup();\n }\n\n /**\n * Activate resource registration without changing existing entries.\n * Repeated calls are idempotent.\n *\n * @returns {CjsMotherLode} This registry.\n */\n Startup()\n {\n this.#active = true;\n return this;\n }\n\n /**\n * Stop registration and deterministically remove every owned entry.\n * Default cleanup destroys attached adapter allocations and releases CPU\n * payloads. Repeated calls are idempotent after a successful cleanup.\n *\n * @param {CjsMotherLodeMutationOptions} [options={}] Cleanup policy applied to every entry.\n * @returns {CjsMotherLode} This inactive registry.\n * @throws {AggregateError} If cleanup fails for one or more entries; registration is still stopped.\n */\n Shutdown(options = {})\n {\n try\n {\n this.Clear(options);\n }\n finally\n {\n this.#active = false;\n }\n return this;\n }\n\n /**\n * Return whether new resources may currently be inserted.\n *\n * @returns {boolean} `true` between `Startup()` and `Shutdown()`.\n */\n IsStarted()\n {\n return this.#active;\n }\n\n /**\n * Insert a canonical key and report whether an existing owner was displaced.\n *\n * The legacy `Insert(resource, path, variant)` form remains accepted while\n * ResMan and consumers migrate to `Insert(key, resource, options)`.\n * Cleanup completes before canonical ownership changes, so a cleanup error\n * leaves the previous resource registered and the supplied resource owned by\n * its caller.\n *\n * @param {string|object|Function} keyOrResource Canonical key, or the legacy resource object.\n * @param {object|Function|string} resourceOrPath Resource object, or the legacy source path.\n * @param {CjsMotherLodeInsertOptions|string} [optionsOrVariant={}] Insertion options, or legacy variant.\n * @returns {CjsMotherLodeInsertResult} Immutable canonical ownership result.\n * @throws {TypeError} If the key, resource, metadata, or activity values are invalid.\n * @throws {Error} If the registry is inactive or displaced-resource cleanup fails.\n */\n Insert(keyOrResource, resourceOrPath, optionsOrVariant = {})\n {\n if (!this.#active)\n {\n throw MotherLodeInactiveError();\n }\n\n const { key, resource, options } = NormalizeInsertArguments(\n keyOrResource,\n resourceOrPath,\n optionsOrVariant\n );\n AssertResource(resource);\n\n const existing = this.#entries.get(key) || null;\n if (existing && existing.resource === resource)\n {\n const updated = { ...existing };\n this.#UpdateRecord(updated, options);\n this.#AssertRecordedBytesTotal(updated, existing);\n this.#TouchRecord(updated, options);\n Object.assign(existing, updated);\n return FreezeInsertResult(key, resource, false, false, null);\n }\n if (existing && options.replace === false)\n {\n return FreezeInsertResult(key, existing.resource, false, false, null);\n }\n\n const record = this.#CreateRecord(key, resource, options, existing);\n\n if (existing)\n {\n this.#CleanupRecord(existing, options, \"replace\", true);\n }\n this.#entries.set(key, record);\n\n return FreezeInsertResult(key, resource, true, Boolean(existing), existing?.resource || null);\n }\n\n /**\n * Replace one exact canonical owner without running user cleanup between the\n * final ownership comparison and registry publication.\n *\n * The prepared replacement becomes canonical first; displaced-owner cleanup\n * then runs exactly once. A cleanup failure therefore cannot roll lookup\n * ownership back to a partially cleaned former resource. Such a failure is\n * reported as `CJS_MOTHERLODE_REPLACE_CLEANUP_FAILED` with a committed\n * result attached. When the expected owner is no longer current, no mutation\n * or cleanup occurs and `committed` is `false`.\n *\n * Recorded bytes and cacheability inherit from the expected record unless\n * explicitly supplied. The replacement is live by default because a\n * successful staged reload is an activity observation.\n *\n * @param {string} key Canonical resolved identity key.\n * @param {object|Function} expected Exact resource that must still own `key`.\n * @param {object|Function} resource Fully prepared replacement resource.\n * @param {CjsMotherLodeConditionalReplaceOptions} [options={}] Replacement metadata, authority guard, and displaced-owner cleanup policy.\n * @returns {CjsMotherLodeConditionalReplaceResult} Immutable compare-and-swap outcome.\n * @throws {TypeError} If the key, resources, metadata, or activity values are invalid.\n * @throws {Error} If the registry is inactive or the prepared resource aliases the expected owner.\n * @throws {AggregateError} After a committed swap when displaced-owner cleanup fails.\n */\n ReplaceExpected(key, expected, resource, options = {})\n {\n if (!this.#active)\n {\n throw MotherLodeInactiveError();\n }\n\n const resolvedKey = NormalizeResolvedKey(key);\n const policy = NormalizeOptions(options, \"conditional replace\");\n if (policy.commitGuard !== undefined && typeof policy.commitGuard !== \"function\")\n {\n throw new TypeError(\"CjsMotherLode conditional replace commitGuard must be a function.\");\n }\n AssertResource(expected);\n AssertResource(resource);\n if (resource === expected)\n {\n const error = new Error(\"CjsMotherLode conditional replacement requires a distinct resource.\");\n error.code = \"CJS_MOTHERLODE_REPLACE_ALIAS\";\n throw error;\n }\n\n const existing = this.#entries.get(resolvedKey) || null;\n if (!existing || existing.resource !== expected)\n {\n return FreezeConditionalReplaceResult(\n resolvedKey,\n false,\n existing?.resource || null,\n null\n );\n }\n\n const recordOptions = {\n ...policy,\n bytes: policy.bytes === undefined ? existing.bytes : policy.bytes,\n cacheable: policy.cacheable === undefined ? existing.cacheable : policy.cacheable,\n cached: policy.cached === undefined ? false : policy.cached\n };\n const record = this.#CreateRecord(resolvedKey, resource, recordOptions, existing);\n\n // Re-check after clock/metadata validation, then publish with no user code\n // between the exact-record comparison and Map mutation.\n if ((policy.commitGuard && !policy.commitGuard())\n || this.#entries.get(resolvedKey) !== existing)\n {\n return FreezeConditionalReplaceResult(\n resolvedKey,\n false,\n this.#entries.get(resolvedKey)?.resource || null,\n null\n );\n }\n this.#entries.set(resolvedKey, record);\n\n const result = FreezeConditionalReplaceResult(resolvedKey, true, resource, expected);\n try\n {\n this.#CleanupRecord(existing, policy, \"conditional replace\");\n }\n catch (cause)\n {\n const error = new AggregateError(\n [ cause ],\n `CjsMotherLode conditional replacement committed but cleanup failed for ${resolvedKey}.`\n );\n error.code = \"CJS_MOTHERLODE_REPLACE_CLEANUP_FAILED\";\n error.result = result;\n throw error;\n }\n return result;\n }\n\n /**\n * Test a canonical identity without loading or renewing its activity.\n * Supplying `variant` retains compatibility with the former path-first API.\n *\n * @param {string} key Canonical resolved key, or normalized source path with `variant`.\n * @param {string} [variant] Optional promised-output variant.\n * @returns {boolean} Whether the resolved identity is registered.\n * @throws {TypeError} If the identity cannot be normalized.\n */\n HasKey(key, variant = undefined)\n {\n return this.#entries.has(NormalizeLookupKey(key, variant));\n }\n\n /**\n * Return a canonical resource without loading or renewing its activity.\n * Supplying `variant` retains compatibility with the former path-first API.\n *\n * @param {string} key Canonical resolved key, or normalized source path with `variant`.\n * @param {string} [variant] Optional promised-output variant.\n * @returns {object|Function|null} Registered resource, or `null` when absent.\n * @throws {TypeError} If the identity cannot be normalized.\n */\n Lookup(key, variant = undefined)\n {\n return this.#entries.get(NormalizeLookupKey(key, variant))?.resource || null;\n }\n\n /**\n * Remove one canonical identity and clean its manager-owned payloads.\n *\n * `Delete(path, variant)` remains accepted for compatibility.\n *\n * @param {string} key Canonical resolved key, or normalized source path with a variant.\n * @param {string|CjsMotherLodeMutationOptions} [variantOrOptions] Compatibility variant or cleanup policy.\n * @param {CjsMotherLodeMutationOptions} [maybeOptions] Cleanup policy when a variant is supplied.\n * @returns {boolean} Whether an entry was removed.\n * @throws {TypeError} If identity or cleanup options are invalid.\n * @throws {Error} If resource cleanup fails after the identity is removed.\n */\n Delete(key, variantOrOptions = undefined, maybeOptions = undefined)\n {\n const { resolvedKey, options } = NormalizeDeleteArguments(key, variantOrOptions, maybeOptions);\n const record = this.#entries.get(resolvedKey);\n if (!record) return false;\n\n this.#entries.delete(resolvedKey);\n this.#CleanupRecord(record, options, \"delete\");\n return true;\n }\n\n /**\n * Remove every promised-output variant for one normalized source path.\n * All matching identities are forgotten before cleanup begins.\n *\n * @param {string} path Source resource path whose canonical variants are removed.\n * @param {CjsMotherLodeMutationOptions} [options={}] Cleanup policy for removed resources.\n * @returns {boolean} Whether at least one variant was removed.\n * @throws {TypeError} If the path is invalid.\n * @throws {AggregateError} If cleanup fails for one or more removed resources.\n */\n DeleteAllVariants(path, options = {})\n {\n const normalizedPath = NormalizePath(path);\n const prefix = `${normalizedPath}\\u0000`;\n const records = [];\n\n for (const [ key, record ] of this.#entries)\n {\n if (key === normalizedPath || key.startsWith(prefix))\n {\n records.push(record);\n this.#entries.delete(key);\n }\n }\n\n this.#CleanupRecords(records, options, \"delete variants\");\n return records.length > 0;\n }\n\n /**\n * Deterministically remove and clean every owned identity while preserving\n * the registry's active/inactive lifecycle state.\n *\n * @param {CjsMotherLodeMutationOptions} [options={}] Cleanup policy for removed resources.\n * @returns {CjsMotherLode} This empty registry.\n * @throws {AggregateError} If cleanup fails for one or more removed resources.\n */\n Clear(options = {})\n {\n const records = [ ...this.#entries.values() ];\n this.#entries.clear();\n this.#CleanupRecords(records, options, \"clear\");\n return this;\n }\n\n /**\n * Remove entries explicitly classified as cached and not locked.\n *\n * JavaScript cannot infer external ownership, so only callers that inserted\n * an entry with `{ cached: true }` classify it for this operation.\n *\n * @param {CjsMotherLodeMutationOptions} [options={}] Cleanup policy for removed cache entries.\n * @returns {number} Number of entries removed before cleanup.\n * @throws {AggregateError} If cleanup fails for one or more removed resources.\n */\n ClearCached(options = {})\n {\n const records = [];\n for (const [ key, record ] of this.#entries)\n {\n if (record.cached && record.lockCount === 0)\n {\n records.push(record);\n this.#entries.delete(key);\n }\n }\n this.#CleanupRecords(records, options, \"clear cached\");\n return records.length;\n }\n\n /**\n * Record explicit use and promote an explicitly cached entry to live.\n * The overload `KeepAlive(path, variant, options)` remains available while\n * callers migrate to canonical keys.\n *\n * @param {string} key Canonical resolved key, or normalized source path with a variant.\n * @param {string|CjsMotherLodeActivityOptions} [variantOrOptions] Compatibility variant or activity values.\n * @param {CjsMotherLodeActivityOptions} [maybeOptions] Activity values when a variant is supplied.\n * @returns {object|Function|null} Renewed resource, or `null` when absent.\n * @throws {TypeError} If identity or activity values are invalid.\n */\n KeepAlive(key, variantOrOptions = undefined, maybeOptions = undefined)\n {\n const { resolvedKey, options } = NormalizeActivityArguments(key, variantOrOptions, maybeOptions);\n const record = this.#entries.get(resolvedKey);\n if (!record) return null;\n record.cached = false;\n record.cacheSequence = 0;\n this.#TouchRecord(record, options);\n return record.resource;\n }\n\n /**\n * Explicitly renew both canonical identity activity and the attached CPU\n * payload lease. The resource-facing `KeepPayloadAlive()` method delegates\n * here when CjsResMan owns the handle. No payload is read or created.\n *\n * @param {string} key Canonical resolved key, or normalized source path with a variant.\n * @param {string|CjsMotherLodeActivityOptions} [variantOrOptions] Compatibility variant or activity values.\n * @param {CjsMotherLodeActivityOptions} [maybeOptions] Activity values when a variant is supplied.\n * @returns {object|Function|null} Renewed resource, or `null` when absent.\n * @throws {TypeError} If identity or activity values are invalid.\n */\n KeepPayloadAlive(key, variantOrOptions = undefined, maybeOptions = undefined)\n {\n const { resolvedKey, options } = NormalizeActivityArguments(key, variantOrOptions, maybeOptions);\n const record = this.#entries.get(resolvedKey);\n if (!record) return null;\n record.cached = false;\n record.cacheSequence = 0;\n this.#TouchRecord(record, options);\n record.payloadLastUsedFrame = record.lastUsedFrame;\n record.payloadLastUsedTime = record.lastUsedTime;\n return record.resource;\n }\n\n /**\n * Add one eviction lock and promote the identity from cached to live.\n * Locking an absent identity is a no-op.\n *\n * @param {string} key Canonical resolved key, or normalized source path with `variant`.\n * @param {string} [variant] Optional promised-output variant.\n * @returns {number} New lock count, or `0` when the identity is absent.\n * @throws {TypeError} If the identity cannot be normalized.\n */\n Lock(key, variant = undefined)\n {\n const record = this.#entries.get(NormalizeLookupKey(key, variant));\n if (!record) return 0;\n record.lockCount += 1;\n record.cached = false;\n record.cacheSequence = 0;\n this.#TouchRecord(record, {});\n return record.lockCount;\n }\n\n /**\n * Release one eviction lock without allowing the count to underflow.\n * Unlocking does not itself classify an entry as cached or evict it.\n *\n * @param {string} key Canonical resolved key, or normalized source path with `variant`.\n * @param {string} [variant] Optional promised-output variant.\n * @returns {number} Remaining lock count, or `0` when absent or already unlocked.\n * @throws {TypeError} If the identity cannot be normalized.\n */\n Unlock(key, variant = undefined)\n {\n const record = this.#entries.get(NormalizeLookupKey(key, variant));\n if (!record) return 0;\n if (record.lockCount > 0) record.lockCount -= 1;\n return record.lockCount;\n }\n\n /**\n * Run one explicit deterministic inactivity sweep.\n *\n * Identity limits remove unlocked canonical entries, destroy their adapter\n * allocations, release payloads, detach resource-facing lifecycle callbacks,\n * and mark CjsResource-compatible handles purged. Payload limits release only\n * the CPU payload while retaining identity and adapters. The sweep never\n * fetches, reloads, prepares, or infers external JavaScript ownership.\n *\n * Cleanup is transactional per identity: a failed cleanup leaves that record\n * canonical and reports a contextual error after all candidates are visited.\n * Successful candidates are still purged when another candidate fails.\n *\n * @param {CjsMotherLodePurgeOptions} [options={}] Explicit sweep point, inactivity limits, and cleanup policy.\n * @returns {CjsMotherLodePurgeResult} Immutable counts and affected canonical keys.\n * @throws {TypeError} If the sweep point, limits, or cleanup policy are invalid.\n * @throws {AggregateError} If one or more cleanup, payload-release, or purge-state operations fail.\n */\n PurgeInactive(options = {})\n {\n const policy = NormalizePurgeOptions(options, this.#activityFrame, this.#now);\n this.#activityFrame = Math.max(this.#activityFrame, policy.frame);\n\n const purgedKeys = [];\n const payloadKeys = [];\n const errors = [];\n let locked = 0;\n\n for (const [ key, record ] of [ ...this.#entries ])\n {\n if (record.lockCount > 0)\n {\n locked += 1;\n continue;\n }\n\n if (IsInactive(\n record.lastUsedFrame,\n record.lastUsedTime,\n policy.frame,\n policy.time,\n policy.maxIdleFrames,\n policy.maxIdleMilliseconds\n ))\n {\n try\n {\n this.#CleanupRecord(record, policy, \"purge inactive\", true);\n }\n catch (error)\n {\n errors.push(error);\n continue;\n }\n\n this.#entries.delete(key);\n purgedKeys.push(key);\n try\n {\n record.resource?.MarkPurged?.();\n }\n catch (cause)\n {\n errors.push(MotherLodeCleanupError(\"mark purged\", key, record.resource, cause));\n }\n continue;\n }\n\n if (policy.releasePayload !== false\n && HasOwnedPayload(record.resource)\n && IsInactive(\n record.payloadLastUsedFrame,\n record.payloadLastUsedTime,\n policy.frame,\n policy.time,\n policy.payloadMaxIdleFrames,\n policy.payloadMaxIdleMilliseconds\n ))\n {\n try\n {\n record.resource.ReleasePayload();\n payloadKeys.push(key);\n }\n catch (cause)\n {\n errors.push(MotherLodeCleanupError(\"release inactive payload\", key, record.resource, cause));\n }\n }\n }\n\n const result = FreezePurgeResult(policy.frame, policy.time, purgedKeys, payloadKeys, locked);\n if (errors.length)\n {\n const error = new AggregateError(errors, \"CjsMotherLode inactivity purge failed.\");\n error.code = \"CJS_MOTHERLODE_PURGE_FAILED\";\n error.result = result;\n throw error;\n }\n return result;\n }\n\n /**\n * Remove complete explicitly cached identities until their recorded byte\n * total fits the configured budget.\n *\n * Candidates are ordered by explicit cache admission, oldest first. Lookup\n * is intentionally pure; callers re-admit a live identity by inserting the\n * same handle with `{ cached: true }`. Locks and `KeepAlive()` promote an\n * entry to live and therefore remove it from byte-budget consideration.\n *\n * Cleanup is transactional per candidate. A failure leaves that candidate\n * canonical, later candidates are still attempted, and the final aggregate\n * error carries the partial immutable result. Successful pressure eviction\n * destroys adapters, releases payloads, detaches lifecycle callbacks, marks\n * compatible handles `PURGED` by default, and never fetches or reconstructs\n * data. Explicit cleanup overrides retain their documented ownership.\n *\n * @param {CjsMotherLodeMutationOptions} [options={}] Cleanup policy for pressure-evicted identities.\n * @returns {CjsMotherLodeCacheTrimResult} Immutable byte totals and affected canonical keys.\n * @throws {TypeError} If cleanup options are invalid.\n * @throws {AggregateError} If cleanup or purge-state publication fails for one or more candidates.\n */\n TrimCache(options = {})\n {\n const policy = NormalizeOptions(options, \"cache trim\");\n const beforeBytes = this.#GetCacheBytes();\n const evictedKeys = [];\n const failedKeys = [];\n const errors = [];\n let evictedBytes = 0;\n\n if (beforeBytes > this.#cacheSize)\n {\n const candidates = [ ...this.#entries.values() ]\n .filter(record => record.cacheable\n && record.cached\n && record.lockCount === 0\n && record.bytes > 0)\n .sort((a, b) => a.cacheSequence - b.cacheSequence);\n\n for (const record of candidates)\n {\n if (this.#GetCacheBytes() <= this.#cacheSize) break;\n if (this.#entries.get(record.key) !== record\n || !record.cacheable\n || !record.cached\n || record.lockCount > 0\n || record.bytes <= 0)\n {\n continue;\n }\n\n try\n {\n this.#CleanupRecord(record, policy, \"trim cache\", true);\n }\n catch (error)\n {\n errors.push(error);\n failedKeys.push(record.key);\n continue;\n }\n\n if (this.#entries.get(record.key) === record)\n {\n this.#entries.delete(record.key);\n }\n evictedKeys.push(record.key);\n evictedBytes += record.bytes;\n\n try\n {\n record.resource?.MarkPurged?.();\n }\n catch (cause)\n {\n errors.push(MotherLodeCleanupError(\"mark cache eviction purged\", record.key, record.resource, cause));\n failedKeys.push(record.key);\n }\n }\n }\n\n const afterBytes = this.#GetCacheBytes();\n const result = FreezeCacheTrimResult(\n this.#cacheSize,\n beforeBytes,\n afterBytes,\n evictedBytes,\n evictedKeys,\n failedKeys\n );\n if (errors.length)\n {\n const error = new AggregateError(errors, \"CjsMotherLode cache trim failed.\");\n error.code = \"CJS_MOTHERLODE_CACHE_TRIM_FAILED\";\n error.result = result;\n throw error;\n }\n return result;\n }\n\n /**\n * Configure and immediately enforce the recorded-byte budget for explicit\n * cached entries. The new budget remains installed if partial cleanup fails,\n * matching Carbon's policy-first `SetCacheSize` behavior.\n *\n * @param {number} bytes Non-negative safe-integer byte budget.\n * @param {CjsMotherLodeMutationOptions} [options={}] Cleanup policy for entries displaced by the smaller budget.\n * @returns {CjsMotherLode} This registry.\n * @throws {TypeError} If `bytes` or cleanup options are invalid.\n * @throws {AggregateError} If enforcing the new budget cannot clean one or more cached entries.\n */\n SetCacheSize(bytes, options = {})\n {\n AssertNonNegativeSafeInteger(bytes, \"CjsMotherLode cache size\");\n const policy = NormalizeOptions(options, \"set cache size\");\n this.#cacheSize = bytes;\n this.TrimCache(policy);\n return this;\n }\n\n /**\n * Return the configured recorded-byte cache budget.\n *\n * @returns {number} Non-negative safe-integer byte budget.\n */\n GetCacheSize()\n {\n return this.#cacheSize;\n }\n\n /**\n * Return an immutable snapshot of canonical identity keys.\n *\n * @returns {readonly string[]} Canonical keys in insertion order.\n */\n GetKeys()\n {\n return Object.freeze([ ...this.#entries.keys() ]);\n }\n\n /**\n * Return an immutable snapshot of canonical resources.\n *\n * @returns {readonly (object|Function)[]} Resources in insertion order.\n */\n GetValues()\n {\n return Object.freeze([ ...this.#entries.values() ].map(record => record.resource));\n }\n\n /**\n * Return the number of canonical identities currently registered.\n *\n * @returns {number} Registry entry count.\n */\n GetSize()\n {\n return this.#entries.size;\n }\n\n /**\n * Return an immutable diagnostic snapshot without renewing activity.\n * Byte totals include only caller-supplied estimates and do not measure\n * JavaScript reachability or trigger cache policy.\n *\n * @returns {CjsMotherLodeStats} Current identity, activity, state, and byte totals.\n */\n GetStats()\n {\n let bytes = 0;\n let cacheBytes = 0;\n let cached = 0;\n let locked = 0;\n let payloads = 0;\n const paths = new Set();\n const states = {};\n\n for (const record of this.#entries.values())\n {\n bytes += record.bytes;\n if (record.cached)\n {\n cached += 1;\n cacheBytes += record.bytes;\n }\n if (record.lockCount > 0) locked += 1;\n if (HasOwnedPayload(record.resource)) payloads += 1;\n\n const path = record.resource?.GetPath?.() || record.resource?.path || GetKeyPath(record.key);\n if (path) paths.add(path);\n\n const state = typeof record.resource?.state === \"string\" ? record.resource.state : \"unknown\";\n states[state] = (states[state] || 0) + 1;\n }\n\n return Object.freeze({\n count: this.#entries.size,\n size: this.#entries.size,\n live: this.#entries.size - cached,\n cached,\n locked,\n payloads,\n bytes,\n cacheBytes,\n cacheSize: this.#cacheSize,\n activityFrame: this.#activityFrame,\n states: Object.freeze(states),\n paths: Object.freeze([ ...paths ])\n });\n }\n\n /**\n * Return a snapshot iterator of canonical key/resource pairs.\n * Later registry mutations do not change the captured key list.\n *\n * @returns {IterableIterator<[string, object|Function]>} Insertion-ordered entry iterator.\n */\n Entries()\n {\n return this.GetKeys().map(key => [ key, this.#entries.get(key).resource ])[Symbol.iterator]();\n }\n\n /**\n * Test a path and optional variant through the temporary legacy API.\n *\n * @deprecated Use `HasKey(getMotherLodeKey(path, variant))`.\n * @param {string} path Source resource path.\n * @param {string} [variant] Optional promised-output variant.\n * @returns {boolean} Whether the resolved identity is registered.\n */\n Has(path, variant = undefined)\n {\n return this.HasKey(path, variant);\n }\n\n /**\n * Return the registry count through the temporary legacy API.\n *\n * @deprecated Use `GetSize()`.\n * @returns {number} Registry entry count.\n */\n GetCount()\n {\n return this.GetSize();\n }\n\n /**\n * Remove all variants through the temporary legacy API.\n *\n * @deprecated Use `DeleteAllVariants(path, options)`.\n * @param {string} path Source resource path.\n * @param {CjsMotherLodeMutationOptions} [options={}] Cleanup policy for removed resources.\n * @returns {boolean} Whether at least one variant was removed.\n */\n DeleteAll(path, options = {})\n {\n return this.DeleteAllVariants(path, options);\n }\n\n /**\n * Create and validate an internal ownership record before it is registered.\n *\n * @param {string} key Canonical resolved identity key.\n * @param {object|Function} resource Caller-supplied resource owner.\n * @param {CjsMotherLodeInsertOptions} options Validated insertion options.\n * @param {object|null} [displaced=null] Existing record excluded from aggregate byte validation.\n * @returns {object} Mutable internal ownership record.\n */\n #CreateRecord(key, resource, options, displaced = null)\n {\n const record = {\n key,\n resource,\n bytes: 0,\n cacheable: true,\n cached: false,\n cacheSequence: 0,\n lockCount: 0,\n lastUsedFrame: 0,\n lastUsedTime: 0,\n payloadLastUsedFrame: 0,\n payloadLastUsedTime: 0\n };\n this.#UpdateRecord(record, options);\n this.#AssertRecordedBytesTotal(record, displaced);\n this.#TouchRecord(record, options);\n record.payloadLastUsedFrame = record.lastUsedFrame;\n record.payloadLastUsedTime = record.lastUsedTime;\n return record;\n }\n\n /**\n * Apply explicit size/cache metadata while preserving lock invariants.\n *\n * @param {object} record Mutable internal ownership record.\n * @param {CjsMotherLodeInsertOptions} options Metadata updates.\n * @returns {object} The updated record.\n */\n #UpdateRecord(record, options)\n {\n if (options.bytes !== undefined)\n {\n AssertNonNegativeSafeInteger(options.bytes, \"CjsMotherLode entry bytes\");\n record.bytes = options.bytes;\n }\n if (options.cacheable !== undefined) record.cacheable = Boolean(options.cacheable);\n if (options.cached !== undefined)\n {\n record.cached = record.cacheable && record.lockCount === 0 && Boolean(options.cached);\n record.cacheSequence = record.cached ? this.#nextCacheSequence++ : 0;\n }\n if (!record.cacheable || record.lockCount > 0)\n {\n record.cached = false;\n record.cacheSequence = 0;\n }\n return record;\n }\n\n /**\n * Reject metadata that would make aggregate recorded-byte arithmetic lose\n * integer precision. This keeps trim results and diagnostics exact without\n * attempting to measure JavaScript object graphs heuristically.\n *\n * @param {object} candidate New or updated record.\n * @param {object|null} [excluded=null] Existing record replaced by the candidate.\n * @returns {void}\n * @throws {RangeError} If aggregate recorded bytes exceed the safe-integer range.\n */\n #AssertRecordedBytesTotal(candidate, excluded = null)\n {\n let total = BigInt(candidate.bytes);\n for (const record of this.#entries.values())\n {\n if (record === excluded) continue;\n total += BigInt(record.bytes);\n if (total > MAX_SAFE_INTEGER_BIGINT)\n {\n throw new RangeError(\"CjsMotherLode aggregate recorded bytes exceed Number.MAX_SAFE_INTEGER.\");\n }\n }\n }\n\n /**\n * Sum exact byte weights for explicit cached entries.\n * Aggregate safety is maintained at insertion/update time.\n *\n * @returns {number} Exact explicit-cache byte total.\n */\n #GetCacheBytes()\n {\n let bytes = 0;\n for (const record of this.#entries.values())\n {\n if (record.cacheable && record.cached) bytes += record.bytes;\n }\n return bytes;\n }\n\n /**\n * Record one explicit activity observation for an internal entry.\n *\n * @param {object} record Mutable internal ownership record.\n * @param {CjsMotherLodeActivityOptions} options Optional frame/time override.\n * @returns {object} The updated record.\n * @throws {TypeError} If frame or time is invalid.\n */\n #TouchRecord(record, options)\n {\n const frame = options.frame === undefined ? this.#activityFrame + 1 : options.frame;\n AssertNonNegativeSafeInteger(frame, \"CjsMotherLode activity frame\");\n this.#activityFrame = Math.max(this.#activityFrame, frame);\n record.lastUsedFrame = frame;\n\n const time = options.time === undefined ? this.#now() : options.time;\n if (typeof time !== \"number\" || !Number.isFinite(time) || time < 0)\n {\n throw new TypeError(\"CjsMotherLode activity time must be a non-negative finite number.\");\n }\n record.lastUsedTime = time;\n return record;\n }\n\n /**\n * Clean one displaced record and attach canonical ownership context to errors.\n *\n * @param {object} record Internal ownership record being removed.\n * @param {CjsMotherLodeMutationOptions} options Cleanup policy.\n * @param {string} operation Human-readable ownership operation.\n * @param {boolean} [preserveOnFailure=false] Keep lifecycle binding when the record remains canonical.\n * @returns {void}\n * @throws {Error} Contextual `CJS_MOTHERLODE_CLEANUP_FAILED` error on failure.\n */\n #CleanupRecord(record, options, operation, preserveOnFailure = false)\n {\n let cleanupComplete = false;\n try\n {\n CleanupOwnedResource(record.resource, options);\n cleanupComplete = true;\n DetachResourceLifecycle(record.resource);\n }\n catch (cause)\n {\n if (!preserveOnFailure && !cleanupComplete)\n {\n try\n {\n DetachResourceLifecycle(record.resource);\n }\n catch (detachCause)\n {\n cause = new AggregateError([ cause, detachCause ], \"Resource cleanup and detach failed.\");\n }\n }\n throw MotherLodeCleanupError(operation, record.key, record.resource, cause);\n }\n }\n\n /**\n * Clean every removed record and aggregate failures without skipping entries.\n *\n * @param {object[]} records Internal ownership records already removed from the registry.\n * @param {CjsMotherLodeMutationOptions} options Shared cleanup policy.\n * @param {string} operation Human-readable ownership operation.\n * @returns {void}\n * @throws {AggregateError} Contextual errors for every failed cleanup.\n */\n #CleanupRecords(records, options, operation)\n {\n const errors = [];\n for (const record of records)\n {\n try\n {\n CleanupOwnedResource(record.resource, options);\n }\n catch (cause)\n {\n errors.push(MotherLodeCleanupError(operation, record.key, record.resource, cause));\n }\n try\n {\n DetachResourceLifecycle(record.resource);\n }\n catch (cause)\n {\n errors.push(MotherLodeCleanupError(`${operation} detach`, record.key, record.resource, cause));\n }\n }\n if (errors.length)\n {\n throw new AggregateError(errors, `CjsMotherLode ${operation} cleanup failed.`);\n }\n }\n\n}\n\n/**\n * Build the canonical normalized identity shared by CjsResMan and MotherLode.\n * The source path and promised-output variant are separated with an internal null byte;\n * variants therefore may not contain that delimiter.\n *\n * @param {string} path Source resource path normalized with Carbon path rules.\n * @param {*} [variant=\"\"] Stable build/outcome variant; empty values use the path alone.\n * @returns {string} Canonical resolved MotherLode identity.\n * @throws {TypeError} If the path is empty/invalid or the variant contains a null byte.\n */\nexport function getMotherLodeKey(path, variant = \"\")\n{\n const normalizedPath = NormalizePath(path);\n if (variant === null || variant === undefined || variant === \"\") return normalizedPath;\n\n const normalizedVariant = String(variant);\n if (normalizedVariant.includes(\"\\u0000\"))\n {\n throw new TypeError(\"CjsMotherLode variant may not contain a null character.\");\n }\n return `${normalizedPath}\\u0000${normalizedVariant}`;\n}\n\nfunction NormalizeInsertArguments(keyOrResource, resourceOrPath, optionsOrVariant)\n{\n if (typeof keyOrResource === \"string\")\n {\n return {\n key: NormalizeResolvedKey(keyOrResource),\n resource: resourceOrPath,\n options: NormalizeOptions(optionsOrVariant, \"insert\")\n };\n }\n\n const resource = keyOrResource;\n const path = resourceOrPath ?? resource?.GetPath?.() ?? resource?.path;\n const isOptions = optionsOrVariant && typeof optionsOrVariant === \"object\" && !Array.isArray(optionsOrVariant);\n const options = isOptions ? NormalizeOptions(optionsOrVariant, \"insert\") : {};\n const variant = isOptions ? options.variant || \"\" : optionsOrVariant;\n return { key: getMotherLodeKey(path, variant), resource, options };\n}\n\nfunction NormalizeDeleteArguments(key, variantOrOptions, maybeOptions)\n{\n if (variantOrOptions && typeof variantOrOptions === \"object\" && !Array.isArray(variantOrOptions))\n {\n return {\n resolvedKey: NormalizeResolvedKey(key),\n options: NormalizeOptions(variantOrOptions, \"delete\")\n };\n }\n return {\n resolvedKey: NormalizeLookupKey(key, variantOrOptions),\n options: NormalizeOptions(maybeOptions || {}, \"delete\")\n };\n}\n\nfunction NormalizeActivityArguments(key, variantOrOptions, maybeOptions)\n{\n if (variantOrOptions && typeof variantOrOptions === \"object\" && !Array.isArray(variantOrOptions))\n {\n return {\n resolvedKey: NormalizeResolvedKey(key),\n options: NormalizeOptions(variantOrOptions, \"activity\")\n };\n }\n return {\n resolvedKey: NormalizeLookupKey(key, variantOrOptions),\n options: NormalizeOptions(maybeOptions || {}, \"activity\")\n };\n}\n\nfunction NormalizeLookupKey(key, variant)\n{\n return variant === undefined ? NormalizeResolvedKey(key) : getMotherLodeKey(key, variant);\n}\n\nfunction NormalizeResolvedKey(key)\n{\n if (typeof key !== \"string\" || !key)\n {\n throw new TypeError(\"CjsMotherLode requires a canonical string key.\");\n }\n const separator = key.indexOf(\"\\u0000\");\n return separator === -1\n ? getMotherLodeKey(key)\n : getMotherLodeKey(key.slice(0, separator), key.slice(separator + 1));\n}\n\nfunction NormalizePath(path)\n{\n const normalizedPath = normalizeResourcePath(path);\n if (!normalizedPath) throw new TypeError(\"CjsMotherLode requires a resource path.\");\n return normalizedPath;\n}\n\nfunction NormalizeOptions(options, operation)\n{\n if (options === null || options === undefined) return {};\n if (!options || typeof options !== \"object\" || Array.isArray(options))\n {\n throw new TypeError(`CjsMotherLode ${operation} options must be an object.`);\n }\n return options;\n}\n\n/**\n * Normalize one explicit inactivity sweep without mutating registry entries.\n *\n * @param {CjsMotherLodePurgeOptions} options Caller policy.\n * @param {number} activityFrame Current registry frame.\n * @param {() => number} now Registry clock.\n * @returns {CjsMotherLodePurgeOptions & {frame: number, time: number}} Validated sweep policy.\n */\nfunction NormalizePurgeOptions(options, activityFrame, now)\n{\n const policy = NormalizeOptions(options, \"purge\");\n const frame = policy.frame === undefined ? activityFrame + 1 : policy.frame;\n AssertNonNegativeSafeInteger(frame, \"CjsMotherLode purge frame\");\n\n const time = policy.time === undefined ? now() : policy.time;\n AssertNonNegativeFiniteNumber(time, \"CjsMotherLode purge time\");\n\n for (const name of [ \"maxIdleFrames\", \"payloadMaxIdleFrames\" ])\n {\n if (policy[name] !== undefined)\n {\n AssertNonNegativeSafeInteger(policy[name], `CjsMotherLode ${name}`);\n }\n }\n for (const name of [ \"maxIdleMilliseconds\", \"payloadMaxIdleMilliseconds\" ])\n {\n if (policy[name] !== undefined)\n {\n AssertNonNegativeFiniteNumber(policy[name], `CjsMotherLode ${name}`);\n }\n }\n\n return { ...policy, frame, time };\n}\n\n/**\n * Test whether either configured frame/time limit has elapsed.\n *\n * @param {number} lastFrame Last explicit lease frame.\n * @param {number} lastTime Last explicit lease timestamp.\n * @param {number} frame Current sweep frame.\n * @param {number} time Current sweep timestamp.\n * @param {number|undefined} maxFrames Optional frame limit.\n * @param {number|undefined} maxMilliseconds Optional millisecond limit.\n * @returns {boolean} Whether at least one configured limit has elapsed.\n */\nfunction IsInactive(lastFrame, lastTime, frame, time, maxFrames, maxMilliseconds)\n{\n const frameExpired = maxFrames !== undefined\n && frame >= lastFrame\n && frame - lastFrame >= maxFrames;\n const timeExpired = maxMilliseconds !== undefined\n && time >= lastTime\n && time - lastTime >= maxMilliseconds;\n return frameExpired || timeExpired;\n}\n\n/**\n * Return whether a resource currently exposes a releasable CPU payload.\n *\n * @param {object|Function} resource Candidate resource.\n * @returns {boolean} Whether `ReleasePayload()` can remove an attached payload.\n */\nfunction HasOwnedPayload(resource)\n{\n return typeof resource?.HasPayload === \"function\"\n && typeof resource?.ReleasePayload === \"function\"\n && Boolean(resource.HasPayload());\n}\n\n/**\n * Detach resource-facing lifecycle callbacks after canonical ownership ends.\n *\n * @param {object|Function} resource Removed resource.\n * @returns {void}\n */\nfunction DetachResourceLifecycle(resource)\n{\n resource?.SetLifecycleController?.(null);\n}\n\nfunction CleanupOwnedResource(resource, options)\n{\n if (options.cleanup === false) return;\n if (typeof options.cleanup === \"function\")\n {\n options.cleanup(resource);\n return;\n }\n\n const errors = [];\n if (options.destroyAdapters !== false && typeof resource?.DestroyAdapterResources === \"function\")\n {\n try\n {\n resource.DestroyAdapterResources({ destroy: true });\n }\n catch (error)\n {\n errors.push(error);\n }\n }\n if (options.releasePayload !== false && typeof resource?.ReleasePayload === \"function\")\n {\n try\n {\n resource.ReleasePayload();\n }\n catch (error)\n {\n errors.push(error);\n }\n }\n if (errors.length)\n {\n throw errors.length === 1 ? errors[0] : new AggregateError(errors, \"Resource cleanup failed.\");\n }\n}\n\nfunction AssertResource(resource)\n{\n if ((typeof resource !== \"object\" && typeof resource !== \"function\") || resource === null)\n {\n throw new TypeError(\"CjsMotherLode requires a resource object.\");\n }\n}\n\nfunction AssertNonNegativeSafeInteger(value, label)\n{\n if (!Number.isSafeInteger(value) || value < 0)\n {\n throw new TypeError(`${label} must be a non-negative safe integer.`);\n }\n}\n\n/**\n * Validate a non-negative finite number with a contextual error label.\n *\n * @param {*} value Candidate numeric value.\n * @param {string} label Error-message field name.\n * @returns {void}\n */\nfunction AssertNonNegativeFiniteNumber(value, label)\n{\n if (typeof value !== \"number\" || !Number.isFinite(value) || value < 0)\n {\n throw new TypeError(`${label} must be a non-negative finite number.`);\n }\n}\n\nfunction FreezeInsertResult(key, resource, inserted, replaced, displaced)\n{\n return Object.freeze({ key, resource, inserted, replaced, displaced });\n}\n\n/**\n * Freeze one exact-owner compare-and-swap result.\n *\n * @param {string} key Canonical resolved identity key.\n * @param {boolean} committed Whether publication replaced the expected owner.\n * @param {object|Function|null} resource Canonical owner after the attempt.\n * @param {object|Function|null} displaced Former owner when committed.\n * @returns {CjsMotherLodeConditionalReplaceResult} Immutable replacement result.\n */\nfunction FreezeConditionalReplaceResult(key, committed, resource, displaced)\n{\n return Object.freeze({ key, committed, resource, displaced });\n}\n\n/**\n * Freeze one inactivity-sweep result and its affected-key snapshots.\n *\n * @param {number} frame Sweep frame.\n * @param {number} time Sweep timestamp.\n * @param {string[]} purgedKeys Removed canonical keys.\n * @param {string[]} payloadKeys Keys whose payloads were released.\n * @param {number} locked Number of locked entries skipped.\n * @returns {CjsMotherLodePurgeResult} Immutable sweep result.\n */\nfunction FreezePurgeResult(frame, time, purgedKeys, payloadKeys, locked)\n{\n return Object.freeze({\n frame,\n time,\n purged: purgedKeys.length,\n payloadsReleased: payloadKeys.length,\n locked,\n purgedKeys: Object.freeze(purgedKeys),\n payloadKeys: Object.freeze(payloadKeys)\n });\n}\n\n/**\n * Freeze one byte-budget housekeeping result and its affected-key snapshots.\n *\n * @param {number} cacheSize Configured cache budget.\n * @param {number} beforeBytes Cached bytes before housekeeping.\n * @param {number} afterBytes Cached bytes after housekeeping.\n * @param {number} evictedBytes Successfully removed cached bytes.\n * @param {string[]} evictedKeys Successfully removed canonical identities.\n * @param {string[]} failedKeys Candidate identities that reported failure.\n * @returns {CjsMotherLodeCacheTrimResult} Immutable cache-housekeeping result.\n */\nfunction FreezeCacheTrimResult(\n cacheSize,\n beforeBytes,\n afterBytes,\n evictedBytes,\n evictedKeys,\n failedKeys\n)\n{\n return Object.freeze({\n cacheSize,\n beforeBytes,\n afterBytes,\n evictedBytes,\n overBudget: afterBytes > cacheSize,\n evicted: evictedKeys.length,\n failed: failedKeys.length,\n evictedKeys: Object.freeze(evictedKeys),\n failedKeys: Object.freeze(failedKeys)\n });\n}\n\nfunction MotherLodeInactiveError()\n{\n const error = new Error(\"CjsMotherLode is shut down. Call Startup() before inserting resources.\");\n error.code = \"CJS_MOTHERLODE_INACTIVE\";\n return error;\n}\n\nfunction MotherLodeCleanupError(operation, key, resource, cause)\n{\n const error = new Error(`CjsMotherLode ${operation} cleanup failed for ${key}.`, { cause });\n error.code = \"CJS_MOTHERLODE_CLEANUP_FAILED\";\n error.operation = operation;\n error.key = key;\n error.resource = resource;\n return error;\n}\n\nfunction GetKeyPath(key)\n{\n const separator = key.indexOf(\"\\u0000\");\n return separator === -1 ? key : key.slice(0, separator);\n}\n\nfunction DefaultNow()\n{\n return Date.now();\n}\n"],"names":["DEFAULT_CACHE_SIZE","MAX_SAFE_INTEGER_BIGINT","BigInt","Number","MAX_SAFE_INTEGER","CjsMotherLode","Map","DefaultNow","constructor","options","Array","isArray","TypeError","now","undefined","cacheSize","SetCacheSize","Startup","Shutdown","Clear","IsStarted","Insert","keyOrResource","resourceOrPath","optionsOrVariant","MotherLodeInactiveError","key","resource","NormalizeInsertArguments","AssertResource","existing","get","updated","Object","assign","FreezeInsertResult","replace","record","set","Boolean","ReplaceExpected","expected","resolvedKey","NormalizeResolvedKey","policy","NormalizeOptions","commitGuard","error","Error","code","FreezeConditionalReplaceResult","recordOptions","bytes","cacheable","cached","result","cause","AggregateError","HasKey","variant","has","NormalizeLookupKey","Lookup","Delete","variantOrOptions","maybeOptions","NormalizeDeleteArguments","delete","DeleteAllVariants","path","normalizedPath","NormalizePath","prefix","records","startsWith","push","length","values","clear","ClearCached","lockCount","KeepAlive","NormalizeActivityArguments","cacheSequence","KeepPayloadAlive","payloadLastUsedFrame","lastUsedFrame","payloadLastUsedTime","lastUsedTime","Lock","Unlock","PurgeInactive","NormalizePurgeOptions","Math","max","frame","purgedKeys","payloadKeys","errors","locked","IsInactive","time","maxIdleFrames","maxIdleMilliseconds","MarkPurged","MotherLodeCleanupError","releasePayload","HasOwnedPayload","payloadMaxIdleFrames","payloadMaxIdleMilliseconds","ReleasePayload","FreezePurgeResult","TrimCache","beforeBytes","evictedKeys","failedKeys","evictedBytes","candidates","filter","sort","a","b","afterBytes","FreezeCacheTrimResult","AssertNonNegativeSafeInteger","GetCacheSize","GetKeys","freeze","keys","GetValues","map","GetSize","size","GetStats","cacheBytes","payloads","paths","Set","states","GetPath","GetKeyPath","add","state","count","live","activityFrame","Entries","Symbol","iterator","Has","GetCount","DeleteAll","#CreateRecord","displaced","#UpdateRecord","#AssertRecordedBytesTotal","candidate","excluded","total","RangeError","#GetCacheBytes","#TouchRecord","isFinite","#CleanupRecord","operation","preserveOnFailure","cleanupComplete","CleanupOwnedResource","DetachResourceLifecycle","detachCause","#CleanupRecords","getMotherLodeKey","normalizedVariant","String","includes","isOptions","separator","indexOf","slice","normalizeResourcePath","AssertNonNegativeFiniteNumber","name","lastFrame","lastTime","maxFrames","maxMilliseconds","frameExpired","timeExpired","HasPayload","SetLifecycleController","cleanup","destroyAdapters","DestroyAdapterResources","destroy","value","label","isSafeInteger","inserted","replaced","committed","purged","payloadsReleased","overBudget","evicted","failed","Date"],"mappings":";;AAAA;AACA;AACA;AAGA,MAAMA,kBAAkB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI;AAC3C,MAAMC,uBAAuB,GAAGC,MAAM,CAACC,MAAM,CAACC,gBAAgB,CAAC;;AAE/D;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,aAAa,CAC1B;EAEE,OAAO,GAAG,KAAK;EACf,cAAc,GAAG,CAAC;EAClB,UAAU,GAAGL,kBAAkB;AAC/B,EAAA,QAAQ,GAAG,IAAIM,GAAG,EAAE;EACpB,kBAAkB,GAAG,CAAC;EACtB,IAAI,GAAGC,UAAU;;AAEjB;AACF;AACA;AACA;AACA;AACA;AACEC,EAAAA,WAAWA,CAACC,OAAO,GAAG,EAAE,EACxB;AACE,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