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AAM,CAAC,aAAa,CAAC,gBAAgB,CAAC,CAAC;gBACvC,aAAa,CAAC,IAAI,CAAC,gBAAgC,CAAC,CAAC;aACtD;YAED,UAAU,CAAC,mBAAmB,GAAG,IAAI,CAAC,mBAAmB,CAAC;YAC1D,UAAU,CAAC,OAAO,GAAG,aAAa,CAAC;QACrC,CAAC;KACF;IAED,OAAO,UAAU,CAAC;AACpB,CAAC;AArVD,sDAqVC;AAED;;;GAGG;AACH,WAAiB,qBAAqB;IACpC;;;;;;;;OAQG;IACH,SAAgB,aAAa,CAAC,OAAgB;QAC5C,OAAO,OAAO,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;IAC1C,CAAC;IAFe,mCAAa,gBAE5B,CAAA;AACH,CAAC,EAbgB,qBAAqB,GAArB,6BAAqB,KAArB,6BAAqB,QAarC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\n/* eslint-disable @typescript-eslint/no-redeclare */\n\nimport {\n ApiItem,\n apiItem_onParentChanged,\n type IApiItemJson,\n type IApiItemOptions,\n type IApiItemConstructor,\n ApiItemKind\n} from '../items/ApiItem';\nimport { ApiNameMixin } from './ApiNameMixin';\nimport type { DeserializerContext } from '../model/DeserializerContext';\nimport type { ApiModel } from '../model/ApiModel';\nimport type { ApiClass } from '../model/ApiClass';\nimport type { ApiInterface } from '../model/ApiInterface';\nimport { type ExcerptToken, ExcerptTokenKind } from './Excerpt';\nimport {\n type IFindApiItemsResult,\n type IFindApiItemsMessage,\n FindApiItemsMessageId\n} from './IFindApiItemsResult';\nimport { InternalError } from '@rushstack/node-core-library';\nimport type { DeclarationReference } from '@microsoft/tsdoc/lib-commonjs/beta/DeclarationReference';\nimport type { HeritageType } from '../model/HeritageType';\nimport type { IResolveDeclarationReferenceResult } from '../model/ModelReferenceResolver';\n\n/**\n * Constructor options for {@link (ApiItemContainerMixin:interface)}.\n * @public\n */\nexport interface IApiItemContainerMixinOptions extends IApiItemOptions {\n preserveMemberOrder?: boolean;\n members?: ApiItem[];\n}\n\nexport interface IApiItemContainerJson extends IApiItemJson {\n preserveMemberOrder?: boolean;\n members: IApiItemJson[];\n}\n\nconst _members: unique symbol = Symbol('ApiItemContainerMixin._members');\nconst _membersSorted: unique symbol = Symbol('ApiItemContainerMixin._membersSorted');\nconst _membersByContainerKey: unique symbol = Symbol('ApiItemContainerMixin._membersByContainerKey');\nconst _membersByName: unique symbol = Symbol('ApiItemContainerMixin._membersByName');\nconst _membersByKind: unique symbol = Symbol('ApiItemContainerMixin._membersByKind');\nconst _preserveMemberOrder: unique symbol = Symbol('ApiItemContainerMixin._preserveMemberOrder');\n\n/**\n * The mixin base class for API items that act as containers for other child items.\n *\n * @remarks\n *\n * This is part of the {@link ApiModel} hierarchy of classes, which are serializable representations of\n * API declarations. The non-abstract classes (e.g. `ApiClass`, `ApiEnum`, `ApiInterface`, etc.) use\n * TypeScript \"mixin\" functions (e.g. `ApiDeclaredItem`, `ApiItemContainerMixin`, etc.) to add various\n * features that cannot be represented as a normal inheritance chain (since TypeScript does not allow a child class\n * to extend more than one base class). The \"mixin\" is a TypeScript merged declaration with three components:\n * the function that generates a subclass, an interface that describes the members of the subclass, and\n * a namespace containing static members of the class.\n *\n * Examples of `ApiItemContainerMixin` child classes include `ApiModel`, `ApiPackage`, `ApiEntryPoint`,\n * and `ApiEnum`. But note that `Parameter` is not considered a \"member\" of an `ApiMethod`; this relationship\n * is modeled using {@link (ApiParameterListMixin:interface).parameters} instead\n * of {@link ApiItem.members}.\n *\n * @public\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport interface ApiItemContainerMixin extends ApiItem {\n /**\n * Disables automatic sorting of {@link ApiItem.members}.\n *\n * @remarks\n * By default `ApiItemContainerMixin` will automatically sort its members according to their\n * {@link ApiItem.getSortKey} string, which provides a standardized mostly alphabetical ordering\n * that is appropriate for most API items. When loading older .api.json files the automatic sorting\n * is reapplied and may update the ordering.\n *\n * Set `preserveMemberOrder` to true to disable automatic sorting for this container; instead, the\n * members will retain whatever ordering appeared in the {@link IApiItemContainerMixinOptions.members} array.\n * The `preserveMemberOrder` option is saved in the .api.json file.\n */\n readonly preserveMemberOrder: boolean;\n\n /**\n * Adds a new member to the container.\n *\n * @remarks\n * An ApiItem cannot be added to more than one container.\n */\n addMember(member: ApiItem): void;\n\n /**\n * Attempts to retrieve a member using its containerKey, or returns `undefined` if no matching member was found.\n *\n * @remarks\n * Use the `getContainerKey()` static member to construct the key. Each subclass has a different implementation\n * of this function, according to the aspects that are important for identifying it.\n *\n * See {@link ApiItem.containerKey} for more information.\n */\n tryGetMemberByKey(containerKey: string): ApiItem | undefined;\n\n /**\n * Returns a list of members with the specified name.\n */\n findMembersByName(name: string): ReadonlyArray;\n\n /**\n * Finds all of the ApiItem's immediate and inherited members by walking up the inheritance tree.\n *\n * @remarks\n *\n * Given the following class heritage:\n *\n * ```\n * export class A {\n * public a: number|boolean;\n * }\n *\n * export class B extends A {\n * public a: number;\n * public b: string;\n * }\n *\n * export class C extends B {\n * public c: boolean;\n * }\n * ```\n *\n * Calling `findMembersWithInheritance` on `C` will return `B.a`, `B.b`, and `C.c`. Calling the\n * method on `B` will return `B.a` and `B.b`. And calling the method on `A` will return just\n * `A.a`.\n *\n * The inherited members returned by this method may be incomplete. If so, there will be a flag\n * on the result object indicating this as well as messages explaining the errors in more detail.\n * Some scenarios include:\n *\n * - Interface extending from a type alias.\n *\n * - Class extending from a variable.\n *\n * - Extending from a declaration not present in the model (e.g. external package).\n *\n * - Extending from an unexported declaration (e.g. ae-forgotten-export). Common in mixin\n * patterns.\n *\n * - Unexpected runtime errors...\n *\n * Lastly, be aware that the types of inherited members are returned with respect to their\n * defining class as opposed to with respect to the inheriting class. For example, consider\n * the following:\n *\n * ```\n * export class A {\n * public a: T;\n * }\n *\n * export class B extends A {}\n * ```\n *\n * When called on `B`, this method will return `B.a` with type `T` as opposed to type\n * `number`, although the latter is more accurate.\n */\n findMembersWithInheritance(): IFindApiItemsResult;\n\n /**\n * For a given member of this container, return its `ApiItem.getMergedSiblings()` list.\n * @internal\n */\n _getMergedSiblingsForMember(memberApiItem: ApiItem): ReadonlyArray;\n\n /** @override */\n serializeInto(jsonObject: Partial): void;\n}\n\n/**\n * Mixin function for {@link ApiDeclaredItem}.\n *\n * @param baseClass - The base class to be extended\n * @returns A child class that extends baseClass, adding the {@link (ApiItemContainerMixin:interface)} functionality.\n *\n * @public\n */\nexport function ApiItemContainerMixin(\n baseClass: TBaseClass\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): TBaseClass & (new (...args: any[]) => ApiItemContainerMixin) {\n class MixedClass extends baseClass implements ApiItemContainerMixin {\n public readonly [_members]: ApiItem[];\n public [_membersSorted]: boolean;\n public [_membersByContainerKey]: Map;\n public [_preserveMemberOrder]: boolean;\n\n // For members of this container that extend ApiNameMixin, this stores the list of members with a given name.\n // Examples include merged declarations, overloaded functions, etc.\n public [_membersByName]: Map | undefined;\n\n // For members of this container that do NOT extend ApiNameMixin, this stores the list of members\n // that share a common ApiItemKind. Examples include overloaded constructors or index signatures.\n public [_membersByKind]: Map | undefined; // key is ApiItemKind\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n public constructor(...args: any[]) {\n super(...args);\n const options: IApiItemContainerMixinOptions = args[0] as IApiItemContainerMixinOptions;\n\n this[_members] = [];\n this[_membersSorted] = false;\n this[_membersByContainerKey] = new Map();\n this[_preserveMemberOrder] = options.preserveMemberOrder ?? false;\n\n if (options.members) {\n for (const member of options.members) {\n this.addMember(member);\n }\n }\n }\n\n /** @override */\n public static onDeserializeInto(\n options: Partial,\n context: DeserializerContext,\n jsonObject: IApiItemContainerJson\n ): void {\n baseClass.onDeserializeInto(options, context, jsonObject);\n options.preserveMemberOrder = jsonObject.preserveMemberOrder;\n options.members = [];\n for (const memberObject of jsonObject.members) {\n options.members.push(ApiItem.deserialize(memberObject, context));\n }\n }\n\n /** @override */\n public get members(): ReadonlyArray {\n if (!this[_membersSorted] && !this[_preserveMemberOrder]) {\n this[_members].sort((x, y) => x.getSortKey().localeCompare(y.getSortKey()));\n this[_membersSorted] = true;\n }\n\n return this[_members];\n }\n\n public get preserveMemberOrder(): boolean {\n return this[_preserveMemberOrder];\n }\n\n public addMember(member: ApiItem): void {\n if (this[_membersByContainerKey].has(member.containerKey)) {\n throw new Error(\n `Another member has already been added with the same name (${member.displayName})` +\n ` and containerKey (${member.containerKey})`\n );\n }\n\n const existingParent: ApiItem | undefined = member.parent;\n if (existingParent !== undefined) {\n throw new Error(\n `This item has already been added to another container: \"${existingParent.displayName}\"`\n );\n }\n\n this[_members].push(member);\n this[_membersByName] = undefined; // invalidate the lookup\n this[_membersByKind] = undefined; // invalidate the lookup\n this[_membersSorted] = false;\n this[_membersByContainerKey].set(member.containerKey, member);\n\n member[apiItem_onParentChanged](this);\n }\n\n public tryGetMemberByKey(containerKey: string): ApiItem | undefined {\n return this[_membersByContainerKey].get(containerKey);\n }\n\n public findMembersByName(name: string): ReadonlyArray {\n this._ensureMemberMaps();\n return this[_membersByName]!.get(name) || [];\n }\n\n public findMembersWithInheritance(): IFindApiItemsResult {\n const messages: IFindApiItemsMessage[] = [];\n let maybeIncompleteResult: boolean = false;\n\n // For API items that don't support inheritance, this method just returns the item's\n // immediate members.\n switch (this.kind) {\n case ApiItemKind.Class:\n case ApiItemKind.Interface:\n break;\n default: {\n return {\n items: this.members.concat(),\n messages,\n maybeIncompleteResult\n };\n }\n }\n\n const membersByName: Map = new Map();\n const membersByKind: Map = new Map();\n\n const toVisit: ApiItem[] = [];\n let next: ApiItem | undefined = this;\n\n while (next) {\n const membersToAdd: ApiItem[] = [];\n\n // For each member, check to see if we've already seen a member with the same name\n // previously in the inheritance tree. If so, we know we won't inherit it, and thus\n // do not add it to our `membersToAdd` array.\n for (const member of next.members) {\n // We add the to-be-added members to an intermediate array instead of immediately\n // to the maps themselves to support method overloads with the same name.\n if (ApiNameMixin.isBaseClassOf(member)) {\n if (!membersByName.has(member.name)) {\n membersToAdd.push(member);\n }\n } else {\n if (!membersByKind.has(member.kind)) {\n membersToAdd.push(member);\n }\n }\n }\n\n for (const member of membersToAdd) {\n if (ApiNameMixin.isBaseClassOf(member)) {\n const members: ApiItem[] = membersByName.get(member.name) || [];\n members.push(member);\n membersByName.set(member.name, members);\n } else {\n const members: ApiItem[] = membersByKind.get(member.kind) || [];\n members.push(member);\n membersByKind.set(member.kind, members);\n }\n }\n\n // Interfaces can extend multiple interfaces, so iterate through all of them.\n const extendedItems: ApiItem[] = [];\n let extendsTypes: readonly HeritageType[] | undefined;\n\n switch (next.kind) {\n case ApiItemKind.Class: {\n const apiClass: ApiClass = next as ApiClass;\n extendsTypes = apiClass.extendsType ? [apiClass.extendsType] : [];\n break;\n }\n case ApiItemKind.Interface: {\n const apiInterface: ApiInterface = next as ApiInterface;\n extendsTypes = apiInterface.extendsTypes;\n break;\n }\n }\n\n if (extendsTypes === undefined) {\n messages.push({\n messageId: FindApiItemsMessageId.UnsupportedKind,\n text: `Unable to analyze references of API item ${next.displayName} because it is of unsupported kind ${next.kind}`\n });\n maybeIncompleteResult = true;\n next = toVisit.shift();\n continue;\n }\n\n for (const extendsType of extendsTypes) {\n // We want to find the reference token associated with the actual inherited declaration.\n // In every case we support, this is the first reference token. For example:\n //\n // ```\n // export class A extends B {}\n // ^\n // export class A extends B {}\n // ^\n // export class A extends B.C {}\n // ^^^\n // ```\n const firstReferenceToken: ExcerptToken | undefined = extendsType.excerpt.spannedTokens.find(\n (token: ExcerptToken) => {\n return token.kind === ExcerptTokenKind.Reference && token.canonicalReference;\n }\n );\n\n if (!firstReferenceToken) {\n messages.push({\n messageId: FindApiItemsMessageId.ExtendsClauseMissingReference,\n text: `Unable to analyze extends clause ${extendsType.excerpt.text} of API item ${next.displayName} because no canonical reference was found`\n });\n maybeIncompleteResult = true;\n continue;\n }\n\n const apiModel: ApiModel | undefined = this.getAssociatedModel();\n if (!apiModel) {\n messages.push({\n messageId: FindApiItemsMessageId.NoAssociatedApiModel,\n text: `Unable to analyze references of API item ${next.displayName} because it is not associated with an ApiModel`\n });\n maybeIncompleteResult = true;\n continue;\n }\n\n const canonicalReference: DeclarationReference = firstReferenceToken.canonicalReference!;\n const apiItemResult: IResolveDeclarationReferenceResult = apiModel.resolveDeclarationReference(\n canonicalReference,\n undefined\n );\n\n const apiItem: ApiItem | undefined = apiItemResult.resolvedApiItem;\n if (!apiItem) {\n messages.push({\n messageId: FindApiItemsMessageId.DeclarationResolutionFailed,\n text: `Unable to resolve declaration reference within API item ${next.displayName}: ${apiItemResult.errorMessage}`\n });\n maybeIncompleteResult = true;\n continue;\n }\n\n extendedItems.push(apiItem);\n }\n\n // For classes, this array will only have one item. For interfaces, there may be multiple items. Sort the array\n // into alphabetical order before adding to our list of API items to visit. This ensures that in the case\n // of multiple interface inheritance, a member inherited from multiple interfaces is attributed to the interface\n // earlier in alphabetical order (as opposed to source order).\n //\n // For example, in the code block below, `Bar.x` is reported as the inherited item, not `Foo.x`.\n //\n // ```\n // interface Foo {\n // public x: string;\n // }\n //\n // interface Bar {\n // public x: string;\n // }\n //\n // interface FooBar extends Foo, Bar {}\n // ```\n extendedItems.sort((x: ApiItem, y: ApiItem) => x.getSortKey().localeCompare(y.getSortKey()));\n\n toVisit.push(...extendedItems);\n next = toVisit.shift();\n }\n\n const items: ApiItem[] = [];\n for (const members of membersByName.values()) {\n items.push(...members);\n }\n for (const members of membersByKind.values()) {\n items.push(...members);\n }\n items.sort((x: ApiItem, y: ApiItem) => x.getSortKey().localeCompare(y.getSortKey()));\n\n return {\n items,\n messages,\n maybeIncompleteResult\n };\n }\n\n /** @internal */\n public _getMergedSiblingsForMember(memberApiItem: ApiItem): ReadonlyArray {\n this._ensureMemberMaps();\n let result: ApiItem[] | undefined;\n if (ApiNameMixin.isBaseClassOf(memberApiItem)) {\n result = this[_membersByName]!.get(memberApiItem.name);\n } else {\n result = this[_membersByKind]!.get(memberApiItem.kind);\n }\n if (!result) {\n throw new InternalError('Item was not found in the _membersByName/_membersByKind lookup');\n }\n return result;\n }\n\n /** @internal */\n public _ensureMemberMaps(): void {\n // Build the _membersByName and _membersByKind tables if they don't already exist\n if (this[_membersByName] === undefined) {\n const membersByName: Map = new Map();\n const membersByKind: Map = new Map();\n\n for (const member of this[_members]) {\n let map: Map | Map;\n let key: string | ApiItemKind;\n\n if (ApiNameMixin.isBaseClassOf(member)) {\n map = membersByName;\n key = member.name;\n } else {\n map = membersByKind;\n key = member.kind;\n }\n\n let list: ApiItem[] | undefined = map.get(key);\n if (list === undefined) {\n list = [];\n map.set(key, list);\n }\n list.push(member);\n }\n\n this[_membersByName] = membersByName;\n this[_membersByKind] = membersByKind;\n }\n }\n\n /** @override */\n public serializeInto(jsonObject: Partial): void {\n super.serializeInto(jsonObject);\n\n const memberObjects: IApiItemJson[] = [];\n\n for (const member of this.members) {\n const memberJsonObject: Partial = {};\n member.serializeInto(memberJsonObject);\n memberObjects.push(memberJsonObject as IApiItemJson);\n }\n\n jsonObject.preserveMemberOrder = this.preserveMemberOrder;\n jsonObject.members = memberObjects;\n }\n }\n\n return MixedClass;\n}\n\n/**\n * Static members for {@link (ApiItemContainerMixin:interface)}.\n * @public\n */\nexport namespace ApiItemContainerMixin {\n /**\n * A type guard that tests whether the specified `ApiItem` subclass extends the `ApiItemContainerMixin` mixin.\n *\n * @remarks\n *\n * The JavaScript `instanceof` operator cannot be used to test for mixin inheritance, because each invocation of\n * the mixin function produces a different subclass. (This could be mitigated by `Symbol.hasInstance`, however\n * the TypeScript type system cannot invoke a runtime test.)\n */\n export function isBaseClassOf(apiItem: ApiItem): apiItem is ApiItemContainerMixin {\n return apiItem.hasOwnProperty(_members);\n }\n}\n"]}