'use strict';
import { getVariableInScope } from '@flint/infra/analysis/expression-analysis';
import { nodeTypes } from '@flint/infra/analysis/function-analysis';
import { isIdentifier } from '@flint/infra/analysis/node-type-type-guards';
import { flintRuleIdentifiers } from '@flint/infra/constants/shared-string-identifiers';
import { isNameMatch } from '@flint/infra/analysis/name-analysis';
import { flintConstants } from '@flint/infra/constants/rules-meta';
import { runtimeConstructors } from '../../../base-repo/constants/runtime-constants.js';
import _0x2de5a4__default, { TypeFlags, ObjectFlags } from 'typescript';

var __defProp=Object['defineProperty'],__name=(_0x19b8bb,_0x193243)=>__defProp(_0x19b8bb,'name',{'value':_0x193243,'configurable':!![]});const reactComponentTypeNames={'functionComponent':'FC'};function isStringTypeNode(_0x54c65c,_0x4cf4bd){const _0x111e03=_0x4cf4bd['tsNodeMap']['get'](_0x54c65c['object']);if(!_0x111e03)return ![];const _0x21f750=_0x4cf4bd['checker']['getTypeAtLocation'](_0x111e03);return (_0x21f750['flags']&_0x2de5a4__default['TypeFlags']['StringLike'])!==0x4*-0x67d+0x1051+0x9a3;}__name(isStringTypeNode,'isStringTypeNode');function getNodeTsType(_0x30c1b6,_0x2e25ca){return _0x2e25ca['program']['getTypeChecker']()['getTypeAtLocation'](_0x2e25ca['esTreeNodeToTSNodeMap']['get'](_0x30c1b6));}__name(getNodeTsType,'getNodeTsType');function forEachUnionTypedParam(_0x3116b9,_0x3b0533){for(const _0x73ca1f of _0x3116b9){if(_0x73ca1f['type']===nodeTypes['identifier']){const _0x281da0=_0x73ca1f['typeAnnotation'];if(_0x281da0&&_0x281da0['type']===nodeTypes['TSTypeAnnotation']){const _0x3a09ad=_0x281da0['typeAnnotation'];_0x3a09ad['type']===nodeTypes['TSUnionType']&&_0x3b0533(_0x73ca1f,_0x3a09ad);}}}}__name(forEachUnionTypedParam,'forEachUnionTypedParam');function hasReactFCTypeAnnotation(_0x3b320){if(_0x3b320['parent']?.['type']!==nodeTypes['variableDeclarator'])return ![];const _0x3f1a27=_0x3b320['parent']['id'];if(_0x3f1a27['typeAnnotation']?.['typeAnnotation'])return isReactFCType(_0x3f1a27['typeAnnotation']['typeAnnotation']);return ![];}__name(hasReactFCTypeAnnotation,'hasReactFCTypeAnnotation');function getTypeAnnotation(_0x3fc6d1){if(!hasTypeAnnotation(_0x3fc6d1))return void(-0x92f+0x1*0x2657+-0x1d28);return _0x3fc6d1['typeAnnotation'];}__name(getTypeAnnotation,'getTypeAnnotation');function identifierHasNullishType(_0x2213ab){if(!isIdentifier(_0x2213ab)||!_0x2213ab['typeAnnotation'])return ![];const _0x1e4a2a=_0x2213ab['typeAnnotation'];if(_0x1e4a2a['type']!==nodeTypes['TSTypeAnnotation'])return ![];return isTypeNullish(_0x1e4a2a['typeAnnotation']);}__name(identifierHasNullishType,'identifierHasNullishType');function isPropertyAMethod(_0x3a3781,_0x5656e3,_0x5c1050){const _0x4760b1=_0x5c1050['tsNodeMap']['get'](_0x3a3781);if(!_0x4760b1)return ![];const _0x394761=_0x5c1050['checker']['getTypeAtLocation'](_0x4760b1),_0x5ccee2=_0x5c1050['checker']['getPropertyOfType'](_0x394761,_0x5656e3);if(_0x5ccee2){const _0x57da8a=_0x5c1050['checker']['getTypeOfSymbolAtLocation'](_0x5ccee2,_0x4760b1);if(_0x57da8a['getCallSignatures']()['length']>-0x17b5+-0x188e+0x7*0x6e5)return !![];}return ![];}__name(isPropertyAMethod,'isPropertyAMethod');function isTypeNullish(_0x43bb4e){if(_0x43bb4e['type']===nodeTypes['TSNullKeyword']||_0x43bb4e['type']===nodeTypes['TSUndefinedKeyword'])return !![];if(_0x43bb4e['type']===nodeTypes['TSUnionType'])return _0x43bb4e['types']['some'](_0x65e0e4=>_0x65e0e4['type']===nodeTypes['TSNullKeyword']||_0x65e0e4['type']===nodeTypes['TSUndefinedKeyword']||_0x65e0e4['type']===nodeTypes['TSLiteralType']&&_0x65e0e4['literal']['type']===nodeTypes['literal']&&_0x65e0e4['literal']['value']===null);return ![];}__name(isTypeNullish,'isTypeNullish');function isNamedDeclaration(_0x12b93f){return _0x2de5a4__default['isInterfaceDeclaration'](_0x12b93f)||_0x2de5a4__default['isClassDeclaration'](_0x12b93f)||_0x2de5a4__default['isTypeAliasDeclaration'](_0x12b93f)||_0x2de5a4__default['isEnumDeclaration'](_0x12b93f);}__name(isNamedDeclaration,'isNamedDeclaration');function isDefinitelyNotNullable(_0x1ccc16,_0x53a032=![]){let _0x555209=![];if(!_0x53a032&&_0x1ccc16){const _0x4516ac=_0x1ccc16['typeAnnotation'];_0x4516ac['type']===nodeTypes['TSUnionType']?_0x555209=!_0x4516ac['types']['some'](_0x51847b=>_0x51847b['type']===nodeTypes['TSNullKeyword']||_0x51847b['type']===nodeTypes['TSUndefinedKeyword']):_0x555209=_0x4516ac['type']!==nodeTypes['TSNullKeyword']&&_0x4516ac['type']!==nodeTypes['TSUndefinedKeyword'];}return _0x555209;}__name(isDefinitelyNotNullable,'isDefinitelyNotNullable');function isInTypePosition(_0x587c25){let _0x1778e5=_0x587c25['parent'],_0x5dd13c=![];while(_0x1778e5){if(_0x1778e5['type']===nodeTypes['TSTypeQuery']||_0x1778e5['type']===nodeTypes['TSQualifiedName']){_0x5dd13c=!![];break;}if(_0x1778e5['type']===nodeTypes['program'])break;_0x1778e5=_0x1778e5['parent'];}return _0x5dd13c;}__name(isInTypePosition,'isInTypePosition');function getRootTSType(_0x327448){if(_0x327448['parent']&&(_0x327448['parent']['type']===nodeTypes['TSTypeAnnotation']||_0x327448['parent']['type']===nodeTypes['TSIndexedAccessType']))return getRootTSType(_0x327448['parent']);return _0x327448;}__name(getRootTSType,'getRootTSType');function getVariableDefinitionsInScope(_0x158be0,_0x1a05c0,_0x41c38c,_0x19ad37=!![]){const _0x36680b=getVariableInScope(_0x158be0,_0x1a05c0,_0x41c38c,_0x19ad37);return _0x36680b&&Array['isArray'](_0x36680b['defs'])?_0x36680b['defs']:[];}__name(getVariableDefinitionsInScope,'getVariableDefinitionsInScope');function isReactFCType(_0x559b04){if(!_0x559b04)return ![];if(_0x559b04['type']===nodeTypes['TSTypeReference']){const _0x46bd1f=_0x559b04['typeName'];if(_0x46bd1f['type']===nodeTypes['TSQualifiedName']&&_0x46bd1f['left']['type']===nodeTypes['identifier']&&isNameMatch(_0x46bd1f['left'],flintConstants['react'])&&_0x46bd1f['right']['type']===nodeTypes['identifier']&&isNameMatch(_0x46bd1f['right'],reactComponentTypeNames['functionComponent'])||_0x46bd1f['type']===nodeTypes['identifier']&&isNameMatch(_0x46bd1f,reactComponentTypeNames['functionComponent']))return !![];}return ![];}__name(isReactFCType,'isReactFCType');function isObjectType(_0x9491d9){return (_0x9491d9['flags']&TypeFlags['Object'])!==-0x3da+0xfc6+-0x6d*0x1c;}__name(isObjectType,'isObjectType');function isTupleType(_0x77dc0f){return 'target'in _0x77dc0f&&!!_0x77dc0f['target']&&typeof _0x77dc0f['target']==='object'&&'objectFlags'in _0x77dc0f['target']&&typeof _0x77dc0f['target']['objectFlags']==='number'&&(_0x77dc0f['target']['objectFlags']&ObjectFlags['Tuple'])!==-0xc76+0x19*0x187+-0x19b9*0x1;}__name(isTupleType,'isTupleType');function isArrayType(_0x5b6676){return _0x5b6676['symbol']&&(_0x5b6676['symbol']['name']===runtimeConstructors['array']||_0x5b6676['symbol']['name']===runtimeConstructors['readonlyArray']);}__name(isArrayType,'isArrayType');function getPropertySignatureCount(_0x40ef23){return _0x40ef23['filter'](_0x5d3d4e=>_0x5d3d4e['type']===nodeTypes['TSPropertySignature'])['length'];}__name(getPropertySignatureCount,'getPropertySignatureCount');function hasTypeAnnotation(_0x522150){return flintRuleIdentifiers['typeAnnotation']in _0x522150;}__name(hasTypeAnnotation,'hasTypeAnnotation');

export { forEachUnionTypedParam, getNodeTsType, getPropertySignatureCount, getRootTSType, getTypeAnnotation, getVariableDefinitionsInScope, hasReactFCTypeAnnotation, identifierHasNullishType, isArrayType, isDefinitelyNotNullable, isInTypePosition, isNamedDeclaration, isObjectType, isPropertyAMethod, isReactFCType, isStringTypeNode, isTupleType, isTypeNullish, reactComponentTypeNames };
