'use strict';
import { hasGeneric, isIdentifier, getVariableInScope, nodeTypes, isNameMatch } from '@flint/infra/analysis';
import { createEslintRule } from '@flint/infra/create-eslint-rule';
import { flintRuleActionNames } from '@flint/infra/constants/rule-strings';
import { firstOrUndefined } from '../../../fd-toolbox/server/collections/single-funcs.js';
import { namingConstants } from '@flint/infra/constants/naming-constants';

var __defProp=Object['defineProperty'],__name=(_0x3b9fe2,_0x3e619a)=>__defProp(_0x3b9fe2,'name',{'value':_0x3e619a,'configurable':!![]});const ruleName='must-use-generic-crud-update-config';const ruleContent='\x0a###\x20**Must**\x20use\x20CrudUpdate\x20with\x20generic\x20or\x20Config<T>\x0a\x0a####\x20Wrong\x0a\x0aconst\x20config\x20=\x20{};\x0aawait\x20crudUpdate(config);\x0a\x0a####\x20Correct\x0a\x0aawait\x20crudUpdate<Foo>();\x0a\x0a//\x20Or\x0a\x0aconst\x20config:\x20Config<Foo>\x20=\x20{...};\x0aawait\x20crudUpdate(config);\x0a\x0a\x0a####\x20Why\x0a\x0aThis\x20prevents\x20type\x20errors\x20and\x20enforces\x20consistency.';var mustUseGenericCrudUpdateConfig = createEslintRule(ruleName,ruleContent,__name(function create(_0x593ff6){return {'CallExpression'(_0x141871){if(!isCrudUpdateCall(_0x141871)||hasGeneric(_0x141871))return;const _0x1ec353=firstOrUndefined(_0x141871['arguments']);if(_0x1ec353&&isConfigIdentifier(_0x1ec353,_0x593ff6['sourceCode']))return;_0x593ff6['report']({'node':_0x141871,'messageId':ruleName});}};},'create'));function isConfigIdentifier(_0x5c068f,_0x2f3b41){let _0x1c4b06=![];if(isIdentifier(_0x5c068f)){const _0x2e4156=getVariableInScope(_0x2f3b41,_0x5c068f,_0x5c068f['name'],!![]);if(_0x2e4156){const _0x554fa2=firstOrUndefined(_0x2e4156['defs']);if(_0x554fa2&&_0x554fa2['type']===nodeTypes['variable']){const _0x15e783=_0x554fa2['node']['id'];if(isIdentifier(_0x15e783)&&_0x15e783['typeAnnotation']&&_0x15e783['typeAnnotation']['typeAnnotation']['type']===nodeTypes['TSTypeReference']){const _0x3de401=_0x15e783['typeAnnotation']['typeAnnotation'];_0x1c4b06=isIdentifier(_0x3de401['typeName'])&&isNameMatch(_0x3de401['typeName'],namingConstants['suffixConfig'])&&Array['isArray'](_0x3de401['typeArguments']?.['params'])&&_0x3de401['typeArguments']['params']['length']>-0x1240+-0x1a87+-0xeed*-0x3;}}}}return _0x1c4b06;}__name(isConfigIdentifier,'isConfigIdentifier');function isCrudUpdateCall(_0x33f8a9){return isIdentifier(_0x33f8a9['callee'])&&isNameMatch(_0x33f8a9['callee'],flintRuleActionNames['crudUpdate']);}__name(isCrudUpdateCall,'isCrudUpdateCall');

export { mustUseGenericCrudUpdateConfig as default, ruleName };
