'use strict';
import { ESLintUtils } from '@typescript-eslint/utils';
import { createNodeVisitor, nodeTypes, hasReactFCTypeAnnotation, hasJSXReturn, isComponentByName, getDeclaredVariableNames } from '@flint/infra/analysis';
import { ruleTypes, url, eslintProperties } from '@flint/infra/constants/rules-meta';
import { firstOrUndefined } from '../../../fd-toolbox/server/collections/single-funcs.js';

var __defProp=Object['defineProperty'],__name=(_0x361c36,_0x2156b6)=>__defProp(_0x361c36,'name',{'value':_0x2156b6,'configurable':!![]});const ruleName='no-conflicting-props';const constants={'meta':{'type':ruleTypes['problem'],'docs':{'description':'Must\x20use\x20suffix\x20Prop\x20for\x20the\x20name\x20props\x20in\x20conflict.'},'messages':{'conflictingProp':'no-conflicting-props\x0aProperty\x20\x27{{name}}\x27\x20conflicts\x20with\x20a\x20local\x20variable.\x20Use\x20\x27{{name}}{{suffix}}\x27\x20instead.\x0a\x0a###\x20**Must**\x20use\x20suffix\x20{{suffix}}\x20for\x20the\x20name\x20of\x20props\x20in\x20conflict.\x0a\x0a####\x20Wrong\x0a\x0afunction\x20Foo({\x0a\x20\x20\x20\x20bar:\x20bar\x0a})\x20{\x0a\x20\x20\x20\x20const\x20[bar,\x20setBar]\x20=\x20useState(bar);\x0a\x20\x20\x20\x20}\x0a\x0a####\x20Correct\x0a\x0afunction\x20Foo({\x0a\x20\x20\x20\x20bar:\x20barProp\x0a})\x20{\x0a\x20\x20\x20\x20const\x20[bar,\x20setBar]\x20=\x20useState(barProp);\x0a}\x0a\x0a####\x20Why\x0a\x0aThis\x20increases\x20code\x20readability.'},'schema':[]},'messageIds':{'conflictingProp':'conflictingProp'}},createRule=ESLintUtils['RuleCreator'](_0x26c9bc=>''+url+_0x26c9bc),noConflictingProps=createRule({'name':ruleName,'meta':constants['meta'],'defaultOptions':[],'create'(_0x469ce1){return {...createNodeVisitor(_0x38d9ba=>checkComponent(_0x469ce1,_0x38d9ba),[nodeTypes['functionDeclaration'],nodeTypes['arrowFunctionExpression']])};}});function hasPropsLikeParam(_0x2fbff6,_0x37aa32){let _0x1d90df=![];const _0x526951=firstOrUndefined(_0x2fbff6['params']);if(_0x526951){if(_0x526951['type']===nodeTypes['objectPattern'])_0x1d90df=!![];else {if(_0x526951['type']===nodeTypes['identifier']){if(_0x526951['name']===eslintProperties['props']&&!_0x526951['typeAnnotation'])_0x1d90df=!![];else {if(_0x526951['typeAnnotation']){const _0xd2e1a2=_0x526951['typeAnnotation']['typeAnnotation'],_0x22787e=_0x37aa32['getText'](_0xd2e1a2);_0x1d90df=/props/i['test'](_0x22787e);}}}}}return _0x1d90df;}__name(hasPropsLikeParam,'hasPropsLikeParam');function isReactComponent(_0x591580,_0x401417){const _0x54439e=hasReactFCTypeAnnotation(_0x591580),_0x4191cd=hasJSXReturn(_0x591580),_0x42f49b=isComponentByName(_0x591580),_0x1c5d26=hasPropsLikeParam(_0x591580,_0x401417);return _0x54439e||_0x4191cd||_0x42f49b&&_0x1c5d26;}__name(isReactComponent,'isReactComponent');function getPropLocalNames(_0x46ac0f){const _0x5812ff=new Map();for(const _0x5eca36 of _0x46ac0f){if(_0x5eca36['type']===nodeTypes['property']&&!_0x5eca36['computed']&&_0x5eca36['value']['type']===nodeTypes['identifier'])_0x5812ff['set'](_0x5eca36['value']['name'],_0x5eca36['value']);else _0x5eca36['type']===nodeTypes['restElement']&&_0x5eca36['argument']['type']===nodeTypes['identifier']&&_0x5812ff['set'](_0x5eca36['argument']['name'],_0x5eca36['argument']);}return _0x5812ff;}__name(getPropLocalNames,'getPropLocalNames');function checkComponent(_0x485ba0,_0x5e6786){if(!isReactComponent(_0x5e6786,_0x485ba0['sourceCode']))return;const _0x35ef5d=firstOrUndefined(_0x5e6786['params']);if(!_0x35ef5d||_0x35ef5d['type']!==nodeTypes['objectPattern'])return;const _0x484a13=getDeclaredVariableNames(_0x5e6786['body']);if(_0x484a13['size']===-0x7fd*0x2+-0x1*0x1b01+0x2afb)return;const _0x3fe458=getPropLocalNames(_0x35ef5d['properties']);for(const [_0x193be7,_0x42bbb9]of _0x3fe458['entries']()){_0x484a13['has'](_0x193be7)&&_0x485ba0['report']({'node':_0x42bbb9,'messageId':constants['messageIds']['conflictingProp'],'data':{'name':_0x193be7,'suffix':'Prop'}});}}__name(checkComponent,'checkComponent');

export { noConflictingProps as default, ruleName };
