'use strict';
import { ESLintUtils } from '@typescript-eslint/utils';
import { nodeTypes, isNameMatch, findPropertyInObject } from '@flint/infra/analysis';
import { ruleTypes, url, eslintProperties } from '@flint/infra/constants/rules-meta';
import { folders } from '../../../base-repo/app-constants/project-paths.js';
import { eslintFixTypeNames } from '../../../base-repo/constants/internal-common-strings.js';
import { eslintRuleSyntax } from '@flint/infra/constants/eslint-rule-syntax';
import { flintRuleIdentifiers } from '@flint/infra/constants/shared-string-identifiers';
import { firstOrUndefined } from '../../../fd-toolbox/server/collections/single-funcs.js';

var __defProp=Object['defineProperty'],__name=(_0x2cfe09,_0x288471)=>__defProp(_0x2cfe09,'name',{'value':_0x288471,'configurable':!![]});const ruleName='must-not-declare-fixer-without-calling-it';const ruleId='mustNotDeclareFixerWithoutCallingIt';const constants={'fixableValues':{'code':eslintFixTypeNames['code'],'whitespace':eslintFixTypeNames['whitespace']},'propertyNames':{'meta':folders['meta'],'create':folders['createSaasKitApp'],'report':eslintRuleSyntax['report']},'meta':{'type':ruleTypes['problem'],'docs':{'description':ruleName},'messages':{[ruleId]:ruleName+'\x0a###\x20**Must\x20not**\x20declare\x20fixer\x20without\x20calling\x20it\x20and\x20call\x20without\x20declaring.\x0a\x0a####\x20Wrong\x0a\x0ameta:\x20{\x20fixable:\x20\x22code\x22\x20},\x0acreate(context)\x20{\x0a\x20\x20\x20\x20return\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20Identifier(node)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20context.report({\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20node,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20messageId:\x20\x22error\x22,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20});\x0a\x20\x20\x20\x20\x20\x20\x20\x20},\x0a\x20\x20\x20\x20};\x0a}\x0a\x0a####\x20Correct\x0a\x0ameta:\x20{\x0a\x20\x20\x20\x20type:\x20\x22problem\x22,\x0a\x20\x20\x20\x20fixable:\x20\x22code\x22\x0a},\x0acreate(context)\x20{\x0a\x20\x20\x20\x20return\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20Identifier(node)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20context.report({\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20node,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20messageId:\x20\x22error\x22,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20fix(fixer)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20return\x20fixer.replaceText(node,\x20\x22foo\x22);\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20},\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20});\x0a\x20\x20\x20\x20\x20\x20\x20\x20},\x0a\x20\x20\x20\x20};\x0a}\x0a\x0a####\x20Why\x0a\x0aThe\x20fixer\x20declaration\x20and\x20its\x20actual\x20use\x20must\x20always\x20go\x20together,\x20otherwise\x20it\x20breaks\x20consistency.'},'schema':[]}},createRule=ESLintUtils['RuleCreator'](_0x1d3412=>''+url+_0x1d3412),mustNotDeclareFixerWithoutCallingIt=createRule({'name':ruleName,'meta':constants['meta'],'defaultOptions':[],'create'(_0x1d4898){const _0x1b747a=new WeakMap(),_0x473b2b=[],_0x4d13d3=new Set(),_0x2034f9=new Map();return {'Property'(_0x25d1e6){isFixableInMetaObject(_0x25d1e6)&&handleFixableProperty(_0x25d1e6,_0x1b747a,_0x473b2b),isNameMatch(_0x25d1e6['key'],constants['propertyNames']['create'])&&handleCreateProperty(_0x25d1e6,_0x1b747a,_0x473b2b),isNameMatch(_0x25d1e6['key'],constants['propertyNames']['meta'])&&handleMetaProperty(_0x25d1e6,_0x1b747a,_0x473b2b);},'VariableDeclarator'(_0xf28db3){if(_0xf28db3['id']['type']!==nodeTypes['identifier']||!_0xf28db3['init'])return;if(_0xf28db3['init']['type']===nodeTypes['memberExpression']&&_0xf28db3['init']['property']['type']===nodeTypes['identifier']&&isNameMatch(_0xf28db3['init']['property'],constants['propertyNames']['report'])&&_0xf28db3['init']['object']['type']===nodeTypes['identifier']){const _0x2b8b8e=findContainingRuleObject(_0xf28db3);if(_0x2b8b8e){const _0x3b3893=_0x1b747a['get'](_0x2b8b8e);_0x3b3893?.['contextName']&&isNameMatch(_0xf28db3['init']['object'],_0x3b3893['contextName'])&&_0x4d13d3['add'](_0xf28db3['id']['name']);}}},'CallExpression'(_0x1381ed){const _0x2389e4=findContainingRuleObject(_0x1381ed);if(_0x2389e4){const _0x51a457=_0x1b747a['get'](_0x2389e4);if(_0x51a457){const _0x508eb9=findFixPropertyInReportCall(_0x1381ed,_0x51a457['contextName'],_0x4d13d3);_0x508eb9&&_0x51a457['fixNodes']['push'](_0x508eb9);}}else {if(_0x1381ed['callee']['type']===nodeTypes['memberExpression']){const _0x2e1c9d=getCallerObjectName(_0x1381ed['callee']);if(_0x2e1c9d&&isNameMatch(_0x1381ed['callee']['property'],constants['propertyNames']['report'])){const _0x90a5d5=findFixPropertyInReportCall(_0x1381ed,_0x2e1c9d,_0x4d13d3);_0x90a5d5&&addFixToContextMap(_0x2034f9,_0x2e1c9d,_0x90a5d5);}}}},[eslintRuleSyntax['programExitSelector']](){for(const _0x1e3f50 of _0x473b2b){const _0x1b0bc7=_0x1b747a['get'](_0x1e3f50);_0x1b0bc7&&checkRuleDefinitionConsistency(_0x1b0bc7,_0x2034f9,_0x1d4898);}}};}});function getContextParamName(_0x236ff5){const _0x188a0f=firstOrUndefined(_0x236ff5['params']);return _0x188a0f&&_0x188a0f['type']===nodeTypes['identifier']?_0x188a0f['name']:void(-0xa7*-0x2f+0x125*-0x7+-0x16a6);}__name(getContextParamName,'getContextParamName');function hasValidFixableValue(_0x5efc92){const _0x135dbe=_0x5efc92['value']['type']===nodeTypes['literal']&&(_0x5efc92['value']['value']===constants['fixableValues']['code']||_0x5efc92['value']['value']===constants['fixableValues']['whitespace']),_0x3acda5=_0x5efc92['value']['type']===nodeTypes['identifier']||_0x5efc92['value']['type']===nodeTypes['memberExpression'];return _0x135dbe||_0x3acda5;}__name(hasValidFixableValue,'hasValidFixableValue');function isFixableInMetaObject(_0x5ef3b3){let _0x4597ec=![];const _0x4d567b=isNameMatch(_0x5ef3b3['key'],'fixable'),_0x45eed3=hasValidFixableValue(_0x5ef3b3),_0xb38f82=findContainingRuleObject(_0x5ef3b3);if(_0x4d567b&&_0x45eed3&&_0xb38f82){let _0x508d93=_0x5ef3b3['parent'];while(_0x508d93&&_0x508d93!==_0xb38f82){if(_0x508d93['type']===nodeTypes['objectExpression']&&_0x508d93['parent']?.['type']===nodeTypes['property']){const _0x393442=_0x508d93['parent'];if(isNameMatch(_0x393442['key'],constants['propertyNames']['meta'])){_0x4597ec=!![];break;}}_0x508d93=_0x508d93['parent'];}}return _0x4597ec;}__name(isFixableInMetaObject,'isFixableInMetaObject');function isFixPropertyWithFunction(_0x179aab){if(_0x179aab['type']!==nodeTypes['property']||!isNameMatch(_0x179aab['key'],eslintProperties['fix']))return ![];return _0x179aab['method']||_0x179aab['value']['type']===nodeTypes['functionExpression']||_0x179aab['value']['type']===nodeTypes['arrowFunctionExpression'];}__name(isFixPropertyWithFunction,'isFixPropertyWithFunction');function isRuleObject(_0x16fa7b){return !!findPropertyInObject(_0x16fa7b,constants['propertyNames']['create']);}__name(isRuleObject,'isRuleObject');function findContainingRuleObject(_0x184398){let _0x13f19f=_0x184398;while(_0x13f19f){if(_0x13f19f['type']===nodeTypes['objectExpression']){const _0x11b6b7=_0x13f19f['parent']?.['type']===nodeTypes['callExpression']&&_0x13f19f['parent']['callee']['type']===nodeTypes['identifier']&&isNameMatch(_0x13f19f['parent']['callee'],flintRuleIdentifiers['eslintRuleCreatorName']),_0x1a74e1=_0x13f19f['parent']?.['type']===nodeTypes['variableDeclarator']&&isRuleObject(_0x13f19f['properties']);if(_0x11b6b7||_0x1a74e1)return _0x13f19f;}_0x13f19f=_0x13f19f['parent'];}return void(-0x4*0x15a+-0x2039*-0x1+-0x1ad1);}__name(findContainingRuleObject,'findContainingRuleObject');function isReportCall(_0x476363,_0x4c053c,_0x56bcf9){let _0x492f95=![];if(_0x476363['callee']['type']===nodeTypes['memberExpression']){const _0x367e33=!!_0x4c053c&&isNameMatch(_0x476363['callee']['object'],_0x4c053c)&&isNameMatch(_0x476363['callee']['property'],constants['propertyNames']['report']);_0x492f95=_0x367e33&&_0x476363['arguments']['length']>-0x148*0x1+-0xe0d+0xf55;}else _0x476363['callee']['type']===nodeTypes['identifier']&&_0x56bcf9?.['has'](_0x476363['callee']['name'])&&(_0x492f95=_0x476363['arguments']['length']>-0x18a6*-0x1+-0xd*-0xaa+-0x2148);return _0x492f95;}__name(isReportCall,'isReportCall');function isFixerFunction(_0x32ad51){return _0x32ad51['type']===nodeTypes['functionExpression']||_0x32ad51['type']===nodeTypes['arrowFunctionExpression'];}__name(isFixerFunction,'isFixerFunction');function findFixInDescriptorObject(_0x239783){let _0xf99a2b;const _0x25f7e6=firstOrUndefined(_0x239783);if(_0x25f7e6&&_0x25f7e6['type']===nodeTypes['objectExpression'])for(const _0x49fd52 of _0x25f7e6['properties']){if(_0x49fd52['type']===nodeTypes['property']&&isFixPropertyWithFunction(_0x49fd52)){_0xf99a2b=_0x49fd52;break;}}return _0xf99a2b;}__name(findFixInDescriptorObject,'findFixInDescriptorObject');function findFixInPositionalArgs(_0x50ffdc){let _0x5b644e;if(_0x50ffdc['length']>=-0x2385*-0x1+-0x2*0x6d2+-0xc1*0x1d&&isFixerFunction(_0x50ffdc[0x1301+0x52+-0x1350]))_0x5b644e=_0x50ffdc[0x17a3+-0x1910+0x170];else _0x50ffdc['length']>=-0x1*0xe59+0x1860+-0xa04&&isFixerFunction(_0x50ffdc[0x23e0+0x23c0+-0x479e])&&(_0x5b644e=_0x50ffdc[0x33b*0x8+-0x1b08+0x132]);return _0x5b644e;}__name(findFixInPositionalArgs,'findFixInPositionalArgs');function findFixPropertyInReportCall(_0x144763,_0x10b48d,_0x5853b6){let _0x3d8050;const _0x387f55=_0x5853b6??new Set(),_0x4d3361=isReportCall(_0x144763,_0x10b48d,_0x387f55);if(_0x4d3361){const _0x45067d=findFixInDescriptorObject(_0x144763['arguments']);_0x45067d?_0x3d8050=_0x45067d:_0x3d8050=findFixInPositionalArgs(_0x144763['arguments']);}return _0x3d8050;}__name(findFixPropertyInReportCall,'findFixPropertyInReportCall');function getOrCreateRuleDefinition(_0x218def,_0x2a484d){let _0x5616f2=_0x218def['get'](_0x2a484d);return !_0x5616f2&&(_0x5616f2={'fixableNode':void(-0x248d+-0x24+0x24b1),'fixNodes':[],'contextName':void(-0x5f6+0x16fc+-0x1*0x1106),'ruleObject':_0x2a484d,'hasReferencedMeta':![]},_0x218def['set'](_0x2a484d,_0x5616f2)),_0x5616f2;}__name(getOrCreateRuleDefinition,'getOrCreateRuleDefinition');function ensureRuleObjectTracked(_0x882ea4,_0x1d4b15){!_0x882ea4['includes'](_0x1d4b15)&&_0x882ea4['push'](_0x1d4b15);}__name(ensureRuleObjectTracked,'ensureRuleObjectTracked');function handleFixableProperty(_0x155dcf,_0x2ebe21,_0xfbdd40){const _0x104b3f=findContainingRuleObject(_0x155dcf);if(_0x104b3f){const _0x525f10=getOrCreateRuleDefinition(_0x2ebe21,_0x104b3f);ensureRuleObjectTracked(_0xfbdd40,_0x104b3f),_0x525f10['fixableNode']=_0x155dcf;}}__name(handleFixableProperty,'handleFixableProperty');function handleCreateProperty(_0x5ae752,_0x3e1ffc,_0x37c4e2){const _0x1001e8=_0x5ae752['value'];if(_0x1001e8['type']===nodeTypes['functionExpression']||_0x1001e8['type']===nodeTypes['arrowFunctionExpression']){const _0x5642bf=findContainingRuleObject(_0x5ae752);if(_0x5642bf){const _0x3ccd47=getOrCreateRuleDefinition(_0x3e1ffc,_0x5642bf);ensureRuleObjectTracked(_0x37c4e2,_0x5642bf),_0x3ccd47['contextName']=getContextParamName(_0x1001e8);}}}__name(handleCreateProperty,'handleCreateProperty');function getCallerObjectName(_0x4f92b3){if(_0x4f92b3['type']===nodeTypes['memberExpression']&&_0x4f92b3['object']['type']===nodeTypes['identifier'])return _0x4f92b3['object']['name'];return void(-0x95*-0xb+-0x1*0x1cf9+-0x36*-0x6b);}__name(getCallerObjectName,'getCallerObjectName');function addFixToContextMap(_0x4d3ebe,_0x5ce6e7,_0x14c1cd){let _0x5c8ca9=_0x4d3ebe['get'](_0x5ce6e7);!_0x5c8ca9&&(_0x5c8ca9=[],_0x4d3ebe['set'](_0x5ce6e7,_0x5c8ca9)),_0x5c8ca9['push'](_0x14c1cd);}__name(addFixToContextMap,'addFixToContextMap');function isMetaDynamicOrReferenced(_0x326265){const _0x586917=_0x326265['type']===nodeTypes['identifier']||_0x326265['type']===nodeTypes['memberExpression'],_0x44aa82=_0x326265['type']===nodeTypes['callExpression'],_0x43dddc=_0x326265['type']===nodeTypes['objectExpression']&&_0x326265['properties']['some'](_0x140ae1=>_0x140ae1['type']===nodeTypes['spreadElement']);return _0x586917||_0x44aa82||_0x43dddc;}__name(isMetaDynamicOrReferenced,'isMetaDynamicOrReferenced');function handleMetaProperty(_0x438f7c,_0x314681,_0x1475c5){const _0x228ce6=findContainingRuleObject(_0x438f7c);if(!_0x228ce6)return;const _0x14581d=getOrCreateRuleDefinition(_0x314681,_0x228ce6);ensureRuleObjectTracked(_0x1475c5,_0x228ce6),isMetaDynamicOrReferenced(_0x438f7c['value'])&&(_0x14581d['hasReferencedMeta']=!![]);}__name(handleMetaProperty,'handleMetaProperty');function checkRuleDefinitionConsistency(_0x45fc6a,_0x23d368,_0x79d74a){const _0xe2452c=!!_0x45fc6a['fixableNode'];let _0x3dfce1=_0x45fc6a['fixNodes']['length']>0x1ce2+-0x394*-0x6+-0x325a;if(!_0x3dfce1&&_0x45fc6a['contextName']){const _0x60b582=_0x23d368['get'](_0x45fc6a['contextName']);_0x3dfce1=!!_0x60b582&&_0x60b582['length']>-0x11dd+0x8*-0x30d+0x2a45;}_0xe2452c&&!_0x3dfce1&&_0x45fc6a['fixableNode']&&_0x79d74a['report']({'node':_0x45fc6a['fixableNode'],'messageId':ruleId});if(_0x3dfce1&&!_0xe2452c&&!_0x45fc6a['hasReferencedMeta'])for(const _0x570012 of _0x45fc6a['fixNodes']){_0x79d74a['report']({'node':_0x570012,'messageId':ruleId});}}__name(checkRuleDefinitionConsistency,'checkRuleDefinitionConsistency');

export { mustNotDeclareFixerWithoutCallingIt as default, ruleId, ruleName };
