{"version":3,"names":["_index","require","getBindingIdentifiers","node","duplicates","outerOnly","newBindingsOnly","search","concat","ids","Object","create","length","id","shift","isAssignmentExpression","isUnaryExpression","isUpdateExpression","isIdentifier","_ids","name","push","isExportDeclaration","isExportAllDeclaration","isDeclaration","declaration","isFunctionDeclaration","isFunctionExpression","keys","type","i","key","nodes","Array","isArray","DeclareClass","DeclareFunction","DeclareModule","DeclareVariable","DeclareInterface","DeclareTypeAlias","DeclareOpaqueType","InterfaceDeclaration","TypeAlias","OpaqueType","CatchClause","LabeledStatement","UnaryExpression","AssignmentExpression","ImportSpecifier","ImportNamespaceSpecifier","ImportDefaultSpecifier","ImportDeclaration","ExportSpecifier","ExportNamespaceSpecifier","ExportDefaultSpecifier","FunctionDeclaration","FunctionExpression","ArrowFunctionExpression","ObjectMethod","ClassMethod","ClassPrivateMethod","ForInStatement","ForOfStatement","ClassDeclaration","ClassExpression","RestElement","UpdateExpression","ObjectProperty","AssignmentPattern","ArrayPattern","ObjectPattern","VariableDeclaration","VariableDeclarator"],"sources":["../../src/retrievers/getBindingIdentifiers.ts"],"sourcesContent":["import {\n isExportDeclaration,\n isIdentifier,\n isClassExpression,\n isDeclaration,\n isFunctionDeclaration,\n isFunctionExpression,\n isExportAllDeclaration,\n isAssignmentExpression,\n isUnaryExpression,\n isUpdateExpression,\n} from \"../validators/generated/index.ts\";\nimport type * as t from \"../index.ts\";\n\nexport { getBindingIdentifiers as default };\n\nfunction getBindingIdentifiers(\n node: t.Node,\n duplicates: true,\n outerOnly?: boolean,\n newBindingsOnly?: boolean,\n): Record>;\n\nfunction getBindingIdentifiers(\n node: t.Node,\n duplicates?: false,\n outerOnly?: boolean,\n newBindingsOnly?: boolean,\n): Record;\n\nfunction getBindingIdentifiers(\n node: t.Node,\n duplicates?: boolean,\n outerOnly?: boolean,\n newBindingsOnly?: boolean,\n): Record | Record>;\n\n/**\n * Return a list of binding identifiers associated with the input `node`.\n */\nfunction getBindingIdentifiers(\n node: t.Node,\n duplicates?: boolean,\n outerOnly?: boolean,\n newBindingsOnly?: boolean,\n): Record | Record> {\n const search: t.Node[] = [].concat(node);\n const ids = Object.create(null);\n\n while (search.length) {\n const id = search.shift();\n if (!id) continue;\n\n if (\n newBindingsOnly &&\n // These nodes do not introduce _new_ bindings, but they are included\n // in getBindingIdentifiers.keys for backwards compatibility.\n // TODO(@nicolo-ribaudo): Check if we can remove them from .keys in a\n // backward-compatible way, and if not what we need to do to remove them\n // in Babel 8.\n (isAssignmentExpression(id) ||\n isUnaryExpression(id) ||\n isUpdateExpression(id))\n ) {\n continue;\n }\n\n if (isIdentifier(id)) {\n if (duplicates) {\n const _ids = (ids[id.name] = ids[id.name] || []);\n _ids.push(id);\n } else {\n ids[id.name] = id;\n }\n continue;\n }\n\n if (isExportDeclaration(id) && !isExportAllDeclaration(id)) {\n if (isDeclaration(id.declaration)) {\n search.push(id.declaration);\n }\n continue;\n }\n\n if (outerOnly) {\n if (isFunctionDeclaration(id)) {\n search.push(id.id);\n continue;\n }\n\n if (\n isFunctionExpression(id) ||\n (process.env.BABEL_8_BREAKING && isClassExpression(id))\n ) {\n continue;\n }\n }\n\n const keys =\n // @ts-expect-error getBindingIdentifiers.keys do not cover all AST types\n getBindingIdentifiers.keys[id.type];\n\n if (keys) {\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i];\n const nodes =\n // @ts-expect-error key must present in id\n id[key] as t.Node[] | t.Node | undefined | null;\n if (nodes) {\n Array.isArray(nodes) ? search.push(...nodes) : search.push(nodes);\n }\n }\n }\n }\n return ids;\n}\n\n/**\n * Mapping of types to their identifier keys.\n */\ngetBindingIdentifiers.keys = {\n DeclareClass: [\"id\"],\n DeclareFunction: [\"id\"],\n DeclareModule: [\"id\"],\n DeclareVariable: [\"id\"],\n DeclareInterface: [\"id\"],\n DeclareTypeAlias: [\"id\"],\n DeclareOpaqueType: [\"id\"],\n InterfaceDeclaration: [\"id\"],\n TypeAlias: [\"id\"],\n OpaqueType: [\"id\"],\n\n CatchClause: [\"param\"],\n LabeledStatement: [\"label\"],\n UnaryExpression: [\"argument\"],\n AssignmentExpression: [\"left\"],\n\n ImportSpecifier: [\"local\"],\n ImportNamespaceSpecifier: [\"local\"],\n ImportDefaultSpecifier: [\"local\"],\n ImportDeclaration: [\"specifiers\"],\n\n ExportSpecifier: [\"exported\"],\n ExportNamespaceSpecifier: [\"exported\"],\n ExportDefaultSpecifier: [\"exported\"],\n\n FunctionDeclaration: [\"id\", \"params\"],\n FunctionExpression: [\"id\", \"params\"],\n ArrowFunctionExpression: [\"params\"],\n ObjectMethod: [\"params\"],\n ClassMethod: [\"params\"],\n ClassPrivateMethod: [\"params\"],\n\n ForInStatement: [\"left\"],\n ForOfStatement: [\"left\"],\n\n ClassDeclaration: [\"id\"],\n ClassExpression: [\"id\"],\n\n RestElement: [\"argument\"],\n UpdateExpression: [\"argument\"],\n\n ObjectProperty: [\"value\"],\n\n AssignmentPattern: [\"left\"],\n ArrayPattern: [\"elements\"],\n ObjectPattern: [\"properties\"],\n\n VariableDeclaration: [\"declarations\"],\n VariableDeclarator: [\"id\"],\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAwCA,SAASC,qBAAqBA,CAC5BC,IAAY,EACZC,UAAoB,EACpBC,SAAmB,EACnBC,eAAyB,EAC2C;EACpE,MAAMC,MAAgB,GAAG,EAAE,CAACC,MAAM,CAACL,IAAI,CAAC;EACxC,MAAMM,GAAG,GAAGC,MAAM,CAACC,MAAM,CAAC,IAAI,CAAC;EAE/B,OAAOJ,MAAM,CAACK,MAAM,EAAE;IACpB,MAAMC,EAAE,GAAGN,MAAM,CAACO,KAAK,CAAC,CAAC;IACzB,IAAI,CAACD,EAAE,EAAE;IAET,IACEP,eAAe,KAMd,IAAAS,6BAAsB,EAACF,EAAE,CAAC,IACzB,IAAAG,wBAAiB,EAACH,EAAE,CAAC,IACrB,IAAAI,yBAAkB,EAACJ,EAAE,CAAC,CAAC,EACzB;MACA;IACF;IAEA,IAAI,I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