'use strict';
import { ESLintUtils } from '@typescript-eslint/utils';
import { getTypeAnnotation, nodeTypes } from '@flint/infra/analysis';
import { ruleTypes, url } from '@flint/infra/constants/rules-meta';

var __defProp=Object['defineProperty'],__name=(_0x328e0e,_0x2ffd24)=>__defProp(_0x328e0e,'name',{'value':_0x2ffd24,'configurable':!![]});const ruleName='must-use-interfaces-for-complex-types';const constants={'messageIds':{'mustUseInterfacesForComplexTypes':'mustUseInterfacesForComplexTypes'},'meta':{'type':ruleTypes['problem'],'docs':{'description':''},'messages':{'mustUseInterfacesForComplexTypes':'must-use-interfaces-for-complex-types\x0aComplexity\x20of\x20this\x20type\x20is\x20{{complexityScore}},\x20but\x20only\x20{{allowedComplexity}}\x20is\x20allowed.\x0a\x0a###\x20**Must**\x20use\x20interfaces\x20for\x20complex\x20types.\x0a\x0a####\x20Wrong\x0a\x0aawait\x20foo<{\x0a\x20\x20\x20\x20bar:\x20string;\x0a\x20\x20\x20\x20baz:\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20qux:\x20string;\x0a\x20\x20\x20\x20\x20\x20\x20\x20quux:\x20string;\x0a\x20\x20\x20\x20}[];\x0a}>();\x0a\x0a####\x20Correct\x0a\x0ainterface\x20Corge\x20{\x0a\x20\x20\x20\x20bar:\x20string;\x0a\x20\x20\x20\x20baz:\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20qux:\x20string;\x0a\x20\x20\x20\x20\x20\x20\x20\x20quux:\x20string;\x0a\x20\x20\x20\x20}[];\x0a}\x0a\x0aawait\x20foo<Corge>();\x0a\x0a####\x20Why\x0a\x0aUsing\x20interfaces\x20for\x20complex\x20types\x20improves\x20code\x20readability,\x20reusability,\x20and\x20maintainability.\x20It\x20makes\x20the\x20code\x20structure\x20clearer\x20and\x20easier\x20to\x20reference\x20in\x20multiple\x20places.'},'schema':[{'type':'object','properties':{'maxComplexity':{'type':'number'}},'additionalProperties':![]}]},'defaultOptions':[{'maxComplexity':0x3}]},createRule=ESLintUtils['RuleCreator'](_0x5da2ba=>''+url+_0x5da2ba),mustUseInterfacesForComplexTypes=createRule({'name':ruleName,'meta':constants['meta'],'defaultOptions':constants['defaultOptions'],'create'(_0x35262c,_0x52eeaf){const [_0x4e1225]=_0x52eeaf;return {'TSTypeParameterInstantiation'(_0x4d304e){const _0x2cac13=_0x4d304e['params']['reduce']((_0x363a10,_0x4c6659)=>_0x363a10+computeTypeComplexity(_0x4c6659),-0x10fc*-0x1+-0x85+-0x57d*0x3);_0x2cac13>_0x4e1225['maxComplexity']&&_0x35262c['report']({'messageId':constants['messageIds']['mustUseInterfacesForComplexTypes'],'node':_0x4d304e,'data':{'complexityScore':_0x2cac13,'allowedComplexity':_0x4e1225['maxComplexity']}});}};}});function computeParameterComplexity(_0x49d128){return _0x49d128['reduce']((_0x33dbb8,_0xc9a119)=>{const _0xe285ca=getTypeAnnotation(_0xc9a119);return _0xe285ca?_0x33dbb8+computeTypeComplexity(_0xe285ca['typeAnnotation']):_0x33dbb8+(-0x1eed+0x2*0xf62+-0xe*-0x3);},0x3*0xc49+-0x19f1+-0xaea);}__name(computeParameterComplexity,'computeParameterComplexity');function computeMemberComplexity(_0x268e3){let _0x957315=-0xf32+-0x3*0x962+0x2b58;switch(_0x268e3['type']){case nodeTypes['TSPropertySignature']:_0x957315=_0x268e3['typeAnnotation']?computeTypeComplexity(_0x268e3['typeAnnotation']['typeAnnotation']):-0x2*-0xde8+-0xe27*0x1+0x10d*-0xd;break;case nodeTypes['TSMethodSignature']:_0x957315+=computeParameterComplexity(_0x268e3['params']),_0x957315+=_0x268e3['returnType']?computeTypeComplexity(_0x268e3['returnType']['typeAnnotation']):-0x27f*0x5+0xd30+0x1*-0xb5;break;case nodeTypes['TSIndexSignature']:_0x957315+=computeParameterComplexity(_0x268e3['parameters']),_0x957315+=_0x268e3['typeAnnotation']?computeTypeComplexity(_0x268e3['typeAnnotation']['typeAnnotation']):-0x218a+0x1d0+0x2*0xfdd;break;default:_0x957315=-0x646*-0x2+-0x9df*0x3+-0x2*-0x889;}return _0x957315;}__name(computeMemberComplexity,'computeMemberComplexity');function computeTypeComplexity(_0xb0b1c6){let _0x2ba0fb=0xff*0x15+-0x920+0xbcb*-0x1;const _0x2482fa=-0x631*0x2+0x5d9*-0x4+0x23c7;if(!_0xb0b1c6)return _0x2ba0fb;switch(_0xb0b1c6['type']){case nodeTypes['TSTypeLiteral']:_0x2ba0fb=_0x2482fa+_0xb0b1c6['members']['reduce']((_0x46882b,_0x411633)=>_0x46882b+computeMemberComplexity(_0x411633),0xc9*-0x2+-0x1886+-0x2*-0xd0c);break;case nodeTypes['TSArrayType']:_0x2ba0fb=_0x2482fa+computeTypeComplexity(_0xb0b1c6['elementType']);break;case nodeTypes['TSTupleType']:_0x2ba0fb=_0x2482fa+_0xb0b1c6['elementTypes']['reduce']((_0x11a47b,_0x5d1e07)=>_0x11a47b+computeTypeComplexity(_0x5d1e07),-0xec8+0x21*0x108+0x134*-0x10);break;case nodeTypes['TSUnionType']:case nodeTypes['TSIntersectionType']:_0x2ba0fb=_0x2482fa+_0xb0b1c6['types']['reduce']((_0x101705,_0xaa2479)=>_0x101705+computeTypeComplexity(_0xaa2479),0x5*-0x4be+0x132c+0x48a);break;case nodeTypes['TSTypeReference']:_0xb0b1c6['typeArguments']&&(_0x2ba0fb=_0xb0b1c6['typeArguments']['params']['reduce']((_0x51d3cc,_0x4e092e)=>_0x51d3cc+computeTypeComplexity(_0x4e092e),-0x946*0x4+-0x1b45+0x405d));break;default:_0x2ba0fb=_0x2482fa;break;}return _0x2ba0fb;}__name(computeTypeComplexity,'computeTypeComplexity');

export { mustUseInterfacesForComplexTypes as default, ruleName };
