'use strict';
import { ESLintUtils } from '@typescript-eslint/utils';
import _0x3881d1__default from 'fs';
import _0x1869d0__default from 'path';
import { isCamelCase, isPascalCase } from '@flint/infra/analysis/name-analysis';
import { caseTransitionBoundary } from '@flint/infra/constants/rules-regex';
import { ruleTypes, url } from '@flint/infra/constants/rules-meta';
import { jsBasicTypes } from '../../../base-repo/constants/basic-types.js';
import { firstOrUndefined, first } from '../../../fd-toolbox/server/collections/single-funcs.js';

var __defProp=Object['defineProperty'],__name=(_0xd8686b,_0x7b2451)=>__defProp(_0xd8686b,'name',{'value':_0x7b2451,'configurable':!![]});const ruleName='must-use-link-for-camel-or-pascal-case-names';const constants={'messageIds':{'mustUseLinkForCamelOrPascalCaseNames':'mustUseLinkForCamelOrPascalCaseNames'},'meta':{'type':ruleTypes['suggestion'],'docs':{'description':'Enforce\x20using\x20markdown\x20links\x20for\x20camelCase\x20or\x20PascalCase\x20words\x20in\x20.md\x20files.'},'messages':{'mustUseLinkForCamelOrPascalCaseNames':'must-use-link-for-camel-or-pascal-case-names\x0a###\x20**Must**\x20use\x20{@link}\x20for\x20camelCase\x20or\x20PascalCase\x20names\x20in\x20docs.\x0a\x0aEvery\x20camelCase\x20or\x20PascalCase\x20name\x20in\x20markdown\x20should\x20be\x20linked\x20to\x20a\x20relevant\x20reference.\x0a\x0a####\x20Wrong\x0a\x0aThis\x20project\x20uses\x20MyComponent\x20and\x20someUtility.\x0a\x0a####\x20Correct\x0a\x0aThis\x20project\x20uses\x20{@link\x20MyComponent}\x20and\x20{@link\x20someUtility}.\x0a\x0a####\x20Why\x0a\x0aLinks\x20help\x20readers\x20quickly\x20navigate\x20to\x20definitions\x20and\x20keep\x20documentation\x20connected\x20to\x20the\x20codebase.'},'schema':[{'type':'object','properties':{'allowed':{'type':jsBasicTypes['array'],'items':{'type':'string'}}},'additionalProperties':![]}]},'allowed':Array['from']([])},createRule=ESLintUtils['RuleCreator'](_0x3937f2=>''+url+_0x3937f2),mustUseLinkForCamelOrPascalCaseNames=createRule({'name':ruleName,'meta':constants['meta'],'defaultOptions':[{'allowed':constants['allowed']}],'create'(_0x12754f){const _0x5516f9=firstOrUndefined(_0x12754f['options'])??{'allowed':constants['allowed']},_0x359818=new Set(_0x5516f9['allowed']),_0x5b507e=_0x12754f['filename'];let _0x517649='';try{_0x517649=_0x3881d1__default['readFileSync'](_0x1869d0__default['resolve'](_0x5b507e),'utf8');}catch{_0x517649=_0x12754f['sourceCode']['text'];}return {'Program'(){_0x517649=_0x517649['replace'](/```[\s\S]*?```/g,''),_0x517649=_0x517649['replace'](/~~~[\s\S]*?~~~/g,'');const _0x490fad=_0x517649['matchAll'](/\w+/g);for(const _0x2f8050 of _0x490fad){const _0x1c303e=first(_0x2f8050),_0x5b15c0=_0x2f8050['index']??0x1724+0x1910+-0x3034,_0x333e49=_0x1c303e['split'](caseTransitionBoundary)['length'];if((isCamelCase(_0x1c303e)||isPascalCase(_0x1c303e))&&_0x333e49>0x5*0x510+-0x254+-0x16fb&&!isWordLinkedMarkdownAtIndex(_0x517649,_0x1c303e,_0x5b15c0)&&!isWordLinkedJSDocnAtIndex(_0x517649,_0x1c303e,_0x5b15c0)&&!_0x359818['has'](_0x1c303e)){const _0x1d505d=getLocFromIndex(_0x517649,_0x5b15c0),_0x2e8027=getLocFromIndex(_0x517649,_0x5b15c0+_0x1c303e['length']);_0x12754f['report']({'loc':{'start':_0x1d505d,'end':_0x2e8027},'messageId':constants['messageIds']['mustUseLinkForCamelOrPascalCaseNames'],'data':{'word':_0x1c303e}});}}}};}});function getLocFromIndex(_0x362f4e,_0x262fec){const _0x17723f=_0x362f4e['slice'](-0x22d2*-0x1+0xde+-0x23b0,_0x262fec)['split']('\x0a'),_0x6369cd=_0x17723f['length'],_0x1aabe3=_0x17723f[_0x17723f['length']-(-0x1*-0xd36+-0x18a9*0x1+-0x1*-0xb74)]['length'];return {'line':_0x6369cd,'column':_0x1aabe3};}__name(getLocFromIndex,'getLocFromIndex');function isWordLinkedMarkdownAtIndex(_0x391caf,_0x3fcf8e,_0x3af625){let _0xb49e7b=![];const _0x3f0695=/^(?:\.{1,2}\/)?[^\s)]+\.(?:md|html|tsx?|jsx?)$/i,_0x5e13fb=_0x391caf['lastIndexOf']('[',_0x3af625),_0x2bee8c=_0x5e13fb!==-(-0x3*0x17d+0x15bf+-0x1147)?_0x391caf['indexOf'](']',_0x5e13fb+(-0x3*-0x5a1+-0x9*0x1f3+0x1*0xa9)):-(-0x243*-0xe+0x7*-0x475+0x2*-0x3b);if(_0x5e13fb!==-(0x7*-0x541+0x24a+0x373*0xa)&&_0x2bee8c!==-(0x91e+0x52*-0x10+-0x3fd)&&_0x3af625>=_0x5e13fb+(0x4*-0x88d+0xc3*0x1b+-0x1*-0xda4)&&_0x3af625+_0x3fcf8e['length']<=_0x2bee8c){let _0x517370=_0x2bee8c+(0x33b*0x7+-0x3e*0x69+0x2d2);while(_0x517370<_0x391caf['length']&&/\s/['test'](_0x391caf[_0x517370]))_0x517370++;if(_0x391caf[_0x517370]==='('){const _0x3588d9=_0x517370,_0x50a817=_0x391caf['indexOf'](')',_0x3588d9+(0x1ffe+-0x2ce*0x6+-0xf29));if(_0x50a817!==-(0xf67+-0x39d*0x4+-0x79*0x2)){const _0x2ba4a0=_0x391caf['slice'](_0x3588d9+(0x229b+-0x105d+-0x123d),_0x50a817)['trim']();_0xb49e7b=_0x3f0695['test'](_0x2ba4a0);}}else _0x391caf[_0x517370]==='['&&(_0xb49e7b=!![]);}return _0xb49e7b;}__name(isWordLinkedMarkdownAtIndex,'isWordLinkedMarkdownAtIndex');function isWordLinkedJSDocnAtIndex(_0x18c688,_0x2ec3fe,_0x3c0d32){const _0x592265=/\{@link\s+([^\s}]+)\s*\}/g;for(const _0x2ea8a4 of _0x18c688['matchAll'](_0x592265)){const _0x34ca69=_0x2ea8a4[0x1d4d+0x4b3*-0x1+-0x1899],_0x510acf=_0x2ea8a4['index']??-0x2548*0x1+0x238f+0x1b9;if(_0x34ca69['includes'](_0x2ec3fe)&&_0x3c0d32>=_0x510acf&&_0x3c0d32<=_0x510acf+first(_0x2ea8a4)['length'])return !![];}return ![];}__name(isWordLinkedJSDocnAtIndex,'isWordLinkedJSDocnAtIndex');

export { mustUseLinkForCamelOrPascalCaseNames as default, ruleName };
