'use strict';
import { ESLintUtils } from '@typescript-eslint/utils';
import { nodeTypes, isNamedDeclaration, getVariableInScope, isReactHook, isPascalCase } from '@flint/infra/analysis';
import { ruleTypes, url } from '@flint/infra/constants/rules-meta';
import { jsBasicTypes, tsBasicTypes } from '../../../base-repo/constants/basic-types.js';
import { reactHooks } from '../../../base-repo/constants/react-hooks.js';
import { variableDeclarationKinds } from '@flint/infra/analysis/module-analysis';
import { flintRuleIdentifiers } from '@flint/infra/constants/shared-string-identifiers';
import _0x2de5a4__default from 'typescript';
import { firstOrUndefined } from '../../../fd-toolbox/server/collections/single-funcs.js';

var __defProp=Object['defineProperty'],__name=(_0x473d9c,_0x1b7f88)=>__defProp(_0x473d9c,'name',{'value':_0x1b7f88,'configurable':!![]});const ruleName='no-untyped-objects-between-components';const constants={'messageIds':{'noUntypedObjects':'noUntypedObjects'},'meta':{'type':ruleTypes['problem'],'docs':{'description':'Must\x20not\x20pass\x20untyped\x20objects\x20between\x20components'},'messages':{'noUntypedObjects':'no-untyped-objects-between-components\x0a###\x20**Must\x20not**\x20pass\x20untyped\x20objects\x20between\x20components.\x0a\x0aDefine\x20proper\x20TypeScript\x20interfaces\x20or\x20types.\x0a\x0a####\x20Wrong\x0a\x0aexport\x20interface\x20FooProps\x20{\x0a\x20\x20\x20\x20bar:\x20\x20{\x20bar:\x20\x22Bar\x22,\x20baz:\x20[]\x20};\x0a}\x0a\x0aexport\x20function\x20Foo({\x20…\x20}:\x20FooProps)\x20{…}\x0a\x0a####\x20Correct\x0a\x0aexport\x20interface\x20FooProps\x20{\x0a\x20\x20\x20\x20bar:\x20\x20BarBaz;\x0a}\x0a\x0aexport\x20function\x20Foo({\x20…\x20}:\x20FooProps)\x20{…}\x0a\x0a####\x20Why\x0a\x0aTyping\x20objects\x20enforces\x20their\x20structure,\x20which\x20improves\x20reliability\x20by\x20catching\x20errors\x20early.'},'schema':[]},'componentPatterns':{'reactHookPrefix':reactHooks['use']},'typeAnnotations':{'any':tsBasicTypes['any'],'object':jsBasicTypes['object']},'definitionTypes':{'variable':nodeTypes['variable'],'parameter':nodeTypes['parameter']}},createRule=ESLintUtils['RuleCreator'](_0x4d1c15=>''+url+_0x4d1c15),noUntypedObjectsBetweenComponents=createRule({'name':ruleName,'meta':constants['meta'],'defaultOptions':[],'create'(_0x4cf477){return {[nodeTypes['JSXElement']](_0x32e3c6){checkJSXOpeningElement(_0x32e3c6['openingElement'],_0x4cf477);}};}});function isUntypedObjectExpression(_0x44f795,_0x249c23){const _0x2d5ffd=ESLintUtils['getParserServices'](_0x249c23),_0x38dcda=_0x2d5ffd['program']['getTypeChecker'](),_0x470f15=_0x2d5ffd['esTreeNodeToTSNodeMap']['get'](_0x44f795),_0x5ef2c1=_0x38dcda['getTypeAtLocation'](_0x470f15),_0x3ac7fb=_0x44f795['type']===nodeTypes['objectExpression'],_0x189009=_0x38dcda['typeToString'](_0x5ef2c1)===constants['typeAnnotations']['any']||_0x38dcda['typeToString'](_0x5ef2c1)===constants['typeAnnotations']['object'];return _0x3ac7fb&&_0x189009;}__name(isUntypedObjectExpression,'isUntypedObjectExpression');function hasNamedSymbol(_0x3725c6){if(!_0x3725c6?.['name'])return ![];return _0x3725c6['name']!=='__object'&&_0x3725c6['name']!=='__type';}__name(hasNamedSymbol,'hasNamedSymbol');function hasDeclaredTypeName(_0x29ca82){const _0x484d61=_0x29ca82['getSymbol'](),_0x328c44=_0x29ca82['aliasSymbol'],_0x8ca1e7=_0x484d61?.['declarations']?.['some'](isNamedDeclaration)??![],_0x4cd0b1=_0x328c44?.['declarations']?.['some'](_0x2de5a4__default['isTypeAliasDeclaration'])??![];if(_0x8ca1e7||_0x4cd0b1)return !![];if(_0x29ca82['isClassOrInterface']()||_0x29ca82['isIntersection']()||_0x29ca82['isUnion']())return !![];return hasNamedSymbol(_0x484d61);}__name(hasDeclaredTypeName,'hasDeclaredTypeName');function isFunctionReturnUntypedObject(_0x1f4238,_0x42caeb){if('returnType'in _0x1f4238&&_0x1f4238['returnType'])return ![];let _0xb3797f=![];const _0x1f1c0a=ESLintUtils['getParserServices'](_0x42caeb),_0x84277f=_0x1f1c0a['program']['getTypeChecker'](),_0x1605c2=_0x1f1c0a['esTreeNodeToTSNodeMap']['get'](_0x1f4238);if(!_0x2de5a4__default['isFunctionLike'](_0x1605c2))return ![];const _0x4d28f0=_0x84277f['getSignatureFromDeclaration'](_0x1605c2);if(_0x4d28f0){const _0x4ae24f=_0x84277f['getReturnTypeOfSignature'](_0x4d28f0),_0x286185=(_0x4ae24f['flags']&_0x2de5a4__default['TypeFlags']['Object'])!==0xae*0x1b+0xde5+0x203f*-0x1;if(_0x286185){const _0x4022b1=hasDeclaredTypeName(_0x4ae24f),_0x1afa95=_0x4ae24f['getFlags']()&(_0x2de5a4__default['TypeFlags']['Any']|_0x2de5a4__default['TypeFlags']['Unknown']);!_0x4022b1&&!_0x1afa95&&(_0xb3797f=!![]);}}return _0xb3797f;}__name(isFunctionReturnUntypedObject,'isFunctionReturnUntypedObject');function isVariableUntypedFunction(_0x5bcb19,_0x2aee8e){let _0x36ab7b;if(_0x5bcb19['defs']['length']>0x82a*0x1+-0x1903+0x10d9){const _0x3ea9e5=firstOrUndefined(_0x5bcb19['defs']);if(_0x3ea9e5){const _0x1f8b17=_0x3ea9e5['node'];if(_0x3ea9e5['type']==='FunctionName')_0x36ab7b=isFunctionReturnUntypedObject(_0x3ea9e5['node'],_0x2aee8e);else _0x3ea9e5['type']===constants['definitionTypes']['variable']&&_0x1f8b17['type']===nodeTypes['variableDeclarator']&&_0x1f8b17['init']&&(_0x1f8b17['init']['type']===nodeTypes['arrowFunctionExpression']||_0x1f8b17['init']['type']===nodeTypes['functionExpression'])&&(_0x36ab7b=isFunctionReturnUntypedObject(_0x1f8b17['init'],_0x2aee8e));}}return _0x36ab7b;}__name(isVariableUntypedFunction,'isVariableUntypedFunction');function hasTypeAnnotationOrSatisfies(_0xe035e9,_0x571c17){let _0x34b597=![];if(_0xe035e9['init']&&_0xe035e9['init']['type']===nodeTypes['TSSatisfiesExpression'])_0x34b597=!![];else {if(_0xe035e9['id']['typeAnnotation']){const _0x2e089d=ESLintUtils['getParserServices'](_0x571c17),_0x4d068b=_0x2e089d['program']['getTypeChecker'](),_0x5d62bf=_0x2e089d['esTreeNodeToTSNodeMap']['get'](_0xe035e9['id']),_0x1f348a=_0x4d068b['getTypeAtLocation'](_0x5d62bf),_0x493fa1=_0x1f348a['getFlags'](),_0x4bb080=(_0x493fa1&(_0x2de5a4__default['TypeFlags']['Any']|_0x2de5a4__default['TypeFlags']['Unknown']))!==-0x357*0x1+0x1*-0x313+0x66a,_0x456866=_0x4d068b['typeToString'](_0x1f348a)===constants['typeAnnotations']['object'];if(!(_0x4bb080||_0x456866))_0x34b597=!![];}}return _0x34b597;}__name(hasTypeAnnotationOrSatisfies,'hasTypeAnnotationOrSatisfies');function isModuleLevelConstant(_0x58a528,_0x71277a){const _0x5ae4a7=getVariableInScope(_0x71277a['sourceCode'],_0x58a528,_0x58a528['name'],!![])?.['defs']?.['at'](-0x16c2+0x12c*-0x8+0x2022);if(_0x5ae4a7&&_0x5ae4a7['type']===constants['definitionTypes']['variable']){const _0x5eee27=_0x5ae4a7['node'];if(_0x5eee27['type']===nodeTypes['variableDeclarator']){const _0x396a8c=_0x5ae4a7['parent'];if(_0x396a8c&&_0x396a8c['type']===nodeTypes['variableDeclaration']&&_0x396a8c['kind']===variableDeclarationKinds['const']){const _0x2046b5=_0x71277a['sourceCode']['getScope'](_0x5eee27);if(_0x2046b5['type']===flintRuleIdentifiers['module']||_0x2046b5['type']===flintRuleIdentifiers['global'])return hasTypeAnnotationOrSatisfies(_0x5eee27,_0x71277a);}}}return ![];}__name(isModuleLevelConstant,'isModuleLevelConstant');function isIdentifierWithoutProperType(_0x48f905,_0x4bb0b4){let _0x4ec050=![];if(_0x48f905['type']===nodeTypes['identifier']){if(isModuleLevelConstant(_0x48f905,_0x4bb0b4))return ![];const _0x578d=ESLintUtils['getParserServices'](_0x4bb0b4),_0x151bc6=_0x578d['program']['getTypeChecker'](),_0x1cdb2d=_0x578d['esTreeNodeToTSNodeMap']['get'](_0x48f905),_0x4005=_0x151bc6['getTypeAtLocation'](_0x1cdb2d),_0x12ebe2=!!(_0x4005['getFlags']()&(_0x2de5a4__default['TypeFlags']['Any']|_0x2de5a4__default['TypeFlags']['Unknown'])),_0x17310f=_0x151bc6['typeToString'](_0x4005)===constants['typeAnnotations']['object'];if(_0x12ebe2||_0x17310f)_0x4ec050=!![];else {const _0x36ff4c=(_0x4005['flags']&_0x2de5a4__default['TypeFlags']['Object'])!==0x1f41+0x23*0xb9+-0x388c,_0x1af0ea=_0x4005['getCallSignatures']()['length']>0x1*0x1aa5+0xa45+-0xe1*0x2a,_0x329933=_0x4005['getNumberIndexType']()!==void(0x1*0x1a29+-0x174+0xb*-0x23f);if(_0x36ff4c&&!_0x329933&&!_0x1af0ea){const _0x58ba46=hasDeclaredTypeName(_0x4005);_0x4ec050=!_0x58ba46;}}}return _0x4ec050;}__name(isIdentifierWithoutProperType,'isIdentifierWithoutProperType');function isUntypedIdentifierCall(_0x19cdeb,_0x574675,_0x30ff87){let _0x44cd11=![];if(isReactHook(_0x19cdeb['name']))_0x44cd11=!![];else {const _0x3a79c3=getVariableInScope(_0x30ff87['sourceCode'],_0x574675,_0x19cdeb['name']);_0x3a79c3&&isVariableUntypedFunction(_0x3a79c3,_0x30ff87)&&(_0x44cd11=!![]);}return _0x44cd11;}__name(isUntypedIdentifierCall,'isUntypedIdentifierCall');function isUntypedMemberExpressionCall(_0x52ce8e){let _0x32030c=![];const _0x356b37=_0x52ce8e['property'];return _0x356b37['type']===nodeTypes['identifier']&&isReactHook(_0x356b37['name'])&&(_0x32030c=!![]),_0x32030c;}__name(isUntypedMemberExpressionCall,'isUntypedMemberExpressionCall');function isCallExpressionReturningObject(_0x2128cf,_0x503c33){let _0x382408=![];if(_0x2128cf['type']===nodeTypes['callExpression']){const _0x51a246=_0x2128cf['callee'];if(_0x51a246['type']===nodeTypes['identifier'])_0x382408=isUntypedIdentifierCall(_0x51a246,_0x2128cf,_0x503c33);else _0x51a246['type']===nodeTypes['memberExpression']&&(_0x382408=isUntypedMemberExpressionCall(_0x51a246));}return _0x382408;}__name(isCallExpressionReturningObject,'isCallExpressionReturningObject');function checkJSXAttribute(_0x3359bd,_0x38b78c){if(_0x3359bd['name']['type']!==nodeTypes['JSXIdentifier']||!_0x3359bd['value']||_0x3359bd['value']['type']!==nodeTypes['JSXExpressionContainer'])return;const _0xe0ae1a=_0x3359bd['value']['expression'];if(!_0xe0ae1a||_0xe0ae1a['type']===nodeTypes['JSXEmptyExpression'])return;const _0x14a672=_0xe0ae1a;(isUntypedObjectExpression(_0x14a672,_0x38b78c)||isIdentifierWithoutProperType(_0x14a672,_0x38b78c)||isCallExpressionReturningObject(_0x14a672,_0x38b78c))&&_0x38b78c['report']({'node':_0x14a672,'messageId':constants['messageIds']['noUntypedObjects']});}__name(checkJSXAttribute,'checkJSXAttribute');function checkJSXOpeningElement(_0x5230bc,_0x5325fc){let _0x254ce5=!![],_0x2d8144;_0x5230bc['name']['type']===nodeTypes['JSXIdentifier']?(_0x2d8144=_0x5230bc['name']['name'],!isPascalCase(_0x2d8144)&&(_0x254ce5=![])):_0x254ce5=![],_0x254ce5&&_0x5230bc['attributes']['forEach'](_0x19bbdd=>{_0x19bbdd['type']===nodeTypes['JSXAttribute']&&checkJSXAttribute(_0x19bbdd,_0x5325fc);});}__name(checkJSXOpeningElement,'checkJSXOpeningElement');

export { noUntypedObjectsBetweenComponents as default, ruleName };
