'use strict';
import { ESLintUtils } from '@typescript-eslint/utils';
import { nodeTypes, hasEventHandler, createNodeVisitor } from '@flint/infra/analysis';
import { ruleTypes, url } from '@flint/infra/constants/rules-meta';
import { flintRuleIdentifiers } from '@flint/infra/constants/shared-string-identifiers';
import { firstOrUndefined } from '../../../fd-toolbox/server/collections/single-funcs.js';

var __defProp=Object['defineProperty'],__name=(_0x1cbfee,_0x45c33b)=>__defProp(_0x1cbfee,'name',{'value':_0x45c33b,'configurable':!![]});const ruleName='use-on-prefix';const constants={'prefix':flintRuleIdentifiers['on'],'meta':{'type':ruleTypes['problem'],'docs':{'description':'Allows\x20only\x20\x27on\x27\x20prefix\x20for\x20event\x20handlers'},'messages':{'useOnPrefix':'use-on-prefix\x0aHandler\x20functions\x20must\x20be\x20named\x20as\x20on{FunctionName}{Callback}.\x0a\x0a###\x20**Must**\x20use\x20“on”\x20prefix\x20for\x20event\x20handlers.\x0a\x0a####\x20Wrong\x0a\x0aconst\x20handleSort\x20=\x20useCallback(()\x20=>\x20{...},[])\x0a\x0a####\x20Correct\x0a\x0aconst\x20onSort\x20=\x20useCallback(()\x20=>\x20{...},[])\x0a\x0a####\x20Why\x0a\x0aPrefixing\x20with\x20\x27on\x27\x20and\x20adding\x20\x27Callback\x27\x20(if\x20names\x20conflict)\x20enhances\x20readability\x20and\x20clarifies\x20function\x20purpose.'},'schema':[]},'messageIds':{'useOnPrefix':'useOnPrefix'}},createRule=ESLintUtils['RuleCreator'](_0xd2f737=>''+url+_0xd2f737),useOnPrefix=createRule({'name':ruleName,'meta':constants['meta'],'create'(_0x88eaad){const _0x978367=new Set();return {...createNodeVisitor(_0x146d1f=>collectPropNamesFromParams(_0x146d1f['params'],_0x978367)),'JSXAttribute'(_0xc227dd){if(_0xc227dd['name']['type']===nodeTypes['JSXIdentifier']&&hasEventHandler(_0xc227dd['name']['name'])&&_0xc227dd['value']&&_0xc227dd['value']['type']===nodeTypes['JSXExpressionContainer']){const _0x13db1c=_0xc227dd['value']['expression'];_0x13db1c['type']===nodeTypes['identifier']&&_0x978367['has'](_0x13db1c['name'])&&!_0x13db1c['name']['startsWith'](constants['prefix'])&&_0x88eaad['report']({'node':_0xc227dd,'messageId':constants['messageIds']['useOnPrefix'],'data':{'name':_0x13db1c['name']}});}}};},'defaultOptions':[]});function collectPropNamesFromParams(_0x41059f,_0x4fcb29){const _0x2146b8=firstOrUndefined(_0x41059f);if(_0x2146b8&&_0x2146b8['type']===nodeTypes['objectPattern'])for(const _0x5b8012 of _0x2146b8['properties']){_0x5b8012['type']===nodeTypes['property']&&_0x5b8012['key']['type']===nodeTypes['identifier']&&_0x4fcb29['add'](_0x5b8012['key']['name']);}}__name(collectPropNamesFromParams,'collectPropNamesFromParams');

export { useOnPrefix as default, ruleName };
