import n from"path";import{TELEMETRY_ENABLED as m,TELEMETRY_ENDPOINT as l}from"../../constants/index.js";import{isGraphqlDoc as c}from"../../server/plugins/graphql-docs/is-graphql-doc.js";import{isMarkdownPage as g}from"../../server/plugins/markdown/is-markdown-page.js";import{isOpenapiDoc as d}from"../../server/plugins/openapi-docs/is-openapi-doc.js";import{isReactPage as _}from"../../server/plugins/pages/is-react-page.js";import{TelemetryClient as E}from"../../shared/telemetry-client.js";import{USER_THEME_ALIAS as h}from"../../server/config/constants.js";import{readFileNames as u}from"../../server/utils/fs.js";import{getPortalConfigStats as P}from"./get-portal-config-stats.js";const C=new E(l,!m),q=(e,o,t)=>{m&&(async()=>{C.send("cli_command_executed",{arguments:e,portal_content:o&&await w(o),config:t&&P(t.getConfig())})})().catch(()=>{})},w=async e=>{let o=0,t=0,r=0,i=0;for(const{relativePath:a}of await e.fs.scan())g(a)?o++:_(a)?i++:c(a)?r++:await d(a,e)&&t++;const p=(await e.cache.load("versions-config","versions-config")).data,s=n.join(e.fs.cwd,h),f=u(s).map(a=>n.relative(s,a));return{total_pages:o+t+r+i,markdown_pages:o,openapi_pages:t,graphql_pages:r,react_pages:i,versions:{versioned_folders:p.size},user_theme_files:f}};export{q as sendCliCommandExecution,C as telemetry};
