'use strict';
import { ESLintUtils } from '@typescript-eslint/utils';
import { nodeTypes, getMethodNameFromCallee } from '@flint/infra/analysis';
import { ruleTypes, url } from '@flint/infra/constants/rules-meta';
import { collectionMethodNames } from '../../../base-repo/constants/internal-common-strings.js';
import { firstOrUndefined } from '../../../fd-toolbox/server/collections/single-funcs.js';

var __defProp=Object['defineProperty'],__name=(_0x18b53b,_0x250750)=>__defProp(_0x18b53b,'name',{'value':_0x250750,'configurable':!![]});const ruleName='no-long-filter-map';const defaultMaxLines=-0x1cf7+0x163*0xd+0xaf5,constants={'meta':{'type':ruleTypes['problem'],'docs':{'description':'Disallow\x20filter-map\x20constructions\x20with\x20too\x20many\x20lines\x20of\x20code'},'messages':{'noLongFilterMap':'no-long-filter-map\x0aCallback\x20functions\x20inside\x20\x27{{methods}}\x27\x20span\x20\x27{{totalLines}}\x20lines\x27,\x20the\x20maximum\x20allowed\x20is\x20\x27{{maxLines}}\x20lines\x27.\x0a\x0a###\x20**Must**\x20keep\x20.filter()\x20or\x20.map()\x20callbacks\x20short.\x0a\x0a####\x20Wrong\x0a\x0a.filter(item\x20=>\x20{\x0a//\x20many\x20lines\x20here\x0a})\x0a.map(item\x20=>\x20{\x0a//\x20many\x20lines\x20here\x0a})\x0a\x0a####\x20Correct\x0a\x0a.filter(isValid)\x0a.map(transform)\x0a\x0a####\x20Why\x0a\x0aShort\x20callbacks\x20improve\x20code\x20clarity\x20and\x20maintainability.'},'schema':[{'type':'object','properties':{'maxLines':{'type':'number','minimum':0x1,'default':defaultMaxLines}},'additionalProperties':![]}]},'messageId':'noLongFilterMap','callbackMethodsSet':new Set([collectionMethodNames['filter'],collectionMethodNames['map']]),'functionTypes':new Set([nodeTypes['functionExpression'],nodeTypes['arrowFunctionExpression']])},createRule=ESLintUtils['RuleCreator'](_0x424816=>''+url+_0x424816),noLongFilterMap=createRule({'name':ruleName,'meta':constants['meta'],'defaultOptions':[{'maxLines':defaultMaxLines}],'create'(_0x4aadd2,_0xc85c04){const [_0x5358dc={}]=_0xc85c04,_0x5cc6b9=_0x5358dc['maxLines']??defaultMaxLines;return {'CallExpression'(_0x43e8ad){if(!isFilterOrMap(_0x43e8ad))return;const _0x39d3e4=firstOrUndefined(_0x43e8ad['arguments']);if(_0x39d3e4&&constants['functionTypes']['has'](_0x39d3e4['type'])&&_0x43e8ad['callee']['type']===nodeTypes['memberExpression']&&_0x43e8ad['callee']['property']['type']===nodeTypes['identifier']){const _0x3bef88=getMethodNameFromCallee(_0x43e8ad['callee']),_0x5cf95b=_0x4aadd2['sourceCode'],_0x4755ea=_0x5cf95b['getText'](_0x39d3e4),_0x323cdd=getLogicalCodeLines(_0x4755ea);_0x323cdd>_0x5cc6b9&&_0x4aadd2['report']({'node':_0x43e8ad,'messageId':constants['messageId'],'data':{'methods':_0x3bef88,'totalLines':_0x323cdd,'maxLines':_0x5cc6b9}});}}};}});function isLogicalLine(_0x5276ee,_0x413b2a){const _0x2a6663=/^[a-zA-Z0-9_$\s,=()]*=>\s*{$/;return !_0x413b2a&&!!_0x5276ee&&!_0x5276ee['startsWith']('//')&&_0x5276ee!=='{'&&_0x5276ee!=='}'&&!(_0x5276ee['startsWith']('/*')&&_0x5276ee['endsWith']('*/'))&&!_0x2a6663['exec'](_0x5276ee);}__name(isLogicalLine,'isLogicalLine');function getLogicalCodeLines(_0x5d1673){const _0x92ed36=_0x5d1673['split']('\x0a');let _0x1b7095=-0x942+0x1*0x5a3+0x39f,_0x23cd7a=![];for(const _0x1850b0 of _0x92ed36){const _0x1b7d38=_0x1850b0['trim']();_0x23cd7a&&_0x1b7d38['includes']('*/')&&(_0x23cd7a=![]),!_0x23cd7a&&_0x1b7d38['startsWith']('/*')&&!_0x1b7d38['endsWith']('*/')&&(_0x23cd7a=!![]),isLogicalLine(_0x1b7d38,_0x23cd7a)&&(_0x1b7095=_0x1b7095+(-0xf3*0xf+0x1b0f+-0xc1*0x11));}return _0x1b7095;}__name(getLogicalCodeLines,'getLogicalCodeLines');function isFilterOrMap(_0x1ddae7){return _0x1ddae7['callee']['type']===nodeTypes['memberExpression']&&_0x1ddae7['callee']['property']['type']===nodeTypes['identifier']&&constants['callbackMethodsSet']['has'](_0x1ddae7['callee']['property']['name']);}__name(isFilterOrMap,'isFilterOrMap');

export { noLongFilterMap as default, ruleName };
