'use strict';
import { nodeTypes } from '@flint/infra/analysis/function-analysis';
import { getNodeTsType } from '@flint/infra/analysis/type-analysis';
import { flintRuleIdentifiers } from '@flint/infra/constants/shared-string-identifiers';
import { isMemberCallExpression } from '@flint/infra/analysis/node-type-type-guards';
import { getPropertyName } from '@flint/infra/analysis/name-analysis';
import _0x2de5a4__default from 'typescript';
import { runtimeConstructors } from '../../../base-repo/constants/runtime-constants.js';
import { collectionMethodNames } from '../../../base-repo/constants/internal-common-strings.js';

var __defProp=Object['defineProperty'],__name=(_0x20b2f2,_0x486456)=>__defProp(_0x20b2f2,'name',{'value':_0x486456,'configurable':!![]});function isLengthUsedInTestContext(_0x4c3ca0){const _0x2b8fff=_0x4c3ca0['parent'];return _0x2b8fff?.['type']===nodeTypes['ifStatement']&&_0x2b8fff['test']===_0x4c3ca0||_0x2b8fff?.['type']===nodeTypes['conditionalExpression']&&_0x2b8fff['test']===_0x4c3ca0||_0x2b8fff?.['type']===nodeTypes['whileStatement']&&_0x2b8fff['test']===_0x4c3ca0||_0x2b8fff?.['type']===nodeTypes['doWhileStatement']&&_0x2b8fff['test']===_0x4c3ca0||_0x2b8fff?.['type']===nodeTypes['forStatement']&&_0x2b8fff['test']===_0x4c3ca0;}__name(isLengthUsedInTestContext,'isLengthUsedInTestContext');function isLengthNegated(_0x1467b7){const _0xeaee48=_0x1467b7['parent'];return _0xeaee48?.['type']===nodeTypes['unaryExpression']&&_0xeaee48['operator']==='!'&&flintRuleIdentifiers['argument']in _0xeaee48&&_0xeaee48['argument']===_0x1467b7;}__name(isLengthNegated,'isLengthNegated');function isLengthInLogicalExpression(_0x26364c){const _0x2b2d5b=_0x26364c['parent'];return _0x2b2d5b?.['type']===nodeTypes['logicalExpression']&&(_0x2b2d5b['left']===_0x26364c||_0x2b2d5b['right']===_0x26364c);}__name(isLengthInLogicalExpression,'isLengthInLogicalExpression');function normalizeNodes(_0x51e8de){return _0x51e8de['map'](_0x49e93b=>_0x49e93b??void(0x7cf+-0x2393+0x1bc4));}__name(normalizeNodes,'normalizeNodes');function isArrayLikeTypeNode(_0x4bfad0,_0x108dc3){const _0x477b94=getNodeTsType(_0x4bfad0,_0x108dc3);return _0x108dc3['program']['getTypeChecker']()['isArrayLikeType'](_0x477b94)&&(_0x477b94['flags']&_0x2de5a4__default['TypeFlags']['Any'])===-0x1b44+-0x23d8+0x3f1c;}__name(isArrayLikeTypeNode,'isArrayLikeTypeNode');function isArrayMethodCallExpression(_0x535f02,_0x4262b5,_0x43fafe){if(!isMemberCallExpression(_0x535f02)||!isArrayLikeTypeNode(_0x535f02['callee']['object'],_0x4262b5))return ![];const _0x63dded=getPropertyName(_0x535f02['callee']);return !!_0x63dded&&_0x43fafe['includes'](_0x63dded);}__name(isArrayMethodCallExpression,'isArrayMethodCallExpression');function isCopiedArray(_0x4e8e50){let _0x18a90a=![];return _0x4e8e50['type']===nodeTypes['arrayExpression']&&(_0x18a90a=hasSpreadElement(_0x4e8e50['elements'])),_0x4e8e50['type']===nodeTypes['callExpression']&&(_0x18a90a=isCopyMethodCall(_0x4e8e50['callee'])),_0x18a90a;}__name(isCopiedArray,'isCopiedArray');function hasSpreadElement(_0x248017){return _0x248017['some'](_0x22c6ea=>_0x22c6ea&&_0x22c6ea['type']===nodeTypes['spreadElement']);}__name(hasSpreadElement,'hasSpreadElement');function isStaticCopyMethod(_0x1b3cd7){return _0x1b3cd7['object']['type']===nodeTypes['identifier']&&_0x1b3cd7['object']['name']===runtimeConstructors['array']&&_0x1b3cd7['property']['type']===nodeTypes['identifier']&&_0x1b3cd7['property']['name']===collectionMethodNames['from'];}__name(isStaticCopyMethod,'isStaticCopyMethod');function isInstanceCopyMethod(_0x32069d){if(_0x32069d['property']['type']!==nodeTypes['identifier'])return ![];const _0x19c224=_0x32069d['property']['name'];return _0x19c224===collectionMethodNames['slice']||_0x19c224===collectionMethodNames['concat'];}__name(isInstanceCopyMethod,'isInstanceCopyMethod');function isCopyMethodCall(_0x2f4aba){if(_0x2f4aba['type']===nodeTypes['identifier']&&_0x2f4aba['name']==='structuredClone')return !![];if(_0x2f4aba['type']!==nodeTypes['memberExpression'])return ![];return isStaticCopyMethod(_0x2f4aba)||isInstanceCopyMethod(_0x2f4aba);}__name(isCopyMethodCall,'isCopyMethodCall');

export { isArrayLikeTypeNode, isArrayMethodCallExpression, isCopiedArray, isLengthInLogicalExpression, isLengthNegated, isLengthUsedInTestContext, normalizeNodes };
