'use strict';
import * as _0x3881d1 from 'fs';
import * as _0x3d0a7b from 'child_process';
import * as _0x545827 from 'os';
import _0x1c3e3a from 'node:path';
import { fileURLToPath } from 'node:url';
import { folders, packagesPath, files } from '../../../base-repo/app-constants/project-paths.js';
import { fileExtensions } from '../../../base-repo/app-constants/internal-system-constants.js';
import { cliMessages, stdioStatuses } from '../../../base-repo/constants/tools-constants.js';
import { executeCommandWithCombinedOutput, filterLintableFiles, runEslintBatches } from '@code-quality/config-aware-lint/resolve-and-run-eslint';
import { cliLogInfo, cliLogWarning, cliLogError } from '../../../fd-toolbox/logging/cli-logger.js';
import { prettierBinary } from '../../ci/constants/paths.js';

var __defProp=Object['defineProperty'],__name=(_0x1b7c35,_0x3b50ef)=>__defProp(_0x1b7c35,'name',{'value':_0x3b50ef,'configurable':!![]});class PreCommitError extends Error{static{__name(this,'PreCommitError');}['details'];constructor(_0xf8a221,_0x364987){super(_0xf8a221),this['name']=PreCommitError['name'],this['details']=_0x364987;}}const gitCommands={'stagedFilesCommand':'git\x20diff\x20--name-only\x20--cached','stagedFilesToFormatCommand':'git\x20diff\x20--cached\x20--name-only\x20--diff-filter=ACMR','unstagedFilesCommand':'git\x20diff\x20--name-status\x20--\x20.\x20\x27:(exclude)packages/flint\x27\x20\x27:(exclude)packages/test\x27','untrackedFilesCommand':'git\x20ls-files\x20--others\x20--exclude-standard'};const errorMessages={'packageNotFound':'Please\x20ensure\x20it\x20is\x20installed\x20as\x20a\x20devDependency.'};let gitRepoRelativePath='';function hideDirtyWorkingTreeChanges(){cliLogInfo('\x0aChecking\x20for\x20unstaged\x20changes\x20in\x20staged\x20files...');const _0x477215=getGitChangedFiles(gitCommands['stagedFilesToFormatCommand']),_0x424b33=new Set(getGitChangedFiles('git\x20diff\x20--name-only\x20--diff-filter=ACMR')),_0x395b29=_0x477215['filter'](_0x561792=>_0x424b33['has'](_0x561792));if(_0x395b29['length']===0x25a7+0x19b6+-0x3*0x151f)return cliLogInfo('No\x20partially\x20staged\x20files\x20found.'),void(0x27*0xda+0x2425*0x1+-0x455b);cliLogInfo('Temporarily\x20hiding\x20unstaged\x20hunks\x20from\x20partially\x20staged\x20files...');const _0x2260b0=_0x395b29['map'](quoteCommandArg)['join']('\x20'),_0x37d6e0=executeCommand('git\x20diff\x20--binary\x20-U0\x20--\x20'+_0x2260b0);_0x37d6e0['status']!==0x20cc+0x194*-0x12+-0x464&&preCommitCheckExitWithError('Failed\x20to\x20capture\x20unstaged\x20changes\x20from\x20partially\x20staged\x20files.',_0x37d6e0['stderr']??_0x37d6e0['stdout']);const _0x4a4ac5=_0x3881d1['mkdtempSync'](_0x1c3e3a['join'](_0x545827['tmpdir'](),'pre-commit-script-')),_0x3f2f66=_0x1c3e3a['join'](_0x4a4ac5,'unstaged.patch');_0x3881d1['writeFileSync'](_0x3f2f66,_0x37d6e0['stdout'],'utf8');const _0x1f0141=executeCommand('git\x20apply\x20-R\x20--unidiff-zero\x20--whitespace=nowarn\x20'+quoteCommandArg(_0x3f2f66));return _0x1f0141['status']!==0x1efd*-0x1+-0x2*-0x11ed+-0x4dd&&preCommitCheckExitWithError('Failed\x20to\x20temporarily\x20hide\x20unstaged\x20hunks\x20from\x20partially\x20staged\x20files.',_0x1f0141['stderr']??_0x1f0141['stdout']),cliLogInfo('Unstaged\x20hunks\x20hidden\x20until\x20checks\x20finish.'),{'patchFilePath':_0x3f2f66,'tempDirPath':_0x4a4ac5};}__name(hideDirtyWorkingTreeChanges,'hideDirtyWorkingTreeChanges');function restoreDirtyWorkingTreeChanges(_0x371523){if(!_0x371523)return;cliLogInfo('\x0aRestoring\x20unstaged\x20hunks\x20for\x20partially\x20staged\x20files...');const _0x10ddf5=executeCommand('git\x20apply\x20--unidiff-zero\x20--whitespace=nowarn\x20'+quoteCommandArg(_0x371523['patchFilePath']));_0x10ddf5['status']!==-0x1*0xeed+0x1c2+0xd2b&&preCommitCheckExitWithError('Failed\x20to\x20restore\x20temporarily\x20hidden\x20unstaged\x20hunks.',(_0x10ddf5['stderr']??_0x10ddf5['stdout'])+'\x0aSaved\x20patch:\x20'+_0x371523['patchFilePath']),_0x3881d1['rmSync'](_0x371523['tempDirPath'],{'recursive':!![],'force':!![]}),cliLogInfo('Restored\x20unstaged\x20hunks.');}__name(restoreDirtyWorkingTreeChanges,'restoreDirtyWorkingTreeChanges');function stageFiles(_0xd53b9f){if(_0xd53b9f['length']===-0x20a+0xa87+-0x87d)return;const _0x28dff0=_0xd53b9f['map'](quoteCommandArg)['join']('\x20'),_0x55168c=executeCommand('git\x20add\x20--\x20'+_0x28dff0);_0x55168c['status']!==0x1939+0x5d1+-0x1*0x1f0a&&preCommitCheckExitWithError('Failed\x20to\x20stage\x20files\x20updated\x20by\x20Prettier.',_0x55168c['stderr']??_0x55168c['stdout']);}__name(stageFiles,'stageFiles');function logErrorSeparator(){cliLogInfo(cliMessages['separatorError']);}__name(logErrorSeparator,'logErrorSeparator');function preCommitCheckExitWithError(_0x4025d3,_0x5c1cf0){throw new PreCommitError(_0x4025d3,_0x5c1cf0);}__name(preCommitCheckExitWithError,'preCommitCheckExitWithError');function printFailureMessageBlock(){cliLogInfo(cliMessages['separatorLine']),logErrorSeparator(),logErrorSeparator(),logErrorSeparator(),cliLogInfo('-----------------------------------------\x20ERROR\x20-----------------------------------------'),cliLogInfo('FAIL\x20FAIL\x20FAIL\x20FAIL\x20FAIL\x20FAIL\x20FAIL\x20Pre\x20commit\x20check\x20failed.\x20FAIL\x20FAIL\x20FAIL\x20FAIL\x20FAIL\x20FAIL\x0a');}__name(printFailureMessageBlock,'printFailureMessageBlock');function findAndSwitchToMonorepoRoot(){try{let _0x39ecdb=process['cwd']();const _0x593b97=_0x1c3e3a['parse'](_0x39ecdb)['root'];while(!_0x3881d1['existsSync'](_0x1c3e3a['join'](_0x39ecdb,folders['dotGit']))&&_0x39ecdb!==_0x593b97){_0x39ecdb=_0x1c3e3a['dirname'](_0x39ecdb);}!_0x3881d1['existsSync'](_0x1c3e3a['join'](_0x39ecdb,folders['dotGit']))&&(_0x39ecdb=process['cwd']());let _0x4b0e1e=_0x39ecdb;while(!![]){const _0x37f2fc=_0x1c3e3a['join'](_0x4b0e1e,packagesPath['git'],files['preCommitScript']);if(_0x3881d1['existsSync'](_0x37f2fc)){const _0x2cd6e2=_0x1c3e3a['relative'](_0x4b0e1e,_0x39ecdb)['replace'](/\\/g,'/');return process['chdir'](_0x4b0e1e),cliLogInfo('Switched\x20to\x20monorepo\x20root:\x20'+_0x4b0e1e),_0x2cd6e2===''?'':_0x2cd6e2;}const _0x57aac3=_0x1c3e3a['dirname'](_0x4b0e1e);if(_0x57aac3===_0x4b0e1e)break;_0x4b0e1e=_0x57aac3;}return cliLogWarning('Could\x20not\x20find\x20monorepo\x20root.\x20Continuing\x20from\x20current\x20directory.'),'';}catch(_0x46f5b1){return cliLogWarning('Error\x20finding\x20monorepo\x20root:\x20'+_0x46f5b1+'.\x20Continuing\x20from\x20current\x20directory.'),'';}}__name(findAndSwitchToMonorepoRoot,'findAndSwitchToMonorepoRoot');function isMainModule(_0x2cfb52){const _0xe9e454=process['argv'][-0x2*-0xb1+-0x4*-0x2bf+-0xc5d];if(!_0xe9e454)return ![];return _0x2cfb52==='file://'+_0xe9e454||fileURLToPath(_0x2cfb52)===_0xe9e454;}__name(isMainModule,'isMainModule');function executeCommand(_0xa4fcbe,_0x23d6e5){try{const _0x409589=_0x3d0a7b['execSync'](_0xa4fcbe,{..._0x23d6e5,'encoding':'utf-8','stdio':stdioStatuses['pipe']});return {'stdout':_0x409589['toString'](),'stderr':'','status':0x0};}catch(_0x138569){return {'stdout':_0x138569['stdout']?.['toString']()??'','stderr':_0x138569['stderr']?.['toString']()??'','status':_0x138569['status']===void(0x5*0x482+0x1d35+0x1*-0x33bf)?-0x2d5*0x2+0x283+0xca*0x4:_0x138569['status']};}}__name(executeCommand,'executeCommand');function withRepoPath(_0x216269,_0x4a6f92){return _0x4a6f92['map'](_0x23247e=>_0x216269+'/'+_0x23247e);}__name(withRepoPath,'withRepoPath');function quoteCommandArg(_0x374311){return '\x22'+_0x374311['replace'](/"/g,'\x5c\x22')+'\x22';}__name(quoteCommandArg,'quoteCommandArg');function runTypeCheck(){cliLogInfo('\x0aRunning\x20TypeScript\x20type\x20check...');const _0x1b5a05=executeCommand(gitCommands['stagedFilesCommand']);if(_0x1b5a05['status']!==-0x10a6+-0x9db*0x2+0x1*0x245c)cliLogWarning('Could\x20not\x20get\x20staged\x20files\x20for\x20TypeScript\x20check.');else {let _0x3796b1=_0x1b5a05['stdout']['trim']()['split']('\x0a');gitRepoRelativePath&&(_0x3796b1=withRepoPath(gitRepoRelativePath,_0x3796b1));const _0xe063c7=_0x3796b1['filter'](_0x386863=>{return /\.(ts|tsx)$/['test'](_0x386863)&&!_0x386863['includes'](folders['nodeModules'])&&_0x3881d1['existsSync'](_0x386863);});if(_0xe063c7['length']===-0x121*0x8+0x18ac+-0x23c*0x7)cliLogInfo('No\x20TypeScript\x20files\x20to\x20check.');else {const _0xfe441c='Found\x20'+_0xe063c7['length']+'\x20TypeScript\x20file(s).';cliLogInfo(_0xfe441c+'\x20Running\x20project-wide\x20type\x20check...');const _0x4be733='npx\x20tsc\x20--noEmit\x20--skipLibCheck',_0x5b644f=executeCommandWithCombinedOutput(_0x4be733);if(_0x5b644f['status']!==-0x1*0xccf+0x19a9*-0x1+0x99e*0x4){const _0x57a2f8=_0x5b644f['output'],_0x14eb4f=_0x57a2f8['split']('\x0a'),_0x4591ff=_0x14eb4f['filter'](_0x523b85=>isRelevantTsError(_0x523b85,_0xe063c7));_0x4591ff['length']>-0xb0e+-0x948+-0x89*-0x26&&preCommitCheckExitWithError('TypeScript\x20type\x20check\x20failed.',_0x4591ff['join']('\x0a')),cliLogInfo('TypeScript\x20type\x20check\x20passed\x20(no\x20errors\x20in\x20staged\x20files).');}else cliLogInfo('TypeScript\x20type\x20check\x20successful.');}}}__name(runTypeCheck,'runTypeCheck');function isRelevantTsError(_0x3ddcf7,_0x2a357d){if(!_0x3ddcf7['includes']('error\x20TS'))return ![];if(_0x3ddcf7['includes'](folders['nodeModules']))return ![];return _0x2a357d['some'](_0x592d17=>_0x3ddcf7['includes'](_0x592d17));}__name(isRelevantTsError,'isRelevantTsError');function shouldSkipChecks(){let _0x5a3810=![];const _0x27837e=executeCommand(gitCommands['stagedFilesCommand']);if(_0x27837e['status']!==0x1f45+-0x425+0xe0*-0x1f){cliLogWarning('Could\x20not\x20determine\x20changed\x20files.\x20Proceeding\x20with\x20checks...');if(_0x27837e['stderr'])cliLogWarning(_0x27837e['stderr']);}else {const _0x4ec46c=_0x27837e['stdout']['trim']();if(_0x4ec46c!==''){const _0x4fb53b=_0x4ec46c['split']('\x0a'),_0x20158c=_0x4fb53b['some'](_0x2a16a6=>!_0x2a16a6['endsWith'](fileExtensions['md'])&&!_0x2a16a6['startsWith'](packagesPath['packagesDocsContent']));!_0x20158c&&(cliLogInfo('Skipping\x20pre-commit\x20checks:\x20Only\x20.md\x20files\x20or\x20files\x20from\x20packages/docs/content\x20are\x20changed.'),_0x5a3810=!![]);}}return _0x5a3810;}__name(shouldSkipChecks,'shouldSkipChecks');function getGitChangedFiles(_0x19343d){const _0x20d77f=executeCommand(_0x19343d);_0x20d77f['status']!==-0xeb5+0x10fa+-0x7*0x53&&preCommitCheckExitWithError('Failed\x20to\x20inspect\x20git\x20file\x20state.',_0x20d77f['stderr']??_0x20d77f['stdout']);const _0x4a5b1c=_0x20d77f['stdout']['trim']()['split']('\x0a')['filter'](_0xc339e5=>!!_0xc339e5);return _0x4a5b1c;}__name(getGitChangedFiles,'getGitChangedFiles');function checkVSCodePrettierExtension(){cliLogInfo('\x0aChecking\x20for\x20VSCode\x20Prettier\x20extension...');const _0x33260d=executeCommand('command\x20-v\x20code');if(_0x33260d['status']===0x1084+0x1*0x1e07+0x94f*-0x5){const _0x11b7f7=executeCommand('code\x20--list-extensions\x20|\x20grep\x20esbenp.prettier-vscode');_0x11b7f7['status']!==0x1eef+0xccd+0x137*-0x24?cliLogWarning('VSCode\x20Prettier\x20extension\x20(esbenp.prettier-vscode)\x20not\x20found.'):cliLogInfo('VSCode\x20Prettier\x20extension\x20found.');}else cliLogWarning('VS\x20Code\x20\x27code\x27\x20command\x20not\x20found\x20in\x20PATH.\x20Cannot\x20check\x20extensions.');}__name(checkVSCodePrettierExtension,'checkVSCodePrettierExtension');function checkPrettierDependencies(){cliLogInfo('\x0aChecking\x20for\x20Prettier\x20dependencies...');const _0x4ec3cf=executeCommand('pnpm\x20list');if(_0x4ec3cf['status']!==0x21a2+-0x67f*-0x6+0x1834*-0x3){preCommitCheckExitWithError('Failed\x20to\x20check\x20pnpm\x20dependencies\x20using\x20\x27pnpm\x20list\x27.',_0x4ec3cf['stderr']??_0x4ec3cf['stdout']);return;}const _0x44a763=_0x4ec3cf['stdout'],_0x4c9d40=/\bprettier-plugin-tailwindcss\b/['test'](_0x44a763),_0x13ba0a=/\bprettier\b/['test'](_0x44a763);!_0x4c9d40&&preCommitCheckExitWithError('\x27prettier-plugin-tailwindcss\x27\x20not\x20found\x20in\x20\x27pnpm\x20list\x27\x20output.',errorMessages['packageNotFound']);!_0x13ba0a&&preCommitCheckExitWithError('\x27prettier\x27\x20package\x20not\x20found\x20in\x20\x27pnpm\x20list\x27\x20output.',errorMessages['packageNotFound']);const _0x4b334d=_0x3881d1['existsSync'](prettierBinary);!_0x4b334d&&preCommitCheckExitWithError('Prettier\x20binary\x20not\x20found\x20at\x20'+prettierBinary+'.','Ensure\x20Prettier\x20is\x20installed\x20correctly.'),cliLogInfo('Prettier\x20dependencies\x20and\x20binary\x20found.');}__name(checkPrettierDependencies,'checkPrettierDependencies');function checkPrettierFormatting(){cliLogInfo('\x0aVerifying\x20Prettier\x20formatting\x20on\x20staged\x20files...');const _0x4e76bb=executeCommand(gitCommands['stagedFilesToFormatCommand']);if(_0x4e76bb['status']!==0x22*0x1+-0x5*-0x1af+-0x88d||_0x4e76bb['stdout']['trim']()===''){cliLogInfo('No\x20files\x20to\x20verify,\x20skipping\x20Prettier.');if(_0x4e76bb['stderr'])cliLogWarning(_0x4e76bb['stderr']);}else {const _0x2667f9=_0x4e76bb['stdout']['trim']()['split']('\x0a')['filter'](Boolean);let _0x3a26f6=[..._0x2667f9];gitRepoRelativePath&&(_0x3a26f6=withRepoPath(gitRepoRelativePath,_0x3a26f6)),_0x3a26f6['length']===-0xd29+-0xf32*-0x1+0x1*-0x209?cliLogInfo('No\x20staged\x20files\x20to\x20verify\x20for\x20Prettier\x20formatting.'):runPrettierFormattingCheck(_0x3a26f6);}}__name(checkPrettierFormatting,'checkPrettierFormatting');function runPrettierFormattingCheck(_0x598eb8){const _0x1a936c=_0x598eb8['map'](quoteCommandArg)['join']('\x20'),_0x2f6b65='npx\x20prettier\x20--ignore-unknown\x20--check\x20'+_0x1a936c;try{_0x3d0a7b['execSync'](_0x2f6b65,{'stdio':stdioStatuses['inherit']});}catch(_0x4f7768){const _0x501937=_0x4f7768 instanceof Error?_0x4f7768['message']:String(_0x4f7768);preCommitCheckExitWithError('Prettier\x20formatting\x20verification\x20failed.',['Some\x20staged\x20files\x20are\x20not\x20correctly\x20formatted.','Prettier\x20--write\x20may\x20not\x20have\x20applied\x20changes.','',_0x501937]['join']('\x0a'));}cliLogInfo('Prettier\x20formatting\x20verification\x20passed.');}__name(runPrettierFormattingCheck,'runPrettierFormattingCheck');function runPrettier(){cliLogInfo('\x0aFormatting\x20staged\x20files\x20with\x20Prettier...');const _0x337215=executeCommand(gitCommands['stagedFilesToFormatCommand']);if(_0x337215['status']!==0x374*-0x5+-0x3c3+-0x1*-0x1507||_0x337215['stdout']['trim']()===''){cliLogInfo('No\x20files\x20to\x20format\x20or\x20error\x20obtaining\x20file\x20list.\x20Skipping\x20Prettier\x20run.');if(_0x337215['stderr'])cliLogWarning(_0x337215['stderr']);return;}const _0x1d8496=_0x337215['stdout']['trim']()['split']('\x0a')['filter'](Boolean);let _0xd2b042=[..._0x1d8496];gitRepoRelativePath&&(_0xd2b042=_0xd2b042['map'](_0x2a35df=>gitRepoRelativePath+'/'+_0x2a35df)),_0xd2b042['length']>-0x21eb*-0x1+0xfe0+-0x7*0x71d?(formatStagedFilesWithPrettier(_0xd2b042),stageFiles(_0x1d8496)):cliLogInfo('No\x20files\x20found\x20by\x20git\x20diff\x20for\x20Prettier\x20to\x20format.'),cliLogInfo('Prettier\x20changes\x20were\x20staged\x20automatically\x20when\x20needed.');}__name(runPrettier,'runPrettier');function formatStagedFilesWithPrettier(_0x3c3f0c){cliLogInfo('Formatting\x20'+_0x3c3f0c['length']+'\x20file(s)\x20with\x20Prettier...');const _0x5bc191=0xf33*0x1+0xab8+-0x19b9;let _0x3ead3a=![];for(let _0x2591de=0x427*0x1+0x6*-0x32b+0xedb;_0x2591de<_0x3c3f0c['length'];_0x2591de+=_0x5bc191){const _0x4242bd=_0x3c3f0c['slice'](_0x2591de,_0x2591de+_0x5bc191),_0x2e6620=_0x4242bd['map'](_0x3d0e92=>{const _0xfee7f4=_0x3d0e92['replace'](/"/g,'\x5c\x22');return '\x22'+_0xfee7f4+'\x22';})['join']('\x20'),_0x3ca1ab='npx\x20prettier\x20--ignore-unknown\x20--write\x20'+_0x2e6620;try{_0x3d0a7b['execSync'](_0x3ca1ab,{'stdio':stdioStatuses['inherit']});}catch(_0x33a32e){_0x3ead3a=!![];const _0x16c629=_0x33a32e instanceof Error?_0x33a32e['message']:String(_0x33a32e);cliLogError('Error\x20formatting\x20batch\x20'+(_0x2591de/_0x5bc191+(-0x1c9*-0x1+0x24f6+-0x72*0x57))+':\x20'+_0x16c629);}}_0x3ead3a&&preCommitCheckExitWithError('Error\x20running\x20Prettier.','One\x20or\x20more\x20batches\x20failed\x20to\x20format.'),cliLogInfo('Prettier\x20formatting\x20complete.\x20Review\x20output\x20above\x20for\x20changes.');}__name(formatStagedFilesWithPrettier,'formatStagedFilesWithPrettier');function processAndReportESLintOutput(_0x25e006,_0x38525f){const _0x583237=_0x25e006['split']('\x0a'),_0x281669=_0x583237['filter'](_0x53c16b=>!_0x53c16b['startsWith']('>\x20eslint')&&!/saas-kit@/['test'](_0x53c16b)&&!/^\\s*✖/['test'](_0x53c16b))['filter'](_0x121ba7=>_0x121ba7['trim']()!=='')['join']('\x0a');let _0x3142d7=_0x38525f;const _0x2ff01a=/\\d+:\\d+\\s+error\\s+/;_0x2ff01a['test'](_0x281669)&&(_0x3142d7=!![]);if(_0x3142d7){const _0xadfdbd=_0x281669['match'](/\\d+:\\d+\\s+error\\s+/g)??[],_0x3b38af=_0x281669['match'](/\\d+:\\d+\\s+warning\\s+/g)??[],_0x517215=_0xadfdbd['length'],_0x174e22=_0x3b38af['length'];let _0x17314c=_0x281669['trimEnd']();_0x17314c+='\x0a\x0aESLint\x20Summary:\x0a\x20\x20Errors\x20found:\x20'+_0x517215+'\x0a\x20\x20Warnings\x20found:\x20'+_0x174e22,preCommitCheckExitWithError('ESLint\x20found\x20errors.',_0x17314c);}cliLogInfo('ESLint\x20check\x20passed.');}__name(processAndReportESLintOutput,'processAndReportESLintOutput');function runESLint(){cliLogInfo('\x0aRunning\x20ESLint\x20on\x20staged\x20files...');const _0x39838d=executeCommand(gitCommands['stagedFilesCommand']);let _0x35bf90=[];if(_0x39838d['status']!==0x1*-0x853+0x2223+-0x19d0){cliLogWarning('Could\x20not\x20get\x20staged\x20files\x20for\x20ESLint.\x20Skipping\x20ESLint\x20check.');if(_0x39838d['stderr'])cliLogWarning(_0x39838d['stderr']);return;}else {let _0xf6f9c5=_0x39838d['stdout']['trim']()['split']('\x0a');gitRepoRelativePath&&(_0xf6f9c5=withRepoPath(gitRepoRelativePath,_0xf6f9c5)),_0x35bf90=filterLintableFiles(_0xf6f9c5);}if(_0x35bf90['length']===0x1ede+0x252a+-0x4408)cliLogInfo('No\x20relevant\x20files\x20to\x20lint.');else {cliLogInfo('Linting\x20'+_0x35bf90['length']+'\x20file(s)...');const {fullLintOutput:_0x541bab,hasFailures:_0x55e1fe}=runEslintBatches(_0x35bf90);processAndReportESLintOutput(_0x541bab,_0x55e1fe);}}__name(runESLint,'runESLint');function runSubmodulesPointersChangesCheck(){cliLogInfo('\x0aChecking\x20for\x20submodules\x20commit\x20pointers\x20changes...');const _0x4d1c5d=executeCommand(gitCommands['stagedFilesCommand'])['stdout'],_0x480fa8=_0x4d1c5d['split']('\x0a')['filter'](Boolean);for(const _0x448038 of _0x480fa8){const _0x518d2e=executeCommand('git\x20diff\x20--cached\x20'+_0x448038)['stdout'];/^\+Subproject commit /m['test'](_0x518d2e)&&preCommitCheckExitWithError('It\x20is\x20forbidden\x20to\x20commit\x20changes\x20in\x20submodule\x20commits!\x20Discard\x20changes\x20in:\x20'+_0x448038);}cliLogInfo('No\x20submodules\x20commit\x20pointers\x20changes\x20found.');}__name(runSubmodulesPointersChangesCheck,'runSubmodulesPointersChangesCheck');function runPreCommitChecks(){cliLogInfo('Starting\x20pre-commit\x20checks...');if(shouldSkipChecks())return;runSubmodulesPointersChangesCheck(),checkVSCodePrettierExtension(),checkPrettierDependencies(),runPrettier(),checkPrettierFormatting(),runESLint(),runTypeCheck();}__name(runPreCommitChecks,'runPreCommitChecks');function printPreCommitFailure(_0x511d88){if(_0x511d88 instanceof PreCommitError){cliLogError(_0x511d88['message']);_0x511d88['details']&&cliLogError(_0x511d88['details']);printFailureMessageBlock();return;}throw _0x511d88;}__name(printPreCommitFailure,'printPreCommitFailure');function main(){let _0x1dcc54,_0x534848;gitRepoRelativePath=findAndSwitchToMonorepoRoot();try{_0x1dcc54=hideDirtyWorkingTreeChanges(),runPreCommitChecks();}catch(_0x1514b2){_0x534848=_0x1514b2;}finally{try{restoreDirtyWorkingTreeChanges(_0x1dcc54);}catch(_0x1aefd1){if(!_0x534848)_0x534848=_0x1aefd1;else _0x1aefd1 instanceof Error&&cliLogError('Additionally\x20failed\x20to\x20restore\x20working\x20tree\x20changes:\x20'+_0x1aefd1['message']);}}_0x534848&&(printPreCommitFailure(_0x534848),process['exit'](0x1028+0x107d+-0x20a4)),cliLogInfo('\x0a##############################\x20Pre\x20commit\x20check\x20successful.##################################'),process['exit'](-0x10ab+0x4*-0x116+0x1503);}__name(main,'main');isMainModule(import.meta.url)&&main();

export { gitCommands, hideDirtyWorkingTreeChanges, restoreDirtyWorkingTreeChanges, stageFiles };
