'use strict';
import { createEslintRule } from '@flint/infra/create-eslint-rule';
import { nodeTypes, isIdentifier } from '@flint/infra/analysis';
import { navigationMethodNames, eslintFixTypeNames } from '../../../base-repo/constants/internal-common-strings.js';
import { first } from '../../../fd-toolbox/server/collections/single-funcs.js';

var __defProp=Object['defineProperty'],__name=(_0x3f6357,_0x52600a)=>__defProp(_0x3f6357,'name',{'value':_0x52600a,'configurable':!![]});const ruleName='must-not-use-see-link-in-docs-if-type-available';const ruleContent='\x0a###\x20**Must\x20not**\x20use\x20see\x20link\x20in\x20docs\x20if\x20type\x20available.\x0a\x0a####\x20Wrong\x0a\x0aexport\x20interface\x20FooProps\x20{\x0a\x20\x20\x20\x20/**\x20Meta\x20data\x20that\x20is\x20used\x20in\x20Foo\x20component,\x20@see\x20{@link\x20FooMetaData}*/\x0a\x20\x20\x20\x20fooMetaData:\x20FooMetaData;\x0a}\x0a\x0a####\x20Correct\x0a\x0aexport\x20interface\x20FooProps\x20{\x0a\x20\x20\x20\x20/**\x20Meta\x20data\x20that\x20is\x20used\x20in\x20Foo\x20component\x20*/\x0a\x20\x20\x20\x20fooMetaData:\x20FooMetaData;\x0a}\x0a\x0a####\x20Why\x0a\x0aLinks\x20to\x20imported\x20interfaces\x20and\x20types\x20of\x20properties\x20are\x20added\x20automatically,\x20there\x27s\x20no\x20need\x20to\x20duplicate\x20link\x20in\x20docs\x20comments',constants={'patterns':{'seeLink':/@see{@link[^}]+}/},'fixTypes':{'removeRange':'removeRange','replace':navigationMethodNames['replace']}};var mustNotUseSeeLinkInDocsIfTypeAvailable = createEslintRule(ruleName,ruleContent,__name(function create(_0x2e2a0a){const _0xf06880=_0x2e2a0a['sourceCode'],_0x4d9b5=/@see\s+{@link\s+([^}\s]+)\s*}/;return {'TSPropertySignature'(_0x470484){const _0x44b847=_0x470484['typeAnnotation']?.['typeAnnotation'],_0x161365=_0xf06880['getCommentsBefore'](_0x470484);if(!_0x44b847||_0x161365['length']===0x116f+0x6*0x359+-0x235*0x11||_0x44b847['type']!==nodeTypes['TSTypeReference']||!isIdentifier(_0x44b847['typeName']))return;const _0x21b6f5=_0x44b847['typeName']['name'];_0x161365['filter'](_0x551fb9=>_0x551fb9['type']===nodeTypes['Block']&&_0x551fb9['value']['startsWith']('*'))['forEach'](_0x2e35b6=>{const _0x4397ef=_0x4d9b5['exec'](_0x2e35b6['value']);_0x4397ef&&_0x4397ef[-0xa23+0x18d6+0x39*-0x42]===_0x21b6f5&&_0x2e2a0a['report']({'node':_0x2e35b6,'messageId':ruleName,'fix'(_0x5bf6ad){const _0x4813ee=getFixInstruction(_0x2e35b6,_0x4397ef,_0xf06880);let _0x489ca1=[];return _0x4813ee['type']===constants['fixTypes']['replace']&&(_0x489ca1=[_0x5bf6ad['replaceText'](_0x2e35b6,_0x4813ee['text'])]),_0x4813ee['type']===constants['fixTypes']['removeRange']&&(_0x489ca1=[_0x5bf6ad['removeRange']([first(_0x4813ee['range']),_0x4813ee['range'][0x2143+-0x2e0+-0x1e62]])]),_0x489ca1;}});});}};},'create'),{'fixable':eslintFixTypeNames['code']});function createRemoveRangeFix(_0x37c23e,_0x433dff){const _0x3db878=[_0x37c23e,_0x433dff];return {'type':constants['fixTypes']['removeRange'],'range':_0x3db878};}__name(createRemoveRangeFix,'createRemoveRangeFix');function createReplaceFix(_0x471232){return {'type':constants['fixTypes']['replace'],'text':_0x471232};}__name(createReplaceFix,'createReplaceFix');function getStandaloneFix(_0x46bb36,_0x15c6b0){const _0x506b20=_0x15c6b0['getIndexFromLoc']({'line':_0x46bb36['loc']['start']['line'],'column':0x0});let _0x308534=_0x46bb36['range'][0x16ea+-0x1750+0x67*0x1];return _0x15c6b0['text']['charAt'](_0x308534)==='\x0a'&&(_0x308534+=-0x4*0x4b7+0x26b6+-0x13d9),createRemoveRangeFix(_0x506b20,_0x308534);}__name(getStandaloneFix,'getStandaloneFix');function getMultilineFix(_0x3decd2,_0x25546f,_0xe9c3e){const _0x3ba692=_0x3decd2['split']('\x0a'),_0xc77c8d=_0x3ba692['findIndex'](_0x4857a9=>_0x4857a9['includes'](_0x25546f));let _0x143fcd;if(_0xc77c8d!==-(-0x1276+-0x1e55+0x30cc)){const _0x442128=_0x3ba692[_0xc77c8d],_0x326aeb=_0xe9c3e(_0x442128)['replace'](constants['patterns']['seeLink'],'');if(!_0x326aeb){_0x3ba692['splice'](_0xc77c8d,-0x4*0x70+0xdfd*0x1+-0xc*0x105);const _0xea688b=_0x3ba692['filter']((_0x262a6a,_0x11d474)=>{const _0x35a45f=_0x11d474===0x2692+-0x47a*0x1+-0x2218||_0x11d474===_0x3ba692['length']-(-0x346*-0x9+-0x19a1+-0x3d4);if(_0x35a45f)return !![];return _0x262a6a['trim']()!=='*';});_0x143fcd=createReplaceFix(_0xea688b['join']('\x0a'));}}return _0x143fcd;}__name(getMultilineFix,'getMultilineFix');function getInlineFix(_0x2bb9ea,_0x1ffdb8,_0x59b18a){const _0x3f07b3=_0x1ffdb8['indexOf'](_0x59b18a),_0x4f967e=first(_0x2bb9ea['range'])+_0x3f07b3,_0x3f2fb3=_0x4f967e+_0x59b18a['length'],_0x14cc53=createRemoveRangeFix(_0x4f967e,_0x3f2fb3);return _0x14cc53;}__name(getInlineFix,'getInlineFix');function getFixInstruction(_0x30aedb,_0x55014f,_0x1c8108){const _0x5952ea=_0x1c8108['getText'](_0x30aedb),_0x3e446d=first(_0x55014f),_0xbf61c6=__name(_0x27837b=>_0x27837b['replace'](/[/*\s]/g,''),'stripCommentDecorations'),_0x1a64c9=_0xbf61c6(_0x5952ea)['replace'](constants['patterns']['seeLink'],'');let _0x3d5d14=getInlineFix(_0x30aedb,_0x5952ea,_0x3e446d);!_0x1a64c9&&(_0x3d5d14=getStandaloneFix(_0x30aedb,_0x1c8108));if(_0x1a64c9&&_0x5952ea['includes']('\x0a')){const _0x1da87e=getMultilineFix(_0x5952ea,_0x3e446d,_0xbf61c6);_0x1da87e&&(_0x3d5d14=_0x1da87e);}return _0x3d5d14;}__name(getFixInstruction,'getFixInstruction');

export { mustNotUseSeeLinkInDocsIfTypeAvailable as default, ruleName };
