oxlint-plugin-react-doctor 0.9.2-dev.d81eeda → 0.9.2-dev.f023fb9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{capability-DEny-1Qf.js → capability-DkrQ0p-y.js} +20 -20
- package/dist/core.js +2 -2
- package/dist/index.js +14 -14
- package/package.json +1 -1
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import{parseSync as e,visitorKeys as t}from"oxc-parser";import{KEYS as n}from"eslint-visitor-keys";import*as r from"node:fs";import*as i from"node:path";const a=[[`nextjs`,`Next.js`,`NEXT_PUBLIC_*`],[`vite`,`Vite`,`VITE_*`],[`tanstack-start`,`TanStack Start`,`VITE_*`],[`cra`,`Create React App`,`REACT_APP_*`],[`gatsby`,`Gatsby`,`GATSBY_*`]],o=e=>{for(let[t,n,r]of a)if(e(t))return`Move secrets to server-only code. In ${n}, only \`${r}\` env vars are exposed to the browser, and they must not contain secrets`},s=e=>e(`nextjs:static-export`)?`Avoid redirects inside useEffect — they flash the wrong page first. Use an event handler (e.g. onClick), or call redirect() from next/navigation during render (it prerenders a client-side redirect under output: "export"). Middleware and getServerSideProps redirects aren't available in a static export.`:void 0,c=[{key:`react-hooks-js/set-state-in-render`,source:`react-compiler`,severity:`error`},{key:`react-hooks-js/immutability`,source:`react-compiler`,severity:`error`},{key:`react-hooks-js/refs`,source:`react-compiler`,severity:`error`},{key:`react-hooks-js/purity`,source:`react-compiler`,severity:`error`},{key:`react-hooks-js/hooks`,source:`react-compiler`,severity:`error`},{key:`react-hooks-js/set-state-in-effect`,source:`react-compiler`,severity:`warn`},{key:`react-hooks-js/globals`,source:`react-compiler`,severity:`error`},{key:`react-hooks-js/error-boundaries`,source:`react-compiler`,severity:`error`},{key:`react-hooks-js/preserve-manual-memoization`,source:`react-compiler`,severity:`error`},{key:`react-hooks-js/unsupported-syntax`,source:`react-compiler`,severity:`error`},{key:`react-hooks-js/component-hook-factories`,source:`react-compiler`,severity:`error`},{key:`react-hooks-js/static-components`,source:`react-compiler`,severity:`error`},{key:`react-hooks-js/use-memo`,source:`react-compiler`,severity:`error`},{key:`react-hooks-js/void-use-memo`,source:`react-compiler`,severity:`error`},{key:`react-hooks-js/incompatible-library`,source:`react-compiler`,severity:`error`},{key:`react-hooks-js/todo`,source:`react-compiler`,severity:`error`}],l=Object.fromEntries(c.map(e=>[e.key,e.severity])),u=new Set(`width.height.min-width.max-width.min-height.max-height.top.right.bottom.left.padding.padding-top.padding-right.padding-bottom.padding-left.margin.margin-top.margin-right.margin-bottom.margin-left.border-width.border-top-width.border-right-width.border-bottom-width.border-left-width.line-height.column-width`.split(`.`)),d=new Set([`width`,`height`,`top`,`left`,`right`,`bottom`,`padding`,`paddingTop`,`paddingRight`,`paddingBottom`,`paddingLeft`,`margin`,`marginTop`,`marginRight`,`marginBottom`,`marginLeft`,`borderWidth`,`fontSize`,`lineHeight`,`gap`]),f=new Set([`animate`,`initial`,`exit`,`whileHover`,`whileTap`,`whileFocus`,`whileDrag`,`whileInView`]),p=/blur\((\d+(?:\.\d+)?)px\)/,m=new Set([`requestAnimationFrame`,`setInterval`]),h=new Set([`framer-motion`,`motion`]),ee=new Set([`bounce`,`elastic`,`wobble`,`jiggle`,`spring`]),te={base:`3.0.0`,textLayoutGuard:`3.0.1`,aria:`6.2.0`,cursor:`6.7.0`,concurrent:`6.7.0`,renderToString:`6.8.0`,modernHooks:`7.0.0`,suspendTerminal:`7.1.0`},g=[`ink-ctrl-c-handler-requires-exit-option`,`ink-newline-inside-text`,`ink-no-bare-process-exit`,`ink-no-direct-raw-mode`,`ink-no-dom-host-elements`,`ink-no-dom-router`,`ink-no-focus-in-render`,`ink-no-layout-inside-text`,`ink-no-live-hooks-in-render-to-string`,`ink-no-measure-element-in-render`,`ink-no-multiple-static`,`ink-no-raw-text`,`ink-no-repeated-render`,`ink-prefer-use-animation`,`ink-prefer-use-paste`,`ink-static-is-append-only`,`ink-static-requires-key`,`ink-suspense-requires-concurrent`,`ink-use-reactive-window-size`,`ink-use-string-width-for-cursor`,`ink-use-suspend-terminal`,`ink-valid-aria-semantics`],ne=[`@react-router/dev`,`react-router-dom`,`react-router`],re=`react-router-csp-nonce-consistency.react-router-descendant-routes-require-splat.react-router-guard-aborted-handle-error.react-router-internal-route-anchor.react-router-loader-fetch-forwards-signal.react-router-loader-parallel-fetch.react-router-nested-route-requires-outlet.react-router-no-catch-middleware-next.react-router-no-client-module-in-server-render.react-router-no-duplicate-route-id.react-router-no-empty-leaf-route.react-router-no-invalid-absolute-child-path.react-router-no-invalid-lazy-route-properties.react-router-no-invalid-splat-path.react-router-no-loader-request-body.react-router-no-middleware-response-body-consumption.react-router-no-multiple-blockers.react-router-no-multiple-middleware-next.react-router-no-multiple-set-search-params-in-tick.react-router-no-navigate-in-render.react-router-no-nested-router.react-router-no-redirect-in-try-catch.react-router-no-route-module-environment-suffix.react-router-no-router-in-render.react-router-no-session-mutation-in-loader.react-router-no-static-cookie-expires.react-router-no-unsynchronized-search-params-mutation.react-router-no-use-loader-data-in-error-ui.react-router-prefer-route-lazy.react-router-require-root-error-boundary.react-router-resource-link-requires-reload.react-router-return-navigation-promise-in-transition.react-router-server-middleware-return-response.react-router-session-mutation-requires-commit.react-router-v8-no-meta-data-field.react-router-v8-no-react-router-dom-import.react-router-v8-no-removed-future-flags.react-router-valid-route-object`.split(`.`),ie=new Set([`@react-router/cloudflare`,`@react-router/node`,`react-router/dom`,`react-router-dom`,`react-router`]),ae=new Set([`flash`,`set`,`unset`]),oe=new Set([`createCookieSessionStorage`,`createFileSessionStorage`,`createMemorySessionStorage`,`createSessionStorage`,`createWorkersKVSessionStorage`]),se=new Set([`createBrowserRouter`,`createHashRouter`,`createMemoryRouter`]),ce=new Set([`append`,`delete`,`set`,`sort`]),le=new Set([`caseSensitive`,`children`,`id`,`index`,`lazy`,`path`]),ue=new Set([`arrayBuffer`,`blob`,`bytes`,`formData`,`json`,`text`]),de=new Set([`unstable_previewServerPrerendering`,`v8_middleware`,`v8_passThroughRequests`,`v8_splitRouteModules`,`v8_trailingSlashAwareDataRequests`,`v8_viteEnvironmentApi`]),fe=new Set([`BrowserRouter`,`HashRouter`,`MemoryRouter`,`Router`,`RouterProvider`]),pe=new Set([...g,`client-passive-event-listeners`,`exhaustive-deps`,`no-barrel-import`,`nextjs-async-dynamic-api-not-awaited`,`nextjs-missing-metadata`,`nextjs-no-img-element`,`nextjs-no-use-search-params-without-suspense`,`no-dynamic-import-path`,`no-full-lodash-import`,`no-hydration-branch-on-browser-global`,`no-indeterminate-attribute`,`no-loading-flag-reset-outside-finally`,`no-locale-format-in-render`,`no-match-media-in-state-initializer`,`no-create-ref-in-function-component`,`no-adjust-state-on-prop-change`,`no-derived-state`,`no-derived-state-effect`,`no-event-handler`,`no-effect-with-fresh-deps`,`no-initialize-state`,`no-mutating-reducer-state`,`only-export-components`,`no-unguarded-browser-global-at-module-scope`,`no-unguarded-browser-global-in-render-or-hook-init`,`window-open-without-noopener`,`prefer-dynamic-import`,`rendering-hydration-mismatch-time`,`remotion-calculate-metadata-fetch-signal`,`remotion-deterministic-randomness`,`remotion-no-css-animation`,`remotion-no-css-transition`,`remotion-no-css-url-assets`,`remotion-no-native-media-elements`,`remotion-no-next-image`,`rerender-memo-with-default-value`,`rn-no-legacy-shadow-styles`,`rn-no-raw-text`,`rn-prefer-expo-image`,`rn-style-prefer-boxshadow`,...re]),me=new Set([`implements`,`returnType`,`superTypeArguments`,`superTypeParameters`,`typeAnnotation`,`typeArguments`,`typeParameters`]),_=e=>typeof e==`object`&&!!e&&typeof e.type==`string`,v=e=>e!=null&&(e.type===`ArrowFunctionExpression`||e.type===`FunctionExpression`||e.type===`FunctionDeclaration`),y=(e,t)=>typeof e==`object`&&!!e&&e.type===t,he={...t,...n,ArrayPattern:[`decorators`,...n.ArrayPattern],AssignmentPattern:[`decorators`,...n.AssignmentPattern],ClassDeclaration:[`decorators`,...n.ClassDeclaration],ClassExpression:[`decorators`,...n.ClassExpression],Identifier:[`decorators`,...n.Identifier],MethodDefinition:[`decorators`,...n.MethodDefinition],ObjectPattern:[`decorators`,...n.ObjectPattern],PropertyDefinition:[`decorators`,...n.PropertyDefinition],RestElement:[`decorators`,...n.RestElement]},ge=e=>e===`var`||e===`function`,_e=e=>{let t=e;for(;t;){if(t.kind===`module`||t.kind===`function`||t.kind===`arrow-function`||t.kind===`method`)return t;t=t.parent}return e},ve=(e,t,n,r)=>{let i={id:r.nextScopeId++,kind:e,node:t,parent:n,children:[],symbols:[],references:[],symbolsByName:new Map};return n&&n.children.push(i),i},b=(e,t,n)=>{let r=ve(e,t,n.currentScope,n);return n.scopeStack.push(r),n.currentScope=r,n.ownScopeForNode.set(t,r),r},x=e=>{e.scopeStack.pop();let t=e.scopeStack[e.scopeStack.length-1];if(!t)throw Error(`scope stack underflow`);e.currentScope=t},S=(e,t,n)=>{let r={id:t.nextSymbolId++,name:n.name,kind:n.kind,bindingIdentifier:n.bindingIdentifier,declarationNode:n.declarationNode,scope:e,initializer:n.initializer,references:[]};return e.symbols.push(r),e.symbolsByName.set(n.name,r),t.symbolByBindingIdentifier.set(n.bindingIdentifier,r),r},ye=e=>{let t=[],n=e=>{if(y(e,`Identifier`)){t.push(e);return}if(y(e,`ObjectPattern`)){for(let t of e.properties)if(y(t,`Property`)){let e=t.value;n(e)}else y(t,`RestElement`)&&n(t.argument);return}if(y(e,`ArrayPattern`)){for(let t of e.elements)t&&n(t);return}if(y(e,`RestElement`)){n(e.argument);return}y(e,`AssignmentPattern`)&&n(e.left)};return n(e),t},C=(e,t,n,r,i,a)=>{if(y(e,`Identifier`)){S(n,r,{name:e.name,kind:i,bindingIdentifier:e,declarationNode:a,initializer:t});return}if(y(e,`ObjectPattern`)){for(let o of e.properties)if(y(o,`Property`)){let e=o.value;C(e,y(e,`AssignmentPattern`)?e.right:t,n,r,i,a)}else y(o,`RestElement`)&&C(o.argument,t,n,r,i,a);return}if(y(e,`ArrayPattern`)){for(let o of e.elements)o&&C(o,y(o,`AssignmentPattern`)?o.right??null:t,n,r,i,a);return}if(y(e,`AssignmentPattern`)){C(e.left,e.right??null,n,r,i,a);return}y(e,`RestElement`)&&C(e.argument,null,n,r,i,a)},w=(e,t)=>{be.add(t)},be=new WeakSet,xe=(e,t,n)=>{let r={id:e.nextReferenceId++,identifier:t,resolvedSymbol:null,flag:n,scope:e.currentScope};e.currentScope.references.push(r),e.referenceByIdentifier.set(t,r)},Se=e=>e.parent?v(e.parent):!1,Ce=e=>e.parent!==null&&e.parent!==void 0&&e.parent.type===`CatchClause`,we=(e,t)=>{if(!y(e,`VariableDeclaration`))return;let n=e.kind===`var`?`var`:e.kind===`let`?`let`:e.kind===`const`?`const`:`using`,r=ge(n)?_e(t.currentScope):t.currentScope;for(let i of e.declarations){let e=i,a=i.init??null;C(i.id,a,r,t,n,e);for(let e of ye(i.id))w(t,e)}},Te=(e,t)=>{y(e,`FunctionDeclaration`)&&e.id&&(S(_e(t.currentScope),t,{name:e.id.name,kind:`function`,bindingIdentifier:e.id,declarationNode:e,initializer:e}),w(t,e.id))},Ee=(e,t)=>{y(e,`ClassDeclaration`)&&e.id&&(S(t.currentScope,t,{name:e.id.name,kind:`class`,bindingIdentifier:e.id,declarationNode:e,initializer:e}),w(t,e.id))},De=(e,t)=>{if(!y(e,`ImportDeclaration`))return;let n=_e(t.currentScope);for(let r of e.specifiers){let e=r.local;y(e,`Identifier`)&&(S(n,t,{name:e.name,kind:`import`,bindingIdentifier:e,declarationNode:r,initializer:r}),w(t,e))}},Oe=(e,t)=>{if(e.type!==`TSImportEqualsDeclaration`&&e.type!==`TSEnumDeclaration`&&e.type!==`TSTypeAliasDeclaration`&&e.type!==`TSInterfaceDeclaration`&&e.type!==`TSModuleDeclaration`)return;let n=e.id;if(!n||!y(n,`Identifier`))return;let r=e.type===`TSImportEqualsDeclaration`?`ts-import-equals`:e.type===`TSEnumDeclaration`?`ts-enum`:e.type===`TSTypeAliasDeclaration`?`ts-type-alias`:e.type===`TSInterfaceDeclaration`?`ts-interface`:`ts-module`;S(_e(t.currentScope),t,{name:n.name,kind:r,bindingIdentifier:n,declarationNode:e,initializer:null}),w(t,n)},ke=(e,t,n)=>{for(let r of e){C(r,null,t,n,`parameter`,r);for(let e of ye(r))w(n,e)}},Ae=e=>!(!y(e,`BlockStatement`)||Se(e)||Ce(e)||e.parent&&e.parent.type===`TSModuleDeclaration`),je=e=>{let t=e.parent;if(!t)return!1;if(t.type===`JSXMemberExpression`)return t.object===e;if(t.type===`JSXNamespacedName`)return!1;let n=e.name.charCodeAt(0);return!(n>=97&&n<=122)},Me=e=>{let t=e.parent;if(!t)return!1;switch(t.type){case`MemberExpression`:return t.property===e&&!t.computed;case`Property`:return t.key===e&&!t.computed&&!t.shorthand;case`MethodDefinition`:case`PropertyDefinition`:return t.key===e&&!t.computed;case`JSXAttribute`:return t.name===e;case`ImportSpecifier`:return t.imported===e;case`ExportSpecifier`:return t.exported===e&&t.local!==t.exported;case`LabeledStatement`:case`BreakStatement`:case`ContinueStatement`:return t.label===e;default:return!1}},Ne=e=>{let t=e.parent;if(!t)return`read`;switch(t.type){case`AssignmentExpression`:return t.left===e?t.operator===`=`?`write`:`read-write`:`read`;case`UpdateExpression`:return`read-write`;case`ForInStatement`:case`ForOfStatement`:return t.left===e?`write`:`read`;default:return`read`}},T=(e,t)=>{t.nodeScope.set(e,t.currentScope)},Pe=(e,t)=>{if(e.type===`AssignmentPattern`){Pe(e.left,t);let n=e.right??null;n&&E(n,t);return}if(e.type===`ObjectPattern`){for(let n of e.properties){let e=n;if(e.type===`RestElement`){Pe(e.argument,t);continue}if(e.type!==`Property`)continue;let r=e;r.computed&&E(r.key,t),Pe(r.value,t)}return}if(e.type===`ArrayPattern`){for(let n of e.elements)n&&Pe(n,t);return}e.type===`RestElement`&&Pe(e.argument,t)},E=(e,t)=>{if(e.type===`ArrowFunctionExpression`||e.type===`FunctionExpression`||e.type===`FunctionDeclaration`){e.type===`FunctionDeclaration`&&e.id&&Te(e,t);let n=e.params??[];for(let e of n)if(!(!(`decorators`in e)||!Array.isArray(e.decorators)))for(let n of e.decorators)_(n)&&E(n,t);T(e,t);let r=b(e.type===`ArrowFunctionExpression`?`arrow-function`:`function`,e,t);(e.type===`FunctionExpression`||e.type===`FunctionDeclaration`)&&e.id&&(S(r,t,{name:e.id.name,kind:`function`,bindingIdentifier:e.id,declarationNode:e,initializer:e}),w(t,e.id)),ke(n,r,t);for(let e of n)Pe(e,t);let i=e.body;i&&E(i,t),x(t);return}if(e.type===`ClassDeclaration`||e.type===`ClassExpression`){if(e.type===`ClassDeclaration`&&e.id&&Ee(e,t),Array.isArray(e.decorators))for(let n of e.decorators)_(n)&&E(n,t);let n=b(`class`,e,t);T(e,t),e.type===`ClassExpression`&&e.id&&(S(n,t,{name:e.id.name,kind:`class`,bindingIdentifier:e.id,declarationNode:e,initializer:e}),w(t,e.id)),e.superClass&&E(e.superClass,t),e.body&&E(e.body,t),x(t);return}if(e.type===`CatchClause`){let n=b(`catch`,e,t);if(T(e,t),e.param){C(e.param,null,n,t,`catch-clause-parameter`,e);for(let n of ye(e.param))w(t,n)}e.body&&E(e.body,t),x(t);return}if(e.type===`ForStatement`||e.type===`ForInStatement`||e.type===`ForOfStatement`){b(`for`,e,t),T(e,t);let n=e,r=he[e.type]??Object.keys(n);for(let e of r){if(e===`parent`||me.has(e))continue;let r=n[e];if(Array.isArray(r))for(let e of r)_(e)&&E(e,t);else _(r)&&E(r,t)}x(t);return}if(e.type===`SwitchStatement`){b(`switch`,e,t),T(e,t),e.discriminant&&E(e.discriminant,t);for(let n of e.cases)E(n,t);x(t);return}if(e.type===`TSModuleDeclaration`){let n=b(`ts-module`,e,t);if(T(e,t),e.id&&y(e.id,`Identifier`)){let r=e.id;S(_e(n.parent??t.currentScope),t,{name:r.name,kind:`ts-module`,bindingIdentifier:r,declarationNode:e,initializer:null}),w(t,r)}e.body&&E(e.body,t),x(t);return}if(e.type===`TSEnumDeclaration`){Oe(e,t),b(`ts-enum`,e,t),T(e,t);let n=e.members??[];for(let e of n)E(e,t);x(t);return}if(e.type===`BlockStatement`&&Ae(e)){b(`block`,e,t),T(e,t);for(let n of e.body)E(n,t);x(t);return}switch(T(e,t),e.type){case`VariableDeclaration`:we(e,t);break;case`ImportDeclaration`:De(e,t);break;case`TSImportEqualsDeclaration`:case`TSTypeAliasDeclaration`:case`TSInterfaceDeclaration`:Oe(e,t);break}(e.type===`Identifier`||e.type===`JSXIdentifier`)&&!be.has(e)&&!Me(e)&&(e.type===`JSXIdentifier`?je(e)&&xe(t,e,Ne(e)):xe(t,e,Ne(e)));let n=e,r=he[e.type]??Object.keys(n);for(let e of r){if(e===`parent`||me.has(e))continue;let r=n[e];if(Array.isArray(r))for(let e of r)_(e)&&E(e,t);else _(r)&&E(r,t)}},Fe=e=>{let t=e=>{for(let t of e.references){let n=t.identifier.name;if(typeof n!=`string`)continue;let r=e;for(;r;){let e=r.symbolsByName.get(n);if(e){t.resolvedSymbol=e,e.references.push(t);break}r=r.parent}}for(let n of e.children)t(n)};t(e)},Ie=e=>{let t={id:0,kind:`module`,node:e,parent:null,children:[],symbols:[],references:[],symbolsByName:new Map},n={nextScopeId:1,nextSymbolId:0,nextReferenceId:0,currentScope:t,scopeStack:[t],rootScope:t,nodeScope:new WeakMap,ownScopeForNode:new WeakMap,symbolByBindingIdentifier:new WeakMap,referenceByIdentifier:new WeakMap};if(n.nodeScope.set(e,t),n.ownScopeForNode.set(e,t),e.type===`Program`)for(let t of e.body)E(t,n);else E(e,n);return Fe(t),{rootScope:t,scopeFor:e=>{let r=e;for(;r;){let e=n.nodeScope.get(r);if(e)return e;r=r.parent??null}return t},ownScopeFor:e=>n.ownScopeForNode.get(e)??null,symbolFor:e=>{let t=n.referenceByIdentifier.get(e);return t?t.resolvedSymbol:n.symbolByBindingIdentifier.get(e)||null},referenceFor:e=>n.referenceByIdentifier.get(e)??null,isGlobalReference:e=>{let t=n.referenceByIdentifier.get(e);return t?t.resolvedSymbol===null:!1}}},Le=(e,t)=>{let n=e;for(;n;){if(n===t)return!0;n=n.parent}return!1},Re=`(?:tsx?|jsx?|mts|mjs)`,ze=RegExp(`/page\\.${Re}$`),Be=RegExp(`/(page|layout)\\.${Re}$`),Ve=[`layout.tsx`,`layout.jsx`,`layout.ts`,`layout.js`,`layout.mts`,`layout.mjs`],He=[`metadata`,`generateMetadata`],Ue=/\/(?:(?:\((?:dashboard|admin|settings|account|internal|manage|console|portal|auth|onboarding|app|ee|protected)\))|(?:dashboard|admin|settings|account|internal|manage|console|portal))\//i,We=new Set([`redirect`,`permanentRedirect`,`notFound`,`forbidden`,`unauthorized`]),Ge=new Set([`revalidateTag`,`revalidatePath`,`expireTag`,`expirePath`,`unstable_expireTag`,`unstable_expirePath`]),Ke=/fonts\.googleapis\.com/,qe=/polyfill\.io|polyfill\.min\.js|cdn\.polyfill/,Je=RegExp(`/route\\.${Re}$`),Ye=/\/(?:cron|jobs\/cron)(?:\/|$)/i,Xe=new Set([`logout`,`log-out`,`signout`,`sign-out`,`unsubscribe`,`delete`,`remove`,`revoke`,`cancel`,`deactivate`]),Ze=RegExp(`/(error|global-error)\\.${Re}$`),Qe=RegExp(`/global-error\\.${Re}$`),$e=new Set([`GET`,`POST`,`PUT`,`PATCH`,`DELETE`,`OPTIONS`,`HEAD`]),et=/google-analytics\.com|googletagmanager\.com\/gtag/,tt=RegExp(`/(opengraph-image|twitter-image)\\d*\\.${Re}$`),nt=1024,rt=1e3,it=1e3,at=new Set([`expo`,`expo-router`,`@expo/cli`,`@expo/metro-config`,`@expo/metro-runtime`]),ot=new Set([`react-native`,`react-native-tvos`,...at,`react-native-windows`,`react-native-macos`]),st=[`@react-native/`,`@react-native-`],ct=e=>at.has(e),lt=e=>{if(ot.has(e))return!0;for(let t of st)if(e.startsWith(t))return!0;return!1};let ut=null;const dt=e=>{ut?.existencePaths.add(e)},D=e=>{ut?.contentPaths.add(e)},ft=()=>ut!==null,pt=e=>{let t=ut,n={existencePaths:new Set,contentPaths:new Set};ut=n;try{return{value:e(),trace:n}}finally{if(ut=t,t!==null){for(let e of n.existencePaths)t.existencePaths.add(e);for(let e of n.contentPaths)t.contentPaths.add(e)}}},mt=e=>pt(e).trace,ht=new Map,gt=new Map,_t=()=>{ht.clear(),gt.clear()},vt=e=>{if(!e)return null;let t=ht.get(e);if(t!==void 0){if(ft()){let n=i.dirname(e);for(;dt(i.join(n,`package.json`)),n!==t;){let e=i.dirname(n);if(e===n)break;n=e}}return t}let n=i.dirname(e);for(;;){let t=i.join(n,`package.json`);dt(t);let a=!1;try{a=r.statSync(t).isFile()}catch{a=!1}if(a)return ht.set(e,n),n;let o=i.dirname(n);if(o===n)return ht.set(e,null),null;n=o}},yt=e=>{let t=vt(e);return t?bt(t):null},bt=e=>{let t=i.join(e,`package.json`);D(t);let n=gt.get(e);if(n!==void 0)return n;let a=null;try{let e=JSON.parse(r.readFileSync(t,`utf-8`));typeof e==`object`&&e&&(a=e)}catch{a=null}return gt.set(e,a),a},xt=new Set([`next`,`vite`,`react-scripts`,`gatsby`,`@remix-run/react`,`@remix-run/node`,`@docusaurus/core`,`@docusaurus/preset-classic`,`@storybook/react`,`@storybook/react-vite`,`@storybook/react-webpack5`,`@storybook/nextjs`,`@storybook/web-components`,`storybook`,`react-dom`,`@vitejs/plugin-react`,`@vitejs/plugin-react-swc`]),St=[`dependencies`,`devDependencies`,`peerDependencies`,`optionalDependencies`],Ct=function*(e){for(let t of St){let n=e[t];if(n)for(let e of Object.keys(n))yield e}},wt=e=>{if(typeof e[`react-native`]==`string`)return!0;for(let t of Ct(e))if(lt(t))return!0;return!1},Tt=e=>{for(let t of Ct(e))if(ct(t))return!0;return!1},Et=e=>{for(let t of Ct(e))if(xt.has(t))return!0;return!1},Dt=e=>St.some(t=>{let n=e[t];return typeof n==`object`&&!!n&&Object.keys(n).length>0}),Ot=(e,t)=>St.some(n=>{let r=e[n];return typeof r==`object`&&!!r&&Object.prototype.propertyIsEnumerable.call(r,t)}),kt=new WeakMap,At=e=>{let t=yt(e);if(!t)return`unknown`;let n=kt.get(t);if(n!==void 0)return n;let r;return r=Tt(t)?`expo`:wt(t)?`react-native`:Et(t)?`web`:Dt(t)?`neutral`:`unknown`,kt.set(t,r),r},jt=new Set([`ParenthesizedExpression`,`TSAsExpression`,`TSSatisfiesExpression`,`TSTypeAssertion`,`TSNonNullExpression`,`TSInstantiationExpression`,`ChainExpression`]),O=e=>{let t=e;for(;;)switch(t.type){case`ParenthesizedExpression`:case`TSAsExpression`:case`TSSatisfiesExpression`:case`TSTypeAssertion`:case`TSNonNullExpression`:case`TSInstantiationExpression`:case`ChainExpression`:if(!(`expression`in t)||!t.expression)return t;t=t.expression;break;default:return t}},Mt=(e,t)=>{if(!y(e,`Program`))return null;let n=new Map,r=new Map,i=null,a=null,o=e=>{for(let t of e.declarations??[])y(t,`VariableDeclarator`)&&(!y(t.id,`Identifier`)||!t.init||n.set(t.id.name,O(t.init)))};for(let t of e.body??[]){if(y(t,`VariableDeclaration`)){o(t);continue}if(y(t,`FunctionDeclaration`)&&t.id){n.set(t.id.name,t);continue}if(y(t,`ExportNamedDeclaration`)){if(t.exportKind===`type`)continue;let e=t.declaration;if(e&&y(e,`VariableDeclaration`)){o(e);for(let t of e.declarations??[])y(t,`VariableDeclarator`)&&y(t.id,`Identifier`)&&r.set(t.id.name,t.id.name)}else e&&y(e,`FunctionDeclaration`)&&e.id&&(n.set(e.id.name,e),r.set(e.id.name,e.id.name));if(t.source)continue;for(let e of t.specifiers??[]){if(!y(e,`ExportSpecifier`)||e.exportKind===`type`)continue;let t=y(e.local,`Identifier`)?e.local.name:null,n=null;y(e.exported,`Identifier`)?n=e.exported.name:y(e.exported,`Literal`)&&typeof e.exported.value==`string`&&(n=e.exported.value),t&&n&&r.set(n,t)}continue}if(!y(t,`ExportDefaultDeclaration`))continue;let e=t.declaration;e&&(y(e,`Identifier`)?a=e.name:((y(e,`FunctionDeclaration`)||y(e,`ClassDeclaration`))&&e.id&&n.set(e.id.name,e),i=O(e)))}if(t===`default`){if(i)return i;if(a){let e=n.get(a);if(e)return e}}let s=r.get(t);return s?n.get(s)??null:null},Nt=e=>{if(y(e,`ImportSpecifier`)){let t=e.imported;return y(t,`Identifier`)?t.name:y(t,`Literal`)&&typeof t.value==`string`?t.value:null}return y(e,`ImportDefaultSpecifier`)?`default`:null},Pt=(e,t)=>{if(!y(e,`Program`))return[];let n=[];for(let r of e.body??[]){if(y(r,`ExportNamedDeclaration`)&&r.source){if(r.exportKind===`type`)continue;let e=r.source.value;if(typeof e!=`string`)continue;for(let n of r.specifiers??[]){if(!y(n,`ExportSpecifier`)||n.exportKind===`type`)continue;let r=n.exported;if((y(r,`Identifier`)?r.name:y(r,`Literal`)&&typeof r.value==`string`?r.value:null)!==t)continue;let i=n.local,a=y(i,`Identifier`)?i.name:y(i,`Literal`)&&typeof i.value==`string`?i.value:null;if(a)return[{importedName:a,source:e}]}}if(y(r,`ExportAllDeclaration`)&&r.source){if(r.exportKind===`type`||r.exported)continue;let e=r.source.value;typeof e==`string`&&n.push({importedName:t,source:e})}}return n},Ft=e=>{let t=(e,n)=>{let r=e;r.parent=n,r.range==null&&typeof r.start==`number`&&typeof r.end==`number`&&(r.range=[r.start,r.end]);let i=e;for(let n of Object.keys(i)){if(n===`parent`)continue;let r=i[n];if(Array.isArray(r))for(let n of r)_(n)&&t(n,e);else _(r)&&t(r,e)}};t(e,null)},It={".ts":`ts`,".tsx":`tsx`,".js":`js`,".jsx":`jsx`,".mjs":`js`,".cjs":`js`,".mts":`ts`,".cts":`ts`},Lt=e=>It[i.extname(e).toLowerCase()]??`tsx`,Rt=({filename:t,sourceText:n,shouldAttachParentReferences:r=!0})=>{try{let i=e(t,n,{astType:`ts`,lang:Lt(t)});if(i.errors.some(e=>e.severity===`Error`))return null;let a=i.program;return r&&Ft(a),a}catch{return null}},zt=new Map,Bt=e=>{e.endsWith(`.d.ts`)||e.endsWith(`.d.mts`)||e.endsWith(`.d.cts`)||D(e);let t;try{t=r.statSync(e)}catch{return null}if(!t.isFile()||t.size>2e6)return null;let n=zt.get(e);if(n&&n.mtimeMs===t.mtimeMs&&n.size===t.size)return n.program;if(e.endsWith(`.d.ts`)||e.endsWith(`.d.mts`)||e.endsWith(`.d.cts`))return zt.set(e,{mtimeMs:t.mtimeMs,size:t.size,program:null}),null;let i;try{i=r.readFileSync(e,`utf8`)}catch{return zt.set(e,{mtimeMs:t.mtimeMs,size:t.size,program:null}),null}let a=Rt({filename:e,sourceText:i});return zt.set(e,{mtimeMs:t.mtimeMs,size:t.size,program:a}),a},Vt=[`.ts`,`.tsx`,`.js`,`.jsx`,`.mjs`,`.cjs`,`.mts`,`.cts`],Ht=[`import`,`default`,`module`,`browser`,`require`],Ut=[`module`,`main`,`browser`],Wt=e=>{dt(e);try{return r.statSync(e).isFile()?e:null}catch{return null}},Gt=e=>{dt(e);try{return r.statSync(e).isDirectory()?e:null}catch{return null}},Kt=e=>{let t=i.extname(e);if(!t)return Vt.map(t=>`${e}${t}`);let n=e.slice(0,-t.length);return t===`.js`?[e,`${n}.ts`,`${n}.tsx`,`${n}.jsx`]:t===`.jsx`?[e,`${n}.tsx`]:t===`.mjs`?[e,`${n}.mts`]:t===`.cjs`?[e,`${n}.cts`]:[e]},qt=e=>typeof e==`object`&&!!e,Jt=e=>{if(typeof e==`string`)return e;if(Array.isArray(e)){for(let t of e){let e=Jt(t);if(e)return e}return null}if(!qt(e))return null;for(let t of Ht){let n=Jt(e[t]);if(n)return n}return null},Yt=e=>{let t=e.exports;return t?Jt(t)||(qt(t)?Jt(t[`.`]):null):null},Xt=e=>Qt(e)||Qt(i.join(e,`index`)),Zt=e=>{let t=Gt(e);if(!t)return null;let n=i.join(t,`package.json`);D(n);try{let e=JSON.parse(r.readFileSync(n,`utf8`)),a=Yt(e)??Ut.map(t=>e[t]).find(e=>typeof e==`string`);return a?Xt(i.resolve(t,a)):null}catch{return null}},Qt=e=>{let t=Wt(e);if(t)return t;for(let t of Kt(e)){let e=Wt(t);if(e)return e}return null},$t=e=>Qt(e)||Zt(e)||Qt(i.join(e,`index`)),en=(e,t)=>$t(i.resolve(i.dirname(e),t)),tn=[`tsconfig.json`,`jsconfig.json`],nn=e=>typeof e==`object`&&!!e,rn=e=>{let t=``,n=!1,r=!1,i=!1;for(let a=0;a<e.length;a++){let o=e[a],s=e[a+1];if(r){o===`
|
|
2
|
-
`&&(r=!1,t+=o);continue}if(i){o===`*`&&s===`/`&&(i=!1,a++);continue}if(n){t+=o,o===`\\`?(t+=s??``,a++):o===`"`&&(n=!1);continue}if(o===`"`){n=!0,t+=o;continue}if(o===`/`&&s===`/`){r=!0,a++;continue}if(o===`/`&&s===`*`){i=!0,a++;continue}t+=o}return t.replace(/,(\s*[}\]])/g,`$1`)},an=(e,t)=>{D(e),t.push(e);let n;try{n=r.readFileSync(e,`utf8`)}catch{return null}try{let e=JSON.parse(rn(n));return nn(e)?e:null}catch{return null}},on=(e,t)=>{let n=e.endsWith(`.json`)?e:`${e}.json`;return e.startsWith(`./`)||e.startsWith(`../`)?i.resolve(t,n):i.join(t,`node_modules`,n)},sn=e=>{let t=new Map;if(!nn(e))return t;for(let[n,r]of Object.entries(e)){if(!Array.isArray(r))continue;let e=r.filter(e=>typeof e==`string`);e.length>0&&t.set(n,e)}return t},cn=(e,t,n)=>{let r=an(e,n);if(!r)return null;let a=i.dirname(e),o=nn(r.compilerOptions)?r.compilerOptions:{},s=typeof o.baseUrl==`string`?o.baseUrl:null,c=s!==null,l=s===null?a:i.resolve(a,s);if(nn(o.paths))return{baseAbsolutePath:l,hasExplicitBaseUrl:c,paths:sn(o.paths)};if(typeof r.extends==`string`&&t<8){let e=on(r.extends,a),i=e?cn(e,t+1,n):null;if(i)return i}return c?{baseAbsolutePath:l,hasExplicitBaseUrl:c,paths:new Map}:null},ln=new Map,un=new Map,dn=e=>{D(e);let t;try{t=r.statSync(e)}catch{return{config:null,probedContentPaths:new Set([e])}}let n=ln.get(e);if(n&&n.mtimeMs===t.mtimeMs){for(let e of n.probedChainPaths)D(e);return{config:n.config,probedContentPaths:new Set(n.probedChainPaths)}}let i=[],a=cn(e,0,i);return ln.set(e,{mtimeMs:t.mtimeMs,config:a,probedChainPaths:i}),{config:a,probedContentPaths:new Set(i)}},fn=e=>{let t=ft(),n=t?un.get(e):void 0;if(n!==void 0){for(let e of n.probedContentPaths)D(e);return n.config}let r=new Set,a=e;for(let n=0;n<30;n++){for(let n of tn){let o=dn(i.join(a,n));for(let e of o.probedContentPaths)r.add(e);if(o.config)return t&&un.set(e,{config:o.config,probedContentPaths:r}),o.config}let n=i.dirname(a);if(n===a)break;a=n}return t&&un.set(e,{config:null,probedContentPaths:r}),null},pn=(e,t)=>{let n=t.indexOf(`*`);if(n===-1)return e===t?``:null;let r=t.slice(0,n),i=t.slice(n+1);return e.length>=r.length+i.length&&e.startsWith(r)&&e.endsWith(i)?e.slice(r.length,e.length-i.length):null},mn=(e,t)=>{let n=fn(i.dirname(e));if(!n)return null;let r=null,a=``,o=-1;for(let e of n.paths.keys()){let n=pn(t,e);if(n===null)continue;let i=e.indexOf(`*`),s=i===-1?e.length:i;s>o&&(r=e,a=n,o=s)}if(r)for(let e of n.paths.get(r)??[]){let t=e.replaceAll(`*`,a),r=$t(i.resolve(n.baseAbsolutePath,t));if(r)return r}return n.hasExplicitBaseUrl?$t(i.resolve(n.baseAbsolutePath,t)):null},hn=()=>{ln.clear(),un.clear()},gn=(e,t)=>i.isAbsolute(t)?null:t.startsWith(`.`)?en(e,t):mn(e,t),_n=new Map,vn=()=>{_n.clear()},yn=(e,t,n)=>{if(n.size>=4||n.has(e))return null;n.add(e);let r=Bt(e);if(!r)return null;let i=Mt(r,t);if(i)return{filePath:e,exportedNode:i,programNode:r};let a=new Map;for(let i of Pt(r,t)){let t=gn(e,i.source);if(!t)continue;let r=yn(t,i.importedName,new Set(n));r&&a.set(r.exportedNode,r)}return a.size===1?a.values().next().value??null:null},bn=(e,t,n)=>xn(e,t,n)?.functionNode??null,xn=(e,t,n)=>{let r=k(e,t,n);return!r||!v(r.exportedNode)?null:{filePath:r.filePath,functionNode:r.exportedNode,programNode:r.programNode}},k=(e,t,n)=>{if(!ft()){let r=gn(e,t);return r?yn(r,n,new Set):null}let r=`${e}\0${t}\0${n}`,i=_n.get(r);if(i!==void 0){for(let e of i.trace.contentPaths)D(e);for(let e of i.trace.existencePaths)dt(e);return i.result}let a=pt(()=>{let r=gn(e,t);return r?yn(r,n,new Set):null});return _n.set(r,{result:a.value,trace:a.trace}),a.value},Sn=(e,t)=>{let n=e,r=he[e.type];if(r!==void 0){for(let e=r.length-1;e>=0;--e){let i=n[r[e]];if(Array.isArray(i))for(let e=i.length-1;e>=0;--e){let n=i[e];_(n)&&t.push(n)}else _(i)&&t.push(i)}return}let i=Object.keys(n);for(let e=i.length-1;e>=0;--e){let r=i[e];if(r===`parent`)continue;let a=n[r];if(Array.isArray(a))for(let e=a.length-1;e>=0;--e){let n=a[e];_(n)&&t.push(n)}else _(a)&&t.push(a)}},Cn=(e,t)=>{let n=e,r=he[e.type];if(r!==void 0){for(let e=0;e<r.length;e+=1){let i=n[r[e]];if(Array.isArray(i))for(let e=0;e<i.length;e+=1){let n=i[e];_(n)&&t(n)}else _(i)&&t(i)}return}for(let e in n){if(e===`parent`||!Object.hasOwn(n,e))continue;let r=n[e];if(Array.isArray(r))for(let e=0;e<r.length;e+=1){let n=r[e];_(n)&&t(n)}else _(r)&&t(r)}},A=(e,t)=>{if(!e||typeof e!=`object`)return;let n=[e];for(;n.length>0;){let e=n.pop();e===void 0||t(e)===!1||Sn(e,n)}},wn=({absoluteFilePath:e,staticImports:t,program:n})=>{let r=new Set;if(A(n,e=>{if(e.type!==`JSXOpeningElement`)return;let t=e.name;if(t){if(t.type===`JSXIdentifier`){let e=t.name;typeof e==`string`&&r.add(e)}else if(t.type===`JSXMemberExpression`){let e=t.property;e?.type===`JSXIdentifier`&&typeof e.name==`string`&&r.add(e.name)}else if(t.type===`JSXNamespacedName`){let e=t.namespace;typeof e?.name==`string`&&r.add(e.name)}}}),r.size!==0)for(let n of t)for(let t of n.entries){let{importName:i}=t;if(i.kind===`NamespaceObject`||!r.has(t.localName.value))continue;let a=i.kind===`Default`?`default`:i.name;a&&bn(e,n.moduleRequest.value,a)}},Tn=e=>e.replace(/^type\s+/,``).trim(),En=(e,t)=>e.split(`,`).map(e=>e.trim()).filter(Boolean).map(e=>{let n=t||e.startsWith(`type `),[r,i]=e.split(/\s+as\s+/),a=Tn(r??``);return{localName:a,exportedName:Tn(i??a),isTypeOnly:n}}),Dn=/\/\*[\s\S]*?\*\//g,On=/^\s*\/\/.*$/gm,kn=e=>e.replace(Dn,``).replace(On,``),An=/^\s*export\s+default\b/m,jn=/^\s*export\s+(?:declare\s+)?(?:(?:async\s+)?function|(?:abstract\s+)?class|const|let|var|enum|interface|type)\s+([\w$]+)/gm,Mn=/^\s*export\s+(?:type\s+)?\{([\s\S]*?)\}(?:\s+from\s+["'][^"']+["'])?\s*;?\s*(?:(?:\/\/[^\n]*)?\s*)/gm,Nn=e=>{let t=kn(e),n=new Set;An.test(t)&&n.add(`default`);for(let e of t.matchAll(jn))e[1]&&n.add(e[1]);for(let e of t.matchAll(Mn)){let t=e[1]??``;for(let e of En(t,!1))n.add(e.exportedName)}return n},Pn=new Map,Fn=(e,t)=>{D(e);try{let n=r.statSync(e),i=Pn.get(e);if(i&&i.mtimeMs===n.mtimeMs&&i.size===n.size)return i.exportedNames.has(t);let a=Nn(r.readFileSync(e,`utf8`));return Pn.set(e,{mtimeMs:n.mtimeMs,size:n.size,exportedNames:a}),a.has(t)}catch{return!1}},In=(e,t)=>{let n=e.replaceAll(`\\`,`/`),r=i.dirname(n);for(let e=0;e<30;e++){for(let e of Ve){let a=i.join(r,e);if(a.replaceAll(`\\`,`/`)!==n&&t(a))return!0}let e=i.dirname(r);if(i.basename(r)===`app`&&i.basename(e)!==`app`||e===r)break;r=e}return!1},Ln=e=>In(e,e=>He.some(t=>Fn(e,t))),j=e=>{if(!y(e,`ImportSpecifier`))return;let t=e.imported;if(y(t,`Identifier`))return t.name;if(y(t,`Literal`)&&typeof t.value==`string`)return t.value},Rn=e=>y(e,`JSXIdentifier`)?e.name===`Suspense`:y(e,`JSXMemberExpression`)&&y(e.property,`JSXIdentifier`)&&e.property.name===`Suspense`,zn=e=>{let t=!1;return A(e,e=>{if(t)return!1;if(y(e,`JSXOpeningElement`)&&Rn(e.name)||y(e,`ImportDeclaration`)&&e.source?.value===`react`&&(e.specifiers??[]).some(e=>y(e,`ImportSpecifier`)&&j(e)===`Suspense`))return t=!0,!1}),t},Bn=e=>In(e,e=>{let t=Bt(e);return!!(t&&zn(t))}),Vn=/^index\.(?:[cm]?[jt]sx?|mjs)$/,Hn=/^\s*import\s+(type\s+)?(?!["'])([^;]*?)\s+from\s+["']([^"']+)["']\s*;?\s*(?:(?:\/\/[^\n]*)?\s*)/gm,Un=/^\s*export\s+(type\s+)?(?:\*(?:\s+as\s+([\w$]+))?|\{([\s\S]*?)\})\s+from\s+["']([^"']+)["']\s*;?\s*(?:(?:\/\/[^\n]*)?\s*)/gm,Wn=/^\s*export\s+(type\s+)?\{([\s\S]*?)\}\s*;?\s*(?:(?:\/\/[^\n]*)?\s*)/gm,Gn=new Map,Kn=e=>Vn.test(i.basename(e)),qn=()=>({isBarrel:!1,exportsByName:new Map,starExportSources:[]}),Jn=(e,t)=>{e.set(t.localName,{...t,didExport:!1})},Yn=(e,t,n,r)=>{for(let i of En(e,n))Jn(r,{localName:i.exportedName,importedName:i.localName,source:t,isTypeOnly:i.isTypeOnly})},Xn=(e,t,n,r)=>{let i=e.trim(),a=i.match(/(?:^|,\s*)\*\s+as\s+([\w$]+)/);a?.[1]&&Jn(r,{localName:a[1],importedName:`*`,source:t,isTypeOnly:n});let o=i.match(/\{([\s\S]*?)\}/);o?.[1]&&Yn(o[1],t,n,r);let s=i.split(`,`)[0]?.trim();s&&!s.startsWith(`{`)&&!s.startsWith(`*`)&&Jn(r,{localName:s,importedName:`default`,source:t,isTypeOnly:n})},Zn=(e,t,n,r)=>{let i=e.replace(Hn,(e,n,r,i)=>(Xn(r,i,!!n,t),``));return i=i.replace(Un,(e,t,i,a,o)=>{let s=!!t;if(i)return n.set(i,{exportedName:i,importedName:`*`,source:o,isTypeOnly:s}),``;if(a){for(let e of En(a,s))n.set(e.exportedName,{exportedName:e.exportedName,importedName:e.localName,source:o,isTypeOnly:e.isTypeOnly});return``}return r.push(o),``}),i=i.replace(Wn,(e,r,i)=>{for(let a of En(i,!!r)){let r=t.get(a.localName);if(!r)return e;r.didExport=!0,n.set(a.exportedName,{exportedName:a.exportedName,importedName:r.importedName,source:r.source,isTypeOnly:a.isTypeOnly||r.isTypeOnly})}return``}),i},Qn=e=>{for(let t of e.values())if(!t.isTypeOnly&&!t.didExport)return!0;return!1},$n=e=>{let t=kn(e).trim();if(!t)return qn();let n=new Map,r=new Map,i=[];return Zn(t,n,r,i).trim()||Qn(n)?qn():{isBarrel:r.size>0||i.length>0,exportsByName:r,starExportSources:i}},er=e=>{if(!Kn(e))return qn();D(e);let t;try{t=r.statSync(e)}catch{t=null}let n=Gn.get(e);if(n!==void 0&&t!==null&&n.mtimeMs===t.mtimeMs&&n.size===t.size)return n.moduleInfo;if(t===null)return qn();let i=qn();try{i=$n(r.readFileSync(e,`utf8`))}catch{i=qn()}return Gn.set(e,{mtimeMs:t.mtimeMs,size:t.size,moduleInfo:i}),i},tr=e=>er(e).isBarrel,nr=i.join(`android`,`gradle.properties`),rr=/^\s*newArchEnabled\s*=\s*false\s*$/m,ir=[`app.config.ts`,`app.config.js`,`app.config.cjs`,`app.config.mjs`],ar=[`app.config.json`,`app.json`],or=new WeakMap,sr=e=>{D(i.join(e,nr));for(let t of ir)dt(i.join(e,t));for(let t of ar)D(i.join(e,t))},cr=e=>{try{return r.readFileSync(e,`utf-8`)}catch{return null}},lr=e=>{let t=e.dependencies?.[`react-native`]??e.devDependencies?.[`react-native`];return typeof t==`string`?t:null},ur=e=>{let t=e.match(/(?:^|[^\d.])0\.(\d+)/);return t?Number.parseInt(t[1],10):null},dr=e=>{let t=cr(i.join(e,nr));return t!==null&&rr.test(t)},fr=e=>{for(let t of ir)if(r.existsSync(i.join(e,t)))return!1;for(let t of ar){let n=cr(i.join(e,t));if(n===null)continue;let r;try{r=JSON.parse(n)}catch{continue}if(typeof r!=`object`||!r)continue;let a=Object.getOwnPropertyDescriptor(r,`expo`)?.value;if(!(typeof a!=`object`||!a)&&Object.getOwnPropertyDescriptor(a,`newArchEnabled`)?.value===!1)return!0}return!1},pr=(e,t)=>{let n=lr(t);if(n!==null){let e=ur(n);if(e!==null&&e<76)return!0}return dr(e)||fr(e)},mr=e=>{let t=vt(e);if(!t)return!1;let n=yt(e);if(!n)return!1;sr(t);let r=or.get(n);if(r!==void 0)return r;let i=pr(t,n);return or.set(n,i),i},hr=e=>{let t=e.match(/^(\d+)(?:\.(\d+))?(?:\.(\d+))?(-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/);return t?{major:Number(t[1]),minor:Number(t[2]??0),patch:Number(t[3]??0),isPrerelease:!!t[4]}:null},gr=(e,t)=>e.major-t.major||e.minor-t.minor||e.patch-t.patch||Number(t.isPrerelease)-Number(e.isPrerelease),_r=e=>{if(typeof e!=`string`)return null;let t=e.trim();if(!t||/^(?:catalog|file|git|https?|link|npm|workspace):/.test(t)||/^(?:latest|next|\*)$/.test(t))return null;let n=[];for(let e of t.split(`||`)){let t=e.trim();if(/^<(?!=)/.test(t)||/^<=/.test(t))return null;let r=t.match(/\d+(?:\.\d+)?(?:\.\d+)?(?:-[0-9A-Za-z.-]+)?/)?.[0];if(!r)return null;let i=hr(r);if(!i)return null;n.push(i)}return n.reduce((e,t)=>gr(t,e)<0?t:e)},vr=e=>_r(e.dependencies?.ink??e.devDependencies?.ink??e.peerDependencies?.ink??e.optionalDependencies?.ink),yr=e=>{let t=e;for(;;){let e=bt(i.join(t,`node_modules`,`ink`));if(e)return{didFindPackage:!0,version:typeof e.version==`string`?hr(e.version):null};let n=i.dirname(t);if(n===t)return{didFindPackage:!1,version:null};t=n}},br=e=>{if(!e)return null;let t=vt(i.resolve(e));if(!t)return null;let n=yr(t);if(n.didFindPackage)return n.version;let r=bt(t);return r?vr(r):null},xr=(e,t)=>{let n=br(e),r=hr(t);return!!(n&&r&&gr(n,r)>=0)},Sr=new Set([`@monaco-editor/react`,`monaco-editor`,`recharts`,`@react-pdf/renderer`,`react-quill`,`@codemirror/view`,`@codemirror/state`,`chart.js`,`react-chartjs-2`,`@toast-ui/editor`,`draft-js`,`mermaid`]),Cr=new Set([`fetch`,`ky`,`got`,`wretch`,`ofetch`]),wr=new Set([`axios`,`ky`,`got`,`ofetch`,`wretch`,`request`]),Tr=new Set([`create`,`insert`,`insertInto`,`update`,`upsert`,`delete`,`remove`,`destroy`,`set`,`append`]),Er=new Set([`POST`,`PUT`,`DELETE`,`PATCH`]),Dr=new Set([`Map`,`Set`,`WeakMap`,`WeakSet`,`Headers`,`URLSearchParams`,`FormData`,`Response`,`NextResponse`]),Or=new Set([`Response`,`NextResponse`]),kr=new Set([`json`,`redirect`,`next`,`rewrite`,`error`]),Ar=new Set([`wheel`,`mousewheel`,`touchstart`,`touchmove`]),jr=new Set([`defer`,`async`]),Mr=new Set([`text/javascript`,`application/javascript`,`module`]),Nr=new Set([`setTimeout`,`setInterval`,`requestAnimationFrame`,`requestIdleCallback`,`queueMicrotask`]),Pr=new Set([`setInterval`,`setTimeout`]),Fr=new Set([`clearInterval`,`clearTimeout`]),Ir=new Set([`WebSocket`,`EventSource`,`BroadcastChannel`,`RTCPeerConnection`]),Lr=new Set([`location`,`window`,`document`,`navigator`,`history`,`screen`,`performance`]),Rr=new Set([`IntersectionObserver`,`MutationObserver`,`ResizeObserver`,`PerformanceObserver`]),zr=new Set([`blur`,`focus`,`getBoundingClientRect`,`getClientRects`,`measure`,`measureInWindow`,`measureLayout`,`scroll`,`scrollBy`,`scrollIntoView`,`scrollTo`,`select`,`setRangeText`,`setSelectionRange`]),Br=new Set([`localStorage`,`sessionStorage`]),Vr=new Set([`index`,`idx`,`i`]),Hr=new Set([`react`,`react-dom`,`preact/compat`,`preact/hooks`,`@wordpress/element`]),Ur=new Set([`next`,`next-themes`,`@remix-run/react`,`swr`,`zustand`,`jotai`,`recoil`,`wouter`,`framer-motion`,`@apollo/client`,`urql`,`usehooks-ts`]),Wr=/^(?:isLoading|isPending)$/,Gr=new Set([`useState`,`useMemo`,`useRef`]),Kr=new Set([`Click`,`Change`,`Input`,`Blur`,`Focus`]),qr=new Set([`Boolean`,`String`,`Number`,`Array`,`Object`,`parseInt`,`parseFloat`]),Jr=/^set[A-Z]/,Yr=/^render[A-Z]/,Xr=/^[A-Z]/,Zr=/^on[A-Z]/,Qr=/^use[A-Z]/,$r=/^(?:on|handle)[A-Z]/,ei=new Set([`useEffect`,`useLayoutEffect`]),ti=new Set([`useEffect`,`useLayoutEffect`,`useMemo`,`useCallback`]),ni=new Set([`use`,`useState`,`useRef`,`useMemo`,`useCallback`,`useReducer`,`useContext`,`useEffect`,`useLayoutEffect`,`useInsertionEffect`,`useImperativeHandle`,`useSyncExternalStore`,`useDeferredValue`,`useTransition`,`useId`,`useDebugValue`]),ri=new Set([`memo`,`forwardRef`,`React.memo`,`React.forwardRef`]),ii=new Set([`useMemo`,`useCallback`]),ai=new Set([`memo`,`forwardRef`,`observer`,`lazy`]),oi=new Set([`subscribe`,`addEventListener`,`addListener`,`on`,`watch`,`listen`,`sub`]),si=new Set([`subscribe`,`sub`,`listen`]),ci=new Set([`unsubscribe`,`removeEventListener`,`removeListener`,`off`,`unwatch`,`unlisten`,`unsub`,`abort`,`disconnect`,`unobserve`,`close`]),li=new Set([`remove`,`cleanup`,`dispose`,`destroy`,`stop`,`teardown`]),ui=new Set([...ci,`cleanup`,`dispose`,`destroy`,`teardown`]),di=new Set([...oi,`connect`,`disconnect`,`open`,`close`,`fetch`,`post`,`put`,`patch`]);new Set([...wr,`api`,`client`,`http`,`fetcher`]);const fi=new Set([`get`,`head`,`options`,`delete`]),pi=new Set([...Cr,...Nr]),mi=new Set([...Cr,`post`,`put`,`patch`,`navigate`,`navigateTo`,`showNotification`,`toast`,`alert`,`confirm`,`logVisit`,`captureEvent`]),hi=new Set([`post`,`put`,`patch`,`delete`,`navigate`,`capture`,`track`,`logEvent`]),gi=new Set([`push`,`replace`]),_i=new Set([`router`,`navigation`,`navigator`,`history`,`location`]),M=(e,t={})=>{if(!y(e,`Property`)&&!y(e,`MethodDefinition`)&&!y(e,`PropertyDefinition`)&&!y(e,`MemberExpression`))return null;let n=y(e,`MemberExpression`)?e.property:e.key;if(e.computed)return t.allowComputedString&&y(n,`Literal`)&&typeof n.value==`string`?n.value:t.allowComputedString&&t.stringifyNonStringLiterals&&y(n,`Literal`)?String(n.value):t.allowComputedString&&y(n,`TemplateLiteral`)&&n.expressions.length===0?n.quasis[0]?.value.cooked??n.quasis[0]?.value.raw??null:null;if(y(n,`Identifier`))return n.name;if(y(n,`Literal`)){if(typeof n.value==`string`)return n.value;if(t.stringifyNonStringLiterals)return String(n.value)}return null},N=e=>{let t=e.property;return!e.computed&&y(t,`Identifier`)?t.name:e.computed&&y(t,`Literal`)?typeof t.value==`string`?t.value:null:e.computed&&y(t,`TemplateLiteral`)&&t.expressions.length===0?t.quasis[0]?.value.cooked??t.quasis[0]?.value.raw??null:null},P=(e,t,n=!1)=>{if(e.type!==`Identifier`&&e.type!==`JSXIdentifier`)return null;let r=null,i=t.symbolFor(e);for(;i?.kind===`const`;){if(!i.initializer||i.declarationNode.type!==`VariableDeclarator`)return null;if(i.declarationNode.id!==i.bindingIdentifier)return n?i:null;let e=O(i.initializer);if(e.type!==`Identifier`)return i;if(r?.has(i.id))return null;r||=new Set,r.add(i.id),i=t.symbolFor(e)}return i},vi={},yi=new WeakMap,bi=(e,t)=>typeof e==`string`?e===t:e.has(t),xi=e=>{let t=yi.get(e);if(t)return t;let n=e.declarationNode.parent,r=!!(e.kind===`import`&&n&&n.type===`ImportDeclaration`&&typeof n.source.value==`string`&&Hr.has(n.source.value)),i={importedName:r?j(e.declarationNode):void 0,isReactImport:r};return yi.set(e,i),i},Si=e=>xi(e).isReactImport,Ci=(e,t,n,r)=>{if(e.type!==`Identifier`)return!1;let i=r?P(e,n):n.symbolFor(e);if(!i)return!1;let a=xi(i);return!!(a.isReactImport&&a.importedName&&bi(t,a.importedName))},wi=(e,t)=>{let n=P(e,t);if(!n)return!1;let r=xi(n);return r.isReactImport?n.declarationNode.type===`ImportDefaultSpecifier`||n.declarationNode.type===`ImportNamespaceSpecifier`||r.importedName===`default`:!1},Ti=(e,t,n)=>e.type===`Identifier`?wi(e,t)?!0:!!(n.allowGlobalReactNamespace&&e.name===`React`&&t.isGlobalReference(e)):!1,Ei=(e,t,n,r)=>{let i=n.symbolFor(e);if(!i||i.kind!==`const`||!i.initializer||i.declarationNode.type!==`VariableDeclarator`)return!1;let a=i.declarationNode.id;if(a.type!==`ObjectPattern`)return!1;for(let e of a.properties){if(e.type!==`Property`||e.value!==i.bindingIdentifier)continue;let a=M(e);return!!(a&&bi(t,a)&&Ti(O(i.initializer),n,r))}return!1},F=(e,t,n,r=vi)=>e.type===`CallExpression`?Di(e.callee,t,n,r):!1,Di=(e,t,n,r,i)=>{let a=O(e);if(r.resolveConditionalAliases&&a.type===`ConditionalExpression`)return Di(a.consequent,t,n,r,new Set(i))&&Di(a.alternate,t,n,r,new Set(i));if(a.type===`Identifier`){if(Ci(a,t,n,!!r.resolveNamedAliases)||r.resolveNamedAliases&&Ei(a,t,n,r))return!0;if(r.resolveConditionalAliases){let e=n.symbolFor(a);if(e?.kind===`const`&&e.initializer&&!i?.has(e.id)){let a=i??new Set;return a.add(e.id),Di(e.initializer,t,n,r,a)}}return!!(r.allowUnboundBareCalls&&bi(t,a.name)&&n.isGlobalReference(a))}return a.type!==`MemberExpression`||!bi(t,N(a)??``)?!1:Ti(O(a.object),n,r)},Oi=e=>e.includes(`\\`)?e.replaceAll(`\\`,`/`):e,ki=e=>{let t=new Set(e);if(t.size!==1)return null;let[n]=t;return n??null},Ai=(e,t,n,r)=>{let i=en(e,n);return i?ji(i,t,new Set(r))||(Fn(i,t)?i:null):null},ji=(e,t,n=new Set)=>{if(n.has(e))return null;n.add(e);let r=er(e);if(!r.isBarrel)return null;let i=r.exportsByName.get(t);if(i){let t=en(e,i.source);return t?ji(t,i.importedName,n)??t:null}return t===`default`?null:ki(r.starExportSources.map(r=>Ai(e,t,r,n)).filter(e=>!!e))},Mi=(e,t,n)=>{let r=k(e,t,n);return r?{filePath:r.filePath,node:r.exportedNode,programNode:r.programNode,kind:v(r.exportedNode)?`function`:`initializer`}:null},I=e=>{let t=e;for(;t.parent&&jt.has(t.parent.type);)t=t.parent;return t},Ni=(e,t)=>{if(!y(e,`ArrowFunctionExpression`)&&!y(e,`FunctionExpression`)&&!y(e,`FunctionDeclaration`))return null;let n=e.params[0],r=y(n,`AssignmentPattern`)?n.left:n;if(y(r,`ObjectPattern`)){let e=r.properties.find(e=>y(e,`Property`)&&M(e,{allowComputedString:!0})===`children`);if(!e||!y(e,`Property`))return null;let n=y(e.value,`AssignmentPattern`)?e.value.left:e.value;if(!y(n,`Identifier`))return null;let i=t.symbolFor(n);return!i||i.references.length===0||i.references.some(e=>e.flag!==`read`)?null:i.references.map(e=>e.identifier)}if(!y(r,`Identifier`))return null;let i=t.symbolFor(r);if(!i||i.references.length===0)return null;let a=[];for(let e of i.references){if(e.flag!==`read`)return null;let t=[],n=I(e.identifier);for(;n.parent&&y(n.parent,`MemberExpression`)&&n.parent.object===n;){let e=N(n.parent);if(!e)return null;t.push(e),n=I(n.parent)}if(t[0]!==`children`){if(t.length===0)return null;continue}if(t.length!==1)return null;a.push(n)}return a.length>0?a:null},L=e=>{let t=e.parent;for(;t;){if(v(t))return t;t=t.parent??null}return null},Pi=e=>{let t=e;for(;t;){if(y(t,`Program`))return t;t=t.parent??null}return null},Fi=e=>{let t=new Map,n=e.body??[];for(let e of n){if(e.type!==`ImportDeclaration`||!(`source`in e)||!e.source)continue;let n=e.source.value;if(typeof n==`string`&&!(!(`specifiers`in e)||!Array.isArray(e.specifiers)))for(let r of e.specifiers){if(!(`local`in r)||!r.local)continue;let e=r.local;if(typeof e.name==`string`){if(r.type===`ImportDefaultSpecifier`)t.set(e.name,{source:n,imported:null,isDefault:!0,isNamespace:!1});else if(r.type===`ImportNamespaceSpecifier`)t.set(e.name,{source:n,imported:null,isDefault:!1,isNamespace:!0});else if(r.type===`ImportSpecifier`){let i=r.imported,a=i?.name??(typeof i?.value==`string`?i.value:null);t.set(e.name,{source:n,imported:a,isDefault:!1,isNamespace:!1})}}}}return t},Ii=new WeakMap,Li=e=>{let t=Pi(e);if(!t)return null;let n=Ii.get(t);return n||(n=Fi(t),Ii.set(t,n)),n},Ri=(e,t)=>{let n=Li(e);if(!n)return!1;for(let e of n.values())if(t.includes(e.source))return!0;return!1},zi=(e,t,n)=>{let r=Li(e);if(!r)return!1;let i=r.get(t);return i?i.source===n:!1},Bi=(e,t,n)=>{let r=Li(e);if(!r)return!1;let i=r.get(t);return i?i.isNamespace&&i.source===n:!1},Vi=(e,t,n)=>{let r=Li(e);if(!r)return!1;let i=r.get(t);return i?i.isDefault&&i.source===n:!1},Hi=(e,t,n)=>{let r=Li(e);if(!r)return null;let i=r.get(t);return!i||i.source!==n?null:i.imported},Ui=(e,t)=>{let n=Li(e);return n?n.get(t)?.source??null:null},Wi=(e,t)=>{let n=Li(e)?.get(t);return n?n.isNamespace?{source:n.source,exportedName:null,isNamespace:!0}:{source:n.source,exportedName:n.isDefault?`default`:n.imported,isNamespace:!1}:null},Gi=e=>{let t=e,n=t.parent;for(;n&&O(n)===e;)t=n,n=t.parent;return n&&y(n,`AssignmentExpression`)&&n.operator===`=`&&n.left===t?n.right:null},Ki=e=>{let t=e.range?.[0];return typeof t==`number`?t:null},qi=new Set([`let`,`var`]),Ji=new Set([`ConditionalExpression`,`LogicalExpression`]),Yi=new WeakMap,Xi=(e,t,n)=>{let r=e.parent??null;for(;r&&n.blockOf(r)===t;){if(Ji.has(r.type))return!0;r=r.parent??null}return!1},Zi=(e,t)=>e.size===t.size&&[...e].every(e=>t.has(e)),Qi=(e,t)=>{let n=new Set(e);for(let e of t)e.isConditionalWithinBlock||(n=new Set),n.add(e);return n},$i=(e,t,n)=>{let r=L(t);if(L(e.bindingIdentifier)!==r||!r)return[];let i=n.cfgFor(r);if(!i)return[];let a=i.blockOf(t);if(!a)return[];let o=Ki(t),s=Ki(e.bindingIdentifier);if(o===null||s===null)return[];let c=new Map,l=(e,t,n)=>{let r=i.blockOf(t);if(!r)return;let a=c.get(r)??[];a.push({expression:e,position:n,isConditionalWithinBlock:Xi(t,r,i)}),c.set(r,a)};e.initializer&&l(e.initializer,e.bindingIdentifier,s);for(let t of e.references){let e=Ki(t.identifier);if(t.flag===`read`||L(t.identifier)!==r||e===null||e>=o)continue;let n=Gi(t.identifier);n&&l(n,t.identifier,e)}for(let e of c.values())e.sort((e,t)=>e.position-t.position);let u=new Map,d=new Map,f=new Set([i.entry]),p=[i.entry];for(;p.length>0;){let e=p.pop();if(!e)break;for(let t of e.successors)f.has(t.to)||(f.add(t.to),p.push(t.to))}if(!f.has(a))return[];let m=!0;for(;m;){m=!1;for(let e of i.blocks){if(!f.has(e))continue;let t=new Set;for(let n of e.predecessors)if(f.has(n.from))for(let e of d.get(n.from)??[])t.add(e);let n=Qi(t,c.get(e)??[]),r=u.get(e)??new Set,i=d.get(e)??new Set;(!Zi(t,r)||!Zi(n,i))&&(u.set(e,t),d.set(e,n),m=!0)}}let h=(c.get(a)??[]).filter(e=>e.position<o);return[...Qi(u.get(a)??new Set,h)].map(e=>e.expression)},ea=(e,t,n)=>{if(!qi.has(e.kind))return e.initializer?[e.initializer]:[];if(!n)return[];let r=Yi.get(n);r||(r=new WeakMap,Yi.set(n,r));let i=r.get(e);i||(i=new WeakMap,r.set(e,i));let a=i.get(t);if(a)return a;let o=$i(e,t,n);return i.set(t,o),o},ta=e=>{if(!v(e)||!y(e.body,`BlockStatement`))return[];let t=[];return A(e.body,n=>{if(n!==e.body&&(v(n)||y(n,`ClassDeclaration`)||y(n,`ClassExpression`)))return!1;y(n,`ReturnStatement`)&&t.push(n)}),t},R=e=>{if(y(e,`ReturnStatement`)||y(e,`ThrowStatement`))return!0;if(y(e,`IfStatement`)){if(y(e.test,`Literal`)){let t=e.test.value?e.consequent:e.alternate;return t?R(t):!1}return!!(e.alternate&&R(e.consequent)&&R(e.alternate))}if(y(e,`TryStatement`))return e.finalizer&&R(e.finalizer)?!0:R(e.block)?e.handler?R(e.handler.body):!0:!1;if(y(e,`DoWhileStatement`))return R(e.body);if(y(e,`WhileStatement`)){let t=e.test;return!!(y(t,`Literal`)&&t.value&&R(e.body))}if(y(e,`ForStatement`)){let t=e.test;return!!((!t||y(t,`Literal`)&&t.value)&&R(e.body))}return y(e,`BlockStatement`)?e.body.some(e=>R(e)):!1},na=new Set([`let`,`var`]),ra=e=>!v(e)||!e.body?[]:y(e.body,`BlockStatement`)?ta(e).flatMap(e=>e.argument?[e.argument]:[]):[e.body],ia=e=>{if(!v(e)||!y(e.body,`BlockStatement`))return!1;let t=!1;return A(e.body,n=>{if(t||n!==e.body&&v(n))return!1;y(n,`ReturnStatement`)&&!n.argument&&(t=!0)}),t},aa=(e,t,n,r=`some`)=>{let i=new Set,a=new Set,o,s=e=>{if(a.has(e))return!1;a.add(e);try{let t=ra(e);return r===`every`&&v(e)&&y(e.body,`BlockStatement`)&&(!R(e.body)||ia(e))?!1:t.length>0&&(r===`every`?t.every(o):t.some(o))}finally{a.delete(e)}};o=a=>{let l=O(a);if(i.has(l))return!1;i.add(l);try{if(t(l))return!0;if(y(l,`Identifier`)){let t=e.symbolFor(l);if(!t||t.kind!==`const`&&!na.has(t.kind))return!1;let i=ea(t,l,n),a=e=>{let t=O(e);return!v(t)&&o(t)};return r===`every`?i.length>0&&i.every(a):i.some(a)}if(y(l,`CallExpression`)){if(l.arguments.length!==0||!y(l.callee,`Identifier`))return!1;let t=e.symbolFor(l.callee);if(!t||t.kind!==`const`&&t.kind!==`function`)return!1;let n=t.initializer?O(t.initializer):null,r=null;return v(n)?r=n:v(t.declarationNode)&&(r=t.declarationNode),!r||r.async||r.generator||r.params.length!==0?!1:s(r)}return y(l,`ConditionalExpression`)?c(l.consequent,l.alternate):y(l,`LogicalExpression`)?c(l.left,l.right):!1}finally{i.delete(l)}};let c=(e,t)=>{let n=[o(e),o(t)];return r===`every`?n.every(Boolean):n.some(Boolean)};return{expressionMatches:o,functionMatches:s}},oa=(e,t,n,r,i=`some`)=>aa(t,n,r,i).functionMatches(e),sa=(e,t,n,r,i)=>{let a=i.cfgFor(e),o=a?.blockOf(t);if(!a||!o)return!1;let s=new Set(ta(e).flatMap(e=>{if(!e.argument||!aa(n,r,i,`every`).expressionMatches(e.argument))return[];let t=a.blockOf(e.argument);return t?[t]:[]}));if(s.size===0)return!1;let c=new Set([o]),l=[o];for(;l.length>0;){let e=l.pop();if(!e)break;if(!s.has(e))for(let t of e.successors){if(t.to===a.exit)return!1;c.has(t.to)||(c.add(t.to),l.push(t.to))}}return!0},ca=e=>y(e,`Program`)?e.range[1]:e.range[0],la=new WeakMap,ua=(e,t)=>{t.push(...e.symbols);for(let n of e.children)ua(n,t)},da=e=>{let t=new Map,n=[];ua(e.rootScope,n);for(let r of n){let n=P(r.bindingIdentifier,e);if(!n)continue;let i=t.get(n.id)??[];i.push(r),t.set(n.id,i)}return t},fa=(e,t)=>{let n=P(e,t);if(!n)return[];let r=la.get(t);return r||(r=da(t),la.set(t,r)),r.get(n.id)??[]},pa=e=>{let t=e.expressions??[],n=e.quasis??[];if(t.length!==0||n.length!==1)return null;let r=n[0]?.value;return r?.cooked??r?.raw??null},z=(e,t,n={})=>{let r=M(e,{allowComputedString:!0,stringifyNonStringLiterals:n.stringifyNonStringLiterals});if(r!==null||!y(e,`Property`)&&!y(e,`MethodDefinition`)&&!y(e,`PropertyDefinition`)&&!y(e,`MemberExpression`)||!e.computed)return r;let i=O(y(e,`MemberExpression`)?e.property:e.key);if(!y(i,`Identifier`))return null;let a=P(i,t);if(a?.kind!==`const`||!a.initializer)return null;let o=O(a.initializer);return y(o,`Literal`)?typeof o.value==`string`?o.value:n.allowConstNumericLiteral&&typeof o.value==`number`?String(o.value):null:n.allowConstTemplateLiteral&&y(o,`TemplateLiteral`)?pa(o):null},ma=new Set([`CatchClause`,`ConditionalExpression`,`DoWhileStatement`,`ForInStatement`,`ForOfStatement`,`ForStatement`,`IfStatement`,`LogicalExpression`,`SwitchCase`,`SwitchStatement`,`TryStatement`,`WhileStatement`]),ha=(e,t)=>{let n=e.parent??null;for(;n&&n!==t;){if(ma.has(n.type))return!1;n=n.parent??null}return n===t},ga=e=>L(e)??Pi(e),_a=e=>{let t=I(e),n=t.parent;return!!(n&&y(n,`VariableDeclarator`)&&n.init===t&&n.parent&&y(n.parent,`VariableDeclaration`)&&n.parent.kind===`const`)},va=e=>{let t=I(e),n=t.parent;return!!(n&&(y(n,`AssignmentExpression`)&&n.left===t||y(n,`UpdateExpression`)&&n.argument===t||y(n,`UnaryExpression`)&&n.operator===`delete`&&n.argument===t))},ya=e=>{let t=I(e),n=t.parent;return n&&y(n,`MemberExpression`)&&O(n.object)===t?n:null},ba=(e,t,n,r)=>{if(!y(e,`ObjectExpression`))return null;for(let i of e.properties.toReversed()){if(!y(i,`Property`))return null;let e=z(i,n);if(e===null)return null;if(e===t)return i.kind===`init`?B(i.value,n,r):null}return null},xa=(e,t,n,r)=>{if(!y(e,`ObjectExpression`))return[];let i=[],a=new Set;for(let o of e.properties){if(!y(o,`Property`))continue;let e=z(o,n),s=o.kind===`init`||o.kind===`get`?B(o.value,n,new Set(r)):null;e===t?(i=s?[s]:[],a.clear(),s&&a.add(s)):e===null&&s&&!a.has(s)&&(i.push(s),a.add(s))}return i},Sa=(e,t,n,r)=>{if(!y(e,`ClassDeclaration`)&&!y(e,`ClassExpression`))return null;for(let i of e.body.body.toReversed()){if(!y(i,`MethodDefinition`)&&!y(i,`PropertyDefinition`)||!i.static)continue;let e=z(i,n);if(e===null)return null;if(e===t)return y(i,`MethodDefinition`)&&i.kind!==`method`?null:i.value?B(i.value,n,r):null}return null},Ca=(e,t,n,r)=>{if(!y(e,`ClassDeclaration`)&&!y(e,`ClassExpression`))return[];let i=[],a=new Set;for(let o of e.body.body){if(!y(o,`MethodDefinition`)&&!y(o,`PropertyDefinition`)||!o.static)continue;let e=z(o,n),s=o.value&&(!y(o,`MethodDefinition`)||o.kind===`method`||o.kind===`get`)?B(o.value,n,new Set(r)):null;e===t?(i=s?[s]:[],a.clear(),s&&a.add(s)):e===null&&s&&!a.has(s)&&(i.push(s),a.add(s))}return i},wa=(e,t,n,r,i,a,o)=>{let s=ga(t);if(!s||!y(e,`Identifier`))return{exactFunction:null,possibleFunctions:[]};let c=[];for(let r of fa(e,a))for(let e of r.references){let r=e.identifier;if(r.range[0]>=t.range[0]||_a(r))continue;let i=ya(r);if(!i){ga(r)===s&&c.push({assignedExpression:null,isDefinite:!1,offset:r.range[0]});continue}if(!va(i)||ga(i)!==s)continue;let o=z(i,a),l=I(i).parent,u=l&&y(l,`AssignmentExpression`)&&l.operator===`=`?l.right:null;if(o===null){c.push({assignedExpression:u,isDefinite:!1,offset:i.range[0]});continue}if(o===n){if(!l||!y(l,`AssignmentExpression`)||l.operator!==`=`||!ha(i,s)){c.push({assignedExpression:u,isDefinite:!1,offset:i.range[0]});continue}c.push({assignedExpression:u,isDefinite:!0,offset:l.range[0]})}}c.sort((e,t)=>e.offset-t.offset);let l=r,u=i,d=new Set(i);for(let e of c){let t=e.assignedExpression?B(e.assignedExpression,a,new Set(o)):null;if(e.isDefinite){l=t,u=t?[t]:[],d.clear(),t&&d.add(t);continue}l=null,t&&!d.has(t)&&(u.push(t),d.add(t))}return{exactFunction:l,possibleFunctions:u}},Ta=(e,t,n)=>{if(!y(e,`MemberExpression`))return{exactFunction:null,possibleFunctions:[]};let r=N(e);if(r===null)return{exactFunction:null,possibleFunctions:[]};let i=O(e.object);if(y(i,`ObjectExpression`))return{exactFunction:ba(i,r,t,n),possibleFunctions:xa(i,r,t,n)};if(y(i,`ClassExpression`))return{exactFunction:Sa(i,r,t,n),possibleFunctions:Ca(i,r,t,n)};if(!y(i,`Identifier`))return{exactFunction:null,possibleFunctions:[]};let a=P(i,t);if(!a||n.has(a.id))return{exactFunction:null,possibleFunctions:[]};n.add(a.id);let o=null,s=[];if(a.kind===`const`&&a.initializer){let e=O(a.initializer);o=ba(e,r,t,n),s=xa(e,r,t,n)}else a.kind===`class`&&a.initializer&&(o=Sa(a.initializer,r,t,n),s=Ca(a.initializer,r,t,n));return wa(i,e,r,o,s,t,n)},Ea=(e,t,n)=>{let r=O(e);if(y(r,`CallExpression`)){let e=O(r.callee);return y(e,`MemberExpression`)&&N(e)===`bind`?Ea(e.object,t,n):[]}if(y(r,`MemberExpression`)){let e=N(r);return e===`call`||e===`apply`?Ea(r.object,t,n):Ta(r,t,n).possibleFunctions}let i=B(r,t,n);return i?[i]:[]},B=(e,t,n)=>{let r=O(e);if(v(r))return r;if(y(r,`CallExpression`)){let e=O(r.callee);return y(e,`MemberExpression`)&&N(e)===`bind`?B(e.object,t,n):null}if(y(r,`MemberExpression`)){let e=N(r);return e===`call`||e===`apply`?B(r.object,t,n):Ta(r,t,n).exactFunction}if(!y(r,`Identifier`))return null;let i=P(r,t);return!i||n.has(i.id)?null:(n.add(i.id),i.kind===`function`?!i.references.some(e=>e.flag!==`read`)&&v(i.declarationNode)?i.declarationNode:null:i.kind!==`const`||!i.initializer?null:B(i.initializer,t,n))},Da=(e,t)=>B(e,t,new Set),Oa=(e,t)=>Ea(e,t,new Set),ka=new WeakMap,Aa=(e,t)=>{let n=O(e);return y(n,`Identifier`)?t.symbolFor(n):null},ja=(e,t)=>{let n=I(e),r=n.parent;return!r||!y(r,`AssignmentExpression`)||r.operator!==`=`||r.left!==n?null:Aa(r.right,t)},Ma=e=>{let t=I(e),n=t.parent;return n&&y(n,`VariableDeclarator`)&&n.init===t&&(y(n.id,`Identifier`)||y(n.id,`ObjectPattern`))?!0:!!(n&&y(n,`AssignmentExpression`)&&n.operator===`=`&&n.right===t&&y(O(n.left),`Identifier`))},Na=(e,t,n)=>{if(e.initializer&&y(e.declarationNode,`VariableDeclarator`)&&e.declarationNode.id===e.bindingIdentifier){let r=Aa(e.initializer,n);if(r&&t.has(r.id))return!0}return e.references.some(e=>{let r=ja(e.identifier,n);return!!(r&&t.has(r.id))})},Pa=(e,t)=>{let n=P(e,t);if(!n)return[];let r=ka.get(t);r||(r=new Map,ka.set(t,r));let i=r.get(n.id);if(i)return i;let a=[],o=[t.rootScope];for(;o.length>0;){let e=o.pop();e&&(a.push(...e.symbols),o.push(...e.children))}let s=new Set([n.id]),c=!0;for(;c;){c=!1;for(let e of a)s.has(e.id)||Na(e,s,t)&&(s.add(e.id),c=!0)}let l=a.filter(e=>s.has(e.id));return r.set(n.id,l),l},Fa=e=>{let t=e;for(;t;){if(v(t)||y(t,`Program`))return t;t=t.parent??null}return null},Ia=new WeakMap,La=(e,t)=>{let n=Ia.get(t);if(!n){let r=new Map,i=new Map,a=Pi(e);a&&A(a,e=>{if(!y(e,`CallExpression`))return;let n=O(e.callee),a=y(n,`Identifier`)?t.symbolFor(n):null,o=a?i.get(a.id):void 0;o===void 0&&(o=Oa(e.callee,t),a&&i.set(a.id,o));for(let t of o){let n=r.get(t)??[];n.push(e),r.set(t,n)}}),n=r,Ia.set(t,n)}return n.get(e)??[]},Ra=new WeakMap,za=(e,t)=>{let n=Ra.get(t);if(n===void 0){let e=null;A(t,n=>{y(n,`AwaitExpression`)&&L(n)===t&&(e===null||n.range[0]<e)&&(e=n.range[0])}),n=e,Ra.set(t,n)}return n===null||e.range[0]<n},Ba=(e,t,n,r=new Set,i=null,a)=>{if(r.has(e)||!v(e)||e.generator||i!==null&&!ha(i,e)||i!==null&&a!==void 0&&!a(i)||i!==null&&e.async&&!za(i,e))return[];r.add(e);let o=Fa(t);return o?La(e,n).flatMap(e=>{let s=Fa(e);return!s||i!==null&&!ha(e,s)||i!==null&&a!==void 0&&!a(e)?[]:s===o?e.range[0]<ca(t)?[[e.range[0]]]:[]:v(s)?Ba(s,t,n,new Set(r),i===null?null:e,a).map(t=>[...t,e.range[0]]):[]}):[]},Va=(e,t,n,r=new Set,i=null)=>Ba(e,t,n,r,i).length>0,Ha=e=>{let t=e.parent;return t?y(t,`AssignmentExpression`)?t.left===e:(y(t,`UpdateExpression`)||y(t,`UnaryExpression`)&&t.operator===`delete`)&&t.argument===e:!1},Ua=e=>{let t=e.parent;for(;t&&O(t)===e;)t=t.parent;return!t||!y(t,`MemberExpression`)||O(t.object)!==e||!Ha(t)?null:t},Wa=(e,t,n)=>{let r=Ua(e);return r&&z(r,n)===t?r:null},Ga=(e,t,n,r)=>e.references.some(e=>{let i=Wa(e.identifier,t,r);if(!i)return!1;let a=Fa(i),o=Fa(n);return!a||!o||!ha(i,a)?!1:a===o?i.range[0]<ca(n):v(a)&&Va(a,n,r)}),Ka=e=>{if(Ma(e))return!0;let t=I(e),n=t.parent;return!!(n&&y(n,`MemberExpression`)&&O(n.object)===t)},qa=e=>{if(Ma(e))return!0;let t=I(e),n=t.parent;if(!n||!y(n,`MemberExpression`)||O(n.object)!==t)return!1;let r=I(n),i=r.parent;return!(i&&y(i,`CallExpression`)&&i.callee===r)},Ja=(e,t,n)=>y(e,`Identifier`)?Pa(e,n).some(e=>e.references.some(e=>{let r=Ua(e.identifier);if(!r)return!1;let i=z(r,n);return i===null||i===t})):!1,Ya=(e,t,n)=>{let r=Fa(e),i=Fa(t);return!r||!i?!0:r===i?e.range[0]<ca(t):v(r)?Va(r,t,n):!0},Xa=(e,t,n,r)=>y(e,`Identifier`)?Pa(e,r).some(e=>e.references.some(e=>{let i=Ua(e.identifier);if(!i||!Ya(i,n,r))return!1;let a=z(i,r);return a===null||a===t})):!1,Za=(e,t,n)=>y(e,`Identifier`)?Ja(e,t,n)?!0:Pa(e,n).some(e=>e.references.some(e=>!Ka(e.identifier))):!1,Qa=(e,t,n,r)=>y(e,`Identifier`)?Xa(e,t,n,r)?!0:Pa(e,r).some(e=>e.references.some(e=>!qa(e.identifier)&&Ya(e.identifier,n,r))):!1,$a=(e,t)=>{let n=O(e);if(!y(n,`CallExpression`))return!1;let r=O(n.callee);if(!y(r,`MemberExpression`))return!1;let i=N(r);if(i===null)return!1;let a=O(r.object);return y(a,`Identifier`)&&Ja(a,i,t)},eo=(e,t,n,r)=>y(e,`Identifier`)?fa(e,r).some(e=>Ga(e,t,n,r)):!1,to=(e,t,n,r={})=>{let i=L(e);return i===L(t)?e.range[0]>=ca(t)||r.requireSynchronousWrite&&(!i||!ha(e,i)||r.isSynchronousNode!==void 0&&!r.isSynchronousNode(e))?[]:[[e.range[0]]]:i?r.requireSynchronousWrite?Ba(i,t,n,new Set,e,r.isSynchronousNode).map(t=>[...t,e.range[0]]):Ba(i,t,n).map(t=>[...t,e.range[0]]):r.requireSynchronousWrite?[]:[[-1/0,e.range[0]]]},no=(e,t,n,r={})=>to(e,t,n,r).length>0,V=(e,t,n,r={})=>e.references.some(e=>e.flag===`read`?!1:no(e.identifier,t,n,r)),ro=(e,t)=>{if(!y(e,`CallExpression`))return!1;let n=O(e.callee);if(y(n,`Identifier`)){let e=t.symbolFor(n);return!!(e&&!V(e,n,t))}if(!y(n,`MemberExpression`))return!1;let r=N(n),i=O(n.object);return!!(r&&y(i,`Identifier`)&&!eo(i,r,n,t))},io=new Set([`FunctionDeclaration`,`FunctionExpression`,`ArrowFunctionExpression`,`ClassDeclaration`,`ClassExpression`]),ao={allowGlobalReactNamespace:!1,allowUnboundBareCalls:!1},oo=new Set([`lodash/sortBy`,`lodash/sortBy.js`,`lodash-es/sortBy`,`lodash-es/sortBy.js`]),so=e=>y(e,`TSArrayType`)||y(e,`TSTupleType`)?!0:y(e,`TSTypeReference`)?y(e.typeName,`Identifier`)&&(e.typeName.name===`Array`||e.typeName.name===`ReadonlyArray`):!1,co=e=>{if(!y(e,`Identifier`))return!1;let t=e.typeAnnotation;return!!(t&&y(t,`TSTypeAnnotation`)&&so(t.typeAnnotation))},lo=(e,t)=>{if(!y(e,`CallExpression`))return!1;let n=O(e.callee);if(!y(n,`Identifier`))return!1;let r=t.symbolFor(n);if(!r||V(r,n,t)||!y(r.declarationNode,`ImportDefaultSpecifier`)&&!y(r.declarationNode,`ImportSpecifier`))return!1;let i=Wi(n,n.name);return!i||i.isNamespace?!1:oo.has(i.source)&&i.exportedName===`default`?!0:(i.source===`lodash`||i.source===`lodash-es`)&&i.exportedName===`sortBy`},uo=(e,t,n,r=new Set)=>{let i=O(e);if(y(i,`ArrayExpression`)||lo(i,t))return!0;if(!y(i,`Identifier`))return!1;let a=t.symbolFor(i);return!a||r.has(a.id)||V(a,n,t)?!1:co(a.bindingIdentifier)?!0:a.initializer?(r.add(a.id),uo(a.initializer,t,n,r)):!1},fo=(e,t)=>{if(!y(e,`CallExpression`))return!1;let n=O(e.callee);if(!y(n,`MemberExpression`)||N(n)!==`map`)return!1;let r=O(n.object);return uo(r,t,e)?!(y(r,`Identifier`)&&eo(r,`map`,e,t)):!1},po=(e,t)=>{if(e.type!==`ArrowFunctionExpression`&&e.type!==`FunctionExpression`)return!1;let n=e.parent;return y(n,`CallExpression`)?F(n,`useMemo`,t,{resolveNamedAliases:!0})&&ro(n,t)?n.arguments[0]===e:n.arguments.some(t=>t===e)&&fo(n,t):!1},mo=(e,t)=>io.has(e.type)&&!po(e,t),ho=(e,t)=>e.type===`JSXElement`||e.type===`JSXFragment`||F(e,`createElement`,t,ao)||go(e,t),go=(e,t)=>{if(!y(e,`CallExpression`))return!1;let n=O(e.callee);if(y(n,`Identifier`))return t.symbolFor(n)?.kind===`import`&&Hi(n,n.name,`react-dom`)===`createPortal`;if(!y(n,`MemberExpression`)||n.computed||!y(n.object,`Identifier`)||!y(n.property,`Identifier`)||n.property.name!==`createPortal`)return!1;let r=t.symbolFor(n.object);return!r||r.kind!==`import`?!1:Vi(n.object,n.object.name,`react-dom`)||Bi(n.object,n.object.name,`react-dom`)},_o=(e,t)=>{let n=!1;return A(e,r=>{if(n||r!==e&&mo(r,t))return!1;if(ho(r,t))return n=!0,!1}),n},vo=new WeakMap,yo=(e,t,n)=>{let r=vo.get(e);if(r&&r.scopes===t&&r.controlFlow===n)return r.hasRenderOutput;let i=oa(e,t,e=>_o(e,t),n);return vo.set(e,{scopes:t,controlFlow:n,hasRenderOutput:i}),i},bo=e=>y(e,`JSXIdentifier`)?e.name:y(e,`JSXNamespacedName`)?`${e.namespace.name}:${e.name.name}`:null,xo=new Set([`Component`,`PureComponent`]),So=(e,t,n,r)=>{let i=O(e);if(y(i,`MemberExpression`)){let e=N(i),n=O(i.object);return!!(e&&xo.has(e)&&y(n,`Identifier`)&&!eo(n,e,i,t)&&wi(n,t))}if(y(i,`ClassExpression`))return Co(i,t,n,r);if(!y(i,`Identifier`))return!1;let a=t.symbolFor(i);if(!a||r.has(a.id)||V(a,i,t))return!1;if(r.add(a.id),Si(a)){let e=j(a.declarationNode);return!!(e&&xo.has(e))}return y(a.declarationNode,`ClassDeclaration`)||y(a.declarationNode,`ClassExpression`)?Co(a.declarationNode,t,n,r):!!(a.kind===`const`&&a.initializer&&So(a.initializer,t,n,r))},Co=(e,t,n=new Set,r=new Set)=>!y(e,`ClassDeclaration`)&&!y(e,`ClassExpression`)||n.has(e)||!e.superClass?!1:(n.add(e),So(e.superClass,t,n,r)),wo=new Set([`FunctionDeclaration`,`FunctionExpression`,`ArrowFunctionExpression`,`MethodDefinition`,`Program`]),To=e=>{let t=e;for(;t;){if(wo.has(t.type))return t;t=t.parent??null}return null},Eo=(e,t)=>{if(t!==`let`&&t!==`const`)return To(e);let n=e.parent;for(;n;){if(n.type===`BlockStatement`){let t=n.parent;return t&&(t.type===`FunctionDeclaration`||t.type===`FunctionExpression`||t.type===`ArrowFunctionExpression`||t.type===`MethodDefinition`)?To(e):n}if(wo.has(n.type))return n;n=n.parent??null}return null},Do=(e,t,n,r)=>{if(y(e,`Identifier`)){let i=r.get(e.name)??[];i.push({bindingIdentifier:e,initializer:t,scopeOwner:n}),r.set(e.name,i);return}if(y(e,`ObjectPattern`)){for(let t of e.properties)if(y(t,`Property`)){let e=t.value;Do(e,y(e,`AssignmentPattern`)?e.right:null,n,r)}else y(t,`RestElement`)&&Do(t.argument,null,n,r);return}if(y(e,`ArrayPattern`)){for(let t of e.elements)t&&Do(t,y(t,`AssignmentPattern`)?t.right??null:null,n,r);return}if(y(e,`AssignmentPattern`)){Do(e.left,e.right??null,n,r);return}y(e,`RestElement`)&&Do(e.argument,null,n,r)},Oo=e=>{let t=new Map;return A(e,e=>{switch(e.type){case`VariableDeclarator`:{let n=e.parent,r=Eo(e,n?.type===`VariableDeclaration`?n.kind:void 0);r&&Do(e.id,e.init??null,r,t);break}case`FunctionDeclaration`:case`FunctionExpression`:case`ArrowFunctionExpression`:if(e.type!==`ArrowFunctionExpression`&&e.id){let n=e.parent?To(e.parent):null;if(n){let r=t.get(e.id.name)??[];r.push({bindingIdentifier:e.id,initializer:e,scopeOwner:n}),t.set(e.id.name,r)}}for(let n of e.params)Do(n,null,e,t);break;case`ClassDeclaration`:case`ClassExpression`:{if(!e.id)break;let n=e.parent?To(e.parent):null;if(n){let r=t.get(e.id.name)??[];r.push({bindingIdentifier:e.id,initializer:e,scopeOwner:n}),t.set(e.id.name,r)}break}case`ImportDeclaration`:{let n=To(e);if(!n)break;for(let r of e.specifiers){let e=r.local;if(e&&y(e,`Identifier`)){let i=t.get(e.name)??[];i.push({bindingIdentifier:e,initializer:r,scopeOwner:n}),t.set(e.name,i)}}break}case`TSImportEqualsDeclaration`:case`TSEnumDeclaration`:case`TSModuleDeclaration`:{let n=e.id;if(n?.type===`Identifier`){let r=To(e);if(r){let e=t.get(n.name)??[];e.push({bindingIdentifier:n,initializer:null,scopeOwner:r}),t.set(n.name,e)}}break}}}),t},ko=new WeakMap,Ao=new WeakMap,jo=e=>{let t=Pi(e);if(!t)return null;let n=ko.get(t);return n||(n=Oo(t),ko.set(t,n)),n},Mo=(e,t,n)=>{let r=jo(e);if(!r)return null;let i=r.get(t);if(!i||i.length===0)return null;let a=i[0];if(i.length===1&&a){let t=e;for(;t;){if(t===a.scopeOwner)return a;t=t.parent??null}return null}let o=e;for(;o;){let t=null;for(let r of i)if(r.scopeOwner===o){if(t===null){t=r;continue}if(n?.preferInitializerBeforeReference){let n=!!(r.initializer&&(y(r.initializer,`FunctionDeclaration`)||r.bindingIdentifier.range[0]<e.range[0]));if(n!==!!(t.initializer&&(y(t.initializer,`FunctionDeclaration`)||t.bindingIdentifier.range[0]<e.range[0]))){n&&(t=r);continue}}(r.initializer!==null||t.initializer===null)&&(t=r)}if(t)return t;o=o.parent??null}return null},No=(e,t,n)=>{let r=Ao.get(e),i;if(!r)i={},Ao.set(e,{primaryBindingName:t,primaryLookup:i});else if(r.primaryBindingName===t)i=r.primaryLookup;else{let e=r.additionalLookups;e||(e=new Map,r.additionalLookups=e);let n=e.get(t);n?i=n:(i={},e.set(t,i))}let a=n?.preferInitializerBeforeReference?`preferredResult`:`defaultResult`;if(a in i)return i[a]??null;let o=Mo(e,t,n);return i[a]=o,o},Po=e=>Xr.test(e),Fo=e=>{let t=No(e,e.name);if(!t?.initializer)return null;let n=t.bindingIdentifier.parent;if(!n||!y(n,`VariableDeclarator`)||n.id!==t.bindingIdentifier)return null;let r=n.parent;if(!r||!y(r,`VariableDeclaration`)||r.kind!==`const`)return null;let i=O(t.initializer);return y(i,`Literal`)&&typeof i.value==`string`?i.value:null},Io=e=>y(e,`JSXIdentifier`)?e.name:y(e,`JSXMemberExpression`)?`${Io(e.object)}.${e.property.name}`:y(e,`JSXNamespacedName`)?`${e.namespace.name}:${e.name.name}`:``,Lo=e=>{let t=e.name;return y(t,`JSXIdentifier`)?Po(t.name)?Fo(t)??t.name:t.name:Io(t)},Ro=(e,t)=>{if(!y(e.name,`JSXIdentifier`))return!1;let n=Lo(e);if(n[0]===n[0]?.toLowerCase())return!0;let r=new Set,i=e=>{let n=I(e);if(y(n,`Literal`))return typeof n.value==`string`;if(y(n,`Identifier`)||y(n,`JSXIdentifier`)){let e=t.symbolFor(n);if(!e||e.kind!==`const`||!e.initializer||r.has(e.id))return!1;r.add(e.id);let a=i(e.initializer);return r.delete(e.id),a}return y(n,`ConditionalExpression`)?i(n.consequent)&&i(n.alternate):!1};return i(e.name)},zo=(e,t,n=new Set)=>{if(!e)return null;let r=O(e);if(v(r))return r;if(y(r,`Identifier`)){let e=t.symbolFor(r);return!e||n.has(e.id)||!e.initializer||V(e,r,t)?null:(n.add(e.id),zo(e.initializer,t,n))}if(!y(r,`CallExpression`)||!F(r,`memo`,t,{resolveNamedAliases:!0})&&!F(r,`forwardRef`,t,{resolveNamedAliases:!0}))return null;let i=r.arguments[0];return!i||y(i,`SpreadElement`)?null:zo(i,t,n)},Bo=(e,t)=>{let n=I(e);if(!v(n)||n.async||n.generator)return!1;let r=n.parent;if(!r||!y(r,`JSXExpressionContainer`))return!1;let i=r.parent;if(!i||!y(i,`JSXAttribute`)||bo(i.name)!==`ref`)return!1;let a=i.parent;return!!(a&&y(a,`JSXOpeningElement`)&&Ro(a,t))},Vo=(e,t)=>t.every((t,n)=>e[n]===t),Ho=e=>{let t=I(e);for(;t.parent&&y(t.parent,`MemberExpression`)&&t.parent.object===t;){if(!N(t.parent))return null;t=I(t.parent)}return t},Uo=(e,t,n,r)=>{if(t.length!==n.length+1||!Vo(t,n)||t[n.length]!==`current`)return!1;let i=Ho(e),a=i?.parent;if(!i||!a||!y(a,`AssignmentExpression`)||a.operator!==`=`||a.left!==i)return!1;let o=L(e);if(!o)return!1;if(Bo(o,r))return!0;if(!v(o)||o.async||o.generator)return!1;let s=L(o);if(!s||!Bo(s,r))return!1;let c=I(o),l=c.parent;return!!(y(l,`ReturnStatement`)&&l.argument===c&&L(l)===s||y(s,`ArrowFunctionExpression`)&&s.body===c)},Wo=(e,t)=>{if(!y(e,`JSXOpeningElement`))return!1;let n=e.name;if(y(n,`JSXIdentifier`)){if(!t)return n.name===`Fragment`;let e=P(n,t);return e?Si(e)&&j(e.declarationNode)===`Fragment`:n.name===`Fragment`&&t.isGlobalReference(n)}return y(n,`JSXMemberExpression`)?!y(n.object,`JSXIdentifier`)||n.property.name!==`Fragment`?!1:t?wi(n.object,t)?!0:n.object.name===`React`&&t.isGlobalReference(n.object):n.object.name===`React`:!1},Go=(e,t,n,r,i)=>{let a=I(e),o=a.parent;if(!o)return!1;if(y(o,`ReturnStatement`)&&o.argument===a)return L(o)===t;if(y(o,`ArrowFunctionExpression`)&&o.body===a)return o===t;if(y(o,`JSXFragment`)&&o.children.some(e=>e===a)||y(o,`JSXElement`)&&o.children.some(e=>e===a)&&(Ro(o.openingElement,n)||Wo(o.openingElement,n)||i.doesCustomElementRenderChildren?.(o.openingElement)))return Go(o,t,n,r,i);if(y(o,`JSXExpressionContainer`)&&o.expression===a&&o.parent&&(y(o.parent,`JSXFragment`)||y(o.parent,`JSXElement`)&&(Ro(o.parent.openingElement,n)||Wo(o.parent.openingElement,n)||i.doesCustomElementRenderChildren?.(o.parent.openingElement))))return Go(o.parent,t,n,r,i);if(y(o,`ConditionalExpression`)&&(o.consequent===a||o.alternate===a)||y(o,`LogicalExpression`)&&(o.left===a||o.right===a)||y(o,`ArrayExpression`)&&o.elements.some(e=>e===a))return Go(o,t,n,r,i);if(!y(o,`VariableDeclarator`)||o.init!==a||!y(o.id,`Identifier`))return!1;let s=n.symbolFor(o.id);if(!s||s.kind!==`const`||s.references.length===0||r.has(s.id))return!1;r.add(s.id);let c=s.references.every(e=>e.flag===`read`&&Go(e.identifier,t,n,r,i));return r.delete(s.id),c},Ko=(e,t,n={})=>Go(e,L(e),t,new Set,n),qo=(e,t)=>t.every((t,n)=>e[n]===t),Jo=(e,t)=>qo(e,t)||qo(t,e),Yo=e=>v(e)&&y(e.body,`BlockStatement`)&&e.body.body.length===0,Xo=(e,t,n)=>F(e,t,n,{resolveNamedAliases:!0}),Zo=(e,t,n=new Set)=>y(e,`ObjectExpression`)?e.properties.every(e=>{if(y(e,`SpreadElement`)){let r=I(e.argument);if(y(r,`ObjectExpression`))return Zo(r,t,n);if(!y(r,`Identifier`))return!1;let i=t.symbolFor(r);if(!i||i.kind!==`const`||n.has(i.id)||!y(i.initializer,`ObjectExpression`))return!1;n.add(i.id);let a=Zo(i.initializer,t,n);return n.delete(i.id),a}return y(e,`Property`)?!v(e.value)||Yo(e.value):!1}):!1,Qo=e=>N(e)||(e.computed&&y(e.property,`Literal`)&&typeof e.property.value==`number`&&Number.isSafeInteger(e.property.value)&&e.property.value>=0?String(e.property.value):null),$o=e=>{let t=[],n=I(e);for(;n.parent&&y(n.parent,`MemberExpression`)&&n.parent.object===n;){let e=Qo(n.parent);if(!e)return null;t.push(e),n=I(n.parent)}return{expression:n,propertyPath:t}},es=(e,t,n)=>{let r=n.environmentsByProgram.get(e);if(r)return r;let i={filename:t,program:e,scopes:Ie(e)};return n.environmentsByProgram.set(e,i),i},ts=(e,t,n=new Set)=>{let r=I(e);if(y(r,`Identifier`)){let e=t.symbolFor(r);return!e||!e.initializer||n.has(e.id)||V(e,r,t)?!1:(n.add(e.id),ts(e.initializer,t,n))}if(!y(r,`CallExpression`))return!1;if(Xo(r,`forwardRef`,t))return!0;if(!Xo(r,`memo`,t))return!1;let i=r.arguments[0];return!i||y(i,`SpreadElement`)?!1:ts(i,t,n)},ns=(e,t)=>{let n=es(e.programNode,e.filePath,t),r=zo(e.exportedNode,n.scopes);return r?{environment:n,functionNode:r,isForwardRef:ts(e.exportedNode,n.scopes)}:null},rs=(e,t,n)=>{if(!y(e,`Identifier`)&&!y(e,`JSXIdentifier`))return null;let r=t.scopes.symbolFor(e);if(r&&r.kind!==`import`){if(V(r,e,t.scopes))return null;let n=zo(r.initializer,t.scopes);return n?{environment:t,functionNode:n,isForwardRef:!!(r.initializer&&ts(r.initializer,t.scopes))}:null}let i=Wi(e,e.name);if(!i||i.isNamespace||i.exportedName===null)return null;let a=k(t.filename,i.source,i.exportedName);return a?ns(a,n):null},is=(e,t,n)=>{if(y(e,`JSXIdentifier`))return rs(e,t,n);if(!y(e,`JSXMemberExpression`)||!y(e.object,`JSXIdentifier`))return null;let r=Wi(e.object,e.object.name);if(!r?.isNamespace)return null;let i=k(t.filename,r.source,e.property.name);return i?ns(i,n):null},as=(e,t,n=new Set)=>{let r=I(e);if(y(r,`Identifier`)){let e=t.scopes.symbolFor(r);return!e||!e.initializer||n.has(e.id)||V(e,r,t.scopes)?!1:(n.add(e.id),as(e.initializer,t,n))}return Co(r,t.scopes)},os=(e,t,n)=>{if(!y(e,`JSXIdentifier`))return!1;let r=t.scopes.symbolFor(e);if(r&&r.kind!==`import`)return V(r,e,t.scopes)?!1:!!(r.initializer&&as(r.initializer,t));let i=Wi(e,e.name);if(!i||i.isNamespace||i.exportedName===null)return!1;let a=k(t.filename,i.source,i.exportedName);if(!a)return!1;let o=es(a.programNode,a.filePath,n);return as(a.exportedNode,o)},ss=(e,t)=>{if(!e)return null;let n=I(e);return!y(n,`ClassDeclaration`)&&!y(n,`ClassExpression`)||!as(n,t)?null:{classNode:n,environment:t}},cs=(e,t,n)=>{if(!y(e,`JSXIdentifier`))return null;let r=t.scopes.symbolFor(e);if(r&&r.kind!==`import`)return V(r,e,t.scopes)?null:ss(r.initializer,t);let i=Wi(e,e.name);if(!i||i.isNamespace||i.exportedName===null)return null;let a=k(t.filename,i.source,i.exportedName);if(!a)return null;let o=es(a.programNode,a.filePath,n);return ss(a.exportedNode,o)},ls=(e,t,n)=>{let r=[...t],i=I(e);for(;i.parent;){let e=i.parent;if(y(e,`ArrayExpression`)){if(e.elements.some(e=>e&&y(e,`SpreadElement`)))return null;let t=e.elements.findIndex(e=>e===i);if(t<0)return null;r.unshift(String(t)),i=I(e);continue}if(y(e,`Property`)&&e.value===i){let t=M(e,{allowComputedString:!0}),a=e.parent;if(!t||!a||!Zo(a,n.scopes))return null;r.unshift(t),i=I(a);continue}if(y(e,`ConditionalExpression`)&&(e.consequent===i||e.alternate===i)||y(e,`LogicalExpression`)&&(e.left===i||e.right===i)){i=I(e);continue}if(y(e,`VariableDeclarator`)&&e.init===i&&y(e.id,`Identifier`)){let t=n.scopes.symbolFor(e.id);return!t||t.kind!==`const`?null:{environment:n,propertyPath:r,symbol:t}}if(y(e,`AssignmentExpression`)&&e.operator===`=`&&e.right===i&&y(e.left,`MemberExpression`)){let t=[],i=e.left;for(;y(i,`MemberExpression`);){let e=Qo(i);if(!e)return null;t.unshift(e),i=I(i.object)}if(!y(i,`Identifier`))return null;let a=n.scopes.symbolFor(i);return!a||a.kind!==`const`?null:{environment:n,originWriteReference:i,propertyPath:[...t,...r],symbol:a}}return null}return null},us=(e,t,n,r,i)=>{if(y(e,`AssignmentPattern`))return us(e.left,t,n,r,i);if(y(e,`Identifier`)){let a=n.scopes.symbolFor(e);return!!(a&&Ts({environment:n,propertyPath:t,symbol:a},r,i-1))}if(!y(e,`ObjectPattern`)||t.length===0)return!1;let[a,...o]=t;for(let t of e.properties){if(!y(t,`Property`))continue;let e=M(t,{allowComputedString:!0});if(!e)return!1;if(e===a)return us(t.value,o,n,r,i)}let s=e.properties.find(e=>y(e,`RestElement`));return s?us(s.argument,t,n,r,i):!0},ds=(e,t)=>{let n=e.arguments[0];return!n||y(n,`SpreadElement`)?!1:Xo(e,`createElement`,t.scopes)?y(n,`Literal`)&&typeof n.value==`string`:!Xo(e,`cloneElement`,t.scopes)||!y(n,`JSXElement`)?!1:Ro(n.openingElement,t.scopes)},fs=(e,t,n,r,i)=>{if(t.length>0)return!1;let a=e.parent;if(!a||!y(a,`Property`)||a.value!==e||M(a,{allowComputedString:!0})!==`ref`)return!1;let o=a.parent;if(!o||!y(o,`ObjectExpression`))return!1;let s=o.parent;return!(!s||!y(s,`CallExpression`)||s.arguments[1]!==o||!ds(s,n)||!H(s,n,r,i))},ps=(e,t,n,r,i)=>{if(i<=0||!v(e.functionNode)||e.functionNode.async||e.functionNode.generator)return!1;let a=e.functionNode.params[t];return!!(a&&us(a,n,e.environment,r,i))},ms=e=>{if(!y(e,`MemberExpression`)||N(e)!==`children`)return!1;let t=I(e.object);return!!(y(t,`MemberExpression`)&&N(t)===`props`&&y(I(t.object),`ThisExpression`))},hs=(e,t)=>{if(!y(e,`JSXOpeningElement`)||!y(e.name,`JSXMemberExpression`)||e.name.property.name!==`Provider`||!y(e.name.object,`JSXIdentifier`))return!1;let n=t.scopes.symbolFor(e.name.object);return!!(n?.kind===`const`&&n.initializer&&y(n.initializer,`CallExpression`)&&Xo(n.initializer,`createContext`,t.scopes))},H=(e,t,n,r)=>Ko(e,t.scopes,{doesCustomElementRenderChildren:e=>vs(e,t,n,r-1)}),gs=(e,t,n)=>{let{functionNode:r}=e;if(n<=0||t.activeRenderedChildrenComponents.has(r)||!y(r,`ArrowFunctionExpression`)&&!y(r,`FunctionExpression`)&&!y(r,`FunctionDeclaration`)||r.async||r.generator)return!1;let i=Ni(r,e.environment.scopes);if(!i)return!1;t.activeRenderedChildrenComponents.add(r);let a=i.every(r=>H(r,e.environment,t,n));return t.activeRenderedChildrenComponents.delete(r),a},_s=(e,t,n)=>{let{classNode:r,environment:i}=e;if(n<=0||t.activeRenderedChildrenComponents.has(r)||!y(r,`ClassDeclaration`)&&!y(r,`ClassExpression`))return!1;let a=r.body.body.find(e=>y(e,`MethodDefinition`)&&!e.computed&&y(e.key,`Identifier`)&&e.key.name===`render`);if(!a||!y(a,`MethodDefinition`))return!1;let o=[];if(A(r,e=>{ms(e)&&o.push(e)}),o.length===0)return!1;t.activeRenderedChildrenComponents.add(r);let s=o.every(e=>L(e)===a.value&&H(e,i,t,n));return t.activeRenderedChildrenComponents.delete(r),s},vs=(e,t,n,r)=>{if(r<=0||!y(e,`JSXOpeningElement`))return!1;if(hs(e,t))return!0;let i=is(e.name,t,n);if(i)return gs(i,n,r);let a=cs(e.name,t,n);return!!(a&&_s(a,n,r))},ys=(e,t,n,r,i)=>{let a=bo(e.name),o=e.parent;if(!a||!o||!y(o,`JSXOpeningElement`))return!1;let s=o.parent;if(!s||!y(s,`JSXElement`)||!H(s,n,r,i))return!1;if(Ro(o,n.scopes))return a===`ref`&&t.length===0;if(y(o.name,`JSXIdentifier`)&&a===`ref`&&t.length===0&&os(o.name,n,r))return!0;let c=is(o.name,n,r);return c?a===`ref`&&c.isForwardRef?ps(c,1,t,r,i):ps(c,0,[a,...t],r,i):!1},bs=(e,t,n,r,i,a)=>{let o=e.arguments.findIndex(e=>e===t);if(o<0)return!1;if(o===0&&y(e.callee,`Identifier`)&&e.callee.name===`Boolean`&&r.scopes.isGlobalReference(e.callee))return!0;if(o===0&&Xo(e,`useImperativeHandle`,r.scopes))return n.length===0;if(o===1&&n.length===1&&n[0]===`ref`&&ds(e,r)&&H(e,r,i,a))return!0;let s=I(e.callee);if(v(s))return yo(s,r.scopes)&&!H(e,r,i,a)?!1:ps({environment:r,functionNode:s,isForwardRef:!1},o,n,i,a);if(!y(e.callee,`Identifier`))return!1;let c=rs(e.callee,r,i);return!!(c&&(!yo(c.functionNode,c.environment.scopes)||H(e,r,i,a))&&ps(c,o,n,i,a))},xs=(e,t,n,r,i)=>{let a;if(t.length===1&&t[0]===`ref`)a=e.parent;else if(t.length===0){let t=e.parent;if(!t||!y(t,`Property`)||t.value!==e||M(t,{allowComputedString:!0})!==`ref`)return!1;a=t.parent?.parent}if(!a||!y(a,`JSXSpreadAttribute`))return!1;let o=a.parent;if(!o||!y(o,`JSXOpeningElement`))return!1;let s=o.parent;return!!(Ro(o,n.scopes)&&s&&y(s,`JSXElement`)&&H(s,n,r,i))},Ss=(e,t,n,r,i)=>{let a=I(e),o=a.parent;if(!o)return!1;if(y(o,`ExpressionStatement`)||y(o,`UnaryExpression`)&&o.operator===`void`&&o.argument===a)return!0;if(t.length===0&&y(o,`BinaryExpression`)&&(o.operator===`===`||o.operator===`!==`||o.operator===`==`||o.operator===`!=`)){let e=o.left===a?o.right:o.left;return!!(y(a,`Identifier`)&&y(e,`Identifier`)&&n.scopes.symbolFor(a)?.id===n.scopes.symbolFor(e)?.id)}if(xs(a,t,n,r,i)||fs(a,t,n,r,i)||t.length>0&&(y(o,`LogicalExpression`)&&o.left===a||y(o,`ConditionalExpression`)&&o.test===a||y(o,`IfStatement`)&&o.test===a||y(o,`UnaryExpression`)&&o.operator===`!`&&o.argument===a))return!0;if(y(o,`JSXExpressionContainer`)&&o.expression===a){let e=o.parent;return!!(e&&y(e,`JSXAttribute`)&&ys(e,t,n,r,i))}if(y(o,`CallExpression`))return bs(o,a,t,n,r,i);if(y(o,`VariableDeclarator`)&&o.init===a&&!y(o.id,`Identifier`))return us(o.id,t,n,r,i);let s=ls(a,t,n);return!!(s&&Ts(s,r,i-1))},Cs=e=>{let t=e.parent;return t&&y(t,`VariableDeclarator`)&&t.init===e&&y(t.id,`Identifier`)?t.id:(y(e,`FunctionDeclaration`)||y(e,`FunctionExpression`))&&e.id?e.id:null},ws=(e,t,n)=>{if(!e||!t||!v(e)||e.async||e.generator)return!1;let r=Cs(e);if(!r||((y(e,`FunctionDeclaration`)||y(e,`FunctionExpression`))&&e.id===r?L(e):L(r))!==t)return!1;let i=y(e,`FunctionDeclaration`)?n.ownScopeFor(t)?.symbolsByName.get(r.name):n.symbolFor(r);return!!(i&&i.references.length>0&&i.references.every(e=>{let r=I(e.identifier),i=r.parent;return!!(i&&y(i,`CallExpression`)&&i.callee===r&&L(i)===t&&Ko(i,n))}))},Ts=(e,t,n)=>{if(n<=0)return!1;let r=`${e.environment.filename}:${e.symbol.id}:${e.propertyPath.join(`.`)}`;if(t.activePaths.has(r))return!1;t.activePaths.add(r);let i=L(e.symbol.bindingIdentifier),a=e.symbol.references.every(r=>{if(r.identifier===e.originWriteReference)return!0;let a=r.identifier.parent;if(a&&y(a,`Property`)&&!a.computed&&a.key===r.identifier&&a.value!==r.identifier)return!0;let o=$o(r.identifier);if(!o)return!1;if(!Jo(o.propertyPath,e.propertyPath))return!0;let s=L(r.identifier);if(s!==i&&!ws(s,i,e.environment.scopes))return!!Uo(r.identifier,o.propertyPath,e.propertyPath,e.environment.scopes);if(r.flag!==`read`)return!1;if(qo(o.propertyPath,e.propertyPath)){if(o.propertyPath.length>e.propertyPath.length){let t=o.expression.parent;return!!(o.propertyPath.length===e.propertyPath.length+1&&o.propertyPath[e.propertyPath.length]===`current`&&t&&y(t,`UnaryExpression`)&&t.operator===`void`&&t.argument===o.expression)}return Ss(o.expression,[],e.environment,t,n)}return Ss(o.expression,e.propertyPath.slice(o.propertyPath.length),e.environment,t,n)});return t.activePaths.delete(r),a},Es=(e,t,n)=>{if(!t)return!1;let r=Pi(e);if(!r)return!1;let i={filename:t,program:r,scopes:n},a={activePaths:new Set,activeRenderedChildrenComponents:new WeakSet,environmentsByProgram:new WeakMap([[r,i]])},o=ls(e,[],i);return o?Ts(o,a,12):Ss(e,[],i,a,12)},Ds=e=>{let t=[];for(let n of e)for(let e of n.entries){if(e.importName.kind===`NamespaceObject`)continue;let r=e.importName.kind===`Default`?`default`:e.importName.name??null;r!==null&&t.push({source:n.moduleRequest.value,exportedName:r})}return t},Os=({absoluteFilePath:e,staticImports:t})=>{let n=!1;for(let r of t){let t=r.moduleRequest.value;if(!t.startsWith(`.`))continue;let i=r.entries.filter(e=>!e.isType);if(i.length===0)continue;let a=en(e,t);if(!(!a||!tr(a))){n||(n=!0,At(e));for(let e of i){let t=e.importName.kind===`Default`?`default`:e.importName.name;t&&ji(a,t)}}}},ks=({absoluteFilePath:e})=>{ze.test(e)&&(Ue.test(e)||Ln(e))},As=({absoluteFilePath:e,staticImports:t})=>{if(Be.test(e)&&!Bn(e))for(let n of Ds(t))bn(e,n.source,n.exportedName)},js=({absoluteFilePath:e,staticImports:t})=>{for(let n of Ds(t))bn(e,n.source,n.exportedName)},Ms=({absoluteFilePath:e,staticImports:t})=>{for(let n of Ds(t))Mi(e,n.source,n.exportedName)},Ns=e=>{let t=[];for(let n of e.body??[]){if(n.type!==`ImportDeclaration`)continue;let e=n.source?.value;if(typeof e==`string`){for(let r of n.specifiers??[])if(r.type===`ImportDefaultSpecifier`)t.push({source:e,exportedName:`default`});else if(r.type===`ImportSpecifier`){let n=r.imported,i=null;typeof n?.name==`string`?i=n.name:typeof n?.value==`string`&&(i=n.value),i&&t.push({source:e,exportedName:i})}}}return t},Ps=({absoluteFilePath:e,staticImports:t},n,r=()=>!0,i=()=>!0)=>{let a=new Map,o=(e,t,n)=>{if(!((a.get(e)??-1)>=n)){a.set(e,n);for(let a of Ns(t)){let t=k(e,a.source,a.exportedName);!t||n===0||!r(t)||!i(t.filePath)||o(t.filePath,t.programNode,n-1)}}};for(let a of Ds(t)){let t=k(e,a.source,a.exportedName);!t||!r(t)||!i(t.filePath)||o(t.filePath,t.programNode,n)}},Fs=e=>{Ps(e,4)},Is=({absoluteFilePath:e,sourceText:t,getProgram:n})=>{if(!t.includes(`createRef`)&&!t.includes(`\\u`))return;let r=n();Ft(r);let i=Ie(r);A(r,t=>{!y(t,`CallExpression`)||!F(t,`createRef`,i,{allowGlobalReactNamespace:!0,allowUnboundBareCalls:!0,resolveNamedAliases:!0})||Es(t,e,i)})},Ls=({absoluteFilePath:e,sourceText:t,staticImports:n,getProgram:r})=>{let i=new Set,a=new Set;for(let e of n)if(e.moduleRequest.value===`react`)for(let t of e.entries){let{importName:e}=t;e.kind===`Name`&&e.name===`useReducer`?i.add(t.localName.value):(e.kind===`Default`||e.kind===`NamespaceObject`)&&a.add(t.localName.value)}if(!(i.size>0||a.size>0&&(t.includes(`useReducer`)||t.includes(`\\u`))))return;let o=r(),s=e=>{if(e?.type!==`Identifier`)return null;let{name:t}=e;return typeof t==`string`?t:null},c=e=>{let t=s(e);if(t!==null)return i.has(t);if(e.type!==`MemberExpression`)return!1;let n=e,r=s(n.object);return r!==null&&a.has(r)&&s(n.property)===`useReducer`},l=new Set;if(A(o,e=>{if(e.type!==`CallExpression`)return;let t=e;if(!t.callee||!c(t.callee))return;let n=t.arguments?.[0];if(!n)return;let r=s(O(n));r!==null&&l.add(r)}),l.size!==0)for(let t of n)for(let n of t.entries){if(n.importName.kind===`NamespaceObject`||!l.has(n.localName.value))continue;let r=n.importName.kind===`Default`?`default`:n.importName.name;r&&bn(e,t.moduleRequest.value,r)}},Rs=({absoluteFilePath:e,staticImports:t,getProgram:n})=>{At(e),wn({absoluteFilePath:e,staticImports:t,program:n()})},U=({absoluteFilePath:e})=>{At(e)},zs=e=>{U(e),Ps(e,1/0,e=>v(e.exportedNode),e=>!e.split(/[\\/]/).includes(`node_modules`))},Bs=({absoluteFilePath:e})=>{mr(e)},Vs=({absoluteFilePath:e})=>{br(e)},Hs=e=>{Vs(e),wn({absoluteFilePath:e.absoluteFilePath,staticImports:e.staticImports,program:e.getProgram()})},Us=new Map([...g.map(e=>[e,Vs]),[`ink-no-raw-text`,Hs],[`client-passive-event-listeners`,js],[`exhaustive-deps`,Fs],[`no-barrel-import`,Os],[`nextjs-async-dynamic-api-not-awaited`,U],[`nextjs-missing-metadata`,ks],[`nextjs-no-use-search-params-without-suspense`,As],[`no-dynamic-import-path`,U],[`no-full-lodash-import`,U],[`no-hydration-branch-on-browser-global`,U],[`no-indeterminate-attribute`,U],[`no-locale-format-in-render`,U],[`no-match-media-in-state-initializer`,U],[`no-create-ref-in-function-component`,Is],[`no-adjust-state-on-prop-change`,js],[`no-derived-state`,js],[`no-derived-state-effect`,js],[`no-event-handler`,js],[`no-effect-with-fresh-deps`,Fs],[`no-initialize-state`,js],[`no-mutating-reducer-state`,Ls],[`no-unguarded-browser-global-at-module-scope`,Ms],[`no-unguarded-browser-global-in-render-or-hook-init`,zs],[`prefer-dynamic-import`,U],[`rendering-hydration-mismatch-time`,U],[`rerender-memo-with-default-value`,Fs],[`rn-no-legacy-shadow-styles`,Bs],[`rn-no-raw-text`,Rs],[`rn-prefer-expo-image`,U],[`rn-style-prefer-boxshadow`,Bs],...re.map(e=>[e,U])]),Ws=new Set([`nextjs-no-img-element`,`no-loading-flag-reset-outside-finally`,`only-export-components`,`remotion-calculate-metadata-fetch-signal`,`remotion-deterministic-randomness`,`remotion-no-css-animation`,`remotion-no-css-transition`,`remotion-no-css-url-assets`,`remotion-no-native-media-elements`,`remotion-no-next-image`,`window-open-without-noopener`]),Gs=t=>{let n=new Set;for(let e of t.ruleIds){let t=Us.get(e);if(!t)return null;n.add(t)}let r=Oi(t.absoluteFilePath),i,a;try{let n=e(r,t.sourceText,{astType:`ts`,lang:Lt(r)});if(n.errors.some(e=>e.severity===`Error`))return null;i=n.module.staticImports;let o;a=()=>(o??=n.program,o)}catch{return null}let o={absoluteFilePath:r,sourceText:t.sourceText,staticImports:i,getProgram:a};return mt(()=>{for(let e of n)e(o)})},Ks={},qs=(e,t,n)=>!e||e.length===0?!1:e.every(e=>y(e,t)&&e[n]===`type`),Js=e=>e.importKind===`type`||qs(e.specifiers,`ImportSpecifier`,`importKind`),Ys=new Set([`solid-js`,`solid-js/web`,`solid-js/store`,`solid-js/h`,`solid-js/html`,`@builder.io/qwik`,`@builder.io/qwik-city`,`@builder.io/qwik-react`,`voby`,`vidode`]),Xs=[`solid-js`,`@builder.io/qwik`],Zs=[`react`,`react-dom`,`preact`],Qs=new WeakMap,$s=new WeakMap,ec=(e,t)=>t.some(t=>e===t||e.startsWith(`${t}/`)),tc=e=>{let t=Qs.get(e);if(t)return t;let n=!1,r=!1;for(let t of e.body){if(!y(t,`ImportDeclaration`))continue;let e=t;if(Js(e))continue;let i=e.source,a=i&&typeof i.value==`string`?i.value:null;a&&((Ys.has(a)||ec(a,Xs))&&(n=!0),ec(a,Zs)&&(r=!0))}let i={hasNonReactRuntime:n,hasReactRuntime:r};return Qs.set(e,i),i},nc=e=>{let t=tc(e);return t.hasNonReactRuntime&&!t.hasReactRuntime},rc=e=>{let t=$s.get(e);if(t!==void 0)return t;let n=!1;for(let t of e.attributes){if(!y(t,`JSXAttribute`)||!y(t.name,`JSXIdentifier`))continue;let e=t.name.name;if(e===`classList`||e.startsWith(`class:`)||e.startsWith(`bind:`)){n=!0;break}}return $s.set(e,n),n},ic=`/test/,/tests/,/testing/,/__tests__/,/__test__/,/__fixtures__/,/fixtures/,/__mocks__/,/mocks/,/testUtils/,/test-utils/,/testutils/,/cypress/,/playwright/,/.storybook/,/.dumi/,/stories/,/__stories__/,/playground/,/playgrounds/,/examples/,/example/,/demo/,/demos/,/sandbox/,/sandboxes/,/e2e/,/e2e-tests/,/specs/,/spec/,/integration-tests/,/integration/,/it/,/benchmarks/,/benchmark/,/__benchmarks__/,/perf/,/perf-tests/,/scripts/,/cli/,/bin/,/tooling/,/tools/,/codemods/,/codemod/,/migrations/,/migration/,/generators/,/generator/,/runbooks/,/devtools/,/internal-tools/,/seeds/,/seed/,/dev-seeder/`.split(`,`),ac=[`.test.`,`.spec.`,`.cy.`,`.stories.`,`.story.`,`.bench.`,`.benchmark.`,`.e2e.`,`.integration-spec.`,`.int-spec.`,`.mock.`,`.mocks.`,`.fixture.`],oc=new Set(`setuptests.js,setuptests.ts,setuptests.jsx,setuptests.tsx,setupvitest.js,setupvitest.ts,setupvitest.jsx,setupvitest.tsx,setupjest.js,setupjest.ts,vitest.setup.js,vitest.setup.ts,vitest.setup.mjs,vitest.config.ts,vitest.config.js,vitest.config.mts,vitest.config.mjs,jest.setup.js,jest.setup.ts,jest.setup.jsx,jest.setup.tsx,jest.config.js,jest.config.ts,jest.config.mjs,playwright.config.ts,playwright.config.js,cypress.config.ts,cypress.config.js,karma.conf.js,karma.conf.ts,vite.config.ts,vite.config.js,vite.config.mts,vite.config.mjs,webpack.config.ts,webpack.config.js,webpack.config.mjs,rollup.config.ts,rollup.config.js,rollup.config.mjs,esbuild.config.ts,esbuild.config.js,esbuild.config.mjs,tsup.config.ts,tsup.config.js,tsup.config.mjs,rsbuild.config.ts,rsbuild.config.js,rspack.config.ts,rspack.config.js,next.config.ts,next.config.js,next.config.mjs,remix.config.js,remix.config.ts,astro.config.ts,astro.config.js,astro.config.mjs,tailwind.config.ts,tailwind.config.js,tailwind.config.mjs,postcss.config.ts,postcss.config.js,postcss.config.mjs,biome.config.ts,biome.config.js,drizzle.config.ts,drizzle.config.js,prisma.config.ts,prisma.config.js,knip.config.ts,knip.config.js,knip.config.mjs,lint-staged.config.js,lint-staged.config.mjs`.split(`,`)),sc=[`/src/`,`/app/`,`/lib/`,`/components/`,`/pages/`,`/features/`,`/modules/`,`/packages/`,`/apps/`,`/frontend/`,`/client/`],cc=ic.filter(e=>e.startsWith(`/.`)),lc=e=>{let t=-1;for(let n of sc){let r=e.lastIndexOf(n);r>t&&(t=r)}return t<0?e:e.slice(t)};let uc,dc=!1;const fc=e=>e?e===uc?dc:(uc=e,dc=mc(e),dc):!1,pc=(e,t)=>e?mc(e,t):!1,mc=(e,t=new Set)=>{let n=e.replaceAll(`\\`,`/`),r=n.lastIndexOf(`/`),i=r===-1?n:n.slice(r+1);if(oc.has(i.toLowerCase()))return!0;for(let e of ac)if(i.includes(e))return!0;let a=n.startsWith(`/`)?n:`/${n}`;for(let e of cc)if(!t.has(e)&&a.includes(e))return!0;let o=lc(n);for(let e of ic)if(!t.has(e)&&(e.startsWith(`/.`)?n:o).includes(e))return!0;return!1},hc=e=>t=>fc(t.filename)?Ks:e(t),gc=e=>(t=>{let n=e(t),r=!1,i=!1,a={};for(let e in n){if(!Object.hasOwn(n,e))continue;let t=n[e];if(typeof t!=`function`){a[e]=t;continue}let o=e.charAt(0);if(o<`A`||o>`Z`){a[e]=t;continue}if(e===`Program`){a.Program=e=>{let n=tc(e);i=n.hasReactRuntime,r=n.hasNonReactRuntime&&!n.hasReactRuntime,t(e)};continue}if(e===`JSXOpeningElement`){a.JSXOpeningElement=e=>{!i&&!r&&rc(e)&&(r=!0),!r&&t(e)};continue}a[e]=(...e)=>{r||t(...e)}}return`Program`in a||(a.Program=e=>{let t=tc(e);i=t.hasReactRuntime,r=t.hasNonReactRuntime&&!t.hasReactRuntime}),a}),W=e=>{if(!(`create`in e))return{...e,create:()=>Ks};let t=e.tags,n=e.create,r=t?.includes(`test-noise`)&&!t?.includes(`migration-hint`);return t?.includes(`react-jsx-only`)&&(n=gc(n)),r&&(n=hc(n)),n===e.create?e:{...e,create:n}};let _c;const vc=e=>{let t=[0];for(let n=0;n<e.length;n+=1){let r=e[n];if(r===`\r`&&e[n+1]===`
|
|
1
|
+
import{parseSync as e,visitorKeys as t}from"oxc-parser";import{KEYS as n}from"eslint-visitor-keys";import*as r from"node:fs";import*as i from"node:path";const a=[[`nextjs`,`Next.js`,`NEXT_PUBLIC_*`],[`vite`,`Vite`,`VITE_*`],[`tanstack-start`,`TanStack Start`,`VITE_*`],[`cra`,`Create React App`,`REACT_APP_*`],[`gatsby`,`Gatsby`,`GATSBY_*`]],o=e=>{for(let[t,n,r]of a)if(e(t))return`Move secrets to server-only code. In ${n}, only \`${r}\` env vars are exposed to the browser, and they must not contain secrets`},s=e=>e(`nextjs:static-export`)?`Avoid redirects inside useEffect — they flash the wrong page first. Use an event handler (e.g. onClick), or call redirect() from next/navigation during render (it prerenders a client-side redirect under output: "export"). Middleware and getServerSideProps redirects aren't available in a static export.`:void 0,c=[{key:`react-hooks-js/set-state-in-render`,source:`react-compiler`,severity:`error`},{key:`react-hooks-js/immutability`,source:`react-compiler`,severity:`error`},{key:`react-hooks-js/refs`,source:`react-compiler`,severity:`error`},{key:`react-hooks-js/purity`,source:`react-compiler`,severity:`error`},{key:`react-hooks-js/hooks`,source:`react-compiler`,severity:`error`},{key:`react-hooks-js/set-state-in-effect`,source:`react-compiler`,severity:`warn`},{key:`react-hooks-js/globals`,source:`react-compiler`,severity:`error`},{key:`react-hooks-js/error-boundaries`,source:`react-compiler`,severity:`error`},{key:`react-hooks-js/preserve-manual-memoization`,source:`react-compiler`,severity:`error`},{key:`react-hooks-js/unsupported-syntax`,source:`react-compiler`,severity:`error`},{key:`react-hooks-js/component-hook-factories`,source:`react-compiler`,severity:`error`},{key:`react-hooks-js/static-components`,source:`react-compiler`,severity:`error`},{key:`react-hooks-js/use-memo`,source:`react-compiler`,severity:`error`},{key:`react-hooks-js/void-use-memo`,source:`react-compiler`,severity:`error`},{key:`react-hooks-js/incompatible-library`,source:`react-compiler`,severity:`error`},{key:`react-hooks-js/todo`,source:`react-compiler`,severity:`error`}],l=Object.fromEntries(c.map(e=>[e.key,e.severity])),u=new Set(`width.height.min-width.max-width.min-height.max-height.top.right.bottom.left.padding.padding-top.padding-right.padding-bottom.padding-left.margin.margin-top.margin-right.margin-bottom.margin-left.border-width.border-top-width.border-right-width.border-bottom-width.border-left-width.line-height.column-width`.split(`.`)),d=new Set([`width`,`height`,`top`,`left`,`right`,`bottom`,`padding`,`paddingTop`,`paddingRight`,`paddingBottom`,`paddingLeft`,`margin`,`marginTop`,`marginRight`,`marginBottom`,`marginLeft`,`borderWidth`,`fontSize`,`lineHeight`,`gap`]),f=new Set([`animate`,`initial`,`exit`,`whileHover`,`whileTap`,`whileFocus`,`whileDrag`,`whileInView`]),p=/blur\((\d+(?:\.\d+)?)px\)/,m=new Set([`requestAnimationFrame`,`setInterval`]),h=new Set([`framer-motion`,`motion`]),ee=new Set([`bounce`,`elastic`,`wobble`,`jiggle`,`spring`]),te={base:`3.0.0`,textLayoutGuard:`3.0.1`,aria:`6.2.0`,cursor:`6.7.0`,concurrent:`6.7.0`,renderToString:`6.8.0`,modernHooks:`7.0.0`,suspendTerminal:`7.1.0`},g=[`ink-ctrl-c-handler-requires-exit-option`,`ink-newline-inside-text`,`ink-no-bare-process-exit`,`ink-no-direct-raw-mode`,`ink-no-dom-host-elements`,`ink-no-dom-router`,`ink-no-focus-in-render`,`ink-no-layout-inside-text`,`ink-no-live-hooks-in-render-to-string`,`ink-no-measure-element-in-render`,`ink-no-multiple-static`,`ink-no-raw-text`,`ink-no-repeated-render`,`ink-prefer-use-animation`,`ink-prefer-use-paste`,`ink-static-is-append-only`,`ink-static-requires-key`,`ink-suspense-requires-concurrent`,`ink-use-reactive-window-size`,`ink-use-string-width-for-cursor`,`ink-use-suspend-terminal`,`ink-valid-aria-semantics`],ne=[`@react-router/dev`,`react-router-dom`,`react-router`],re=`react-router-csp-nonce-consistency.react-router-descendant-routes-require-splat.react-router-guard-aborted-handle-error.react-router-internal-route-anchor.react-router-loader-fetch-forwards-signal.react-router-loader-parallel-fetch.react-router-nested-route-requires-outlet.react-router-no-catch-middleware-next.react-router-no-client-module-in-server-render.react-router-no-duplicate-route-id.react-router-no-empty-leaf-route.react-router-no-invalid-absolute-child-path.react-router-no-invalid-lazy-route-properties.react-router-no-invalid-splat-path.react-router-no-loader-request-body.react-router-no-middleware-response-body-consumption.react-router-no-multiple-blockers.react-router-no-multiple-middleware-next.react-router-no-multiple-set-search-params-in-tick.react-router-no-navigate-in-render.react-router-no-nested-router.react-router-no-redirect-in-try-catch.react-router-no-route-module-environment-suffix.react-router-no-router-in-render.react-router-no-session-mutation-in-loader.react-router-no-static-cookie-expires.react-router-no-unsynchronized-search-params-mutation.react-router-no-use-loader-data-in-error-ui.react-router-prefer-route-lazy.react-router-require-root-error-boundary.react-router-resource-link-requires-reload.react-router-return-navigation-promise-in-transition.react-router-server-middleware-return-response.react-router-session-mutation-requires-commit.react-router-v8-no-meta-data-field.react-router-v8-no-react-router-dom-import.react-router-v8-no-removed-future-flags.react-router-valid-route-object`.split(`.`),ie=new Set([`@react-router/cloudflare`,`@react-router/node`,`react-router/dom`,`react-router-dom`,`react-router`]),ae=new Set([`flash`,`set`,`unset`]),oe=new Set([`createCookieSessionStorage`,`createFileSessionStorage`,`createMemorySessionStorage`,`createSessionStorage`,`createWorkersKVSessionStorage`]),se=new Set([`createBrowserRouter`,`createHashRouter`,`createMemoryRouter`]),ce=new Set([`append`,`delete`,`set`,`sort`]),le=new Set([`caseSensitive`,`children`,`id`,`index`,`lazy`,`path`]),ue=new Set([`arrayBuffer`,`blob`,`bytes`,`formData`,`json`,`text`]),de=new Set([`unstable_previewServerPrerendering`,`v8_middleware`,`v8_passThroughRequests`,`v8_splitRouteModules`,`v8_trailingSlashAwareDataRequests`,`v8_viteEnvironmentApi`]),fe=new Set([`BrowserRouter`,`HashRouter`,`MemoryRouter`,`Router`,`RouterProvider`]),pe=new Set([...g,`client-passive-event-listeners`,`exhaustive-deps`,`no-barrel-import`,`nextjs-async-dynamic-api-not-awaited`,`nextjs-missing-metadata`,`nextjs-no-img-element`,`nextjs-no-use-search-params-without-suspense`,`no-dynamic-import-path`,`no-full-lodash-import`,`no-hydration-branch-on-browser-global`,`no-indeterminate-attribute`,`no-loading-flag-reset-outside-finally`,`no-locale-format-in-render`,`no-match-media-in-state-initializer`,`no-create-ref-in-function-component`,`no-adjust-state-on-prop-change`,`no-derived-state`,`no-derived-state-effect`,`no-event-handler`,`no-initialize-state`,`no-mutating-reducer-state`,`only-export-components`,`no-unguarded-browser-global-at-module-scope`,`no-unguarded-browser-global-in-render-or-hook-init`,`window-open-without-noopener`,`prefer-dynamic-import`,`rendering-hydration-mismatch-time`,`remotion-calculate-metadata-fetch-signal`,`remotion-deterministic-randomness`,`remotion-no-css-animation`,`remotion-no-css-transition`,`remotion-no-css-url-assets`,`remotion-no-native-media-elements`,`remotion-no-next-image`,`rerender-memo-with-default-value`,`rn-no-legacy-shadow-styles`,`rn-no-raw-text`,`rn-prefer-expo-image`,`rn-style-prefer-boxshadow`,...re]),me=new Set([`implements`,`returnType`,`superTypeArguments`,`superTypeParameters`,`typeAnnotation`,`typeArguments`,`typeParameters`]),_=e=>typeof e==`object`&&!!e&&typeof e.type==`string`,v=e=>e!=null&&(e.type===`ArrowFunctionExpression`||e.type===`FunctionExpression`||e.type===`FunctionDeclaration`),y=(e,t)=>typeof e==`object`&&!!e&&e.type===t,he={...t,...n,ArrayPattern:[`decorators`,...n.ArrayPattern],AssignmentPattern:[`decorators`,...n.AssignmentPattern],ClassDeclaration:[`decorators`,...n.ClassDeclaration],ClassExpression:[`decorators`,...n.ClassExpression],Identifier:[`decorators`,...n.Identifier],MethodDefinition:[`decorators`,...n.MethodDefinition],ObjectPattern:[`decorators`,...n.ObjectPattern],PropertyDefinition:[`decorators`,...n.PropertyDefinition],RestElement:[`decorators`,...n.RestElement]},ge=e=>e===`var`||e===`function`,_e=e=>{let t=e;for(;t;){if(t.kind===`module`||t.kind===`function`||t.kind===`arrow-function`||t.kind===`method`)return t;t=t.parent}return e},ve=(e,t,n,r)=>{let i={id:r.nextScopeId++,kind:e,node:t,parent:n,children:[],symbols:[],references:[],symbolsByName:new Map};return n&&n.children.push(i),i},b=(e,t,n)=>{let r=ve(e,t,n.currentScope,n);return n.scopeStack.push(r),n.currentScope=r,n.ownScopeForNode.set(t,r),r},x=e=>{e.scopeStack.pop();let t=e.scopeStack[e.scopeStack.length-1];if(!t)throw Error(`scope stack underflow`);e.currentScope=t},S=(e,t,n)=>{let r={id:t.nextSymbolId++,name:n.name,kind:n.kind,bindingIdentifier:n.bindingIdentifier,declarationNode:n.declarationNode,scope:e,initializer:n.initializer,references:[]};return e.symbols.push(r),e.symbolsByName.set(n.name,r),t.symbolByBindingIdentifier.set(n.bindingIdentifier,r),r},ye=e=>{let t=[],n=e=>{if(y(e,`Identifier`)){t.push(e);return}if(y(e,`ObjectPattern`)){for(let t of e.properties)if(y(t,`Property`)){let e=t.value;n(e)}else y(t,`RestElement`)&&n(t.argument);return}if(y(e,`ArrayPattern`)){for(let t of e.elements)t&&n(t);return}if(y(e,`RestElement`)){n(e.argument);return}y(e,`AssignmentPattern`)&&n(e.left)};return n(e),t},C=(e,t,n,r,i,a)=>{if(y(e,`Identifier`)){S(n,r,{name:e.name,kind:i,bindingIdentifier:e,declarationNode:a,initializer:t});return}if(y(e,`ObjectPattern`)){for(let o of e.properties)if(y(o,`Property`)){let e=o.value;C(e,y(e,`AssignmentPattern`)?e.right:t,n,r,i,a)}else y(o,`RestElement`)&&C(o.argument,t,n,r,i,a);return}if(y(e,`ArrayPattern`)){for(let o of e.elements)o&&C(o,y(o,`AssignmentPattern`)?o.right??null:t,n,r,i,a);return}if(y(e,`AssignmentPattern`)){C(e.left,e.right??null,n,r,i,a);return}y(e,`RestElement`)&&C(e.argument,null,n,r,i,a)},w=(e,t)=>{be.add(t)},be=new WeakSet,xe=(e,t,n)=>{let r={id:e.nextReferenceId++,identifier:t,resolvedSymbol:null,flag:n,scope:e.currentScope};e.currentScope.references.push(r),e.referenceByIdentifier.set(t,r)},Se=e=>e.parent?v(e.parent):!1,Ce=e=>e.parent!==null&&e.parent!==void 0&&e.parent.type===`CatchClause`,we=(e,t)=>{if(!y(e,`VariableDeclaration`))return;let n=e.kind===`var`?`var`:e.kind===`let`?`let`:e.kind===`const`?`const`:`using`,r=ge(n)?_e(t.currentScope):t.currentScope;for(let i of e.declarations){let e=i,a=i.init??null;C(i.id,a,r,t,n,e);for(let e of ye(i.id))w(t,e)}},Te=(e,t)=>{y(e,`FunctionDeclaration`)&&e.id&&(S(_e(t.currentScope),t,{name:e.id.name,kind:`function`,bindingIdentifier:e.id,declarationNode:e,initializer:e}),w(t,e.id))},Ee=(e,t)=>{y(e,`ClassDeclaration`)&&e.id&&(S(t.currentScope,t,{name:e.id.name,kind:`class`,bindingIdentifier:e.id,declarationNode:e,initializer:e}),w(t,e.id))},De=(e,t)=>{if(!y(e,`ImportDeclaration`))return;let n=_e(t.currentScope);for(let r of e.specifiers){let e=r.local;y(e,`Identifier`)&&(S(n,t,{name:e.name,kind:`import`,bindingIdentifier:e,declarationNode:r,initializer:r}),w(t,e))}},Oe=(e,t)=>{if(e.type!==`TSImportEqualsDeclaration`&&e.type!==`TSEnumDeclaration`&&e.type!==`TSTypeAliasDeclaration`&&e.type!==`TSInterfaceDeclaration`&&e.type!==`TSModuleDeclaration`)return;let n=e.id;if(!n||!y(n,`Identifier`))return;let r=e.type===`TSImportEqualsDeclaration`?`ts-import-equals`:e.type===`TSEnumDeclaration`?`ts-enum`:e.type===`TSTypeAliasDeclaration`?`ts-type-alias`:e.type===`TSInterfaceDeclaration`?`ts-interface`:`ts-module`;S(_e(t.currentScope),t,{name:n.name,kind:r,bindingIdentifier:n,declarationNode:e,initializer:null}),w(t,n)},ke=(e,t,n)=>{for(let r of e){C(r,null,t,n,`parameter`,r);for(let e of ye(r))w(n,e)}},Ae=e=>!(!y(e,`BlockStatement`)||Se(e)||Ce(e)||e.parent&&e.parent.type===`TSModuleDeclaration`),je=e=>{let t=e.parent;if(!t)return!1;if(t.type===`JSXMemberExpression`)return t.object===e;if(t.type===`JSXNamespacedName`)return!1;let n=e.name.charCodeAt(0);return!(n>=97&&n<=122)},Me=e=>{let t=e.parent;if(!t)return!1;switch(t.type){case`MemberExpression`:return t.property===e&&!t.computed;case`Property`:return t.key===e&&!t.computed&&!t.shorthand;case`MethodDefinition`:case`PropertyDefinition`:return t.key===e&&!t.computed;case`JSXAttribute`:return t.name===e;case`ImportSpecifier`:return t.imported===e;case`ExportSpecifier`:return t.exported===e&&t.local!==t.exported;case`LabeledStatement`:case`BreakStatement`:case`ContinueStatement`:return t.label===e;default:return!1}},Ne=e=>{let t=e.parent;if(!t)return`read`;switch(t.type){case`AssignmentExpression`:return t.left===e?t.operator===`=`?`write`:`read-write`:`read`;case`UpdateExpression`:return`read-write`;case`ForInStatement`:case`ForOfStatement`:return t.left===e?`write`:`read`;default:return`read`}},T=(e,t)=>{t.nodeScope.set(e,t.currentScope)},Pe=(e,t)=>{if(e.type===`AssignmentPattern`){Pe(e.left,t);let n=e.right??null;n&&E(n,t);return}if(e.type===`ObjectPattern`){for(let n of e.properties){let e=n;if(e.type===`RestElement`){Pe(e.argument,t);continue}if(e.type!==`Property`)continue;let r=e;r.computed&&E(r.key,t),Pe(r.value,t)}return}if(e.type===`ArrayPattern`){for(let n of e.elements)n&&Pe(n,t);return}e.type===`RestElement`&&Pe(e.argument,t)},E=(e,t)=>{if(e.type===`ArrowFunctionExpression`||e.type===`FunctionExpression`||e.type===`FunctionDeclaration`){e.type===`FunctionDeclaration`&&e.id&&Te(e,t);let n=e.params??[];for(let e of n)if(!(!(`decorators`in e)||!Array.isArray(e.decorators)))for(let n of e.decorators)_(n)&&E(n,t);T(e,t);let r=b(e.type===`ArrowFunctionExpression`?`arrow-function`:`function`,e,t);(e.type===`FunctionExpression`||e.type===`FunctionDeclaration`)&&e.id&&(S(r,t,{name:e.id.name,kind:`function`,bindingIdentifier:e.id,declarationNode:e,initializer:e}),w(t,e.id)),ke(n,r,t);for(let e of n)Pe(e,t);let i=e.body;i&&E(i,t),x(t);return}if(e.type===`ClassDeclaration`||e.type===`ClassExpression`){if(e.type===`ClassDeclaration`&&e.id&&Ee(e,t),Array.isArray(e.decorators))for(let n of e.decorators)_(n)&&E(n,t);let n=b(`class`,e,t);T(e,t),e.type===`ClassExpression`&&e.id&&(S(n,t,{name:e.id.name,kind:`class`,bindingIdentifier:e.id,declarationNode:e,initializer:e}),w(t,e.id)),e.superClass&&E(e.superClass,t),e.body&&E(e.body,t),x(t);return}if(e.type===`CatchClause`){let n=b(`catch`,e,t);if(T(e,t),e.param){C(e.param,null,n,t,`catch-clause-parameter`,e);for(let n of ye(e.param))w(t,n)}e.body&&E(e.body,t),x(t);return}if(e.type===`ForStatement`||e.type===`ForInStatement`||e.type===`ForOfStatement`){b(`for`,e,t),T(e,t);let n=e,r=he[e.type]??Object.keys(n);for(let e of r){if(e===`parent`||me.has(e))continue;let r=n[e];if(Array.isArray(r))for(let e of r)_(e)&&E(e,t);else _(r)&&E(r,t)}x(t);return}if(e.type===`SwitchStatement`){b(`switch`,e,t),T(e,t),e.discriminant&&E(e.discriminant,t);for(let n of e.cases)E(n,t);x(t);return}if(e.type===`TSModuleDeclaration`){let n=b(`ts-module`,e,t);if(T(e,t),e.id&&y(e.id,`Identifier`)){let r=e.id;S(_e(n.parent??t.currentScope),t,{name:r.name,kind:`ts-module`,bindingIdentifier:r,declarationNode:e,initializer:null}),w(t,r)}e.body&&E(e.body,t),x(t);return}if(e.type===`TSEnumDeclaration`){Oe(e,t),b(`ts-enum`,e,t),T(e,t);let n=e.members??[];for(let e of n)E(e,t);x(t);return}if(e.type===`BlockStatement`&&Ae(e)){b(`block`,e,t),T(e,t);for(let n of e.body)E(n,t);x(t);return}switch(T(e,t),e.type){case`VariableDeclaration`:we(e,t);break;case`ImportDeclaration`:De(e,t);break;case`TSImportEqualsDeclaration`:case`TSTypeAliasDeclaration`:case`TSInterfaceDeclaration`:Oe(e,t);break}(e.type===`Identifier`||e.type===`JSXIdentifier`)&&!be.has(e)&&!Me(e)&&(e.type===`JSXIdentifier`?je(e)&&xe(t,e,Ne(e)):xe(t,e,Ne(e)));let n=e,r=he[e.type]??Object.keys(n);for(let e of r){if(e===`parent`||me.has(e))continue;let r=n[e];if(Array.isArray(r))for(let e of r)_(e)&&E(e,t);else _(r)&&E(r,t)}},Fe=e=>{let t=e=>{for(let t of e.references){let n=t.identifier.name;if(typeof n!=`string`)continue;let r=e;for(;r;){let e=r.symbolsByName.get(n);if(e){t.resolvedSymbol=e,e.references.push(t);break}r=r.parent}}for(let n of e.children)t(n)};t(e)},Ie=e=>{let t={id:0,kind:`module`,node:e,parent:null,children:[],symbols:[],references:[],symbolsByName:new Map},n={nextScopeId:1,nextSymbolId:0,nextReferenceId:0,currentScope:t,scopeStack:[t],rootScope:t,nodeScope:new WeakMap,ownScopeForNode:new WeakMap,symbolByBindingIdentifier:new WeakMap,referenceByIdentifier:new WeakMap};if(n.nodeScope.set(e,t),n.ownScopeForNode.set(e,t),e.type===`Program`)for(let t of e.body)E(t,n);else E(e,n);return Fe(t),{rootScope:t,scopeFor:e=>{let r=e;for(;r;){let e=n.nodeScope.get(r);if(e)return e;r=r.parent??null}return t},ownScopeFor:e=>n.ownScopeForNode.get(e)??null,symbolFor:e=>{let t=n.referenceByIdentifier.get(e);return t?t.resolvedSymbol:n.symbolByBindingIdentifier.get(e)||null},referenceFor:e=>n.referenceByIdentifier.get(e)??null,isGlobalReference:e=>{let t=n.referenceByIdentifier.get(e);return t?t.resolvedSymbol===null:!1}}},Le=(e,t)=>{let n=e;for(;n;){if(n===t)return!0;n=n.parent}return!1},Re=`(?:tsx?|jsx?|mts|mjs)`,ze=RegExp(`/page\\.${Re}$`),Be=RegExp(`/(page|layout)\\.${Re}$`),Ve=[`layout.tsx`,`layout.jsx`,`layout.ts`,`layout.js`,`layout.mts`,`layout.mjs`],He=[`metadata`,`generateMetadata`],Ue=/\/(?:(?:\((?:dashboard|admin|settings|account|internal|manage|console|portal|auth|onboarding|app|ee|protected)\))|(?:dashboard|admin|settings|account|internal|manage|console|portal))\//i,We=new Set([`redirect`,`permanentRedirect`,`notFound`,`forbidden`,`unauthorized`]),Ge=new Set([`revalidateTag`,`revalidatePath`,`expireTag`,`expirePath`,`unstable_expireTag`,`unstable_expirePath`]),Ke=/fonts\.googleapis\.com/,qe=/polyfill\.io|polyfill\.min\.js|cdn\.polyfill/,Je=RegExp(`/route\\.${Re}$`),Ye=/\/(?:cron|jobs\/cron)(?:\/|$)/i,Xe=new Set([`logout`,`log-out`,`signout`,`sign-out`,`unsubscribe`,`delete`,`remove`,`revoke`,`cancel`,`deactivate`]),Ze=RegExp(`/(error|global-error)\\.${Re}$`),Qe=RegExp(`/global-error\\.${Re}$`),$e=new Set([`GET`,`POST`,`PUT`,`PATCH`,`DELETE`,`OPTIONS`,`HEAD`]),et=/google-analytics\.com|googletagmanager\.com\/gtag/,tt=RegExp(`/(opengraph-image|twitter-image)\\d*\\.${Re}$`),nt=1024,rt=1e3,it=1e3,at=new Set([`expo`,`expo-router`,`@expo/cli`,`@expo/metro-config`,`@expo/metro-runtime`]),ot=new Set([`react-native`,`react-native-tvos`,...at,`react-native-windows`,`react-native-macos`]),st=[`@react-native/`,`@react-native-`],ct=e=>at.has(e),lt=e=>{if(ot.has(e))return!0;for(let t of st)if(e.startsWith(t))return!0;return!1};let ut=null;const dt=e=>{ut?.existencePaths.add(e)},D=e=>{ut?.contentPaths.add(e)},ft=()=>ut!==null,pt=e=>{let t=ut,n={existencePaths:new Set,contentPaths:new Set};ut=n;try{return{value:e(),trace:n}}finally{if(ut=t,t!==null){for(let e of n.existencePaths)t.existencePaths.add(e);for(let e of n.contentPaths)t.contentPaths.add(e)}}},mt=e=>pt(e).trace,ht=new Map,gt=new Map,_t=()=>{ht.clear(),gt.clear()},vt=e=>{if(!e)return null;let t=ht.get(e);if(t!==void 0){if(ft()){let n=i.dirname(e);for(;dt(i.join(n,`package.json`)),n!==t;){let e=i.dirname(n);if(e===n)break;n=e}}return t}let n=i.dirname(e);for(;;){let t=i.join(n,`package.json`);dt(t);let a=!1;try{a=r.statSync(t).isFile()}catch{a=!1}if(a)return ht.set(e,n),n;let o=i.dirname(n);if(o===n)return ht.set(e,null),null;n=o}},yt=e=>{let t=vt(e);return t?bt(t):null},bt=e=>{let t=i.join(e,`package.json`);D(t);let n=gt.get(e);if(n!==void 0)return n;let a=null;try{let e=JSON.parse(r.readFileSync(t,`utf-8`));typeof e==`object`&&e&&(a=e)}catch{a=null}return gt.set(e,a),a},xt=new Set([`next`,`vite`,`react-scripts`,`gatsby`,`@remix-run/react`,`@remix-run/node`,`@docusaurus/core`,`@docusaurus/preset-classic`,`@storybook/react`,`@storybook/react-vite`,`@storybook/react-webpack5`,`@storybook/nextjs`,`@storybook/web-components`,`storybook`,`react-dom`,`@vitejs/plugin-react`,`@vitejs/plugin-react-swc`]),St=[`dependencies`,`devDependencies`,`peerDependencies`,`optionalDependencies`],Ct=function*(e){for(let t of St){let n=e[t];if(n)for(let e of Object.keys(n))yield e}},wt=e=>{if(typeof e[`react-native`]==`string`)return!0;for(let t of Ct(e))if(lt(t))return!0;return!1},Tt=e=>{for(let t of Ct(e))if(ct(t))return!0;return!1},Et=e=>{for(let t of Ct(e))if(xt.has(t))return!0;return!1},Dt=e=>St.some(t=>{let n=e[t];return typeof n==`object`&&!!n&&Object.keys(n).length>0}),Ot=(e,t)=>St.some(n=>{let r=e[n];return typeof r==`object`&&!!r&&Object.prototype.propertyIsEnumerable.call(r,t)}),kt=new WeakMap,At=e=>{let t=yt(e);if(!t)return`unknown`;let n=kt.get(t);if(n!==void 0)return n;let r;return r=Tt(t)?`expo`:wt(t)?`react-native`:Et(t)?`web`:Dt(t)?`neutral`:`unknown`,kt.set(t,r),r},jt=new Set([`ParenthesizedExpression`,`TSAsExpression`,`TSSatisfiesExpression`,`TSTypeAssertion`,`TSNonNullExpression`,`TSInstantiationExpression`,`ChainExpression`]),O=e=>{let t=e;for(;;)switch(t.type){case`ParenthesizedExpression`:case`TSAsExpression`:case`TSSatisfiesExpression`:case`TSTypeAssertion`:case`TSNonNullExpression`:case`TSInstantiationExpression`:case`ChainExpression`:if(!(`expression`in t)||!t.expression)return t;t=t.expression;break;default:return t}},Mt=(e,t)=>{if(!y(e,`Program`))return null;let n=new Map,r=new Map,i=null,a=null,o=e=>{for(let t of e.declarations??[])y(t,`VariableDeclarator`)&&(!y(t.id,`Identifier`)||!t.init||n.set(t.id.name,O(t.init)))};for(let t of e.body??[]){if(y(t,`VariableDeclaration`)){o(t);continue}if(y(t,`FunctionDeclaration`)&&t.id){n.set(t.id.name,t);continue}if(y(t,`ExportNamedDeclaration`)){if(t.exportKind===`type`)continue;let e=t.declaration;if(e&&y(e,`VariableDeclaration`)){o(e);for(let t of e.declarations??[])y(t,`VariableDeclarator`)&&y(t.id,`Identifier`)&&r.set(t.id.name,t.id.name)}else e&&y(e,`FunctionDeclaration`)&&e.id&&(n.set(e.id.name,e),r.set(e.id.name,e.id.name));if(t.source)continue;for(let e of t.specifiers??[]){if(!y(e,`ExportSpecifier`)||e.exportKind===`type`)continue;let t=y(e.local,`Identifier`)?e.local.name:null,n=null;y(e.exported,`Identifier`)?n=e.exported.name:y(e.exported,`Literal`)&&typeof e.exported.value==`string`&&(n=e.exported.value),t&&n&&r.set(n,t)}continue}if(!y(t,`ExportDefaultDeclaration`))continue;let e=t.declaration;e&&(y(e,`Identifier`)?a=e.name:((y(e,`FunctionDeclaration`)||y(e,`ClassDeclaration`))&&e.id&&n.set(e.id.name,e),i=O(e)))}if(t===`default`){if(i)return i;if(a){let e=n.get(a);if(e)return e}}let s=r.get(t);return s?n.get(s)??null:null},Nt=e=>{if(y(e,`ImportSpecifier`)){let t=e.imported;return y(t,`Identifier`)?t.name:y(t,`Literal`)&&typeof t.value==`string`?t.value:null}return y(e,`ImportDefaultSpecifier`)?`default`:null},Pt=(e,t)=>{if(!y(e,`Program`))return[];let n=[];for(let r of e.body??[]){if(y(r,`ExportNamedDeclaration`)&&r.source){if(r.exportKind===`type`)continue;let e=r.source.value;if(typeof e!=`string`)continue;for(let n of r.specifiers??[]){if(!y(n,`ExportSpecifier`)||n.exportKind===`type`)continue;let r=n.exported;if((y(r,`Identifier`)?r.name:y(r,`Literal`)&&typeof r.value==`string`?r.value:null)!==t)continue;let i=n.local,a=y(i,`Identifier`)?i.name:y(i,`Literal`)&&typeof i.value==`string`?i.value:null;if(a)return[{importedName:a,source:e}]}}if(y(r,`ExportAllDeclaration`)&&r.source){if(r.exportKind===`type`||r.exported)continue;let e=r.source.value;typeof e==`string`&&n.push({importedName:t,source:e})}}return n},Ft=e=>{let t=(e,n)=>{let r=e;r.parent=n,r.range==null&&typeof r.start==`number`&&typeof r.end==`number`&&(r.range=[r.start,r.end]);let i=e;for(let n of Object.keys(i)){if(n===`parent`)continue;let r=i[n];if(Array.isArray(r))for(let n of r)_(n)&&t(n,e);else _(r)&&t(r,e)}};t(e,null)},It={".ts":`ts`,".tsx":`tsx`,".js":`js`,".jsx":`jsx`,".mjs":`js`,".cjs":`js`,".mts":`ts`,".cts":`ts`},Lt=e=>It[i.extname(e).toLowerCase()]??`tsx`,Rt=({filename:t,sourceText:n,shouldAttachParentReferences:r=!0})=>{try{let i=e(t,n,{astType:`ts`,lang:Lt(t)});if(i.errors.some(e=>e.severity===`Error`))return null;let a=i.program;return r&&Ft(a),a}catch{return null}},zt=new Map,Bt=e=>{e.endsWith(`.d.ts`)||e.endsWith(`.d.mts`)||e.endsWith(`.d.cts`)||D(e);let t;try{t=r.statSync(e)}catch{return null}if(!t.isFile()||t.size>2e6)return null;let n=zt.get(e);if(n&&n.mtimeMs===t.mtimeMs&&n.size===t.size)return n.program;if(e.endsWith(`.d.ts`)||e.endsWith(`.d.mts`)||e.endsWith(`.d.cts`))return zt.set(e,{mtimeMs:t.mtimeMs,size:t.size,program:null}),null;let i;try{i=r.readFileSync(e,`utf8`)}catch{return zt.set(e,{mtimeMs:t.mtimeMs,size:t.size,program:null}),null}let a=Rt({filename:e,sourceText:i});return zt.set(e,{mtimeMs:t.mtimeMs,size:t.size,program:a}),a},Vt=[`.ts`,`.tsx`,`.js`,`.jsx`,`.mjs`,`.cjs`,`.mts`,`.cts`],Ht=[`import`,`default`,`module`,`browser`,`require`],Ut=[`module`,`main`,`browser`],Wt=e=>{dt(e);try{return r.statSync(e).isFile()?e:null}catch{return null}},Gt=e=>{dt(e);try{return r.statSync(e).isDirectory()?e:null}catch{return null}},Kt=e=>{let t=i.extname(e);if(!t)return Vt.map(t=>`${e}${t}`);let n=e.slice(0,-t.length);return t===`.js`?[e,`${n}.ts`,`${n}.tsx`,`${n}.jsx`]:t===`.jsx`?[e,`${n}.tsx`]:t===`.mjs`?[e,`${n}.mts`]:t===`.cjs`?[e,`${n}.cts`]:[e]},qt=e=>typeof e==`object`&&!!e,Jt=e=>{if(typeof e==`string`)return e;if(Array.isArray(e)){for(let t of e){let e=Jt(t);if(e)return e}return null}if(!qt(e))return null;for(let t of Ht){let n=Jt(e[t]);if(n)return n}return null},Yt=e=>{let t=e.exports;return t?Jt(t)||(qt(t)?Jt(t[`.`]):null):null},Xt=e=>Qt(e)||Qt(i.join(e,`index`)),Zt=e=>{let t=Gt(e);if(!t)return null;let n=i.join(t,`package.json`);D(n);try{let e=JSON.parse(r.readFileSync(n,`utf8`)),a=Yt(e)??Ut.map(t=>e[t]).find(e=>typeof e==`string`);return a?Xt(i.resolve(t,a)):null}catch{return null}},Qt=e=>{let t=Wt(e);if(t)return t;for(let t of Kt(e)){let e=Wt(t);if(e)return e}return null},$t=e=>Qt(e)||Zt(e)||Qt(i.join(e,`index`)),en=(e,t)=>$t(i.resolve(i.dirname(e),t)),tn=[`tsconfig.json`,`jsconfig.json`],nn=e=>typeof e==`object`&&!!e,rn=e=>{let t=``,n=!1,r=!1,i=!1;for(let a=0;a<e.length;a++){let o=e[a],s=e[a+1];if(r){o===`
|
|
2
|
+
`&&(r=!1,t+=o);continue}if(i){o===`*`&&s===`/`&&(i=!1,a++);continue}if(n){t+=o,o===`\\`?(t+=s??``,a++):o===`"`&&(n=!1);continue}if(o===`"`){n=!0,t+=o;continue}if(o===`/`&&s===`/`){r=!0,a++;continue}if(o===`/`&&s===`*`){i=!0,a++;continue}t+=o}return t.replace(/,(\s*[}\]])/g,`$1`)},an=(e,t)=>{D(e),t.push(e);let n;try{n=r.readFileSync(e,`utf8`)}catch{return null}try{let e=JSON.parse(rn(n));return nn(e)?e:null}catch{return null}},on=(e,t)=>{let n=e.endsWith(`.json`)?e:`${e}.json`;return e.startsWith(`./`)||e.startsWith(`../`)?i.resolve(t,n):i.join(t,`node_modules`,n)},sn=e=>{let t=new Map;if(!nn(e))return t;for(let[n,r]of Object.entries(e)){if(!Array.isArray(r))continue;let e=r.filter(e=>typeof e==`string`);e.length>0&&t.set(n,e)}return t},cn=(e,t,n)=>{let r=an(e,n);if(!r)return null;let a=i.dirname(e),o=nn(r.compilerOptions)?r.compilerOptions:{},s=typeof o.baseUrl==`string`?o.baseUrl:null,c=s!==null,l=s===null?a:i.resolve(a,s);if(nn(o.paths))return{baseAbsolutePath:l,hasExplicitBaseUrl:c,paths:sn(o.paths)};if(typeof r.extends==`string`&&t<8){let e=on(r.extends,a),i=e?cn(e,t+1,n):null;if(i)return i}return c?{baseAbsolutePath:l,hasExplicitBaseUrl:c,paths:new Map}:null},ln=new Map,un=new Map,dn=e=>{D(e);let t;try{t=r.statSync(e)}catch{return{config:null,probedContentPaths:new Set([e])}}let n=ln.get(e);if(n&&n.mtimeMs===t.mtimeMs){for(let e of n.probedChainPaths)D(e);return{config:n.config,probedContentPaths:new Set(n.probedChainPaths)}}let i=[],a=cn(e,0,i);return ln.set(e,{mtimeMs:t.mtimeMs,config:a,probedChainPaths:i}),{config:a,probedContentPaths:new Set(i)}},fn=e=>{let t=ft(),n=t?un.get(e):void 0;if(n!==void 0){for(let e of n.probedContentPaths)D(e);return n.config}let r=new Set,a=e;for(let n=0;n<30;n++){for(let n of tn){let o=dn(i.join(a,n));for(let e of o.probedContentPaths)r.add(e);if(o.config)return t&&un.set(e,{config:o.config,probedContentPaths:r}),o.config}let n=i.dirname(a);if(n===a)break;a=n}return t&&un.set(e,{config:null,probedContentPaths:r}),null},pn=(e,t)=>{let n=t.indexOf(`*`);if(n===-1)return e===t?``:null;let r=t.slice(0,n),i=t.slice(n+1);return e.length>=r.length+i.length&&e.startsWith(r)&&e.endsWith(i)?e.slice(r.length,e.length-i.length):null},mn=(e,t)=>{let n=fn(i.dirname(e));if(!n)return null;let r=null,a=``,o=-1;for(let e of n.paths.keys()){let n=pn(t,e);if(n===null)continue;let i=e.indexOf(`*`),s=i===-1?e.length:i;s>o&&(r=e,a=n,o=s)}if(r)for(let e of n.paths.get(r)??[]){let t=e.replaceAll(`*`,a),r=$t(i.resolve(n.baseAbsolutePath,t));if(r)return r}return n.hasExplicitBaseUrl?$t(i.resolve(n.baseAbsolutePath,t)):null},hn=()=>{ln.clear(),un.clear()},gn=(e,t)=>i.isAbsolute(t)?null:t.startsWith(`.`)?en(e,t):mn(e,t),_n=new Map,vn=()=>{_n.clear()},yn=(e,t,n)=>{if(n.size>=4||n.has(e))return null;n.add(e);let r=Bt(e);if(!r)return null;let i=Mt(r,t);if(i)return{filePath:e,exportedNode:i,programNode:r};let a=new Map;for(let i of Pt(r,t)){let t=gn(e,i.source);if(!t)continue;let r=yn(t,i.importedName,new Set(n));r&&a.set(r.exportedNode,r)}return a.size===1?a.values().next().value??null:null},bn=(e,t,n)=>xn(e,t,n)?.functionNode??null,xn=(e,t,n)=>{let r=k(e,t,n);return!r||!v(r.exportedNode)?null:{filePath:r.filePath,functionNode:r.exportedNode,programNode:r.programNode}},k=(e,t,n)=>{if(!ft()){let r=gn(e,t);return r?yn(r,n,new Set):null}let r=`${e}\0${t}\0${n}`,i=_n.get(r);if(i!==void 0){for(let e of i.trace.contentPaths)D(e);for(let e of i.trace.existencePaths)dt(e);return i.result}let a=pt(()=>{let r=gn(e,t);return r?yn(r,n,new Set):null});return _n.set(r,{result:a.value,trace:a.trace}),a.value},Sn=(e,t)=>{let n=e,r=he[e.type];if(r!==void 0){for(let e=r.length-1;e>=0;--e){let i=n[r[e]];if(Array.isArray(i))for(let e=i.length-1;e>=0;--e){let n=i[e];_(n)&&t.push(n)}else _(i)&&t.push(i)}return}let i=Object.keys(n);for(let e=i.length-1;e>=0;--e){let r=i[e];if(r===`parent`)continue;let a=n[r];if(Array.isArray(a))for(let e=a.length-1;e>=0;--e){let n=a[e];_(n)&&t.push(n)}else _(a)&&t.push(a)}},Cn=(e,t)=>{let n=e,r=he[e.type];if(r!==void 0){for(let e=0;e<r.length;e+=1){let i=n[r[e]];if(Array.isArray(i))for(let e=0;e<i.length;e+=1){let n=i[e];_(n)&&t(n)}else _(i)&&t(i)}return}for(let e in n){if(e===`parent`||!Object.hasOwn(n,e))continue;let r=n[e];if(Array.isArray(r))for(let e=0;e<r.length;e+=1){let n=r[e];_(n)&&t(n)}else _(r)&&t(r)}},A=(e,t)=>{if(!e||typeof e!=`object`)return;let n=[e];for(;n.length>0;){let e=n.pop();e===void 0||t(e)===!1||Sn(e,n)}},wn=({absoluteFilePath:e,staticImports:t,program:n})=>{let r=new Set;if(A(n,e=>{if(e.type!==`JSXOpeningElement`)return;let t=e.name;if(t){if(t.type===`JSXIdentifier`){let e=t.name;typeof e==`string`&&r.add(e)}else if(t.type===`JSXMemberExpression`){let e=t.property;e?.type===`JSXIdentifier`&&typeof e.name==`string`&&r.add(e.name)}else if(t.type===`JSXNamespacedName`){let e=t.namespace;typeof e?.name==`string`&&r.add(e.name)}}}),r.size!==0)for(let n of t)for(let t of n.entries){let{importName:i}=t;if(i.kind===`NamespaceObject`||!r.has(t.localName.value))continue;let a=i.kind===`Default`?`default`:i.name;a&&bn(e,n.moduleRequest.value,a)}},Tn=e=>e.replace(/^type\s+/,``).trim(),En=(e,t)=>e.split(`,`).map(e=>e.trim()).filter(Boolean).map(e=>{let n=t||e.startsWith(`type `),[r,i]=e.split(/\s+as\s+/),a=Tn(r??``);return{localName:a,exportedName:Tn(i??a),isTypeOnly:n}}),Dn=/\/\*[\s\S]*?\*\//g,On=/^\s*\/\/.*$/gm,kn=e=>e.replace(Dn,``).replace(On,``),An=/^\s*export\s+default\b/m,jn=/^\s*export\s+(?:declare\s+)?(?:(?:async\s+)?function|(?:abstract\s+)?class|const|let|var|enum|interface|type)\s+([\w$]+)/gm,Mn=/^\s*export\s+(?:type\s+)?\{([\s\S]*?)\}(?:\s+from\s+["'][^"']+["'])?\s*;?\s*(?:(?:\/\/[^\n]*)?\s*)/gm,Nn=e=>{let t=kn(e),n=new Set;An.test(t)&&n.add(`default`);for(let e of t.matchAll(jn))e[1]&&n.add(e[1]);for(let e of t.matchAll(Mn)){let t=e[1]??``;for(let e of En(t,!1))n.add(e.exportedName)}return n},Pn=new Map,Fn=(e,t)=>{D(e);try{let n=r.statSync(e),i=Pn.get(e);if(i&&i.mtimeMs===n.mtimeMs&&i.size===n.size)return i.exportedNames.has(t);let a=Nn(r.readFileSync(e,`utf8`));return Pn.set(e,{mtimeMs:n.mtimeMs,size:n.size,exportedNames:a}),a.has(t)}catch{return!1}},In=(e,t)=>{let n=e.replaceAll(`\\`,`/`),r=i.dirname(n);for(let e=0;e<30;e++){for(let e of Ve){let a=i.join(r,e);if(a.replaceAll(`\\`,`/`)!==n&&t(a))return!0}let e=i.dirname(r);if(i.basename(r)===`app`&&i.basename(e)!==`app`||e===r)break;r=e}return!1},Ln=e=>In(e,e=>He.some(t=>Fn(e,t))),j=e=>{if(!y(e,`ImportSpecifier`))return;let t=e.imported;if(y(t,`Identifier`))return t.name;if(y(t,`Literal`)&&typeof t.value==`string`)return t.value},Rn=e=>y(e,`JSXIdentifier`)?e.name===`Suspense`:y(e,`JSXMemberExpression`)&&y(e.property,`JSXIdentifier`)&&e.property.name===`Suspense`,zn=e=>{let t=!1;return A(e,e=>{if(t)return!1;if(y(e,`JSXOpeningElement`)&&Rn(e.name)||y(e,`ImportDeclaration`)&&e.source?.value===`react`&&(e.specifiers??[]).some(e=>y(e,`ImportSpecifier`)&&j(e)===`Suspense`))return t=!0,!1}),t},Bn=e=>In(e,e=>{let t=Bt(e);return!!(t&&zn(t))}),Vn=/^index\.(?:[cm]?[jt]sx?|mjs)$/,Hn=/^\s*import\s+(type\s+)?(?!["'])([^;]*?)\s+from\s+["']([^"']+)["']\s*;?\s*(?:(?:\/\/[^\n]*)?\s*)/gm,Un=/^\s*export\s+(type\s+)?(?:\*(?:\s+as\s+([\w$]+))?|\{([\s\S]*?)\})\s+from\s+["']([^"']+)["']\s*;?\s*(?:(?:\/\/[^\n]*)?\s*)/gm,Wn=/^\s*export\s+(type\s+)?\{([\s\S]*?)\}\s*;?\s*(?:(?:\/\/[^\n]*)?\s*)/gm,Gn=new Map,Kn=e=>Vn.test(i.basename(e)),qn=()=>({isBarrel:!1,exportsByName:new Map,starExportSources:[]}),Jn=(e,t)=>{e.set(t.localName,{...t,didExport:!1})},Yn=(e,t,n,r)=>{for(let i of En(e,n))Jn(r,{localName:i.exportedName,importedName:i.localName,source:t,isTypeOnly:i.isTypeOnly})},Xn=(e,t,n,r)=>{let i=e.trim(),a=i.match(/(?:^|,\s*)\*\s+as\s+([\w$]+)/);a?.[1]&&Jn(r,{localName:a[1],importedName:`*`,source:t,isTypeOnly:n});let o=i.match(/\{([\s\S]*?)\}/);o?.[1]&&Yn(o[1],t,n,r);let s=i.split(`,`)[0]?.trim();s&&!s.startsWith(`{`)&&!s.startsWith(`*`)&&Jn(r,{localName:s,importedName:`default`,source:t,isTypeOnly:n})},Zn=(e,t,n,r)=>{let i=e.replace(Hn,(e,n,r,i)=>(Xn(r,i,!!n,t),``));return i=i.replace(Un,(e,t,i,a,o)=>{let s=!!t;if(i)return n.set(i,{exportedName:i,importedName:`*`,source:o,isTypeOnly:s}),``;if(a){for(let e of En(a,s))n.set(e.exportedName,{exportedName:e.exportedName,importedName:e.localName,source:o,isTypeOnly:e.isTypeOnly});return``}return r.push(o),``}),i=i.replace(Wn,(e,r,i)=>{for(let a of En(i,!!r)){let r=t.get(a.localName);if(!r)return e;r.didExport=!0,n.set(a.exportedName,{exportedName:a.exportedName,importedName:r.importedName,source:r.source,isTypeOnly:a.isTypeOnly||r.isTypeOnly})}return``}),i},Qn=e=>{for(let t of e.values())if(!t.isTypeOnly&&!t.didExport)return!0;return!1},$n=e=>{let t=kn(e).trim();if(!t)return qn();let n=new Map,r=new Map,i=[];return Zn(t,n,r,i).trim()||Qn(n)?qn():{isBarrel:r.size>0||i.length>0,exportsByName:r,starExportSources:i}},er=e=>{if(!Kn(e))return qn();D(e);let t;try{t=r.statSync(e)}catch{t=null}let n=Gn.get(e);if(n!==void 0&&t!==null&&n.mtimeMs===t.mtimeMs&&n.size===t.size)return n.moduleInfo;if(t===null)return qn();let i=qn();try{i=$n(r.readFileSync(e,`utf8`))}catch{i=qn()}return Gn.set(e,{mtimeMs:t.mtimeMs,size:t.size,moduleInfo:i}),i},tr=e=>er(e).isBarrel,nr=i.join(`android`,`gradle.properties`),rr=/^\s*newArchEnabled\s*=\s*false\s*$/m,ir=[`app.config.ts`,`app.config.js`,`app.config.cjs`,`app.config.mjs`],ar=[`app.config.json`,`app.json`],or=new WeakMap,sr=e=>{D(i.join(e,nr));for(let t of ir)dt(i.join(e,t));for(let t of ar)D(i.join(e,t))},cr=e=>{try{return r.readFileSync(e,`utf-8`)}catch{return null}},lr=e=>{let t=e.dependencies?.[`react-native`]??e.devDependencies?.[`react-native`];return typeof t==`string`?t:null},ur=e=>{let t=e.match(/(?:^|[^\d.])0\.(\d+)/);return t?Number.parseInt(t[1],10):null},dr=e=>{let t=cr(i.join(e,nr));return t!==null&&rr.test(t)},fr=e=>{for(let t of ir)if(r.existsSync(i.join(e,t)))return!1;for(let t of ar){let n=cr(i.join(e,t));if(n===null)continue;let r;try{r=JSON.parse(n)}catch{continue}if(typeof r!=`object`||!r)continue;let a=Object.getOwnPropertyDescriptor(r,`expo`)?.value;if(!(typeof a!=`object`||!a)&&Object.getOwnPropertyDescriptor(a,`newArchEnabled`)?.value===!1)return!0}return!1},pr=(e,t)=>{let n=lr(t);if(n!==null){let e=ur(n);if(e!==null&&e<76)return!0}return dr(e)||fr(e)},mr=e=>{let t=vt(e);if(!t)return!1;let n=yt(e);if(!n)return!1;sr(t);let r=or.get(n);if(r!==void 0)return r;let i=pr(t,n);return or.set(n,i),i},hr=e=>{let t=e.match(/^(\d+)(?:\.(\d+))?(?:\.(\d+))?(-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/);return t?{major:Number(t[1]),minor:Number(t[2]??0),patch:Number(t[3]??0),isPrerelease:!!t[4]}:null},gr=(e,t)=>e.major-t.major||e.minor-t.minor||e.patch-t.patch||Number(t.isPrerelease)-Number(e.isPrerelease),_r=e=>{if(typeof e!=`string`)return null;let t=e.trim();if(!t||/^(?:catalog|file|git|https?|link|npm|workspace):/.test(t)||/^(?:latest|next|\*)$/.test(t))return null;let n=[];for(let e of t.split(`||`)){let t=e.trim();if(/^<(?!=)/.test(t)||/^<=/.test(t))return null;let r=t.match(/\d+(?:\.\d+)?(?:\.\d+)?(?:-[0-9A-Za-z.-]+)?/)?.[0];if(!r)return null;let i=hr(r);if(!i)return null;n.push(i)}return n.reduce((e,t)=>gr(t,e)<0?t:e)},vr=e=>_r(e.dependencies?.ink??e.devDependencies?.ink??e.peerDependencies?.ink??e.optionalDependencies?.ink),yr=e=>{let t=e;for(;;){let e=bt(i.join(t,`node_modules`,`ink`));if(e)return{didFindPackage:!0,version:typeof e.version==`string`?hr(e.version):null};let n=i.dirname(t);if(n===t)return{didFindPackage:!1,version:null};t=n}},br=e=>{if(!e)return null;let t=vt(i.resolve(e));if(!t)return null;let n=yr(t);if(n.didFindPackage)return n.version;let r=bt(t);return r?vr(r):null},xr=(e,t)=>{let n=br(e),r=hr(t);return!!(n&&r&&gr(n,r)>=0)},Sr=new Set([`@monaco-editor/react`,`monaco-editor`,`recharts`,`@react-pdf/renderer`,`react-quill`,`@codemirror/view`,`@codemirror/state`,`chart.js`,`react-chartjs-2`,`@toast-ui/editor`,`draft-js`,`mermaid`]),Cr=new Set([`fetch`,`ky`,`got`,`wretch`,`ofetch`]),wr=new Set([`axios`,`ky`,`got`,`ofetch`,`wretch`,`request`]),Tr=new Set([`create`,`insert`,`insertInto`,`update`,`upsert`,`delete`,`remove`,`destroy`,`set`,`append`]),Er=new Set([`POST`,`PUT`,`DELETE`,`PATCH`]),Dr=new Set([`Map`,`Set`,`WeakMap`,`WeakSet`,`Headers`,`URLSearchParams`,`FormData`,`Response`,`NextResponse`]),Or=new Set([`Response`,`NextResponse`]),kr=new Set([`json`,`redirect`,`next`,`rewrite`,`error`]),Ar=new Set([`wheel`,`mousewheel`,`touchstart`,`touchmove`]),jr=new Set([`defer`,`async`]),Mr=new Set([`text/javascript`,`application/javascript`,`module`]),Nr=new Set([`setTimeout`,`setInterval`,`requestAnimationFrame`,`requestIdleCallback`,`queueMicrotask`]),Pr=new Set([`setInterval`,`setTimeout`]),Fr=new Set([`clearInterval`,`clearTimeout`]),Ir=new Set([`WebSocket`,`EventSource`,`BroadcastChannel`,`RTCPeerConnection`]),Lr=new Set([`location`,`window`,`document`,`navigator`,`history`,`screen`,`performance`]),Rr=new Set([`IntersectionObserver`,`MutationObserver`,`ResizeObserver`,`PerformanceObserver`]),zr=new Set([`blur`,`focus`,`getBoundingClientRect`,`getClientRects`,`measure`,`measureInWindow`,`measureLayout`,`scroll`,`scrollBy`,`scrollIntoView`,`scrollTo`,`select`,`setRangeText`,`setSelectionRange`]),Br=new Set([`localStorage`,`sessionStorage`]),Vr=new Set([`index`,`idx`,`i`]),Hr=new Set([`react`,`react-dom`,`preact/compat`,`preact/hooks`,`@wordpress/element`]),Ur=new Set([`next`,`next-themes`,`@remix-run/react`,`swr`,`zustand`,`jotai`,`recoil`,`wouter`,`framer-motion`,`@apollo/client`,`urql`,`usehooks-ts`]),Wr=/^(?:isLoading|isPending)$/,Gr=new Set([`useState`,`useMemo`,`useRef`]),Kr=new Set([`Click`,`Change`,`Input`,`Blur`,`Focus`]),qr=new Set([`Boolean`,`String`,`Number`,`Array`,`Object`,`parseInt`,`parseFloat`]),Jr=/^set[A-Z]/,Yr=/^render[A-Z]/,Xr=/^[A-Z]/,Zr=/^on[A-Z]/,Qr=/^use[A-Z]/,$r=/^(?:on|handle)[A-Z]/,ei=new Set([`useEffect`,`useLayoutEffect`]),ti=new Set([`useEffect`,`useLayoutEffect`,`useMemo`,`useCallback`]),ni=new Set([`use`,`useState`,`useRef`,`useMemo`,`useCallback`,`useReducer`,`useContext`,`useEffect`,`useLayoutEffect`,`useInsertionEffect`,`useImperativeHandle`,`useSyncExternalStore`,`useDeferredValue`,`useTransition`,`useId`,`useDebugValue`]),ri=new Set([`memo`,`forwardRef`,`React.memo`,`React.forwardRef`]),ii=new Set([`useMemo`,`useCallback`]),ai=new Set([`memo`,`forwardRef`,`observer`,`lazy`]),oi=new Set([`subscribe`,`addEventListener`,`addListener`,`on`,`watch`,`listen`,`sub`]),si=new Set([`subscribe`,`sub`,`listen`]),ci=new Set([`unsubscribe`,`removeEventListener`,`removeListener`,`off`,`unwatch`,`unlisten`,`unsub`,`abort`,`disconnect`,`unobserve`,`close`]),li=new Set([`remove`,`cleanup`,`dispose`,`destroy`,`stop`,`teardown`]),ui=new Set([...ci,`cleanup`,`dispose`,`destroy`,`teardown`]),di=new Set([...oi,`connect`,`disconnect`,`open`,`close`,`fetch`,`post`,`put`,`patch`]);new Set([...wr,`api`,`client`,`http`,`fetcher`]);const fi=new Set([`get`,`head`,`options`,`delete`]),pi=new Set([...Cr,...Nr]),mi=new Set([...Cr,`post`,`put`,`patch`,`navigate`,`navigateTo`,`showNotification`,`toast`,`alert`,`confirm`,`logVisit`,`captureEvent`]),hi=new Set([`post`,`put`,`patch`,`delete`,`navigate`,`capture`,`track`,`logEvent`]),gi=new Set([`push`,`replace`]),_i=new Set([`router`,`navigation`,`navigator`,`history`,`location`]),M=(e,t={})=>{if(!y(e,`Property`)&&!y(e,`MethodDefinition`)&&!y(e,`PropertyDefinition`)&&!y(e,`MemberExpression`))return null;let n=y(e,`MemberExpression`)?e.property:e.key;if(e.computed)return t.allowComputedString&&y(n,`Literal`)&&typeof n.value==`string`?n.value:t.allowComputedString&&t.stringifyNonStringLiterals&&y(n,`Literal`)?String(n.value):t.allowComputedString&&y(n,`TemplateLiteral`)&&n.expressions.length===0?n.quasis[0]?.value.cooked??n.quasis[0]?.value.raw??null:null;if(y(n,`Identifier`))return n.name;if(y(n,`Literal`)){if(typeof n.value==`string`)return n.value;if(t.stringifyNonStringLiterals)return String(n.value)}return null},N=e=>{let t=e.property;return!e.computed&&y(t,`Identifier`)?t.name:e.computed&&y(t,`Literal`)?typeof t.value==`string`?t.value:null:e.computed&&y(t,`TemplateLiteral`)&&t.expressions.length===0?t.quasis[0]?.value.cooked??t.quasis[0]?.value.raw??null:null},P=(e,t,n=!1)=>{if(e.type!==`Identifier`&&e.type!==`JSXIdentifier`)return null;let r=null,i=t.symbolFor(e);for(;i?.kind===`const`;){if(!i.initializer||i.declarationNode.type!==`VariableDeclarator`)return null;if(i.declarationNode.id!==i.bindingIdentifier)return n?i:null;let e=O(i.initializer);if(e.type!==`Identifier`)return i;if(r?.has(i.id))return null;r||=new Set,r.add(i.id),i=t.symbolFor(e)}return i},vi={},yi=new WeakMap,bi=(e,t)=>typeof e==`string`?e===t:e.has(t),xi=e=>{let t=yi.get(e);if(t)return t;let n=e.declarationNode.parent,r=!!(e.kind===`import`&&n&&n.type===`ImportDeclaration`&&typeof n.source.value==`string`&&Hr.has(n.source.value)),i={importedName:r?j(e.declarationNode):void 0,isReactImport:r};return yi.set(e,i),i},Si=e=>xi(e).isReactImport,Ci=(e,t,n,r)=>{if(e.type!==`Identifier`)return!1;let i=r?P(e,n):n.symbolFor(e);if(!i)return!1;let a=xi(i);return!!(a.isReactImport&&a.importedName&&bi(t,a.importedName))},wi=(e,t)=>{let n=P(e,t);if(!n)return!1;let r=xi(n);return r.isReactImport?n.declarationNode.type===`ImportDefaultSpecifier`||n.declarationNode.type===`ImportNamespaceSpecifier`||r.importedName===`default`:!1},Ti=(e,t,n)=>e.type===`Identifier`?wi(e,t)?!0:!!(n.allowGlobalReactNamespace&&e.name===`React`&&t.isGlobalReference(e)):!1,Ei=(e,t,n,r)=>{let i=n.symbolFor(e);if(!i||i.kind!==`const`||!i.initializer||i.declarationNode.type!==`VariableDeclarator`)return!1;let a=i.declarationNode.id;if(a.type!==`ObjectPattern`)return!1;for(let e of a.properties){if(e.type!==`Property`||e.value!==i.bindingIdentifier)continue;let a=M(e);return!!(a&&bi(t,a)&&Ti(O(i.initializer),n,r))}return!1},F=(e,t,n,r=vi)=>e.type===`CallExpression`?Di(e.callee,t,n,r):!1,Di=(e,t,n,r,i)=>{let a=O(e);if(r.resolveConditionalAliases&&a.type===`ConditionalExpression`)return Di(a.consequent,t,n,r,new Set(i))&&Di(a.alternate,t,n,r,new Set(i));if(a.type===`Identifier`){if(Ci(a,t,n,!!r.resolveNamedAliases)||r.resolveNamedAliases&&Ei(a,t,n,r))return!0;if(r.resolveConditionalAliases){let e=n.symbolFor(a);if(e?.kind===`const`&&e.initializer&&!i?.has(e.id)){let a=i??new Set;return a.add(e.id),Di(e.initializer,t,n,r,a)}}return!!(r.allowUnboundBareCalls&&bi(t,a.name)&&n.isGlobalReference(a))}return a.type!==`MemberExpression`||!bi(t,N(a)??``)?!1:Ti(O(a.object),n,r)},Oi=e=>e.includes(`\\`)?e.replaceAll(`\\`,`/`):e,ki=e=>{let t=new Set(e);if(t.size!==1)return null;let[n]=t;return n??null},Ai=(e,t,n,r)=>{let i=en(e,n);return i?ji(i,t,new Set(r))||(Fn(i,t)?i:null):null},ji=(e,t,n=new Set)=>{if(n.has(e))return null;n.add(e);let r=er(e);if(!r.isBarrel)return null;let i=r.exportsByName.get(t);if(i){let t=en(e,i.source);return t?ji(t,i.importedName,n)??t:null}return t===`default`?null:ki(r.starExportSources.map(r=>Ai(e,t,r,n)).filter(e=>!!e))},Mi=(e,t,n)=>{let r=k(e,t,n);return r?{filePath:r.filePath,node:r.exportedNode,programNode:r.programNode,kind:v(r.exportedNode)?`function`:`initializer`}:null},I=e=>{let t=e;for(;t.parent&&jt.has(t.parent.type);)t=t.parent;return t},Ni=(e,t)=>{if(!y(e,`ArrowFunctionExpression`)&&!y(e,`FunctionExpression`)&&!y(e,`FunctionDeclaration`))return null;let n=e.params[0],r=y(n,`AssignmentPattern`)?n.left:n;if(y(r,`ObjectPattern`)){let e=r.properties.find(e=>y(e,`Property`)&&M(e,{allowComputedString:!0})===`children`);if(!e||!y(e,`Property`))return null;let n=y(e.value,`AssignmentPattern`)?e.value.left:e.value;if(!y(n,`Identifier`))return null;let i=t.symbolFor(n);return!i||i.references.length===0||i.references.some(e=>e.flag!==`read`)?null:i.references.map(e=>e.identifier)}if(!y(r,`Identifier`))return null;let i=t.symbolFor(r);if(!i||i.references.length===0)return null;let a=[];for(let e of i.references){if(e.flag!==`read`)return null;let t=[],n=I(e.identifier);for(;n.parent&&y(n.parent,`MemberExpression`)&&n.parent.object===n;){let e=N(n.parent);if(!e)return null;t.push(e),n=I(n.parent)}if(t[0]!==`children`){if(t.length===0)return null;continue}if(t.length!==1)return null;a.push(n)}return a.length>0?a:null},L=e=>{let t=e.parent;for(;t;){if(v(t))return t;t=t.parent??null}return null},Pi=e=>{let t=e;for(;t;){if(y(t,`Program`))return t;t=t.parent??null}return null},Fi=e=>{let t=new Map,n=e.body??[];for(let e of n){if(e.type!==`ImportDeclaration`||!(`source`in e)||!e.source)continue;let n=e.source.value;if(typeof n==`string`&&!(!(`specifiers`in e)||!Array.isArray(e.specifiers)))for(let r of e.specifiers){if(!(`local`in r)||!r.local)continue;let e=r.local;if(typeof e.name==`string`){if(r.type===`ImportDefaultSpecifier`)t.set(e.name,{source:n,imported:null,isDefault:!0,isNamespace:!1});else if(r.type===`ImportNamespaceSpecifier`)t.set(e.name,{source:n,imported:null,isDefault:!1,isNamespace:!0});else if(r.type===`ImportSpecifier`){let i=r.imported,a=i?.name??(typeof i?.value==`string`?i.value:null);t.set(e.name,{source:n,imported:a,isDefault:!1,isNamespace:!1})}}}}return t},Ii=new WeakMap,Li=e=>{let t=Pi(e);if(!t)return null;let n=Ii.get(t);return n||(n=Fi(t),Ii.set(t,n)),n},Ri=(e,t)=>{let n=Li(e);if(!n)return!1;for(let e of n.values())if(t.includes(e.source))return!0;return!1},zi=(e,t,n)=>{let r=Li(e);if(!r)return!1;let i=r.get(t);return i?i.source===n:!1},Bi=(e,t,n)=>{let r=Li(e);if(!r)return!1;let i=r.get(t);return i?i.isNamespace&&i.source===n:!1},Vi=(e,t,n)=>{let r=Li(e);if(!r)return!1;let i=r.get(t);return i?i.isDefault&&i.source===n:!1},Hi=(e,t,n)=>{let r=Li(e);if(!r)return null;let i=r.get(t);return!i||i.source!==n?null:i.imported},Ui=(e,t)=>{let n=Li(e);return n?n.get(t)?.source??null:null},Wi=(e,t)=>{let n=Li(e)?.get(t);return n?n.isNamespace?{source:n.source,exportedName:null,isNamespace:!0}:{source:n.source,exportedName:n.isDefault?`default`:n.imported,isNamespace:!1}:null},Gi=e=>{let t=e,n=t.parent;for(;n&&O(n)===e;)t=n,n=t.parent;return n&&y(n,`AssignmentExpression`)&&n.operator===`=`&&n.left===t?n.right:null},Ki=e=>{let t=e.range?.[0];return typeof t==`number`?t:null},qi=new Set([`let`,`var`]),Ji=new Set([`ConditionalExpression`,`LogicalExpression`]),Yi=new WeakMap,Xi=(e,t,n)=>{let r=e.parent??null;for(;r&&n.blockOf(r)===t;){if(Ji.has(r.type))return!0;r=r.parent??null}return!1},Zi=(e,t)=>e.size===t.size&&[...e].every(e=>t.has(e)),Qi=(e,t)=>{let n=new Set(e);for(let e of t)e.isConditionalWithinBlock||(n=new Set),n.add(e);return n},$i=(e,t,n)=>{let r=L(t);if(L(e.bindingIdentifier)!==r||!r)return[];let i=n.cfgFor(r);if(!i)return[];let a=i.blockOf(t);if(!a)return[];let o=Ki(t),s=Ki(e.bindingIdentifier);if(o===null||s===null)return[];let c=new Map,l=(e,t,n)=>{let r=i.blockOf(t);if(!r)return;let a=c.get(r)??[];a.push({expression:e,position:n,isConditionalWithinBlock:Xi(t,r,i)}),c.set(r,a)};e.initializer&&l(e.initializer,e.bindingIdentifier,s);for(let t of e.references){let e=Ki(t.identifier);if(t.flag===`read`||L(t.identifier)!==r||e===null||e>=o)continue;let n=Gi(t.identifier);n&&l(n,t.identifier,e)}for(let e of c.values())e.sort((e,t)=>e.position-t.position);let u=new Map,d=new Map,f=new Set([i.entry]),p=[i.entry];for(;p.length>0;){let e=p.pop();if(!e)break;for(let t of e.successors)f.has(t.to)||(f.add(t.to),p.push(t.to))}if(!f.has(a))return[];let m=!0;for(;m;){m=!1;for(let e of i.blocks){if(!f.has(e))continue;let t=new Set;for(let n of e.predecessors)if(f.has(n.from))for(let e of d.get(n.from)??[])t.add(e);let n=Qi(t,c.get(e)??[]),r=u.get(e)??new Set,i=d.get(e)??new Set;(!Zi(t,r)||!Zi(n,i))&&(u.set(e,t),d.set(e,n),m=!0)}}let h=(c.get(a)??[]).filter(e=>e.position<o);return[...Qi(u.get(a)??new Set,h)].map(e=>e.expression)},ea=(e,t,n)=>{if(!qi.has(e.kind))return e.initializer?[e.initializer]:[];if(!n)return[];let r=Yi.get(n);r||(r=new WeakMap,Yi.set(n,r));let i=r.get(e);i||(i=new WeakMap,r.set(e,i));let a=i.get(t);if(a)return a;let o=$i(e,t,n);return i.set(t,o),o},ta=e=>{if(!v(e)||!y(e.body,`BlockStatement`))return[];let t=[];return A(e.body,n=>{if(n!==e.body&&(v(n)||y(n,`ClassDeclaration`)||y(n,`ClassExpression`)))return!1;y(n,`ReturnStatement`)&&t.push(n)}),t},R=e=>{if(y(e,`ReturnStatement`)||y(e,`ThrowStatement`))return!0;if(y(e,`IfStatement`)){if(y(e.test,`Literal`)){let t=e.test.value?e.consequent:e.alternate;return t?R(t):!1}return!!(e.alternate&&R(e.consequent)&&R(e.alternate))}if(y(e,`TryStatement`))return e.finalizer&&R(e.finalizer)?!0:R(e.block)?e.handler?R(e.handler.body):!0:!1;if(y(e,`DoWhileStatement`))return R(e.body);if(y(e,`WhileStatement`)){let t=e.test;return!!(y(t,`Literal`)&&t.value&&R(e.body))}if(y(e,`ForStatement`)){let t=e.test;return!!((!t||y(t,`Literal`)&&t.value)&&R(e.body))}return y(e,`BlockStatement`)?e.body.some(e=>R(e)):!1},na=new Set([`let`,`var`]),ra=e=>!v(e)||!e.body?[]:y(e.body,`BlockStatement`)?ta(e).flatMap(e=>e.argument?[e.argument]:[]):[e.body],ia=e=>{if(!v(e)||!y(e.body,`BlockStatement`))return!1;let t=!1;return A(e.body,n=>{if(t||n!==e.body&&v(n))return!1;y(n,`ReturnStatement`)&&!n.argument&&(t=!0)}),t},aa=(e,t,n,r=`some`)=>{let i=new Set,a=new Set,o,s=e=>{if(a.has(e))return!1;a.add(e);try{let t=ra(e);return r===`every`&&v(e)&&y(e.body,`BlockStatement`)&&(!R(e.body)||ia(e))?!1:t.length>0&&(r===`every`?t.every(o):t.some(o))}finally{a.delete(e)}};o=a=>{let l=O(a);if(i.has(l))return!1;i.add(l);try{if(t(l))return!0;if(y(l,`Identifier`)){let t=e.symbolFor(l);if(!t||t.kind!==`const`&&!na.has(t.kind))return!1;let i=ea(t,l,n),a=e=>{let t=O(e);return!v(t)&&o(t)};return r===`every`?i.length>0&&i.every(a):i.some(a)}if(y(l,`CallExpression`)){if(l.arguments.length!==0||!y(l.callee,`Identifier`))return!1;let t=e.symbolFor(l.callee);if(!t||t.kind!==`const`&&t.kind!==`function`)return!1;let n=t.initializer?O(t.initializer):null,r=null;return v(n)?r=n:v(t.declarationNode)&&(r=t.declarationNode),!r||r.async||r.generator||r.params.length!==0?!1:s(r)}return y(l,`ConditionalExpression`)?c(l.consequent,l.alternate):y(l,`LogicalExpression`)?c(l.left,l.right):!1}finally{i.delete(l)}};let c=(e,t)=>{let n=[o(e),o(t)];return r===`every`?n.every(Boolean):n.some(Boolean)};return{expressionMatches:o,functionMatches:s}},oa=(e,t,n,r,i=`some`)=>aa(t,n,r,i).functionMatches(e),sa=(e,t,n,r,i)=>{let a=i.cfgFor(e),o=a?.blockOf(t);if(!a||!o)return!1;let s=new Set(ta(e).flatMap(e=>{if(!e.argument||!aa(n,r,i,`every`).expressionMatches(e.argument))return[];let t=a.blockOf(e.argument);return t?[t]:[]}));if(s.size===0)return!1;let c=new Set([o]),l=[o];for(;l.length>0;){let e=l.pop();if(!e)break;if(!s.has(e))for(let t of e.successors){if(t.to===a.exit)return!1;c.has(t.to)||(c.add(t.to),l.push(t.to))}}return!0},ca=e=>y(e,`Program`)?e.range[1]:e.range[0],la=new WeakMap,ua=(e,t)=>{t.push(...e.symbols);for(let n of e.children)ua(n,t)},da=e=>{let t=new Map,n=[];ua(e.rootScope,n);for(let r of n){let n=P(r.bindingIdentifier,e);if(!n)continue;let i=t.get(n.id)??[];i.push(r),t.set(n.id,i)}return t},fa=(e,t)=>{let n=P(e,t);if(!n)return[];let r=la.get(t);return r||(r=da(t),la.set(t,r)),r.get(n.id)??[]},pa=e=>{let t=e.expressions??[],n=e.quasis??[];if(t.length!==0||n.length!==1)return null;let r=n[0]?.value;return r?.cooked??r?.raw??null},z=(e,t,n={})=>{let r=M(e,{allowComputedString:!0,stringifyNonStringLiterals:n.stringifyNonStringLiterals});if(r!==null||!y(e,`Property`)&&!y(e,`MethodDefinition`)&&!y(e,`PropertyDefinition`)&&!y(e,`MemberExpression`)||!e.computed)return r;let i=O(y(e,`MemberExpression`)?e.property:e.key);if(!y(i,`Identifier`))return null;let a=P(i,t);if(a?.kind!==`const`||!a.initializer)return null;let o=O(a.initializer);return y(o,`Literal`)?typeof o.value==`string`?o.value:n.allowConstNumericLiteral&&typeof o.value==`number`?String(o.value):null:n.allowConstTemplateLiteral&&y(o,`TemplateLiteral`)?pa(o):null},ma=new Set([`CatchClause`,`ConditionalExpression`,`DoWhileStatement`,`ForInStatement`,`ForOfStatement`,`ForStatement`,`IfStatement`,`LogicalExpression`,`SwitchCase`,`SwitchStatement`,`TryStatement`,`WhileStatement`]),ha=(e,t)=>{let n=e.parent??null;for(;n&&n!==t;){if(ma.has(n.type))return!1;n=n.parent??null}return n===t},ga=e=>L(e)??Pi(e),_a=e=>{let t=I(e),n=t.parent;return!!(n&&y(n,`VariableDeclarator`)&&n.init===t&&n.parent&&y(n.parent,`VariableDeclaration`)&&n.parent.kind===`const`)},va=e=>{let t=I(e),n=t.parent;return!!(n&&(y(n,`AssignmentExpression`)&&n.left===t||y(n,`UpdateExpression`)&&n.argument===t||y(n,`UnaryExpression`)&&n.operator===`delete`&&n.argument===t))},ya=e=>{let t=I(e),n=t.parent;return n&&y(n,`MemberExpression`)&&O(n.object)===t?n:null},ba=(e,t,n,r)=>{if(!y(e,`ObjectExpression`))return null;for(let i of e.properties.toReversed()){if(!y(i,`Property`))return null;let e=z(i,n);if(e===null)return null;if(e===t)return i.kind===`init`?B(i.value,n,r):null}return null},xa=(e,t,n,r)=>{if(!y(e,`ObjectExpression`))return[];let i=[],a=new Set;for(let o of e.properties){if(!y(o,`Property`))continue;let e=z(o,n),s=o.kind===`init`||o.kind===`get`?B(o.value,n,new Set(r)):null;e===t?(i=s?[s]:[],a.clear(),s&&a.add(s)):e===null&&s&&!a.has(s)&&(i.push(s),a.add(s))}return i},Sa=(e,t,n,r)=>{if(!y(e,`ClassDeclaration`)&&!y(e,`ClassExpression`))return null;for(let i of e.body.body.toReversed()){if(!y(i,`MethodDefinition`)&&!y(i,`PropertyDefinition`)||!i.static)continue;let e=z(i,n);if(e===null)return null;if(e===t)return y(i,`MethodDefinition`)&&i.kind!==`method`?null:i.value?B(i.value,n,r):null}return null},Ca=(e,t,n,r)=>{if(!y(e,`ClassDeclaration`)&&!y(e,`ClassExpression`))return[];let i=[],a=new Set;for(let o of e.body.body){if(!y(o,`MethodDefinition`)&&!y(o,`PropertyDefinition`)||!o.static)continue;let e=z(o,n),s=o.value&&(!y(o,`MethodDefinition`)||o.kind===`method`||o.kind===`get`)?B(o.value,n,new Set(r)):null;e===t?(i=s?[s]:[],a.clear(),s&&a.add(s)):e===null&&s&&!a.has(s)&&(i.push(s),a.add(s))}return i},wa=(e,t,n,r,i,a,o)=>{let s=ga(t);if(!s||!y(e,`Identifier`))return{exactFunction:null,possibleFunctions:[]};let c=[];for(let r of fa(e,a))for(let e of r.references){let r=e.identifier;if(r.range[0]>=t.range[0]||_a(r))continue;let i=ya(r);if(!i){ga(r)===s&&c.push({assignedExpression:null,isDefinite:!1,offset:r.range[0]});continue}if(!va(i)||ga(i)!==s)continue;let o=z(i,a),l=I(i).parent,u=l&&y(l,`AssignmentExpression`)&&l.operator===`=`?l.right:null;if(o===null){c.push({assignedExpression:u,isDefinite:!1,offset:i.range[0]});continue}if(o===n){if(!l||!y(l,`AssignmentExpression`)||l.operator!==`=`||!ha(i,s)){c.push({assignedExpression:u,isDefinite:!1,offset:i.range[0]});continue}c.push({assignedExpression:u,isDefinite:!0,offset:l.range[0]})}}c.sort((e,t)=>e.offset-t.offset);let l=r,u=i,d=new Set(i);for(let e of c){let t=e.assignedExpression?B(e.assignedExpression,a,new Set(o)):null;if(e.isDefinite){l=t,u=t?[t]:[],d.clear(),t&&d.add(t);continue}l=null,t&&!d.has(t)&&(u.push(t),d.add(t))}return{exactFunction:l,possibleFunctions:u}},Ta=(e,t,n)=>{if(!y(e,`MemberExpression`))return{exactFunction:null,possibleFunctions:[]};let r=N(e);if(r===null)return{exactFunction:null,possibleFunctions:[]};let i=O(e.object);if(y(i,`ObjectExpression`))return{exactFunction:ba(i,r,t,n),possibleFunctions:xa(i,r,t,n)};if(y(i,`ClassExpression`))return{exactFunction:Sa(i,r,t,n),possibleFunctions:Ca(i,r,t,n)};if(!y(i,`Identifier`))return{exactFunction:null,possibleFunctions:[]};let a=P(i,t);if(!a||n.has(a.id))return{exactFunction:null,possibleFunctions:[]};n.add(a.id);let o=null,s=[];if(a.kind===`const`&&a.initializer){let e=O(a.initializer);o=ba(e,r,t,n),s=xa(e,r,t,n)}else a.kind===`class`&&a.initializer&&(o=Sa(a.initializer,r,t,n),s=Ca(a.initializer,r,t,n));return wa(i,e,r,o,s,t,n)},Ea=(e,t,n)=>{let r=O(e);if(y(r,`CallExpression`)){let e=O(r.callee);return y(e,`MemberExpression`)&&N(e)===`bind`?Ea(e.object,t,n):[]}if(y(r,`MemberExpression`)){let e=N(r);return e===`call`||e===`apply`?Ea(r.object,t,n):Ta(r,t,n).possibleFunctions}let i=B(r,t,n);return i?[i]:[]},B=(e,t,n)=>{let r=O(e);if(v(r))return r;if(y(r,`CallExpression`)){let e=O(r.callee);return y(e,`MemberExpression`)&&N(e)===`bind`?B(e.object,t,n):null}if(y(r,`MemberExpression`)){let e=N(r);return e===`call`||e===`apply`?B(r.object,t,n):Ta(r,t,n).exactFunction}if(!y(r,`Identifier`))return null;let i=P(r,t);return!i||n.has(i.id)?null:(n.add(i.id),i.kind===`function`?!i.references.some(e=>e.flag!==`read`)&&v(i.declarationNode)?i.declarationNode:null:i.kind!==`const`||!i.initializer?null:B(i.initializer,t,n))},Da=(e,t)=>B(e,t,new Set),Oa=(e,t)=>Ea(e,t,new Set),ka=new WeakMap,Aa=(e,t)=>{let n=O(e);return y(n,`Identifier`)?t.symbolFor(n):null},ja=(e,t)=>{let n=I(e),r=n.parent;return!r||!y(r,`AssignmentExpression`)||r.operator!==`=`||r.left!==n?null:Aa(r.right,t)},Ma=e=>{let t=I(e),n=t.parent;return n&&y(n,`VariableDeclarator`)&&n.init===t&&(y(n.id,`Identifier`)||y(n.id,`ObjectPattern`))?!0:!!(n&&y(n,`AssignmentExpression`)&&n.operator===`=`&&n.right===t&&y(O(n.left),`Identifier`))},Na=(e,t,n)=>{if(e.initializer&&y(e.declarationNode,`VariableDeclarator`)&&e.declarationNode.id===e.bindingIdentifier){let r=Aa(e.initializer,n);if(r&&t.has(r.id))return!0}return e.references.some(e=>{let r=ja(e.identifier,n);return!!(r&&t.has(r.id))})},Pa=(e,t)=>{let n=P(e,t);if(!n)return[];let r=ka.get(t);r||(r=new Map,ka.set(t,r));let i=r.get(n.id);if(i)return i;let a=[],o=[t.rootScope];for(;o.length>0;){let e=o.pop();e&&(a.push(...e.symbols),o.push(...e.children))}let s=new Set([n.id]),c=!0;for(;c;){c=!1;for(let e of a)s.has(e.id)||Na(e,s,t)&&(s.add(e.id),c=!0)}let l=a.filter(e=>s.has(e.id));return r.set(n.id,l),l},Fa=e=>{let t=e;for(;t;){if(v(t)||y(t,`Program`))return t;t=t.parent??null}return null},Ia=new WeakMap,La=(e,t)=>{let n=Ia.get(t);if(!n){let r=new Map,i=new Map,a=Pi(e);a&&A(a,e=>{if(!y(e,`CallExpression`))return;let n=O(e.callee),a=y(n,`Identifier`)?t.symbolFor(n):null,o=a?i.get(a.id):void 0;o===void 0&&(o=Oa(e.callee,t),a&&i.set(a.id,o));for(let t of o){let n=r.get(t)??[];n.push(e),r.set(t,n)}}),n=r,Ia.set(t,n)}return n.get(e)??[]},Ra=new WeakMap,za=(e,t)=>{let n=Ra.get(t);if(n===void 0){let e=null;A(t,n=>{y(n,`AwaitExpression`)&&L(n)===t&&(e===null||n.range[0]<e)&&(e=n.range[0])}),n=e,Ra.set(t,n)}return n===null||e.range[0]<n},Ba=(e,t,n,r=new Set,i=null,a)=>{if(r.has(e)||!v(e)||e.generator||i!==null&&!ha(i,e)||i!==null&&a!==void 0&&!a(i)||i!==null&&e.async&&!za(i,e))return[];r.add(e);let o=Fa(t);return o?La(e,n).flatMap(e=>{let s=Fa(e);return!s||i!==null&&!ha(e,s)||i!==null&&a!==void 0&&!a(e)?[]:s===o?e.range[0]<ca(t)?[[e.range[0]]]:[]:v(s)?Ba(s,t,n,new Set(r),i===null?null:e,a).map(t=>[...t,e.range[0]]):[]}):[]},Va=(e,t,n,r=new Set,i=null)=>Ba(e,t,n,r,i).length>0,Ha=e=>{let t=e.parent;return t?y(t,`AssignmentExpression`)?t.left===e:(y(t,`UpdateExpression`)||y(t,`UnaryExpression`)&&t.operator===`delete`)&&t.argument===e:!1},Ua=e=>{let t=e.parent;for(;t&&O(t)===e;)t=t.parent;return!t||!y(t,`MemberExpression`)||O(t.object)!==e||!Ha(t)?null:t},Wa=(e,t,n)=>{let r=Ua(e);return r&&z(r,n)===t?r:null},Ga=(e,t,n,r)=>e.references.some(e=>{let i=Wa(e.identifier,t,r);if(!i)return!1;let a=Fa(i),o=Fa(n);return!a||!o||!ha(i,a)?!1:a===o?i.range[0]<ca(n):v(a)&&Va(a,n,r)}),Ka=e=>{if(Ma(e))return!0;let t=I(e),n=t.parent;return!!(n&&y(n,`MemberExpression`)&&O(n.object)===t)},qa=e=>{if(Ma(e))return!0;let t=I(e),n=t.parent;if(!n||!y(n,`MemberExpression`)||O(n.object)!==t)return!1;let r=I(n),i=r.parent;return!(i&&y(i,`CallExpression`)&&i.callee===r)},Ja=(e,t,n)=>y(e,`Identifier`)?Pa(e,n).some(e=>e.references.some(e=>{let r=Ua(e.identifier);if(!r)return!1;let i=z(r,n);return i===null||i===t})):!1,Ya=(e,t,n)=>{let r=Fa(e),i=Fa(t);return!r||!i?!0:r===i?e.range[0]<ca(t):v(r)?Va(r,t,n):!0},Xa=(e,t,n,r)=>y(e,`Identifier`)?Pa(e,r).some(e=>e.references.some(e=>{let i=Ua(e.identifier);if(!i||!Ya(i,n,r))return!1;let a=z(i,r);return a===null||a===t})):!1,Za=(e,t,n)=>y(e,`Identifier`)?Ja(e,t,n)?!0:Pa(e,n).some(e=>e.references.some(e=>!Ka(e.identifier))):!1,Qa=(e,t,n,r)=>y(e,`Identifier`)?Xa(e,t,n,r)?!0:Pa(e,r).some(e=>e.references.some(e=>!qa(e.identifier)&&Ya(e.identifier,n,r))):!1,$a=(e,t)=>{let n=O(e);if(!y(n,`CallExpression`))return!1;let r=O(n.callee);if(!y(r,`MemberExpression`))return!1;let i=N(r);if(i===null)return!1;let a=O(r.object);return y(a,`Identifier`)&&Ja(a,i,t)},eo=(e,t,n,r)=>y(e,`Identifier`)?fa(e,r).some(e=>Ga(e,t,n,r)):!1,to=(e,t,n,r={})=>{let i=L(e);return i===L(t)?e.range[0]>=ca(t)||r.requireSynchronousWrite&&(!i||!ha(e,i)||r.isSynchronousNode!==void 0&&!r.isSynchronousNode(e))?[]:[[e.range[0]]]:i?r.requireSynchronousWrite?Ba(i,t,n,new Set,e,r.isSynchronousNode).map(t=>[...t,e.range[0]]):Ba(i,t,n).map(t=>[...t,e.range[0]]):r.requireSynchronousWrite?[]:[[-1/0,e.range[0]]]},no=(e,t,n,r={})=>to(e,t,n,r).length>0,V=(e,t,n,r={})=>e.references.some(e=>e.flag===`read`?!1:no(e.identifier,t,n,r)),ro=(e,t)=>{if(!y(e,`CallExpression`))return!1;let n=O(e.callee);if(y(n,`Identifier`)){let e=t.symbolFor(n);return!!(e&&!V(e,n,t))}if(!y(n,`MemberExpression`))return!1;let r=N(n),i=O(n.object);return!!(r&&y(i,`Identifier`)&&!eo(i,r,n,t))},io=new Set([`FunctionDeclaration`,`FunctionExpression`,`ArrowFunctionExpression`,`ClassDeclaration`,`ClassExpression`]),ao={allowGlobalReactNamespace:!1,allowUnboundBareCalls:!1},oo=new Set([`lodash/sortBy`,`lodash/sortBy.js`,`lodash-es/sortBy`,`lodash-es/sortBy.js`]),so=e=>y(e,`TSArrayType`)||y(e,`TSTupleType`)?!0:y(e,`TSTypeReference`)?y(e.typeName,`Identifier`)&&(e.typeName.name===`Array`||e.typeName.name===`ReadonlyArray`):!1,co=e=>{if(!y(e,`Identifier`))return!1;let t=e.typeAnnotation;return!!(t&&y(t,`TSTypeAnnotation`)&&so(t.typeAnnotation))},lo=(e,t)=>{if(!y(e,`CallExpression`))return!1;let n=O(e.callee);if(!y(n,`Identifier`))return!1;let r=t.symbolFor(n);if(!r||V(r,n,t)||!y(r.declarationNode,`ImportDefaultSpecifier`)&&!y(r.declarationNode,`ImportSpecifier`))return!1;let i=Wi(n,n.name);return!i||i.isNamespace?!1:oo.has(i.source)&&i.exportedName===`default`?!0:(i.source===`lodash`||i.source===`lodash-es`)&&i.exportedName===`sortBy`},uo=(e,t,n,r=new Set)=>{let i=O(e);if(y(i,`ArrayExpression`)||lo(i,t))return!0;if(!y(i,`Identifier`))return!1;let a=t.symbolFor(i);return!a||r.has(a.id)||V(a,n,t)?!1:co(a.bindingIdentifier)?!0:a.initializer?(r.add(a.id),uo(a.initializer,t,n,r)):!1},fo=(e,t)=>{if(!y(e,`CallExpression`))return!1;let n=O(e.callee);if(!y(n,`MemberExpression`)||N(n)!==`map`)return!1;let r=O(n.object);return uo(r,t,e)?!(y(r,`Identifier`)&&eo(r,`map`,e,t)):!1},po=(e,t)=>{if(e.type!==`ArrowFunctionExpression`&&e.type!==`FunctionExpression`)return!1;let n=e.parent;return y(n,`CallExpression`)?F(n,`useMemo`,t,{resolveNamedAliases:!0})&&ro(n,t)?n.arguments[0]===e:n.arguments.some(t=>t===e)&&fo(n,t):!1},mo=(e,t)=>io.has(e.type)&&!po(e,t),ho=(e,t)=>e.type===`JSXElement`||e.type===`JSXFragment`||F(e,`createElement`,t,ao)||go(e,t),go=(e,t)=>{if(!y(e,`CallExpression`))return!1;let n=O(e.callee);if(y(n,`Identifier`))return t.symbolFor(n)?.kind===`import`&&Hi(n,n.name,`react-dom`)===`createPortal`;if(!y(n,`MemberExpression`)||n.computed||!y(n.object,`Identifier`)||!y(n.property,`Identifier`)||n.property.name!==`createPortal`)return!1;let r=t.symbolFor(n.object);return!r||r.kind!==`import`?!1:Vi(n.object,n.object.name,`react-dom`)||Bi(n.object,n.object.name,`react-dom`)},_o=(e,t)=>{let n=!1;return A(e,r=>{if(n||r!==e&&mo(r,t))return!1;if(ho(r,t))return n=!0,!1}),n},vo=new WeakMap,yo=(e,t,n)=>{let r=vo.get(e);if(r&&r.scopes===t&&r.controlFlow===n)return r.hasRenderOutput;let i=oa(e,t,e=>_o(e,t),n);return vo.set(e,{scopes:t,controlFlow:n,hasRenderOutput:i}),i},bo=e=>y(e,`JSXIdentifier`)?e.name:y(e,`JSXNamespacedName`)?`${e.namespace.name}:${e.name.name}`:null,xo=new Set([`Component`,`PureComponent`]),So=(e,t,n,r)=>{let i=O(e);if(y(i,`MemberExpression`)){let e=N(i),n=O(i.object);return!!(e&&xo.has(e)&&y(n,`Identifier`)&&!eo(n,e,i,t)&&wi(n,t))}if(y(i,`ClassExpression`))return Co(i,t,n,r);if(!y(i,`Identifier`))return!1;let a=t.symbolFor(i);if(!a||r.has(a.id)||V(a,i,t))return!1;if(r.add(a.id),Si(a)){let e=j(a.declarationNode);return!!(e&&xo.has(e))}return y(a.declarationNode,`ClassDeclaration`)||y(a.declarationNode,`ClassExpression`)?Co(a.declarationNode,t,n,r):!!(a.kind===`const`&&a.initializer&&So(a.initializer,t,n,r))},Co=(e,t,n=new Set,r=new Set)=>!y(e,`ClassDeclaration`)&&!y(e,`ClassExpression`)||n.has(e)||!e.superClass?!1:(n.add(e),So(e.superClass,t,n,r)),wo=new Set([`FunctionDeclaration`,`FunctionExpression`,`ArrowFunctionExpression`,`MethodDefinition`,`Program`]),To=e=>{let t=e;for(;t;){if(wo.has(t.type))return t;t=t.parent??null}return null},Eo=(e,t)=>{if(t!==`let`&&t!==`const`)return To(e);let n=e.parent;for(;n;){if(n.type===`BlockStatement`){let t=n.parent;return t&&(t.type===`FunctionDeclaration`||t.type===`FunctionExpression`||t.type===`ArrowFunctionExpression`||t.type===`MethodDefinition`)?To(e):n}if(wo.has(n.type))return n;n=n.parent??null}return null},Do=(e,t,n,r)=>{if(y(e,`Identifier`)){let i=r.get(e.name)??[];i.push({bindingIdentifier:e,initializer:t,scopeOwner:n}),r.set(e.name,i);return}if(y(e,`ObjectPattern`)){for(let t of e.properties)if(y(t,`Property`)){let e=t.value;Do(e,y(e,`AssignmentPattern`)?e.right:null,n,r)}else y(t,`RestElement`)&&Do(t.argument,null,n,r);return}if(y(e,`ArrayPattern`)){for(let t of e.elements)t&&Do(t,y(t,`AssignmentPattern`)?t.right??null:null,n,r);return}if(y(e,`AssignmentPattern`)){Do(e.left,e.right??null,n,r);return}y(e,`RestElement`)&&Do(e.argument,null,n,r)},Oo=e=>{let t=new Map;return A(e,e=>{switch(e.type){case`VariableDeclarator`:{let n=e.parent,r=Eo(e,n?.type===`VariableDeclaration`?n.kind:void 0);r&&Do(e.id,e.init??null,r,t);break}case`FunctionDeclaration`:case`FunctionExpression`:case`ArrowFunctionExpression`:if(e.type!==`ArrowFunctionExpression`&&e.id){let n=e.parent?To(e.parent):null;if(n){let r=t.get(e.id.name)??[];r.push({bindingIdentifier:e.id,initializer:e,scopeOwner:n}),t.set(e.id.name,r)}}for(let n of e.params)Do(n,null,e,t);break;case`ClassDeclaration`:case`ClassExpression`:{if(!e.id)break;let n=e.parent?To(e.parent):null;if(n){let r=t.get(e.id.name)??[];r.push({bindingIdentifier:e.id,initializer:e,scopeOwner:n}),t.set(e.id.name,r)}break}case`ImportDeclaration`:{let n=To(e);if(!n)break;for(let r of e.specifiers){let e=r.local;if(e&&y(e,`Identifier`)){let i=t.get(e.name)??[];i.push({bindingIdentifier:e,initializer:r,scopeOwner:n}),t.set(e.name,i)}}break}case`TSImportEqualsDeclaration`:case`TSEnumDeclaration`:case`TSModuleDeclaration`:{let n=e.id;if(n?.type===`Identifier`){let r=To(e);if(r){let e=t.get(n.name)??[];e.push({bindingIdentifier:n,initializer:null,scopeOwner:r}),t.set(n.name,e)}}break}}}),t},ko=new WeakMap,Ao=new WeakMap,jo=e=>{let t=Pi(e);if(!t)return null;let n=ko.get(t);return n||(n=Oo(t),ko.set(t,n)),n},Mo=(e,t,n)=>{let r=jo(e);if(!r)return null;let i=r.get(t);if(!i||i.length===0)return null;let a=i[0];if(i.length===1&&a){let t=e;for(;t;){if(t===a.scopeOwner)return a;t=t.parent??null}return null}let o=e;for(;o;){let t=null;for(let r of i)if(r.scopeOwner===o){if(t===null){t=r;continue}if(n?.preferInitializerBeforeReference){let n=!!(r.initializer&&(y(r.initializer,`FunctionDeclaration`)||r.bindingIdentifier.range[0]<e.range[0]));if(n!==!!(t.initializer&&(y(t.initializer,`FunctionDeclaration`)||t.bindingIdentifier.range[0]<e.range[0]))){n&&(t=r);continue}}(r.initializer!==null||t.initializer===null)&&(t=r)}if(t)return t;o=o.parent??null}return null},No=(e,t,n)=>{let r=Ao.get(e),i;if(!r)i={},Ao.set(e,{primaryBindingName:t,primaryLookup:i});else if(r.primaryBindingName===t)i=r.primaryLookup;else{let e=r.additionalLookups;e||(e=new Map,r.additionalLookups=e);let n=e.get(t);n?i=n:(i={},e.set(t,i))}let a=n?.preferInitializerBeforeReference?`preferredResult`:`defaultResult`;if(a in i)return i[a]??null;let o=Mo(e,t,n);return i[a]=o,o},Po=e=>Xr.test(e),Fo=e=>{let t=No(e,e.name);if(!t?.initializer)return null;let n=t.bindingIdentifier.parent;if(!n||!y(n,`VariableDeclarator`)||n.id!==t.bindingIdentifier)return null;let r=n.parent;if(!r||!y(r,`VariableDeclaration`)||r.kind!==`const`)return null;let i=O(t.initializer);return y(i,`Literal`)&&typeof i.value==`string`?i.value:null},Io=e=>y(e,`JSXIdentifier`)?e.name:y(e,`JSXMemberExpression`)?`${Io(e.object)}.${e.property.name}`:y(e,`JSXNamespacedName`)?`${e.namespace.name}:${e.name.name}`:``,Lo=e=>{let t=e.name;return y(t,`JSXIdentifier`)?Po(t.name)?Fo(t)??t.name:t.name:Io(t)},Ro=(e,t)=>{if(!y(e.name,`JSXIdentifier`))return!1;let n=Lo(e);if(n[0]===n[0]?.toLowerCase())return!0;let r=new Set,i=e=>{let n=I(e);if(y(n,`Literal`))return typeof n.value==`string`;if(y(n,`Identifier`)||y(n,`JSXIdentifier`)){let e=t.symbolFor(n);if(!e||e.kind!==`const`||!e.initializer||r.has(e.id))return!1;r.add(e.id);let a=i(e.initializer);return r.delete(e.id),a}return y(n,`ConditionalExpression`)?i(n.consequent)&&i(n.alternate):!1};return i(e.name)},zo=(e,t,n=new Set)=>{if(!e)return null;let r=O(e);if(v(r))return r;if(y(r,`Identifier`)){let e=t.symbolFor(r);return!e||n.has(e.id)||!e.initializer||V(e,r,t)?null:(n.add(e.id),zo(e.initializer,t,n))}if(!y(r,`CallExpression`)||!F(r,`memo`,t,{resolveNamedAliases:!0})&&!F(r,`forwardRef`,t,{resolveNamedAliases:!0}))return null;let i=r.arguments[0];return!i||y(i,`SpreadElement`)?null:zo(i,t,n)},Bo=(e,t)=>{let n=I(e);if(!v(n)||n.async||n.generator)return!1;let r=n.parent;if(!r||!y(r,`JSXExpressionContainer`))return!1;let i=r.parent;if(!i||!y(i,`JSXAttribute`)||bo(i.name)!==`ref`)return!1;let a=i.parent;return!!(a&&y(a,`JSXOpeningElement`)&&Ro(a,t))},Vo=(e,t)=>t.every((t,n)=>e[n]===t),Ho=e=>{let t=I(e);for(;t.parent&&y(t.parent,`MemberExpression`)&&t.parent.object===t;){if(!N(t.parent))return null;t=I(t.parent)}return t},Uo=(e,t,n,r)=>{if(t.length!==n.length+1||!Vo(t,n)||t[n.length]!==`current`)return!1;let i=Ho(e),a=i?.parent;if(!i||!a||!y(a,`AssignmentExpression`)||a.operator!==`=`||a.left!==i)return!1;let o=L(e);if(!o)return!1;if(Bo(o,r))return!0;if(!v(o)||o.async||o.generator)return!1;let s=L(o);if(!s||!Bo(s,r))return!1;let c=I(o),l=c.parent;return!!(y(l,`ReturnStatement`)&&l.argument===c&&L(l)===s||y(s,`ArrowFunctionExpression`)&&s.body===c)},Wo=(e,t)=>{if(!y(e,`JSXOpeningElement`))return!1;let n=e.name;if(y(n,`JSXIdentifier`)){if(!t)return n.name===`Fragment`;let e=P(n,t);return e?Si(e)&&j(e.declarationNode)===`Fragment`:n.name===`Fragment`&&t.isGlobalReference(n)}return y(n,`JSXMemberExpression`)?!y(n.object,`JSXIdentifier`)||n.property.name!==`Fragment`?!1:t?wi(n.object,t)?!0:n.object.name===`React`&&t.isGlobalReference(n.object):n.object.name===`React`:!1},Go=(e,t,n,r,i)=>{let a=I(e),o=a.parent;if(!o)return!1;if(y(o,`ReturnStatement`)&&o.argument===a)return L(o)===t;if(y(o,`ArrowFunctionExpression`)&&o.body===a)return o===t;if(y(o,`JSXFragment`)&&o.children.some(e=>e===a)||y(o,`JSXElement`)&&o.children.some(e=>e===a)&&(Ro(o.openingElement,n)||Wo(o.openingElement,n)||i.doesCustomElementRenderChildren?.(o.openingElement)))return Go(o,t,n,r,i);if(y(o,`JSXExpressionContainer`)&&o.expression===a&&o.parent&&(y(o.parent,`JSXFragment`)||y(o.parent,`JSXElement`)&&(Ro(o.parent.openingElement,n)||Wo(o.parent.openingElement,n)||i.doesCustomElementRenderChildren?.(o.parent.openingElement))))return Go(o.parent,t,n,r,i);if(y(o,`ConditionalExpression`)&&(o.consequent===a||o.alternate===a)||y(o,`LogicalExpression`)&&(o.left===a||o.right===a)||y(o,`ArrayExpression`)&&o.elements.some(e=>e===a))return Go(o,t,n,r,i);if(!y(o,`VariableDeclarator`)||o.init!==a||!y(o.id,`Identifier`))return!1;let s=n.symbolFor(o.id);if(!s||s.kind!==`const`||s.references.length===0||r.has(s.id))return!1;r.add(s.id);let c=s.references.every(e=>e.flag===`read`&&Go(e.identifier,t,n,r,i));return r.delete(s.id),c},Ko=(e,t,n={})=>Go(e,L(e),t,new Set,n),qo=(e,t)=>t.every((t,n)=>e[n]===t),Jo=(e,t)=>qo(e,t)||qo(t,e),Yo=e=>v(e)&&y(e.body,`BlockStatement`)&&e.body.body.length===0,Xo=(e,t,n)=>F(e,t,n,{resolveNamedAliases:!0}),Zo=(e,t,n=new Set)=>y(e,`ObjectExpression`)?e.properties.every(e=>{if(y(e,`SpreadElement`)){let r=I(e.argument);if(y(r,`ObjectExpression`))return Zo(r,t,n);if(!y(r,`Identifier`))return!1;let i=t.symbolFor(r);if(!i||i.kind!==`const`||n.has(i.id)||!y(i.initializer,`ObjectExpression`))return!1;n.add(i.id);let a=Zo(i.initializer,t,n);return n.delete(i.id),a}return y(e,`Property`)?!v(e.value)||Yo(e.value):!1}):!1,Qo=e=>N(e)||(e.computed&&y(e.property,`Literal`)&&typeof e.property.value==`number`&&Number.isSafeInteger(e.property.value)&&e.property.value>=0?String(e.property.value):null),$o=e=>{let t=[],n=I(e);for(;n.parent&&y(n.parent,`MemberExpression`)&&n.parent.object===n;){let e=Qo(n.parent);if(!e)return null;t.push(e),n=I(n.parent)}return{expression:n,propertyPath:t}},es=(e,t,n)=>{let r=n.environmentsByProgram.get(e);if(r)return r;let i={filename:t,program:e,scopes:Ie(e)};return n.environmentsByProgram.set(e,i),i},ts=(e,t,n=new Set)=>{let r=I(e);if(y(r,`Identifier`)){let e=t.symbolFor(r);return!e||!e.initializer||n.has(e.id)||V(e,r,t)?!1:(n.add(e.id),ts(e.initializer,t,n))}if(!y(r,`CallExpression`))return!1;if(Xo(r,`forwardRef`,t))return!0;if(!Xo(r,`memo`,t))return!1;let i=r.arguments[0];return!i||y(i,`SpreadElement`)?!1:ts(i,t,n)},ns=(e,t)=>{let n=es(e.programNode,e.filePath,t),r=zo(e.exportedNode,n.scopes);return r?{environment:n,functionNode:r,isForwardRef:ts(e.exportedNode,n.scopes)}:null},rs=(e,t,n)=>{if(!y(e,`Identifier`)&&!y(e,`JSXIdentifier`))return null;let r=t.scopes.symbolFor(e);if(r&&r.kind!==`import`){if(V(r,e,t.scopes))return null;let n=zo(r.initializer,t.scopes);return n?{environment:t,functionNode:n,isForwardRef:!!(r.initializer&&ts(r.initializer,t.scopes))}:null}let i=Wi(e,e.name);if(!i||i.isNamespace||i.exportedName===null)return null;let a=k(t.filename,i.source,i.exportedName);return a?ns(a,n):null},is=(e,t,n)=>{if(y(e,`JSXIdentifier`))return rs(e,t,n);if(!y(e,`JSXMemberExpression`)||!y(e.object,`JSXIdentifier`))return null;let r=Wi(e.object,e.object.name);if(!r?.isNamespace)return null;let i=k(t.filename,r.source,e.property.name);return i?ns(i,n):null},as=(e,t,n=new Set)=>{let r=I(e);if(y(r,`Identifier`)){let e=t.scopes.symbolFor(r);return!e||!e.initializer||n.has(e.id)||V(e,r,t.scopes)?!1:(n.add(e.id),as(e.initializer,t,n))}return Co(r,t.scopes)},os=(e,t,n)=>{if(!y(e,`JSXIdentifier`))return!1;let r=t.scopes.symbolFor(e);if(r&&r.kind!==`import`)return V(r,e,t.scopes)?!1:!!(r.initializer&&as(r.initializer,t));let i=Wi(e,e.name);if(!i||i.isNamespace||i.exportedName===null)return!1;let a=k(t.filename,i.source,i.exportedName);if(!a)return!1;let o=es(a.programNode,a.filePath,n);return as(a.exportedNode,o)},ss=(e,t)=>{if(!e)return null;let n=I(e);return!y(n,`ClassDeclaration`)&&!y(n,`ClassExpression`)||!as(n,t)?null:{classNode:n,environment:t}},cs=(e,t,n)=>{if(!y(e,`JSXIdentifier`))return null;let r=t.scopes.symbolFor(e);if(r&&r.kind!==`import`)return V(r,e,t.scopes)?null:ss(r.initializer,t);let i=Wi(e,e.name);if(!i||i.isNamespace||i.exportedName===null)return null;let a=k(t.filename,i.source,i.exportedName);if(!a)return null;let o=es(a.programNode,a.filePath,n);return ss(a.exportedNode,o)},ls=(e,t,n)=>{let r=[...t],i=I(e);for(;i.parent;){let e=i.parent;if(y(e,`ArrayExpression`)){if(e.elements.some(e=>e&&y(e,`SpreadElement`)))return null;let t=e.elements.findIndex(e=>e===i);if(t<0)return null;r.unshift(String(t)),i=I(e);continue}if(y(e,`Property`)&&e.value===i){let t=M(e,{allowComputedString:!0}),a=e.parent;if(!t||!a||!Zo(a,n.scopes))return null;r.unshift(t),i=I(a);continue}if(y(e,`ConditionalExpression`)&&(e.consequent===i||e.alternate===i)||y(e,`LogicalExpression`)&&(e.left===i||e.right===i)){i=I(e);continue}if(y(e,`VariableDeclarator`)&&e.init===i&&y(e.id,`Identifier`)){let t=n.scopes.symbolFor(e.id);return!t||t.kind!==`const`?null:{environment:n,propertyPath:r,symbol:t}}if(y(e,`AssignmentExpression`)&&e.operator===`=`&&e.right===i&&y(e.left,`MemberExpression`)){let t=[],i=e.left;for(;y(i,`MemberExpression`);){let e=Qo(i);if(!e)return null;t.unshift(e),i=I(i.object)}if(!y(i,`Identifier`))return null;let a=n.scopes.symbolFor(i);return!a||a.kind!==`const`?null:{environment:n,originWriteReference:i,propertyPath:[...t,...r],symbol:a}}return null}return null},us=(e,t,n,r,i)=>{if(y(e,`AssignmentPattern`))return us(e.left,t,n,r,i);if(y(e,`Identifier`)){let a=n.scopes.symbolFor(e);return!!(a&&Ts({environment:n,propertyPath:t,symbol:a},r,i-1))}if(!y(e,`ObjectPattern`)||t.length===0)return!1;let[a,...o]=t;for(let t of e.properties){if(!y(t,`Property`))continue;let e=M(t,{allowComputedString:!0});if(!e)return!1;if(e===a)return us(t.value,o,n,r,i)}let s=e.properties.find(e=>y(e,`RestElement`));return s?us(s.argument,t,n,r,i):!0},ds=(e,t)=>{let n=e.arguments[0];return!n||y(n,`SpreadElement`)?!1:Xo(e,`createElement`,t.scopes)?y(n,`Literal`)&&typeof n.value==`string`:!Xo(e,`cloneElement`,t.scopes)||!y(n,`JSXElement`)?!1:Ro(n.openingElement,t.scopes)},fs=(e,t,n,r,i)=>{if(t.length>0)return!1;let a=e.parent;if(!a||!y(a,`Property`)||a.value!==e||M(a,{allowComputedString:!0})!==`ref`)return!1;let o=a.parent;if(!o||!y(o,`ObjectExpression`))return!1;let s=o.parent;return!(!s||!y(s,`CallExpression`)||s.arguments[1]!==o||!ds(s,n)||!H(s,n,r,i))},ps=(e,t,n,r,i)=>{if(i<=0||!v(e.functionNode)||e.functionNode.async||e.functionNode.generator)return!1;let a=e.functionNode.params[t];return!!(a&&us(a,n,e.environment,r,i))},ms=e=>{if(!y(e,`MemberExpression`)||N(e)!==`children`)return!1;let t=I(e.object);return!!(y(t,`MemberExpression`)&&N(t)===`props`&&y(I(t.object),`ThisExpression`))},hs=(e,t)=>{if(!y(e,`JSXOpeningElement`)||!y(e.name,`JSXMemberExpression`)||e.name.property.name!==`Provider`||!y(e.name.object,`JSXIdentifier`))return!1;let n=t.scopes.symbolFor(e.name.object);return!!(n?.kind===`const`&&n.initializer&&y(n.initializer,`CallExpression`)&&Xo(n.initializer,`createContext`,t.scopes))},H=(e,t,n,r)=>Ko(e,t.scopes,{doesCustomElementRenderChildren:e=>vs(e,t,n,r-1)}),gs=(e,t,n)=>{let{functionNode:r}=e;if(n<=0||t.activeRenderedChildrenComponents.has(r)||!y(r,`ArrowFunctionExpression`)&&!y(r,`FunctionExpression`)&&!y(r,`FunctionDeclaration`)||r.async||r.generator)return!1;let i=Ni(r,e.environment.scopes);if(!i)return!1;t.activeRenderedChildrenComponents.add(r);let a=i.every(r=>H(r,e.environment,t,n));return t.activeRenderedChildrenComponents.delete(r),a},_s=(e,t,n)=>{let{classNode:r,environment:i}=e;if(n<=0||t.activeRenderedChildrenComponents.has(r)||!y(r,`ClassDeclaration`)&&!y(r,`ClassExpression`))return!1;let a=r.body.body.find(e=>y(e,`MethodDefinition`)&&!e.computed&&y(e.key,`Identifier`)&&e.key.name===`render`);if(!a||!y(a,`MethodDefinition`))return!1;let o=[];if(A(r,e=>{ms(e)&&o.push(e)}),o.length===0)return!1;t.activeRenderedChildrenComponents.add(r);let s=o.every(e=>L(e)===a.value&&H(e,i,t,n));return t.activeRenderedChildrenComponents.delete(r),s},vs=(e,t,n,r)=>{if(r<=0||!y(e,`JSXOpeningElement`))return!1;if(hs(e,t))return!0;let i=is(e.name,t,n);if(i)return gs(i,n,r);let a=cs(e.name,t,n);return!!(a&&_s(a,n,r))},ys=(e,t,n,r,i)=>{let a=bo(e.name),o=e.parent;if(!a||!o||!y(o,`JSXOpeningElement`))return!1;let s=o.parent;if(!s||!y(s,`JSXElement`)||!H(s,n,r,i))return!1;if(Ro(o,n.scopes))return a===`ref`&&t.length===0;if(y(o.name,`JSXIdentifier`)&&a===`ref`&&t.length===0&&os(o.name,n,r))return!0;let c=is(o.name,n,r);return c?a===`ref`&&c.isForwardRef?ps(c,1,t,r,i):ps(c,0,[a,...t],r,i):!1},bs=(e,t,n,r,i,a)=>{let o=e.arguments.findIndex(e=>e===t);if(o<0)return!1;if(o===0&&y(e.callee,`Identifier`)&&e.callee.name===`Boolean`&&r.scopes.isGlobalReference(e.callee))return!0;if(o===0&&Xo(e,`useImperativeHandle`,r.scopes))return n.length===0;if(o===1&&n.length===1&&n[0]===`ref`&&ds(e,r)&&H(e,r,i,a))return!0;let s=I(e.callee);if(v(s))return yo(s,r.scopes)&&!H(e,r,i,a)?!1:ps({environment:r,functionNode:s,isForwardRef:!1},o,n,i,a);if(!y(e.callee,`Identifier`))return!1;let c=rs(e.callee,r,i);return!!(c&&(!yo(c.functionNode,c.environment.scopes)||H(e,r,i,a))&&ps(c,o,n,i,a))},xs=(e,t,n,r,i)=>{let a;if(t.length===1&&t[0]===`ref`)a=e.parent;else if(t.length===0){let t=e.parent;if(!t||!y(t,`Property`)||t.value!==e||M(t,{allowComputedString:!0})!==`ref`)return!1;a=t.parent?.parent}if(!a||!y(a,`JSXSpreadAttribute`))return!1;let o=a.parent;if(!o||!y(o,`JSXOpeningElement`))return!1;let s=o.parent;return!!(Ro(o,n.scopes)&&s&&y(s,`JSXElement`)&&H(s,n,r,i))},Ss=(e,t,n,r,i)=>{let a=I(e),o=a.parent;if(!o)return!1;if(y(o,`ExpressionStatement`)||y(o,`UnaryExpression`)&&o.operator===`void`&&o.argument===a)return!0;if(t.length===0&&y(o,`BinaryExpression`)&&(o.operator===`===`||o.operator===`!==`||o.operator===`==`||o.operator===`!=`)){let e=o.left===a?o.right:o.left;return!!(y(a,`Identifier`)&&y(e,`Identifier`)&&n.scopes.symbolFor(a)?.id===n.scopes.symbolFor(e)?.id)}if(xs(a,t,n,r,i)||fs(a,t,n,r,i)||t.length>0&&(y(o,`LogicalExpression`)&&o.left===a||y(o,`ConditionalExpression`)&&o.test===a||y(o,`IfStatement`)&&o.test===a||y(o,`UnaryExpression`)&&o.operator===`!`&&o.argument===a))return!0;if(y(o,`JSXExpressionContainer`)&&o.expression===a){let e=o.parent;return!!(e&&y(e,`JSXAttribute`)&&ys(e,t,n,r,i))}if(y(o,`CallExpression`))return bs(o,a,t,n,r,i);if(y(o,`VariableDeclarator`)&&o.init===a&&!y(o.id,`Identifier`))return us(o.id,t,n,r,i);let s=ls(a,t,n);return!!(s&&Ts(s,r,i-1))},Cs=e=>{let t=e.parent;return t&&y(t,`VariableDeclarator`)&&t.init===e&&y(t.id,`Identifier`)?t.id:(y(e,`FunctionDeclaration`)||y(e,`FunctionExpression`))&&e.id?e.id:null},ws=(e,t,n)=>{if(!e||!t||!v(e)||e.async||e.generator)return!1;let r=Cs(e);if(!r||((y(e,`FunctionDeclaration`)||y(e,`FunctionExpression`))&&e.id===r?L(e):L(r))!==t)return!1;let i=y(e,`FunctionDeclaration`)?n.ownScopeFor(t)?.symbolsByName.get(r.name):n.symbolFor(r);return!!(i&&i.references.length>0&&i.references.every(e=>{let r=I(e.identifier),i=r.parent;return!!(i&&y(i,`CallExpression`)&&i.callee===r&&L(i)===t&&Ko(i,n))}))},Ts=(e,t,n)=>{if(n<=0)return!1;let r=`${e.environment.filename}:${e.symbol.id}:${e.propertyPath.join(`.`)}`;if(t.activePaths.has(r))return!1;t.activePaths.add(r);let i=L(e.symbol.bindingIdentifier),a=e.symbol.references.every(r=>{if(r.identifier===e.originWriteReference)return!0;let a=r.identifier.parent;if(a&&y(a,`Property`)&&!a.computed&&a.key===r.identifier&&a.value!==r.identifier)return!0;let o=$o(r.identifier);if(!o)return!1;if(!Jo(o.propertyPath,e.propertyPath))return!0;let s=L(r.identifier);if(s!==i&&!ws(s,i,e.environment.scopes))return!!Uo(r.identifier,o.propertyPath,e.propertyPath,e.environment.scopes);if(r.flag!==`read`)return!1;if(qo(o.propertyPath,e.propertyPath)){if(o.propertyPath.length>e.propertyPath.length){let t=o.expression.parent;return!!(o.propertyPath.length===e.propertyPath.length+1&&o.propertyPath[e.propertyPath.length]===`current`&&t&&y(t,`UnaryExpression`)&&t.operator===`void`&&t.argument===o.expression)}return Ss(o.expression,[],e.environment,t,n)}return Ss(o.expression,e.propertyPath.slice(o.propertyPath.length),e.environment,t,n)});return t.activePaths.delete(r),a},Es=(e,t,n)=>{if(!t)return!1;let r=Pi(e);if(!r)return!1;let i={filename:t,program:r,scopes:n},a={activePaths:new Set,activeRenderedChildrenComponents:new WeakSet,environmentsByProgram:new WeakMap([[r,i]])},o=ls(e,[],i);return o?Ts(o,a,12):Ss(e,[],i,a,12)},Ds=e=>{let t=[];for(let n of e)for(let e of n.entries){if(e.importName.kind===`NamespaceObject`)continue;let r=e.importName.kind===`Default`?`default`:e.importName.name??null;r!==null&&t.push({source:n.moduleRequest.value,exportedName:r})}return t},Os=({absoluteFilePath:e,staticImports:t})=>{let n=!1;for(let r of t){let t=r.moduleRequest.value;if(!t.startsWith(`.`))continue;let i=r.entries.filter(e=>!e.isType);if(i.length===0)continue;let a=en(e,t);if(!(!a||!tr(a))){n||(n=!0,At(e));for(let e of i){let t=e.importName.kind===`Default`?`default`:e.importName.name;t&&ji(a,t)}}}},ks=({absoluteFilePath:e})=>{ze.test(e)&&(Ue.test(e)||Ln(e))},As=({absoluteFilePath:e,staticImports:t})=>{if(Be.test(e)&&!Bn(e))for(let n of Ds(t))bn(e,n.source,n.exportedName)},js=({absoluteFilePath:e,staticImports:t})=>{for(let n of Ds(t))bn(e,n.source,n.exportedName)},Ms=({absoluteFilePath:e,staticImports:t})=>{for(let n of Ds(t))Mi(e,n.source,n.exportedName)},Ns=e=>{let t=[];for(let n of e.body??[]){if(n.type!==`ImportDeclaration`)continue;let e=n.source?.value;if(typeof e==`string`){for(let r of n.specifiers??[])if(r.type===`ImportDefaultSpecifier`)t.push({source:e,exportedName:`default`});else if(r.type===`ImportSpecifier`){let n=r.imported,i=null;typeof n?.name==`string`?i=n.name:typeof n?.value==`string`&&(i=n.value),i&&t.push({source:e,exportedName:i})}}}return t},Ps=({absoluteFilePath:e,staticImports:t},n,r=()=>!0,i=()=>!0)=>{let a=new Map,o=(e,t,n)=>{if(!((a.get(e)??-1)>=n)){a.set(e,n);for(let a of Ns(t)){let t=k(e,a.source,a.exportedName);!t||n===0||!r(t)||!i(t.filePath)||o(t.filePath,t.programNode,n-1)}}};for(let a of Ds(t)){let t=k(e,a.source,a.exportedName);!t||!r(t)||!i(t.filePath)||o(t.filePath,t.programNode,n)}},Fs=e=>{Ps(e,4)},Is=({absoluteFilePath:e,sourceText:t,getProgram:n})=>{if(!t.includes(`createRef`)&&!t.includes(`\\u`))return;let r=n();Ft(r);let i=Ie(r);A(r,t=>{!y(t,`CallExpression`)||!F(t,`createRef`,i,{allowGlobalReactNamespace:!0,allowUnboundBareCalls:!0,resolveNamedAliases:!0})||Es(t,e,i)})},Ls=({absoluteFilePath:e,sourceText:t,staticImports:n,getProgram:r})=>{let i=new Set,a=new Set;for(let e of n)if(e.moduleRequest.value===`react`)for(let t of e.entries){let{importName:e}=t;e.kind===`Name`&&e.name===`useReducer`?i.add(t.localName.value):(e.kind===`Default`||e.kind===`NamespaceObject`)&&a.add(t.localName.value)}if(!(i.size>0||a.size>0&&(t.includes(`useReducer`)||t.includes(`\\u`))))return;let o=r(),s=e=>{if(e?.type!==`Identifier`)return null;let{name:t}=e;return typeof t==`string`?t:null},c=e=>{let t=s(e);if(t!==null)return i.has(t);if(e.type!==`MemberExpression`)return!1;let n=e,r=s(n.object);return r!==null&&a.has(r)&&s(n.property)===`useReducer`},l=new Set;if(A(o,e=>{if(e.type!==`CallExpression`)return;let t=e;if(!t.callee||!c(t.callee))return;let n=t.arguments?.[0];if(!n)return;let r=s(O(n));r!==null&&l.add(r)}),l.size!==0)for(let t of n)for(let n of t.entries){if(n.importName.kind===`NamespaceObject`||!l.has(n.localName.value))continue;let r=n.importName.kind===`Default`?`default`:n.importName.name;r&&bn(e,t.moduleRequest.value,r)}},Rs=({absoluteFilePath:e,staticImports:t,getProgram:n})=>{At(e),wn({absoluteFilePath:e,staticImports:t,program:n()})},U=({absoluteFilePath:e})=>{At(e)},zs=e=>{U(e),Ps(e,1/0,e=>v(e.exportedNode),e=>!e.split(/[\\/]/).includes(`node_modules`))},Bs=({absoluteFilePath:e})=>{mr(e)},Vs=({absoluteFilePath:e})=>{br(e)},Hs=e=>{Vs(e),wn({absoluteFilePath:e.absoluteFilePath,staticImports:e.staticImports,program:e.getProgram()})},Us=new Map([...g.map(e=>[e,Vs]),[`ink-no-raw-text`,Hs],[`client-passive-event-listeners`,js],[`exhaustive-deps`,Fs],[`no-barrel-import`,Os],[`nextjs-async-dynamic-api-not-awaited`,U],[`nextjs-missing-metadata`,ks],[`nextjs-no-use-search-params-without-suspense`,As],[`no-dynamic-import-path`,U],[`no-full-lodash-import`,U],[`no-hydration-branch-on-browser-global`,U],[`no-indeterminate-attribute`,U],[`no-locale-format-in-render`,U],[`no-match-media-in-state-initializer`,U],[`no-create-ref-in-function-component`,Is],[`no-adjust-state-on-prop-change`,js],[`no-derived-state`,js],[`no-derived-state-effect`,js],[`no-event-handler`,js],[`no-initialize-state`,js],[`no-mutating-reducer-state`,Ls],[`no-unguarded-browser-global-at-module-scope`,Ms],[`no-unguarded-browser-global-in-render-or-hook-init`,zs],[`prefer-dynamic-import`,U],[`rendering-hydration-mismatch-time`,U],[`rerender-memo-with-default-value`,Fs],[`rn-no-legacy-shadow-styles`,Bs],[`rn-no-raw-text`,Rs],[`rn-prefer-expo-image`,U],[`rn-style-prefer-boxshadow`,Bs],...re.map(e=>[e,U])]),Ws=new Set([`nextjs-no-img-element`,`no-loading-flag-reset-outside-finally`,`only-export-components`,`remotion-calculate-metadata-fetch-signal`,`remotion-deterministic-randomness`,`remotion-no-css-animation`,`remotion-no-css-transition`,`remotion-no-css-url-assets`,`remotion-no-native-media-elements`,`remotion-no-next-image`,`window-open-without-noopener`]),Gs=t=>{let n=new Set;for(let e of t.ruleIds){let t=Us.get(e);if(!t)return null;n.add(t)}let r=Oi(t.absoluteFilePath),i,a;try{let n=e(r,t.sourceText,{astType:`ts`,lang:Lt(r)});if(n.errors.some(e=>e.severity===`Error`))return null;i=n.module.staticImports;let o;a=()=>(o??=n.program,o)}catch{return null}let o={absoluteFilePath:r,sourceText:t.sourceText,staticImports:i,getProgram:a};return mt(()=>{for(let e of n)e(o)})},Ks={},qs=(e,t,n)=>!e||e.length===0?!1:e.every(e=>y(e,t)&&e[n]===`type`),Js=e=>e.importKind===`type`||qs(e.specifiers,`ImportSpecifier`,`importKind`),Ys=new Set([`solid-js`,`solid-js/web`,`solid-js/store`,`solid-js/h`,`solid-js/html`,`@builder.io/qwik`,`@builder.io/qwik-city`,`@builder.io/qwik-react`,`voby`,`vidode`]),Xs=[`solid-js`,`@builder.io/qwik`],Zs=[`react`,`react-dom`,`preact`],Qs=new WeakMap,$s=new WeakMap,ec=(e,t)=>t.some(t=>e===t||e.startsWith(`${t}/`)),tc=e=>{let t=Qs.get(e);if(t)return t;let n=!1,r=!1;for(let t of e.body){if(!y(t,`ImportDeclaration`))continue;let e=t;if(Js(e))continue;let i=e.source,a=i&&typeof i.value==`string`?i.value:null;a&&((Ys.has(a)||ec(a,Xs))&&(n=!0),ec(a,Zs)&&(r=!0))}let i={hasNonReactRuntime:n,hasReactRuntime:r};return Qs.set(e,i),i},nc=e=>{let t=tc(e);return t.hasNonReactRuntime&&!t.hasReactRuntime},rc=e=>{let t=$s.get(e);if(t!==void 0)return t;let n=!1;for(let t of e.attributes){if(!y(t,`JSXAttribute`)||!y(t.name,`JSXIdentifier`))continue;let e=t.name.name;if(e===`classList`||e.startsWith(`class:`)||e.startsWith(`bind:`)){n=!0;break}}return $s.set(e,n),n},ic=`/test/,/tests/,/testing/,/__tests__/,/__test__/,/__fixtures__/,/fixtures/,/__mocks__/,/mocks/,/testUtils/,/test-utils/,/testutils/,/cypress/,/playwright/,/.storybook/,/.dumi/,/stories/,/__stories__/,/playground/,/playgrounds/,/examples/,/example/,/demo/,/demos/,/sandbox/,/sandboxes/,/e2e/,/e2e-tests/,/specs/,/spec/,/integration-tests/,/integration/,/it/,/benchmarks/,/benchmark/,/__benchmarks__/,/perf/,/perf-tests/,/scripts/,/cli/,/bin/,/tooling/,/tools/,/codemods/,/codemod/,/migrations/,/migration/,/generators/,/generator/,/runbooks/,/devtools/,/internal-tools/,/seeds/,/seed/,/dev-seeder/`.split(`,`),ac=[`.test.`,`.spec.`,`.cy.`,`.stories.`,`.story.`,`.bench.`,`.benchmark.`,`.e2e.`,`.integration-spec.`,`.int-spec.`,`.mock.`,`.mocks.`,`.fixture.`],oc=new Set(`setuptests.js,setuptests.ts,setuptests.jsx,setuptests.tsx,setupvitest.js,setupvitest.ts,setupvitest.jsx,setupvitest.tsx,setupjest.js,setupjest.ts,vitest.setup.js,vitest.setup.ts,vitest.setup.mjs,vitest.config.ts,vitest.config.js,vitest.config.mts,vitest.config.mjs,jest.setup.js,jest.setup.ts,jest.setup.jsx,jest.setup.tsx,jest.config.js,jest.config.ts,jest.config.mjs,playwright.config.ts,playwright.config.js,cypress.config.ts,cypress.config.js,karma.conf.js,karma.conf.ts,vite.config.ts,vite.config.js,vite.config.mts,vite.config.mjs,webpack.config.ts,webpack.config.js,webpack.config.mjs,rollup.config.ts,rollup.config.js,rollup.config.mjs,esbuild.config.ts,esbuild.config.js,esbuild.config.mjs,tsup.config.ts,tsup.config.js,tsup.config.mjs,rsbuild.config.ts,rsbuild.config.js,rspack.config.ts,rspack.config.js,next.config.ts,next.config.js,next.config.mjs,remix.config.js,remix.config.ts,astro.config.ts,astro.config.js,astro.config.mjs,tailwind.config.ts,tailwind.config.js,tailwind.config.mjs,postcss.config.ts,postcss.config.js,postcss.config.mjs,biome.config.ts,biome.config.js,drizzle.config.ts,drizzle.config.js,prisma.config.ts,prisma.config.js,knip.config.ts,knip.config.js,knip.config.mjs,lint-staged.config.js,lint-staged.config.mjs`.split(`,`)),sc=[`/src/`,`/app/`,`/lib/`,`/components/`,`/pages/`,`/features/`,`/modules/`,`/packages/`,`/apps/`,`/frontend/`,`/client/`],cc=ic.filter(e=>e.startsWith(`/.`)),lc=e=>{let t=-1;for(let n of sc){let r=e.lastIndexOf(n);r>t&&(t=r)}return t<0?e:e.slice(t)};let uc,dc=!1;const fc=e=>e?e===uc?dc:(uc=e,dc=mc(e),dc):!1,pc=(e,t)=>e?mc(e,t):!1,mc=(e,t=new Set)=>{let n=e.replaceAll(`\\`,`/`),r=n.lastIndexOf(`/`),i=r===-1?n:n.slice(r+1);if(oc.has(i.toLowerCase()))return!0;for(let e of ac)if(i.includes(e))return!0;let a=n.startsWith(`/`)?n:`/${n}`;for(let e of cc)if(!t.has(e)&&a.includes(e))return!0;let o=lc(n);for(let e of ic)if(!t.has(e)&&(e.startsWith(`/.`)?n:o).includes(e))return!0;return!1},hc=e=>t=>fc(t.filename)?Ks:e(t),gc=e=>(t=>{let n=e(t),r=!1,i=!1,a={};for(let e in n){if(!Object.hasOwn(n,e))continue;let t=n[e];if(typeof t!=`function`){a[e]=t;continue}let o=e.charAt(0);if(o<`A`||o>`Z`){a[e]=t;continue}if(e===`Program`){a.Program=e=>{let n=tc(e);i=n.hasReactRuntime,r=n.hasNonReactRuntime&&!n.hasReactRuntime,t(e)};continue}if(e===`JSXOpeningElement`){a.JSXOpeningElement=e=>{!i&&!r&&rc(e)&&(r=!0),!r&&t(e)};continue}a[e]=(...e)=>{r||t(...e)}}return`Program`in a||(a.Program=e=>{let t=tc(e);i=t.hasReactRuntime,r=t.hasNonReactRuntime&&!t.hasReactRuntime}),a}),W=e=>{if(!(`create`in e))return{...e,create:()=>Ks};let t=e.tags,n=e.create,r=t?.includes(`test-noise`)&&!t?.includes(`migration-hint`);return t?.includes(`react-jsx-only`)&&(n=gc(n)),r&&(n=hc(n)),n===e.create?e:{...e,create:n}};let _c;const vc=e=>{let t=[0];for(let n=0;n<e.length;n+=1){let r=e[n];if(r===`\r`&&e[n+1]===`
|
|
3
3
|
`){n+=1,t.push(n+1);continue}(r===`\r`||r===`
|
|
4
4
|
`||r===`\u2028`||r===`\u2029`)&&t.push(n+1)}return t},yc=e=>{if(_c?.content===e)return _c.lineStartOffsets;let t=vc(e);return _c={content:e,lineStartOffsets:t},t},G=(e,t)=>{if(Number.isNaN(t)||t<0)return{line:1,column:1};let n=yc(e),r=Math.min(Math.trunc(t),e.length),i=0,a=n.length-1;for(;i<a;){let e=i+a+1>>1;n[e]<=r?i=e:a=e-1}return{line:i+1,column:r-n[i]+1}},bc=(e,t)=>G(e,e.search(t)),xc=/\.(?:[cm]?[jt]sx?|json|jsonc|map|html?|mdx?|ya?ml|toml|sql|rules|env|txt|log|svg|xml|pem|key|crt|cert|pub|py|php)$/i,Sc=/(?:^|\/)\.env(?:\.|$)/,Cc=/\.(?:[cm]?[jt]sx?)$/i,wc=/\.(?:[cm]?[jt]sx?|py|php)$/i,Tc=/\.(?:[cm]?[jt]sx?|py)$/i,Ec=/(?:^|\/)(?:api|backend|server|servers|middleware|route|routes|functions|lambdas|workers)(?:\/|$)|(?:^|\/)[^/]+\.server\.[cm]?[jt]sx?$/i,Dc=/(?:^|\/)(?:__fixtures__|__mocks__|__tests__|__integration__|fixtures|mocks|test|tests|testdata|test-data|e2e|playwright|cypress|specs?)(?:\/|$)|^(?:test|spec)-[^/]+\.[cm]?[jt]sx?$|\.(?:test|spec|e2e|e2e-spec|integration-test|fixture|fixtures|stories|story)\.[cm]?[jt]sx?$|(?:^|\/)(?:playwright|cypress|vitest|jest|karma)[^/]*\.conf(?:ig)?\.[cm]?[jt]s$|(?:^|\/)(?:test_[^/]+|[^/]+_test|conftest)\.py$|\.env\.[^/]*(?:test|e2e)[^/]*$/i,Oc=/(?:^|\/)(?:vite|next|nuxt|astro|remix|webpack|rollup|rspack|rsbuild|esbuild|tsup|metro|expo|babel|tailwind|postcss|svelte|farm|parcel|snowpack)[^/]*\.config\.[cm]?[jt]sx?$/i,kc=/(?:^|\/)scripts(?:\/|$)/i,Ac=/(?:^|\/)(?:examples?|tutorials?|demos?|samples?|playgrounds?)(?:\/|$)/i,jc=/(?:^|\/)(?:README|CHANGELOG|CONTRIBUTING|PUBLISHING|DOCS)\.mdx?$|\.mdx?$/i,Mc=/(?:^|\/)(?:generated|__generated__|dist|build|coverage|out|storybook-static|vendor|vendors|third[-_]?party|libraries)(?:\/|$)|(?:^|\/)\.next\/|(?:^|\/)\.yarn\/|(?:^|\/)public\/(?:chunks?|assets?|build|dist|static)\/|(?:generated|\.gen)\.[cm]?[jt]sx?$|@\d+\.\d+\.\d+(?:[-.][\w.]+)?\.[cm]?js$|[.-]min\.[cm]?js$|\.asm\.js$|(?:^|\/)[\w-]+[.@-]\d+\.\d+\.\d+(?:[-.][\w.]+)?\//i,Nc=/\.(iife|umd|global|min)\.js$/i,Pc=[/(?:^|\/)\.next\/static\//,/(?:^|\/)\.output\/public\//,/(?:^|\/)build\/static\//,/(?:^|\/)dist\/assets\//,/(?:^|\/)public\//,/(?:^|\/)out\//,/(?:^|\/)storybook-static\//],Fc=/\b(?:exec|execSync|spawn|child_process|eval|new Function|vm\.run|readFile|writeFile|fs\.read|fs\.write|fetch|axios|http\.request|sandbox|runCode|executeCode)\b/,Ic=new Set([`.next`,`.output`]),Lc=e=>{let t=e.split(`/`);for(let e=0;e<t.length;e+=1)if(Ic.has(t[e])&&(t[e]===`.next`&&t[e+1]===`dev`||t[e+1]===`server`&&e+2<t.length))return!0;return!1},Rc=(e,t)=>Lc(e)?!1:t||e.endsWith(`.map`)?!0:Pc.some(t=>t.test(e)),zc=e=>/(?:^|\/)(?:package\.json|Dockerfile|docker-compose\.ya?ml|\.github\/workflows\/[^/]+\.ya?ml|vercel\.json|next\.config\.[cm]?[jt]s|netlify\.toml)$/i.test(e),Bc=new Map,Vc=(e,t)=>{let n=Bc.get(t);n||(n=new Map,Bc.set(t,n));let r=n.get(e);if(r!==void 0)return r;let i=t.test(e)&&!Dc.test(e)&&!kc.test(e)&&!jc.test(e)&&!Mc.test(e);return n.set(e,i),i},K=e=>/\.d\.[cm]?[jt]s$/i.test(e)?!1:Vc(e,Cc),Hc=/<script\b|on(?:load|error|click|mouseover)\s*=/i,Uc=/dangerouslyAllowSVG\s*:\s*true/i,Wc=/<(?:object|embed|iframe)\b[^>]+(?:data|src)=["'][^"']+\.svg(?:\?[^"']*)?["']/i,Gc=W({id:`active-static-asset`,title:`Executable SVG exposure`,severity:`warn`,recommendation:"Prefer `<img>` for SVG images; if SVG must be served directly, use attachment disposition and a CSP that blocks scripts and objects.",scan:e=>{let t=[];if(e.relativePath.endsWith(`.svg`)&&Rc(e.relativePath,e.isGeneratedBundle)){if(Hc.test(e.content)){let n=bc(e.content,Hc);t.push({message:`A browser-reachable SVG contains script or event-handler code.`,line:n.line,column:n.column,severity:`error`,title:`Active SVG in public assets`,help:`Serve untrusted SVG as downloads, sanitize it, or isolate it on a cookieless asset origin with a restrictive CSP.`})}return t}if(!K(e.relativePath)&&!zc(e.relativePath))return t;let n=[Uc,Wc].find(t=>t.test(e.content));if(n!==void 0){let r=bc(e.content,n);t.push({message:`The app enables or embeds SVG in an executable browser context.`,line:r.line,column:r.column})}return t}}),Kc=e=>/(?:^|\/)(?:firestore\.rules|storage\.rules|database\.rules\.json)$/.test(e),qc=/\s/,Jc=/[\p{ID_Continue}$]/u,Yc=new Set([`return`,`typeof`,`case`,`in`,`of`,`new`,`delete`,`void`,`instanceof`,`do`,`else`,`yield`,`await`,`throw`]),Xc=(e,t,n)=>{let r=n-1;for(;r>=0&&qc.test(t[r]);)--r;if(r<0)return!0;let i=t[r],a=r>0?t[r-1]:``;if(Jc.test(i)){let n=r;for(;n>0&&Jc.test(t[n-1]);)--n;return n>0&&t[n-1]===`.`?!1:Yc.has(e.slice(n,r+1))}return i===`<`?!1:i===`>`?a===`=`:i===`+`||i===`-`?a!==i:i===`!`?!(Jc.test(a)||a===`)`||a===`]`):!(i===`)`||i===`]`||i===`}`||i===`"`||i===`'`||i==="`")},Zc=(e,t)=>{let n=t+1,r=!1;for(;n<e.length;){let t=e[n];if(t===`\\`){n+=2;continue}if(t===`
|
|
5
5
|
`)return null;if(t===`[`)r=!0;else if(t===`]`)r=!1;else if(t===`/`&&!r)return e[n+1]===`/`?null:n+1;n+=1}return null},Qc=(e,t,n)=>{for(let r=t+1;r<e.length;r+=1){let t=e[r];if(t===`\\`){r+=1;continue}if(t===n)return!1;if(qc.test(t))return!0}return!1},$c=(e,t)=>{let n=null,r=null,i=!1,a=[],o=0,s=t=>{t>=e.length||e[t]===`
|
|
6
6
|
`||(n??=e.split(``),n[t]=` `)};for(;o<e.length;){let c=e[o],l=e[o+1];if(r!==null){if(c===`\\`){i&&(s(o),s(o+1)),o+=2;continue}if(c===`
|
|
7
7
|
`&&r!=="`"){r=null,o+=1;continue}if(c===r){r=null,o+=1;continue}if(t&&r==="`"&&c===`$`&&l===`{`){a.push(0),r=null,o+=2;continue}i&&s(o),o+=1;continue}if(c===`"`||c===`'`){r=c,i=t&&Qc(e,o,c),o+=1;continue}if(c==="`"){r="`",i=t,o+=1;continue}if(c===`/`&&l===`/`){for(n??=e.split(``);o<e.length&&e[o]!==`
|
|
8
|
-
`;)n[o]=` `,o+=1;continue}if(c===`/`&&l===`*`){for(n??=e.split(``);o<e.length;){if(e[o]===`*`&&e[o+1]===`/`){n[o]=` `,n[o+1]=` `,o+=2;break}s(o),o+=1}continue}if(c===`/`){let r=Xc(e,n??e,o)?Zc(e,o):null;if(r!==null){if(t)for(let e=o+1;e<r-1;e+=1)s(e);o=r;continue}}if(a.length>0){let e=a.length-1;c===`{`?a[e]+=1:c===`}`&&(a[e]===0?(a.pop(),r="`",i=t):--a[e])}o+=1}return n?.join(``)??e},el=e=>e.includes(`//`)||e.includes(`/*`)?$c(e,!1):e,tl=e=>$c(e,!0),nl=new WeakMap,rl=new WeakMap,il=(e,t=!1)=>{if(!Cc.test(e.relativePath)&&!Kc(e.relativePath))return e.content;let n=t?rl:nl,r=n.get(e);if(r!==void 0)return r;let i=t?tl(e.content):el(e.content);return n.set(e,i),i},q=({shouldScan:e,pattern:t,requireAll:n,suppressWhen:r,ignoreStringLiterals:i,message:a})=>o=>{if(!e(o))return[];let s=il(o,i);if(n!==void 0&&!n.every(e=>e.test(s)))return[];let c=-1;if(t instanceof RegExp)c=s.search(t);else for(let e=0;e<t.length&&(c=s.search(t[e]),!(c>=0));e+=1);if(c<0||r!==void 0&&r.test(s))return[];let{line:l,column:u}=G(s,c);return[{message:a,line:l,column:u}]},al=/\b(?:tool\s*\(\s*\{|createTool\s*\(|defineTool\s*\(|new\s+(?:DynamicTool|StructuredTool)\s*\()/,ol=/\b(?:tool|createTool|defineTool|DynamicTool|StructuredTool)\b/,sl=/(?:^|\/)(?:agents?|tools?|mcp)(?:\/|$)|(?:agent|tool|mcp)[^/]*\.[cm]?[jt]sx?$/i,cl=W({id:`agent-tool-capability-risk`,title:`Agent tool exposes dangerous capability`,severity:`warn`,recommendation:`Treat tool inputs as prompt-injection controlled. Validate arguments, scope permissions per call, and avoid exposing shell/file/network primitives directly to agents.`,scan:q({shouldScan:e=>K(e.relativePath)&&sl.test(e.relativePath)&&ol.test(e.content)&&Fc.test(e.content),pattern:al,requireAll:[Fc],ignoreStringLiterals:!0,message:`An agent-callable tool appears to expose network, filesystem, shell, or code-execution capability.`})}),ll=W({id:`artifact-baas-authority-surface`,title:`BaaS authority map shipped in browser artifact`,severity:`warn`,recommendation:`Client BaaS config is often public, but shipped collection names plus owner, role, tenant, or admin fields give attackers a precise authorization map. Verify rules/RLS enforce every boundary server-side.`,scan:q({shouldScan:e=>Rc(e.relativePath,e.isGeneratedBundle),pattern:/\b(?:collection\s*\(\s*["'](?:boosts|sessions|sessions_admin|users|orgs|candidateJobs|conversations|documents|profiles)|from\s*\(\s*["'](?:users|profiles|documents|organizations|memberships)|creatorID|creatorId|providerId|ghostOrg|ownerId|orgId|tenantId|workspaceId|isAdmin|SuperAdmin)\b/i,requireAll:[/\b(?:initializeApp|firebase|firestore|getFirestore)\b[\s\S]{0,700}\b(?:apiKey|authDomain|projectId|databaseURL|storageBucket)\b|\b(?:apiKey|authDomain|projectId|databaseURL|storageBucket)\b[\s\S]{0,700}\b(?:firebase|firestore|getFirestore|initializeApp)\b|\bcreateClient\b[\s\S]{0,700}\b(?:supabase|SUPABASE_URL)\b|\b(?:supabase|SUPABASE_URL)\b[\s\S]{0,700}\bcreateClient\b/i],message:`A browser artifact exposes Firebase/Supabase config together with sensitive collections or authorization fields.`})}),ul=new Set([`auth`,`getSession`,`getServerSession`,`getUser`,`requireAuth`,`checkAuth`,`verifyAuth`,`authenticate`,`currentUser`,`getAuth`,`validateSession`]),dl=/^auth(?:n|z|ed|enticate[ds]?|enticating|entication|orize[ds]?|orizing|orization|orizer)?$/,fl=new Set([`signedin`,`loggedin`,`signin`]),pl=new Set([`require`,`ensure`,`assert`,`verify`,`validate`,`check`,`protect`,`enforce`,`guard`,`gate`,`restrict`,`is`,`has`,`can`,`must`]),ml=new Set([`get`,`fetch`,`load`,`read`,`resolve`,`retrieve`,`use`]),hl=new Set([`current`,`my`,`own`]),gl=new Set([`session`,`sessions`,`login`,`admin`,`admins`,`superadmin`,`superuser`,`role`,`roles`,`permission`,`permissions`,`jwt`,`identity`,`principal`,`credential`,`credentials`]),_l=new Set([`user`,`users`,`account`,`accounts`,`token`,`tokens`,`access`,`me`,`viewer`,`caller`,`subject`,`scope`,`scopes`]),vl=new Set([`getUser`]),yl=/(?:^|[._])(?:auth|authn|authz|clerk|session|jwt|firebase|supabase|nextauth|kinde|workos|stytch|descope|cognito|propelauth|lucia)/i,bl=[/^sk_live_/,/^sk_test_/,/^AKIA[0-9A-Z]{16}$/,/^ghp_[a-zA-Z0-9]{36}$/,/^gho_[a-zA-Z0-9]{36}$/,/^github_pat_/,/^glpat-/,/^xox[bporas]-/,/^sk-[a-zA-Z0-9]{32,}$/],xl=[/\b(?:AKIA|ASIA)[0-9A-Z]{16}\b/,/\bAWS_SECRET_ACCESS_KEY\s*[:=]\s*["']?[A-Za-z0-9/+=]{35,}["']?/,/\bgithub_pat_[A-Za-z0-9_]{30,}\b/,/\bgh[pousr]_[A-Za-z0-9]{30,}\b/,/\bglpat-[A-Za-z0-9_-]{20,}\b/,/\bxox[baprs]-[A-Za-z0-9-]{20,}\b/,/\bsk_(?:live|test)_[A-Za-z0-9]{16,}\b/,/\brk_(?:live|test)_[A-Za-z0-9]{16,}\b/,/\bsk-[A-Za-z0-9_-]{32,}\b/,/\bsk-ant-api\d{2}-[A-Za-z0-9_-]{20,}\b/,/\blin_(?:api|oauth)_[A-Za-z0-9]{20,}\b/,/\bvercel_[A-Za-z0-9]{20,}\b/,/\bsntrys_[A-Za-z0-9_-]{20,}\b/,/\bkey-[a-f0-9]{32}\b/i,/\bnpm_[A-Za-z0-9]{30,}\b/,/\bSG\.[A-Za-z0-9_-]{20,}\.[A-Za-z0-9_-]{20,}\b/,/https:\/\/hooks\.slack\.com\/services\/T[A-Z0-9]+\/B[A-Z0-9]+\/[A-Za-z0-9]+/,/https:\/\/discord(?:app)?\.com\/api\/webhooks\/\d+\/[A-Za-z0-9_-]+/,/\bsb_secret_[A-Za-z0-9_]{20,}\b/,/\bservice_role\b/i,/"private_key"\s*:\s*"-----BEGIN PRIVATE KEY-----/,/-----BEGIN (?:RSA |EC |OPENSSH |DSA )?PRIVATE KEY-----/,/\b(?:postgres|mysql|mongodb(?:\+srv)?|redis):\/\/[^:\s/@]+:(?!(?:pass(?:word)?|my[a-z]*pass(?:word)?|mysecretpassword|myusername|postgres|mysql|redis|root|admin|minioadmin|secret|example|changeme|change_me|test|guest|placeholder|default|user(?:name)?|x{3,}|\*{2,}|\$\{[^}]*\}|\$[A-Z_]+|<[^>]*>|%[\w.]+%|\{\{[^}]*\}\})@)[^@\s/]+@(?!(?:localhost|127\.0\.0\.1|0\.0\.0\.0|host\.docker\.internal)(?:[:/\s]|$))[^\s:/@]*\./i],Sl=/\beyJ[A-Za-z0-9_-]{8,}\.eyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{16,}\b/,Cl=/\b(?:NEXT_PUBLIC|VITE|REACT_APP|EXPO_PUBLIC)_[A-Z0-9_]*(?:SECRET|TOKEN|PASSWORD|PRIVATE|DATABASE_URL|SERVICE_ROLE|AWS_ACCESS_KEY|AWS_SECRET)[A-Z0-9_]*\b/i,wl=/\b(?:process\s*\.\s*env|import\s*\.\s*meta\s*\.\s*env|window\.__[A-Z0-9_]*ENV[A-Z0-9_]*__|__[A-Z0-9_]*ENV[A-Z0-9_]*__)\b/,Tl=/\b(?:(?:process|window)\s*(?:\/[*/]|<!--|-->|\.\s*(?:\/[*/]|<!--|-->))|import\s*(?:\/[*/]|<!--|-->|\.\s*(?:\/[*/]|<!--|-->|meta\s*(?:\/[*/]|<!--|-->|\.\s*(?:\/[*/]|<!--|-->)))))/,El=/\b(?:DATABASE_URL|AWS_SECRET_ACCESS_KEY|AWS_ACCESS_KEY_ID|MAILGUN_API_KEY|SALESFORCE_CLIENT_SECRET|OKTA_CLIENT_SECRET|SESSION_SECRET|COOKIE_SECRET|PRIVATE_KEY|SERVICE_ROLE)\b/,Dl=/(?:SENTRY_DSN|PUBLIC_KEY|PUBLISHABLE|ANON_KEY|POSTHOG_(?:PROJECT_)?TOKEN|POSTHOG_KEY|TLDRAW_LICENSE_KEY|CLERK_PUBLISHABLE_KEY|ALGOLIA_SEARCH_KEY|GC_API_KEY|GOOGLE_MAPS_API_KEY|MAPBOX_TOKEN|MIXPANEL_TOKEN|FACEBOOK_CLIENT_TOKEN|(?:NEXT_PUBLIC|VITE|REACT_APP|EXPO_PUBLIC)_(?:DISABLE|ENABLE|ALLOW|REQUIRE)_)|(?:TOKEN|SECRET|PASSWORD|PRIVATE)_(?:KIND|TYPE|URL|URI|ENDPOINT|HEADER|NAME)$/i,Ol=[/^appl_/,/^goog_/,/^amzn_/,/^strp_/,/^pk_(?:live|test)_/,/^sb_publishable_/,/^phc_/,/^public-token-(?:live|test)-/,/^pk\.eyJ/],kl=[/^[\s._\-*\u2022xX]{8,}$/,/(?:\.{3,}|\u2026|[*\u2022]{3,})/,/(?:^|[_\-\s])(?:your|redacted|masked|placeholder|replace[_\-\s]?me|changeme)(?:$|[_\-\s])/i,/<[^>]*(?:auth|credential|key|password|secret|token|your|redacted|placeholder|masked)[^>]*>/i,/\[[^\]]*(?:auth|credential|key|password|secret|token|your|redacted|placeholder|masked)[^\]]*\]/i,/\{[^}]*(?:auth|credential|key|password|secret|token|your|redacted|placeholder|masked)[^}]*\}/i],Al=[/(?:^|[_\-\s])(?:example|sample|dummy)(?:$|[_\-\s])/i],jl=/(?:placeholder|example|sample|dummy|masked|redacted|mask)/i,Ml=/(?:api_?key|secret|token|password|credential|auth(?!or(?!i[sz])))/i,Nl=/(?:^|\/)[^/]+\.config\.[cm]?[jt]s$/,Pl=/(?:^|\/)(?:\.[a-z-]+rc|[a-z-]+\.rc)\.[cm]?[jt]s$/,Fl=/(?:^|\/)[^/]+\.(?:test|spec|stories|story|fixture|fixtures)\.[cm]?[jt]sx?$/,Il=/(?:^|\/)[^/]+\.server\.[cm]?[jt]sx?$/,Ll=/(?:^|\/)(?:middleware|proxy|route)\.[cm]?[jt]sx?$/,Rl=/(?:^|\/)pages\/api\/.+\.[cm]?[jt]sx?$/,zl=/(?:^|\/)[^/]+\.(?:client|browser|web)\.[cm]?[jt]sx?$/,Bl=/(?:^|\/)(?:src\/)?(?:main|index|[Aa]pp|client)\.[cm]?[jt]sx?$/,Vl=new Set([`backend`,`functions`,`lambdas`,`lambda`,`middleware`,`server`,`servers`]),Hl=new Set([`api`,`backend`,`edge`,`function`,`functions`,`lambda`,`lambdas`,`server`,`servers`,`worker`,`workers`]),Ul=new Set([`__fixtures__`,`__mocks__`,`__tests__`,`fixtures`,`mocks`,`test`,`tests`]),Wl=new Set([`bin`,`config`,`configs`,`script`,`scripts`,`tooling`,`tools`]),Gl=new Set([`components`,`features`,`hooks`,`pages`,`ui`,`views`,`widgets`]),Kl=new Set(`modal.label.text.title.name.id.url.path.route.page.param.field.column.header.placeholder.prefix.description.type.icon.class.style.variant.event.action.status.state.mode.flag.option.config.message.error.display.view.component.element.container.wrapper.button.link.input.select.dialog.menu.form.step.index.count.length.role.scope.context.provider.ref.handler.query.schema.constant`.split(`.`)),J=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),
|
|
9
|
-
`,`\u2028`,`\u2029`])
|
|
10
|
-
`),n=[],r=[],i,a,o;for(let e=0;e<t.length;e+=1){let s=t[e],c=s.trim();if(c===``||c.startsWith(`#`))continue;let l=s.length-s.trimStart().length;if(i!==void 0&&l<=i&&(i=void 0,a=void 0,o=void 0),i===void 0){/^steps:\s*(?:#.*)?$/.test(c)?i=l:n.push(s);continue}if((c===`-`||c.startsWith(`- `))&&(a===void 0||l===a)){a=l,o={startLineIndex:e,lines:[s]},r.push(o);continue}o===void 0?n.push(s):o.lines.push(s)}let s=
|
|
8
|
+
`;)n[o]=` `,o+=1;continue}if(c===`/`&&l===`*`){for(n??=e.split(``);o<e.length;){if(e[o]===`*`&&e[o+1]===`/`){n[o]=` `,n[o+1]=` `,o+=2;break}s(o),o+=1}continue}if(c===`/`){let r=Xc(e,n??e,o)?Zc(e,o):null;if(r!==null){if(t)for(let e=o+1;e<r-1;e+=1)s(e);o=r;continue}}if(a.length>0){let e=a.length-1;c===`{`?a[e]+=1:c===`}`&&(a[e]===0?(a.pop(),r="`",i=t):--a[e])}o+=1}return n?.join(``)??e},el=e=>e.includes(`//`)||e.includes(`/*`)?$c(e,!1):e,tl=e=>$c(e,!0),nl=new WeakMap,rl=new WeakMap,il=(e,t=!1)=>{if(!Cc.test(e.relativePath)&&!Kc(e.relativePath))return e.content;let n=t?rl:nl,r=n.get(e);if(r!==void 0)return r;let i=t?tl(e.content):el(e.content);return n.set(e,i),i},q=({shouldScan:e,pattern:t,requireAll:n,suppressWhen:r,ignoreStringLiterals:i,message:a})=>o=>{if(!e(o))return[];let s=il(o,i);if(n!==void 0&&!n.every(e=>e.test(s)))return[];let c=-1;if(t instanceof RegExp)c=s.search(t);else for(let e=0;e<t.length&&(c=s.search(t[e]),!(c>=0));e+=1);if(c<0||r!==void 0&&r.test(s))return[];let{line:l,column:u}=G(s,c);return[{message:a,line:l,column:u}]},al=/\b(?:tool\s*\(\s*\{|createTool\s*\(|defineTool\s*\(|new\s+(?:DynamicTool|StructuredTool)\s*\()/,ol=/\b(?:tool|createTool|defineTool|DynamicTool|StructuredTool)\b/,sl=/(?:^|\/)(?:agents?|tools?|mcp)(?:\/|$)|(?:agent|tool|mcp)[^/]*\.[cm]?[jt]sx?$/i,cl=W({id:`agent-tool-capability-risk`,title:`Agent tool exposes dangerous capability`,severity:`warn`,recommendation:`Treat tool inputs as prompt-injection controlled. Validate arguments, scope permissions per call, and avoid exposing shell/file/network primitives directly to agents.`,scan:q({shouldScan:e=>K(e.relativePath)&&sl.test(e.relativePath)&&ol.test(e.content)&&Fc.test(e.content),pattern:al,requireAll:[Fc],ignoreStringLiterals:!0,message:`An agent-callable tool appears to expose network, filesystem, shell, or code-execution capability.`})}),ll=W({id:`artifact-baas-authority-surface`,title:`BaaS authority map shipped in browser artifact`,severity:`warn`,recommendation:`Client BaaS config is often public, but shipped collection names plus owner, role, tenant, or admin fields give attackers a precise authorization map. Verify rules/RLS enforce every boundary server-side.`,scan:q({shouldScan:e=>Rc(e.relativePath,e.isGeneratedBundle),pattern:/\b(?:collection\s*\(\s*["'](?:boosts|sessions|sessions_admin|users|orgs|candidateJobs|conversations|documents|profiles)|from\s*\(\s*["'](?:users|profiles|documents|organizations|memberships)|creatorID|creatorId|providerId|ghostOrg|ownerId|orgId|tenantId|workspaceId|isAdmin|SuperAdmin)\b/i,requireAll:[/\b(?:initializeApp|firebase|firestore|getFirestore)\b[\s\S]{0,700}\b(?:apiKey|authDomain|projectId|databaseURL|storageBucket)\b|\b(?:apiKey|authDomain|projectId|databaseURL|storageBucket)\b[\s\S]{0,700}\b(?:firebase|firestore|getFirestore|initializeApp)\b|\bcreateClient\b[\s\S]{0,700}\b(?:supabase|SUPABASE_URL)\b|\b(?:supabase|SUPABASE_URL)\b[\s\S]{0,700}\bcreateClient\b/i],message:`A browser artifact exposes Firebase/Supabase config together with sensitive collections or authorization fields.`})}),ul=new Set([`auth`,`getSession`,`getServerSession`,`getUser`,`requireAuth`,`checkAuth`,`verifyAuth`,`authenticate`,`currentUser`,`getAuth`,`validateSession`]),dl=/^auth(?:n|z|ed|enticate[ds]?|enticating|entication|orize[ds]?|orizing|orization|orizer)?$/,fl=new Set([`signedin`,`loggedin`,`signin`]),pl=new Set([`require`,`ensure`,`assert`,`verify`,`validate`,`check`,`protect`,`enforce`,`guard`,`gate`,`restrict`,`is`,`has`,`can`,`must`]),ml=new Set([`get`,`fetch`,`load`,`read`,`resolve`,`retrieve`,`use`]),hl=new Set([`current`,`my`,`own`]),gl=new Set([`session`,`sessions`,`login`,`admin`,`admins`,`superadmin`,`superuser`,`role`,`roles`,`permission`,`permissions`,`jwt`,`identity`,`principal`,`credential`,`credentials`]),_l=new Set([`user`,`users`,`account`,`accounts`,`token`,`tokens`,`access`,`me`,`viewer`,`caller`,`subject`,`scope`,`scopes`]),vl=new Set([`getUser`]),yl=/(?:^|[._])(?:auth|authn|authz|clerk|session|jwt|firebase|supabase|nextauth|kinde|workos|stytch|descope|cognito|propelauth|lucia)/i,bl=[/^sk_live_/,/^sk_test_/,/^AKIA[0-9A-Z]{16}$/,/^ghp_[a-zA-Z0-9]{36}$/,/^gho_[a-zA-Z0-9]{36}$/,/^github_pat_/,/^glpat-/,/^xox[bporas]-/,/^sk-[a-zA-Z0-9]{32,}$/],xl=[/\b(?:AKIA|ASIA)[0-9A-Z]{16}\b/,/\bAWS_SECRET_ACCESS_KEY\s*[:=]\s*["']?[A-Za-z0-9/+=]{35,}["']?/,/\bgithub_pat_[A-Za-z0-9_]{30,}\b/,/\bgh[pousr]_[A-Za-z0-9]{30,}\b/,/\bglpat-[A-Za-z0-9_-]{20,}\b/,/\bxox[baprs]-[A-Za-z0-9-]{20,}\b/,/\bsk_(?:live|test)_[A-Za-z0-9]{16,}\b/,/\brk_(?:live|test)_[A-Za-z0-9]{16,}\b/,/\bsk-[A-Za-z0-9_-]{32,}\b/,/\bsk-ant-api\d{2}-[A-Za-z0-9_-]{20,}\b/,/\blin_(?:api|oauth)_[A-Za-z0-9]{20,}\b/,/\bvercel_[A-Za-z0-9]{20,}\b/,/\bsntrys_[A-Za-z0-9_-]{20,}\b/,/\bkey-[a-f0-9]{32}\b/i,/\bnpm_[A-Za-z0-9]{30,}\b/,/\bSG\.[A-Za-z0-9_-]{20,}\.[A-Za-z0-9_-]{20,}\b/,/https:\/\/hooks\.slack\.com\/services\/T[A-Z0-9]+\/B[A-Z0-9]+\/[A-Za-z0-9]+/,/https:\/\/discord(?:app)?\.com\/api\/webhooks\/\d+\/[A-Za-z0-9_-]+/,/\bsb_secret_[A-Za-z0-9_]{20,}\b/,/\bservice_role\b/i,/"private_key"\s*:\s*"-----BEGIN PRIVATE KEY-----/,/-----BEGIN (?:RSA |EC |OPENSSH |DSA )?PRIVATE KEY-----/,/\b(?:postgres|mysql|mongodb(?:\+srv)?|redis):\/\/[^:\s/@]+:(?!(?:pass(?:word)?|my[a-z]*pass(?:word)?|mysecretpassword|myusername|postgres|mysql|redis|root|admin|minioadmin|secret|example|changeme|change_me|test|guest|placeholder|default|user(?:name)?|x{3,}|\*{2,}|\$\{[^}]*\}|\$[A-Z_]+|<[^>]*>|%[\w.]+%|\{\{[^}]*\}\})@)[^@\s/]+@(?!(?:localhost|127\.0\.0\.1|0\.0\.0\.0|host\.docker\.internal)(?:[:/\s]|$))[^\s:/@]*\./i],Sl=/\beyJ[A-Za-z0-9_-]{8,}\.eyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{16,}\b/,Cl=/\b(?:NEXT_PUBLIC|VITE|REACT_APP|EXPO_PUBLIC)_[A-Z0-9_]*(?:SECRET|TOKEN|PASSWORD|PRIVATE|DATABASE_URL|SERVICE_ROLE|AWS_ACCESS_KEY|AWS_SECRET)[A-Z0-9_]*\b/i,wl=/\b(?:process\s*\.\s*env|import\s*\.\s*meta\s*\.\s*env|window\.__[A-Z0-9_]*ENV[A-Z0-9_]*__|__[A-Z0-9_]*ENV[A-Z0-9_]*__)\b/,Tl=/\b(?:(?:process|window)\s*(?:\/[*/]|<!--|-->|\.\s*(?:\/[*/]|<!--|-->))|import\s*(?:\/[*/]|<!--|-->|\.\s*(?:\/[*/]|<!--|-->|meta\s*(?:\/[*/]|<!--|-->|\.\s*(?:\/[*/]|<!--|-->)))))/,El=/\b(?:DATABASE_URL|AWS_SECRET_ACCESS_KEY|AWS_ACCESS_KEY_ID|MAILGUN_API_KEY|SALESFORCE_CLIENT_SECRET|OKTA_CLIENT_SECRET|SESSION_SECRET|COOKIE_SECRET|PRIVATE_KEY|SERVICE_ROLE)\b/,Dl=/(?:SENTRY_DSN|PUBLIC_KEY|PUBLISHABLE|ANON_KEY|POSTHOG_(?:PROJECT_)?TOKEN|POSTHOG_KEY|TLDRAW_LICENSE_KEY|CLERK_PUBLISHABLE_KEY|ALGOLIA_SEARCH_KEY|GC_API_KEY|GOOGLE_MAPS_API_KEY|MAPBOX_TOKEN|MIXPANEL_TOKEN|FACEBOOK_CLIENT_TOKEN|(?:NEXT_PUBLIC|VITE|REACT_APP|EXPO_PUBLIC)_(?:DISABLE|ENABLE|ALLOW|REQUIRE)_)|(?:TOKEN|SECRET|PASSWORD|PRIVATE)_(?:KIND|TYPE|URL|URI|ENDPOINT|HEADER|NAME)$/i,Ol=[/^appl_/,/^goog_/,/^amzn_/,/^strp_/,/^pk_(?:live|test)_/,/^sb_publishable_/,/^phc_/,/^public-token-(?:live|test)-/,/^pk\.eyJ/],kl=[/^[\s._\-*\u2022xX]{8,}$/,/(?:\.{3,}|\u2026|[*\u2022]{3,})/,/(?:^|[_\-\s])(?:your|redacted|masked|placeholder|replace[_\-\s]?me|changeme)(?:$|[_\-\s])/i,/<[^>]*(?:auth|credential|key|password|secret|token|your|redacted|placeholder|masked)[^>]*>/i,/\[[^\]]*(?:auth|credential|key|password|secret|token|your|redacted|placeholder|masked)[^\]]*\]/i,/\{[^}]*(?:auth|credential|key|password|secret|token|your|redacted|placeholder|masked)[^}]*\}/i],Al=[/(?:^|[_\-\s])(?:example|sample|dummy)(?:$|[_\-\s])/i],jl=/(?:placeholder|example|sample|dummy|masked|redacted|mask)/i,Ml=/(?:api_?key|secret|token|password|credential|auth(?!or(?!i[sz])))/i,Nl=/(?:^|\/)[^/]+\.config\.[cm]?[jt]s$/,Pl=/(?:^|\/)(?:\.[a-z-]+rc|[a-z-]+\.rc)\.[cm]?[jt]s$/,Fl=/(?:^|\/)[^/]+\.(?:test|spec|stories|story|fixture|fixtures)\.[cm]?[jt]sx?$/,Il=/(?:^|\/)[^/]+\.server\.[cm]?[jt]sx?$/,Ll=/(?:^|\/)(?:middleware|proxy|route)\.[cm]?[jt]sx?$/,Rl=/(?:^|\/)pages\/api\/.+\.[cm]?[jt]sx?$/,zl=/(?:^|\/)[^/]+\.(?:client|browser|web)\.[cm]?[jt]sx?$/,Bl=/(?:^|\/)(?:src\/)?(?:main|index|[Aa]pp|client)\.[cm]?[jt]sx?$/,Vl=new Set([`backend`,`functions`,`lambdas`,`lambda`,`middleware`,`server`,`servers`]),Hl=new Set([`api`,`backend`,`edge`,`function`,`functions`,`lambda`,`lambdas`,`server`,`servers`,`worker`,`workers`]),Ul=new Set([`__fixtures__`,`__mocks__`,`__tests__`,`fixtures`,`mocks`,`test`,`tests`]),Wl=new Set([`bin`,`config`,`configs`,`script`,`scripts`,`tooling`,`tools`]),Gl=new Set([`components`,`features`,`hooks`,`pages`,`ui`,`views`,`widgets`]),Kl=new Set(`alert.modal.label.text.title.name.id.url.path.route.page.param.field.column.header.placeholder.prefix.description.type.icon.class.style.variant.event.action.status.state.mode.flag.option.config.message.error.display.view.component.element.container.wrapper.button.link.input.select.dialog.menu.form.step.index.count.length.role.scope.context.provider.ref.handler.query.schema.constant`.split(`.`)),ql=new Set([`start`,`end`]),J=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),Jl=new RegExp(Cl.source,`gi`),Yl=e=>{for(let t of e.matchAll(Jl)){let e=t[0]??``;if(!Dl.test(e))return new RegExp(J(e))}},Xl=e=>wl.test(e)&&El.test(e),Zl=/\.(?:[cm]?[jt]sx?)$/i,Ql=/\/\/|\/\*|<!--/,$l=new Set([`\r`,`
|
|
9
|
+
`,`\u2028`,`\u2029`]),eu=e=>{let t=0;for(;t<e.length;){let n=e.indexOf(`-->`,t);if(n===-1)return!1;let r=n-1;for(;r>=0&&!$l.has(e[r]??``)&&e[r]?.trim()===``;)--r;if(r<0||$l.has(e[r]??``))return!0;t=n+3}return!1},tu=(t,n)=>{if(!Zl.test(t)||!n.startsWith(`#!`)&&!Ql.test(n)&&!eu(n))return n;try{let r=e(t,n,{astType:`ts`,lang:Lt(t)});if(r.errors.some(e=>e.severity===`Error`))return;let i=n.search(/[\r\n\u2028\u2029]/),a=[...n.startsWith(`#!`)?[{start:0,end:i===-1?n.length:i}]:[],...r.comments];if(a.length===0)return n;let o=[],s=0;for(let e of a)o.push(n.slice(s,e.start)),o.push(n.slice(e.start,e.end).replace(/[^\r\n\u2028\u2029]/g,` `)),s=e.end;return o.push(n.slice(s)),o.join(``)}catch{return}},nu=(e,t,n)=>{if(jc.test(e.relativePath)||!Rc(e.relativePath,e.isGeneratedBundle))return[];let r=t(e.content);if(r===void 0)return[];let i=bc(e.content,r);return[{message:n,line:i.line,column:i.column}]},ru=`A browser artifact contains server-secret environment names or a full environment dump shape.`,iu=e=>Yl(e)??(Xl(e)?El:void 0),au=W({id:`artifact-env-leak`,title:`Server env leaked to browser artifact`,severity:`error`,recommendation:`Treat public env prefixes as publication, not secrecy; keep secret env vars server-only and rebuild after rotating leaked keys.`,scan:e=>{let t=!1,n=nu(e,e=>{let n=Yl(e);if(n)return t=!0,n;if(El.test(e))return wl.test(e)?(t=!0,El):Tl.test(e)?El:void 0},ru);if(n.length===0)return n;let r=t?n:nu(e,iu,ru),i=tu(e.relativePath,e.content);return i===void 0?n:i===e.content?r:nu({...e,content:i},iu,ru)}}),ou=W({id:`artifact-secret-leak`,title:`Secret shipped in browser artifact`,severity:`error`,recommendation:`Remove the secret from client bundles/static assets, rotate it, and route privileged service calls through server-only code.`,scan:e=>nu(e,e=>xl.find(t=>t.test(e)),`A browser-delivered artifact contains a secret-looking credential value.`)}),su=/(?:npm|pnpm|yarn|bun)\s+(?:install|ci)\b(?:(?!--ignore-scripts)[\s\S]){0,700}\bsecrets\.[A-Z0-9_]+|\bsecrets\.[A-Z0-9_]+(?:(?!--ignore-scripts)[\s\S]){0,700}(?:npm|pnpm|yarn|bun)\s+(?:install|ci)\b/i,cu=/(?:npm|pnpm|yarn|bun)\s+(?:install|ci)\b/i,lu=/\bsecrets\.[A-Z0-9_]+/,uu=/--ignore-scripts\b/,du=`The build or install pipeline can execute package lifecycle code while CI secrets may be present.`,fu=e=>/(?:^|\/)\.github\/workflows\/[^/]+\.ya?ml$/i.test(e),pu=e=>{let t=e.split(`
|
|
10
|
+
`),n=[],r=[],i,a,o;for(let e=0;e<t.length;e+=1){let s=t[e],c=s.trim();if(c===``||c.startsWith(`#`))continue;let l=s.length-s.trimStart().length;if(i!==void 0&&l<=i&&(i=void 0,a=void 0,o=void 0),i===void 0){/^steps:\s*(?:#.*)?$/.test(c)?i=l:n.push(s);continue}if((c===`-`||c.startsWith(`- `))&&(a===void 0||l===a)){a=l,o={startLineIndex:e,lines:[s]},r.push(o);continue}o===void 0?n.push(s):o.lines.push(s)}let s=lu.test(n.join(`
|
|
11
11
|
`));for(let e of r){let t=e.lines.join(`
|
|
12
|
-
`);if(!su.test(t)||lu.test(t)||!s&&!cu.test(t))continue;let n=Math.max(e.lines.findIndex(e=>su.test(e)),0),r=e.lines[n].search(su);return[{message:uu,line:e.startLineIndex+n+1,column:(r===-1?0:r)+1}]}return[]},pu=q({shouldScan:e=>zc(e.relativePath)&&!e.relativePath.endsWith(`package.json`)&&!du(e.relativePath),pattern:ou,message:uu}),mu=W({id:`build-pipeline-secret-boundary`,title:`Build pipeline runs code near secrets`,severity:`warn`,recommendation:`Run dependency installs with scripts disabled before exposing secrets, isolate untrusted build code, and move signing/deploy authority into a narrow privileged step.`,scan:e=>du(e.relativePath)?fu(e.content):pu(e)}),hu=W({id:`clickjacking-redirect-risk`,title:`Redirect or frame boundary risk`,severity:`warn`,recommendation:"Allowlist redirect origins/paths, set `frame-ancestors` for privileged pages, and avoid URL-prefilled privileged dialogs.",scan:q({shouldScan:e=>K(e.relativePath)||zc(e.relativePath),pattern:/\bredirect\s*\((?!\s*(?:await\s+)?[\w$]*(?:safe|valid|sanitiz|allowlist|whitelist)[\w$]*\s*\()[^)'"`\n]*\b(?:searchParams\.get|nextUrl\.searchParams|returnTo|callbackUrl|continue|next)\b|<iframe\b[\s\S]{0,700}(?:\b(?:next=|continue=|redirect=|redirect_uri|userstoinvite|sharingaction|\.\.)|[?&](?:amp;)?role=)|frame-ancestors\s+(?:\*|'self'\s+\*)|X-Frame-Options["']?\s*:\s*["']?ALLOW/i,message:`Redirect or framing configuration may let attacker-controlled URLs chain into privileged UI or clickjacking.`})}),gu=e=>/(?:^|\/)(?:tools?|scripts?)\/|(?:^|\/)management\/commands\/|(?:^|\/)(?:build|make|gulpfile|gruntfile)\.[cm]?[jt]s$/i.test(e),_u=e=>Vc(e,wc),vu=String.raw`(?:req\.|request\.|params\.|query\.|body\.|searchParams|\$_(?:GET|POST|REQUEST))`,yu=String.raw`(?:(?<![.\w$])(?:exec(?:Sync)?|system|passthru|proc_open|shell_exec)|\b(?:os\.system|subprocess\.(?:run|Popen|call)|(?:child_process|childProcess|cp)\.exec\w*))`,bu=String.raw`(?:(?<![.\w$])spawn(?:Sync)?|\b(?:child_process|childProcess|cp)\.spawn\w*)`,xu=String.raw`['"](?:sh|bash|zsh|dash|ksh|cmd(?:\.exe)?|powershell(?:\.exe)?|pwsh)['"]`,Su=String.raw`['"](?:-c|/c|-Command)['"]`,Cu=W({id:`command-execution-input-risk`,title:`Command execution uses caller-shaped input`,severity:`error`,recommendation:`Avoid shell execution for caller-controlled values. Use fixed commands, argument arrays, strict allowlists, and no shell interpolation.`,scan:q({shouldScan:e=>_u(e.relativePath)&&!gu(e.relativePath),pattern:[new RegExp(String.raw`${yu}\s*\([^)]{0,220}(?:${vu}|shell\s*=\s*true|f['"\`][^'"\`]*\{)`,`i`),new RegExp(String.raw`${bu}\s*\((?:[^,)]{0,120}?${vu}|\s*${xu}\s*,\s*\[\s*${Su}\s*,[^\]]{0,220}${vu}|(?=[^)]{0,220}shell\s*[:=]\s*true)[^)]{0,220}${vu})`,`i`)],message:`Command execution appears to include request, query, body, or shell-interpolated input.`})}),wu=W({id:`cors-cookie-trust-risk`,title:`Broad cookie or credentialed CORS trust`,severity:`warn`,recommendation:`Keep auth cookies host-only and HttpOnly, avoid credentialed CORS for less-trusted docs/vendor origins, and isolate documentation domains from app sessions.`,scan:q({shouldScan:e=>K(e.relativePath)||zc(e.relativePath),pattern:/Access-Control-Allow-Credentials["']?\s*[:,]\s*["']?true[\s\S]{0,700}Access-Control-Allow-Origin["']?\s*[:,]\s*["']?(?:\*|https:\/\/docs\.|https:\/\/.*mintlify)|\b(?:session|auth|token|jwt)[^=\n]{0,80}(?:=[^;\n]{0,120};[^=\n]{0,80})?\bDomain=\./i,message:`Credentialed CORS or broad auth-cookie scope can make a docs/custom-domain XSS become account compromise.`})}),Tu=(e,t)=>{let n=e[t],r=n===`(`?`)`:n===`{`?`}`:n===`[`?`]`:``;if(r===``)return-1;let i=0,a=null;for(let o=t;o<e.length;o+=1){let t=e[o];if(a!==null){t===`\\`?o+=1:t===a&&(a=null);continue}if(t===`"`||t===`'`||t==="`")a=t;else if(t===n)i+=1;else if(t===r&&(--i,i===0))return o}return-1},Eu=e=>`end`in e&&typeof e.end==`number`?e.end:-1,Y=e=>`start`in e&&typeof e.start==`number`?e.start:-1,Du=e=>{let t=O(e);for(;y(t,`SequenceExpression`);){let e=t.expressions.at(-1);if(!e)break;t=O(e)}return t},Ou=e=>{if(e.kind!==`import`)return null;let t=e.declarationNode.parent;return y(t,`ImportDeclaration`)?t:null},ku=e=>{let t=[],n=new Map;for(let r of e){let e=`${r.truthiness}:${r.nullishness}`,i=n.get(r.expression);i?.has(e)||(i?i.add(e):n.set(r.expression,new Set([e])),t.push(r))}return t},Au=e=>y(e,`JSXElement`)||y(e,`JSXFragment`)||y(e,`ArrayExpression`)||y(e,`ObjectExpression`)||y(e,`ArrowFunctionExpression`)||y(e,`FunctionExpression`)||y(e,`ClassExpression`)||y(e,`NewExpression`)?{expression:e,truthiness:`truthy`,nullishness:`non-nullish`}:y(e,`Literal`)?e.value===null?{expression:e,truthiness:`falsy`,nullishness:`nullish`}:{expression:e,truthiness:e.value?`truthy`:`falsy`,nullishness:`non-nullish`}:y(e,`UnaryExpression`)&&e.operator===`void`?{expression:e,truthiness:`falsy`,nullishness:`nullish`}:{expression:e,truthiness:`unknown`,nullishness:`unknown`},X=e=>{let t=Du(e);if(y(t,`ConditionalExpression`)){let e=X(t.test);return e.every(e=>e.truthiness===`truthy`)?X(t.consequent):e.every(e=>e.truthiness===`falsy`)?X(t.alternate):ku([...X(t.consequent),...X(t.alternate)])}if(!y(t,`LogicalExpression`))return[Au(t)];let n=X(t.left),r=X(t.right),i=[];for(let e of n){if(t.operator===`&&`){e.truthiness!==`truthy`&&i.push(e.truthiness===`falsy`?e:{...e,truthiness:`falsy`}),e.truthiness!==`falsy`&&i.push(...r);continue}if(t.operator===`||`){e.truthiness!==`falsy`&&i.push(e.truthiness===`truthy`?e:{...e,truthiness:`truthy`,nullishness:`non-nullish`}),e.truthiness!==`truthy`&&i.push(...r);continue}e.nullishness!==`nullish`&&i.push(e.nullishness===`non-nullish`?e:{...e,nullishness:`non-nullish`}),e.nullishness!==`non-nullish`&&i.push(...r)}return ku(i)},ju=e=>{let t=[],n=new Set;for(let r of X(e))n.has(r.expression)||(n.add(r.expression),t.push(r.expression));return t},Mu=new Set([`assign`,`defineProperties`,`defineProperty`]),Nu=new Set([`defineProperty`,`set`]),Pu=new WeakMap,Fu=e=>{let t=I(e);for(;t.parent;){let e=t.parent;if(!y(e,`MemberExpression`)||e.object!==t)break;t=I(e)}return t},Iu=e=>{let t=e;for(;t;){if(v(t)||y(t,`Program`))return t;t=t.parent}return e},Lu=(e,t)=>{if(y(e,`ReturnStatement`)||y(e,`ThrowStatement`)||y(e,`BreakStatement`)||t&&y(e,`ContinueStatement`))return!0;if(y(e,`BlockStatement`))return e.body.some(e=>Lu(e,t));if(!y(e,`IfStatement`))return!1;if(y(e.test,`Literal`)){let n=e.test.value?e.consequent:e.alternate;return n?Lu(n,t):!1}return!!(e.alternate&&Lu(e.consequent,t)&&Lu(e.alternate,t))},Ru=e=>Lu(e,!0),zu=(e,t)=>{let n=t.indexOf(e);return n>0&&t.slice(0,n).some(Ru)},Bu=(e,t)=>{let n=e;for(;n.parent&&n!==t;){let e=n.parent;if((y(e,`BlockStatement`)||y(e,`Program`))&&zu(n,e.body)||(y(e,`WhileStatement`)&&y(e.test,`Literal`)&&!e.test.value||y(e,`ForStatement`)&&e.test&&y(e.test,`Literal`)&&!e.test.value)&&e.body===n||y(e,`SwitchCase`)&&zu(n,e.consequent)||y(e,`IfStatement`)&&y(e.test,`Literal`)&&(e.test.value===!1&&e.consequent===n||e.test.value===!0&&e.alternate===n)||y(e,`ConditionalExpression`)&&y(e.test,`Literal`)&&(e.test.value===!1&&e.consequent===n||e.test.value===!0&&e.alternate===n)||y(e,`LogicalExpression`)&&e.right===n&&y(e.left,`Literal`)&&(e.operator===`&&`&&!e.left.value||e.operator===`||`&&e.left.value))return!0;n=e}return!1},Vu=(e,t)=>{let n=e;for(;n.parent&&n!==t;){let e=n.parent;if(y(e,`IfStatement`)&&(!y(e.test,`Literal`)||e.test.value===!0&&e.alternate===n||e.test.value===!1&&e.consequent===n)||y(e,`ConditionalExpression`)&&(!y(e.test,`Literal`)||e.test.value===!0&&e.alternate===n||e.test.value===!1&&e.consequent===n)||y(e,`LogicalExpression`)&&e.right===n&&(!y(e.left,`Literal`)||e.operator===`&&`&&!e.left.value||e.operator===`||`&&e.left.value)||y(e,`DoWhileStatement`)&&!(e.body===n&&y(e.test,`Literal`)&&!e.test.value)||y(e,`TryStatement`)&&e.block===n||y(e,`ForStatement`)||y(e,`ForInStatement`)||y(e,`ForOfStatement`)||y(e,`WhileStatement`)||y(e,`SwitchCase`)||y(e,`CatchClause`)||(y(e,`CallExpression`)||y(e,`MemberExpression`))&&e.optional)return!0;n=e}return!1},Hu=e=>{let t=Pu.get(e);if(t)return t;let n=(t,n,r)=>{let i=O(t);if(!y(i,`MemberExpression`))return!1;let a=O(i.object);return!!(y(a,`Identifier`)&&a.name===n&&e.isGlobalReference(a)&&r.has(N(i)??``))},r=e=>{let t=O(e);if(!y(t,`ObjectExpression`))return null;let n=new Set;for(let e of t.properties){if(!y(e,`Property`))return null;let t=M(e,{allowComputedString:!0});if(t===null)return null;n.add(t)}return n},i=e=>{let t=Fu(e),i=t.parent;if(i){if(y(i,`AssignmentExpression`)&&i.left===t||y(i,`UpdateExpression`)&&i.argument===t||y(i,`UnaryExpression`)&&i.operator===`delete`){if(!y(t,`MemberExpression`))return null;let e=N(t);return e===null?null:new Set([e])}if(!(!y(i,`CallExpression`)||i.arguments[0]!==t)){if(n(i.callee,`Object`,Mu)){let e=O(i.callee);if(!y(e,`MemberExpression`))return;let t=N(e);if(t===`assign`){let e=i.arguments.slice(1).map(r);return e.some(e=>e===null)?null:new Set(e.flatMap(e=>[...e??[]]))}if(t===`defineProperties`){let e=i.arguments[1];return e?r(e):null}let n=i.arguments[1];return n&&y(n,`Literal`)&&typeof n.value==`string`?new Set([n.value]):null}if(n(i.callee,`Reflect`,Nu)){let e=i.arguments[1];return e&&y(e,`Literal`)&&typeof e.value==`string`?new Set([e.value]):null}}}},a=t=>{let n=O(t.callee);if(v(n))return n;if(!y(n,`Identifier`))return null;let r=P(n,e);if(!r)return null;if(r.kind===`function`&&v(r.declarationNode))return r.declarationNode;if(r.kind!==`const`||!r.initializer)return null;let i=O(r.initializer);return v(i)?i:null},o=[],s=new Map;A(e.rootScope.node,t=>{if(y(t,`CallExpression`)){let e=Iu(t),n=a(t);n&&!Bu(t,e)&&o.push({call:t,owner:e,targetOwner:n})}if(!y(t,`Identifier`))return;let n=i(t);if(n===void 0)return;let r=P(t,e);if(!r)return;let c=Iu(t);if(Bu(t,c))return;let l=s.get(r.id)??[];l.push({node:t,owner:c,propertyNames:n}),s.set(r.id,l)});let c=t=>{let n=Iu(t),r=Y(t),i=new Set,a=(e,t)=>{for(let n of o)n.owner!==e||Y(n.call)>=t||i.has(n.targetOwner)||(i.add(n.targetOwner),a(n.targetOwner,1/0))};return a(n,r),y(n,`Program`)||a(e.rootScope.node,1/0),i},l=e=>{if(y(e,`Program`))return 1/0;let t=o.find(t=>y(t.owner,`Program`)&&t.targetOwner===e);return t?Y(t.call):1/0},u=new Map;for(let e of o){let t=u.get(e.owner)??[];t.push(e),u.set(e.owner,t)}let d=new WeakMap,f=(e,t)=>{let n=d.get(e)?.get(t);if(n!==void 0)return n;let r=[e],i=new Set,a=!1;for(;r.length>0;){let e=r.pop();if(!(!e||i.has(e))){if(e===t){a=!0;break}i.add(e);for(let t of u.get(e)??[])r.push(t.targetOwner)}}let o=d.get(e)??new WeakMap;return o.set(t,a),d.set(e,o),a},p=(e,t)=>{let n=new Set,r=e;for(;r?.parent&&r!==t;){let t=r.parent,i=y(t,`DoWhileStatement`)&&y(t.test,`Literal`)&&!t.test.value,a=y(t,`ForStatement`)||y(t,`ForInStatement`)||y(t,`ForOfStatement`)||y(t,`WhileStatement`)||y(t,`DoWhileStatement`)?t.body:null,o=e;for(;a&&y(a,`BlockStatement`)&&o&&o.parent!==a;)o=o.parent??null;let s=a&&y(a,`BlockStatement`)&&o?a.body.findIndex(e=>e===o):-1,c=!!(a&&y(a,`BlockStatement`)&&s>=0&&a.body.slice(s+1).some(e=>Lu(e,!1)));a&&!i&&!c&&n.add(t),r=t}return n},m=(e,t,n)=>{let r=p(e,n);return r.size===0?!1:[...p(t,n)].some(e=>r.has(e))},h=new WeakMap,ee=e=>{let t=h.get(e);if(t)return t;let n=new Map;for(let t of o){if(!f(t.targetOwner,e))continue;let r=n.get(t.owner)??[];r.push(t),n.set(t.owner,r)}return h.set(e,n),n},te=(e,t)=>{let n=ee(e),r=ee(t);for(let[e,t]of n){let n=r.get(e);if(n){for(let r of t)for(let t of n)if(r!==t&&(Y(r.call)<Y(t.call)||v(e)||m(r.call,t.call,e)))return!0}}return!1},g={getEventsBefore:(t,n)=>{let r=s.get(t.id)??[],i=[],a=(e,t,n,s)=>{if(n.has(e))return;let c=new Set(n);c.add(e);let l=[...r.filter(t=>t.owner===e).map(e=>({event:e,index:Y(e.node)})),...o.filter(t=>t.owner===e).map(e=>({call:e,index:Y(e.call)}))].sort((e,t)=>e.index-t.index);for(let e of l){if(e.index>=t)break;if(`event`in e){i.push({isConditional:s||Vu(e.event.node,e.event.owner),node:e.event.node});continue}a(e.call.targetOwner,1/0,c,s||Vu(e.call.call,e.call.owner))}},c=Iu(n);return y(c,`Program`)||a(e.rootScope.node,l(c),new Set,!1),a(c,Y(n),new Set,!1),i},getOutermostTarget:Fu,isGlobalNamespaceMethod:n,isExecutionOrderAmbiguous:e=>{let t=Iu(e);if(y(t,`Program`))return!1;let n=o.filter(e=>y(e.owner,`Program`)&&f(e.targetOwner,t));return n.length===0?!1:n.length!==1||n[0]?.targetOwner!==t},isMutationOrderAmbiguous:(e,t,n)=>{let r=Iu(t),i=Y(t);return(s.get(e.id)??[]).some(e=>n!==null&&e.propertyNames!==null&&!e.propertyNames.has(n)?!1:e.owner===r?Y(e.node)>=i&&(v(r)||m(e.node,t,r)):y(e.owner,`Program`)?(ee(r).get(e.owner)??[]).some(t=>m(e.node,t.call,e.owner)):f(e.owner,r)||te(e.owner,r))},isMutatedBefore:(e,t,n)=>{let r=s.get(e.id);if(!r)return!1;let i=Y(t),a=Iu(t),o=c(t);return r.some(e=>n!==null&&e.propertyNames!==null&&!e.propertyNames.has(n)?!1:e.owner===a?Y(e.node)<i:y(e.owner,`Program`)&&!y(a,`Program`)?Y(e.node)<l(a):o.has(e.owner))}};return Pu.set(e,g),g},Uu=(e,t)=>t===`katex`?e===`katex`||e.startsWith(`katex/`):e===t,Wu=(e,t,n)=>{let r=O(e);if(!y(r,`CallExpression`))return!1;let i=O(r.callee),a=r.arguments[0];return!!(y(i,`Identifier`)&&i.name===`require`&&n.isGlobalReference(i)&&a&&y(a,`Literal`)&&typeof a.value==`string`&&Uu(a.value,t))},Gu=(e,t)=>{if(e.kind!==`ts-import-equals`)return!1;let n=e.declarationNode;if(!y(n,`TSImportEqualsDeclaration`))return!1;let r=n.moduleReference;return!!(y(r,`TSExternalModuleReference`)&&y(r.expression,`Literal`)&&typeof r.expression.value==`string`&&Uu(r.expression.value,t))},Ku=(e,t)=>{let n=O(e);return!!(y(n,`AwaitExpression`)&&y(n.argument,`ImportExpression`)&&y(n.argument.source,`Literal`)&&typeof n.argument.source.value==`string`&&Uu(n.argument.source.value,t))},qu=(e,t,n,r,i)=>{let a=P(O(e),i),o=Hu(i);if(!a||o.isExecutionOrderAmbiguous(r)||o.isMutationOrderAmbiguous(a,r,n)||o.isMutatedBefore(a,r,n))return null;let s=Ou(a);if(typeof s?.source.value==`string`&&Uu(s.source.value,t))return y(a.declarationNode,`ImportDefaultSpecifier`)||y(a.declarationNode,`ImportNamespaceSpecifier`)||j(a.declarationNode)===`default`?a:null;if(Gu(a,t))return a;if(a.kind!==`const`||!a.initializer)return null;let c=O(a.initializer);return Wu(c,t,i)||y(c,`MemberExpression`)&&N(c)===`default`&&(Wu(c.object,t,i)||Ku(c.object,t))||Ku(c,t)?a:null},Ju=(e,t,n,r,i)=>{let a=P(O(e),i);if(!a)return null;let o=Ou(a),s=Hu(i);return typeof o?.source.value!=`string`||!Uu(o.source.value,t)||j(a.declarationNode)!==n||s.isExecutionOrderAmbiguous(r)||s.isMutationOrderAmbiguous(a,r,null)||s.isMutatedBefore(a,r,null)?null:a},Yu=(e,t,n)=>qu(e,`katex`,`renderToString`,t,n)!==null||Wu(e,`katex`,n),Xu=(e,t,n)=>{if(Ju(e,`katex`,`renderToString`,t,n))return!0;let r=O(e);if(!y(r,`Identifier`))return!1;let i=n.referenceFor(r)?.resolvedSymbol;if(!i||i.kind!==`const`||!i.initializer||Hu(n).isMutatedBefore(i,t,null))return!1;let a=O(i.initializer),o=i.bindingIdentifier.parent;return y(o,`Property`)&&M(o,{allowComputedString:!0})===`renderToString`?Yu(a,i.declarationNode,n):y(a,`MemberExpression`)&&N(a)===`renderToString`&&Yu(a.object,i.declarationNode,n)?!0:y(a,`Identifier`)?Xu(a,i.declarationNode,n):!1},Zu=(e,t)=>{let n=O(e);if(y(n,`Identifier`)){if(!/katex/i.test(n.name))return!1;let e=t.referenceFor(n)?.resolvedSymbol;return!!(e&&e.kind!==`parameter`&&e.kind!==`let`)}if(!y(n,`MemberExpression`)||N(n)!==`renderToString`)return!1;let r=O(n.object);if(!y(r,`Identifier`)||!/katex/i.test(r.name))return!1;let i=t.referenceFor(r)?.resolvedSymbol;if(!i)return!1;if(i.kind===`import`){if(!Uu(String(Ou(i)?.source.value??``),`katex`))return!0;let e=Hu(t);return e.isExecutionOrderAmbiguous(n)||e.isMutationOrderAmbiguous(i,n,`renderToString`)?!1:e.isMutatedBefore(i,n,`renderToString`)}if(i.kind===`parameter`||i.kind===`let`||i.kind===`var`)return!0;if(i.kind!==`const`||!i.initializer)return!1;let a=O(i.initializer);if(y(a,`ObjectExpression`))return!0;if(y(a,`CallExpression`)){let e=O(a.callee);return y(e,`Identifier`)&&e.name===`require`}return y(a,`AwaitExpression`)&&y(a.argument,`ImportExpression`)},Qu=new WeakMap,$u=(e,t)=>{let n=O(e);return y(n,`Identifier`)?n.name===`undefined`&&t.isGlobalReference(n):y(n,`Literal`)&&!n.value},ed=(e,t)=>{let n=O(e);if(!y(n,`ObjectExpression`))return null;let r;for(let e of n.properties){if(!y(e,`Property`))return null;let n=M(e,{allowComputedString:!0});if(n===null)return null;if(n===t){if(e.kind!==`init`)return null;r=e.value}}return r},td=e=>{let t=O(e);if(!y(t,`ObjectExpression`))return null;for(let e of t.properties){if(!y(e,`Property`))return null;let t=M(e,{allowComputedString:!0});if(t===null||t===`get`||t===`set`)return null}return ed(t,`value`)},nd=(e,t,n)=>{let r=td(t);return r===null?`trusted`:r===void 0?e:$u(r,n)?`untrusted`:`trusted`},rd=(e,t)=>e===t?e:e===`trusted`||t===`trusted`?`trusted`:e===`unsupported`||t===`unsupported`?`unsupported`:`untrusted`,id=(e,t,n,r)=>{let i=Hu(n),a=i.getOutermostTarget(t),o=a.parent;if(!o)return`unsupported`;if(y(o,`AssignmentExpression`)&&o.left===a){if(!y(a,`MemberExpression`))return`unsupported`;let t=N(a);return t===null?`trusted`:t===`trust`?$u(o.right,n)?`untrusted`:`trusted`:e}if(y(o,`UnaryExpression`)&&o.operator===`delete`){if(!y(a,`MemberExpression`))return`unsupported`;let t=N(a);return t===null?`trusted`:t===`trust`?`absent`:e}if(y(o,`UpdateExpression`)){if(!y(a,`MemberExpression`))return`unsupported`;let t=N(a);return t===`trust`||t===null?`trusted`:e}if(!y(o,`CallExpression`)||o.arguments[0]!==a)return`unsupported`;if(i.isGlobalNamespaceMethod(o.callee,`Object`,Mu)){let t=O(o.callee);if(!y(t,`MemberExpression`))return`unsupported`;let i=N(t);if(i===`assign`){let t=e;for(let e of o.arguments.slice(1)){let i=ad(e,e,n,new Set(r));i!==`absent`&&(t=i)}return t}if(i===`defineProperties`){let t=o.arguments[1];if(!t)return`unsupported`;let r=ed(t,`trust`);return r===null?`trusted`:r===void 0?e:nd(e,r,n)}let a=o.arguments[1];if(!a||!y(a,`Literal`)||typeof a.value!=`string`)return`trusted`;if(a.value!==`trust`)return e;let s=o.arguments[2];return s?nd(e,s,n):`unsupported`}if(i.isGlobalNamespaceMethod(o.callee,`Reflect`,Nu)){let t=O(o.callee);if(!y(t,`MemberExpression`))return`unsupported`;let r=N(t),i=o.arguments[1];if(!i||!y(i,`Literal`)||typeof i.value!=`string`)return`trusted`;if(i.value!==`trust`)return e;let a=o.arguments[2];return a?r===`defineProperty`?nd(e,a,n):$u(a,n)?`untrusted`:`trusted`:`unsupported`}return`unsupported`},ad=(e,t,n,r)=>{if(e===void 0)return`absent`;let i=O(e);if(y(i,`Identifier`)){if(i.name===`undefined`&&n.isGlobalReference(i))return`absent`;let e=P(i,n);if(!e||e.kind!==`const`||!e.initializer||r.has(e.id))return`unsupported`;let a=new Set(r);a.add(e.id);let o=Hu(n);if(o.isMutationOrderAmbiguous(e,t,`trust`))return`unsupported`;let s=ad(e.initializer,t,n,a);for(let r of o.getEventsBefore(e,t)){let e=id(s,r.node,n,a);s=r.isConditional?rd(s,e):e}return s}if(!y(i,`ObjectExpression`))return`unsupported`;let a=`absent`;for(let e of i.properties){if(y(e,`SpreadElement`)){let t=ad(e.argument,e.argument,n,new Set(r));t!==`absent`&&(a=t===`unsupported`?`trusted`:t);continue}if(!y(e,`Property`)){a=`trusted`;continue}let t=M(e,{allowComputedString:!0});if(t===null){a=`trusted`;continue}t===`trust`&&(a=$u(e.value,n)?`untrusted`:`trusted`)}return a},od=(e,t,n)=>{let r=Qu.get(e),i=new Map(r);for(let[e,n]of t)i.set(e,n);Qu.set(e,i);try{return n()}finally{r?Qu.set(e,r):Qu.delete(e)}},sd=(e,t,n,r)=>{let i=e?O(e):void 0;if(i&&y(i,`Identifier`)){let e=n.referenceFor(i)?.resolvedSymbol,t=e?Qu.get(n)?.get(e.id):void 0;if(t)return t}let a=ad(e,t,n,r);return{isSafe:a===`absent`||a===`untrusted`}},cd={containsKatex:!1,isConclusive:!0,isSafe:!0,isSafeInAttributeContext:!0},ld={containsKatex:!1,isConclusive:!0,isSafe:!0,isSafeInAttributeContext:!1},Z={containsKatex:!1,isConclusive:!1,isSafe:!1,isSafeInAttributeContext:!1},ud={containsKatex:!0,isConclusive:!1,isSafe:!1,isSafeInAttributeContext:!1},dd={containsKatex:!0,isConclusive:!0,isSafe:!1,isSafeInAttributeContext:!1},fd=new WeakMap,pd=new WeakMap,md=(e,t,n)=>{fd.set(e,t),pd.set(e,n)},hd=e=>({containsKatex:e.some(e=>e.containsKatex),isConclusive:e.every(e=>e.isSafe)?e.filter(e=>e.containsKatex).every(e=>e.isConclusive):e.some(e=>e.containsKatex&&e.isConclusive&&!e.isSafe)||e.some(e=>e.containsKatex&&e.isConclusive)&&e.some(e=>!e.containsKatex&&!e.isSafe),isSafe:e.every(e=>e.isSafe),isSafeInAttributeContext:e.every(e=>e.isSafeInAttributeContext)}),gd=(e,t)=>{let n=O(e);if(!y(n,`ObjectExpression`))return{isKnown:!1,value:null};let r=!0,i=null;for(let e of n.properties){if(!y(e,`Property`)){r=!1,i=null;continue}let n=M(e,{allowComputedString:!0});n===null?(r=!1,i=null):n===t&&(r=!0,i=e.value)}return{isKnown:r,value:i}},_d=(e,t)=>{let n=O(e);if(y(n,`Identifier`)){let e=P(n,t);return!!(e&&e.kind===`import`&&Ou(e)?.source.value===`react`&&j(e.declarationNode)===`useMemo`)}if(!y(n,`MemberExpression`)||N(n)!==`useMemo`)return!1;let r=P(O(n.object),t);return!!(r&&r.kind===`import`&&Ou(r)?.source.value===`react`&&(y(r.declarationNode,`ImportDefaultSpecifier`)||y(r.declarationNode,`ImportNamespaceSpecifier`)||j(r.declarationNode)===`default`))},vd=(e,t)=>{let n=O(e),r=!1;for(;y(n,`CallExpression`);){let e=O(n.callee);if(!y(e,`MemberExpression`))return!1;let t=N(e);if(t!==`replace`&&t!==`replaceAll`)return!1;let i=n.arguments[0],a=n.arguments[1];if(!i||!a||!y(a,`Literal`)||typeof a.value!=`string`||a.value.includes(`<`)||a.value.includes(`$`))return!1;if(y(i,`Literal`)){let e=`regex`in i?i.regex:void 0,n=t===`replaceAll`&&i.value===`<`,a=e?.pattern===`<`&&e.flags.includes(`g`);(n||a)&&(r=!0)}n=O(e.object)}return!r||!y(n,`Identifier`)?!1:t.referenceFor(n)?.resolvedSymbol?.kind===`parameter`},yd=(e,t)=>{let n=O(e.callee);return y(n,`MemberExpression`)&&N(n)===`sanitize`&&(qu(n.object,`dompurify`,`sanitize`,e,t)||qu(n.object,`isomorphic-dompurify`,`sanitize`,e,t))?ld:y(n,`MemberExpression`)&&N(n)===`escape`&&qu(n.object,`html-escaper`,`escape`,e,t)||Ju(n,`html-escaper`,`escape`,e,t)?cd:Ju(n,`dompurify`,`sanitize`,e,t)||Ju(n,`isomorphic-dompurify`,`sanitize`,e,t)?ld:null},bd=(e,t)=>{if(!t.isSafe)return null;let n=O(e.callee);if(!y(n,`MemberExpression`))return null;let r=N(n);if((r===`trim`||r===`trimEnd`||r===`trimStart`)&&e.arguments.length===0)return t;if(r!==`replace`&&r!==`replaceAll`)return null;let i=e.arguments[1];return!i||!y(i,`Literal`)||typeof i.value!=`string`||i.value.includes(`<`)?null:{containsKatex:t.containsKatex,isConclusive:t.isConclusive,isSafe:!0,isSafeInAttributeContext:t.isSafeInAttributeContext&&!/[&>"']/.test(i.value)}},xd=e=>{let t=e.toLowerCase();for(let e of[`script`,`style`,`textarea`,`title`])if(t.lastIndexOf(`<${e}`)>t.lastIndexOf(`</${e}`))return`raw-text`;let n=e.lastIndexOf(`<`);if(n<=e.lastIndexOf(`>`))return`text`;let r=e.slice(n+1),i=null;for(let e=0;e<r.length;e+=1){let t=r[e];(t===`"`||t===`'`)&&r[e-1]!==`\\`&&(i===t?i=null:i===null&&(i=t))}return i===null?`unsafe-tag`:`attribute`},Sd=(e,t,n,r)=>{let i=e.expressions.map(e=>Q(e,t,new Set(n),r)),a=``,o=!0;for(let t=0;t<i.length;t+=1){a+=e.quasis[t]?.value.raw??``;let n=xd(a),r=i[t]??Z;n===`text`?o&&=r.isSafe:n===`attribute`?o&&=r.isSafeInAttributeContext:o=!1}return{containsKatex:i.some(e=>e.containsKatex),isConclusive:o?i.filter(e=>e.containsKatex).every(e=>e.isConclusive):i.some(e=>e.containsKatex&&e.isConclusive&&!e.isSafe)||i.some(e=>e.containsKatex&&e.isConclusive)&&i.some(e=>!e.containsKatex&&!e.isSafe),isSafe:o,isSafeInAttributeContext:!1}},Cd=(e,t)=>{let n=e;for(;n.parent&&n!==t;){let e=n.parent;if(y(e,`BlockStatement`)){let t=e.body.findIndex(e=>e===n);if(t>0&&e.body.slice(0,t).some(e=>R(e)))return!0}if(y(e,`SwitchCase`)){let t=e.consequent.findIndex(e=>e===n);if(t>0&&e.consequent.slice(0,t).some(e=>R(e)))return!0}if(y(e,`IfStatement`)&&y(e.test,`Literal`)){let t=e.alternate,r=e.consequent,i=!!e.test.value;if(!i&&r===n||i&&t===n)return!0}if(y(e,`WhileStatement`)&&e.body===n){let t=e.test;if(y(t,`Literal`)&&!t.value)return!0}if(y(e,`ForStatement`)&&e.body===n){let t=e.test;if(t&&y(t,`Literal`)&&!t.value)return!0}n=e}return!1},wd=(e,t,n,r=new Map)=>{if(!v(e))return Z;if(!y(e.body,`BlockStatement`))return Q(e.body,t,n,r);let i=e.body,a=[];return A(i,e=>{if(e!==i&&v(e))return!1;if(y(e,`ReturnStatement`))return Cd(e,i)||a.push(e.argument?Q(e.argument,t,new Set(n),r):cd),!1}),a.length===0?cd:hd(a)},Td=(e,t)=>{let n=O(e);if(!y(n,`Identifier`))return null;let r=P(n,t);if(!r||r.references.some(e=>e.flag!==`read`))return null;if(r.kind===`function`&&v(r.declarationNode))return{functionNode:r.declarationNode,symbol:r};if(r.kind!==`const`||!r.initializer)return null;let i=O(r.initializer);return v(i)?{functionNode:i,symbol:r}:null},Ed=(e,t,n,r)=>{let i=new Map;if(!v(e))return i;let a=(e,t)=>e===void 0||y(e,`Identifier`)&&e.name===`undefined`&&t.isGlobalReference(e)||y(e,`UnaryExpression`)&&e.operator===`void`,o=(e,t,n,a)=>a?od(r,i,()=>sd(e,t,n,new Set)):sd(e,t,n,new Set);for(let[s,c]of e.params.entries()){let e=t.arguments[s],l=y(c,`AssignmentPattern`)&&a(e,n),u=l&&y(c,`AssignmentPattern`)?c.right:e,d=l?r:n,f=l?c:t,p=y(c,`AssignmentPattern`)?c.left:c;if(y(p,`Identifier`)){let e=r.symbolFor(p);if(!e||e.references.some(e=>e.flag!==`read`))continue;i.set(e.id,o(u,f,d,l));continue}if(!(!y(p,`ObjectPattern`)||!u))for(let e of p.properties){if(!y(e,`Property`))continue;let t=M(e,{allowComputedString:!0});if(t===null)continue;let n=gd(u,t),s=y(e.value,`AssignmentPattern`)?e.value.left:e.value;if(!y(s,`Identifier`))continue;let c=r.symbolFor(s);if(!n.isKnown||!c||c.references.some(e=>e.flag!==`read`))continue;let l=y(e.value,`AssignmentPattern`)&&(n.value===null||a(n.value??void 0,d)),p=l&&y(e.value,`AssignmentPattern`)?e.value.right:n.value??void 0,m=l?r:d,h=l?e:f;i.set(c.id,o(p,h,m,l))}}return i},Dd=(e,t)=>{let n=O(e.callee);if(!y(n,`Identifier`))return null;let r=P(n,t);if(!r||r.kind!==`import`)return null;let i=Ou(r),a=j(r.declarationNode),o=fd.get(t),s=i?.source.value,c=pd.get(t)??0;if(!o||typeof s!=`string`||!a||c>=2)return null;let l=xn(o,s,a);if(!l||!v(l.functionNode))return null;let u=Ie(l.programNode);return md(u,l.filePath,c+1),od(u,Ed(l.functionNode,e,t,u),()=>wd(l.functionNode,u,new Set))},Od=(e,t,n,r)=>{if(!y(e,`CallExpression`))return Z;let i=O(e.callee);if(y(i,`MemberExpression`)&&N(i)===`renderToString`&&Yu(i.object,e,t)||Xu(i,e,t))return{containsKatex:!0,isConclusive:!0,isSafe:sd(e.arguments[1],e,t,new Set).isSafe,isSafeInAttributeContext:!1};let a=Dd(e,t);if(a?.containsKatex)return a;let o=Td(i,t);if(o&&!n.has(o.symbol.id)){let i=new Set(n);i.add(o.symbol.id);let a=e.arguments.map(e=>{let i=O(e);return v(i)?wd(i,t,new Set(n),r):Q(i,t,new Set(n),r)}),s=new Map,c=!1;if(v(o.functionNode))for(let[e,n]of o.functionNode.params.entries()){if(!y(n,`Identifier`))continue;let r=t.symbolFor(n),i=a[e],o=r?.references.every(e=>e.flag===`read`);r&&i&&o&&s.set(r.id,i),i?.containsKatex&&r&&!o&&(c=!0)}let l=od(t,Ed(o.functionNode,e,t,t),()=>wd(o.functionNode,t,i,s));return!a.some(e=>e.containsKatex)||l.containsKatex?l:c?ud:dd}if(Zu(i,t))return{containsKatex:!0,isConclusive:!0,isSafe:!1,isSafeInAttributeContext:!1};if(y(i,`MemberExpression`)){let a=Q(i.object,t,new Set(n),r);if(a.containsKatex)return bd(e,a)||(a.isConclusive?{containsKatex:!0,isConclusive:!0,isSafe:!1,isSafeInAttributeContext:!1}:ud)}let s=yd(e,t);if(s)return s;if(vd(e,t))return ld;if(_d(i,t)){let i=e.arguments[0];if(!i)return Z;let a=O(i);if(v(a))return wd(a,t,new Set(n),r);let o=Td(a,t);if(!o||n.has(o.symbol.id))return Z;let s=new Set(n);return s.add(o.symbol.id),wd(o.functionNode,t,s,r)}return e.arguments.some(e=>{let i=O(e);return(v(i)?wd(i,t,new Set(n),r):Q(i,t,new Set(n),r)).containsKatex})?ud:Z},kd=(e,t)=>{let n=Du(e);if(y(n,`Literal`))return!!n.value;if(y(n,`Identifier`)&&(n.name===`undefined`||n.name===`NaN`)&&t.isGlobalReference(n))return!1;if(y(n,`TemplateLiteral`)){let e=pa(n);return e===null?null:!!e}if(y(n,`ArrayExpression`)||y(n,`ObjectExpression`)||y(n,`ArrowFunctionExpression`)||y(n,`FunctionExpression`)||y(n,`ClassExpression`)||y(n,`NewExpression`)||y(n,`JSXElement`)||y(n,`JSXFragment`))return!0;if(y(n,`UnaryExpression`)){if(n.operator===`void`)return!1;if(n.operator===`typeof`)return!0;if(n.operator===`!`){let e=kd(n.argument,t);return e===null?null:!e}}return null},Q=(e,t,n,r=new Map)=>{let i=O(e);if(y(i,`Literal`)||y(i,`UnaryExpression`)&&i.operator===`void`)return cd;if(y(i,`Identifier`)){if((i.name===`undefined`||i.name===`NaN`)&&t.isGlobalReference(i))return cd;let e=t.referenceFor(i)?.resolvedSymbol,a=e?r.get(e.id):void 0;if(a)return a;if(!e||e.kind!==`const`||!e.initializer||n.has(e.id))return Z;let o=new Set(n);return o.add(e.id),Q(e.initializer,t,o,r)}if(y(i,`CallExpression`))return Od(i,t,n,r);if(y(i,`TemplateLiteral`))return Sd(i,t,n,r);if(y(i,`ConditionalExpression`)){let e=kd(i.test,t);return e===null?hd([Q(i.consequent,t,new Set(n),r),Q(i.alternate,t,new Set(n),r)]):Q(e?i.consequent:i.alternate,t,new Set(n),r)}if(y(i,`LogicalExpression`)){let e=i.operator===`??`?null:kd(i.left,t);if(e!==null)return Q(i.operator===`&&`?e?i.right:i.left:e?i.left:i.right,t,new Set(n),r);let a=ju(i);if(a.length===1)return Q(a[0]??i,t,new Set(n),r);let o=[i.left,i.right].map(e=>Q(e,t,new Set(n),r));return{...i.operator===`&&`?o[1]??Z:hd(a.map(e=>Q(e,t,new Set(n),r))),containsKatex:o.some(e=>e.containsKatex)}}if(y(i,`BinaryExpression`)&&i.operator===`+`)return hd([Q(i.left,t,new Set(n),r),Q(i.right,t,new Set(n),r)]);if(y(i,`SequenceExpression`)){let e=i.expressions.at(-1);return e?Q(e,t,n,r):Z}return Z},Ad=e=>{let t=null;if(y(e,`JSXAttribute`)&&y(e.name,`JSXIdentifier`)&&e.name.name===`dangerouslySetInnerHTML`&&y(e.value,`JSXExpressionContainer`)&&y(e.value.expression,`ObjectExpression`)&&(t=e.value.expression),y(e,`Property`)&&M(e,{allowComputedString:!0})===`dangerouslySetInnerHTML`&&y(O(e.value),`ObjectExpression`)&&(t=O(e.value)),!y(t,`ObjectExpression`))return null;let n=null;for(let e of t.properties){if(y(e,`SpreadElement`)){n=null;continue}if(!y(e,`Property`)){n=null;continue}let t=M(e,{allowComputedString:!0});if(t===null){n=null;continue}t===`__html`&&(n=e.value)}return n},jd=(e,t)=>{let n=Rt({filename:t,sourceText:e});if(n===null)return[];let r=Ie(n);md(r,t,0);let i=[];return A(n,e=>{let t=Ad(e);if(t===null)return;let n=Q(t,r,new Set);if(!n.containsKatex)return;let a=Y(e),o=Eu(e);a<0||o<0||i.push({endIndex:o,proof:n,startIndex:a})}),i},Md=/dangerouslySetInnerHTML|(?:\.(?:inner|outer)HTML|\[\s*["'](?:inner|outer)HTML["']\s*\])\s*[+]?=(?!=)|\.insertAdjacentHTML\s*\(|\bdocument\.write(?:ln)?\s*\(|\.(?:createContextualFragment|setHTMLUnsafe)\s*\(/,Nd=/(?:__html\s*:|(?:\.(?:inner|outer)HTML|\[\s*["'](?:inner|outer)HTML["']\s*\])\s*[+]?=(?!=)|\.insertAdjacentHTML\s*\(\s*[^,]*,|\bdocument\.write(?:ln)?\s*\(|\.(?:createContextualFragment|setHTMLUnsafe)\s*\()\s*([\s\S]*)/,Pd=/searchParams|query|params|request|req\.|response\.|result\.|data\.|await|fetch|props\.|children|content|html|body|text|message|markup|\blocation\b|document\.cookie|\breferrer\b|\blocalStorage\b|\bsessionStorage\b|URLSearchParams|window\.name/i,Fd=/^(?:"(?:\\.|[^"\\\n])*"|'(?:\\.|[^'\\\n])*'|`[^`$]*`)\s*(?:\/\/[^\n]*)?\s*(?:[;,})\n]|$)/,Id=/^[A-Z][A-Z0-9_]*\s*(?:\/\/[^\n]*)?\s*(?:[;,})\n]|$)/,Ld=/^[\w$]+(?:\??\.[\w$]+)*\??\.(?:inner|outer)HTML\b/,Rd=/\b(?:DOMPurify|sanitize\w*|purify|(?:escape|encode)[A-Za-z]*(?:Html|HTML|Entit\w*)|insane|xss)\b|(?<!un)safe|(?<!un)saniti[sz]/i,zd=/[:=]\s*[^\n;]*\b(?:DOMPurify\b|sanitize\w*\s*\(|purify\w*\s*\()/i,Bd=/=\s*[\w$.?[\]]*\.(?:inner|outer)HTML\s*(?:[;,)\n]|$)/,Vd=/process\.env/,Hd=/\b(?:t|i18n|translate|formatMessage|intl)\s*[.(]/,Ud=/^(?:[\w$.]+\.)?(?:toHtml|render[A-Za-z]*(?:Html|HTML)|renderToString|renderToStaticMarkup|codeToHtml|codeToHast|highlight[A-Za-z]*)\s*\(/,Wd=/\b(?:shiki|prism|hljs|highlightjs|getHighlighter|codeToHtml|codeToHast|refractor|lowlight|starry-night)\b|highlight\.js/i,Gd=/[:=]\s*[^\n;]*(?:\b(?:katex|shiki|hljs|prism|mermaid)\b|hast-util-to-html|renderHtmlFromRichText|(?:toHtml|render[A-Za-z]*(?:Html|HTML)|renderToString|renderToStaticMarkup|codeToHtml|codeToHast)\s*\()/i,Kd=/\b(?:(?:katex|shiki|hljs|prism|mermaid|highlighter)[\w$]*\.(?:render\w*|highlight\w*|codeTo(?:Html|Hast))|(?:toHtml|render(?:Html|HTML)[A-Za-z]*|render[A-Za-z]*(?:Html|HTML)|renderToString|renderToStaticMarkup|codeToHtml|codeToHast|highlight[A-Za-z]*))\s*\(/i,qd=/^[\w$]+\s*(?:[;,})\n]|$)/,Jd=/^[\w$]+\s*(?:\|\||\?\?)\s*(?:"[^"\n]*"|'[^'\n]*'|`[^`$]*`)\s*(?:[;,})\n]|$)/,Yd=/^[\w$]+(?:\.[\w$]+|\[[^\]]*\])+\s*(?:[;,})\n]|$)/,Xd=/<style\b[^<>]*$/,Zd=/(?:^|\/)emails(?:\/|$)|email[-_.]templates?(?:\/|$)|RawHtml|[A-Za-z]*[Ee]mail[A-Za-z]*\.(?:t|j)sx?/i,Qd=/(?:^|\/)\.[\w-]+\//,$d=/(?<!un)saniti[sz]e?d?[\w-]*\.[cm]?[jt]sx?$/i,ef=/(?:^|[^\w$.])([\w$]+(?:\.[\w$]+)*)(?:(?:\.(?:inner|outer)HTML|\[\s*["'](?:inner|outer)HTML["']\s*\])\s*[+]?=(?!=)|\.insertAdjacentHTML\s*\()/,tf=/\b(?:appendChild|append|prepend|before|after|replaceWith|replaceChild|replaceChildren|insertBefore|insertAdjacentElement)\s*\(/,nf=5e3,rf=e=>{if(!e.startsWith("`"))return null;let t=e.indexOf("`",1);if(t<0||t>nf)return null;let n=e.slice(1,t).match(/\$\{[^}]*\}/g);return n===null?``:n.join(` `)},af=(e,t,n)=>{let r=ff(e,t,n);return r===null?null:n.slice(r.initializerStartIndex,r.initializerStartIndex+nf)},of=e=>{if(!/^["']/.test(e))return!1;let t=e.replace(/"(?:\\.|[^"\\\n])*"|'(?:\\.|[^'\\\n])*'/g,``),n=t.search(/[;,})\]]/),r=n>=0?t.slice(0,n):t;return/^[\s+]*$/.test(r)},sf=(e,t)=>{let n=t.includes(`createElement`),r=t.includes(`createHTMLDocument`);if(!n&&!r)return!1;let i=J(e),a=J(e.split(`.`)[0]??e);if(RegExp(`\\b${a}\\s*=\\s*[^\\n;]*(?:getElementById|querySelector|getElementsBy|\\.current\\b|document\\.(?:body|head|documentElement))`).test(t))return!1;if(n&&(RegExp(`${i}\\s*=\\s*document\\.createElement\\(\\s*["'\`]template["'\`]`).test(t)||RegExp(`${a}\\s*=\\s*[^\\n;]*\\bcreateElement\\(\\s*["'\`](?:style|textarea)["'\`]`).test(t))||r&&RegExp(`${a}\\s*=\\s*[^\\n;]*\\bcreateHTMLDocument\\s*\\(`).test(t))return!0;if(!n||!RegExp(`${a}\\s*=\\s*[^\\n;]*\\bcreateElement\\s*\\(`).test(t))return!1;let o=RegExp(`${tf.source}[^)]*\\b${a}\\b`),s=RegExp(`\\breturn\\b[^\\n]*\\b${a}\\b(?!\\s*\\.\\s*(?:textContent|innerText|innerHTML|outerHTML))`);return o.test(t)||s.test(t)?!1:RegExp(`\\b${a}\\.(?:textContent|innerText|querySelector|querySelectorAll|children|childNodes)\\b`).test(t)},cf=e=>{let t=[],n=``,r=0,i=null;for(let a=0;a<e.length;a+=1){let o=e[a];if(i!==null){n+=o,o===i&&e[a-1]!==`\\`&&(i=null);continue}if(o===`"`||o===`'`||o==="`"){i=o,n+=o;continue}if(o===`(`||o===`[`||o===`{`?r+=1:(o===`)`||o===`]`||o===`}`)&&--r,o===`+`&&r===0&&e[a-1]!==`+`&&e[a+1]!==`+`){t.push(n),n=``;continue}n+=o}return t.push(n),t},lf=e=>{let t=e.replace(/[;}]\s*$/,``).trim();if(!t.includes(`+`))return!1;let n=cf(t).map(e=>e.trim()).filter(e=>e.length>0);return n.length<2?!1:n.every(e=>{let t=e.replace(/\(\s*([\w$]+(?:\??\.[\w$]+)*)\s+as\s+[^)]*\)/g,`$1`);return Ld.test(t)?!Pd.test(t.replace(Ld,``)):!1})},uf=(e,t)=>{let n=0,r=null;for(let i=t;i<e.length;i+=1){let t=e[i];if(r!==null){t===r&&e[i-1]!==`\\`&&(r=null);continue}if(t===`"`||t===`'`||t==="`"){r=t;continue}if(t===`{`&&(n+=1),t===`}`&&(--n,n===0))return i}return e.length},df=(e,t)=>{let n=[],r=null,i=!1,a=!1;for(let o=0;o<t;o+=1){let t=e[o],s=e[o+1];if(i){t===`
|
|
13
|
-
`&&(i=!1);continue}if(a){t===`*`&&s===`/`&&(a=!1,o+=1);continue}if(r!==null){t===r&&e[o-1]!==`\\`&&(r=null);continue}if(t===`/`&&s===`/`){i=!0,o+=1;continue}if(t===`/`&&s===`*`){a=!0,o+=1;continue}if(t===`"`||t===`'`||t==="`"){r=t;continue}t===`{`&&n.push(o),t===`}`&&n.pop()}let o=n.at(-1);return o===void 0?e.length:
|
|
14
|
-
`);for(let i=0;i<r.length;i+=1){let a=r[i]??``;if(!
|
|
15
|
-
`),c=
|
|
16
|
-
`).length+ +(i>0)+a.search(
|
|
17
|
-
`))?.[1]?.trimStart(),te=
|
|
18
|
-
`).slice(0,-a.length+a.search(
|
|
12
|
+
`);if(!cu.test(t)||uu.test(t)||!s&&!lu.test(t))continue;let n=Math.max(e.lines.findIndex(e=>cu.test(e)),0),r=e.lines[n].search(cu);return[{message:du,line:e.startLineIndex+n+1,column:(r===-1?0:r)+1}]}return[]},mu=q({shouldScan:e=>zc(e.relativePath)&&!e.relativePath.endsWith(`package.json`)&&!fu(e.relativePath),pattern:su,message:du}),hu=W({id:`build-pipeline-secret-boundary`,title:`Build pipeline runs code near secrets`,severity:`warn`,recommendation:`Run dependency installs with scripts disabled before exposing secrets, isolate untrusted build code, and move signing/deploy authority into a narrow privileged step.`,scan:e=>fu(e.relativePath)?pu(e.content):mu(e)}),gu=W({id:`clickjacking-redirect-risk`,title:`Redirect or frame boundary risk`,severity:`warn`,recommendation:"Allowlist redirect origins/paths, set `frame-ancestors` for privileged pages, and avoid URL-prefilled privileged dialogs.",scan:q({shouldScan:e=>K(e.relativePath)||zc(e.relativePath),pattern:/\bredirect\s*\((?!\s*(?:await\s+)?[\w$]*(?:safe|valid|sanitiz|allowlist|whitelist)[\w$]*\s*\()[^)'"`\n]*\b(?:searchParams\.get|nextUrl\.searchParams|returnTo|callbackUrl|continue|next)\b|<iframe\b[\s\S]{0,700}(?:\b(?:next=|continue=|redirect=|redirect_uri|userstoinvite|sharingaction|\.\.)|[?&](?:amp;)?role=)|frame-ancestors\s+(?:\*|'self'\s+\*)|X-Frame-Options["']?\s*:\s*["']?ALLOW/i,message:`Redirect or framing configuration may let attacker-controlled URLs chain into privileged UI or clickjacking.`})}),_u=e=>/(?:^|\/)(?:tools?|scripts?)\/|(?:^|\/)management\/commands\/|(?:^|\/)(?:build|make|gulpfile|gruntfile)\.[cm]?[jt]s$/i.test(e),vu=e=>Vc(e,wc),yu=String.raw`(?:req\.|request\.|params\.|query\.|body\.|searchParams|\$_(?:GET|POST|REQUEST))`,bu=String.raw`(?:(?<![.\w$])(?:exec(?:Sync)?|system|passthru|proc_open|shell_exec)|\b(?:os\.system|subprocess\.(?:run|Popen|call)|(?:child_process|childProcess|cp)\.exec\w*))`,xu=String.raw`(?:(?<![.\w$])spawn(?:Sync)?|\b(?:child_process|childProcess|cp)\.spawn\w*)`,Su=String.raw`['"](?:sh|bash|zsh|dash|ksh|cmd(?:\.exe)?|powershell(?:\.exe)?|pwsh)['"]`,Cu=String.raw`['"](?:-c|/c|-Command)['"]`,wu=W({id:`command-execution-input-risk`,title:`Command execution uses caller-shaped input`,severity:`error`,recommendation:`Avoid shell execution for caller-controlled values. Use fixed commands, argument arrays, strict allowlists, and no shell interpolation.`,scan:q({shouldScan:e=>vu(e.relativePath)&&!_u(e.relativePath),pattern:[new RegExp(String.raw`${bu}\s*\([^)]{0,220}(?:${yu}|shell\s*=\s*true|f['"\`][^'"\`]*\{)`,`i`),new RegExp(String.raw`${xu}\s*\((?:[^,)]{0,120}?${yu}|\s*${Su}\s*,\s*\[\s*${Cu}\s*,[^\]]{0,220}${yu}|(?=[^)]{0,220}shell\s*[:=]\s*true)[^)]{0,220}${yu})`,`i`)],message:`Command execution appears to include request, query, body, or shell-interpolated input.`})}),Tu=W({id:`cors-cookie-trust-risk`,title:`Broad cookie or credentialed CORS trust`,severity:`warn`,recommendation:`Keep auth cookies host-only and HttpOnly, avoid credentialed CORS for less-trusted docs/vendor origins, and isolate documentation domains from app sessions.`,scan:q({shouldScan:e=>K(e.relativePath)||zc(e.relativePath),pattern:/Access-Control-Allow-Credentials["']?\s*[:,]\s*["']?true[\s\S]{0,700}Access-Control-Allow-Origin["']?\s*[:,]\s*["']?(?:\*|https:\/\/docs\.|https:\/\/.*mintlify)|\b(?:session|auth|token|jwt)[^=\n]{0,80}(?:=[^;\n]{0,120};[^=\n]{0,80})?\bDomain=\./i,message:`Credentialed CORS or broad auth-cookie scope can make a docs/custom-domain XSS become account compromise.`})}),Eu=(e,t)=>{let n=e[t],r=n===`(`?`)`:n===`{`?`}`:n===`[`?`]`:``;if(r===``)return-1;let i=0,a=null;for(let o=t;o<e.length;o+=1){let t=e[o];if(a!==null){t===`\\`?o+=1:t===a&&(a=null);continue}if(t===`"`||t===`'`||t==="`")a=t;else if(t===n)i+=1;else if(t===r&&(--i,i===0))return o}return-1},Du=e=>`end`in e&&typeof e.end==`number`?e.end:-1,Y=e=>`start`in e&&typeof e.start==`number`?e.start:-1,Ou=e=>{let t=O(e);for(;y(t,`SequenceExpression`);){let e=t.expressions.at(-1);if(!e)break;t=O(e)}return t},ku=e=>{if(e.kind!==`import`)return null;let t=e.declarationNode.parent;return y(t,`ImportDeclaration`)?t:null},Au=e=>{let t=[],n=new Map;for(let r of e){let e=`${r.truthiness}:${r.nullishness}`,i=n.get(r.expression);i?.has(e)||(i?i.add(e):n.set(r.expression,new Set([e])),t.push(r))}return t},ju=e=>y(e,`JSXElement`)||y(e,`JSXFragment`)||y(e,`ArrayExpression`)||y(e,`ObjectExpression`)||y(e,`ArrowFunctionExpression`)||y(e,`FunctionExpression`)||y(e,`ClassExpression`)||y(e,`NewExpression`)?{expression:e,truthiness:`truthy`,nullishness:`non-nullish`}:y(e,`Literal`)?e.value===null?{expression:e,truthiness:`falsy`,nullishness:`nullish`}:{expression:e,truthiness:e.value?`truthy`:`falsy`,nullishness:`non-nullish`}:y(e,`UnaryExpression`)&&e.operator===`void`?{expression:e,truthiness:`falsy`,nullishness:`nullish`}:{expression:e,truthiness:`unknown`,nullishness:`unknown`},X=e=>{let t=Ou(e);if(y(t,`ConditionalExpression`)){let e=X(t.test);return e.every(e=>e.truthiness===`truthy`)?X(t.consequent):e.every(e=>e.truthiness===`falsy`)?X(t.alternate):Au([...X(t.consequent),...X(t.alternate)])}if(!y(t,`LogicalExpression`))return[ju(t)];let n=X(t.left),r=X(t.right),i=[];for(let e of n){if(t.operator===`&&`){e.truthiness!==`truthy`&&i.push(e.truthiness===`falsy`?e:{...e,truthiness:`falsy`}),e.truthiness!==`falsy`&&i.push(...r);continue}if(t.operator===`||`){e.truthiness!==`falsy`&&i.push(e.truthiness===`truthy`?e:{...e,truthiness:`truthy`,nullishness:`non-nullish`}),e.truthiness!==`truthy`&&i.push(...r);continue}e.nullishness!==`nullish`&&i.push(e.nullishness===`non-nullish`?e:{...e,nullishness:`non-nullish`}),e.nullishness!==`non-nullish`&&i.push(...r)}return Au(i)},Mu=e=>{let t=[],n=new Set;for(let r of X(e))n.has(r.expression)||(n.add(r.expression),t.push(r.expression));return t},Nu=new Set([`assign`,`defineProperties`,`defineProperty`]),Pu=new Set([`defineProperty`,`set`]),Fu=new WeakMap,Iu=e=>{let t=I(e);for(;t.parent;){let e=t.parent;if(!y(e,`MemberExpression`)||e.object!==t)break;t=I(e)}return t},Lu=e=>{let t=e;for(;t;){if(v(t)||y(t,`Program`))return t;t=t.parent}return e},Ru=(e,t)=>{if(y(e,`ReturnStatement`)||y(e,`ThrowStatement`)||y(e,`BreakStatement`)||t&&y(e,`ContinueStatement`))return!0;if(y(e,`BlockStatement`))return e.body.some(e=>Ru(e,t));if(!y(e,`IfStatement`))return!1;if(y(e.test,`Literal`)){let n=e.test.value?e.consequent:e.alternate;return n?Ru(n,t):!1}return!!(e.alternate&&Ru(e.consequent,t)&&Ru(e.alternate,t))},zu=e=>Ru(e,!0),Bu=(e,t)=>{let n=t.indexOf(e);return n>0&&t.slice(0,n).some(zu)},Vu=(e,t)=>{let n=e;for(;n.parent&&n!==t;){let e=n.parent;if((y(e,`BlockStatement`)||y(e,`Program`))&&Bu(n,e.body)||(y(e,`WhileStatement`)&&y(e.test,`Literal`)&&!e.test.value||y(e,`ForStatement`)&&e.test&&y(e.test,`Literal`)&&!e.test.value)&&e.body===n||y(e,`SwitchCase`)&&Bu(n,e.consequent)||y(e,`IfStatement`)&&y(e.test,`Literal`)&&(e.test.value===!1&&e.consequent===n||e.test.value===!0&&e.alternate===n)||y(e,`ConditionalExpression`)&&y(e.test,`Literal`)&&(e.test.value===!1&&e.consequent===n||e.test.value===!0&&e.alternate===n)||y(e,`LogicalExpression`)&&e.right===n&&y(e.left,`Literal`)&&(e.operator===`&&`&&!e.left.value||e.operator===`||`&&e.left.value))return!0;n=e}return!1},Hu=(e,t)=>{let n=e;for(;n.parent&&n!==t;){let e=n.parent;if(y(e,`IfStatement`)&&(!y(e.test,`Literal`)||e.test.value===!0&&e.alternate===n||e.test.value===!1&&e.consequent===n)||y(e,`ConditionalExpression`)&&(!y(e.test,`Literal`)||e.test.value===!0&&e.alternate===n||e.test.value===!1&&e.consequent===n)||y(e,`LogicalExpression`)&&e.right===n&&(!y(e.left,`Literal`)||e.operator===`&&`&&!e.left.value||e.operator===`||`&&e.left.value)||y(e,`DoWhileStatement`)&&!(e.body===n&&y(e.test,`Literal`)&&!e.test.value)||y(e,`TryStatement`)&&e.block===n||y(e,`ForStatement`)||y(e,`ForInStatement`)||y(e,`ForOfStatement`)||y(e,`WhileStatement`)||y(e,`SwitchCase`)||y(e,`CatchClause`)||(y(e,`CallExpression`)||y(e,`MemberExpression`))&&e.optional)return!0;n=e}return!1},Uu=e=>{let t=Fu.get(e);if(t)return t;let n=(t,n,r)=>{let i=O(t);if(!y(i,`MemberExpression`))return!1;let a=O(i.object);return!!(y(a,`Identifier`)&&a.name===n&&e.isGlobalReference(a)&&r.has(N(i)??``))},r=e=>{let t=O(e);if(!y(t,`ObjectExpression`))return null;let n=new Set;for(let e of t.properties){if(!y(e,`Property`))return null;let t=M(e,{allowComputedString:!0});if(t===null)return null;n.add(t)}return n},i=e=>{let t=Iu(e),i=t.parent;if(i){if(y(i,`AssignmentExpression`)&&i.left===t||y(i,`UpdateExpression`)&&i.argument===t||y(i,`UnaryExpression`)&&i.operator===`delete`){if(!y(t,`MemberExpression`))return null;let e=N(t);return e===null?null:new Set([e])}if(!(!y(i,`CallExpression`)||i.arguments[0]!==t)){if(n(i.callee,`Object`,Nu)){let e=O(i.callee);if(!y(e,`MemberExpression`))return;let t=N(e);if(t===`assign`){let e=i.arguments.slice(1).map(r);return e.some(e=>e===null)?null:new Set(e.flatMap(e=>[...e??[]]))}if(t===`defineProperties`){let e=i.arguments[1];return e?r(e):null}let n=i.arguments[1];return n&&y(n,`Literal`)&&typeof n.value==`string`?new Set([n.value]):null}if(n(i.callee,`Reflect`,Pu)){let e=i.arguments[1];return e&&y(e,`Literal`)&&typeof e.value==`string`?new Set([e.value]):null}}}},a=t=>{let n=O(t.callee);if(v(n))return n;if(!y(n,`Identifier`))return null;let r=P(n,e);if(!r)return null;if(r.kind===`function`&&v(r.declarationNode))return r.declarationNode;if(r.kind!==`const`||!r.initializer)return null;let i=O(r.initializer);return v(i)?i:null},o=[],s=new Map;A(e.rootScope.node,t=>{if(y(t,`CallExpression`)){let e=Lu(t),n=a(t);n&&!Vu(t,e)&&o.push({call:t,owner:e,targetOwner:n})}if(!y(t,`Identifier`))return;let n=i(t);if(n===void 0)return;let r=P(t,e);if(!r)return;let c=Lu(t);if(Vu(t,c))return;let l=s.get(r.id)??[];l.push({node:t,owner:c,propertyNames:n}),s.set(r.id,l)});let c=t=>{let n=Lu(t),r=Y(t),i=new Set,a=(e,t)=>{for(let n of o)n.owner!==e||Y(n.call)>=t||i.has(n.targetOwner)||(i.add(n.targetOwner),a(n.targetOwner,1/0))};return a(n,r),y(n,`Program`)||a(e.rootScope.node,1/0),i},l=e=>{if(y(e,`Program`))return 1/0;let t=o.find(t=>y(t.owner,`Program`)&&t.targetOwner===e);return t?Y(t.call):1/0},u=new Map;for(let e of o){let t=u.get(e.owner)??[];t.push(e),u.set(e.owner,t)}let d=new WeakMap,f=(e,t)=>{let n=d.get(e)?.get(t);if(n!==void 0)return n;let r=[e],i=new Set,a=!1;for(;r.length>0;){let e=r.pop();if(!(!e||i.has(e))){if(e===t){a=!0;break}i.add(e);for(let t of u.get(e)??[])r.push(t.targetOwner)}}let o=d.get(e)??new WeakMap;return o.set(t,a),d.set(e,o),a},p=(e,t)=>{let n=new Set,r=e;for(;r?.parent&&r!==t;){let t=r.parent,i=y(t,`DoWhileStatement`)&&y(t.test,`Literal`)&&!t.test.value,a=y(t,`ForStatement`)||y(t,`ForInStatement`)||y(t,`ForOfStatement`)||y(t,`WhileStatement`)||y(t,`DoWhileStatement`)?t.body:null,o=e;for(;a&&y(a,`BlockStatement`)&&o&&o.parent!==a;)o=o.parent??null;let s=a&&y(a,`BlockStatement`)&&o?a.body.findIndex(e=>e===o):-1,c=!!(a&&y(a,`BlockStatement`)&&s>=0&&a.body.slice(s+1).some(e=>Ru(e,!1)));a&&!i&&!c&&n.add(t),r=t}return n},m=(e,t,n)=>{let r=p(e,n);return r.size===0?!1:[...p(t,n)].some(e=>r.has(e))},h=new WeakMap,ee=e=>{let t=h.get(e);if(t)return t;let n=new Map;for(let t of o){if(!f(t.targetOwner,e))continue;let r=n.get(t.owner)??[];r.push(t),n.set(t.owner,r)}return h.set(e,n),n},te=(e,t)=>{let n=ee(e),r=ee(t);for(let[e,t]of n){let n=r.get(e);if(n){for(let r of t)for(let t of n)if(r!==t&&(Y(r.call)<Y(t.call)||v(e)||m(r.call,t.call,e)))return!0}}return!1},g={getEventsBefore:(t,n)=>{let r=s.get(t.id)??[],i=[],a=(e,t,n,s)=>{if(n.has(e))return;let c=new Set(n);c.add(e);let l=[...r.filter(t=>t.owner===e).map(e=>({event:e,index:Y(e.node)})),...o.filter(t=>t.owner===e).map(e=>({call:e,index:Y(e.call)}))].sort((e,t)=>e.index-t.index);for(let e of l){if(e.index>=t)break;if(`event`in e){i.push({isConditional:s||Hu(e.event.node,e.event.owner),node:e.event.node});continue}a(e.call.targetOwner,1/0,c,s||Hu(e.call.call,e.call.owner))}},c=Lu(n);return y(c,`Program`)||a(e.rootScope.node,l(c),new Set,!1),a(c,Y(n),new Set,!1),i},getOutermostTarget:Iu,isGlobalNamespaceMethod:n,isExecutionOrderAmbiguous:e=>{let t=Lu(e);if(y(t,`Program`))return!1;let n=o.filter(e=>y(e.owner,`Program`)&&f(e.targetOwner,t));return n.length===0?!1:n.length!==1||n[0]?.targetOwner!==t},isMutationOrderAmbiguous:(e,t,n)=>{let r=Lu(t),i=Y(t);return(s.get(e.id)??[]).some(e=>n!==null&&e.propertyNames!==null&&!e.propertyNames.has(n)?!1:e.owner===r?Y(e.node)>=i&&(v(r)||m(e.node,t,r)):y(e.owner,`Program`)?(ee(r).get(e.owner)??[]).some(t=>m(e.node,t.call,e.owner)):f(e.owner,r)||te(e.owner,r))},isMutatedBefore:(e,t,n)=>{let r=s.get(e.id);if(!r)return!1;let i=Y(t),a=Lu(t),o=c(t);return r.some(e=>n!==null&&e.propertyNames!==null&&!e.propertyNames.has(n)?!1:e.owner===a?Y(e.node)<i:y(e.owner,`Program`)&&!y(a,`Program`)?Y(e.node)<l(a):o.has(e.owner))}};return Fu.set(e,g),g},Wu=(e,t)=>t===`katex`?e===`katex`||e.startsWith(`katex/`):e===t,Gu=(e,t,n)=>{let r=O(e);if(!y(r,`CallExpression`))return!1;let i=O(r.callee),a=r.arguments[0];return!!(y(i,`Identifier`)&&i.name===`require`&&n.isGlobalReference(i)&&a&&y(a,`Literal`)&&typeof a.value==`string`&&Wu(a.value,t))},Ku=(e,t)=>{if(e.kind!==`ts-import-equals`)return!1;let n=e.declarationNode;if(!y(n,`TSImportEqualsDeclaration`))return!1;let r=n.moduleReference;return!!(y(r,`TSExternalModuleReference`)&&y(r.expression,`Literal`)&&typeof r.expression.value==`string`&&Wu(r.expression.value,t))},qu=(e,t)=>{let n=O(e);return!!(y(n,`AwaitExpression`)&&y(n.argument,`ImportExpression`)&&y(n.argument.source,`Literal`)&&typeof n.argument.source.value==`string`&&Wu(n.argument.source.value,t))},Ju=(e,t,n,r,i)=>{let a=P(O(e),i),o=Uu(i);if(!a||o.isExecutionOrderAmbiguous(r)||o.isMutationOrderAmbiguous(a,r,n)||o.isMutatedBefore(a,r,n))return null;let s=ku(a);if(typeof s?.source.value==`string`&&Wu(s.source.value,t))return y(a.declarationNode,`ImportDefaultSpecifier`)||y(a.declarationNode,`ImportNamespaceSpecifier`)||j(a.declarationNode)===`default`?a:null;if(Ku(a,t))return a;if(a.kind!==`const`||!a.initializer)return null;let c=O(a.initializer);return Gu(c,t,i)||y(c,`MemberExpression`)&&N(c)===`default`&&(Gu(c.object,t,i)||qu(c.object,t))||qu(c,t)?a:null},Yu=(e,t,n,r,i)=>{let a=P(O(e),i);if(!a)return null;let o=ku(a),s=Uu(i);return typeof o?.source.value!=`string`||!Wu(o.source.value,t)||j(a.declarationNode)!==n||s.isExecutionOrderAmbiguous(r)||s.isMutationOrderAmbiguous(a,r,null)||s.isMutatedBefore(a,r,null)?null:a},Xu=(e,t,n)=>Ju(e,`katex`,`renderToString`,t,n)!==null||Gu(e,`katex`,n),Zu=(e,t,n)=>{if(Yu(e,`katex`,`renderToString`,t,n))return!0;let r=O(e);if(!y(r,`Identifier`))return!1;let i=n.referenceFor(r)?.resolvedSymbol;if(!i||i.kind!==`const`||!i.initializer||Uu(n).isMutatedBefore(i,t,null))return!1;let a=O(i.initializer),o=i.bindingIdentifier.parent;return y(o,`Property`)&&M(o,{allowComputedString:!0})===`renderToString`?Xu(a,i.declarationNode,n):y(a,`MemberExpression`)&&N(a)===`renderToString`&&Xu(a.object,i.declarationNode,n)?!0:y(a,`Identifier`)?Zu(a,i.declarationNode,n):!1},Qu=(e,t)=>{let n=O(e);if(y(n,`Identifier`)){if(!/katex/i.test(n.name))return!1;let e=t.referenceFor(n)?.resolvedSymbol;return!!(e&&e.kind!==`parameter`&&e.kind!==`let`)}if(!y(n,`MemberExpression`)||N(n)!==`renderToString`)return!1;let r=O(n.object);if(!y(r,`Identifier`)||!/katex/i.test(r.name))return!1;let i=t.referenceFor(r)?.resolvedSymbol;if(!i)return!1;if(i.kind===`import`){if(!Wu(String(ku(i)?.source.value??``),`katex`))return!0;let e=Uu(t);return e.isExecutionOrderAmbiguous(n)||e.isMutationOrderAmbiguous(i,n,`renderToString`)?!1:e.isMutatedBefore(i,n,`renderToString`)}if(i.kind===`parameter`||i.kind===`let`||i.kind===`var`)return!0;if(i.kind!==`const`||!i.initializer)return!1;let a=O(i.initializer);if(y(a,`ObjectExpression`))return!0;if(y(a,`CallExpression`)){let e=O(a.callee);return y(e,`Identifier`)&&e.name===`require`}return y(a,`AwaitExpression`)&&y(a.argument,`ImportExpression`)},$u=new WeakMap,ed=(e,t)=>{let n=O(e);return y(n,`Identifier`)?n.name===`undefined`&&t.isGlobalReference(n):y(n,`Literal`)&&!n.value},td=(e,t)=>{let n=O(e);if(!y(n,`ObjectExpression`))return null;let r;for(let e of n.properties){if(!y(e,`Property`))return null;let n=M(e,{allowComputedString:!0});if(n===null)return null;if(n===t){if(e.kind!==`init`)return null;r=e.value}}return r},nd=e=>{let t=O(e);if(!y(t,`ObjectExpression`))return null;for(let e of t.properties){if(!y(e,`Property`))return null;let t=M(e,{allowComputedString:!0});if(t===null||t===`get`||t===`set`)return null}return td(t,`value`)},rd=(e,t,n)=>{let r=nd(t);return r===null?`trusted`:r===void 0?e:ed(r,n)?`untrusted`:`trusted`},id=(e,t)=>e===t?e:e===`trusted`||t===`trusted`?`trusted`:e===`unsupported`||t===`unsupported`?`unsupported`:`untrusted`,ad=(e,t,n,r)=>{let i=Uu(n),a=i.getOutermostTarget(t),o=a.parent;if(!o)return`unsupported`;if(y(o,`AssignmentExpression`)&&o.left===a){if(!y(a,`MemberExpression`))return`unsupported`;let t=N(a);return t===null?`trusted`:t===`trust`?ed(o.right,n)?`untrusted`:`trusted`:e}if(y(o,`UnaryExpression`)&&o.operator===`delete`){if(!y(a,`MemberExpression`))return`unsupported`;let t=N(a);return t===null?`trusted`:t===`trust`?`absent`:e}if(y(o,`UpdateExpression`)){if(!y(a,`MemberExpression`))return`unsupported`;let t=N(a);return t===`trust`||t===null?`trusted`:e}if(!y(o,`CallExpression`)||o.arguments[0]!==a)return`unsupported`;if(i.isGlobalNamespaceMethod(o.callee,`Object`,Nu)){let t=O(o.callee);if(!y(t,`MemberExpression`))return`unsupported`;let i=N(t);if(i===`assign`){let t=e;for(let e of o.arguments.slice(1)){let i=od(e,e,n,new Set(r));i!==`absent`&&(t=i)}return t}if(i===`defineProperties`){let t=o.arguments[1];if(!t)return`unsupported`;let r=td(t,`trust`);return r===null?`trusted`:r===void 0?e:rd(e,r,n)}let a=o.arguments[1];if(!a||!y(a,`Literal`)||typeof a.value!=`string`)return`trusted`;if(a.value!==`trust`)return e;let s=o.arguments[2];return s?rd(e,s,n):`unsupported`}if(i.isGlobalNamespaceMethod(o.callee,`Reflect`,Pu)){let t=O(o.callee);if(!y(t,`MemberExpression`))return`unsupported`;let r=N(t),i=o.arguments[1];if(!i||!y(i,`Literal`)||typeof i.value!=`string`)return`trusted`;if(i.value!==`trust`)return e;let a=o.arguments[2];return a?r===`defineProperty`?rd(e,a,n):ed(a,n)?`untrusted`:`trusted`:`unsupported`}return`unsupported`},od=(e,t,n,r)=>{if(e===void 0)return`absent`;let i=O(e);if(y(i,`Identifier`)){if(i.name===`undefined`&&n.isGlobalReference(i))return`absent`;let e=P(i,n);if(!e||e.kind!==`const`||!e.initializer||r.has(e.id))return`unsupported`;let a=new Set(r);a.add(e.id);let o=Uu(n);if(o.isMutationOrderAmbiguous(e,t,`trust`))return`unsupported`;let s=od(e.initializer,t,n,a);for(let r of o.getEventsBefore(e,t)){let e=ad(s,r.node,n,a);s=r.isConditional?id(s,e):e}return s}if(!y(i,`ObjectExpression`))return`unsupported`;let a=`absent`;for(let e of i.properties){if(y(e,`SpreadElement`)){let t=od(e.argument,e.argument,n,new Set(r));t!==`absent`&&(a=t===`unsupported`?`trusted`:t);continue}if(!y(e,`Property`)){a=`trusted`;continue}let t=M(e,{allowComputedString:!0});if(t===null){a=`trusted`;continue}t===`trust`&&(a=ed(e.value,n)?`untrusted`:`trusted`)}return a},sd=(e,t,n)=>{let r=$u.get(e),i=new Map(r);for(let[e,n]of t)i.set(e,n);$u.set(e,i);try{return n()}finally{r?$u.set(e,r):$u.delete(e)}},cd=(e,t,n,r)=>{let i=e?O(e):void 0;if(i&&y(i,`Identifier`)){let e=n.referenceFor(i)?.resolvedSymbol,t=e?$u.get(n)?.get(e.id):void 0;if(t)return t}let a=od(e,t,n,r);return{isSafe:a===`absent`||a===`untrusted`}},ld={containsKatex:!1,isConclusive:!0,isSafe:!0,isSafeInAttributeContext:!0},ud={containsKatex:!1,isConclusive:!0,isSafe:!0,isSafeInAttributeContext:!1},Z={containsKatex:!1,isConclusive:!1,isSafe:!1,isSafeInAttributeContext:!1},dd={containsKatex:!0,isConclusive:!1,isSafe:!1,isSafeInAttributeContext:!1},fd={containsKatex:!0,isConclusive:!0,isSafe:!1,isSafeInAttributeContext:!1},pd=new WeakMap,md=new WeakMap,hd=(e,t,n)=>{pd.set(e,t),md.set(e,n)},gd=e=>({containsKatex:e.some(e=>e.containsKatex),isConclusive:e.every(e=>e.isSafe)?e.filter(e=>e.containsKatex).every(e=>e.isConclusive):e.some(e=>e.containsKatex&&e.isConclusive&&!e.isSafe)||e.some(e=>e.containsKatex&&e.isConclusive)&&e.some(e=>!e.containsKatex&&!e.isSafe),isSafe:e.every(e=>e.isSafe),isSafeInAttributeContext:e.every(e=>e.isSafeInAttributeContext)}),_d=(e,t)=>{let n=O(e);if(!y(n,`ObjectExpression`))return{isKnown:!1,value:null};let r=!0,i=null;for(let e of n.properties){if(!y(e,`Property`)){r=!1,i=null;continue}let n=M(e,{allowComputedString:!0});n===null?(r=!1,i=null):n===t&&(r=!0,i=e.value)}return{isKnown:r,value:i}},vd=(e,t)=>{let n=O(e);if(y(n,`Identifier`)){let e=P(n,t);return!!(e&&e.kind===`import`&&ku(e)?.source.value===`react`&&j(e.declarationNode)===`useMemo`)}if(!y(n,`MemberExpression`)||N(n)!==`useMemo`)return!1;let r=P(O(n.object),t);return!!(r&&r.kind===`import`&&ku(r)?.source.value===`react`&&(y(r.declarationNode,`ImportDefaultSpecifier`)||y(r.declarationNode,`ImportNamespaceSpecifier`)||j(r.declarationNode)===`default`))},yd=(e,t)=>{let n=O(e),r=!1;for(;y(n,`CallExpression`);){let e=O(n.callee);if(!y(e,`MemberExpression`))return!1;let t=N(e);if(t!==`replace`&&t!==`replaceAll`)return!1;let i=n.arguments[0],a=n.arguments[1];if(!i||!a||!y(a,`Literal`)||typeof a.value!=`string`||a.value.includes(`<`)||a.value.includes(`$`))return!1;if(y(i,`Literal`)){let e=`regex`in i?i.regex:void 0,n=t===`replaceAll`&&i.value===`<`,a=e?.pattern===`<`&&e.flags.includes(`g`);(n||a)&&(r=!0)}n=O(e.object)}return!r||!y(n,`Identifier`)?!1:t.referenceFor(n)?.resolvedSymbol?.kind===`parameter`},bd=(e,t)=>{let n=O(e.callee);return y(n,`MemberExpression`)&&N(n)===`sanitize`&&(Ju(n.object,`dompurify`,`sanitize`,e,t)||Ju(n.object,`isomorphic-dompurify`,`sanitize`,e,t))?ud:y(n,`MemberExpression`)&&N(n)===`escape`&&Ju(n.object,`html-escaper`,`escape`,e,t)||Yu(n,`html-escaper`,`escape`,e,t)?ld:Yu(n,`dompurify`,`sanitize`,e,t)||Yu(n,`isomorphic-dompurify`,`sanitize`,e,t)?ud:null},xd=(e,t)=>{if(!t.isSafe)return null;let n=O(e.callee);if(!y(n,`MemberExpression`))return null;let r=N(n);if((r===`trim`||r===`trimEnd`||r===`trimStart`)&&e.arguments.length===0)return t;if(r!==`replace`&&r!==`replaceAll`)return null;let i=e.arguments[1];return!i||!y(i,`Literal`)||typeof i.value!=`string`||i.value.includes(`<`)?null:{containsKatex:t.containsKatex,isConclusive:t.isConclusive,isSafe:!0,isSafeInAttributeContext:t.isSafeInAttributeContext&&!/[&>"']/.test(i.value)}},Sd=e=>{let t=e.toLowerCase();for(let e of[`script`,`style`,`textarea`,`title`])if(t.lastIndexOf(`<${e}`)>t.lastIndexOf(`</${e}`))return`raw-text`;let n=e.lastIndexOf(`<`);if(n<=e.lastIndexOf(`>`))return`text`;let r=e.slice(n+1),i=null;for(let e=0;e<r.length;e+=1){let t=r[e];(t===`"`||t===`'`)&&r[e-1]!==`\\`&&(i===t?i=null:i===null&&(i=t))}return i===null?`unsafe-tag`:`attribute`},Cd=(e,t,n,r)=>{let i=e.expressions.map(e=>Q(e,t,new Set(n),r)),a=``,o=!0;for(let t=0;t<i.length;t+=1){a+=e.quasis[t]?.value.raw??``;let n=Sd(a),r=i[t]??Z;n===`text`?o&&=r.isSafe:n===`attribute`?o&&=r.isSafeInAttributeContext:o=!1}return{containsKatex:i.some(e=>e.containsKatex),isConclusive:o?i.filter(e=>e.containsKatex).every(e=>e.isConclusive):i.some(e=>e.containsKatex&&e.isConclusive&&!e.isSafe)||i.some(e=>e.containsKatex&&e.isConclusive)&&i.some(e=>!e.containsKatex&&!e.isSafe),isSafe:o,isSafeInAttributeContext:!1}},wd=(e,t)=>{let n=e;for(;n.parent&&n!==t;){let e=n.parent;if(y(e,`BlockStatement`)){let t=e.body.findIndex(e=>e===n);if(t>0&&e.body.slice(0,t).some(e=>R(e)))return!0}if(y(e,`SwitchCase`)){let t=e.consequent.findIndex(e=>e===n);if(t>0&&e.consequent.slice(0,t).some(e=>R(e)))return!0}if(y(e,`IfStatement`)&&y(e.test,`Literal`)){let t=e.alternate,r=e.consequent,i=!!e.test.value;if(!i&&r===n||i&&t===n)return!0}if(y(e,`WhileStatement`)&&e.body===n){let t=e.test;if(y(t,`Literal`)&&!t.value)return!0}if(y(e,`ForStatement`)&&e.body===n){let t=e.test;if(t&&y(t,`Literal`)&&!t.value)return!0}n=e}return!1},Td=(e,t,n,r=new Map)=>{if(!v(e))return Z;if(!y(e.body,`BlockStatement`))return Q(e.body,t,n,r);let i=e.body,a=[];return A(i,e=>{if(e!==i&&v(e))return!1;if(y(e,`ReturnStatement`))return wd(e,i)||a.push(e.argument?Q(e.argument,t,new Set(n),r):ld),!1}),a.length===0?ld:gd(a)},Ed=(e,t)=>{let n=O(e);if(!y(n,`Identifier`))return null;let r=P(n,t);if(!r||r.references.some(e=>e.flag!==`read`))return null;if(r.kind===`function`&&v(r.declarationNode))return{functionNode:r.declarationNode,symbol:r};if(r.kind!==`const`||!r.initializer)return null;let i=O(r.initializer);return v(i)?{functionNode:i,symbol:r}:null},Dd=(e,t,n,r)=>{let i=new Map;if(!v(e))return i;let a=(e,t)=>e===void 0||y(e,`Identifier`)&&e.name===`undefined`&&t.isGlobalReference(e)||y(e,`UnaryExpression`)&&e.operator===`void`,o=(e,t,n,a)=>a?sd(r,i,()=>cd(e,t,n,new Set)):cd(e,t,n,new Set);for(let[s,c]of e.params.entries()){let e=t.arguments[s],l=y(c,`AssignmentPattern`)&&a(e,n),u=l&&y(c,`AssignmentPattern`)?c.right:e,d=l?r:n,f=l?c:t,p=y(c,`AssignmentPattern`)?c.left:c;if(y(p,`Identifier`)){let e=r.symbolFor(p);if(!e||e.references.some(e=>e.flag!==`read`))continue;i.set(e.id,o(u,f,d,l));continue}if(!(!y(p,`ObjectPattern`)||!u))for(let e of p.properties){if(!y(e,`Property`))continue;let t=M(e,{allowComputedString:!0});if(t===null)continue;let n=_d(u,t),s=y(e.value,`AssignmentPattern`)?e.value.left:e.value;if(!y(s,`Identifier`))continue;let c=r.symbolFor(s);if(!n.isKnown||!c||c.references.some(e=>e.flag!==`read`))continue;let l=y(e.value,`AssignmentPattern`)&&(n.value===null||a(n.value??void 0,d)),p=l&&y(e.value,`AssignmentPattern`)?e.value.right:n.value??void 0,m=l?r:d,h=l?e:f;i.set(c.id,o(p,h,m,l))}}return i},Od=(e,t)=>{let n=O(e.callee);if(!y(n,`Identifier`))return null;let r=P(n,t);if(!r||r.kind!==`import`)return null;let i=ku(r),a=j(r.declarationNode),o=pd.get(t),s=i?.source.value,c=md.get(t)??0;if(!o||typeof s!=`string`||!a||c>=2)return null;let l=xn(o,s,a);if(!l||!v(l.functionNode))return null;let u=Ie(l.programNode);return hd(u,l.filePath,c+1),sd(u,Dd(l.functionNode,e,t,u),()=>Td(l.functionNode,u,new Set))},kd=(e,t,n,r)=>{if(!y(e,`CallExpression`))return Z;let i=O(e.callee);if(y(i,`MemberExpression`)&&N(i)===`renderToString`&&Xu(i.object,e,t)||Zu(i,e,t))return{containsKatex:!0,isConclusive:!0,isSafe:cd(e.arguments[1],e,t,new Set).isSafe,isSafeInAttributeContext:!1};let a=Od(e,t);if(a?.containsKatex)return a;let o=Ed(i,t);if(o&&!n.has(o.symbol.id)){let i=new Set(n);i.add(o.symbol.id);let a=e.arguments.map(e=>{let i=O(e);return v(i)?Td(i,t,new Set(n),r):Q(i,t,new Set(n),r)}),s=new Map,c=!1;if(v(o.functionNode))for(let[e,n]of o.functionNode.params.entries()){if(!y(n,`Identifier`))continue;let r=t.symbolFor(n),i=a[e],o=r?.references.every(e=>e.flag===`read`);r&&i&&o&&s.set(r.id,i),i?.containsKatex&&r&&!o&&(c=!0)}let l=sd(t,Dd(o.functionNode,e,t,t),()=>Td(o.functionNode,t,i,s));return!a.some(e=>e.containsKatex)||l.containsKatex?l:c?dd:fd}if(Qu(i,t))return{containsKatex:!0,isConclusive:!0,isSafe:!1,isSafeInAttributeContext:!1};if(y(i,`MemberExpression`)){let a=Q(i.object,t,new Set(n),r);if(a.containsKatex)return xd(e,a)||(a.isConclusive?{containsKatex:!0,isConclusive:!0,isSafe:!1,isSafeInAttributeContext:!1}:dd)}let s=bd(e,t);if(s)return s;if(yd(e,t))return ud;if(vd(i,t)){let i=e.arguments[0];if(!i)return Z;let a=O(i);if(v(a))return Td(a,t,new Set(n),r);let o=Ed(a,t);if(!o||n.has(o.symbol.id))return Z;let s=new Set(n);return s.add(o.symbol.id),Td(o.functionNode,t,s,r)}return e.arguments.some(e=>{let i=O(e);return(v(i)?Td(i,t,new Set(n),r):Q(i,t,new Set(n),r)).containsKatex})?dd:Z},Ad=(e,t)=>{let n=Ou(e);if(y(n,`Literal`))return!!n.value;if(y(n,`Identifier`)&&(n.name===`undefined`||n.name===`NaN`)&&t.isGlobalReference(n))return!1;if(y(n,`TemplateLiteral`)){let e=pa(n);return e===null?null:!!e}if(y(n,`ArrayExpression`)||y(n,`ObjectExpression`)||y(n,`ArrowFunctionExpression`)||y(n,`FunctionExpression`)||y(n,`ClassExpression`)||y(n,`NewExpression`)||y(n,`JSXElement`)||y(n,`JSXFragment`))return!0;if(y(n,`UnaryExpression`)){if(n.operator===`void`)return!1;if(n.operator===`typeof`)return!0;if(n.operator===`!`){let e=Ad(n.argument,t);return e===null?null:!e}}return null},Q=(e,t,n,r=new Map)=>{let i=O(e);if(y(i,`Literal`)||y(i,`UnaryExpression`)&&i.operator===`void`)return ld;if(y(i,`Identifier`)){if((i.name===`undefined`||i.name===`NaN`)&&t.isGlobalReference(i))return ld;let e=t.referenceFor(i)?.resolvedSymbol,a=e?r.get(e.id):void 0;if(a)return a;if(!e||e.kind!==`const`||!e.initializer||n.has(e.id))return Z;let o=new Set(n);return o.add(e.id),Q(e.initializer,t,o,r)}if(y(i,`CallExpression`))return kd(i,t,n,r);if(y(i,`TemplateLiteral`))return Cd(i,t,n,r);if(y(i,`ConditionalExpression`)){let e=Ad(i.test,t);return e===null?gd([Q(i.consequent,t,new Set(n),r),Q(i.alternate,t,new Set(n),r)]):Q(e?i.consequent:i.alternate,t,new Set(n),r)}if(y(i,`LogicalExpression`)){let e=i.operator===`??`?null:Ad(i.left,t);if(e!==null)return Q(i.operator===`&&`?e?i.right:i.left:e?i.left:i.right,t,new Set(n),r);let a=Mu(i);if(a.length===1)return Q(a[0]??i,t,new Set(n),r);let o=[i.left,i.right].map(e=>Q(e,t,new Set(n),r));return{...i.operator===`&&`?o[1]??Z:gd(a.map(e=>Q(e,t,new Set(n),r))),containsKatex:o.some(e=>e.containsKatex)}}if(y(i,`BinaryExpression`)&&i.operator===`+`)return gd([Q(i.left,t,new Set(n),r),Q(i.right,t,new Set(n),r)]);if(y(i,`SequenceExpression`)){let e=i.expressions.at(-1);return e?Q(e,t,n,r):Z}return Z},jd=e=>{let t=null;if(y(e,`JSXAttribute`)&&y(e.name,`JSXIdentifier`)&&e.name.name===`dangerouslySetInnerHTML`&&y(e.value,`JSXExpressionContainer`)&&y(e.value.expression,`ObjectExpression`)&&(t=e.value.expression),y(e,`Property`)&&M(e,{allowComputedString:!0})===`dangerouslySetInnerHTML`&&y(O(e.value),`ObjectExpression`)&&(t=O(e.value)),!y(t,`ObjectExpression`))return null;let n=null;for(let e of t.properties){if(y(e,`SpreadElement`)){n=null;continue}if(!y(e,`Property`)){n=null;continue}let t=M(e,{allowComputedString:!0});if(t===null){n=null;continue}t===`__html`&&(n=e.value)}return n},Md=(e,t)=>{let n=Rt({filename:t,sourceText:e});if(n===null)return[];let r=Ie(n);hd(r,t,0);let i=[];return A(n,e=>{let t=jd(e);if(t===null)return;let n=Q(t,r,new Set);if(!n.containsKatex)return;let a=Y(e),o=Du(e);a<0||o<0||i.push({endIndex:o,proof:n,startIndex:a})}),i},Nd=/dangerouslySetInnerHTML|(?:\.(?:inner|outer)HTML|\[\s*["'](?:inner|outer)HTML["']\s*\])\s*[+]?=(?!=)|\.insertAdjacentHTML\s*\(|\bdocument\.write(?:ln)?\s*\(|\.(?:createContextualFragment|setHTMLUnsafe)\s*\(/,Pd=/(?:__html\s*:|(?:\.(?:inner|outer)HTML|\[\s*["'](?:inner|outer)HTML["']\s*\])\s*[+]?=(?!=)|\.insertAdjacentHTML\s*\(\s*[^,]*,|\bdocument\.write(?:ln)?\s*\(|\.(?:createContextualFragment|setHTMLUnsafe)\s*\()\s*([\s\S]*)/,Fd=/searchParams|query|params|request|req\.|response\.|result\.|data\.|await|fetch|props\.|children|content|html|body|text|message|markup|\blocation\b|document\.cookie|\breferrer\b|\blocalStorage\b|\bsessionStorage\b|URLSearchParams|window\.name/i,Id=/^(?:"(?:\\.|[^"\\\n])*"|'(?:\\.|[^'\\\n])*'|`[^`$]*`)\s*(?:\/\/[^\n]*)?\s*(?:[;,})\n]|$)/,Ld=/^[A-Z][A-Z0-9_]*\s*(?:\/\/[^\n]*)?\s*(?:[;,})\n]|$)/,Rd=/^[\w$]+(?:\??\.[\w$]+)*\??\.(?:inner|outer)HTML\b/,zd=/\b(?:DOMPurify|sanitize\w*|purify|(?:escape|encode)[A-Za-z]*(?:Html|HTML|Entit\w*)|insane|xss)\b|(?<!un)safe|(?<!un)saniti[sz]/i,Bd=/[:=]\s*[^\n;]*\b(?:DOMPurify\b|sanitize\w*\s*\(|purify\w*\s*\()/i,Vd=/=\s*[\w$.?[\]]*\.(?:inner|outer)HTML\s*(?:[;,)\n]|$)/,Hd=/process\.env/,Ud=/\b(?:t|i18n|translate|formatMessage|intl)\s*[.(]/,Wd=/^(?:[\w$.]+\.)?(?:toHtml|render[A-Za-z]*(?:Html|HTML)|renderToString|renderToStaticMarkup|codeToHtml|codeToHast|highlight[A-Za-z]*)\s*\(/,Gd=/\b(?:shiki|prism|hljs|highlightjs|getHighlighter|codeToHtml|codeToHast|refractor|lowlight|starry-night)\b|highlight\.js/i,Kd=/[:=]\s*[^\n;]*(?:\b(?:katex|shiki|hljs|prism|mermaid)\b|hast-util-to-html|renderHtmlFromRichText|(?:toHtml|render[A-Za-z]*(?:Html|HTML)|renderToString|renderToStaticMarkup|codeToHtml|codeToHast)\s*\()/i,qd=/\b(?:(?:katex|shiki|hljs|prism|mermaid|highlighter)[\w$]*\.(?:render\w*|highlight\w*|codeTo(?:Html|Hast))|(?:toHtml|render(?:Html|HTML)[A-Za-z]*|render[A-Za-z]*(?:Html|HTML)|renderToString|renderToStaticMarkup|codeToHtml|codeToHast|highlight[A-Za-z]*))\s*\(/i,Jd=/^[\w$]+\s*(?:[;,})\n]|$)/,Yd=/^[\w$]+\s*(?:\|\||\?\?)\s*(?:"[^"\n]*"|'[^'\n]*'|`[^`$]*`)\s*(?:[;,})\n]|$)/,Xd=/^[\w$]+(?:\.[\w$]+|\[[^\]]*\])+\s*(?:[;,})\n]|$)/,Zd=/<style\b[^<>]*$/,Qd=/(?:^|\/)emails(?:\/|$)|email[-_.]templates?(?:\/|$)|RawHtml|[A-Za-z]*[Ee]mail[A-Za-z]*\.(?:t|j)sx?/i,$d=/(?:^|\/)\.[\w-]+\//,ef=/(?<!un)saniti[sz]e?d?[\w-]*\.[cm]?[jt]sx?$/i,tf=/(?:^|[^\w$.])([\w$]+(?:\.[\w$]+)*)(?:(?:\.(?:inner|outer)HTML|\[\s*["'](?:inner|outer)HTML["']\s*\])\s*[+]?=(?!=)|\.insertAdjacentHTML\s*\()/,nf=/\b(?:appendChild|append|prepend|before|after|replaceWith|replaceChild|replaceChildren|insertBefore|insertAdjacentElement)\s*\(/,rf=5e3,af=e=>{if(!e.startsWith("`"))return null;let t=e.indexOf("`",1);if(t<0||t>rf)return null;let n=e.slice(1,t).match(/\$\{[^}]*\}/g);return n===null?``:n.join(` `)},of=(e,t,n)=>{let r=pf(e,t,n);return r===null?null:n.slice(r.initializerStartIndex,r.initializerStartIndex+rf)},sf=e=>{if(!/^["']/.test(e))return!1;let t=e.replace(/"(?:\\.|[^"\\\n])*"|'(?:\\.|[^'\\\n])*'/g,``),n=t.search(/[;,})\]]/),r=n>=0?t.slice(0,n):t;return/^[\s+]*$/.test(r)},cf=(e,t)=>{let n=t.includes(`createElement`),r=t.includes(`createHTMLDocument`);if(!n&&!r)return!1;let i=J(e),a=J(e.split(`.`)[0]??e);if(RegExp(`\\b${a}\\s*=\\s*[^\\n;]*(?:getElementById|querySelector|getElementsBy|\\.current\\b|document\\.(?:body|head|documentElement))`).test(t))return!1;if(n&&(RegExp(`${i}\\s*=\\s*document\\.createElement\\(\\s*["'\`]template["'\`]`).test(t)||RegExp(`${a}\\s*=\\s*[^\\n;]*\\bcreateElement\\(\\s*["'\`](?:style|textarea)["'\`]`).test(t))||r&&RegExp(`${a}\\s*=\\s*[^\\n;]*\\bcreateHTMLDocument\\s*\\(`).test(t))return!0;if(!n||!RegExp(`${a}\\s*=\\s*[^\\n;]*\\bcreateElement\\s*\\(`).test(t))return!1;let o=RegExp(`${nf.source}[^)]*\\b${a}\\b`),s=RegExp(`\\breturn\\b[^\\n]*\\b${a}\\b(?!\\s*\\.\\s*(?:textContent|innerText|innerHTML|outerHTML))`);return o.test(t)||s.test(t)?!1:RegExp(`\\b${a}\\.(?:textContent|innerText|querySelector|querySelectorAll|children|childNodes)\\b`).test(t)},lf=e=>{let t=[],n=``,r=0,i=null;for(let a=0;a<e.length;a+=1){let o=e[a];if(i!==null){n+=o,o===i&&e[a-1]!==`\\`&&(i=null);continue}if(o===`"`||o===`'`||o==="`"){i=o,n+=o;continue}if(o===`(`||o===`[`||o===`{`?r+=1:(o===`)`||o===`]`||o===`}`)&&--r,o===`+`&&r===0&&e[a-1]!==`+`&&e[a+1]!==`+`){t.push(n),n=``;continue}n+=o}return t.push(n),t},uf=e=>{let t=e.replace(/[;}]\s*$/,``).trim();if(!t.includes(`+`))return!1;let n=lf(t).map(e=>e.trim()).filter(e=>e.length>0);return n.length<2?!1:n.every(e=>{let t=e.replace(/\(\s*([\w$]+(?:\??\.[\w$]+)*)\s+as\s+[^)]*\)/g,`$1`);return Rd.test(t)?!Fd.test(t.replace(Rd,``)):!1})},df=(e,t)=>{let n=0,r=null;for(let i=t;i<e.length;i+=1){let t=e[i];if(r!==null){t===r&&e[i-1]!==`\\`&&(r=null);continue}if(t===`"`||t===`'`||t==="`"){r=t;continue}if(t===`{`&&(n+=1),t===`}`&&(--n,n===0))return i}return e.length},ff=(e,t)=>{let n=[],r=null,i=!1,a=!1;for(let o=0;o<t;o+=1){let t=e[o],s=e[o+1];if(i){t===`
|
|
13
|
+
`&&(i=!1);continue}if(a){t===`*`&&s===`/`&&(a=!1,o+=1);continue}if(r!==null){t===r&&e[o-1]!==`\\`&&(r=null);continue}if(t===`/`&&s===`/`){i=!0,o+=1;continue}if(t===`/`&&s===`*`){a=!0,o+=1;continue}if(t===`"`||t===`'`||t==="`"){r=t;continue}t===`{`&&n.push(o),t===`}`&&n.pop()}let o=n.at(-1);return o===void 0?e.length:df(e,o)},pf=(e,t,n)=>{let r=RegExp(`(const|let|var)\\s+${J(e)}\\s*(?::[^=\\n]*)?=\\s*([^;\\n]+)`,`g`),i=null,a=-1;for(let e of n.matchAll(r)){let r=e.index;if(r===void 0||r>=t||r<=a||ff(n,r)<t)continue;a=r;let o=e[2];o!==void 0&&(i={declarationIndex:r,initializer:o,initializerStartIndex:r+e[0].length-o.length,isImmutable:e[1]===`const`})}return i},$=(e,t,n,r)=>{if(t.isImmutable)return!0;let i=r.slice(t.initializerStartIndex+t.initializer.length,n);return!RegExp(`(?:^|[^\\w$.])${J(e)}\\s*=(?!=)`).test(i)},mf=(e,t,n)=>{if(!/highlight/i.test(e))return!1;let r=e.match(/^([\w$]+)/)?.[1];if(r===void 0)return!1;let i=pf(r,n,t);return i===null?/highlighted/i.test(e)||Gd.test(t):$(r,i,n,t)&&qd.test(i.initializer)},hf=(e,t,n,r=new Set)=>{let i=e.trim(),a=lf(i);if(a.length>1)return a.every(e=>hf(e,t,n,r));let o=[...i.matchAll(/\$\{([^}]*)\}/g)].flatMap(e=>e[1]===void 0?[]:[e[1]]);if(o.length>1)return o.every(e=>hf(e,t,n,r));let s=i.match(/^([\w$]+)(?:(?:\??\.[\w$]+)|(?:\[\s*(?:"[^"\n]*"|'[^'\n]*'|\d+)\s*\]))*$/)?.[1];if(s&&!r.has(s)){let e=pf(s,n,t);if(e&&$(s,e,n,t)){let n=new Set(r);return n.add(s),hf(e.initializer,t,e.initializerStartIndex,n)}}return!!(Id.test(`${i};`)||Ld.test(`${i};`)||zd.test(i)||Hd.test(i)||Ud.test(i)||Wd.test(i)||mf(i,t,n))},gf=(e,t,n,r,i=new Set)=>{let a=e.trim().match(/^([\w$]+)$/)?.[1];if(!a)return!1;if(a===t)return!0;if(i.has(a))return!1;let o=pf(a,n,r);if(!o?.isImmutable)return!1;let s=new Set(i);return s.add(a),gf(o.initializer,t,o.initializerStartIndex,r,s)},_f=(e,t,n)=>{let r=[/function\s+([\w$]+)\s*\(([^)]*)\)\s*\{/g,/(?:const|let|var)\s+([\w$]+)\s*=\s*(?:async\s*)?\(([^)]*)\)\s*=>\s*\{/g],i=null,a=-1;for(let o of r)for(let r of n.matchAll(o)){let o=r.index;if(o===void 0||o>=t||o<a)continue;let s=df(n,o+r[0].lastIndexOf(`{`));if(s<t)continue;let c=(r[2]??``).split(`,`).findIndex(t=>t.trim().match(/^(?:\.\.\.)?([\w$]+)/)?.[1]===e);if(c<0)continue;a=o;let l=r[1]??``;i={bodyEndIndex:s,declarationNameIndex:o+r[0].indexOf(l),functionName:l,parameterIndex:c}}return i},vf=e=>{let t=[],n=0,r=0,i=null;for(let a=0;a<e.length;a+=1){let o=e[a];if(i!==null){o===i&&e[a-1]!==`\\`&&(i=null);continue}if(o===`"`||o===`'`||o==="`"){i=o;continue}(o===`(`||o===`[`||o===`{`)&&(r+=1),(o===`)`||o===`]`||o===`}`)&&--r,o===`,`&&r===0&&(t.push(e.slice(n,a).trim()),n=a+1)}return t.push(e.slice(n).trim()),t},yf=(e,t,n,r=new Set)=>{let i=e.trim().match(/^([\w$]+)$/)?.[1];if(i===void 0||r.has(i))return!1;if(_f(i,t,n)!==null)return!0;let a=pf(i,t,n);if(!a||!$(i,a,t,n))return!1;let o=new Set(r);return o.add(i),yf(a.initializer,a.initializerStartIndex,n,o)},bf=(e,t,n,r,i)=>{let a=e.trim();if(hf(a,t,n))return!1;let o=a.match(/^([\w$]+)(?:\.|\s*(?:[;,})\n]|$))/)?.[1];if(o===void 0)return Fd.test(a);if(r.has(o))return!1;r.add(o);let s=pf(o,n,t),c=_f(o,n,t);if(s!==null&&(c===null||s.declarationIndex>c.declarationNameIndex))return $(o,s,n,t)&&hf(s.initializer,t,s.initializerStartIndex)?!1:!$(o,s,n,t)||bf(s.initializer,t,s.initializerStartIndex,r,i)?!0:yf(s.initializer,s.initializerStartIndex,t)?!1:Fd.test(a);if(c!==null&&c.functionName.length>0){let e=RegExp(`\\b${J(c.functionName)}\\s*\\(`,`g`),n=!1,s=!0;for(let a of t.matchAll(e)){if(a.index===c.declarationNameIndex||i.has(a.index))continue;let e=a.index+a[0].lastIndexOf(`(`),l=Eu(t,e);if(l<0)continue;let u=vf(t.slice(e+1,l))[c.parameterIndex];if(u===void 0||a.index>=c.declarationNameIndex&&a.index<=c.bodyEndIndex&&gf(u,o,a.index,t))continue;n=!0,s&&=hf(u,t,a.index);let d=new Set(r);d.delete(o);let f=new Set(i);if(f.add(a.index),bf(u,t,a.index,d,f))return!0}return n?!s&&Fd.test(a):Fd.test(a)}return Fd.test(a)},xf=W({id:`dangerous-html-sink`,title:`HTML injection sink with dynamic content`,severity:`warn`,recommendation:`Prefer rendering structured React nodes. If HTML is required, sanitize with a well-reviewed sanitizer and keep the trust boundary close to the sink.`,scan:e=>{if(e.isGeneratedBundle||!K(e.relativePath)||Qd.test(e.relativePath)||$d.test(e.relativePath)||ef.test(e.relativePath)||!Nd.test(e.content))return[];let t=Md(e.content,e.absolutePath),n=[],r=e.content.split(`
|
|
14
|
+
`);for(let i=0;i<r.length;i+=1){let a=r[i]??``;if(!Nd.test(a))continue;let o=a.slice(0,a.search(Nd)).replace(/"[^"]*"|'[^']*'|`[^`]*`/g,``);if(/(?:^|[^:])\/\//.test(o)||/^\s*[/*]/.test(a))continue;let s=r.slice(i,i+1+4).join(`
|
|
15
|
+
`),c=Pd.exec(s);if(c===null)continue;let l=(c[1]??``).trimStart(),u=l.slice(0,300),d=u.search(/[;}]/),f=d>=0?u.slice(0,d+1):u,p=r.slice(0,i).join(`
|
|
16
|
+
`).length+ +(i>0)+a.search(Nd),m=t.find(e=>p>=e.startIndex&&p<e.endIndex)?.proof;if(m?.isConclusive&&m.isSafe)continue;let h=m?.isConclusive===!0;if(Id.test(f)||Ld.test(f))continue;if(Rd.test(f)&&!f.includes(`+`)){let e=f.replace(Rd,``);if(!Fd.test(e))continue}if(uf(f))continue;let ee=Pd.exec(r.slice(i,i+1+60).join(`
|
|
17
|
+
`))?.[1]?.trimStart(),te=af(ee??l),g=Jd.test(f)||Xd.test(f)||Yd.test(f)?f.match(/^[\w$]+/)?.[0]:void 0;if(te===null&&g!==void 0&&Jd.test(f)&&_f(g,p,e.content)===null){let t=of(g,p,e.content);if(t!==null){if(sf(t))continue;te=af(t)}}if(te===``)continue;let ne=te??f,re=lf(ne).length>1||(te?.match(/\$\{/g)?.length??0)>1;if(!h&&!re&&zd.test(ne)||!re&&Hd.test(ne)||!re&&Ud.test(ne)||!h&&!bf(ne,e.content,p,new Set,new Set)||!h&&Wd.test(f)||!h&&mf(f,e.content,p))continue;if(g!==void 0){let t=J(g),n=pf(g,p,e.content),r=n?.initializer;if(!(r!==void 0&&(lf(r).length>1||(r.match(/\$\{/g)?.length??0)>1))){let i=RegExp(`\\b${t}\\b\\s*${Kd.source}`,`i`);if(!h&&(r===void 0?i.test(e.content):n!==null&&$(g,n,p,e.content)&&qd.test(r)))continue;let a=RegExp(`\\b${t}\\b\\s*${Bd.source}`,`i`);if(!h&&(r===void 0?a.test(e.content):n!==null&&$(g,n,p,e.content)&&Bd.test(`=${r}`)))continue}if(RegExp(`\\b${t}\\b\\s*${Vd.source}`).test(e.content)||RegExp(`highlight[\\w$]*\\s*\\.map\\(\\s*(?:async\\s+)?\\(?\\s*${t}\\b`,`i`).test(e.content)&&Gd.test(e.content))continue}if(Xd.test(f)){let t=f.match(/\.([\w$]+)\s*(?:[;,})\n]|$)/)?.[1];if(t!==void 0&&RegExp(`\\b${J(t)}\\s*:\\s*${Ud.source}`).test(e.content))continue}let ie=tf.exec(a),ae=ie?.[1]??ie?.[2];if(ae!==void 0&&cf(ae,e.content))continue;let oe=r.slice(Math.max(0,i-5),i+1).join(`
|
|
18
|
+
`).slice(0,-a.length+a.search(Nd));Zd.test(oe)||n.push({message:`HTML is injected from a dynamic-looking source, which can become XSS if the value is user-controlled or unsanitized.`,line:i+1,column:a.search(/\S/)+1})}return n}}),Sf=e=>!(!K(e)||Ec.test(e)||Oc.test(e)),Cf=/firebase|firestore|supabase|\b(?:setDoc|addDoc)\s*\(/i,wf=W({id:`firebase-client-owned-authz-field`,title:`Client writes authorization field`,severity:`error`,recommendation:`Derive authority fields on the server or enforce them in Firebase/Supabase rules; never trust client-provided owner, org, or role values.`,scan:q({shouldScan:e=>Sf(e.relativePath)&&(Cf.test(e.content)||Cf.test(e.relativePath)),pattern:/(?:\b(?:setDoc|updateDoc|addDoc)\s*\(|(?:\b(?:firebase|firestore|getFirestore)\b|\bcollection\s*\(|\.collection\s*\()[\s\S]{0,500}\.(?:set|update|add)\s*\()(?:[^;'"`]|'[^'\n]*'|"[^"\n]*"|`[^`]*`){0,700}\b(?:ownerId|ownerID|creatorId|creatorID|providerId|providerID|orgId|orgID|tenantId|tenantID|workspaceId|workspaceID|ghostOrg|role|roles|isAdmin)\b/i,message:`Client code writes an ownership, tenant, or role field that should be server-owned and immutable.`})}),Tf=W({id:`firebase-permissive-rules`,title:`Permissive Firebase security rule`,severity:`error`,recommendation:"Bind every read/write to `request.auth.uid`, immutable ownership, and tenant membership instead of treating sign-in as authorization.",scan:q({shouldScan:e=>Kc(e.relativePath),pattern:/allow\s+(?:read|write|create|update|delete|list|get|read,\s*write)\s*:\s*if\s+(?:true|request\.auth\s*!=\s*null)\s*;?/i,message:`Firebase rules grant broad access to everyone or to any signed-in user, which is the Chattr/Firewreck failure mode.`})}),Ef=W({id:`firebase-query-filter-as-auth`,title:`Firestore query filter used as authorization`,severity:`warn`,recommendation:"Make sure Firestore rules compare the requested document against `request.auth.uid` and trusted membership data.",scan:q({shouldScan:e=>Sf(e.relativePath),pattern:/\.where\s*\(\s*["'](?:uid|userId|userID|ownerId|ownerID|orgId|orgID|tenantId|tenantID|role)["']\s*,\s*["']==["']/i,message:`Firestore query code filters by an auth-shaped field; filtering is not authorization unless rules enforce the same boundary.`})}),Df=/api\.github\.com|github\.com|gitlab\.com|bitbucket\.org/gi,Of=/\$\{([^}]*)\}/g,kf=/\b(?:params|searchParams|query|req|request|input|payload)\s*[.[]|\buntrusted|\bdecodeURI\w*/,Af=/encodeURIComponent\s*\(/,jf=/^\s*[\w$]+\.toString\(\)\s*$/,Mf=W({id:`git-provider-url-injection-risk`,title:`Git provider URL built from interpolation`,severity:`warn`,recommendation:`Validate owner, repo, org, and branch identifiers against strict slugs and build URLs with URL/path encoders instead of raw interpolation.`,scan:e=>{if(!K(e.relativePath))return[];let t=[];for(let n of e.content.matchAll(Df)){let r=e.content.slice(n.index,n.index+200),i=r.indexOf("`"),a=i>=0?r.slice(0,i):r;if(!Array.from(a.matchAll(Of)).some(e=>{let t=e[1]??``;return kf.test(t)&&!Af.test(t)&&!jf.test(t)}))continue;let o=G(e.content,n.index);t.push({message:`GitHub/GitLab/Bitbucket URL construction interpolates path components that may be attacker-controlled.`,line:o.line,column:o.column});break}return t}}),Nf=/child_process|childProcess|execa|subprocess|Deno\.run/,Pf=/(?:\b(?:eval|new\s+Function|vm\.runIn\w*)|(?<![.\w$])(?:exec(?:File)?(?:Sync)?|spawn(?:Sync)?)|\b(?:child_process|childProcess|cp)\.(?:exec|spawn)\w*)\s*\([^;]{0,200}(?<!["'])\b(?:exif|metadata|manifest|preset|plugin|upload|drop(?:ped|s)?\b|archive|zip|unzip|untar)(?!\w*["'])/,Ff=/(?:\b(?:eval|new\s+Function|vm\.runIn\w*)|\b(?:child_process|childProcess|cp)\.(?:exec|spawn)\w*)\s*\([^;]{0,200}(?<!["'])\b(?:exif|metadata|manifest|preset|plugin|upload|drop(?:ped|s)?\b|archive|zip|unzip|untar)(?!\w*["'])/,If=`Imported metadata, uploads, or plugin manifests appear to reach code execution.`,Lf=q({shouldScan:()=>!0,pattern:Pf,message:If}),Rf=q({shouldScan:()=>!0,pattern:Ff,message:If}),zf=W({id:`import-metadata-execution-risk`,title:`Imported metadata reaches code execution`,severity:`error`,recommendation:`Parse imported metadata as data with strict schemas; do not evaluate EXIF, manifests, presets, dropped files, or archives.`,scan:e=>K(e.relativePath)?Nf.test(e.content)?Lf(e):Rf(e):[]}),Bf=/createHash\s*\(\s*["'](?:md5|sha1)["']|\bmd5\s*\(/gi,Vf=/\b(?:password|token|secret|signature|signing|auth|credential|session|cookie|csrf|api.?key)\b/i,Hf=/(?<!cipher\.)\bcreate(?:Cipher|Decipher)\s*\(/,Uf=/\bcreate(?:Cipher|Decipher)iv\s*\(\s*["'](?:des|des3|des-?ede3?|rc4|rc2|bf|blowfish)\b/i,Wf=/\b(?:DES|RC4|Blowfish)\b/,Gf=/\b(?:cipher|decipher|encrypt|decrypt|crypto)\b/i,Kf=/[A-Za-z_$][\w$.]{0,100}signature[\w$]*(?:\([^)]*\))?\s*(?:===?|!==?)\s*[A-Za-z_$][\w$.]*(?:\([^)]*\))?|[A-Za-z_$][\w$.]{0,100}(?:\([^)]*\))?\s*(?:===?|!==?)\s*[A-Za-z_$][\w$.]{0,100}signature[\w$]*(?:\([^)]*\))?/i,qf=/(?:===?|!==?)\s*[A-Z](?:[a-z]|[A-Z0-9_]*\b(?!\s*[.(]))|^[A-Z](?:[a-z]|[A-Z0-9_]*\b(?!\s*[.(]))[\w$.]*(?:\([^)]*\))?\s*(?:===?|!==?)/,Jf=/signature(?:Method|Type|Status|Algorithm|Kind|Mode|Version)\b/i,Yf=/(?:===?|!==?)\s*(?:true|false|null|undefined)\b/,Xf=/\.(?:length|size|byteLength)\s*(?:===?|!==?)|\.(?:length|size|byteLength)\s*$/,Zf=/\bcrypto\b|createH(?:mac|ash)|createSign|createVerify|\bsubtle\b|\bhmac\b|\bdigest\b|\bsha-?(?:1|256|384|512)\b|\bmd5\b|\bwebhook|x-(?:hub-)?signature/i,Qf=/\.[cm]?[jt]sx$/i,$f=/timingSafeEqual|timing.?safe/i,ep=/gravatar|digest[-_ ]?auth|oauth[-_ ]?1|pkcs#?12|smime|\b_id\b|\betag\b|checksum|cache[-_ ]?key|fingerprint/i,tp=/token|secret|password|nonce|salt|csrf|credential|otp/i,np=/(?:focus|render|refresh|remount|redraw|animation|layout|cache|update)[-_]?nonce/i,rp=/Math\.random\s*\(/g,ip=/createHash|md5|cipher|encrypt|decrypt|crypto|signature|Math\.random/i,ap=(e,t,n,r)=>{for(let i of e.matchAll(t)){let t=e.slice(Math.max(0,i.index-250),i.index+250);if(n.test(t)&&!r?.test(t))return i.index}return-1},op=(e,t,n,r)=>{for(let i of e.matchAll(t)){let t=e.lastIndexOf(`
|
|
19
19
|
`,i.index)+1,a=e.indexOf(`
|
|
20
|
-
`,i.index),o=a<0?e.length:a,s=e.slice(t,o);if(!r.test(s)&&n.test(s))return i.index}return-1},
|
|
21
|
-
`&&(t[n]=` `),n+=1;continue}(i===`"`||i===`'`||i==="`")&&(r=i),n+=1}return t.join(``)},pp=/cookie\s*:\s*\{/gi,mp=RegExp(`document\\.cookie\\s*=\\s*[\`"'][^\`"'=;]*?${sp}[^\`"'=;]*=`,`gi`),hp=e=>{if(e.trim().length===0)return 0;let t=0,n=null,r=1;for(let i=0;i<e.length;i+=1){let a=e[i];if(n!==null){a===`\\`?i+=1:a===n&&(n=null);continue}a===`"`||a===`'`||a==="`"?n=a:a===`(`||a===`[`||a===`{`?t+=1:a===`)`||a===`]`||a===`}`?--t:a===`,`&&t===0&&(r+=1)}return r},gp=(e,t,n,r,i)=>{t.lastIndex=0;for(let a=t.exec(e);a!==null;a=t.exec(e)){if(!r(a.index,a[0]))continue;let t=G(e,a.index);i.push({message:n,line:t.line,column:t.column})}},_p=W({id:`insecure-session-cookie`,title:`Auth cookie missing HttpOnly protection`,severity:`warn`,recommendation:"Set auth/session cookies server-side with `httpOnly: true`, `secure: true`, and `sameSite`. Cookies set via `document.cookie` or with `httpOnly: false` are readable by any XSS payload and can be stolen.",scan:e=>{if(!K(e.relativePath))return[];let t=il(e);if(!/cookie/i.test(t))return[];let n=[],r=`An auth/session cookie is exposed to JavaScript (set via document.cookie, with httpOnly: false, or without cookie options), letting an XSS payload steal it.`;lp.lastIndex=0;for(let e=lp.exec(t);e!==null;e=lp.exec(t)){let i=e.index+e[0].lastIndexOf(`(`),a=Tu(t,i);if(a<0)continue;let o=t.slice(i+1,a),s=hp(o)<3,c=o.replace(dp,``);if(!s&&!up.test(c))continue;let l=G(t,e.index);n.push({message:r,line:l.line,column:l.column})}let i=fp(t);pp.lastIndex=0;for(let e=pp.exec(i);e!==null;e=pp.exec(i)){let t=e.index+e[0].length-1,a=Tu(i,t),o=a>=0?i.slice(t,a):i.slice(t,t+400);if(!up.test(o))continue;let s=G(i,e.index);n.push({message:r,line:s.line,column:s.column})}return gp(t,mp,r,()=>!0,n),n}}),vp=/\b(?:alg|algorithms?)\s*:\s*\[?\s*["'`]none["'`]/gi,yp=(e,t)=>{let n=null,r=[];for(let i=0;i<t;i+=1){let t=e[i];if(n==="`"){t===`\\`?i+=1:t==="`"?n=null:t===`$`&&e[i+1]===`{`&&(r.push(0),n=null,i+=1);continue}if(n!==null){t===`\\`?i+=1:t===n&&(n=null);continue}if(t===`"`||t===`'`||t==="`")n=t;else if(r.length>0){let e=r.length-1;t===`{`?r[e]+=1:t===`}`&&(r[e]===0?(r.pop(),n="`"):--r[e])}}return n!==null},bp=W({id:`jwt-insecure-verification`,title:`JWT verified with the 'none' algorithm`,severity:`error`,recommendation:"Never accept the `none` algorithm; it disables signature verification and lets any forged token through. Pin the real algorithm(s) explicitly (`jwt.verify(token, key, { algorithms: ['RS256'] })`).",scan:e=>{if(!K(e.relativePath))return[];let t=il(e);if(!/\bjwt\b|jsonwebtoken|\bjose\b/i.test(t))return[];let n=[];vp.lastIndex=0;for(let e=vp.exec(t);e!==null;e=vp.exec(t)){if(yp(t,e.index))continue;let r=G(t,e.index);n.push({message:`JWT is configured with the 'none' algorithm, which disables signature verification, so any forged token is accepted.`,line:r.line,column:r.column})}return n}}),xp=/PRIVATE KEY|SSH_PRIVATE_KEY|GPG_PRIVATE_KEY|DEPLOY_KEY|SIGNING_KEY/i,Sp=W({id:`key-lifecycle-risk`,title:`Long-lived key material in repository`,severity:`error`,committedFilesOnly:!0,recommendation:`Remove private keys from source, rotate exposed credentials, prefer short-lived deploy credentials, and document revocation/expiry for release keys.`,scan:q({shouldScan:e=>!Dc.test(e.relativePath)&&!jc.test(e.relativePath)&&xp.test(e.content),pattern:/(?<!(?:placeholder|example|sample|dummy|fake)[\s\S]{0,40})-----BEGIN (?:RSA |EC |OPENSSH |DSA )?PRIVATE KEY-----(?:\s|\\r|\\n)*[A-Za-z0-9+/=][A-Za-z0-9+/=\s]{38,}(?![^-]{0,160}\.\.\.)|\b(?:SSH_PRIVATE_KEY|GPG_PRIVATE_KEY|DEPLOY_KEY|SIGNING_KEY)\b\s*[:=]\s*["'][^"'\n]{16,}["']/i,message:`Private or long-lived release key material appears in the repository.`})}),Cp=W({id:`local-rpc-native-bridge-risk`,title:`Weak localhost native bridge boundary`,severity:`warn`,recommendation:`Use exact origin allowlists after URL parsing, per-request nonces, narrow methods, and never expose install/update commands to arbitrary web pages.`,scan:q({shouldScan:e=>K(e.relativePath),pattern:/\b(?:127\.0\.0\.1|localhost|Access-Control-Allow-Origin|websocket|WebSocket)\b[\s\S]{0,700}(?:\b(?:UpdateApp|InstallApp|child_process)\b|(?<![.\w$])(?:exec(?:File)?(?:Sync)?|spawn(?:Sync)?)\s*\()/i,message:`Code appears to bridge browser code to localhost/native capabilities with weak origin or update/install checks.`})}),wp=/\bfrom\s+["']@modelcontextprotocol\/sdk[^"']*["']|\bMcpServer\b|\bMcpAgent\b/,Tp=/@modelcontextprotocol\/sdk|\bMcpServer\b|\bMcpAgent\b/,Ep=/\bserver\.\s*tool\s*\(|\bregisterTool\s*\(|\bsetRequestHandler\s*\(\s*CallToolRequestSchema/,Dp=/\b(?:tool|registerTool|setRequestHandler)\b/,Op=W({id:`mcp-tool-capability-risk`,title:`MCP tool exposes dangerous capability`,severity:`warn`,recommendation:`MCP tool calls run with the connecting client's authority. Validate inputs, enforce per-tool authorization, and avoid raw filesystem/shell/network access where possible.`,scan:q({shouldScan:e=>K(e.relativePath)&&Tp.test(e.content)&&Dp.test(e.content)&&Fc.test(e.content),pattern:Ep,requireAll:[wp,Fc],ignoreStringLiterals:!0,message:`An MCP tool/resource/prompt handler appears to expose file, shell, network, or code-execution capability.`})}),kp=W({id:`mdx-ssr-execution-risk`,title:`Server-rendered MDX can execute code`,severity:`warn`,recommendation:`Use a constrained compiler for untrusted content, disable expressions/raw HTML, sandbox renderers, and avoid caching attacker-controlled output across tenants.`,scan:q({shouldScan:e=>K(e.relativePath),pattern:/(?:@mdx-js\/mdx|next-mdx-remote|\b(?:MDXRemote|compileMDX|evaluateMdx)\b)[\s\S]{0,700}\b(?:repo\b|customer|tenant|user[-_]?(?:content|markdown|mdx|input|provided|generated|submitted)|untrusted|searchParams|req\.|request\.|fetch\s*\(|prisma\.|db\.|database|rehypeRaw|allowDangerousHtml)/i,message:`MDX/markdown rendering code may evaluate user or repository content during SSR or static generation.`})}),Ap=W({id:`nosql-injection-risk`,title:`NoSQL query accepts operator-shaped input`,severity:`warn`,recommendation:"Coerce scalar fields before querying, reject operator keys from client input, and avoid `$where` or request-derived regexes.",scan:q({shouldScan:e=>Vc(e.relativePath,Tc),pattern:/\$where\s*['"]?\s*:\s*(?:f?['"`][^'"`]{0,200}\$\{|function|f['"])|\.find\s*\(\s*JSON\.parse\s*\(\s*(?:req|request)\.|\.aggregate\s*\(\s*\[?\s*\{[^}]{0,400}\$where|\bnew\s+RegExp\s*\(\s*(?:req|request)\.|\$regex['"]?\s*:\s*(?:req|request)\./i,message:"Code appears to pass raw JSON, regex, or `$where` style input into a NoSQL query."})}),jp=[...xl.filter(e=>!e.test(`service_role`)),Sl],Mp=W({id:`package-metadata-secret`,title:`Secret-like package metadata`,severity:`warn`,recommendation:`Keep secrets out of package metadata and generated reports; they are often published to registries, logs, or browser artifacts.`,scan:e=>{if(!e.relativePath.endsWith(`package.json`))return[];let t=Jl(e.content)??jp.find(t=>t.test(e.content));if(t===void 0)return[];let n=bc(e.content,t);return[{message:`Package metadata contains secret-like values or public env secret names.`,line:n.line,column:n.column}]}}),Np=W({id:`path-traversal-risk`,title:`Filesystem path uses caller input`,severity:`warn`,recommendation:`Resolve paths against a fixed base directory, reject traversal after normalization, and map user-visible identifiers to server-owned paths.`,scan:q({shouldScan:e=>K(e.relativePath)&&!gu(e.relativePath),pattern:/\b(?:readFile|readFileSync|writeFile|writeFileSync)\s*\(\s*(?:req\.|request\.|params\.|query\.|body\.|parsed\.|`[^`]*(?<![-./\w$'"`])(?:req\.|request\.|params\.|query\.|body\.))|\bpath\.(?:join|resolve)\s*\([^)]*(?<![-./\w$'"`])(?<!basename\(\s{0,4})(?:req\.|request\.|params\.|query\.|body\.|parsed\.)/,message:`Filesystem access appears to use request, query, params, or body data as part of the path.`})}),Pp=/\b(?:repoUrl|updateUrl|UpdateApp|InstallApp|auto.?updater?|installer|curl(?!\s+(?:-T\b|--upload-file\b))|wget)\b[\s\S]{0,250}(?:\.(?:zip|exe|dmg|appimage|msi|deb|rpm)\b|\.tar\.gz\b|\|\s*(?:bash|sh)\b)/i,Fp=/sha(?:256|512|1)sum|--checksum|checksum=|EXPECTED_SHA|gpg\s+--verify|\.sha(?:256|512)\b/i,Ip=/\b(?:child_process|childProcess|execa|os\.system|subprocess\.|Deno\.run|autoUpdater|electron-updater)\b|\b(?:exec(?:File)?(?:Sync)?|spawn(?:Sync)?)\s*\(/,Lp=/.\/\.github\/workflows\//i,Rp=/(?:^|\/)[\w-]+[.@-]\d+\.\d+\.\d+(?:[-.][\w.]+)?\//,zp=e=>zc(e)&&!Lp.test(e)&&!Rp.test(e)&&!Ac.test(e),Bp=W({id:`plugin-update-trust-risk`,title:`Plugin or updater trust boundary risk`,severity:`warn`,recommendation:`Require signed updates/plugins, pin trusted repositories, verify hashes before execution, and keep custom repository installs behind explicit warnings.`,scan:e=>{if(!K(e.relativePath)&&!zp(e.relativePath))return[];let t=il(e);if(!Pp.test(t)||Fp.test(t)||Cc.test(e.relativePath)&&!Ip.test(t))return[];let n=bc(t,Pp);return[{message:`Code appears to download, install, update, or execute plugin/updater content across a trust boundary.`,line:n.line,column:n.column}]}}),Vp=/origin(?!al)|\.source\s*[!=]==?/i,Hp=/\b(?:event|e|evt|msg|message)\.data\b/,Up=/\b(?:const|let|var)\s+[^;=]*=\s*$/,Wp=/port\d?\b|worker|channel|broadcast|socket|\bws\b|\bsse\b|eventsource|^_?self\.|^source\./i,Gp=String.raw`=\s*new\s+(?:EventSource|WebSocket|Worker|SharedWorker|BroadcastChannel|MessageChannel)\b`,Kp=(e,t)=>{let n=/^[\w$]+/.exec(e)?.[0];return n===void 0?!1:RegExp(`(?<![\\w$.])${J(n)}\\s*${Gp}`).test(t)},qp=/worker/i,Jp=(e,t)=>{let n=Y(t),r=Eu(t);return n<0||r<0?``:e.slice(n,r)},Yp=(e,t)=>{if(t.type===`CallExpression`){let n=_(t.callee)?Jp(e,t.callee):``;if(!n.endsWith(`addEventListener`))return null;let r=t.arguments[0];return _(r)&&r.type===`Literal`&&r.value===`message`?n:null}if(t.type===`AssignmentExpression`&&_(t.left)){let n=Jp(e,t.left);return n.endsWith(`.onmessage`)?n:null}return null},Xp=W({id:`postmessage-origin-risk`,title:`postMessage handler without origin check`,severity:`warn`,recommendation:"Validate `event.origin` against an exact allowlist before using `event.data`, especially when an iframe or parent window can be attacker-controlled.",scan:e=>{if(!K(e.relativePath)||qp.test(e.relativePath))return[];let t=e.content.includes(`onmessage`),n=e.content.includes(`addEventListener`)&&(e.content.includes(`message`)||e.content.includes(`\\`));if(!t&&!n)return[];let r=Rt({filename:e.absolutePath,sourceText:e.content,shouldAttachParentReferences:!1});if(r===null)return[];let i=[];return A(r,t=>{let n=Yp(e.content,t);if(n===null||Wp.test(n)||Kp(n,e.content))return;let r=Jp(e.content,t),a=r.search(Hp);if(a<0)return;let o=r.search(Vp);if(o>=0&&(Up.test(r.slice(0,a))||o<a))return;let s=G(e.content,Y(t));i.push({message:`A message event handler reads cross-window messages without an obvious origin check.`,line:s.line,column:s.column})}),i}}),Zp=/(?:^|\/)(?:locales?|i18n|lang|langs|translations?)\//i,Qp=/(?:^|\/)(?:\.env(?:\.[^/]*)?|(?:debug|crash|trace|stack[-_]?trace|report|dump|phpinfo)(?:[-_.][^/]*)?\.(?:txt|log|json|html?)|[^/]+\.log)$/i,$p=e=>Rc(e,Nc.test(e))&&!Zp.test(e)&&Qp.test(e),em=W({id:`public-debug-artifact`,title:`Public debug artifact`,severity:`warn`,recommendation:`Remove debug artifacts from public output; logs and dumps often reveal source paths, internal routes, tokens, or environment snapshots.`,scan:e=>{if(!$p(e.relativePath))return[];let t={message:`A browser-reachable debug, log, dump, report, or env artifact is present.`,line:1,column:1};return[xl.some(t=>t.test(e.content))?{...t,severity:`error`}:t]}}),tm=/(?:^|\/)docs?\//i,nm=W({id:`public-env-secret-name`,title:`Secret-like public env variable`,severity:`warn`,recommendation:`Public env prefixes are inlined into browser bundles. Rename public values to non-secret names, and keep tokens, passwords, private keys, and service-role credentials server-only.`,scan:e=>{if(!xf(e.relativePath)||tm.test(e.relativePath))return[];let t=Jl(e.content);if(t===void 0)return[];let n=bc(e.content,t);return[{message:`Client code references a public env variable whose name looks like a secret or privileged credential.`,line:n.line,column:n.column}]}}),rm=`(?:"[^"\\n]{0,200}"|'[^'\\n]{0,200}'|\`[^\`$]{0,200}\`)`,im=`\\s*\\(?\\s*(?:${rm}|(?:[\\w\$]+(?:\\.[\\w\$]+)*\\.escape(?:Id|Literal|Identifier)|(?:[\\w\$]+\\.)*(?:connection|conn|client|pool|db|mysql|sqlstring|knex)\\.escape)\\s*\\([^()]{0,200}\\))\\s*\\)?`,am=W({id:`raw-sql-injection-risk`,title:`Raw SQL built outside parameter binding`,severity:`warn`,recommendation:`Keep user input in driver parameters or ORM bind variables. Avoid unsafe/raw SQL helpers and string interpolation for queries.`,scan:q({shouldScan:e=>_u(e.relativePath),pattern:[/\$queryRawUnsafe\s*\(/,/\$executeRawUnsafe\s*\(/,/\bPrisma\.raw\s*\((?!\s*(?:["'][^"'\n]*["']\s*[,)]|`[^`$]*`))/,/\bsql\.\s*(?:raw|unsafe)\s*\((?!\s*(?:["'][^"'\n]*["']\s*[,)]|`[^`$]*`))/,/\b(?:client|pool|conn)\.query\s*\(\s*['"`]\s*(?:SELECT|INSERT|UPDATE|DELETE)\b[^)]{0,400}\$\{(?!\s*[\w$.]*(?:sanitiz|escape|quote)[\w$]*\s*\()/i,RegExp(`\\.query\\s*\\(\\s*${rm}(?:\\s*\\+${im})*\\s*\\+(?!${im})`,`i`),/\.(?:where|orderBy|having)Raw\s*\((?!\s*(?:["'][^"'\n]*["']\s*[,)]|`[^`$]*`))/,/\bcursor\.execute\s*\(\s*f['"]/,/\bcursor\.execute\s*\(\s*(?:"[^"]{0,400}"|'[^']{0,400}')\s*(?:%|\.format\s*\(|\+)/,/\b(?:engine|session)\.execute\s*\(\s*(?:text\s*\(\s*)?f['"]/,/\$[\w]+->(?:query|exec|prepare|executeQuery|executeStatement|createQuery|createNativeQuery)\s*\(\s*(?:"[^"]{0,400}"|'[^']{0,400}')\s*\.\s*\$/,/mysqli_query\s*\(\s*[^,]+,\s*(?:"[^"]{0,400}"|'[^']{0,400}')\s*\.\s*\$/],message:`Code uses a raw SQL escape hatch or string-built query shape that can bypass parameter binding.`})}),om=e=>Sc.test(e)||/(?:^|\/)\.npmrc$/.test(e)||/(?:^|\/)[^/]*(?:credential|credentials|service-account|serviceAccount|firebase-admin|google-service-account|gcp-service-account)[^/]*\.(?:json|env|pem|key)$/i.test(e),sm=e=>/(?:^|\/)\.env(?:\.[^./]+)*\.(?:example|sample|template|dist|defaults?)$|(?:^|\/)[^/]*(?:example|sample|template)[^/]*\.(?:env|json|pem|key)$/i.test(e),cm=W({id:`repository-secret-file`,title:`Secret file checked into repository`,severity:`error`,committedFilesOnly:!0,recommendation:`Remove committed env files, service-account credentials, npm auth tokens, and webhook URLs; rotate exposed values and keep only redacted examples in source.`,scan:e=>{if(!om(e.relativePath)||sm(e.relativePath)||Dc.test(e.relativePath))return[];let t=xl.find(t=>t.test(e.content))??Jl(e.content);if(t===void 0)return[];let n=bc(e.content,t);return[{message:`A repository credential/config file contains secret-looking values.`,line:n.line,column:n.column}]}}),lm=`(?:req|request|ctx\\.req|ctx\\.request)\\.(?:body|query|params)|await\\s+(?:req|request)\\.json\\(\\s*\\)`,um=W({id:`request-body-mass-assignment`,title:`Request input spread without field allowlist`,severity:`warn`,recommendation:"Assign explicit, allowlisted fields (or validate with a strict schema and no `.passthrough()`) instead of spreading/merging request input. Otherwise the client can set ownership, role, or price columns (mass assignment) or pollute the prototype.",scan:q({shouldScan:e=>K(e.relativePath),pattern:[RegExp(`\\.\\.\\.\\s*(?:${lm})`,`i`),RegExp(`(?:Object\\.assign\\s*\\(|_\\.(?:merge|mergeWith|defaultsDeep)\\s*\\(|(?:^|[^.\\w])(?:merge|defaultsDeep)\\s*\\()[\\s\\S]{0,80}?(?:${lm})`,`i`)],message:`Request input is spread or merged into an object without a field allowlist, enabling mass assignment (client-set owner/role/price fields) or prototype pollution.`})}),dm=W({id:`secret-in-fallback`,title:`Hardcoded secret fallback for env var`,severity:`error`,recommendation:"Remove the literal fallback and fail closed (throw when the variable is unset). The hardcoded value is a committed secret, and the `??`/`||` default makes the app run with it in any environment that forgot to set the var.",scan:q({shouldScan:e=>K(e.relativePath),pattern:/\bprocess\.env\.(?!(?:(?:(?:NEXT|EXPO|GATSBY|NUXT|REACT_APP|VITE)_)?PUBLIC_[A-Z0-9_]*(?<!_SECRET)(?<!_PRIVATE_KEY)(?<!_PASSWORD)(?<!_PASSWD)|[A-Z0-9_]*(?:PUBLISHABLE|ANON)_KEY)(?![A-Z0-9_]))[A-Z][A-Z0-9_]*(?:SECRET|TOKEN|PASSWORD|PASSWD|PRIVATE_KEY|API_?KEY|APIKEY|ACCESS_KEY|CLIENT_SECRET|CREDENTIAL|SIGNING_KEY|ENCRYPTION_KEY|WEBHOOK_SECRET|SERVICE_ROLE)[A-Z0-9_]*(?<!_(?:NAME|HEADER|ENDPOINT|URL|URI|ID|PREFIX|SUFFIX|PARAM|PARAMS|FIELD|ISSUER|AUDIENCE|ALGORITHM|ALG|REGION|BUCKET|HOST|HOSTNAME|PORT|PATH|VERSION|SCOPE|TYPE|FORMAT|EXPIRY|TTL))\s*(?:\?\?|\|\|)\s*(["'`])(?![0-9]+["'`])(?![a-z][a-z0-9]*(?:[_-][a-z0-9]+)*[_-](?:token|secret|key|password|passwd|credential)s?["'`])(?![\w-]{0,12}0{8,}["'`])(?!test test test test test test test test test test test junk["'`])(?!(?:changeme|change[_-]?me|placeholder|your[_-]|example|sample|dummy|development|local|todo|replace[_-]?me|https?:\/\/|x{3,}|\*{3,}))[^"'`\n]{8,}\1/i,message:`A secret env var has a hardcoded string fallback: the literal is a committed secret and the app fails open (uses it) when the variable is unset.`})}),fm=(e,t)=>{if(!y(e,`Program`))return!1;for(let n of e.body){if(!y(n,`ExpressionStatement`)||n.directive===void 0)return!1;if(n.directive===t)return!0}return!1},pm=(e,t=`source.tsx`)=>{let n=Rt({filename:t,sourceText:e,shouldAttachParentReferences:!1});return n===null?!1:fm(n,`use server`)},mm=q({shouldScan:e=>xf(e.relativePath),pattern:/\b(?:ownerId|ownerID|creatorId|creatorID|userId|userID|uid|providerId|providerID|orgId|orgID|tenantId|tenantID|teamId|teamID|workspaceId|workspaceID|ghostOrg|role|roles|isAdmin|admin)\b/,requireAll:[/\b(?:supabase\b|\.from\s*\(\s*["'][^"']+["']\s*\))[\s\S]{0,700}\b(?:insert|upsert|update)\s*\(\s*(?:\{|\[?\s*\{)[\s\S]{0,700}\b(?:ownerId|creatorId|userId|orgId|tenantId|role|isAdmin)\b/i],message:`Client Supabase code appears to write user, tenant, owner, or role fields that should be enforced by RLS.`}),hm=W({id:`supabase-client-owned-authz-field`,title:`Client writes Supabase authorization field`,severity:`error`,recommendation:"Use RLS policies based on `auth.uid()` and server-owned membership rows; do not trust client-provided owner, org, or role columns.",scan:e=>{let t=mm(e);return t.length===0?t:pm(e.content,e.relativePath)?[]:t}}),gm=e=>/(?:^|\/)supabase\/(?:migrations|schemas)\//.test(e),_m=e=>e.endsWith(`.sql`)||gm(e),vm=/^\$[A-Za-z_]?\w*\$/,ym=new Set([`do`,`plpgsql`,`sql`,`plpython3u`,`plpythonu`,`plperl`,`plperlu`,`plv8`]),bm=(e,t)=>{let n=t-1;for(;n>=0&&/\s/.test(e[n]??``);)--n;let r=n;for(;r>=0&&/[A-Za-z0-9_]/.test(e[r]??``);)--r;return e.slice(r+1,n+1).toLowerCase()},xm=(e,t,n,r)=>{let i=n,a=!1;for(;i<r;){let n=e[i];if(n===`;`){a=!1,i+=1;continue}if(/[A-Za-z_]/.test(n)){let t=i;for(;t<r&&/[A-Za-z0-9_]/.test(e[t]??``);)t+=1;e.slice(i,t).toLowerCase()===`execute`&&(a=!0),i=t;continue}if(n===`'`){let n=a;for(n||(t[i]=` `),i+=1;i<r;){if(e[i]===`'`){if(e[i+1]===`'`){n||(t[i]=` `,t[i+1]=` `),i+=2;continue}n||(t[i]=` `),i+=1;break}!n&&e[i]!==`
|
|
20
|
+
`,i.index),o=a<0?e.length:a,s=e.slice(t,o);if(!r.test(s)&&n.test(s))return i.index}return-1},sp=W({id:`insecure-crypto-risk`,title:`Weak cryptography in security context`,severity:`warn`,recommendation:"Use modern primitives, `crypto.randomBytes` / Web Crypto randomness, and timing-safe comparisons for signatures, digests, tokens, and auth material.",scan:e=>{if(!K(e.relativePath)||Ac.test(e.relativePath)||ep.test(e.relativePath)||!ip.test(e.content))return[];let t=il(e),n=ap(t,Bf,Vf,ep);if(n<0&&(n=t.search(Uf)),n<0&&(n=t.search(Hf)),n<0&&Gf.test(t)&&(n=t.search(Wf)),n<0&&!$f.test(t)&&!Qf.test(e.relativePath)&&Zf.test(t)){let e=Kf.exec(t);e!==null&&!qf.test(e[0])&&!Jf.test(e[0])&&!Yf.test(e[0])&&!Xf.test(e[0])&&(n=e.index)}if(n<0&&(n=op(t,rp,tp,np)),n<0)return[];let r=G(t,n);return[{message:`Code uses weak hashes, deprecated ciphers, timing-unsafe comparisons, or Math.random in a security-shaped context.`,line:r.line,column:r.column}]}}),cp=`(?<![A-Za-z0-9])(?:session|sess|sid|connect\\.sid|auth|jwt|access[_-]?token|refresh[_-]?token|id[_-]?token)(?![A-Za-z0-9])`,lp=`[\`"'][^\`"']*?${cp}[^\`"']*[\`"']`,up=RegExp(`(?:\\.cookies\\.set|cookies\\(\\s*\\)\\.set|\\.cookie)\\s*\\(\\s*${lp}`,`gi`),dp=/httpOnly\s*:\s*false\b/i,fp=/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|`(?:[^`\\]|\\.)*`/g,pp=e=>{let t=e.split(``),n=0,r=null;for(;n<e.length;){let i=e[n];if(r!==null){if(i===`\\`){n+=2;continue}i===r?r=null:i!==`
|
|
21
|
+
`&&(t[n]=` `),n+=1;continue}(i===`"`||i===`'`||i==="`")&&(r=i),n+=1}return t.join(``)},mp=/cookie\s*:\s*\{/gi,hp=RegExp(`document\\.cookie\\s*=\\s*[\`"'][^\`"'=;]*?${cp}[^\`"'=;]*=`,`gi`),gp=e=>{if(e.trim().length===0)return 0;let t=0,n=null,r=1;for(let i=0;i<e.length;i+=1){let a=e[i];if(n!==null){a===`\\`?i+=1:a===n&&(n=null);continue}a===`"`||a===`'`||a==="`"?n=a:a===`(`||a===`[`||a===`{`?t+=1:a===`)`||a===`]`||a===`}`?--t:a===`,`&&t===0&&(r+=1)}return r},_p=(e,t,n,r,i)=>{t.lastIndex=0;for(let a=t.exec(e);a!==null;a=t.exec(e)){if(!r(a.index,a[0]))continue;let t=G(e,a.index);i.push({message:n,line:t.line,column:t.column})}},vp=W({id:`insecure-session-cookie`,title:`Auth cookie missing HttpOnly protection`,severity:`warn`,recommendation:"Set auth/session cookies server-side with `httpOnly: true`, `secure: true`, and `sameSite`. Cookies set via `document.cookie` or with `httpOnly: false` are readable by any XSS payload and can be stolen.",scan:e=>{if(!K(e.relativePath))return[];let t=il(e);if(!/cookie/i.test(t))return[];let n=[],r=`An auth/session cookie is exposed to JavaScript (set via document.cookie, with httpOnly: false, or without cookie options), letting an XSS payload steal it.`;up.lastIndex=0;for(let e=up.exec(t);e!==null;e=up.exec(t)){let i=e.index+e[0].lastIndexOf(`(`),a=Eu(t,i);if(a<0)continue;let o=t.slice(i+1,a),s=gp(o)<3,c=o.replace(fp,``);if(!s&&!dp.test(c))continue;let l=G(t,e.index);n.push({message:r,line:l.line,column:l.column})}let i=pp(t);mp.lastIndex=0;for(let e=mp.exec(i);e!==null;e=mp.exec(i)){let t=e.index+e[0].length-1,a=Eu(i,t),o=a>=0?i.slice(t,a):i.slice(t,t+400);if(!dp.test(o))continue;let s=G(i,e.index);n.push({message:r,line:s.line,column:s.column})}return _p(t,hp,r,()=>!0,n),n}}),yp=/\b(?:alg|algorithms?)\s*:\s*\[?\s*["'`]none["'`]/gi,bp=(e,t)=>{let n=null,r=[];for(let i=0;i<t;i+=1){let t=e[i];if(n==="`"){t===`\\`?i+=1:t==="`"?n=null:t===`$`&&e[i+1]===`{`&&(r.push(0),n=null,i+=1);continue}if(n!==null){t===`\\`?i+=1:t===n&&(n=null);continue}if(t===`"`||t===`'`||t==="`")n=t;else if(r.length>0){let e=r.length-1;t===`{`?r[e]+=1:t===`}`&&(r[e]===0?(r.pop(),n="`"):--r[e])}}return n!==null},xp=W({id:`jwt-insecure-verification`,title:`JWT verified with the 'none' algorithm`,severity:`error`,recommendation:"Never accept the `none` algorithm; it disables signature verification and lets any forged token through. Pin the real algorithm(s) explicitly (`jwt.verify(token, key, { algorithms: ['RS256'] })`).",scan:e=>{if(!K(e.relativePath))return[];let t=il(e);if(!/\bjwt\b|jsonwebtoken|\bjose\b/i.test(t))return[];let n=[];yp.lastIndex=0;for(let e=yp.exec(t);e!==null;e=yp.exec(t)){if(bp(t,e.index))continue;let r=G(t,e.index);n.push({message:`JWT is configured with the 'none' algorithm, which disables signature verification, so any forged token is accepted.`,line:r.line,column:r.column})}return n}}),Sp=/PRIVATE KEY|SSH_PRIVATE_KEY|GPG_PRIVATE_KEY|DEPLOY_KEY|SIGNING_KEY/i,Cp=W({id:`key-lifecycle-risk`,title:`Long-lived key material in repository`,severity:`error`,committedFilesOnly:!0,recommendation:`Remove private keys from source, rotate exposed credentials, prefer short-lived deploy credentials, and document revocation/expiry for release keys.`,scan:q({shouldScan:e=>!Dc.test(e.relativePath)&&!jc.test(e.relativePath)&&Sp.test(e.content),pattern:/(?<!(?:placeholder|example|sample|dummy|fake)[\s\S]{0,40})-----BEGIN (?:RSA |EC |OPENSSH |DSA )?PRIVATE KEY-----(?:\s|\\r|\\n)*[A-Za-z0-9+/=][A-Za-z0-9+/=\s]{38,}(?![^-]{0,160}\.\.\.)|\b(?:SSH_PRIVATE_KEY|GPG_PRIVATE_KEY|DEPLOY_KEY|SIGNING_KEY)\b\s*[:=]\s*["'][^"'\n]{16,}["']/i,message:`Private or long-lived release key material appears in the repository.`})}),wp=W({id:`local-rpc-native-bridge-risk`,title:`Weak localhost native bridge boundary`,severity:`warn`,recommendation:`Use exact origin allowlists after URL parsing, per-request nonces, narrow methods, and never expose install/update commands to arbitrary web pages.`,scan:q({shouldScan:e=>K(e.relativePath),pattern:/\b(?:127\.0\.0\.1|localhost|Access-Control-Allow-Origin|websocket|WebSocket)\b[\s\S]{0,700}(?:\b(?:UpdateApp|InstallApp|child_process)\b|(?<![.\w$])(?:exec(?:File)?(?:Sync)?|spawn(?:Sync)?)\s*\()/i,message:`Code appears to bridge browser code to localhost/native capabilities with weak origin or update/install checks.`})}),Tp=/\bfrom\s+["']@modelcontextprotocol\/sdk[^"']*["']|\bMcpServer\b|\bMcpAgent\b/,Ep=/@modelcontextprotocol\/sdk|\bMcpServer\b|\bMcpAgent\b/,Dp=/\bserver\.\s*tool\s*\(|\bregisterTool\s*\(|\bsetRequestHandler\s*\(\s*CallToolRequestSchema/,Op=/\b(?:tool|registerTool|setRequestHandler)\b/,kp=W({id:`mcp-tool-capability-risk`,title:`MCP tool exposes dangerous capability`,severity:`warn`,recommendation:`MCP tool calls run with the connecting client's authority. Validate inputs, enforce per-tool authorization, and avoid raw filesystem/shell/network access where possible.`,scan:q({shouldScan:e=>K(e.relativePath)&&Ep.test(e.content)&&Op.test(e.content)&&Fc.test(e.content),pattern:Dp,requireAll:[Tp,Fc],ignoreStringLiterals:!0,message:`An MCP tool/resource/prompt handler appears to expose file, shell, network, or code-execution capability.`})}),Ap=W({id:`mdx-ssr-execution-risk`,title:`Server-rendered MDX can execute code`,severity:`warn`,recommendation:`Use a constrained compiler for untrusted content, disable expressions/raw HTML, sandbox renderers, and avoid caching attacker-controlled output across tenants.`,scan:q({shouldScan:e=>K(e.relativePath),pattern:/(?:@mdx-js\/mdx|next-mdx-remote|\b(?:MDXRemote|compileMDX|evaluateMdx)\b)[\s\S]{0,700}\b(?:repo\b|customer|tenant|user[-_]?(?:content|markdown|mdx|input|provided|generated|submitted)|untrusted|searchParams|req\.|request\.|fetch\s*\(|prisma\.|db\.|database|rehypeRaw|allowDangerousHtml)/i,message:`MDX/markdown rendering code may evaluate user or repository content during SSR or static generation.`})}),jp=W({id:`nosql-injection-risk`,title:`NoSQL query accepts operator-shaped input`,severity:`warn`,recommendation:"Coerce scalar fields before querying, reject operator keys from client input, and avoid `$where` or request-derived regexes.",scan:q({shouldScan:e=>Vc(e.relativePath,Tc),pattern:/\$where\s*['"]?\s*:\s*(?:f?['"`][^'"`]{0,200}\$\{|function|f['"])|\.find\s*\(\s*JSON\.parse\s*\(\s*(?:req|request)\.|\.aggregate\s*\(\s*\[?\s*\{[^}]{0,400}\$where|\bnew\s+RegExp\s*\(\s*(?:req|request)\.|\$regex['"]?\s*:\s*(?:req|request)\./i,message:"Code appears to pass raw JSON, regex, or `$where` style input into a NoSQL query."})}),Mp=[...xl.filter(e=>!e.test(`service_role`)),Sl],Np=W({id:`package-metadata-secret`,title:`Secret-like package metadata`,severity:`warn`,recommendation:`Keep secrets out of package metadata and generated reports; they are often published to registries, logs, or browser artifacts.`,scan:e=>{if(!e.relativePath.endsWith(`package.json`))return[];let t=Yl(e.content)??Mp.find(t=>t.test(e.content));if(t===void 0)return[];let n=bc(e.content,t);return[{message:`Package metadata contains secret-like values or public env secret names.`,line:n.line,column:n.column}]}}),Pp=W({id:`path-traversal-risk`,title:`Filesystem path uses caller input`,severity:`warn`,recommendation:`Resolve paths against a fixed base directory, reject traversal after normalization, and map user-visible identifiers to server-owned paths.`,scan:q({shouldScan:e=>K(e.relativePath)&&!_u(e.relativePath),pattern:/\b(?:readFile|readFileSync|writeFile|writeFileSync)\s*\(\s*(?:req\.|request\.|params\.|query\.|body\.|parsed\.|`[^`]*(?<![-./\w$'"`])(?:req\.|request\.|params\.|query\.|body\.))|\bpath\.(?:join|resolve)\s*\([^)]*(?<![-./\w$'"`])(?<!basename\(\s{0,4})(?:req\.|request\.|params\.|query\.|body\.|parsed\.)/,message:`Filesystem access appears to use request, query, params, or body data as part of the path.`})}),Fp=/\b(?:repoUrl|updateUrl|UpdateApp|InstallApp|auto.?updater?|installer|curl(?!\s+(?:-T\b|--upload-file\b))|wget)\b[\s\S]{0,250}(?:\.(?:zip|exe|dmg|appimage|msi|deb|rpm)\b|\.tar\.gz\b|\|\s*(?:bash|sh)\b)/i,Ip=/sha(?:256|512|1)sum|--checksum|checksum=|EXPECTED_SHA|gpg\s+--verify|\.sha(?:256|512)\b/i,Lp=/\b(?:child_process|childProcess|execa|os\.system|subprocess\.|Deno\.run|autoUpdater|electron-updater)\b|\b(?:exec(?:File)?(?:Sync)?|spawn(?:Sync)?)\s*\(/,Rp=/.\/\.github\/workflows\//i,zp=/(?:^|\/)[\w-]+[.@-]\d+\.\d+\.\d+(?:[-.][\w.]+)?\//,Bp=e=>zc(e)&&!Rp.test(e)&&!zp.test(e)&&!Ac.test(e),Vp=W({id:`plugin-update-trust-risk`,title:`Plugin or updater trust boundary risk`,severity:`warn`,recommendation:`Require signed updates/plugins, pin trusted repositories, verify hashes before execution, and keep custom repository installs behind explicit warnings.`,scan:e=>{if(!K(e.relativePath)&&!Bp(e.relativePath))return[];let t=il(e);if(!Fp.test(t)||Ip.test(t)||Cc.test(e.relativePath)&&!Lp.test(t))return[];let n=bc(t,Fp);return[{message:`Code appears to download, install, update, or execute plugin/updater content across a trust boundary.`,line:n.line,column:n.column}]}}),Hp=/origin(?!al)|\.source\s*[!=]==?/i,Up=/\b(?:event|e|evt|msg|message)\.data\b/,Wp=/\b(?:const|let|var)\s+[^;=]*=\s*$/,Gp=/port\d?\b|worker|channel|broadcast|socket|\bws\b|\bsse\b|eventsource|^_?self\.|^source\./i,Kp=String.raw`=\s*new\s+(?:EventSource|WebSocket|Worker|SharedWorker|BroadcastChannel|MessageChannel)\b`,qp=(e,t)=>{let n=/^[\w$]+/.exec(e)?.[0];return n===void 0?!1:RegExp(`(?<![\\w$.])${J(n)}\\s*${Kp}`).test(t)},Jp=/worker/i,Yp=(e,t)=>{let n=Y(t),r=Du(t);return n<0||r<0?``:e.slice(n,r)},Xp=(e,t)=>{if(t.type===`CallExpression`){let n=_(t.callee)?Yp(e,t.callee):``;if(!n.endsWith(`addEventListener`))return null;let r=t.arguments[0];return _(r)&&r.type===`Literal`&&r.value===`message`?n:null}if(t.type===`AssignmentExpression`&&_(t.left)){let n=Yp(e,t.left);return n.endsWith(`.onmessage`)?n:null}return null},Zp=W({id:`postmessage-origin-risk`,title:`postMessage handler without origin check`,severity:`warn`,recommendation:"Validate `event.origin` against an exact allowlist before using `event.data`, especially when an iframe or parent window can be attacker-controlled.",scan:e=>{if(!K(e.relativePath)||Jp.test(e.relativePath))return[];let t=e.content.includes(`onmessage`),n=e.content.includes(`addEventListener`)&&(e.content.includes(`message`)||e.content.includes(`\\`));if(!t&&!n)return[];let r=Rt({filename:e.absolutePath,sourceText:e.content,shouldAttachParentReferences:!1});if(r===null)return[];let i=[];return A(r,t=>{let n=Xp(e.content,t);if(n===null||Gp.test(n)||qp(n,e.content))return;let r=Yp(e.content,t),a=r.search(Up);if(a<0)return;let o=r.search(Hp);if(o>=0&&(Wp.test(r.slice(0,a))||o<a))return;let s=G(e.content,Y(t));i.push({message:`A message event handler reads cross-window messages without an obvious origin check.`,line:s.line,column:s.column})}),i}}),Qp=/(?:^|\/)(?:locales?|i18n|lang|langs|translations?)\//i,$p=/(?:^|\/)(?:\.env(?:\.[^/]*)?|(?:debug|crash|trace|stack[-_]?trace|report|dump|phpinfo)(?:[-_.][^/]*)?\.(?:txt|log|json|html?)|[^/]+\.log)$/i,em=e=>Rc(e,Nc.test(e))&&!Qp.test(e)&&$p.test(e),tm=W({id:`public-debug-artifact`,title:`Public debug artifact`,severity:`warn`,recommendation:`Remove debug artifacts from public output; logs and dumps often reveal source paths, internal routes, tokens, or environment snapshots.`,scan:e=>{if(!em(e.relativePath))return[];let t={message:`A browser-reachable debug, log, dump, report, or env artifact is present.`,line:1,column:1};return[xl.some(t=>t.test(e.content))?{...t,severity:`error`}:t]}}),nm=/(?:^|\/)docs?\//i,rm=W({id:`public-env-secret-name`,title:`Secret-like public env variable`,severity:`warn`,recommendation:`Public env prefixes are inlined into browser bundles. Rename public values to non-secret names, and keep tokens, passwords, private keys, and service-role credentials server-only.`,scan:e=>{if(!Sf(e.relativePath)||nm.test(e.relativePath))return[];let t=Yl(e.content);if(t===void 0)return[];let n=bc(e.content,t);return[{message:`Client code references a public env variable whose name looks like a secret or privileged credential.`,line:n.line,column:n.column}]}}),im=`(?:"[^"\\n]{0,200}"|'[^'\\n]{0,200}'|\`[^\`$]{0,200}\`)`,am=`\\s*\\(?\\s*(?:${im}|(?:[\\w\$]+(?:\\.[\\w\$]+)*\\.escape(?:Id|Literal|Identifier)|(?:[\\w\$]+\\.)*(?:connection|conn|client|pool|db|mysql|sqlstring|knex)\\.escape)\\s*\\([^()]{0,200}\\))\\s*\\)?`,om=W({id:`raw-sql-injection-risk`,title:`Raw SQL built outside parameter binding`,severity:`warn`,recommendation:`Keep user input in driver parameters or ORM bind variables. Avoid unsafe/raw SQL helpers and string interpolation for queries.`,scan:q({shouldScan:e=>vu(e.relativePath),pattern:[/\$queryRawUnsafe\s*\(/,/\$executeRawUnsafe\s*\(/,/\bPrisma\.raw\s*\((?!\s*(?:["'][^"'\n]*["']\s*[,)]|`[^`$]*`))/,/\bsql\.\s*(?:raw|unsafe)\s*\((?!\s*(?:["'][^"'\n]*["']\s*[,)]|`[^`$]*`))/,/\b(?:client|pool|conn)\.query\s*\(\s*['"`]\s*(?:SELECT|INSERT|UPDATE|DELETE)\b[^)]{0,400}\$\{(?!\s*[\w$.]*(?:sanitiz|escape|quote)[\w$]*\s*\()/i,RegExp(`\\.query\\s*\\(\\s*${im}(?:\\s*\\+${am})*\\s*\\+(?!${am})`,`i`),/\.(?:where|orderBy|having)Raw\s*\((?!\s*(?:["'][^"'\n]*["']\s*[,)]|`[^`$]*`))/,/\bcursor\.execute\s*\(\s*f['"]/,/\bcursor\.execute\s*\(\s*(?:"[^"]{0,400}"|'[^']{0,400}')\s*(?:%|\.format\s*\(|\+)/,/\b(?:engine|session)\.execute\s*\(\s*(?:text\s*\(\s*)?f['"]/,/\$[\w]+->(?:query|exec|prepare|executeQuery|executeStatement|createQuery|createNativeQuery)\s*\(\s*(?:"[^"]{0,400}"|'[^']{0,400}')\s*\.\s*\$/,/mysqli_query\s*\(\s*[^,]+,\s*(?:"[^"]{0,400}"|'[^']{0,400}')\s*\.\s*\$/],message:`Code uses a raw SQL escape hatch or string-built query shape that can bypass parameter binding.`})}),sm=e=>Sc.test(e)||/(?:^|\/)\.npmrc$/.test(e)||/(?:^|\/)[^/]*(?:credential|credentials|service-account|serviceAccount|firebase-admin|google-service-account|gcp-service-account)[^/]*\.(?:json|env|pem|key)$/i.test(e),cm=e=>/(?:^|\/)\.env(?:\.[^./]+)*\.(?:example|sample|template|dist|defaults?)$|(?:^|\/)[^/]*(?:example|sample|template)[^/]*\.(?:env|json|pem|key)$/i.test(e),lm=W({id:`repository-secret-file`,title:`Secret file checked into repository`,severity:`error`,committedFilesOnly:!0,recommendation:`Remove committed env files, service-account credentials, npm auth tokens, and webhook URLs; rotate exposed values and keep only redacted examples in source.`,scan:e=>{if(!sm(e.relativePath)||cm(e.relativePath)||Dc.test(e.relativePath))return[];let t=xl.find(t=>t.test(e.content))??Yl(e.content);if(t===void 0)return[];let n=bc(e.content,t);return[{message:`A repository credential/config file contains secret-looking values.`,line:n.line,column:n.column}]}}),um=`(?:req|request|ctx\\.req|ctx\\.request)\\.(?:body|query|params)|await\\s+(?:req|request)\\.json\\(\\s*\\)`,dm=W({id:`request-body-mass-assignment`,title:`Request input spread without field allowlist`,severity:`warn`,recommendation:"Assign explicit, allowlisted fields (or validate with a strict schema and no `.passthrough()`) instead of spreading/merging request input. Otherwise the client can set ownership, role, or price columns (mass assignment) or pollute the prototype.",scan:q({shouldScan:e=>K(e.relativePath),pattern:[RegExp(`\\.\\.\\.\\s*(?:${um})`,`i`),RegExp(`(?:Object\\.assign\\s*\\(|_\\.(?:merge|mergeWith|defaultsDeep)\\s*\\(|(?:^|[^.\\w])(?:merge|defaultsDeep)\\s*\\()[\\s\\S]{0,80}?(?:${um})`,`i`)],message:`Request input is spread or merged into an object without a field allowlist, enabling mass assignment (client-set owner/role/price fields) or prototype pollution.`})}),fm=W({id:`secret-in-fallback`,title:`Hardcoded secret fallback for env var`,severity:`error`,recommendation:"Remove the literal fallback and fail closed (throw when the variable is unset). The hardcoded value is a committed secret, and the `??`/`||` default makes the app run with it in any environment that forgot to set the var.",scan:q({shouldScan:e=>K(e.relativePath),pattern:/\bprocess\.env\.(?!(?:(?:(?:NEXT|EXPO|GATSBY|NUXT|REACT_APP|VITE)_)?PUBLIC_[A-Z0-9_]*(?<!_SECRET)(?<!_PRIVATE_KEY)(?<!_PASSWORD)(?<!_PASSWD)|[A-Z0-9_]*(?:PUBLISHABLE|ANON)_KEY)(?![A-Z0-9_]))[A-Z][A-Z0-9_]*(?:SECRET|TOKEN|PASSWORD|PASSWD|PRIVATE_KEY|API_?KEY|APIKEY|ACCESS_KEY|CLIENT_SECRET|CREDENTIAL|SIGNING_KEY|ENCRYPTION_KEY|WEBHOOK_SECRET|SERVICE_ROLE)[A-Z0-9_]*(?<!_(?:NAME|HEADER|ENDPOINT|URL|URI|ID|PREFIX|SUFFIX|PARAM|PARAMS|FIELD|ISSUER|AUDIENCE|ALGORITHM|ALG|REGION|BUCKET|HOST|HOSTNAME|PORT|PATH|VERSION|SCOPE|TYPE|FORMAT|EXPIRY|TTL))\s*(?:\?\?|\|\|)\s*(["'`])(?![0-9]+["'`])(?![a-z][a-z0-9]*(?:[_-][a-z0-9]+)*[_-](?:token|secret|key|password|passwd|credential)s?["'`])(?![\w-]{0,12}0{8,}["'`])(?!test test test test test test test test test test test junk["'`])(?!(?:changeme|change[_-]?me|placeholder|your[_-]|example|sample|dummy|development|local|todo|replace[_-]?me|https?:\/\/|x{3,}|\*{3,}))[^"'`\n]{8,}\1/i,message:`A secret env var has a hardcoded string fallback: the literal is a committed secret and the app fails open (uses it) when the variable is unset.`})}),pm=(e,t)=>{if(!y(e,`Program`))return!1;for(let n of e.body){if(!y(n,`ExpressionStatement`)||n.directive===void 0)return!1;if(n.directive===t)return!0}return!1},mm=(e,t=`source.tsx`)=>{let n=Rt({filename:t,sourceText:e,shouldAttachParentReferences:!1});return n===null?!1:pm(n,`use server`)},hm=q({shouldScan:e=>Sf(e.relativePath),pattern:/\b(?:ownerId|ownerID|creatorId|creatorID|userId|userID|uid|providerId|providerID|orgId|orgID|tenantId|tenantID|teamId|teamID|workspaceId|workspaceID|ghostOrg|role|roles|isAdmin|admin)\b/,requireAll:[/\b(?:supabase\b|\.from\s*\(\s*["'][^"']+["']\s*\))[\s\S]{0,700}\b(?:insert|upsert|update)\s*\(\s*(?:\{|\[?\s*\{)[\s\S]{0,700}\b(?:ownerId|creatorId|userId|orgId|tenantId|role|isAdmin)\b/i],message:`Client Supabase code appears to write user, tenant, owner, or role fields that should be enforced by RLS.`}),gm=W({id:`supabase-client-owned-authz-field`,title:`Client writes Supabase authorization field`,severity:`error`,recommendation:"Use RLS policies based on `auth.uid()` and server-owned membership rows; do not trust client-provided owner, org, or role columns.",scan:e=>{let t=hm(e);return t.length===0?t:mm(e.content,e.relativePath)?[]:t}}),_m=e=>/(?:^|\/)supabase\/(?:migrations|schemas)\//.test(e),vm=e=>e.endsWith(`.sql`)||_m(e),ym=/^\$[A-Za-z_]?\w*\$/,bm=new Set([`do`,`plpgsql`,`sql`,`plpython3u`,`plpythonu`,`plperl`,`plperlu`,`plv8`]),xm=(e,t)=>{let n=t-1;for(;n>=0&&/\s/.test(e[n]??``);)--n;let r=n;for(;r>=0&&/[A-Za-z0-9_]/.test(e[r]??``);)--r;return e.slice(r+1,n+1).toLowerCase()},Sm=(e,t,n,r)=>{let i=n,a=!1;for(;i<r;){let n=e[i];if(n===`;`){a=!1,i+=1;continue}if(/[A-Za-z_]/.test(n)){let t=i;for(;t<r&&/[A-Za-z0-9_]/.test(e[t]??``);)t+=1;e.slice(i,t).toLowerCase()===`execute`&&(a=!0),i=t;continue}if(n===`'`){let n=a;for(n||(t[i]=` `),i+=1;i<r;){if(e[i]===`'`){if(e[i+1]===`'`){n||(t[i]=` `,t[i+1]=` `),i+=2;continue}n||(t[i]=` `),i+=1;break}!n&&e[i]!==`
|
|
22
22
|
`&&(t[i]=` `),i+=1}continue}if(n===`"`){for(i+=1;i<r;){if(e[i]===`"`){if(e[i+1]===`"`){i+=2;continue}i+=1;break}i+=1}continue}if(n===`-`&&e[i+1]===`-`){for(;i<r&&e[i]!==`
|
|
23
23
|
`;)t[i]=` `,i+=1;continue}if(n===`/`&&e[i+1]===`*`){for(;i<r;){if(e[i]===`*`&&e[i+1]===`/`){t[i]=` `,t[i+1]=` `,i+=2;break}e[i]!==`
|
|
24
|
-
`&&(t[i]=` `),i+=1}continue}i+=1}},
|
|
24
|
+
`&&(t[i]=` `),i+=1}continue}i+=1}},Cm=e=>{let t=e.split(``),n=0;for(;n<e.length;){let r=e[n];if(r===`-`&&e[n+1]===`-`){for(;n<e.length&&e[n]!==`
|
|
25
25
|
`;)t[n]=` `,n+=1;continue}if(r===`/`&&e[n+1]===`*`){for(;n<e.length;){if(e[n]===`*`&&e[n+1]===`/`){t[n]=` `,t[n+1]=` `,n+=2;break}e[n]!==`
|
|
26
26
|
`&&(t[n]=` `),n+=1}continue}if(r===`'`){for(t[n]=` `,n+=1;n<e.length;){if(e[n]===`'`){if(e[n+1]===`'`){t[n]=` `,t[n+1]=` `,n+=2;continue}t[n]=` `,n+=1;break}e[n]!==`
|
|
27
|
-
`&&(t[n]=` `),n+=1}continue}if(r===`$`){let r=
|
|
28
|
-
`&&(t[r]=` `);n=o;continue}}if(r===`"`){for(n+=1;n<e.length;){if(e[n]===`"`){if(e[n+1]===`"`){n+=2;continue}n+=1;break}n+=1}continue}n+=1}return t.join(``)},
|
|
29
|
-
`);for(let r=0;r<n.length;r+=1){let i=n[r]??``,a=i.match(
|
|
30
|
-
`);
|
|
31
|
-
//# sourceMappingURL=capability-
|
|
27
|
+
`&&(t[n]=` `),n+=1}continue}if(r===`$`){let r=ym.exec(e.slice(n));if(r!==null){let i=r[0],a=e.indexOf(i,n+i.length),o=a<0?e.length:a+i.length,s=xm(e,n);if(bm.has(s))Sm(e,t,n+i.length,o);else for(let r=n;r<o;r+=1)e[r]!==`
|
|
28
|
+
`&&(t[r]=` `);n=o;continue}}if(r===`"`){for(n+=1;n<e.length;){if(e[n]===`"`){if(e[n+1]===`"`){n+=2;continue}n+=1;break}n+=1}continue}n+=1}return t.join(``)},wm=/disable\s+row\s+level\s+security/i,Tm=/auth\.role\(\)\s*=\s*["']service_role["']/i,Em=/create\s+policy/gi,Dm=/;|create\s+policy/i,Om=/\b(?:using|with\s+check)\s*\(\s*true\s*\)/i,km=/\bfor\s+select\b/i,Am=/\bto\s+([\s\S]+?)(?=\s+(?:using|with\s+check|as|for)\b|;|$)/i,jm=new Set([`service_role`,`postgres`,`supabase_admin`]),Mm=e=>{let t=Am.exec(e);if(t===null)return!1;let n=t[1].split(`,`).map(e=>e.trim().replace(/["'`]/g,``).toLowerCase()).filter(Boolean);return n.length>0&&n.every(e=>jm.has(e))},Nm=(e,t)=>Tm.test(t)?!0:!Om.test(e)||km.test(e)?!1:!Mm(e),Pm=W({id:`supabase-rls-policy-risk`,title:`Permissive Supabase RLS policy`,severity:`error`,recommendation:"Keep public-read policies explicit, but gate inserts, updates, deletes, and service-role bypasses behind `auth.uid()` plus trusted tenant membership.",scan:e=>{if(!vm(e.relativePath))return[];let t=Cm(e.content),n=t.search(wm);Em.lastIndex=0;for(let r=Em.exec(t);r!==null;r=Em.exec(t)){let i=r.index+r[0].length,a=t.slice(i).search(Dm),o=a<0?t.length:i+a;if(Nm(t.slice(r.index,o),e.content.slice(r.index,o))){(n<0||r.index<n)&&(n=r.index);break}}if(n<0)return[];let{line:r,column:i}=G(t,n);return[{message:`Supabase policy SQL disables RLS, permits writes broadly, or references a service-role bypass.`,line:r,column:i}]}}),Fm=/create\s+(?:unlogged\s+)?table\s+(?:if\s+not\s+exists\s+)?(?!["`]?(?:auth|storage|realtime|vault|extensions|graphql|graphql_public|pgbouncer|net|supabase_functions|supabase_migrations|cron|pgsodium|pgmq|information_schema|pg_catalog|pg_temp|private|internal)["`]?\s*\.)(?:["`]?public["`]?\s*\.\s*)?["`]?([A-Za-z_][\w$]*)["`]?(?:\s*\(|\s+as\b)/gi,Im=/alter\s+table\s+(?:if\s+exists\s+)?(?:only\s+)?(?:["`]?public["`]?\s*\.\s*)?["`]?([A-Za-z_][\w$]*)["`]?\s+(?:force\s+)?enable\s+row\s+level\s+security/gi,Lm=/\benable\s+row\s+level\s+security\b/gi,Rm=e=>{let t=new Map,n=0;for(let r of e.matchAll(Im)){let e=r[1];e!==void 0&&(n+=1,t.set(e.toLowerCase(),r.index))}return{lastEnableIndexByTable:t,staticEnableCount:n}},zm=(e,t)=>(e.match(Lm)?.length??0)>t,Bm=W({id:`supabase-table-missing-rls`,title:`Supabase table created without Row Level Security`,severity:`error`,recommendation:"Enable RLS in the same migration (`alter table <name> enable row level security;`) and add `auth.uid()`-scoped policies for select/insert/update/delete. A public table without RLS is fully readable and writable with the public anon key.",scan:e=>{if(!_m(e.relativePath))return[];let t=Cm(e.content);if(!/create\s+(?:unlogged\s+)?table/i.test(t))return[];let n=[],{lastEnableIndexByTable:r,staticEnableCount:i}=Rm(t);if(zm(t,i))return[];Fm.lastIndex=0;for(let e=Fm.exec(t);e!==null;e=Fm.exec(t)){let i=e[1];if(i===void 0)continue;let a=r.get(i.toLowerCase());if(a!==void 0&&a>=e.index)continue;let o=G(t,e.index);n.push({message:`Supabase migration creates a public table but never enables Row Level Security, leaving every row exposed to the anon key.`,line:o.line,column:o.column})}return n}}),Vm=W({id:`svg-filter-clickjacking-risk`,title:`SVG-filtered iframe clickjacking primitive`,severity:`warn`,recommendation:"Avoid filtering cross-origin iframes. Use `frame-ancestors` on sensitive pages and keep SVG filters away from embedded privileged UI.",scan:q({shouldScan:e=>K(e.relativePath),pattern:/<iframe\b(?:=>|[^>]){0,300}\bfilter\s*:\s*["']?url\(#|filter\s*:\s*url\(#[\s\S]{0,700}<iframe\b|<fe(?:DisplacementMap|ColorMatrix|Composite|Tile|Morphology)\b[\s\S]{0,700}<iframe\b/i,message:`An iframe is rendered through an SVG/CSS filter, which can support advanced clickjacking or visual exfiltration tricks.`})}),Hm=e=>K(e)?Ec.test(e)?!0:/(?:^|\/)(?:middleware|route)\.[cm]?[jt]sx?$/.test(e):!1,Um=W({id:`tenant-static-proxy-risk`,title:`Tenant-controlled static asset proxy`,severity:`warn`,recommendation:`Bind tenant identity to the trusted host or authenticated org, canonicalize after decoding, reject traversal, and never let one tenant choose another tenant's asset prefix.`,scan:q({shouldScan:e=>Hm(e.relativePath),pattern:/\b(?:fetch|path\.join|getObject\w*|GetObjectCommand|getSignedUrl|createReadStream)\s*\([^;]{0,200}(?:\$\{[^}]{0,100}\b(?:tenant|subdomain|workspace|hostPattern|(?<!\.)organization(?:Id|Slug)?)\b|\b(?:tenant|subdomain|workspace)(?:Id|Slug|Name)?\b\s*[,)+\].])/i,message:`Route code appears to compose tenant or subdomain input into a static/CDN/object-store fetch path.`})}),Wm=[/dangerouslySetInnerHTML\s*=\s*\{\{\s*__html\s*:[\s\S]{0,300}?\bJSON\.stringify\s*\(/gi,/<script\b[^>]*>(?:(?!<\/script>)[\s\S]){0,300}?\bJSON\.stringify\s*\(/gi],Gm=/\$\{|["'`]\s*\+\s*$/,Km=/^\s*\{(?!\{)/,qm=/"(?:[^"\\\n]|\\.)*"|'(?:[^'\\\n]|\\.)*'/g,Jm=/\b(?:true|false|null)\b|[\d.]+(?:e[+-]?\d+)?/gi,Ym=e=>{if(e.includes("`")||e.includes("${"))return!1;let t=e.replace(qm,``).replace(Jm,``);return!/[A-Za-z_$]/.test(t)},Xm=/^[\s)]*\.replace\s*\([^)]*(?:\\u003[cC]|<|<)/,Zm=/(?:\b(?:escapeHtml|escapeJSON|escapeJson|htmlEscape|jsesc)|(?<![.\w])(?:serialize|serializeJavascript|devalue|uneval|superjson))\s*\(\s*$/i,Qm=/\bJSON\.stringify\s*\($/i,$m=W({id:`unsafe-json-in-html`,title:`Unescaped JSON in HTML or script sink`,severity:`warn`,recommendation:'JSON.stringify does not HTML-escape, so a `<\/script>` (or `<`) in the data breaks out and becomes XSS. Use an HTML-safe serializer (serialize-javascript, devalue) or escape `<`, `>`, and `&`, or pass data via a JSON `<script type="application/json">` read with JSON.parse.',scan:e=>{if(!K(e.relativePath))return[];let t=il(e);if(!t.includes(`JSON.stringify`))return[];let n=[],r=new Set;for(let[e,i]of Wm.entries()){i.lastIndex=0;for(let a=i.exec(t);a!==null;a=i.exec(t)){let i=a[0].replace(Qm,``);if(Zm.test(i))continue;if(e===1){let e=t.indexOf(`>`,a.index),n=a[0].search(/\bJSON\.stringify\s*\($/i);if(e>=0&&n>=0){let r=t.slice(e+1,a.index+n);if(!Gm.test(r)||Km.test(r))continue}}let o=a.index+a[0].length-1,s=Eu(t,o);if(s>=0){let e=t.slice(s+1,s+1+160);if(Xm.test(e)||Ym(t.slice(o+1,s)))continue}if(r.has(a.index))continue;r.add(a.index);let c=G(t,a.index);n.push({message:"JSON.stringify is embedded in HTML/script markup without HTML-escaping; data containing `<\/script>` or `<` breaks out and becomes XSS.",line:c.line,column:c.column})}}return n}}),eh=/(?:(?<![.\w$])fetch|\baxios\.\s*(?:get|post|put|delete|head)|\bgot|\bgot\.\s*(?:get|post))\s*\(\s*([^,)]+)/,th=/\b(?:url|targetUrl|callbackUrl|redirectUrl|webhookUrl|companyUrl|websiteUrl|domainUrl|imageUrl|fetchUrl|next|return_to|returnTo|destination|location)\b/i,nh=/\breq\.|\brequest\.(?:query|body|params|nextUrl)|\bsearchParams\b|\bparams\.|\bbody\.|\bquery\./,rh=/\bredirect\s*:\s*["'](?:manual|error)["']/,ih=/\b(params|body|query)\./g,ah=(e,t)=>RegExp(`(?:const|let|var)\\s+${e}\\s*(?::[^=;\\n]{0,80})?=\\s*new\\s+URLSearchParams\\b`).test(t),oh=(e,t)=>{let n=e.replace(ih,(e,n)=>ah(n,t)?``:e);return nh.test(n)},sh=(e,t)=>{if(oh(e,t))return!0;let n=/^[\w$]+$/.exec(e.trim());if(n===null)return!1;let r=RegExp(`(?:const|let|var)[^=;\\n]{0,80}\\b${n[0]}\\b[^=;\\n]{0,80}=([^;\\n]*)`,`g`);for(let e of t.matchAll(r)){let n=e[1]??``;if(/\breq\.|\brequest\.|\bsearchParams\b|\$_(?:GET|POST|REQUEST)/.test(n)||oh(n,t))return!0}return!1},ch=W({id:`untrusted-redirect-following`,title:`Server fetch follows redirects for caller-shaped URL`,severity:`warn`,recommendation:'Use `redirect: "manual"` or equivalent and re-validate every redirect target before following it to avoid SSRF redirect bypasses.',scan:e=>{if(!Hm(e.relativePath)||!eh.test(e.content))return[];let t=[],n=e.content.split(`
|
|
29
|
+
`);for(let r=0;r<n.length;r+=1){let i=n[r]??``,a=i.match(eh),o=a?.[1]??``;if(!a||!th.test(o)||!sh(o,e.content))continue;let s=n.slice(r,r+5).join(`
|
|
30
|
+
`);rh.test(s)||t.push({message:`Server-side fetch code appears to follow redirects for a URL shaped like caller-controlled input.`,line:r+1,column:i.search(/\S/)+1})}return t}}),lh=W({id:`url-prefilled-privileged-action`,title:`URL pre-fills a privileged action`,severity:`warn`,recommendation:`Require server-side validation and explicit confirmation for URL-sourced invite, role, permission, redirect, or sharing parameters.`,scan:q({shouldScan:e=>Sf(e.relativePath),pattern:/(?<!(?:safe|valid|sanitiz|relativ|allowlist|whitelist|parse|normaliz)[\w$]*\(\s*(?:new\s+)?(?:[\w$]+\s*\.\s*){0,4})\b(?:searchParams|useSearchParams\s*\(\s*\)|URLSearchParams\s*\([^)]{0,120}\))(?:[?!])?\.get(?:All)?\s*\(\s*["'](?:userstoinvite|role|permission|sharingaction|invite|admin|next|continue|returnTo|redirect_uri|callbackUrl)["']|\bsearchParams\.(?:userstoinvite|role|permission|sharingaction|invite|admin|returnTo|redirect_uri|callbackUrl)\b/i,message:`Client code reads sensitive action state from the URL, which can pre-fill invites, roles, redirects, or sharing flows with attacker values.`})}),uh=/(?:^|\/)[^/]*webhook[^/]*\/|(?:^|\/)[^/]*webhook[^/]*\.[cm]?[jt]s$|\bwebhook\b/i,dh=/\b(?:export\s+(?:async\s+)?function\s+POST|export\s+const\s+(?:POST|handler|webhook)|webhookHandler|webhookRoute)\b/i,fh=RegExp(`verifySignature|verify.*signature|verify\\w*(?:Webhook|Auth)|constructEvent|createHmac|timingSafeEqual|svix|webhookSecret|stripe\\.webhooks|["'][\\w-]*signature["']|\\b[A-Za-z]{0,40}(?:verif|valid|check|assert|authenticat|compare|guard)[A-Za-z]{0,40}(?:secret|signature|hmac|webhook|digest)[A-Za-z]{0,40}\\s*\\(`,`i`),ph=/webhook[\s_-]?ur[il]\w*/gi,mh=/process\.env\.\w*WEBHOOK_URL|\b(?:send|post|dispatch|publish|notify)\w*Webhook/,hh=/\b(?:req|request)\b/,gh=/\/\/[^\n]*|\/\*[\s\S]*?\*\/|"(?:\\.|[^"\\\n])*"|'(?:\\.|[^'\\\n])*'|`(?:\\.|[^`\\])*`/g,_h=W({id:`webhook-signature-risk`,title:`Webhook handler lacks signature verification`,severity:`warn`,recommendation:`Verify provider signatures before parsing or acting on webhook bodies. Use provider SDK helpers or HMAC verification with timing-safe comparison.`,scan:q({shouldScan:e=>{if(!K(e.relativePath)||mh.test(e.content))return!1;let t=e.content.replace(gh,``).replace(ph,``);return uh.test(e.relativePath)||uh.test(t)},pattern:dh,requireAll:[hh],suppressWhen:fh,message:`Webhook handler code does not show an obvious signature verification step.`})}),vh=()=>{vn(),_t(),hn()},yh=e=>xc.test(e)||Sc.test(e),bh=e=>{let t=Nc.test(e);return sm(e)||vm(e)||Kc(e)||zc(e)?{bucket:`priority`,isGeneratedBundleByName:t}:Rc(e,t)?{bucket:`artifact`,isGeneratedBundleByName:t}:yh(e)?{bucket:`other`,isGeneratedBundleByName:t}:null},xh=(e,t)=>t||yh(e)||zc(e)||sm(e),Sh=[`nextjs`,`astro`,`vite`,`cra`,`remix`,`gatsby`,`expo`,`react-native`,`tanstack-start`,`preact`,`unknown`];export{yl as $,p as $i,Kr as $n,Nt as $r,ro as $t,xp as A,qe as Ai,L as An,wr as Ar,W as At,Mu as B,pe as Bi,M as Bn,Bn as Br,Gs as Bt,Pp as C,He as Ci,Ui as Cn,jr as Cr,Nl as Ct,kp as D,tt as Di,zi as Dn,Pr as Dr,ll as Dt,Ap as E,Re as Ei,Vi as En,Nr as Er,Ml as Et,Ef as F,he as Fi,Si as Fn,Or as Fr,qs as Ft,wu as G,ue as Gi,ai as Gn,A as Gr,Ro as Gt,Ou as H,se as Hi,ni as Hn,j as Hr,Wo as Ht,Tf as I,y as Ii,F as In,Dr as Ir,Js as It,ou as J,ae as Ji,mi as Jn,xn as Jr,No as Jt,gu as K,ie as Ki,ei as Kn,Sn as Kr,Lo as Kt,wf as L,v as Li,wi as Ln,xr as Lr,Ks as Lt,sp as M,$e as Mi,Mi as Mn,Er as Mr,fc as Mt,zf as N,Ie as Ni,ji as Nn,Tr as Nr,pc as Nt,wp as O,ze as Oi,Bi as On,Fr as Or,cl as Ot,Mf as P,Le as Pi,Oi as Pn,kr as Pr,nc as Pt,ml as Q,m as Qi,di as Qn,Bt as Qr,go as Qt,xf as R,_ as Ri,P as Rn,mr as Rr,Us as Rt,Vp as S,Ue as Si,Wi as Sn,Ar as Sr,Wl as St,jp as T,We as Ti,Ri as Tn,Br as Tr,kl as Tt,Y as U,le as Ui,ui as Un,Ln as Ur,Bo as Ut,ku as V,fe as Vi,li as Vn,zn as Vr,Es as Vt,Tu as W,ne as Wi,si as Wn,Cn as Wr,zo as Wt,pl as X,de as Xi,fi as Xn,gn as Xr,bo as Xt,au as Y,oe as Yi,hi as Yn,k as Yr,Co as Yt,ul as Z,te as Zi,pi as Zn,en as Zr,yo as Zt,lm as _,Ye as _i,R as _n,Xr as _r,Ll as _t,_h as a,c as aa,Ot as ai,Za as an,Wr as ar,vl as at,tm as b,et as bi,Ki as bn,Rr as br,Ul as bt,$m as c,o as ca,bt as ci,Xa as cn,Ur as cr,zl as ct,Bm as d,st as di,ha as dn,Hr as dr,Kl as dt,ee as ea,Mt as ei,to as en,ci as er,hl as et,Pm as f,lt as fi,z as fn,Yr as fr,Rl as ft,dm as g,Ge as gi,sa as gn,qr as gr,Vl as gt,fm as h,rt as hi,oa as hn,oi as hr,ql as ht,vh as i,h as ia,Dt as ii,$a as in,Vr as ir,_l as it,vp as j,Je as ji,I as jn,Sr as jr,hc as jt,Cp as k,Be as ki,Pi as kn,Cr as kr,Gc as kt,Um as l,dt as li,eo as ln,Zr as lr,Gl as lt,pm as m,nt as mi,ca as mn,Gr as mr,jl as mt,bh as n,u as na,O as ni,no as nn,ti as nr,gl as nt,lh as o,l as oa,vt as oi,Qa as on,ii as or,Ol as ot,gm as p,it as pi,pa as pn,Jr as pr,bl as pt,hu as q,ce as qi,gi as qn,bn as qr,Po as qt,xh as r,f as ra,At as ri,Ya as rn,Qr as rr,dl as rt,ch as s,s as sa,yt as si,Ja as sn,_i as sr,Bl as st,Sh as t,d as ta,jt as ti,V as tn,$r as tr,fl as tt,Vm as u,ot as ui,Da as un,ri as ur,Al as ut,om as v,Ze as vi,ta as vn,Mr as vr,Il as vt,Np as w,Xe as wi,Hi as wn,Ir as wr,Pl as wt,Zp as x,Ke as xi,Gi as xn,Lr as xr,Fl as xt,rm as y,Qe as yi,ea as yn,zr as yr,Hl as yt,Nu as z,me as zi,N as zn,er as zr,Ws as zt};
|
|
31
|
+
//# sourceMappingURL=capability-DkrQ0p-y.js.map
|