oxlint-plugin-react-doctor 0.9.18 → 0.9.19-dev.2c5d72c
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-03XscVX8.js +28 -0
- package/dist/core.d.ts +23 -2
- package/dist/core.js +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +12 -12
- package/dist/{react-native-dependency-names-wQiIw9Gw.d.ts → react-native-dependency-names-HniFQ29a.d.ts} +2 -1
- package/package.json +1 -1
- package/dist/capability-BE9ryJ2C.js +0 -28
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import*as e from"node:fs";import{readFileSync as t}from"node:fs";import*as n from"node:path";import{KEYS as r}from"eslint-visitor-keys";import{parseSync as i,rawTransferSupported as a,visitorKeys as o}from"oxc-parser";const s=[[`nextjs`,`Next.js`,`NEXT_PUBLIC_*`],[`vite`,`Vite`,`VITE_*`],[`tanstack-start`,`TanStack Start`,`VITE_*`],[`cra`,`Create React App`,`REACT_APP_*`],[`gatsby`,`Gatsby`,`GATSBY_*`]],c=e=>{for(let[t,n,r]of s)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`},l=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,u=[{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`}],d=Object.fromEntries(u.map(e=>[e.key,e.severity])),f=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(`.`)),p=new Set([`width`,`height`,`top`,`left`,`right`,`bottom`,`padding`,`paddingTop`,`paddingRight`,`paddingBottom`,`paddingLeft`,`margin`,`marginTop`,`marginRight`,`marginBottom`,`marginLeft`,`borderWidth`,`fontSize`,`lineHeight`,`gap`]),m=new Set([`animate`,`initial`,`exit`,`whileHover`,`whileTap`,`whileFocus`,`whileDrag`,`whileInView`]),h=/blur\((\d+(?:\.\d+)?)px\)/,g=new Set([`requestAnimationFrame`,`setInterval`]),_=new Set([`framer-motion`,`motion`]),v=new Set([`bounce`,`elastic`,`wobble`,`jiggle`,`spring`]),y={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`},b=[`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`],ee=[`@react-router/dev`,`react-router-dom`,`react-router`],te=[`Component`,`element`,`lazy`],ne=[`action`,`clientAction`,`clientLoader`,`loader`],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([...b,`client-passive-event-listeners`,`effect-needs-cleanup`,`effect-listener-cleanup-reference-mismatch`,`anchor-target-exists`,`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-img-without-dimensions`,`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-reset-all-state-on-prop-change`,`no-side-effect-in-state-updater-function`,`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`,`rendering-hydration-no-flicker`,`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`,`rules-of-hooks`,`server-sequential-independent-await`,`rn-no-deprecated-modules`,`rn-no-legacy-shadow-styles`,`rn-no-raw-text`,`rn-prefer-expo-image`,`rn-style-prefer-boxshadow`,...re]),x=(e,t)=>typeof e==`object`&&!!e&&e.type===t,me=e=>{if(e.kind!==`import`)return null;let t=e.declarationNode.parent;return x(t,`ImportDeclaration`)?t:null},S=e=>{if(!x(e,`ImportSpecifier`))return;let t=e.imported;if(x(t,`Identifier`))return t.name;if(x(t,`Literal`)&&typeof t.value==`string`)return t.value},C=(e,t={})=>{if(!x(e,`Property`)&&!x(e,`MethodDefinition`)&&!x(e,`PropertyDefinition`)&&!x(e,`MemberExpression`))return null;let n=x(e,`MemberExpression`)?e.property:e.key;if(e.computed)return t.allowComputedString&&x(n,`Literal`)&&typeof n.value==`string`?n.value:t.allowComputedString&&t.stringifyNonStringLiterals&&x(n,`Literal`)?String(n.value):t.allowComputedString&&x(n,`TemplateLiteral`)&&n.expressions.length===0?n.quasis[0]?.value.cooked??n.quasis[0]?.value.raw??null:null;if(x(n,`Identifier`))return n.name;if(x(n,`Literal`)){if(typeof n.value==`string`)return n.value;if(t.stringifyNonStringLiterals)return String(n.value)}return null},w=e=>{let t=e.property;return!e.computed&&x(t,`Identifier`)?t.name:e.computed&&x(t,`Literal`)?typeof t.value==`string`?t.value:null:e.computed&&x(t,`TemplateLiteral`)&&t.expressions.length===0?t.quasis[0]?.value.cooked??t.quasis[0]?.value.raw??null:null},he=new Set([`ParenthesizedExpression`,`TSAsExpression`,`TSSatisfiesExpression`,`TSTypeAssertion`,`TSNonNullExpression`,`TSInstantiationExpression`,`ChainExpression`]),T=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}},ge=e=>{let t=me(e);if(!t||typeof t.source.value!=`string`||t.importKind===`type`||x(e.declarationNode,`ImportSpecifier`)&&e.declarationNode.importKind===`type`)return null;if(x(e.declarationNode,`ImportNamespaceSpecifier`))return{source:t.source.value,importedName:null,isNamespace:!0};if(x(e.declarationNode,`ImportDefaultSpecifier`))return{source:t.source.value,importedName:`default`,isNamespace:!1};let n=S(e.declarationNode);return n?{source:t.source.value,importedName:n,isNamespace:!1}:null},_e=(e,t,n)=>{let r=t.symbolFor(e);if(!r||n.has(r.id))return null;if(r.kind===`import`)return ge(r);if(r.kind!==`const`||!r.initializer)return null;if(n.add(r.id),x(r.declarationNode,`VariableDeclarator`)&&x(r.declarationNode.id,`ObjectPattern`)){let e=ve(r.initializer,t,n);if(!e||!e.isNamespace&&e.importedName!==`default`)return null;for(let t of r.declarationNode.id.properties){if(!x(t,`Property`)||(x(t.value,`AssignmentPattern`)?t.value.left:t.value)!==r.bindingIdentifier)continue;let n=C(t,{allowComputedString:!0});return n?{source:e.source,importedName:n,isNamespace:!1}:null}return null}return ve(r.initializer,t,n)},ve=(e,t,n=new Set)=>{let r=T(e);if(x(r,`Identifier`))return _e(r,t,n);if(!x(r,`MemberExpression`))return null;let i=w(r);if(!i)return null;let a=ve(r.object,t,n);return!a||!a.isNamespace&&a.importedName!==`default`?null:{source:a.source,importedName:i,isNamespace:!1}};let E=null;const ye=e=>{E?.existencePaths.add(e)},D=e=>{E?.contentPaths.add(e)},be=()=>E!==null,xe=e=>{let t=E,n={existencePaths:new Set,contentPaths:new Set};E=n;try{return{value:e(),trace:n}}finally{if(E=t,t!==null){for(let e of n.existencePaths)t.existencePaths.add(e);for(let e of n.contentPaths)t.contentPaths.add(e)}}},Se=e=>{if(E!==null){for(let t of e.existencePaths)E.existencePaths.add(t);for(let t of e.contentPaths)E.contentPaths.add(t)}},Ce=e=>xe(e).trace,we=new Map,Te=new Map;let Ee=0;const De=()=>{we.clear(),Te.clear(),Ee+=1},Oe=()=>Ee,ke=t=>{if(!t)return null;let r=n.dirname(t),i=we.get(r);if(i!==void 0){if(be()){let e=r;for(;ye(n.join(e,`package.json`)),e!==i;){let t=n.dirname(e);if(t===e)break;e=t}}return i}let a=r;for(;;){let t=n.join(a,`package.json`);ye(t);let i=!1;try{i=e.statSync(t,{throwIfNoEntry:!1})?.isFile()??!1}catch{i=!1}if(i)return we.set(r,a),a;let o=n.dirname(a);if(o===a)return we.set(r,null),null;a=o}},Ae=e=>{let t=ke(e);return t?je(t):null},je=t=>{let r=Te.get(t);if(r!==void 0&&!be())return r;let i=n.join(t,`package.json`);if(D(i),r!==void 0)return r;let a=null;try{let t=JSON.parse(e.readFileSync(i,`utf-8`));typeof t==`object`&&t&&(a=t)}catch{a=null}return Te.set(t,a),a},Me=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},Ne=(e,t)=>e.major-t.major||e.minor-t.minor||e.patch-t.patch||Number(t.isPrerelease)-Number(e.isPrerelease),Pe=new Map;let Fe=Oe();const Ie=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=Me(r);if(!i)return null;n.push(i)}return n.reduce((e,t)=>Ne(t,e)<0?t:e)},Le=(e,t)=>{let n=e.dependencies?.[t]??e.devDependencies?.[t]??e.peerDependencies?.[t]??e.optionalDependencies?.[t],r=Ie(n);return r&&typeof n==`string`?{version:r,declaredRange:n}:null},Re=(e,t)=>{let r=e;for(;;){let e=je(n.join(r,`node_modules`,t));if(e)return{didFindPackage:!0,version:typeof e.version==`string`?Me(e.version):null};let i=n.dirname(r);if(i===r)return{didFindPackage:!1,version:null};r=i}},ze=(e,t)=>{let n=Re(e,t);if(n.didFindPackage)return n.version?{version:n.version,declaredRange:null}:null;let r=je(e);return r?Le(r,t):null},Be=(e,t)=>{if(!e)return null;let r=ke(n.resolve(e));if(!r)return null;let i=Oe();i!==Fe&&(Pe.clear(),Fe=i);let a=JSON.stringify([r,t]),o=Pe.get(a);if(o)return Se(o.trace),o.version;let{value:s,trace:c}=xe(()=>ze(r,t));return Pe.set(a,{version:s,trace:c}),s},Ve=new Set([`implements`,`returnType`,`superTypeArguments`,`superTypeParameters`,`typeAnnotation`,`typeArguments`,`typeParameters`]),He={...o,...r,ArrayPattern:[`decorators`,...r.ArrayPattern],AssignmentPattern:[`decorators`,...r.AssignmentPattern],ClassDeclaration:[`decorators`,...r.ClassDeclaration],ClassExpression:[`decorators`,...r.ClassExpression],Identifier:[`decorators`,...r.Identifier],MethodDefinition:[`decorators`,...r.MethodDefinition],ObjectPattern:[`decorators`,...r.ObjectPattern],PropertyDefinition:[`decorators`,...r.PropertyDefinition],RestElement:[`decorators`,...r.RestElement]},Ue=new Map,We=e=>e.filter(e=>e!==`parent`&&!Ve.has(e)),Ge=e=>{let t=Ue.get(e.type);if(t)return t;let n=He[e.type];if(!n)return We(Object.keys(e));let r=We(n);return Ue.set(e.type,r),r},O=e=>typeof e==`object`&&!!e&&typeof e.type==`string`,k=e=>e!=null&&(e.type===`ArrowFunctionExpression`||e.type===`FunctionExpression`||e.type===`FunctionDeclaration`),Ke=e=>e===`var`||e===`function`,qe=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},Je=(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},Ye=(e,t,n)=>{let r=Je(e,t,n.currentScope,n);return n.scopeStack.push(r),n.currentScope=r,n.ownScopeForNode.set(t,r),r},Xe=e=>{e.scopeStack.pop();let t=e.scopeStack[e.scopeStack.length-1];if(!t)throw Error(`scope stack underflow`);e.currentScope=t},Ze=(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},Qe=(e,t,n,r,i,a)=>{if(x(e,`Identifier`)){Ze(n,r,{name:e.name,kind:i,bindingIdentifier:e,declarationNode:a,initializer:t});return}if(x(e,`ObjectPattern`)){for(let o of e.properties)if(x(o,`Property`)){let e=o.value;Qe(e,x(e,`AssignmentPattern`)?e.right:t,n,r,i,a)}else x(o,`RestElement`)&&Qe(o.argument,t,n,r,i,a);return}if(x(e,`ArrayPattern`)){for(let o of e.elements)o&&Qe(o,x(o,`AssignmentPattern`)?o.right??null:t,n,r,i,a);return}if(x(e,`AssignmentPattern`)){Qe(e.left,e.right??null,n,r,i,a);return}x(e,`RestElement`)&&Qe(e.argument,null,n,r,i,a)},$e=(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)},et=e=>e.parent?k(e.parent):!1,tt=e=>e.parent!==null&&e.parent!==void 0&&e.parent.type===`CatchClause`,nt=(e,t)=>{if(!x(e,`VariableDeclaration`))return;let n=e.kind===`var`?`var`:e.kind===`let`?`let`:e.kind===`const`?`const`:`using`,r=Ke(n)?qe(t.currentScope):t.currentScope;for(let i of e.declarations){let e=i,a=i.init??null;Qe(i.id,a,r,t,n,e)}},rt=(e,t)=>{x(e,`FunctionDeclaration`)&&e.id&&Ze(qe(t.currentScope),t,{name:e.id.name,kind:`function`,bindingIdentifier:e.id,declarationNode:e,initializer:e})},it=(e,t)=>{x(e,`ClassDeclaration`)&&e.id&&Ze(t.currentScope,t,{name:e.id.name,kind:`class`,bindingIdentifier:e.id,declarationNode:e,initializer:e})},at=(e,t)=>{if(!x(e,`ImportDeclaration`))return;let n=qe(t.currentScope);for(let r of e.specifiers){let e=r.local;x(e,`Identifier`)&&Ze(n,t,{name:e.name,kind:`import`,bindingIdentifier:e,declarationNode:r,initializer:r})}},ot=(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||!x(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`;Ze(qe(t.currentScope),t,{name:n.name,kind:r,bindingIdentifier:n,declarationNode:e,initializer:null})},st=(e,t,n)=>{for(let r of e)Qe(r,null,t,n,`parameter`,r)},ct=e=>!(!x(e,`BlockStatement`)||et(e)||tt(e)||e.parent&&e.parent.type===`TSModuleDeclaration`),lt=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)},ut=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}},dt=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`}},ft=(e,t)=>{t.nodeScope.set(e,t.currentScope)},pt=(e,t,n)=>{let r=Ye(e,t,n);return ft(t,n),r},mt=(e,t,n)=>{if(e.type===`AssignmentPattern`){mt(e.left,t,n);let r=e.right??null;r&&A(r,t,n);return}if(e.type===`ObjectPattern`){for(let r of e.properties){let e=r;if(e.type===`RestElement`){mt(e.argument,t,n);continue}if(e.type!==`Property`)continue;let i=e;i.computed&&A(i.key,t,n),mt(i.value,t,n)}return}if(e.type===`ArrayPattern`){for(let r of e.elements)r&&mt(r,t,n);return}e.type===`RestElement`&&mt(e.argument,t,n)},A=(e,t,n)=>{if(e.type===`ArrowFunctionExpression`||e.type===`FunctionExpression`||e.type===`FunctionDeclaration`){e.type===`FunctionDeclaration`&&e.id&&rt(e,t);let n=e.params??[],r=t.currentScope;for(let e of n)if(!(!(`decorators`in e)||!Array.isArray(e.decorators)))for(let n of e.decorators)O(n)&&A(n,t,r);ft(e,t);let i=Ye(e.type===`ArrowFunctionExpression`?`arrow-function`:`function`,e,t);(e.type===`FunctionExpression`||e.type===`FunctionDeclaration`)&&e.id&&Ze(i,t,{name:e.id.name,kind:`function`,bindingIdentifier:e.id,declarationNode:e,initializer:e}),st(n,i,t);for(let e of n)mt(e,t,r);let a=e.body;a&&A(a,t,r),Xe(t);return}if(e.type===`ClassDeclaration`||e.type===`ClassExpression`){if(e.type===`ClassDeclaration`&&e.id&&it(e,t),Array.isArray(e.decorators))for(let n of e.decorators)O(n)&&A(n,t,null);let n=pt(`class`,e,t);e.type===`ClassExpression`&&e.id&&Ze(n,t,{name:e.id.name,kind:`class`,bindingIdentifier:e.id,declarationNode:e,initializer:e}),e.superClass&&A(e.superClass,t,n),e.body&&A(e.body,t,n),Xe(t);return}if(e.type===`CatchClause`){let n=pt(`catch`,e,t);e.param&&Qe(e.param,null,n,t,`catch-clause-parameter`,e),e.body&&A(e.body,t,n),Xe(t);return}if(e.type===`ForStatement`||e.type===`ForInStatement`||e.type===`ForOfStatement`){pt(`for`,e,t),ht(e,t),Xe(t);return}if(e.type===`SwitchStatement`){let n=pt(`switch`,e,t);e.discriminant&&A(e.discriminant,t,n);for(let r of e.cases)A(r,t,n);Xe(t);return}if(e.type===`TSModuleDeclaration`){let n=pt(`ts-module`,e,t);if(e.id&&x(e.id,`Identifier`)){let r=e.id;Ze(qe(n.parent??t.currentScope),t,{name:r.name,kind:`ts-module`,bindingIdentifier:r,declarationNode:e,initializer:null})}e.body&&A(e.body,t,n),Xe(t);return}if(e.type===`TSEnumDeclaration`){ot(e,t);let n=pt(`ts-enum`,e,t),r=e.members??[];for(let e of r)A(e,t,n);Xe(t);return}if(e.type===`BlockStatement`&&ct(e)){let n=pt(`block`,e,t);for(let r of e.body)A(r,t,n);Xe(t);return}switch(t.currentScope!==n&&ft(e,t),e.type){case`VariableDeclaration`:nt(e,t);break;case`ImportDeclaration`:at(e,t);break;case`TSImportEqualsDeclaration`:case`TSTypeAliasDeclaration`:case`TSInterfaceDeclaration`:ot(e,t);break}(e.type===`Identifier`||e.type===`JSXIdentifier`)&&!t.symbolByBindingIdentifier.has(e)&&!ut(e)&&(e.type===`JSXIdentifier`?lt(e)&&$e(t,e,dt(e)):$e(t,e,dt(e))),ht(e,t)},ht=(e,t)=>{let n=e,r=t.currentScope;for(let i of Ge(e)){let e=n[i];if(Array.isArray(e))for(let n of e)O(n)&&A(n,t,r);else O(e)&&A(e,t,r)}},gt=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)},_t=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 r of e.body)A(r,n,t);else A(e,n,t);return gt(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}}},vt=(e,t)=>{let n=e;for(;n;){if(n===t)return!0;n=n.parent}return!1},yt=1024,bt=2e6,xt=1e3,j=e=>{let t=e.parent;for(;t;){if(k(t))return t;t=t.parent??null}return null},St=e=>x(e,`Identifier`)?e.name:x(e,`Literal`)&&typeof e.value==`string`?e.value:null,Ct=e=>{if(x(e,`ImportSpecifier`)){let t=e.imported;return x(t,`Identifier`)?t.name:x(t,`Literal`)&&typeof t.value==`string`?t.value:null}return x(e,`ImportDefaultSpecifier`)?`default`:null},wt=(e,t)=>{if(!x(e,`ExportNamedDeclaration`)||!e.source||e.exportKind===`type`)return null;let n=e.source.value;if(typeof n!=`string`)return null;for(let r of e.specifiers??[]){let e=Tt(r,t,n);if(e)return e}return null},Tt=(e,t,n)=>{if(!x(e,`ExportSpecifier`)||e.exportKind===`type`||St(e.exported)!==t)return null;let r=St(e.local);return r?{importedName:r,source:n}:null},Et=(e,t)=>{if(!x(e,`ExportAllDeclaration`)||!e.source||e.exportKind===`type`||e.exported)return null;let n=e.source.value;return typeof n==`string`?{importedName:t,source:n}:null},Dt=(e,t)=>{if(!x(e,`Program`))return[];let n=[];for(let r of e.body??[]){let e=wt(r,t);if(e)return[e];let i=Et(r,t);i&&n.push(i)}return n},M=(e,t)=>{if(e){if(x(e,`Identifier`)){t.add(e.name);return}if(x(e,`AssignmentPattern`)){M(e.left,t);return}if(x(e,`RestElement`)){M(e.argument,t);return}if(x(e,`ArrayPattern`)){for(let n of e.elements??[])M(n,t);return}if(x(e,`ObjectPattern`))for(let n of e.properties??[]){if(x(n,`RestElement`)){M(n.argument,t);continue}x(n,`Property`)&&M(n.value,t)}}},Ot=(e,t,n)=>{if(e&&!x(e,`Identifier`)){if(x(e,`AssignmentPattern`)){N(e.right,t,n),Ot(e.left,t,n);return}if(x(e,`RestElement`)){Ot(e.argument,t,n);return}if(x(e,`ArrayPattern`)){for(let r of e.elements??[])Ot(r,t,n);return}if(x(e,`ObjectPattern`))for(let r of e.properties??[]){if(x(r,`RestElement`)){Ot(r.argument,t,n);continue}x(r,`Property`)&&(r.computed&&N(r.key,t,n),Ot(r.value,t,n))}}},kt=(e,t,n)=>{if(!x(e,`FunctionDeclaration`)&&!x(e,`FunctionExpression`)&&!x(e,`ArrowFunctionExpression`))return;let r=new Set(n);for(let t of e.params??[])M(t,r);for(let n of e.params??[])Ot(n,t,r);N(e.body,t,r)},N=(e,t,n)=>{if(!e)return;if(x(e,`Identifier`)){n.has(e.name)||t.add(e.name);return}if(x(e,`MemberExpression`)){N(e.object,t,n),e.computed&&N(e.property,t,n);return}if(x(e,`Property`)){e.computed&&N(e.key,t,n),N(e.value,t,n);return}if(x(e,`FunctionDeclaration`)||x(e,`FunctionExpression`)||x(e,`ArrowFunctionExpression`)){kt(e,t,n);return}if(x(e,`TSAsExpression`)||x(e,`TSSatisfiesExpression`)||x(e,`TSTypeAssertion`)||x(e,`TSNonNullExpression`)||x(e,`TSInstantiationExpression`)){N(e.expression,t,n);return}if(typeof e.type==`string`&&e.type.startsWith(`TS`))return;let r=e;for(let e of Object.keys(r)){if(e===`parent`||Ve.has(e))continue;let i=r[e];if(Array.isArray(i))for(let e of i)O(e)&&N(e,t,n);else O(i)&&N(i,t,n)}},At=(e,t)=>N(e,t,new Set),jt=e=>{let t=[],n=new Set;if(x(e,`VariableDeclaration`))for(let r of e.declarations??[])x(r.init,`AwaitExpression`)&&(r.init.argument&&t.push(r.init.argument),M(r.id,n));else if(x(e,`ExpressionStatement`)){let r=e.expression;x(r,`AwaitExpression`)?r.argument&&t.push(r.argument):x(r,`AssignmentExpression`)&&x(r.right,`AwaitExpression`)&&(r.right.argument&&t.push(r.right.argument),x(r.left,`Identifier`)&&n.add(r.left.name))}else x(e,`ReturnStatement`)&&x(e.argument,`AwaitExpression`)?e.argument.argument&&t.push(e.argument.argument):x(e,`ForOfStatement`)&&e.await&&(e.right&&t.push(e.right),M(x(e.left,`VariableDeclaration`)?e.left.declarations?.[0]?.id??null:e.left,n));return t.length===0?null:{awaitedExpressions:t,boundNames:[...n]}},Mt=(e,t)=>{if(x(e,`VariableDeclaration`))for(let n of e.declarations??[])M(n.id,t)},Nt=(e,t,n)=>{let r=new Map,i=[];for(let a of e.body??[]){let e=jt(a);if(!e){let e=new Set;if(Mt(a,e),e.size===0)continue;let t=new Set;At(a,t);let n=new Set;for(let e of t)for(let t of r.get(e)??[])n.add(t);if(n.size===0)continue;for(let t of e)r.set(t,n);continue}if(n&&!e.awaitedExpressions.every(e=>n(e))){r.clear(),i.length=0;continue}let o=new Set;for(let t of e.awaitedExpressions)At(t,o);let s=new Set;for(let e of o)for(let t of r.get(e)??[])s.add(t);if(i.filter((e,t)=>!s.has(t)).length+1>=t)return a;let c=i.length;i.push(s);let l=new Set(s);l.add(c);for(let t of e.boundNames)r.set(t,l)}return null},P=e=>{let t=e;for(;t.parent&&he.has(t.parent.type);)t=t.parent;return t},Pt=e=>{if(x(e,`FunctionDeclaration`)&&x(e.id,`Identifier`))return e.id;let t=P(e),n=t.parent;return x(n,`VariableDeclarator`)&&n.init===t&&x(n.id,`Identifier`)?n.id:null},Ft=e=>{let t=P(e);return!!(t.parent&&x(t.parent,`AwaitExpression`)&&t.parent.argument===t)},F=(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=T(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},It=(e,t)=>{if(!k(e)||e.async||!x(e.body,`BlockStatement`))return!1;let[n,r,i,a,o]=e.body.body.toReversed();if(!x(o,`VariableDeclaration`)||o.kind!==`const`||o.declarations.length!==1||!x(a,`IfStatement`)||a.alternate||!x(i,`VariableDeclaration`)||i.kind!==`const`||i.declarations.length!==1||!x(r,`ExpressionStatement`)||!x(n,`ReturnStatement`))return!1;let s=o.declarations[0],c=i.declarations[0];if(!s?.init||!c?.init||!n.argument)return!1;let l=T(s.init),u=T(r.expression);if(!x(l,`CallExpression`)||!x(u,`CallExpression`)||!x(l.callee,`MemberExpression`)||!x(u.callee,`MemberExpression`)||l.optional||u.optional||l.callee.optional||u.callee.optional||w(l.callee)!==`get`||w(u.callee)!==`set`||l.arguments.length!==1||u.arguments.length!==2)return!1;let d=F(l.callee.object,t);if(d?.kind!==`const`||!d.initializer||j(d.bindingIdentifier)||F(u.callee.object,t)!==d)return!1;let f=T(d.initializer);if(!x(f,`NewExpression`)||!x(f.callee,`Identifier`)||![`Map`,`WeakMap`].includes(f.callee.name)||!t.isGlobalReference(f.callee)||f.arguments.length!==0)return!1;let p=a.consequent;if(x(p,`BlockStatement`)){if(p.body.length!==1)return!1;p=p.body[0]}let m=t.symbolFor(s.id),h=t.symbolFor(c.id),g=l.arguments[0],_=u.arguments[0],v=u.arguments[1];if(!m||!h||!x(p,`ReturnStatement`)||!p.argument||!g||!_||!v||t.symbolFor(T(a.test))!==m||t.symbolFor(T(p.argument))!==m||t.symbolFor(T(v))!==h||t.symbolFor(T(n.argument))!==h)return!1;let y=F(T(g),t);if(!y||y.references.some(e=>e.flag!==`read`)||y.kind!==`parameter`||j(y.bindingIdentifier)!==e||F(T(_),t)!==y)return!1;let b=l.callee.object,ee=u.callee.object;return d.references.every(e=>e.flag===`read`&&(e.identifier===b||e.identifier===ee))},Lt=e=>{let t=e;for(;t;){if(x(t,`Program`))return t;t=t.parent??null}return null},Rt=new WeakMap,zt=(e,t)=>{t.push(...e.symbols);for(let n of e.children)zt(n,t)},Bt=e=>{let t=new Map,n=[];zt(e.rootScope,n);for(let r of n){let n=F(r.bindingIdentifier,e);if(!n)continue;let i=t.get(n.id)??[];i.push(r),t.set(n.id,i)}return t},Vt=(e,t)=>{let n=F(e,t);if(!n)return[];let r=Rt.get(t);return r||(r=Bt(t),Rt.set(t,r)),r.get(n.id)??[]},Ht=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},I=(e,t,n={})=>{let r=C(e,{allowComputedString:!0,stringifyNonStringLiterals:n.stringifyNonStringLiterals});if(r!==null||!x(e,`Property`)&&!x(e,`MethodDefinition`)&&!x(e,`PropertyDefinition`)&&!x(e,`MemberExpression`)||!e.computed)return r;let i=T(x(e,`MemberExpression`)?e.property:e.key);if(!x(i,`Identifier`))return null;let a=F(i,t);if(a?.kind!==`const`||!a.initializer)return null;let o=T(a.initializer);return x(o,`Literal`)?typeof o.value==`string`?o.value:n.allowConstNumericLiteral&&typeof o.value==`number`?String(o.value):null:n.allowConstTemplateLiteral&&x(o,`TemplateLiteral`)?Ht(o):null},Ut=e=>{if(!k(e))return null;if(!x(e.body,`BlockStatement`))return e.body;if(e.body.body.length!==1)return null;let t=e.body.body[0];return x(t,`ReturnStatement`)&&t.argument?t.argument:null},Wt=new Set([`CatchClause`,`ConditionalExpression`,`DoWhileStatement`,`ForInStatement`,`ForOfStatement`,`ForStatement`,`IfStatement`,`LogicalExpression`,`SwitchCase`,`SwitchStatement`,`TryStatement`,`WhileStatement`]),Gt=(e,t)=>{let n=e.parent??null;for(;n&&n!==t;){if(Wt.has(n.type))return!1;n=n.parent??null}return n===t},Kt=e=>j(e)??Lt(e),qt=e=>{let t=P(e),n=t.parent;return!!(n&&x(n,`VariableDeclarator`)&&n.init===t&&n.parent&&x(n.parent,`VariableDeclaration`)&&n.parent.kind===`const`)},Jt=e=>{let t=P(e),n=t.parent;return!!(n&&(x(n,`AssignmentExpression`)&&n.left===t||x(n,`UpdateExpression`)&&n.argument===t||x(n,`UnaryExpression`)&&n.operator===`delete`&&n.argument===t))},Yt=e=>{let t=P(e),n=t.parent;return n&&x(n,`MemberExpression`)&&T(n.object)===t?n:null},Xt=(e,t,n,r,i)=>{if(i<=0||!x(e,`ObjectExpression`))return null;for(let a of e.properties.toReversed()){if(!x(a,`Property`))return null;let e=I(a,n);if(e===null)return null;if(e===t)return a.kind===`init`?L(a.value,n,r,i-1):null}return null},Zt=(e,t,n,r,i)=>{if(i<=0||!x(e,`ObjectExpression`))return[];let a=[],o=new Set;for(let s of e.properties){if(!x(s,`Property`))continue;let e=I(s,n),c=s.kind===`init`||s.kind===`get`?L(s.value,n,new Set(r),i-1):null;e===t?(a=c?[c]:[],o.clear(),c&&o.add(c)):e===null&&c&&!o.has(c)&&(a.push(c),o.add(c))}return a},Qt=(e,t,n,r,i)=>{if(i<=0||!x(e,`ClassDeclaration`)&&!x(e,`ClassExpression`))return null;for(let a of e.body.body.toReversed()){if(!x(a,`MethodDefinition`)&&!x(a,`PropertyDefinition`)||!a.static)continue;let e=I(a,n);if(e===null)return null;if(e===t)return x(a,`MethodDefinition`)&&a.kind!==`method`?null:a.value?L(a.value,n,r,i-1):null}return null},$t=(e,t,n,r,i)=>{if(i<=0||!x(e,`ClassDeclaration`)&&!x(e,`ClassExpression`))return[];let a=[],o=new Set;for(let s of e.body.body){if(!x(s,`MethodDefinition`)&&!x(s,`PropertyDefinition`)||!s.static)continue;let e=I(s,n),c=s.value&&(!x(s,`MethodDefinition`)||s.kind===`method`||s.kind===`get`)?L(s.value,n,new Set(r),i-1):null;e===t?(a=c?[c]:[],o.clear(),c&&o.add(c)):e===null&&c&&!o.has(c)&&(a.push(c),o.add(c))}return a},en=(e,t,n,r,i,a,o,s)=>{let c=Kt(t);if(s<=0||!c||!x(e,`Identifier`))return{exactFunction:null,possibleFunctions:[]};let l=[];for(let r of Vt(e,a))for(let e of r.references){let r=e.identifier;if(r.range[0]>=t.range[0]||qt(r))continue;let i=Yt(r);if(!i){Kt(r)===c&&l.push({assignedExpression:null,isDefinite:!1,offset:r.range[0]});continue}if(!Jt(i)||Kt(i)!==c)continue;let o=I(i,a),s=P(i).parent,u=s&&x(s,`AssignmentExpression`)&&s.operator===`=`?s.right:null;if(o===null){l.push({assignedExpression:u,isDefinite:!1,offset:i.range[0]});continue}if(o===n){if(!s||!x(s,`AssignmentExpression`)||s.operator!==`=`||!Gt(i,c)){l.push({assignedExpression:u,isDefinite:!1,offset:i.range[0]});continue}l.push({assignedExpression:u,isDefinite:!0,offset:s.range[0]})}}l.sort((e,t)=>e.offset-t.offset);let u=r,d=i,f=new Set(i);for(let e of l){let t=e.assignedExpression?L(e.assignedExpression,a,new Set(o),s-1):null;if(e.isDefinite){u=t,d=t?[t]:[],f.clear(),t&&f.add(t);continue}u=null,t&&!f.has(t)&&(d.push(t),f.add(t))}return{exactFunction:u,possibleFunctions:d}},tn=(e,t,n,r)=>{if(r<=0||!x(e,`MemberExpression`))return{exactFunction:null,possibleFunctions:[]};let i=w(e);if(i===null)return{exactFunction:null,possibleFunctions:[]};let a=T(e.object);if(x(a,`ObjectExpression`))return{exactFunction:Xt(a,i,t,n,r),possibleFunctions:Zt(a,i,t,n,r)};if(x(a,`ClassExpression`))return{exactFunction:Qt(a,i,t,n,r),possibleFunctions:$t(a,i,t,n,r)};if(!x(a,`Identifier`))return{exactFunction:null,possibleFunctions:[]};let o=F(a,t);if(!o||n.has(o.id))return{exactFunction:null,possibleFunctions:[]};n.add(o.id);let s=null,c=[];if(o.kind===`const`&&o.initializer){let e=T(o.initializer);s=Xt(e,i,t,n,r),c=Zt(e,i,t,n,r)}else o.kind===`class`&&o.initializer&&(s=Qt(o.initializer,i,t,n,r),c=$t(o.initializer,i,t,n,r));return en(a,e,i,s,c,t,n,r)},nn=(e,t,n,r)=>{if(r<=0)return[];let i=T(e);if(x(i,`CallExpression`)){let e=T(i.callee);return x(e,`MemberExpression`)&&w(e)===`bind`?nn(e.object,t,n,r-1):[]}if(x(i,`MemberExpression`)){let e=w(i);return e===`call`||e===`apply`?nn(i.object,t,n,r-1):tn(i,t,n,r).possibleFunctions}let a=L(i,t,n,r);return a?[a]:[]},L=(e,t,n,r)=>{let i=T(e);if(k(i))return i;if(r<=0)return null;if(x(i,`CallExpression`)){let e=T(i.callee);if(x(e,`MemberExpression`)&&w(e)===`bind`)return L(e.object,t,n,r-1);if(!i.arguments.every(e=>x(e,`Literal`)))return null;let a=L(e,t,n,r-1);if(!k(a)||a.async||a.generator||!a.params.every(e=>x(e,`Identifier`)))return null;let o=Ut(a),s=o&&T(o);return k(s)?s:null}if(x(i,`MemberExpression`)){let e=w(i);return e===`call`||e===`apply`?L(i.object,t,n,r-1):tn(i,t,n,r).exactFunction}if(!x(i,`Identifier`))return null;let a=F(i,t);return!a||n.has(a.id)?null:(n.add(a.id),a.kind===`function`?!a.references.some(e=>e.flag!==`read`)&&k(a.declarationNode)?a.declarationNode:null:a.kind!==`const`||!a.initializer?null:L(a.initializer,t,n,r-1))},rn=(e,t)=>L(e,t,new Set,15),an=(e,t)=>nn(e,t,new Set,15),on=(e,t)=>{if(!x(e,`CallExpression`)||!x(e.callee,`MemberExpression`)||w(e.callee)!==`join`)return!1;let n=T(e.callee.object);for(let e=0;e<15;e++){if(x(n,`ArrayExpression`))return!0;if(x(n,`Identifier`)){let e=F(n,t);if(!e?.initializer||e.references.some(e=>e.flag!==`read`))return!1;n=T(e.initializer);continue}if(!x(n,`CallExpression`))return!1;let e=T(n.callee);if(x(e,`MemberExpression`)&&[`map`,`filter`,`slice`].includes(w(e)??``)){n=T(e.object);continue}let r=rn(e,t);return!!(k(r)&&!r.async&&x(r.returnType,`TSTypeAnnotation`)&&x(r.returnType.typeAnnotation,`TSArrayType`))}return!1},sn=(e,t)=>{if(!x(e,`Program`))return null;let n=new Map,r=new Map,i=null,a=null,o=e=>{for(let t of e.declarations??[])x(t,`VariableDeclarator`)&&(!x(t.id,`Identifier`)||!t.init||n.set(t.id.name,T(t.init)))};for(let t of e.body??[]){if(x(t,`ImportDeclaration`)){if(t.importKind===`type`)continue;for(let e of t.specifiers??[])x(e,`ImportSpecifier`)&&e.importKind===`type`||(x(e,`ImportDefaultSpecifier`)||x(e,`ImportNamespaceSpecifier`)||x(e,`ImportSpecifier`))&&x(e.local,`Identifier`)&&n.set(e.local.name,e.local);continue}if(x(t,`VariableDeclaration`)){o(t);continue}if(x(t,`FunctionDeclaration`)&&t.id){n.set(t.id.name,t);continue}if(x(t,`ExportNamedDeclaration`)){if(t.exportKind===`type`)continue;let e=t.declaration;if(e&&x(e,`VariableDeclaration`)){o(e);for(let t of e.declarations??[])x(t,`VariableDeclarator`)&&x(t.id,`Identifier`)&&r.set(t.id.name,t.id.name)}else e&&x(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(!x(e,`ExportSpecifier`)||e.exportKind===`type`)continue;let t=x(e.local,`Identifier`)?e.local.name:null,n=null;x(e.exported,`Identifier`)?n=e.exported.name:x(e.exported,`Literal`)&&typeof e.exported.value==`string`&&(n=e.exported.value),t&&n&&r.set(n,t)}continue}if(!x(t,`ExportDefaultDeclaration`))continue;let e=t.declaration;e&&(x(e,`Identifier`)?a=e.name:((x(e,`FunctionDeclaration`)||x(e,`ClassDeclaration`))&&e.id&&n.set(e.id.name,e),i=T(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},cn=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 in i){if(n===`parent`||!Object.hasOwn(i,n))continue;let r=i[n];if(Array.isArray(r))for(let n=0;n<r.length;n+=1){let i=r[n];O(i)&&t(i,e)}else O(r)&&t(r,e)}};t(e,null)},ln={".ts":`ts`,".tsx":`tsx`,".js":`js`,".jsx":`jsx`,".mjs":`js`,".cjs":`js`,".mts":`ts`,".cts":`ts`},un=e=>ln[n.extname(e).toLowerCase()]??`tsx`;let dn=process.platform!==`win32`&&a();const fn=(e,t)=>({astType:`ts`,lang:un(e),experimentalRawTransfer:t}),pn=(e,t)=>{if(dn)try{return i(e,t,fn(e,!0))}catch{dn=!1}return i(e,t,fn(e,!1))},mn=({filename:e,sourceText:t,shouldAttachParentReferences:n=!0})=>{try{let r=pn(e,t);if(r.errors.some(e=>e.severity===`Error`))return null;let i=r.program;return n&&cn(i),i}catch{return null}},hn=new Map,gn=(e,t)=>{if(hn.delete(e),hn.set(e,t),hn.size>256){let e=hn.keys().next().value;e!==void 0&&hn.delete(e)}},_n=t=>{t.endsWith(`.d.ts`)||t.endsWith(`.d.mts`)||t.endsWith(`.d.cts`)||D(t);let n;try{n=e.statSync(t,{throwIfNoEntry:!1})}catch{return null}if(!n?.isFile()||n.size>2e6)return null;let r=hn.get(t);if(r&&r.mtimeMs===n.mtimeMs&&r.size===n.size)return gn(t,r),r.program;if(t.endsWith(`.d.ts`)||t.endsWith(`.d.mts`)||t.endsWith(`.d.cts`))return gn(t,{mtimeMs:n.mtimeMs,size:n.size,program:null}),null;let i;try{i=e.readFileSync(t,`utf8`)}catch{return gn(t,{mtimeMs:n.mtimeMs,size:n.size,program:null}),null}let a=mn({filename:t,sourceText:i});return gn(t,{mtimeMs:n.mtimeMs,size:n.size,program:a}),a},vn=[`.ts`,`.tsx`,`.js`,`.jsx`,`.mjs`,`.cjs`,`.mts`,`.cts`],yn=[`import`,`default`,`module`,`browser`,`require`],bn=[`module`,`main`,`browser`],xn={isDirectory:!0,isFile:!1},Sn={isDirectory:!1,isFile:!0},Cn={isDirectory:!1,isFile:!1},wn=new Map,Tn=new Map,En=t=>{ye(t);let n=wn.get(t);if(n)return n;let r=Cn;try{let n=e.statSync(t,{throwIfNoEntry:!1});n?.isFile()?r=Sn:n?.isDirectory()&&(r=xn)}catch{return wn.set(t,Cn),Cn}return wn.set(t,r),r},Dn=e=>En(e).isFile?e:null,On=e=>En(e).isDirectory?e:null,kn=e=>{let t=n.extname(e);if(!vn.includes(t))return vn.map(t=>`${e}${t}`);let r=e.slice(0,-t.length);return t===`.js`?[e,`${r}.ts`,`${r}.tsx`,`${r}.jsx`]:t===`.jsx`?[e,`${r}.tsx`]:t===`.mjs`?[e,`${r}.mts`]:t===`.cjs`?[e,`${r}.cts`]:[e]},An=e=>typeof e==`object`&&!!e,jn=e=>{if(typeof e==`string`)return e;if(Array.isArray(e)){for(let t of e){let e=jn(t);if(e)return e}return null}if(!An(e))return null;for(let t of yn){let n=jn(e[t]);if(n)return n}return null},Mn=e=>{let t=e.exports;return t?jn(t)||(An(t)?jn(t[`.`]):null):null},Nn=t=>{D(t);let n=Tn.get(t);if(n!==void 0)return n;let r;try{r=JSON.parse(e.readFileSync(t,`utf8`))}catch{r=null}return Tn.set(t,r),r},Pn=e=>In(e)||In(n.join(e,`index`)),Fn=e=>{let t=On(e);if(!t)return null;let r=Nn(n.join(t,`package.json`));if(!r)return null;let i=Mn(r)??bn.map(e=>r[e]).find(e=>typeof e==`string`);return i?Pn(n.resolve(t,i)):null},In=e=>{let t=Dn(e);if(t)return t;for(let t of kn(e)){let e=Dn(t);if(e)return e}return null},Ln=e=>In(e)||Fn(e)||In(n.join(e,`index`)),Rn=(e,t)=>Ln(n.resolve(n.dirname(e),t)),zn=()=>{wn.clear(),Tn.clear()},Bn=[`tsconfig.json`,`jsconfig.json`],Vn=e=>typeof e==`object`&&!!e,Hn=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`)},Un=(t,n)=>{D(t),n.push(t);let r;try{r=e.readFileSync(t,`utf8`)}catch{return null}try{let e=JSON.parse(Hn(r));return Vn(e)?e:null}catch{return null}},Wn=(e,t)=>{let r=e.endsWith(`.json`)?e:`${e}.json`;return e.startsWith(`./`)||e.startsWith(`../`)?n.resolve(t,r):n.join(t,`node_modules`,r)},Gn=e=>{let t=new Map;if(!Vn(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},Kn=(e,t,r)=>{let i=Un(e,r);if(!i)return null;let a=n.dirname(e),o=Vn(i.compilerOptions)?i.compilerOptions:{},s=typeof o.baseUrl==`string`?o.baseUrl:null,c=s!==null,l=s===null?a:n.resolve(a,s);if(Vn(o.paths))return{baseAbsolutePath:l,hasExplicitBaseUrl:c,paths:Gn(o.paths)};if(typeof i.extends==`string`&&t<8){let e=Wn(i.extends,a),n=e?Kn(e,t+1,r):null;if(n)return n}return c?{baseAbsolutePath:l,hasExplicitBaseUrl:c,paths:new Map}:null},qn=new Map,Jn=new Map,Yn=t=>{D(t);let n;try{n=e.statSync(t,{throwIfNoEntry:!1})}catch{n=void 0}if(n===void 0)return{config:null,probedContentPaths:new Set([t])};let r=qn.get(t);if(r&&r.mtimeMs===n.mtimeMs){for(let e of r.probedChainPaths)D(e);return{config:r.config,probedContentPaths:new Set(r.probedChainPaths)}}let i=[],a=Kn(t,0,i);return qn.set(t,{mtimeMs:n.mtimeMs,config:a,probedChainPaths:i}),{config:a,probedContentPaths:new Set(i)}},Xn=(e,t,n)=>{let r=new Set(t.probedContentPaths),i=n;for(let n=e.length-1;n>=0;n--){let a=e[n];i++;for(let e of a.probedContentPaths)r.add(e);Jn.set(a.directory,{config:t.config,directoryCount:i,probedContentPaths:new Set(r)})}},Zn=e=>{let t=Jn.get(e);if(t!==void 0){for(let e of t.probedContentPaths)D(e);return t.config}let r=[],i=e;for(let e=0;e<30;e++){let t=Jn.get(i),a=30-e;if(t!==void 0&&t.directoryCount<=a){for(let e of t.probedContentPaths)D(e);return Xn(r,t,t.directoryCount),t.config}let o=new Set;for(let e of Bn){let t=Yn(n.join(i,e));for(let e of t.probedContentPaths)o.add(e);if(t.config)return r.push({directory:i,probedContentPaths:o}),Xn(r,{config:t.config,probedContentPaths:new Set},0),t.config}r.push({directory:i,probedContentPaths:o});let s=n.dirname(i);if(s===i)return Xn(r,{config:null,probedContentPaths:new Set},0),null;i=s}let a=new Set;for(let e of r)for(let t of e.probedContentPaths)a.add(t);return Jn.set(e,{config:null,directoryCount:r.length,probedContentPaths:a}),null},Qn=(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},$n=(e,t)=>{let r=Zn(n.dirname(e));if(!r)return null;let i=null,a=``,o=-1;for(let e of r.paths.keys()){let n=Qn(t,e);if(n===null)continue;let r=e.indexOf(`*`),s=r===-1?e.length:r;s>o&&(i=e,a=n,o=s)}if(i)for(let e of r.paths.get(i)??[]){let t=e.replaceAll(`*`,a),i=Ln(n.resolve(r.baseAbsolutePath,t));if(i)return i}return r.hasExplicitBaseUrl?Ln(n.resolve(r.baseAbsolutePath,t)):null},er=()=>{qn.clear(),Jn.clear()},tr=(e,t)=>n.isAbsolute(t)?null:t.startsWith(`.`)?Rn(e,t):$n(e,t),nr=new Map,rr=()=>{nr.clear()},ir=(e,t,n)=>{if(n.size>=4||n.has(e))return null;n.add(e);let r=_n(e);if(!r)return null;let i=sn(r,t);if(i)return{filePath:e,exportedNode:i,programNode:r};let a=new Map;for(let i of Dt(r,t)){let t=tr(e,i.source);if(!t)continue;let r=ir(t,i.importedName,new Set(n));r&&a.set(r.exportedNode,r)}return a.size===1?a.values().next().value??null:null},ar=(e,t,n)=>or(e,t,n)?.functionNode??null,or=(e,t,n)=>{let r=R(e,t,n);return!r||!k(r.exportedNode)?null:{filePath:r.filePath,functionNode:r.exportedNode,programNode:r.programNode}},R=(e,t,n)=>{if(!be()){let r=tr(e,t);return r?ir(r,n,new Set):null}let r=`${e}\0${t}\0${n}`,i=nr.get(r);if(i!==void 0){for(let e of i.trace.contentPaths)D(e);for(let e of i.trace.existencePaths)ye(e);return i.result}let a=xe(()=>{let r=tr(e,t);return r?ir(r,n,new Set):null});return nr.set(r,{result:a.value,trace:a.trace}),a.value},sr=(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];O(n)&&t.push(n)}else O(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];O(n)&&t.push(n)}else O(a)&&t.push(a)}},cr=(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];O(n)&&t(n)}else O(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];O(n)&&t(n)}else O(r)&&t(r)}},z=(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||sr(e,n)}},lr=new WeakMap,ur=new Set([`TSStringKeyword`,`TSNumberKeyword`,`TSBooleanKeyword`]),dr=new Set([`String`,`Number`,`Boolean`]),fr=(e,t,n)=>{let r=[],i=15,a=(e,t,n,o,s,c)=>{let l=e=>{let r=F(T(e),o);return!r||r.references.some(e=>e.flag!==`read`)?null:t.has(r.bindingIdentifier)?t.get(r.bindingIdentifier)??null:n&&j(r.bindingIdentifier)===n?null:r.bindingIdentifier};z(e,e=>{if(k(e)||x(e,`ClassDeclaration`)||x(e,`ClassExpression`))return!1;if(c&&x(e,`AwaitExpression`)&&!x(T(e.argument),`CallExpression`)&&r.push({binding:e,member:null,inputs:[],crossFile:!0}),!x(e,`CallExpression`))return;let n=T(e.callee);if(e.optional||x(n,`MemberExpression`)&&n.optional)return c&&r.push({binding:e,member:null,inputs:[],crossFile:!0}),!1;let u=e.arguments.map(l),d=x(n,`MemberExpression`)?T(n.object):n,f=F(d,o),p=x(n,`Identifier`)&&(f?.kind===`function`||k(f?.initializer))?rn(n,o):null,m=o,h=s,g=c;if(f?.kind===`import`){let e=x(n,`MemberExpression`)?w(n):null,t=f.declarationNode,a=me(f),o=null;if(x(t,`ImportNamespaceSpecifier`)?o=e:x(n,`Identifier`)&&(o=Ct(t)),s&&i>0&&o&&a&&a.importKind!==`type`&&(!x(t,`ImportSpecifier`)||t.importKind!==`type`)){i--;let e=or(s,a.source.value,o);e&&(p=e.functionNode,m=lr.get(e.programNode)??_t(e.programNode),lr.set(e.programNode,m),h=e.filePath,g=!0)}!p&&!c&&(x(n,`Identifier`)||e!==null)&&r.push({binding:f.bindingIdentifier,member:e,inputs:u})}else if(!c&&x(n,`MemberExpression`)&&w(n)===`get`&&f?.kind===`const`&&f.initializer){let e=T(f.initializer);if(x(e,`NewExpression`)&&x(e.callee,`Identifier`)&&(e.callee.name===`Map`||e.callee.name===`WeakMap`)&&o.isGlobalReference(e.callee)){let e=l(d);e&&r.push({binding:e,member:`get`,inputs:[u[0]??null]})}}if(g&&p){let t=Pt(p),n=t?m.symbolFor(t):null;if(n&&(n.kind!==`const`&&n.kind!==`function`||n.references.some(e=>e.flag!==`read`)))return r.push({binding:e,member:null,inputs:[],crossFile:!0}),!1}if(g&&p&&It(p,m))return r.push({binding:p,member:null,inputs:u,crossFile:!0}),!1;if(!k(p)||i<=0){c&&(i<=0||f?.kind===`import`||Ft(e)||x(e.parent,`ReturnStatement`)&&!on(e,o)&&!(x(n,`Identifier`)&&dr.has(n.name)&&o.isGlobalReference(n))||x(n,`Identifier`)&&n.name===`fetch`&&o.isGlobalReference(n))&&r.push({binding:e,member:null,inputs:[],crossFile:!0});return}if(c&&!p.async&&!Ft(e)&&(!x(e.parent,`ReturnStatement`)||x(p.returnType,`TSTypeAnnotation`)&&ur.has(p.returnType.typeAnnotation.type)))return;i--;let _=new Map(t);for(let[e,t]of p.params.entries()){let n=m.symbolFor(t);n&&_.set(n.bindingIdentifier,u[e]??null)}a(p.body,_,p,m,h,g)})};for(let r of jt(e)?.awaitedExpressions??[])a(r,new Map,null,t,n,!1);return r},pr=(e,t,n,r)=>{let i=fr(e,n,r);if(i.length===0)return!1;let a=fr(t,n,r),o=e=>i.some(t=>t.binding===e.binding&&t.member===e.member&&t.inputs.length>0&&t.inputs.length===e.inputs.length&&t.inputs.every((t,n)=>t!==null&&t===e.inputs[n]));return a.some(o)&&(!a.some(e=>e.crossFile)||a.every(o))},mr=`(?:tsx?|jsx?|mts|mjs)`,hr=RegExp(`/page\\.${mr}$`),gr=RegExp(`/(page|layout)\\.${mr}$`),_r=[`layout.tsx`,`layout.jsx`,`layout.ts`,`layout.js`,`layout.mts`,`layout.mjs`],vr=[`metadata`,`generateMetadata`],yr=/\/(?:(?:\((?:dashboard|admin|settings|account|internal|manage|console|portal|auth|onboarding|app|ee|protected)\))|(?:dashboard|admin|settings|account|internal|manage|console|portal))\//i,br=new Set([`redirect`,`permanentRedirect`,`notFound`,`forbidden`,`unauthorized`]),xr=new Set([`revalidateTag`,`revalidatePath`,`expireTag`,`expirePath`,`unstable_expireTag`,`unstable_expirePath`]),Sr=/fonts\.googleapis\.com/,Cr=/polyfill\.io|polyfill\.min\.js|cdn\.polyfill/,wr=RegExp(`/route\\.${mr}$`),Tr=/\/(?:cron|jobs\/cron)(?:\/|$)/i,Er=new Set([`logout`,`log-out`,`signout`,`sign-out`,`unsubscribe`,`delete`,`remove`,`revoke`,`cancel`,`deactivate`]),Dr=RegExp(`/(error|global-error)\\.${mr}$`),Or=RegExp(`/global-error\\.${mr}$`),kr=new Set([`GET`,`POST`,`PUT`,`PATCH`,`DELETE`,`OPTIONS`,`HEAD`]),Ar=/google-analytics\.com|googletagmanager\.com\/gtag/,jr=RegExp(`/(opengraph-image|twitter-image)\\d*\\.${mr}$`),Mr=new Set([`expo`,`expo-router`,`@expo/cli`,`@expo/metro-config`,`@expo/metro-runtime`]),Nr=new Set([`react-native`,`react-native-tvos`,...Mr,`react-native-windows`,`react-native-macos`]),Pr=[`@react-native/`,`@react-native-`],Fr=e=>Mr.has(e),Ir=e=>{if(Nr.has(e))return!0;for(let t of Pr)if(e.startsWith(t))return!0;return!1},Lr=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`]),Rr=[`dependencies`,`devDependencies`,`peerDependencies`,`optionalDependencies`],zr=function*(e){for(let t of Rr){let n=e[t];if(n)for(let e of Object.keys(n))yield e}},Br=e=>{if(typeof e[`react-native`]==`string`)return!0;for(let t of zr(e))if(Ir(t))return!0;return!1},Vr=e=>{for(let t of zr(e))if(Fr(t))return!0;return!1},Hr=e=>{for(let t of zr(e))if(Lr.has(t))return!0;return!1},Ur=e=>Rr.some(t=>{let n=e[t];return typeof n==`object`&&!!n&&Object.keys(n).length>0}),Wr=(e,t)=>Rr.some(n=>{let r=e[n];return typeof r==`object`&&!!r&&Object.prototype.propertyIsEnumerable.call(r,t)}),Gr=new WeakMap,Kr=e=>{let t=Ae(e);if(!t)return`unknown`;let n=Gr.get(t);if(n!==void 0)return n;let r;return r=Vr(t)?`expo`:Br(t)?`react-native`:Hr(t)?`web`:Ur(t)?`neutral`:`unknown`,Gr.set(t,r),r},qr=({absoluteFilePath:e,staticImports:t,program:n})=>{let r=new Set;if(z(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&&ar(e,n.moduleRequest.value,a)}},Jr=e=>e.replace(/^type\s+/,``).trim(),Yr=(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=Jr(r??``);return{localName:a,exportedName:Jr(i??a),isTypeOnly:n}}),Xr=/\/\*[\s\S]*?\*\//g,Zr=/^\s*\/\/.*$/gm,Qr=e=>e.replace(Xr,``).replace(Zr,``),$r=/^\s*export\s+default\b/m,ei=/^\s*export\s+(?:declare\s+)?(?:(?:async\s+)?function|(?:abstract\s+)?class|const|let|var|enum|interface|type)\s+([\w$]+)/gm,ti=/^\s*export\s+(?:type\s+)?\{([\s\S]*?)\}(?:\s+from\s+["'][^"']+["'])?\s*;?\s*(?:(?:\/\/[^\n]*)?\s*)/gm,ni=e=>{let t=Qr(e),n=new Set;$r.test(t)&&n.add(`default`);for(let e of t.matchAll(ei))e[1]&&n.add(e[1]);for(let e of t.matchAll(ti)){let t=e[1]??``;for(let e of Yr(t,!1))n.add(e.exportedName)}return n},ri=new Map,ii=(t,n)=>{D(t);try{let r=e.statSync(t,{throwIfNoEntry:!1});if(r===void 0)return!1;let i=ri.get(t);if(i&&i.mtimeMs===r.mtimeMs&&i.size===r.size)return i.exportedNames.has(n);let a=ni(e.readFileSync(t,`utf8`));return ri.set(t,{mtimeMs:r.mtimeMs,size:r.size,exportedNames:a}),a.has(n)}catch{return!1}},ai=(e,t)=>{let r=e.replaceAll(`\\`,`/`),i=n.dirname(r);for(let e=0;e<30;e++){for(let e of _r){let a=n.join(i,e);if(a.replaceAll(`\\`,`/`)!==r&&t(a))return!0}let e=n.dirname(i);if(n.basename(i)===`app`&&n.basename(e)!==`app`||e===i)break;i=e}return!1},oi=e=>ai(e,e=>vr.some(t=>ii(e,t))),si=e=>x(e,`JSXIdentifier`)?e.name===`Suspense`:x(e,`JSXMemberExpression`)&&x(e.property,`JSXIdentifier`)&&e.property.name===`Suspense`,ci=e=>{let t=!1;return z(e,e=>{if(t)return!1;if(x(e,`JSXOpeningElement`)&&si(e.name)||x(e,`ImportDeclaration`)&&e.source?.value===`react`&&(e.specifiers??[]).some(e=>x(e,`ImportSpecifier`)&&S(e)===`Suspense`))return t=!0,!1}),t},li=e=>ai(e,e=>{let t=_n(e);return!!(t&&ci(t))}),ui=e=>{if(x(e,`ImportDeclaration`)){if(e.importKind===`type`||e.specifiers.length>0&&e.specifiers.every(e=>x(e,`ImportSpecifier`)&&e.importKind===`type`))return null}else if(x(e,`ExportNamedDeclaration`)){if(e.exportKind===`type`||!e.source||e.specifiers.length>0&&e.specifiers.every(e=>x(e,`ExportSpecifier`)&&e.exportKind===`type`))return null}else if(x(e,`ExportAllDeclaration`)){if(e.exportKind===`type`)return null}else return null;return e.source&&typeof e.source.value==`string`?e.source.value:null},di=/^index\.(?:[cm]?[jt]sx?|mjs)$/,fi=/^\s*import\s+(type\s+)?(?!["'])([^;]*?)\s+from\s+["']([^"']+)["']\s*;?\s*(?:(?:\/\/[^\n]*)?\s*)/gm,pi=/^\s*export\s+(type\s+)?(?:\*(?:\s+as\s+([\w$]+))?|\{([\s\S]*?)\})\s+from\s+["']([^"']+)["']\s*;?\s*(?:(?:\/\/[^\n]*)?\s*)/gm,mi=/^\s*export\s+(type\s+)?\{([\s\S]*?)\}\s*;?\s*(?:(?:\/\/[^\n]*)?\s*)/gm,hi=new Map,gi=e=>di.test(n.basename(e)),_i=()=>({isBarrel:!1,exportsByName:new Map,starExportSources:[]}),vi=(e,t)=>{e.set(t.localName,{...t,didExport:!1})},yi=(e,t,n,r)=>{for(let i of Yr(e,n))vi(r,{localName:i.exportedName,importedName:i.localName,source:t,isTypeOnly:i.isTypeOnly})},bi=(e,t,n,r)=>{let i=e.trim(),a=i.match(/(?:^|,\s*)\*\s+as\s+([\w$]+)/);a?.[1]&&vi(r,{localName:a[1],importedName:`*`,source:t,isTypeOnly:n});let o=i.match(/\{([\s\S]*?)\}/);o?.[1]&&yi(o[1],t,n,r);let s=i.split(`,`)[0]?.trim();s&&!s.startsWith(`{`)&&!s.startsWith(`*`)&&vi(r,{localName:s,importedName:`default`,source:t,isTypeOnly:n})},xi=(e,t,n,r)=>{let i=e.replace(fi,(e,n,r,i)=>(bi(r,i,!!n,t),``));return i=i.replace(pi,(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 Yr(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(mi,(e,r,i)=>{for(let a of Yr(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},Si=e=>{for(let t of e.values())if(!t.isTypeOnly&&!t.didExport)return!0;return!1},Ci=e=>{let t=Qr(e).trim();if(!t)return _i();let n=new Map,r=new Map,i=[];return xi(t,n,r,i).trim()||Si(n)?_i():{isBarrel:r.size>0||i.length>0,exportsByName:r,starExportSources:i}},wi=t=>{if(!gi(t))return _i();D(t);let n;try{n=e.statSync(t,{throwIfNoEntry:!1})??null}catch{n=null}let r=hi.get(t);if(r!==void 0&&n!==null&&r.mtimeMs===n.mtimeMs&&r.size===n.size)return r.moduleInfo;if(n===null)return _i();let i=_i();try{i=Ci(e.readFileSync(t,`utf8`))}catch{i=_i()}return hi.set(t,{mtimeMs:n.mtimeMs,size:n.size,moduleInfo:i}),i},Ti=e=>wi(e).isBarrel,Ei=n.join(`android`,`gradle.properties`),Di=/^\s*newArchEnabled\s*=\s*false\s*$/m,Oi=[`app.config.ts`,`app.config.js`,`app.config.cjs`,`app.config.mjs`],ki=[`app.config.json`,`app.json`],Ai=new WeakMap,ji=e=>{D(n.join(e,Ei));for(let t of Oi)ye(n.join(e,t));for(let t of ki)D(n.join(e,t))},Mi=t=>{try{return e.readFileSync(t,`utf-8`)}catch{return null}},Ni=e=>{let t=e.dependencies?.[`react-native`]??e.devDependencies?.[`react-native`];return typeof t==`string`?t:null},Pi=e=>{let t=e.match(/(?:^|[^\d.])0\.(\d+)/);return t?Number.parseInt(t[1],10):null},Fi=e=>{let t=Mi(n.join(e,Ei));return t!==null&&Di.test(t)},Ii=t=>{for(let r of Oi)if(e.existsSync(n.join(t,r)))return!1;for(let e of ki){let r=Mi(n.join(t,e));if(r===null)continue;let i;try{i=JSON.parse(r)}catch{continue}if(typeof i!=`object`||!i)continue;let a=Object.getOwnPropertyDescriptor(i,`expo`)?.value;if(!(typeof a!=`object`||!a)&&Object.getOwnPropertyDescriptor(a,`newArchEnabled`)?.value===!1)return!0}return!1},Li=(e,t)=>{let n=Ni(t);if(n!==null){let e=Pi(n);if(e!==null&&e<76)return!0}return Fi(e)||Ii(e)},Ri=e=>{let t=ke(e);if(!t)return!1;let n=Ae(e);if(!n)return!1;ji(t);let r=Ai.get(n);if(r!==void 0)return r;let i=Li(t,n);return Ai.set(n,i),i},zi=e=>Be(e,`ink`)?.version??null,Bi=(e,t)=>{let n=zi(e),r=Me(t);return!!(n&&r&&Ne(n,r)>=0)},Vi=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`]),Hi=new Set([`fetch`,`ky`,`got`,`wretch`,`ofetch`]),Ui=new Set([`axios`,`ky`,`got`,`ofetch`,`wretch`,`request`]),Wi=new Set([`create`,`insert`,`insertInto`,`update`,`upsert`,`delete`,`remove`,`destroy`,`set`,`append`]),Gi=new Set([`POST`,`PUT`,`DELETE`,`PATCH`]),Ki=new Set([`Map`,`Set`,`WeakMap`,`WeakSet`,`Headers`,`URLSearchParams`,`FormData`,`Response`,`NextResponse`]),qi=new Set([`Response`,`NextResponse`]),Ji=new Set([`json`,`redirect`,`next`,`rewrite`,`error`]),Yi=new Set([`wheel`,`mousewheel`,`touchstart`,`touchmove`]),Xi=new Set([`defer`,`async`]),Zi=new Set([`text/javascript`,`application/javascript`,`module`]),Qi=new Set([`setTimeout`,`setInterval`,`requestAnimationFrame`,`requestIdleCallback`,`queueMicrotask`]),$i=new Set([`setInterval`,`setTimeout`]),ea=new Set([`clearInterval`,`clearTimeout`]),ta=new Set([`WebSocket`,`EventSource`,`BroadcastChannel`,`RTCPeerConnection`]),na=new Set([`location`,`window`,`document`,`navigator`,`history`,`screen`,`performance`]),ra=new Set([`IntersectionObserver`,`MutationObserver`,`ResizeObserver`,`PerformanceObserver`]),ia=new Set([`blur`,`canPlayType`,`focus`,`getBoundingClientRect`,`getClientRects`,`measure`,`measureInWindow`,`measureLayout`,`scroll`,`scrollBy`,`scrollIntoView`,`scrollTo`,`select`,`setRangeText`,`setSelectionRange`]),aa=new Set([`localStorage`,`sessionStorage`]),oa=new Set([`index`,`idx`,`i`]),sa=new Set([`react`,`react-dom`,`preact/compat`,`preact/hooks`,`@wordpress/element`]),ca=new Set([`next`,`next-themes`,`@remix-run/react`,`swr`,`zustand`,`jotai`,`recoil`,`wouter`,`framer-motion`,`@apollo/client`,`urql`,`usehooks-ts`]),la=new Set([`useState`,`useMemo`,`useRef`]),ua=new Set([`Click`,`Change`,`Input`,`Blur`,`Focus`]),da=new Set([`Boolean`,`String`,`Number`,`Array`,`Object`,`parseInt`,`parseFloat`]),fa=/^set[A-Z]/,pa=/^render[A-Z]/,ma=/^[A-Z]/,ha=/^on[A-Z]/,ga=/^use[A-Z]/,_a=/^(?:on|handle)[A-Z]/,va=new Set([`useEffect`,`useLayoutEffect`]),ya=new Set([`useEffect`,`useLayoutEffect`,`useMemo`,`useCallback`]),ba=new Set([`use`,`useState`,`useRef`,`useMemo`,`useCallback`,`useReducer`,`useContext`,`useEffect`,`useLayoutEffect`,`useInsertionEffect`,`useImperativeHandle`,`useSyncExternalStore`,`useDeferredValue`,`useTransition`,`useId`,`useDebugValue`]),xa=new Set([`memo`,`forwardRef`,`React.memo`,`React.forwardRef`]),Sa=new Set([`useMemo`,`useCallback`]),Ca=new Set([`memo`,`forwardRef`,`observer`,`lazy`]),wa=new Set([`subscribe`,`addEventListener`,`addListener`,`on`,`watch`,`listen`,`sub`]),Ta=new Set([`subscribe`,`sub`,`listen`]),Ea=new Set([`unsubscribe`,`removeEventListener`,`removeListener`,`off`,`unwatch`,`unlisten`,`unsub`,`abort`,`disconnect`,`unobserve`,`close`]),Da=new Set([`remove`,`cleanup`,`dispose`,`destroy`,`stop`,`teardown`]),Oa=new Set([...Ea,`cleanup`,`dispose`,`destroy`,`teardown`]),ka=new Set([...wa,`connect`,`disconnect`,`open`,`close`,`fetch`,`post`,`put`,`patch`]),Aa=new Set([`get`,`head`,`options`,`delete`]),ja=new Set([...Hi,...Qi]),Ma=new Set([...Hi,`post`,`put`,`patch`,`navigate`,`navigateTo`,`showNotification`,`toast`,`alert`,`confirm`,`logVisit`,`captureEvent`]),Na=new Set([`post`,`put`,`patch`,`delete`,`navigate`,`capture`,`track`,`logEvent`]),Pa=new Set([`push`,`replace`]),Fa=new Set([`router`,`navigation`,`navigator`,`history`,`location`]),Ia=new Map([[`react_ujs`,new Set([`useContext`,`useContexts`])]]),La={},Ra=new WeakMap,za=(e,t)=>typeof e==`string`?e===t:e.has(t),Ba=e=>{let t=Ra.get(e);if(t)return t;let n=e.declarationNode.parent,r=!!(e.kind===`import`&&n&&n.type===`ImportDeclaration`&&typeof n.source.value==`string`&&sa.has(n.source.value)),i={importedName:r?S(e.declarationNode):void 0,isReactImport:r};return Ra.set(e,i),i},Va=e=>Ba(e).isReactImport,Ha=(e,t,n,r)=>{if(e.type!==`Identifier`)return!1;let i=r?F(e,n):n.symbolFor(e);if(!i)return!1;let a=Ba(i);return!!(a.isReactImport&&a.importedName&&za(t,a.importedName))},Ua=(e,t)=>{let n=F(e,t);if(!n)return!1;let r=Ba(n);return r.isReactImport?n.declarationNode.type===`ImportDefaultSpecifier`||n.declarationNode.type===`ImportNamespaceSpecifier`||r.importedName===`default`:!1},Wa=(e,t,n)=>e.type===`Identifier`?Ua(e,t)?!0:!!(n.allowGlobalReactNamespace&&e.name===`React`&&t.isGlobalReference(e)):!1,Ga=(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=C(e);return!!(a&&za(t,a)&&Wa(T(i.initializer),n,r))}return!1},Ka=(e,t,n,r=La)=>e.type===`CallExpression`?qa(e.callee,t,n,r):!1,qa=(e,t,n,r,i)=>{let a=T(e);if(r.resolveConditionalAliases&&a.type===`ConditionalExpression`)return qa(a.consequent,t,n,r,new Set(i))&&qa(a.alternate,t,n,r,new Set(i));if(a.type===`Identifier`){if(Ha(a,t,n,!!r.resolveNamedAliases)||r.resolveNamedAliases&&Ga(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),qa(e.initializer,t,n,r,a)}}return!!(r.allowUnboundBareCalls&&za(t,a.name)&&n.isGlobalReference(a))}return a.type!==`MemberExpression`||!za(t,w(a)??``)?!1:Wa(T(a.object),n,r)},Ja=e=>e.includes(`\\`)?e.replaceAll(`\\`,`/`):e,Ya=e=>{let t=new Set(e);if(t.size!==1)return null;let[n]=t;return n??null},Xa=(e,t,n,r)=>{let i=Rn(e,n);return i?Za(i,t,new Set(r))||(ii(i,t)?i:null):null},Za=(e,t,n=new Set)=>{if(n.has(e))return null;n.add(e);let r=wi(e);if(!r.isBarrel)return null;let i=r.exportsByName.get(t);if(i){let t=Rn(e,i.source);return t?Za(t,i.importedName,n)??t:null}return t===`default`?null:Ya(r.starExportSources.map(r=>Xa(e,t,r,n)).filter(e=>!!e))},Qa=(e,t,n)=>{let r=R(e,t,n);return r?{filePath:r.filePath,node:r.exportedNode,programNode:r.programNode,kind:k(r.exportedNode)?`function`:`initializer`}:null},$a=(e,t)=>{if(!x(e,`ArrowFunctionExpression`)&&!x(e,`FunctionExpression`)&&!x(e,`FunctionDeclaration`))return null;let n=e.params[0],r=x(n,`AssignmentPattern`)?n.left:n;if(x(r,`ObjectPattern`)){let e=r.properties.find(e=>x(e,`Property`)&&C(e,{allowComputedString:!0})===`children`);if(!e||!x(e,`Property`))return null;let n=x(e.value,`AssignmentPattern`)?e.value.left:e.value;if(!x(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(!x(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=P(e.identifier);for(;n.parent&&x(n.parent,`MemberExpression`)&&n.parent.object===n;){let e=w(n.parent);if(!e)return null;t.push(e),n=P(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},eo=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},to=new WeakMap,no=e=>{let t=Lt(e);if(!t)return null;let n=to.get(t);return n||(n=eo(t),to.set(t,n)),n},ro=(e,t)=>{let n=no(e);if(!n)return!1;for(let e of n.values())if(t.includes(e.source))return!0;return!1},io=(e,t,n)=>{let r=no(e);if(!r)return!1;let i=r.get(t);return i?i.source===n:!1},ao=(e,t,n)=>{let r=no(e);if(!r)return!1;let i=r.get(t);return i?i.isNamespace&&i.source===n:!1},oo=(e,t,n)=>{let r=no(e);if(!r)return!1;let i=r.get(t);return i?i.isDefault&&i.source===n:!1},so=(e,t,n)=>{let r=no(e);if(!r)return null;let i=r.get(t);return!i||i.source!==n?null:i.imported},co=(e,t)=>{let n=no(e);return n?n.get(t)?.source??null:null},lo=(e,t)=>{let n=no(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},uo=(e,t)=>{let n=e.parent;for(;n;){if(`typeParameters`in n){let e=n.typeParameters;if(e&&x(e,`TSTypeParameterDeclaration`)&&e.params.some(e=>x(e,`TSTypeParameter`)&&x(e.name,`Identifier`)&&e.name.name===t))return!0}n=n.parent}return!1},fo=e=>{if(!x(e,`Identifier`)||uo(e,e.name))return!1;let t=lo(e,e.name);return!!(t&&t.source===`react`&&(t.isNamespace||t.exportedName===`default`))},po=e=>{let t=Lt(e);return!t||!x(t,`Program`)?!1:t.body.some(e=>x(e,`TSModuleDeclaration`)&&x(e.id,`Identifier`)&&e.id.name===`JSX`)},mo=(e,t)=>{if(!x(e,`TSTypeReference`))return!1;let n=e.typeName;if(x(n,`Identifier`)){if(uo(n,n.name))return!1;let e=so(n,n.name,`react`);return e===`ReactElement`||t&&e===`ReactNode`}if(!x(n,`TSQualifiedName`)||!x(n.right,`Identifier`))return!1;if((n.right.name===`ReactElement`||t&&n.right.name===`ReactNode`)&&fo(n.left))return!0;if(n.right.name!==`Element`)return!1;if(x(n.left,`Identifier`)){if(n.left.name!==`JSX`)return!1;let e=lo(n.left,n.left.name);return e?e.source===`react`&&e.exportedName===`JSX`:!po(n.left)}return x(n.left,`TSQualifiedName`)&&x(n.left.right,`Identifier`)&&n.left.right.name===`JSX`&&fo(n.left.left)},ho=(e,t)=>x(e,`TSUnionType`)?t?e.types.every(e=>x(e,`TSNullKeyword`)||x(e,`TSUndefinedKeyword`)||ho(e,t)):e.types.some(e=>ho(e,t)):mo(e,t),go=(e,t=!1)=>{let n=Reflect.get(e,`returnType`);return x(n,`TSTypeAnnotation`)?ho(n.typeAnnotation,t):!1},_o=e=>{let t=e,n=t.parent;for(;n&&T(n)===e;)t=n,n=t.parent;return n&&x(n,`AssignmentExpression`)&&n.operator===`=`&&n.left===t?n.right:null},vo=e=>{let t=e.range?.[0];return typeof t==`number`?t:null},yo=new Set([`let`,`var`]),bo=new Set([`ConditionalExpression`,`LogicalExpression`]),xo=new WeakMap,So=(e,t,n)=>{let r=e.parent??null;for(;r&&n.blockOf(r)===t;){if(bo.has(r.type))return!0;r=r.parent??null}return!1},Co=(e,t)=>e.size===t.size&&[...e].every(e=>t.has(e)),wo=(e,t)=>{let n=new Set(e);for(let e of t)e.isConditionalWithinBlock||(n=new Set),n.add(e);return n},To=(e,t,n)=>{let r=j(t);if(j(e.bindingIdentifier)!==r||!r)return[];let i=n.cfgFor(r);if(!i)return[];let a=i.blockOf(t);if(!a)return[];let o=vo(t),s=vo(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:So(t,r,i)}),c.set(r,a)};e.initializer&&l(e.initializer,e.bindingIdentifier,s);for(let t of e.references){let e=vo(t.identifier);if(t.flag===`read`||j(t.identifier)!==r||e===null||e>=o)continue;let n=_o(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=wo(t,c.get(e)??[]),r=u.get(e)??new Set,i=d.get(e)??new Set;(!Co(t,r)||!Co(n,i))&&(u.set(e,t),d.set(e,n),m=!0)}}let h=(c.get(a)??[]).filter(e=>e.position<o);return[...wo(u.get(a)??new Set,h)].map(e=>e.expression)},Eo=(e,t,n)=>{if(!yo.has(e.kind))return e.initializer?[e.initializer]:[];if(!n)return[];let r=xo.get(n);r||(r=new WeakMap,xo.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=To(e,t,n);return i.set(t,o),o},Do=e=>{if(!k(e)||!x(e.body,`BlockStatement`))return[];let t=[];return z(e.body,n=>{if(n!==e.body&&(k(n)||x(n,`ClassDeclaration`)||x(n,`ClassExpression`)))return!1;x(n,`ReturnStatement`)&&t.push(n)}),t},B=e=>{if(x(e,`ReturnStatement`)||x(e,`ThrowStatement`))return!0;if(x(e,`IfStatement`)){if(x(e.test,`Literal`)){let t=e.test.value?e.consequent:e.alternate;return t?B(t):!1}return!!(e.alternate&&B(e.consequent)&&B(e.alternate))}if(x(e,`TryStatement`))return e.finalizer&&B(e.finalizer)?!0:B(e.block)?e.handler?B(e.handler.body):!0:!1;if(x(e,`DoWhileStatement`))return B(e.body);if(x(e,`WhileStatement`)){let t=e.test;return!!(x(t,`Literal`)&&t.value&&B(e.body))}if(x(e,`ForStatement`)){let t=e.test;return!!((!t||x(t,`Literal`)&&t.value)&&B(e.body))}return x(e,`BlockStatement`)?e.body.some(e=>B(e)):!1},Oo=new Set([`let`,`var`]),ko=e=>!k(e)||!e.body?[]:x(e.body,`BlockStatement`)?Do(e).flatMap(e=>e.argument?[e.argument]:[]):[e.body],Ao=e=>{if(!k(e)||!x(e.body,`BlockStatement`))return!1;let t=!1;return z(e.body,n=>{if(t||n!==e.body&&k(n))return!1;x(n,`ReturnStatement`)&&!n.argument&&(t=!0)}),t},jo=(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=ko(e);return r===`every`&&k(e)&&x(e.body,`BlockStatement`)&&(!B(e.body)||Ao(e))?!1:t.length>0&&(r===`every`?t.every(o):t.some(o))}finally{a.delete(e)}};o=a=>{let l=T(a);if(i.has(l))return!1;i.add(l);try{if(t(l))return!0;if(x(l,`Identifier`)){let t=e.symbolFor(l);if(!t||t.kind!==`const`&&!Oo.has(t.kind))return!1;let i=Eo(t,l,n),a=e=>{let t=T(e);return!k(t)&&o(t)};return r===`every`?i.length>0&&i.every(a):i.some(a)}if(x(l,`CallExpression`)){if(l.arguments.length!==0||!x(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?T(t.initializer):null,r=null;return k(n)?r=n:k(t.declarationNode)&&(r=t.declarationNode),!r||r.async||r.generator||r.params.length!==0?!1:s(r)}return x(l,`ConditionalExpression`)?c(l.consequent,l.alternate):x(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}},Mo=(e,t,n,r,i=`some`)=>jo(t,n,r,i).functionMatches(e),No=(e,t,n,r,i)=>{let a=i.cfgFor(e),o=a?.blockOf(t);if(!a||!o)return!1;let s=new Set(Do(e).flatMap(e=>{if(!e.argument||!jo(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},Po=e=>x(e,`Program`)?e.range[1]:e.range[0],Fo=new WeakMap,Io=(e,t)=>{let n=T(e);return x(n,`Identifier`)?t.symbolFor(n):null},Lo=(e,t)=>{let n=P(e),r=n.parent;return!r||!x(r,`AssignmentExpression`)||r.operator!==`=`||r.left!==n?null:Io(r.right,t)},Ro=e=>{let t=P(e),n=t.parent;return n&&x(n,`VariableDeclarator`)&&n.init===t&&(x(n.id,`Identifier`)||x(n.id,`ObjectPattern`))?!0:!!(n&&x(n,`AssignmentExpression`)&&n.operator===`=`&&n.right===t&&x(T(n.left),`Identifier`))},zo=(e,t,n)=>{if(e.initializer&&x(e.declarationNode,`VariableDeclarator`)&&e.declarationNode.id===e.bindingIdentifier){let r=Io(e.initializer,n);if(r&&t.has(r.id))return!0}return e.references.some(e=>{let r=Lo(e.identifier,n);return!!(r&&t.has(r.id))})},Bo=(e,t)=>{let n=F(e,t);if(!n)return[];let r=Fo.get(t);r||(r=new Map,Fo.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)||zo(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},Vo=e=>{let t=e;for(;t;){if(k(t)||x(t,`Program`))return t;t=t.parent??null}return null},Ho=new WeakMap,Uo=(e,t)=>{let n=Ho.get(t);if(!n){let r=new Map,i=new Map,a=Lt(e);a&&z(a,e=>{if(!x(e,`CallExpression`))return;let n=T(e.callee),a=x(n,`Identifier`)?t.symbolFor(n):null,o=a?i.get(a.id):void 0;o===void 0&&(o=an(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,Ho.set(t,n)}return n.get(e)??[]},Wo=new WeakMap,Go=(e,t)=>{let n=Wo.get(t);if(n===void 0){let e=null;z(t,n=>{x(n,`AwaitExpression`)&&j(n)===t&&(e===null||n.range[0]<e)&&(e=n.range[0])}),n=e,Wo.set(t,n)}return n===null||e.range[0]<n},Ko=(e,t,n,r=new Set,i=null,a)=>{if(r.has(e)||!k(e)||e.generator||i!==null&&!Gt(i,e)||i!==null&&a!==void 0&&!a(i)||i!==null&&e.async&&!Go(i,e))return[];r.add(e);let o=Vo(t);return o?Uo(e,n).flatMap(e=>{let s=Vo(e);return!s||i!==null&&!Gt(e,s)||i!==null&&a!==void 0&&!a(e)?[]:s===o?e.range[0]<Po(t)?[[e.range[0]]]:[]:k(s)?Ko(s,t,n,new Set(r),i===null?null:e,a).map(t=>[...t,e.range[0]]):[]}):[]},qo=(e,t,n,r=new Set,i=null)=>Ko(e,t,n,r,i).length>0,Jo=e=>{let t=e.parent;return t?x(t,`AssignmentExpression`)?t.left===e:(x(t,`UpdateExpression`)||x(t,`UnaryExpression`)&&t.operator===`delete`)&&t.argument===e:!1},Yo=e=>{let t=e.parent;for(;t&&T(t)===e;)t=t.parent;return!t||!x(t,`MemberExpression`)||T(t.object)!==e||!Jo(t)?null:t},Xo=(e,t,n)=>{let r=Yo(e);return r&&I(r,n)===t?r:null},Zo=(e,t,n,r)=>e.references.some(e=>{let i=Xo(e.identifier,t,r);if(!i)return!1;let a=Vo(i),o=Vo(n);return!a||!o||!Gt(i,a)?!1:a===o?i.range[0]<Po(n):k(a)&&qo(a,n,r)}),Qo=e=>{if(Ro(e))return!0;let t=P(e),n=t.parent;return!!(n&&x(n,`MemberExpression`)&&T(n.object)===t)},$o=e=>{if(Ro(e))return!0;let t=P(e),n=t.parent;if(!n||!x(n,`MemberExpression`)||T(n.object)!==t)return!1;let r=P(n),i=r.parent;return!(i&&x(i,`CallExpression`)&&i.callee===r)},es=(e,t,n)=>x(e,`Identifier`)?Bo(e,n).some(e=>e.references.some(e=>{let r=Yo(e.identifier);if(!r)return!1;let i=I(r,n);return i===null||i===t})):!1,ts=(e,t,n)=>{let r=Vo(e),i=Vo(t);return!r||!i?!0:r===i?e.range[0]<Po(t):k(r)?qo(r,t,n):!0},ns=(e,t,n,r)=>x(e,`Identifier`)?Bo(e,r).some(e=>e.references.some(e=>{let i=Yo(e.identifier);if(!i||!ts(i,n,r))return!1;let a=I(i,r);return a===null||a===t})):!1,rs=(e,t,n)=>x(e,`Identifier`)?es(e,t,n)?!0:Bo(e,n).some(e=>e.references.some(e=>!Qo(e.identifier))):!1,is=(e,t,n,r)=>x(e,`Identifier`)?ns(e,t,n,r)?!0:Bo(e,r).some(e=>e.references.some(e=>!$o(e.identifier)&&ts(e.identifier,n,r))):!1,as=(e,t)=>{let n=T(e);if(!x(n,`CallExpression`))return!1;let r=T(n.callee);if(!x(r,`MemberExpression`))return!1;let i=w(r);if(i===null)return!1;let a=T(r.object);return x(a,`Identifier`)&&es(a,i,t)},os=(e,t,n,r)=>x(e,`Identifier`)?Vt(e,r).some(e=>Zo(e,t,n,r)):!1,ss=(e,t,n,r={})=>{let i=j(e);return i===j(t)?e.range[0]>=Po(t)||r.requireSynchronousWrite&&(!i||!Gt(e,i)||r.isSynchronousNode!==void 0&&!r.isSynchronousNode(e))?[]:[[e.range[0]]]:i?r.requireSynchronousWrite?Ko(i,t,n,new Set,e,r.isSynchronousNode).map(t=>[...t,e.range[0]]):Ko(i,t,n).map(t=>[...t,e.range[0]]):r.requireSynchronousWrite?[]:[[-1/0,e.range[0]]]},cs=(e,t,n,r={})=>ss(e,t,n,r).length>0,V=(e,t,n,r={})=>e.references.some(e=>e.flag===`read`?!1:cs(e.identifier,t,n,r)),ls=(e,t)=>{if(!x(e,`CallExpression`))return!1;let n=T(e.callee);if(x(n,`Identifier`)){let e=t.symbolFor(n);return!!(e&&!V(e,n,t))}if(!x(n,`MemberExpression`))return!1;let r=w(n),i=T(n.object);return!!(r&&x(i,`Identifier`)&&!os(i,r,n,t))},us=new Set([`FunctionDeclaration`,`FunctionExpression`,`ArrowFunctionExpression`,`ClassDeclaration`,`ClassExpression`]),ds={allowGlobalReactNamespace:!1,allowUnboundBareCalls:!1},fs=new Set([`lodash/sortBy`,`lodash/sortBy.js`,`lodash-es/sortBy`,`lodash-es/sortBy.js`]),ps=e=>x(e,`TSArrayType`)||x(e,`TSTupleType`)?!0:x(e,`TSTypeReference`)?x(e.typeName,`Identifier`)&&(e.typeName.name===`Array`||e.typeName.name===`ReadonlyArray`):!1,ms=e=>{if(!x(e,`Identifier`))return!1;let t=e.typeAnnotation;return!!(t&&x(t,`TSTypeAnnotation`)&&ps(t.typeAnnotation))},hs=(e,t)=>{if(!x(e,`CallExpression`))return!1;let n=T(e.callee);if(!x(n,`Identifier`))return!1;let r=t.symbolFor(n);if(!r||V(r,n,t)||!x(r.declarationNode,`ImportDefaultSpecifier`)&&!x(r.declarationNode,`ImportSpecifier`))return!1;let i=lo(n,n.name);return!i||i.isNamespace?!1:fs.has(i.source)&&i.exportedName===`default`?!0:(i.source===`lodash`||i.source===`lodash-es`)&&i.exportedName===`sortBy`},gs=(e,t,n,r=new Set)=>{let i=T(e);if(x(i,`ArrayExpression`)||hs(i,t))return!0;if(!x(i,`Identifier`))return!1;let a=t.symbolFor(i);return!a||r.has(a.id)||V(a,n,t)?!1:ms(a.bindingIdentifier)?!0:a.initializer?(r.add(a.id),gs(a.initializer,t,n,r)):!1},_s=(e,t)=>{if(!x(e,`CallExpression`))return!1;let n=T(e.callee);if(!x(n,`MemberExpression`)||w(n)!==`map`)return!1;let r=T(n.object);return gs(r,t,e)?!(x(r,`Identifier`)&&os(r,`map`,e,t)):!1},vs=(e,t)=>{if(e.type!==`ArrowFunctionExpression`&&e.type!==`FunctionExpression`)return!1;let n=e.parent;if(x(n,`CallExpression`))return Ka(n,`useMemo`,t,{resolveNamedAliases:!0})&&ls(n,t)?n.arguments[0]===e:n.arguments.some(t=>t===e)&&_s(n,t);if(x(n,`Property`)&&n.kind===`init`&&n.value===e){let e=n.parent;if(!x(e,`ObjectExpression`))return!1;let r=e.parent;if(!x(r,`CallExpression`)||!r.arguments.some(t=>t===e)||!ls(r,t))return!1;let i=rn(r.callee,t);return!!(i&&go(i,!0))}return!1},ys=(e,t)=>us.has(e.type)&&!vs(e,t),bs=(e,t)=>e.type===`JSXElement`||e.type===`JSXFragment`||Ka(e,`createElement`,t,ds)||xs(e,t),xs=(e,t)=>{if(!x(e,`CallExpression`))return!1;let n=T(e.callee);if(x(n,`Identifier`))return t.symbolFor(n)?.kind===`import`&&so(n,n.name,`react-dom`)===`createPortal`;if(!x(n,`MemberExpression`)||n.computed||!x(n.object,`Identifier`)||!x(n.property,`Identifier`)||n.property.name!==`createPortal`)return!1;let r=t.symbolFor(n.object);return!r||r.kind!==`import`?!1:oo(n.object,n.object.name,`react-dom`)||ao(n.object,n.object.name,`react-dom`)},Ss=(e,t)=>{if(ys(e,t))return!1;let n=!1;return z(e,r=>{if(n||r!==e&&ys(r,t))return!1;if(bs(r,t))return n=!0,!1}),n},Cs=new WeakMap,ws=(e,t,n)=>{let r=Cs.get(e);if(r&&r.scopes===t&&r.controlFlow===n)return r.hasRenderOutput;let i=Mo(e,t,e=>Ss(e,t),n);return Cs.set(e,{scopes:t,controlFlow:n,hasRenderOutput:i}),i},Ts=e=>x(e,`JSXIdentifier`)?e.name:x(e,`JSXNamespacedName`)?`${e.namespace.name}:${e.name.name}`:null,Es=new Set([`Component`,`PureComponent`]),Ds=(e,t,n,r)=>{let i=T(e);if(x(i,`MemberExpression`)){let e=w(i),n=T(i.object);return!!(e&&Es.has(e)&&x(n,`Identifier`)&&!os(n,e,i,t)&&Ua(n,t))}if(x(i,`ClassExpression`))return Os(i,t,n,r);if(!x(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),Va(a)){let e=S(a.declarationNode);return!!(e&&Es.has(e))}return x(a.declarationNode,`ClassDeclaration`)||x(a.declarationNode,`ClassExpression`)?Os(a.declarationNode,t,n,r):!!(a.kind===`const`&&a.initializer&&Ds(a.initializer,t,n,r))},Os=(e,t,n=new Set,r=new Set)=>!x(e,`ClassDeclaration`)&&!x(e,`ClassExpression`)||n.has(e)||!e.superClass?!1:(n.add(e),Ds(e.superClass,t,n,r)),ks=new Set([`FunctionDeclaration`,`FunctionExpression`,`ArrowFunctionExpression`,`MethodDefinition`,`Program`]),As=e=>{let t=e;for(;t;){if(ks.has(t.type))return t;t=t.parent??null}return null},js=(e,t)=>{if(t!==`let`&&t!==`const`)return As(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`)?As(e):n}if(ks.has(n.type))return n;n=n.parent??null}return null},Ms=(e,t,n,r)=>{if(x(e,`Identifier`)){let i=r.get(e.name)??[];i.push({bindingIdentifier:e,initializer:t,scopeOwner:n}),r.set(e.name,i);return}if(x(e,`ObjectPattern`)){for(let t of e.properties)if(x(t,`Property`)){let e=t.value;Ms(e,x(e,`AssignmentPattern`)?e.right:null,n,r)}else x(t,`RestElement`)&&Ms(t.argument,null,n,r);return}if(x(e,`ArrayPattern`)){for(let t of e.elements)t&&Ms(t,x(t,`AssignmentPattern`)?t.right??null:null,n,r);return}if(x(e,`AssignmentPattern`)){Ms(e.left,e.right??null,n,r);return}x(e,`RestElement`)&&Ms(e.argument,null,n,r)},Ns=e=>{let t=new Map;return z(e,e=>{switch(e.type){case`VariableDeclarator`:{let n=e.parent,r=js(e,n?.type===`VariableDeclaration`?n.kind:void 0);r&&Ms(e.id,e.init??null,r,t);break}case`FunctionDeclaration`:case`FunctionExpression`:case`ArrowFunctionExpression`:if(e.type!==`ArrowFunctionExpression`&&e.id){let n=e.parent?As(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)Ms(n,null,e,t);break;case`ClassDeclaration`:case`ClassExpression`:{if(!e.id)break;let n=e.parent?As(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=As(e);if(!n)break;for(let r of e.specifiers){let e=r.local;if(e&&x(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=As(e);if(r){let e=t.get(n.name)??[];e.push({bindingIdentifier:n,initializer:null,scopeOwner:r}),t.set(n.name,e)}}break}}}),t},Ps=new WeakMap,Fs=new WeakMap,Is=e=>{let t=Lt(e);if(!t)return null;let n=Ps.get(t);return n||(n=Ns(t),Ps.set(t,n)),n},Ls=(e,t,n)=>{let r=Is(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&&(x(r.initializer,`FunctionDeclaration`)||r.bindingIdentifier.range[0]<e.range[0]));if(n!==!!(t.initializer&&(x(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},Rs=(e,t,n)=>{let r=Fs.get(e),i;if(!r)i={},Fs.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=Ls(e,t,n);return i[a]=o,o},zs=e=>ma.test(e),Bs=e=>{let t=Rs(e,e.name);if(!t?.initializer)return null;let n=t.bindingIdentifier.parent;if(!n||!x(n,`VariableDeclarator`)||n.id!==t.bindingIdentifier)return null;let r=n.parent;if(!r||!x(r,`VariableDeclaration`)||r.kind!==`const`)return null;let i=T(t.initializer);return x(i,`Literal`)&&typeof i.value==`string`?i.value:null},Vs=e=>x(e,`JSXIdentifier`)?e.name:x(e,`JSXMemberExpression`)?`${Vs(e.object)}.${e.property.name}`:x(e,`JSXNamespacedName`)?`${e.namespace.name}:${e.name.name}`:``,Hs=e=>{let t=e.name;return x(t,`JSXIdentifier`)?zs(t.name)?Bs(t)??t.name:t.name:Vs(t)},Us=(e,t)=>{if(!x(e.name,`JSXIdentifier`))return!1;let n=Hs(e);if(n[0]===n[0]?.toLowerCase())return!0;let r=new Set,i=e=>{let n=P(e);if(x(n,`Literal`))return typeof n.value==`string`;if(x(n,`Identifier`)||x(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 x(n,`ConditionalExpression`)?i(n.consequent)&&i(n.alternate):!1};return i(e.name)},Ws=(e,t,n=new Set)=>{if(!e)return null;let r=T(e);if(k(r))return r;if(x(r,`Identifier`)){let e=t.symbolFor(r);return!e||n.has(e.id)||!e.initializer||V(e,r,t)?null:(n.add(e.id),Ws(e.initializer,t,n))}if(!x(r,`CallExpression`)||!Ka(r,`memo`,t,{resolveNamedAliases:!0})&&!Ka(r,`forwardRef`,t,{resolveNamedAliases:!0}))return null;let i=r.arguments[0];return!i||x(i,`SpreadElement`)?null:Ws(i,t,n)},Gs=(e,t)=>{let n=P(e);if(!k(n)||n.async||n.generator)return!1;let r=n.parent;if(!r||!x(r,`JSXExpressionContainer`))return!1;let i=r.parent;if(!i||!x(i,`JSXAttribute`)||Ts(i.name)!==`ref`)return!1;let a=i.parent;return!!(a&&x(a,`JSXOpeningElement`)&&Us(a,t))},Ks=(e,t)=>t.every((t,n)=>e[n]===t),qs=e=>{let t=P(e);for(;t.parent&&x(t.parent,`MemberExpression`)&&t.parent.object===t;){if(!w(t.parent))return null;t=P(t.parent)}return t},Js=(e,t,n,r)=>{if(t.length!==n.length+1||!Ks(t,n)||t[n.length]!==`current`)return!1;let i=qs(e),a=i?.parent;if(!i||!a||!x(a,`AssignmentExpression`)||a.operator!==`=`||a.left!==i)return!1;let o=j(e);if(!o)return!1;if(Gs(o,r))return!0;if(!k(o)||o.async||o.generator)return!1;let s=j(o);if(!s||!Gs(s,r))return!1;let c=P(o),l=c.parent;return!!(x(l,`ReturnStatement`)&&l.argument===c&&j(l)===s||x(s,`ArrowFunctionExpression`)&&s.body===c)},Ys=(e,t)=>{if(!x(e,`JSXOpeningElement`))return!1;let n=e.name;if(x(n,`JSXIdentifier`)){if(!t)return n.name===`Fragment`;let e=F(n,t);return e?Va(e)&&S(e.declarationNode)===`Fragment`:n.name===`Fragment`&&t.isGlobalReference(n)}return x(n,`JSXMemberExpression`)?!x(n.object,`JSXIdentifier`)||n.property.name!==`Fragment`?!1:t?Ua(n.object,t)?!0:n.object.name===`React`&&t.isGlobalReference(n.object):n.object.name===`React`:!1},Xs=(e,t,n,r,i)=>{let a=P(e),o=a.parent;if(!o)return!1;if(x(o,`ReturnStatement`)&&o.argument===a)return j(o)===t;if(x(o,`ArrowFunctionExpression`)&&o.body===a)return o===t;if(x(o,`JSXFragment`)&&o.children.some(e=>e===a)||x(o,`JSXElement`)&&o.children.some(e=>e===a)&&(Us(o.openingElement,n)||Ys(o.openingElement,n)||i.doesCustomElementRenderChildren?.(o.openingElement)))return Xs(o,t,n,r,i);if(x(o,`JSXExpressionContainer`)&&o.expression===a&&o.parent&&(x(o.parent,`JSXFragment`)||x(o.parent,`JSXElement`)&&(Us(o.parent.openingElement,n)||Ys(o.parent.openingElement,n)||i.doesCustomElementRenderChildren?.(o.parent.openingElement))))return Xs(o.parent,t,n,r,i);if(x(o,`ConditionalExpression`)&&(o.consequent===a||o.alternate===a)||x(o,`LogicalExpression`)&&(o.left===a||o.right===a)||x(o,`ArrayExpression`)&&o.elements.some(e=>e===a))return Xs(o,t,n,r,i);if(!x(o,`VariableDeclarator`)||o.init!==a||!x(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`&&Xs(e.identifier,t,n,r,i));return r.delete(s.id),c},Zs=(e,t,n={})=>Xs(e,j(e),t,new Set,n),Qs=(e,t)=>t.every((t,n)=>e[n]===t),$s=(e,t)=>Qs(e,t)||Qs(t,e),ec=e=>k(e)&&x(e.body,`BlockStatement`)&&e.body.body.length===0,tc=(e,t,n)=>Ka(e,t,n,{resolveNamedAliases:!0}),nc=(e,t,n=new Set)=>x(e,`ObjectExpression`)?e.properties.every(e=>{if(x(e,`SpreadElement`)){let r=P(e.argument);if(x(r,`ObjectExpression`))return nc(r,t,n);if(!x(r,`Identifier`))return!1;let i=t.symbolFor(r);if(!i||i.kind!==`const`||n.has(i.id)||!x(i.initializer,`ObjectExpression`))return!1;n.add(i.id);let a=nc(i.initializer,t,n);return n.delete(i.id),a}return x(e,`Property`)?!k(e.value)||ec(e.value):!1}):!1,rc=e=>w(e)||(e.computed&&x(e.property,`Literal`)&&typeof e.property.value==`number`&&Number.isSafeInteger(e.property.value)&&e.property.value>=0?String(e.property.value):null),ic=e=>{let t=[],n=P(e);for(;n.parent&&x(n.parent,`MemberExpression`)&&n.parent.object===n;){let e=rc(n.parent);if(!e)return null;t.push(e),n=P(n.parent)}return{expression:n,propertyPath:t}},ac=(e,t,n)=>{let r=n.environmentsByProgram.get(e);if(r)return r;let i={filename:t,program:e,scopes:_t(e)};return n.environmentsByProgram.set(e,i),i},oc=(e,t,n=new Set)=>{let r=P(e);if(x(r,`Identifier`)){let e=t.symbolFor(r);return!e||!e.initializer||n.has(e.id)||V(e,r,t)?!1:(n.add(e.id),oc(e.initializer,t,n))}if(!x(r,`CallExpression`))return!1;if(tc(r,`forwardRef`,t))return!0;if(!tc(r,`memo`,t))return!1;let i=r.arguments[0];return!i||x(i,`SpreadElement`)?!1:oc(i,t,n)},sc=(e,t)=>{let n=ac(e.programNode,e.filePath,t),r=Ws(e.exportedNode,n.scopes);return r?{environment:n,functionNode:r,isForwardRef:oc(e.exportedNode,n.scopes)}:null},cc=(e,t,n)=>{if(!x(e,`Identifier`)&&!x(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=Ws(r.initializer,t.scopes);return n?{environment:t,functionNode:n,isForwardRef:!!(r.initializer&&oc(r.initializer,t.scopes))}:null}let i=lo(e,e.name);if(!i||i.isNamespace||i.exportedName===null)return null;let a=R(t.filename,i.source,i.exportedName);return a?sc(a,n):null},lc=(e,t,n)=>{if(x(e,`JSXIdentifier`))return cc(e,t,n);if(!x(e,`JSXMemberExpression`)||!x(e.object,`JSXIdentifier`))return null;let r=lo(e.object,e.object.name);if(!r?.isNamespace)return null;let i=R(t.filename,r.source,e.property.name);return i?sc(i,n):null},uc=(e,t,n=new Set)=>{let r=P(e);if(x(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),uc(e.initializer,t,n))}return Os(r,t.scopes)},dc=(e,t,n)=>{if(!x(e,`JSXIdentifier`))return!1;let r=t.scopes.symbolFor(e);if(r&&r.kind!==`import`)return V(r,e,t.scopes)?!1:!!(r.initializer&&uc(r.initializer,t));let i=lo(e,e.name);if(!i||i.isNamespace||i.exportedName===null)return!1;let a=R(t.filename,i.source,i.exportedName);if(!a)return!1;let o=ac(a.programNode,a.filePath,n);return uc(a.exportedNode,o)},fc=(e,t)=>{if(!e)return null;let n=P(e);return!x(n,`ClassDeclaration`)&&!x(n,`ClassExpression`)||!uc(n,t)?null:{classNode:n,environment:t}},pc=(e,t,n)=>{if(!x(e,`JSXIdentifier`))return null;let r=t.scopes.symbolFor(e);if(r&&r.kind!==`import`)return V(r,e,t.scopes)?null:fc(r.initializer,t);let i=lo(e,e.name);if(!i||i.isNamespace||i.exportedName===null)return null;let a=R(t.filename,i.source,i.exportedName);if(!a)return null;let o=ac(a.programNode,a.filePath,n);return fc(a.exportedNode,o)},mc=(e,t,n)=>{let r=[...t],i=P(e);for(;i.parent;){let e=i.parent;if(x(e,`ArrayExpression`)){if(e.elements.some(e=>e&&x(e,`SpreadElement`)))return null;let t=e.elements.findIndex(e=>e===i);if(t<0)return null;r.unshift(String(t)),i=P(e);continue}if(x(e,`Property`)&&e.value===i){let t=C(e,{allowComputedString:!0}),a=e.parent;if(!t||!a||!nc(a,n.scopes))return null;r.unshift(t),i=P(a);continue}if(x(e,`ConditionalExpression`)&&(e.consequent===i||e.alternate===i)||x(e,`LogicalExpression`)&&(e.left===i||e.right===i)){i=P(e);continue}if(x(e,`VariableDeclarator`)&&e.init===i&&x(e.id,`Identifier`)){let t=n.scopes.symbolFor(e.id);return!t||t.kind!==`const`?null:{environment:n,propertyPath:r,symbol:t}}if(x(e,`AssignmentExpression`)&&e.operator===`=`&&e.right===i&&x(e.left,`MemberExpression`)){let t=[],i=e.left;for(;x(i,`MemberExpression`);){let e=rc(i);if(!e)return null;t.unshift(e),i=P(i.object)}if(!x(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},hc=(e,t,n,r,i)=>{if(x(e,`AssignmentPattern`))return hc(e.left,t,n,r,i);if(x(e,`Identifier`)){let a=n.scopes.symbolFor(e);return!!(a&&jc({environment:n,propertyPath:t,symbol:a},r,i-1))}if(!x(e,`ObjectPattern`)||t.length===0)return!1;let[a,...o]=t;for(let t of e.properties){if(!x(t,`Property`))continue;let e=C(t,{allowComputedString:!0});if(!e)return!1;if(e===a)return hc(t.value,o,n,r,i)}let s=e.properties.find(e=>x(e,`RestElement`));return s?hc(s.argument,t,n,r,i):!0},gc=(e,t)=>{let n=e.arguments[0];return!n||x(n,`SpreadElement`)?!1:tc(e,`createElement`,t.scopes)?x(n,`Literal`)&&typeof n.value==`string`:!tc(e,`cloneElement`,t.scopes)||!x(n,`JSXElement`)?!1:Us(n.openingElement,t.scopes)},_c=(e,t,n,r,i)=>{if(t.length>0)return!1;let a=e.parent;if(!a||!x(a,`Property`)||a.value!==e||C(a,{allowComputedString:!0})!==`ref`)return!1;let o=a.parent;if(!o||!x(o,`ObjectExpression`))return!1;let s=o.parent;return!(!s||!x(s,`CallExpression`)||s.arguments[1]!==o||!gc(s,n)||!xc(s,n,r,i))},vc=(e,t,n,r,i)=>{if(i<=0||!k(e.functionNode)||e.functionNode.async||e.functionNode.generator)return!1;let a=e.functionNode.params[t];return!!(a&&hc(a,n,e.environment,r,i))},yc=e=>{if(!x(e,`MemberExpression`)||w(e)!==`children`)return!1;let t=P(e.object);return!!(x(t,`MemberExpression`)&&w(t)===`props`&&x(P(t.object),`ThisExpression`))},bc=(e,t)=>{if(!x(e,`JSXOpeningElement`)||!x(e.name,`JSXMemberExpression`)||e.name.property.name!==`Provider`||!x(e.name.object,`JSXIdentifier`))return!1;let n=t.scopes.symbolFor(e.name.object);return!!(n?.kind===`const`&&n.initializer&&x(n.initializer,`CallExpression`)&&tc(n.initializer,`createContext`,t.scopes))},xc=(e,t,n,r)=>Zs(e,t.scopes,{doesCustomElementRenderChildren:e=>wc(e,t,n,r-1)}),Sc=(e,t,n)=>{let{functionNode:r}=e;if(n<=0||t.activeRenderedChildrenComponents.has(r)||!x(r,`ArrowFunctionExpression`)&&!x(r,`FunctionExpression`)&&!x(r,`FunctionDeclaration`)||r.async||r.generator)return!1;let i=$a(r,e.environment.scopes);if(!i)return!1;t.activeRenderedChildrenComponents.add(r);let a=i.every(r=>xc(r,e.environment,t,n));return t.activeRenderedChildrenComponents.delete(r),a},Cc=(e,t,n)=>{let{classNode:r,environment:i}=e;if(n<=0||t.activeRenderedChildrenComponents.has(r)||!x(r,`ClassDeclaration`)&&!x(r,`ClassExpression`))return!1;let a=r.body.body.find(e=>x(e,`MethodDefinition`)&&!e.computed&&x(e.key,`Identifier`)&&e.key.name===`render`);if(!a||!x(a,`MethodDefinition`))return!1;let o=[];if(z(r,e=>{yc(e)&&o.push(e)}),o.length===0)return!1;t.activeRenderedChildrenComponents.add(r);let s=o.every(e=>j(e)===a.value&&xc(e,i,t,n));return t.activeRenderedChildrenComponents.delete(r),s},wc=(e,t,n,r)=>{if(r<=0||!x(e,`JSXOpeningElement`))return!1;if(bc(e,t))return!0;let i=lc(e.name,t,n);if(i)return Sc(i,n,r);let a=pc(e.name,t,n);return!!(a&&Cc(a,n,r))},Tc=(e,t,n,r,i)=>{let a=Ts(e.name),o=e.parent;if(!a||!o||!x(o,`JSXOpeningElement`))return!1;let s=o.parent;if(!s||!x(s,`JSXElement`)||!xc(s,n,r,i))return!1;if(Us(o,n.scopes))return a===`ref`&&t.length===0;if(x(o.name,`JSXIdentifier`)&&a===`ref`&&t.length===0&&dc(o.name,n,r))return!0;let c=lc(o.name,n,r);return c?a===`ref`&&c.isForwardRef?vc(c,1,t,r,i):vc(c,0,[a,...t],r,i):!1},Ec=(e,t,n,r,i,a)=>{let o=e.arguments.findIndex(e=>e===t);if(o<0)return!1;if(o===0&&x(e.callee,`Identifier`)&&e.callee.name===`Boolean`&&r.scopes.isGlobalReference(e.callee))return!0;if(o===0&&tc(e,`useImperativeHandle`,r.scopes))return n.length===0;if(o===1&&n.length===1&&n[0]===`ref`&&gc(e,r)&&xc(e,r,i,a))return!0;let s=P(e.callee);if(k(s))return ws(s,r.scopes)&&!xc(e,r,i,a)?!1:vc({environment:r,functionNode:s,isForwardRef:!1},o,n,i,a);if(!x(e.callee,`Identifier`))return!1;let c=cc(e.callee,r,i);return!!(c&&(!ws(c.functionNode,c.environment.scopes)||xc(e,r,i,a))&&vc(c,o,n,i,a))},Dc=(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||!x(t,`Property`)||t.value!==e||C(t,{allowComputedString:!0})!==`ref`)return!1;a=t.parent?.parent}if(!a||!x(a,`JSXSpreadAttribute`))return!1;let o=a.parent;if(!o||!x(o,`JSXOpeningElement`))return!1;let s=o.parent;return!!(Us(o,n.scopes)&&s&&x(s,`JSXElement`)&&xc(s,n,r,i))},Oc=(e,t,n,r,i)=>{let a=P(e),o=a.parent;if(!o)return!1;if(x(o,`ExpressionStatement`)||x(o,`UnaryExpression`)&&o.operator===`void`&&o.argument===a)return!0;if(t.length===0&&x(o,`BinaryExpression`)&&(o.operator===`===`||o.operator===`!==`||o.operator===`==`||o.operator===`!=`)){let e=o.left===a?o.right:o.left;return!!(x(a,`Identifier`)&&x(e,`Identifier`)&&n.scopes.symbolFor(a)?.id===n.scopes.symbolFor(e)?.id)}if(Dc(a,t,n,r,i)||_c(a,t,n,r,i)||t.length>0&&(x(o,`LogicalExpression`)&&o.left===a||x(o,`ConditionalExpression`)&&o.test===a||x(o,`IfStatement`)&&o.test===a||x(o,`UnaryExpression`)&&o.operator===`!`&&o.argument===a))return!0;if(x(o,`JSXExpressionContainer`)&&o.expression===a){let e=o.parent;return!!(e&&x(e,`JSXAttribute`)&&Tc(e,t,n,r,i))}if(x(o,`CallExpression`))return Ec(o,a,t,n,r,i);if(x(o,`VariableDeclarator`)&&o.init===a&&!x(o.id,`Identifier`))return hc(o.id,t,n,r,i);let s=mc(a,t,n);return!!(s&&jc(s,r,i-1))},kc=e=>{let t=e.parent;return t&&x(t,`VariableDeclarator`)&&t.init===e&&x(t.id,`Identifier`)?t.id:(x(e,`FunctionDeclaration`)||x(e,`FunctionExpression`))&&e.id?e.id:null},Ac=(e,t,n)=>{if(!e||!t||!k(e)||e.async||e.generator)return!1;let r=kc(e);if(!r||((x(e,`FunctionDeclaration`)||x(e,`FunctionExpression`))&&e.id===r?j(e):j(r))!==t)return!1;let i=x(e,`FunctionDeclaration`)?n.ownScopeFor(t)?.symbolsByName.get(r.name):n.symbolFor(r);return!!(i&&i.references.length>0&&i.references.every(e=>{let r=P(e.identifier),i=r.parent;return!!(i&&x(i,`CallExpression`)&&i.callee===r&&j(i)===t&&Zs(i,n))}))},jc=(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=j(e.symbol.bindingIdentifier),a=e.symbol.references.every(r=>{if(r.identifier===e.originWriteReference)return!0;let a=r.identifier.parent;if(a&&x(a,`Property`)&&!a.computed&&a.key===r.identifier&&a.value!==r.identifier)return!0;let o=ic(r.identifier);if(!o)return!1;if(!$s(o.propertyPath,e.propertyPath))return!0;let s=j(r.identifier);if(s!==i&&!Ac(s,i,e.environment.scopes))return!!Js(r.identifier,o.propertyPath,e.propertyPath,e.environment.scopes);if(r.flag!==`read`)return!1;if(Qs(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&&x(t,`UnaryExpression`)&&t.operator===`void`&&t.argument===o.expression)}return Oc(o.expression,[],e.environment,t,n)}return Oc(o.expression,e.propertyPath.slice(o.propertyPath.length),e.environment,t,n)});return t.activePaths.delete(r),a},Mc=(e,t,n)=>{if(!t)return!1;let r=Lt(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=mc(e,[],i);return o?jc(o,a,12):Oc(e,[],i,a,12)},Nc=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},Pc=({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=Rn(e,t);if(!(!a||!Ti(a))){n||(n=!0,Kr(e));for(let e of i){let t=e.importName.kind===`Default`?`default`:e.importName.name;t&&Za(a,t)}}}},Fc=({absoluteFilePath:e})=>{hr.test(e)&&(yr.test(e)||oi(e))},Ic=({absoluteFilePath:e,staticImports:t})=>{if(gr.test(e)&&!li(e))for(let n of Nc(t))ar(e,n.source,n.exportedName)},H=({absoluteFilePath:e,staticImports:t})=>{Ae(e);for(let n of Nc(t))ar(e,n.source,n.exportedName)},Lc=({absoluteFilePath:e,getProgram:t})=>{let n=t();cn(n);let r=_t(n);z(n,t=>{if(!x(t,`CallExpression`))return;let n=ve(t.callee,r);!n?.importedName||!n.source.startsWith(`.`)||ar(e,n.source,n.importedName)})},Rc=({absoluteFilePath:e,staticImports:t})=>{for(let n of Nc(t))R(e,n.source,n.exportedName)},zc=(e,t,n,r)=>{let i=n.get(t);if(!(i!==void 0&&i<=r)){n.set(t,r);for(let i of e.body??[]){let e=ui(i);if(!e)continue;let a=tr(t,e);if(!a||r>=8)continue;let o=r+1,s=n.get(a);if(s!==void 0&&s<=o)continue;let c=_n(a);if(!c){n.set(a,o);continue}zc(c,a,n,o)}}},Bc=e=>{Rc(e);let t=e.getProgram(),n=!1;z(t,e=>{if(n)return!1;if(!x(e,`CallExpression`))return;let t=T(e.callee);if(!x(t,`MemberExpression`))return;let r=w(t);n=r===`add`||r===`set`}),n&&zc(t,e.absoluteFilePath,new Map,0)},Vc=({absoluteFilePath:e,staticImports:t})=>{for(let n of Nc(t))Qa(e,n.source,n.exportedName)},Hc=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},Uc=({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 Hc(t)){let t=R(e,a.source,a.exportedName);!t||n===0||!r(t)||!i(t.filePath)||o(t.filePath,t.programNode,n-1)}}};for(let a of Nc(t)){let t=R(e,a.source,a.exportedName);!t||!r(t)||!i(t.filePath)||o(t.filePath,t.programNode,n)}},Wc=e=>{let t=e.getProgram();cn(t);let n=_t(t);z(t,t=>{if(x(t,`BlockStatement`))for(let[r,i]of t.body.entries()){let a=t.body[r+1];!x(i,`VariableDeclaration`)||!x(a,`VariableDeclaration`)||pr(i,a,n,e.absoluteFilePath)}})},Gc=e=>{Uc(e,4),Rc(e),Be(e.absoluteFilePath,`@xstate/react`)},Kc=({absoluteFilePath:e,sourceText:t,getProgram:n})=>{if(!t.includes(`createRef`)&&!t.includes(`\\u`))return;let r=n();cn(r);let i=_t(r);z(r,t=>{!x(t,`CallExpression`)||!Ka(t,`createRef`,i,{allowGlobalReactNamespace:!0,allowUnboundBareCalls:!0,resolveNamedAliases:!0})||Mc(t,e,i)})},qc=({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(z(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(T(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&&ar(e,t.moduleRequest.value,r)}},Jc=({absoluteFilePath:e,staticImports:t,getProgram:n})=>{Kr(e),qr({absoluteFilePath:e,staticImports:t,program:n()})},U=({absoluteFilePath:e})=>{Kr(e)},Yc=e=>{U(e),Vc(e)},Xc=e=>{U(e),Uc(e,1/0,e=>k(e.exportedNode),e=>!e.split(/[\\/]/).includes(`node_modules`))},Zc=({absoluteFilePath:e})=>{Ri(e)},Qc=({absoluteFilePath:e})=>{Be(e,`react-native`)},$c=({absoluteFilePath:e})=>{zi(e)},el=e=>{$c(e),qr({absoluteFilePath:e.absoluteFilePath,staticImports:e.staticImports,program:e.getProgram()})},tl=new Map([...b.map(e=>[e,$c]),[`ink-no-raw-text`,el],[`client-passive-event-listeners`,H],[`effect-needs-cleanup`,H],[`effect-listener-cleanup-reference-mismatch`,H],[`exhaustive-deps`,Gc],[`rules-of-hooks`,Lc],[`no-barrel-import`,Pc],[`nextjs-async-dynamic-api-not-awaited`,U],[`nextjs-missing-metadata`,Fc],[`nextjs-no-use-search-params-without-suspense`,Ic],[`no-dynamic-import-path`,U],[`no-full-lodash-import`,U],[`no-hydration-branch-on-browser-global`,Yc],[`no-indeterminate-attribute`,U],[`no-locale-format-in-render`,U],[`no-match-media-in-state-initializer`,U],[`no-create-ref-in-function-component`,Kc],[`no-adjust-state-on-prop-change`,H],[`no-derived-state`,H],[`no-derived-state-effect`,H],[`no-event-handler`,H],[`no-initialize-state`,H],[`no-reset-all-state-on-prop-change`,H],[`no-mutating-reducer-state`,qc],[`no-side-effect-in-state-updater-function`,Bc],[`no-unguarded-browser-global-at-module-scope`,Vc],[`no-unguarded-browser-global-in-render-or-hook-init`,Xc],[`prefer-dynamic-import`,U],[`rendering-hydration-mismatch-time`,U],[`rendering-hydration-no-flicker`,H],[`rerender-memo-with-default-value`,Gc],[`server-sequential-independent-await`,Wc],[`rn-no-deprecated-modules`,Qc],[`rn-no-legacy-shadow-styles`,Zc],[`rn-no-raw-text`,Jc],[`rn-prefer-expo-image`,U],[`rn-style-prefer-boxshadow`,Zc],...re.map(e=>[e,U])]),nl=new Set([`anchor-target-exists`,`nextjs-no-img-element`,`no-img-without-dimensions`,`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`]),rl=e=>{let t=new Set;for(let n of e.ruleIds){let e=tl.get(n);if(!e)return null;t.add(e)}let n=Ja(e.absoluteFilePath),r,i;try{let t=pn(n,e.sourceText);if(t.errors.some(e=>e.severity===`Error`))return null;r=t.module.staticImports;let a;i=()=>(a??=t.program,a)}catch{return null}let a={absoluteFilePath:n,sourceText:e.sourceText,staticImports:r,getProgram:i};return Ce(()=>{for(let e of t)e(a)})},il={},al=(e,t,n)=>!e||e.length===0?!1:e.every(e=>x(e,t)&&e[n]===`type`),ol=e=>e.importKind===`type`||al(e.specifiers,`ImportSpecifier`,`importKind`),sl=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`]),cl=[`solid-js`,`@builder.io/qwik`],ll=[`react`,`react-dom`,`preact`],ul=new WeakMap,dl=new WeakMap,fl=(e,t)=>t.some(t=>e===t||e.startsWith(`${t}/`)),pl=e=>{let t=ul.get(e);if(t)return t;let n=!1,r=!1,i=!1,a=!1,o=!1,s=!1;for(let t of e.body){if(i||z(t,e=>{if(i)return!1;if(x(e,`JSXOpeningElement`)&&ml(e))return i=!0,!1;x(e,`JSXOpeningElement`)&&x(e.name,`JSXIdentifier`)&&/^[a-z]/.test(e.name.name)&&e.attributes.some(e=>x(e,`JSXAttribute`)&&Ts(e.name)===`class`)&&(s=!0)}),!x(t,`ImportDeclaration`))continue;let e=t,c=e.source,l=c&&typeof c.value==`string`?c.value:null;if(l){if(l===`solid-js`)for(let t of e.specifiers){if(!x(t,`ImportSpecifier`)||e.importKind!==`type`&&t.importKind!==`type`)continue;let n=S(t);n===`Component`&&(a=!0),n===`JSX`&&(o=!0)}ol(e)||((sl.has(l)||fl(l,cl))&&(n=!0),fl(l,ll)&&(r=!0))}}let c={hasNonReactMarker:i||a||o&&s,hasNonReactRuntime:n,hasReactRuntime:r};return ul.set(e,c),c},ml=e=>{let t=dl.get(e);if(t!==void 0)return t;let n=!1;for(let t of e.attributes){if(!x(t,`JSXAttribute`))continue;let r=Ts(t.name);if(r&&(r===`classList`&&x(t.value,`JSXExpressionContainer`)&&x(t.value.expression,`ObjectExpression`)||x(e.name,`JSXIdentifier`)&&/^[a-z]/.test(e.name.name)&&(r.startsWith(`class:`)||r.startsWith(`bind:`)||r.startsWith(`on:`)||r.startsWith(`oncapture:`)))){n=!0;break}}return dl.set(e,n),n},hl=new Set(`/playground/./playgrounds/./examples/./example/./demo/./demos/./sandbox/./sandboxes/./specs/./spec/./integration/./it/./perf/./scripts/./cli/./bin/./tooling/./tools/./codemods/./codemod/./migrations/./migration/./generators/./generator/./runbooks/./devtools/./internal-tools/./seeds/./seed/./dev-seeder/`.split(`.`)),gl=new Set,_l=[`/test/`,`/tests/`,`/testing/`,`/__tests__/`,`/__test__/`,`/__fixtures__/`,`/fixtures/`,`/__mocks__/`,`/mocks/`,`/testUtils/`,`/test-utils/`,`/test-stubs/`,`/testutils/`,`/cypress/`,`/playwright/`,`/.storybook/`,`/.dumi/`,`/stories/`,`/__stories__/`,...hl,`/e2e/`,`/e2e-tests/`,`/integration-tests/`,`/benchmarks/`,`/benchmark/`,`/__benchmarks__/`,`/perf-tests/`],vl=[`.test.`,`.spec.`,`.cy.`,`.stories.`,`.story.`,`.bench.`,`.benchmark.`,`.e2e.`,`.integration-spec.`,`.int-spec.`,`.mock.`,`.mocks.`,`.fixture.`],yl=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(`,`)),bl=[`/src/`,`/app/`,`/lib/`,`/components/`,`/pages/`,`/features/`,`/modules/`,`/packages/`,`/apps/`,`/frontend/`,`/client/`],xl=_l.filter(e=>e.startsWith(`/.`)),Sl=e=>{let t=-1;for(let n of bl){let r=e.lastIndexOf(n);r>t&&(t=r)}return t<0?e:e.slice(t)};let Cl,wl=!1,Tl,El=!1;const Dl=e=>e?e===Cl?wl:(Cl=e,wl=Al(e),wl):!1,Ol=e=>{if(!e)return!1;if(e===Tl)return El;Tl=e;let t=e.replaceAll(`\\`,`/`),n=t.startsWith(`/`)?t:`/${t}`;return El=Al(n,bl.some(e=>n.includes(e))?hl:gl),El},kl=(e,t)=>e?Al(e,t):!1,Al=(e,t=gl)=>{let n=e.replaceAll(`\\`,`/`),r=n.lastIndexOf(`/`),i=r===-1?n:n.slice(r+1);if(yl.has(i.toLowerCase()))return!0;for(let e of vl)if(i.includes(e))return!0;let a=n.startsWith(`/`)?n:`/${n}`;for(let e of xl)if(!t.has(e)&&a.includes(e))return!0;let o=Sl(n);for(let e of _l)if(!t.has(e)&&(e.startsWith(`/.`)?n:o).includes(e))return!0;return!1},jl=(e,t=Dl)=>n=>t(n.filename)?il:e(n),Ml=e=>{let t=e?.[`react-doctor`];return typeof t!=`object`||!t||Array.isArray(t)?null:t},Nl=(e,t)=>Object.getOwnPropertyDescriptor(e,t)?.value,Pl=(e,t)=>{let n=Ml(e);if(!n)return;let r=Nl(n,t);return typeof r==`string`?r:void 0},Fl=(e,t)=>{let n=Ml(e);if(!n)return;let r=Nl(n,t);return typeof r==`number`&&Number.isFinite(r)?r:void 0},Il=new WeakMap,Ll=(e,t)=>{let n=Nl(e,t);if(Array.isArray(n))return n.filter(e=>typeof e==`string`&&e.length>0)},Rl=(e,t)=>{let n=Ml(e);if(!n)return;let r=Il.get(n);if(r||(r=new Map,Il.set(n,r)),r.has(t))return r.get(t);let i=Ll(n,t);return r.set(t,i),i},zl=(e,t)=>Rl(e,t)??[],Bl=(e,t)=>zl(e,`capabilities`).includes(t),Vl=(e,t)=>{let n=Ml(e);return!n||Nl(n,`capabilities`)===void 0?!0:Bl(e,t)},Hl=(e,t,n)=>!t?.some(t=>!Vl(e,t))&&!n?.some(t=>Bl(e,t)),Ul=(e,t,n)=>r=>Hl(r.settings,t,n)?e(r):il,Wl=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=pl(e);i=n.hasReactRuntime,r=!n.hasReactRuntime&&(n.hasNonReactRuntime||n.hasNonReactMarker),!r&&t(e)};continue}if(e===`JSXOpeningElement`){a.JSXOpeningElement=e=>{!i&&!r&&ml(e)&&(r=!0),!r&&t(e)};continue}a[e]=e=>{r||t(e)}}return`Program`in a||(a.Program=e=>{let t=pl(e);i=t.hasReactRuntime,r=!t.hasReactRuntime&&(t.hasNonReactRuntime||t.hasNonReactMarker)}),a}),W=e=>{if(!(`create`in e))return{...e,create:()=>il};let t=e.tags,n=e.create,r=t?.includes(`test-noise`)&&!t?.includes(`migration-hint`);return t?.includes(`react-jsx-only`)&&(n=Wl(n)),r&&(n=jl(n,Ol)),(e.requires||e.disabledWhen)&&(n=Ul(n,e.requires,e.disabledWhen)),n===e.create?e:{...e,create:n}};let Gl;const Kl=e=>{let t=[0];for(let n=0;n<e.length;n+=1){let r=e[n];if(r===`\r`&&e[n+1]===`
|
|
3
|
-
`){n+=1,t.push(n+1);continue}(r===`\r`||r===`
|
|
4
|
-
`||r===`\u2028`||r===`\u2029`)&&t.push(n+1)}return t},ql=e=>{if(Gl?.content===e)return Gl.lineStartOffsets;let t=Kl(e);return Gl={content:e,lineStartOffsets:t},t},G=(e,t)=>{if(Number.isNaN(t)||t<0)return{line:1,column:1};let n=ql(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}},Jl=(e,t)=>G(e,e.search(t)),Yl=/\.(?:[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,Xl=/(?:^|\/)\.env(?:\.|$)/,Zl=/\.(?:[cm]?[jt]sx?)$/i,Ql=/\.(?:[cm]?[jt]sx?|py|php)$/i,$l=/\.(?:[cm]?[jt]sx?|py)$/i,eu=/(?:^|\/)(?:api|backend|server|servers|middleware|route|routes|functions|lambdas|workers)(?:\/|$)|(?:^|\/)[^/]+\.server\.[cm]?[jt]sx?$/i,tu=/(?:^|\/)(?:__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,nu=/(?:^|\/)(?: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,ru=/(?:^|\/)scripts(?:\/|$)/i,iu=/(?:^|\/)(?:examples?|tutorials?|demos?|samples?|playgrounds?)(?:\/|$)/i,au=/(?:^|\/)(?:README|CHANGELOG|CONTRIBUTING|PUBLISHING|DOCS)\.mdx?$|\.mdx?$/i,ou=/(?:^|\/)(?: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,su=/\.(iife|umd|global|min)\.js$/i,cu=[/(?:^|\/)\.next\/static\//,/(?:^|\/)\.output\/public\//,/(?:^|\/)build\/static\//,/(?:^|\/)dist\/assets\//,/(?:^|\/)public\//,/(?:^|\/)out\//,/(?:^|\/)storybook-static\//],lu=/\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/,uu=new Set([`.next`,`.output`]),du=e=>{let t=e.split(`/`);for(let e=0;e<t.length;e+=1)if(uu.has(t[e])&&(t[e]===`.next`&&t[e+1]===`dev`||t[e+1]===`server`&&e+2<t.length))return!0;return!1},fu=(e,t)=>du(e)?!1:t||e.endsWith(`.map`)?!0:cu.some(t=>t.test(e)),pu=e=>/(?:^|\/)(?:package\.json|Dockerfile|docker-compose\.ya?ml|\.github\/workflows\/[^/]+\.ya?ml|vercel\.json|next\.config\.[cm]?[jt]s|netlify\.toml)$/i.test(e),mu=new Map,hu=(e,t)=>{let n=mu.get(t);n||(n=new Map,mu.set(t,n));let r=n.get(e);if(r!==void 0)return r;let i=t.test(e)&&!tu.test(e)&&!ru.test(e)&&!au.test(e)&&!ou.test(e);return n.set(e,i),i},K=e=>/\.d\.[cm]?[jt]s$/i.test(e)?!1:hu(e,Zl),gu=/<script\b|on(?:load|error|click|mouseover)\s*=/i,_u=/dangerouslyAllowSVG\s*:\s*true/i,vu=/<(?:object|embed|iframe)\b[^>]+(?:data|src)=["'][^"']+\.svg(?:\?[^"']*)?["']/i,yu=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`)&&fu(e.relativePath,e.isGeneratedBundle)){if(gu.test(e.content)){let n=Jl(e.content,gu);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)&&!pu(e.relativePath))return t;let n=[_u,vu].find(t=>t.test(e.content));if(n!==void 0){let r=Jl(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}}),bu=e=>/(?:^|\/)(?:firestore\.rules|storage\.rules|database\.rules\.json)$/.test(e),xu=/\s/,Su=/[\p{ID_Continue}$]/u,Cu=/["'`/]/g,wu=/["'`/{}]/g,Tu=/["\\\n]/g,Eu=/['\\\n]/g,Du=/[`\\$\n]/g,Ou=new Set([`return`,`typeof`,`case`,`in`,`of`,`new`,`delete`,`void`,`instanceof`,`do`,`else`,`yield`,`await`,`throw`]),ku=()=>{let e=[],t=[],n=-1,r=-1,i=()=>{n<0||(e.push(n),t.push(r),n=-1,r=-1)},a=(e,t)=>{if(e===r){r=t;return}if(e<r){r=Math.max(r,t);return}i(),n=e,r=t};return{blank:e=>a(e,e+1),blankSpan:a,isBlanked:i=>{if(i>=n&&i<r)return!0;for(let n=e.length-1;n>=0;--n)if(!(e[n]>i))return t[n]>i;return!1},apply:n=>{if(i(),e.length===0)return n;let r=[],a=0;for(let i=0;i<e.length;i+=1)r.push(n.slice(a,e[i]),` `.repeat(t[i]-e[i])),a=t[i];return r.push(n.slice(a)),r.join(``)}}},Au=(e,t,n)=>{let r=n=>t.isBlanked(n)?` `:e[n],i=n-1;for(;i>=0&&xu.test(r(i));)--i;if(i<0)return!0;let a=r(i),o=i>0?r(i-1):``;if(Su.test(a)){let t=i;for(;t>0&&Su.test(r(t-1));)--t;return t>0&&r(t-1)===`.`?!1:Ou.has(e.slice(t,i+1))}return a===`<`?!1:a===`>`?o===`=`:a===`+`||a===`-`?o!==a:a===`!`?!(Su.test(o)||o===`)`||o===`]`):!(a===`)`||a===`]`||a===`}`||a===`"`||a===`'`||a==="`")},ju=(e,t)=>{let n=t+1,r=!1;for(;n<e.length;){let t=e[n];if(t===`\\`){n+=2;continue}if(t===`
|
|
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},Mu=(e,t,n)=>{for(let r=t+1;r<e.length;r+=1){let t=e.charCodeAt(r);if(t===92){r+=1;continue}if(t===n)return!1;if(xu.test(e[r]))return!0}return!1},Nu=(e,t)=>{let n=e.length,r=ku(),i=-1,a=!1,o=[],s=0,c=t=>{t>=n||e.charCodeAt(t)===10||r.blank(t)};for(;s<n;){if(i===-1){let t=o.length>0?wu:Cu;t.lastIndex=s;let n=t.exec(e);if(n===null)break;s=n.index}else{let t=i===34?Tu:i===39?Eu:Du;t.lastIndex=s;let o=t.exec(e),c=o===null?n:o.index;if(a&&c>s&&r.blankSpan(s,c),s=c,o===null)break}let l=e.charCodeAt(s),u=e.charCodeAt(s+1);if(i!==-1){if(l===92){a&&(c(s),c(s+1)),s+=2;continue}if(l===10&&i!==96){i=-1,s+=1;continue}if(l===i){i=-1,s+=1;continue}if(t&&i===96&&l===36&&u===123){o.push(0),i=-1,s+=2;continue}a&&c(s),s+=1;continue}if(l===34||l===39){i=l,a=t&&Mu(e,s,l),s+=1;continue}if(l===96){i=96,a=t,s+=1;continue}if(l===47&&u===47){for(;s<n&&e.charCodeAt(s)!==10;)r.blank(s),s+=1;continue}if(l===47&&u===42){for(;s<n;){if(e.charCodeAt(s)===42&&e.charCodeAt(s+1)===47){r.blank(s),r.blank(s+1),s+=2;break}c(s),s+=1}continue}if(l===47){let n=Au(e,r,s)?ju(e,s):null;if(n!==null){if(t)for(let e=s+1;e<n-1;e+=1)c(e);s=n;continue}}if(o.length>0){let e=o.length-1;l===123?o[e]+=1:l===125&&(o[e]===0?(o.pop(),i=96,a=t):--o[e])}s+=1}return r.apply(e)},Pu=e=>e.includes(`//`)||e.includes(`/*`)?Nu(e,!1):e,Fu=e=>Nu(e,!0),Iu=new WeakMap,Lu=new WeakMap,Ru=(e,t=!1)=>{if(!Zl.test(e.relativePath)&&!bu(e.relativePath))return e.content;let n=t?Lu:Iu,r=n.get(e);if(r!==void 0)return r;let i=t?Fu(e.content):Pu(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=Ru(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}]},zu=/\b(?:tool\s*\(\s*\{|createTool\s*\(|defineTool\s*\(|new\s+(?:DynamicTool|StructuredTool)\s*\()/,Bu=/\b(?:tool|createTool|defineTool|DynamicTool|StructuredTool)\b/,Vu=/(?:^|\/)(?:agents?|tools?|mcp)(?:\/|$)|(?:agent|tool|mcp)[^/]*\.[cm]?[jt]sx?$/i,Hu=W({id:`agent-tool-capability-risk`,defaultEnabled:!1,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)&&Vu.test(e.relativePath)&&Bu.test(e.content)&&lu.test(e.content),pattern:zu,requireAll:[lu],ignoreStringLiterals:!0,message:`An agent-callable tool appears to expose network, filesystem, shell, or code-execution capability.`})}),Uu=W({id:`artifact-baas-authority-surface`,defaultEnabled:!1,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=>fu(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.`})}),Wu=new Set([`auth`,`getSession`,`getServerSession`,`getUser`,`requireAuth`,`checkAuth`,`verifyAuth`,`authenticate`,`currentUser`,`getAuth`,`validateSession`]),Gu=/^auth(?:n|z|ed|enticate[ds]?|enticating|entication|orize[ds]?|orizing|orization|orizer)?$/,Ku=new Set([`signedin`,`loggedin`,`signin`]),qu=new Set([`require`,`ensure`,`assert`,`verify`,`validate`,`check`,`protect`,`enforce`,`guard`,`gate`,`restrict`,`is`,`has`,`can`,`must`]),Ju=new Set([`get`,`fetch`,`load`,`read`,`resolve`,`retrieve`,`use`]),Yu=new Set([`current`,`my`,`own`]),Xu=new Set([`session`,`sessions`,`login`,`admin`,`admins`,`superadmin`,`superuser`,`role`,`roles`,`permission`,`permissions`,`jwt`,`identity`,`principal`,`credential`,`credentials`]),Zu=new Set([`user`,`users`,`account`,`accounts`,`token`,`tokens`,`access`,`me`,`viewer`,`caller`,`subject`,`scope`,`scopes`]),Qu=new Set([`getUser`]),$u=/(?:^|[._])(?:auth|authn|authz|clerk|session|jwt|firebase|supabase|nextauth|kinde|workos|stytch|descope|cognito|propelauth|lucia)/i,ed=[/^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,}$/],td=[/\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],nd=/\beyJ[A-Za-z0-9_-]{8,}\.eyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{16,}\b/,rd=/\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,id=/\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/,ad=/\b(?:(?:process|window)\s*(?:\/[*/]|<!--|-->|\.\s*(?:\/[*/]|<!--|-->))|import\s*(?:\/[*/]|<!--|-->|\.\s*(?:\/[*/]|<!--|-->|meta\s*(?:\/[*/]|<!--|-->|\.\s*(?:\/[*/]|<!--|-->)))))/,od=/\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/,sd=/(?:SENTRY_DSN|PUBLIC_KEY|(?:^|_)PUBLIC_TOKEN$|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,cd=[/^appl_/,/^goog_/,/^amzn_/,/^strp_/,/^pk_(?:live|test)_/,/^sb_publishable_/,/^phc_/,/^public-token-(?:live|test)-/,/^pk\.eyJ/],ld=[/^[\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],ud=[/(?:^|[_\-\s])(?:example|sample|dummy)(?:$|[_\-\s])/i],dd=/(?:placeholder|example|sample|dummy|masked|redacted|mask)/i,fd=/(?:api_?key|secret|token|password|credential|auth(?!or(?!i[sz])))/i,pd=/(?:^|\/)[^/]+\.config\.[cm]?[jt]s$/,md=/(?:^|\/)(?:\.[a-z-]+rc|[a-z-]+\.rc)\.[cm]?[jt]s$/,hd=/(?:^|\/)[^/]+\.(?:test|spec|stories|story|fixture|fixtures)\.[cm]?[jt]sx?$/,gd=/(?:^|\/)[^/]+\.server\.[cm]?[jt]sx?$/,_d=/(?:^|\/)(?:middleware|proxy|route)\.[cm]?[jt]sx?$/,vd=/(?:^|\/)pages\/api\/.+\.[cm]?[jt]sx?$/,yd=/(?:^|\/)[^/]+\.(?:client|browser|web)\.[cm]?[jt]sx?$/,bd=/(?:^|\/)(?:src\/)?(?:main|index|[Aa]pp|client)\.[cm]?[jt]sx?$/,xd=new Set([`backend`,`functions`,`lambdas`,`lambda`,`middleware`,`server`,`servers`]),Sd=new Set([`api`,`backend`,`edge`,`function`,`functions`,`lambda`,`lambdas`,`server`,`servers`,`worker`,`workers`]),Cd=new Set([`__fixtures__`,`__mocks__`,`__tests__`,`fixtures`,`mocks`,`test`,`tests`]),wd=new Set([`bin`,`config`,`configs`,`script`,`scripts`,`tooling`,`tools`]),Td=new Set([`components`,`features`,`hooks`,`pages`,`ui`,`views`,`widgets`]),Ed=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(`.`)),Dd=new Set([`start`,`end`]),J=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),Od=new RegExp(rd.source,`gi`),kd=e=>{for(let t of e.matchAll(Od)){let e=t[0]??``;if(!sd.test(e))return new RegExp(J(e))}},Ad=e=>id.test(e)&&od.test(e),jd=/\.(?:[cm]?[jt]sx?)$/i,Md=/\/\/|\/\*|<!--/,Nd=new Set([`\r`,`
|
|
6
|
-
`,`\u2028`,`\u2029`]),Pd=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&&!Nd.has(e[r]??``)&&e[r]?.trim()===``;)--r;if(r<0||Nd.has(e[r]??``))return!0;t=n+3}return!1},Fd=(e,t)=>{if(!jd.test(e)||!t.startsWith(`#!`)&&!Md.test(t)&&!Pd(t))return t;try{let n=i(e,t,{astType:`ts`,lang:un(e)});if(n.errors.some(e=>e.severity===`Error`))return;let r=t.search(/[\r\n\u2028\u2029]/),a=[...t.startsWith(`#!`)?[{start:0,end:r===-1?t.length:r}]:[],...n.comments];if(a.length===0)return t;let o=[],s=0;for(let e of a)o.push(t.slice(s,e.start)),o.push(t.slice(e.start,e.end).replace(/[^\r\n\u2028\u2029]/g,` `)),s=e.end;return o.push(t.slice(s)),o.join(``)}catch{return}},Id=/\.map$/i,Ld=/\s/,Rd=/[^\r\n\u2028\u2029]/g,Y=(e,t)=>{let n=t;for(;n<e.length&&Ld.test(e[n]??``);)n+=1;return n},zd=(e,t)=>{if(e[t]!==`"`)return;let n=t+1;for(;n<e.length;){if(e[n]===`\\`){n+=2;continue}if(e[n]===`"`)return n+1;n+=1}},Bd=(e,t)=>{let n=Y(e,t);if(e[n]===`"`)return zd(e,n);if(e[n]!==`[`&&e[n]!==`{`){let t=n;for(;t<e.length&&![`,`,`]`,`}`].includes(e[t]??``);)t+=1;return t}let r=[e[n]===`[`?`]`:`}`],i=n+1;for(;i<e.length&&r.length>0;){if(e[i]===`"`){let t=zd(e,i);if(t===void 0)return;i=t;continue}e[i]===`[`&&r.push(`]`),e[i]===`{`&&r.push(`}`),e[i]===r.at(-1)&&r.pop(),i+=1}return r.length===0?i:void 0},Vd=(e,t)=>{let n=Y(e,0);if(e[n]!==`{`)return;n=Y(e,n+1);let r;for(;n<e.length&&e[n]!==`}`;){let i=zd(e,n);if(i===void 0)return;let a=JSON.parse(e.slice(n,i));if(n=Y(e,i),e[n]!==`:`)return;if(n=Y(e,n+1),a===t){if(r!==void 0)return;r=n}let o=Bd(e,n);if(o===void 0)return;if(n=Y(e,o),e[n]===`,`){n=Y(e,n+1);continue}if(e[n]!==`}`)return}return r},Hd=(e,t,n)=>{let r=Y(e,t);if(e[r]!==`[`)return;r=Y(e,r+1);let i=[];for(let t of n){if(typeof t==`string`){let t=zd(e,r);if(t===void 0)return;i.push({start:r,end:t}),r=t}else if(t===null&&e.startsWith(`null`,r))i.push({start:r,end:r+4}),r+=4;else return;if(r=Y(e,r),e[r]===`,`){r=Y(e,r+1);continue}}return e[r]===`]`?i:void 0},Ud=(e,t)=>`${e}/${t}`.split(/[\\/]/).includes(`node_modules`),Wd=(e,t)=>{if(!Id.test(e)||!t.includes(`"sourcesContent"`))return t;try{let e=JSON.parse(t);if(typeof e!=`object`||!e||Array.isArray(e))return t;let n=Reflect.get(e,`sources`),r=Reflect.get(e,`sourcesContent`),i=Reflect.get(e,`sourceRoot`);if(!Array.isArray(n)||!n.every(e=>typeof e==`string`)||!Array.isArray(r)||n.length!==r.length||i!==void 0&&typeof i!=`string`)return t;let a=Vd(t,`sourcesContent`);if(a===void 0)return t;let o=Hd(t,a,r);if(o===void 0)return t;let s=i??``,c=[],l=0;for(let[e,r]of n.entries()){if(!Ud(s,r))continue;let n=o[e];if(n===void 0)return t;c.push(t.slice(l,n.start)),c.push(t.slice(n.start,n.end).replace(Rd,` `)),l=n.end}return l===0?t:(c.push(t.slice(l)),c.join(``))}catch{return t}},Gd=(e,t,n)=>{if(au.test(e.relativePath)||!fu(e.relativePath,e.isGeneratedBundle))return[];let r=t(e.content);if(r===void 0)return[];let i=Jl(e.content,r);return[{message:n,line:i.line,column:i.column}]},Kd=`A browser artifact contains server-secret environment names or a full environment dump shape.`,qd=e=>kd(e)??(Ad(e)?od:void 0),Jd=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=Wd(e.relativePath,e.content),n=t===e.content?e:{...e,content:t},r=!1,i=Gd(n,e=>{let t=kd(e);if(t)return r=!0,t;if(od.test(e))return id.test(e)?(r=!0,od):ad.test(e)?od:void 0},Kd);if(i.length===0)return i;let a=r?i:Gd(n,qd,Kd),o=Fd(n.relativePath,n.content);return o===void 0?i:o===n.content?a:Gd({...n,content:o},qd,Kd)}}),Yd=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=>Gd(e,e=>td.find(t=>t.test(e)),`A browser-delivered artifact contains a secret-looking credential value.`)}),Xd=/(?: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,Zd=/(?:npm|pnpm|yarn|bun)\s+(?:install|ci)\b/i,Qd=/\bsecrets\.[A-Z0-9_]+/,$d=/--ignore-scripts\b/,ef=`The build or install pipeline can execute package lifecycle code while CI secrets may be present.`,tf=e=>/(?:^|\/)\.github\/workflows\/[^/]+\.ya?ml$/i.test(e),nf=e=>{let t=e.split(`
|
|
7
|
-
`),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=Qd.test(n.join(`
|
|
8
|
-
`));for(let e of r){let t=e.lines.join(`
|
|
9
|
-
`);if(!Zd.test(t)||$d.test(t)||!s&&!Qd.test(t))continue;let n=Math.max(e.lines.findIndex(e=>Zd.test(e)),0),r=e.lines[n].search(Zd);return[{message:ef,line:e.startLineIndex+n+1,column:(r===-1?0:r)+1}]}return[]},rf=q({shouldScan:e=>pu(e.relativePath)&&!e.relativePath.endsWith(`package.json`)&&!tf(e.relativePath),pattern:Xd,message:ef}),af=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=>tf(e.relativePath)?nf(e.content):rf(e)}),of=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)||pu(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.`})}),sf=e=>/(?:^|\/)(?:tools?|scripts?)\/|(?:^|\/)management\/commands\/|(?:^|\/)(?:build|make|gulpfile|gruntfile)\.[cm]?[jt]s$/i.test(e),cf=e=>hu(e,Ql),lf=String.raw`(?:req\.|request\.|params\.|query\.|body\.|searchParams|\$_(?:GET|POST|REQUEST))`,uf=String.raw`(?:(?<![.\w$])(?:exec(?:Sync)?|system|passthru|proc_open|shell_exec)|\b(?:os\.system|subprocess\.(?:run|Popen|call)|(?:child_process|childProcess|cp)\.exec\w*))`,df=String.raw`(?:(?<![.\w$])spawn(?:Sync)?|\b(?:child_process|childProcess|cp)\.spawn\w*)`,ff=String.raw`['"](?:sh|bash|zsh|dash|ksh|cmd(?:\.exe)?|powershell(?:\.exe)?|pwsh)['"]`,pf=String.raw`['"](?:-c|/c|-Command)['"]`,mf=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=>cf(e.relativePath)&&!sf(e.relativePath),pattern:[new RegExp(String.raw`${uf}\s*\([^)]{0,220}(?:${lf}|shell\s*=\s*true|f['"\`][^'"\`]*\{)`,`i`),new RegExp(String.raw`${df}\s*\((?:[^,)]{0,120}?${lf}|\s*${ff}\s*,\s*\[\s*${pf}\s*,[^\]]{0,220}${lf}|(?=[^)]{0,220}shell\s*[:=]\s*true)[^)]{0,220}${lf})`,`i`)],message:`Command execution appears to include request, query, body, or shell-interpolated input.`})}),hf=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)||pu(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.`})}),gf=(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},_f=e=>`end`in e&&typeof e.end==`number`?e.end:-1,X=e=>`start`in e&&typeof e.start==`number`?e.start:-1,vf=e=>{let t=T(e);for(;x(t,`SequenceExpression`);){let e=t.expressions.at(-1);if(!e)break;t=T(e)}return t},yf=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},bf=e=>x(e,`JSXElement`)||x(e,`JSXFragment`)||x(e,`ArrayExpression`)||x(e,`ObjectExpression`)||x(e,`ArrowFunctionExpression`)||x(e,`FunctionExpression`)||x(e,`ClassExpression`)||x(e,`NewExpression`)?{expression:e,truthiness:`truthy`,nullishness:`non-nullish`}:x(e,`Literal`)?e.value===null?{expression:e,truthiness:`falsy`,nullishness:`nullish`}:{expression:e,truthiness:e.value?`truthy`:`falsy`,nullishness:`non-nullish`}:x(e,`UnaryExpression`)&&e.operator===`void`?{expression:e,truthiness:`falsy`,nullishness:`nullish`}:{expression:e,truthiness:`unknown`,nullishness:`unknown`},xf=e=>{let t=vf(e);if(x(t,`ConditionalExpression`)){let e=xf(t.test);return e.every(e=>e.truthiness===`truthy`)?xf(t.consequent):e.every(e=>e.truthiness===`falsy`)?xf(t.alternate):yf([...xf(t.consequent),...xf(t.alternate)])}if(!x(t,`LogicalExpression`))return[bf(t)];let n=xf(t.left),r=xf(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 yf(i)},Sf=e=>{let t=[],n=new Set;for(let r of xf(e))n.has(r.expression)||(n.add(r.expression),t.push(r.expression));return t},Cf=new Set([`assign`,`defineProperties`,`defineProperty`]),wf=new Set([`defineProperty`,`set`]),Tf=new WeakMap,Ef=e=>{let t=P(e);for(;t.parent;){let e=t.parent;if(!x(e,`MemberExpression`)||e.object!==t)break;t=P(e)}return t},Z=e=>{let t=e;for(;t;){if(k(t)||x(t,`Program`))return t;t=t.parent}return e},Df=(e,t)=>{if(x(e,`ReturnStatement`)||x(e,`ThrowStatement`)||x(e,`BreakStatement`)||t&&x(e,`ContinueStatement`))return!0;if(x(e,`BlockStatement`))return e.body.some(e=>Df(e,t));if(!x(e,`IfStatement`))return!1;if(x(e.test,`Literal`)){let n=e.test.value?e.consequent:e.alternate;return n?Df(n,t):!1}return!!(e.alternate&&Df(e.consequent,t)&&Df(e.alternate,t))},Of=e=>Df(e,!0),kf=(e,t)=>{let n=t.indexOf(e);return n>0&&t.slice(0,n).some(Of)},Af=(e,t)=>{let n=e;for(;n.parent&&n!==t;){let e=n.parent;if((x(e,`BlockStatement`)||x(e,`Program`))&&kf(n,e.body)||(x(e,`WhileStatement`)&&x(e.test,`Literal`)&&!e.test.value||x(e,`ForStatement`)&&e.test&&x(e.test,`Literal`)&&!e.test.value)&&e.body===n||x(e,`SwitchCase`)&&kf(n,e.consequent)||x(e,`IfStatement`)&&x(e.test,`Literal`)&&(e.test.value===!1&&e.consequent===n||e.test.value===!0&&e.alternate===n)||x(e,`ConditionalExpression`)&&x(e.test,`Literal`)&&(e.test.value===!1&&e.consequent===n||e.test.value===!0&&e.alternate===n)||x(e,`LogicalExpression`)&&e.right===n&&x(e.left,`Literal`)&&(e.operator===`&&`&&!e.left.value||e.operator===`||`&&e.left.value))return!0;n=e}return!1},jf=(e,t)=>{let n=e;for(;n.parent&&n!==t;){let e=n.parent;if(x(e,`IfStatement`)&&(!x(e.test,`Literal`)||e.test.value===!0&&e.alternate===n||e.test.value===!1&&e.consequent===n)||x(e,`ConditionalExpression`)&&(!x(e.test,`Literal`)||e.test.value===!0&&e.alternate===n||e.test.value===!1&&e.consequent===n)||x(e,`LogicalExpression`)&&e.right===n&&(!x(e.left,`Literal`)||e.operator===`&&`&&!e.left.value||e.operator===`||`&&e.left.value)||x(e,`DoWhileStatement`)&&!(e.body===n&&x(e.test,`Literal`)&&!e.test.value)||x(e,`ForStatement`)||x(e,`ForInStatement`)||x(e,`ForOfStatement`)&&e.right!==n||x(e,`WhileStatement`)||x(e,`SwitchCase`)||x(e,`CatchClause`)||x(e,`TryStatement`)&&e.block===n||(x(e,`CallExpression`)||x(e,`MemberExpression`))&&e.optional)return!0;n=e}return!1},Mf=(e,t)=>{let n=T(e);if(x(n,`Literal`))return!1;if(x(n,`Identifier`)){if(t.isGlobalReference(n)&&(n.name===`undefined`||n.name===`NaN`||n.name===`Infinity`))return!1;let e=t.symbolFor(n);return e?e.kind===`var`||e.kind===`function`||e.kind===`parameter`||e.kind===`import`?!1:X(e.declarationNode)>X(n):!0}if(x(n,`ArrayExpression`))return n.elements.some(e=>e?x(e,`SpreadElement`)?!0:Mf(e,t):!1);if(x(n,`ObjectExpression`))return n.properties.length>0;if(x(n,`TemplateLiteral`))return n.expressions.length>0;if(x(n,`UnaryExpression`)){let e=T(n.argument);return n.operator===`typeof`&&x(e,`Identifier`)&&!t.symbolFor(e)?!1:Mf(e,t)?!0:n.operator===`void`||n.operator===`typeof`||n.operator===`!`?!1:!(x(e,`Literal`)&&(typeof e.value==`number`||typeof e.value==`string`))}return!0},Nf=(e,t,n)=>{let r=e;for(;r.parent&&r.parent!==t;)r=r.parent;let i=t.body.findIndex(e=>e===r);return r.parent!==t||i<=0?!1:t.body.slice(0,i).some(e=>x(e,`EmptyStatement`)?!1:x(e,`ExpressionStatement`)?Mf(e.expression,n):x(e,`VariableDeclaration`)?e.declarations.some(e=>!x(e.id,`Identifier`)||!!(e.init&&Mf(e.init,n))):!0)},Pf=(e,t)=>x(e,`AwaitExpression`)?Mf(e.argument,t):!1,Ff=(e,t,n)=>{let r=e;for(;r.parent&&r!==t;){let t=r.parent;if(x(t,`IfStatement`)&&(!x(t.test,`Literal`)||t.test.value===!0&&t.alternate===r||t.test.value===!1&&t.consequent===r)||x(t,`ConditionalExpression`)&&(!x(t.test,`Literal`)||t.test.value===!0&&t.alternate===r||t.test.value===!1&&t.consequent===r)||x(t,`LogicalExpression`)&&t.right===r&&(!x(t.left,`Literal`)||t.operator===`&&`&&!t.left.value||t.operator===`||`&&t.left.value)||x(t,`WhileStatement`)&&(!x(t.test,`Literal`)||!t.test.value)||x(t,`ForStatement`)&&t.test&&(!x(t.test,`Literal`)||!t.test.value)||x(t,`ForInStatement`)||x(t,`ForOfStatement`)||x(t,`SwitchCase`)||x(t,`CatchClause`)||x(t,`TryStatement`)&&t.block===r&&x(r,`BlockStatement`)&&(Nf(e,r,n)||Pf(e,n))||(x(t,`CallExpression`)||x(t,`MemberExpression`))&&t.optional)return!0;r=t}return!1},If=(e,t)=>{let n=e;for(;n;){if(n===t)return!0;n=n.parent}return!1},Lf=(e,t)=>{let n=e;for(;n.parent&&n!==t;){let e=n.parent;if(x(e,`IfStatement`)&&(!x(e.test,`Literal`)||e.test.value===!0&&e.alternate===n||e.test.value===!1&&e.consequent===n)||x(e,`ConditionalExpression`)&&(!x(e.test,`Literal`)||e.test.value===!0&&e.alternate===n||e.test.value===!1&&e.consequent===n)||x(e,`LogicalExpression`)&&e.right===n&&(!x(e.left,`Literal`)||e.operator===`&&`&&!e.left.value||e.operator===`||`&&e.left.value)||x(e,`ForStatement`)||x(e,`ForInStatement`)||x(e,`ForOfStatement`)||x(e,`WhileStatement`)||x(e,`SwitchCase`)||x(e,`CatchClause`)||x(e,`TryStatement`)&&e.block===n||(x(e,`CallExpression`)||x(e,`MemberExpression`))&&e.optional)return n;n=e}return null},Rf=e=>x(e,`AwaitExpression`)||x(e,`YieldExpression`)?e.argument?_f(e.argument):_f(e):x(e,`ForOfStatement`)?_f(e.right):X(e),zf=(e,t,n)=>{if(X(t)<Rf(e))return!1;let r=Lf(e,n);return!!(r&&If(t,r))},Bf=e=>{let t=Tf.get(e);if(t)return t;let n=(t,n,r)=>{let i=T(t);if(!x(i,`MemberExpression`))return!1;let a=T(i.object);return!!(x(a,`Identifier`)&&a.name===n&&e.isGlobalReference(a)&&r.has(w(i)??``))},r=e=>{let t=T(e);if(!x(t,`ObjectExpression`))return null;let n=new Set;for(let e of t.properties){if(!x(e,`Property`))return null;let t=C(e,{allowComputedString:!0});if(t===null)return null;n.add(t)}return n},i=e=>{let t=Ef(e),i=t.parent;if(i){if(x(i,`AssignmentExpression`)&&i.left===t||x(i,`UpdateExpression`)&&i.argument===t||x(i,`UnaryExpression`)&&i.operator===`delete`){if(!x(t,`MemberExpression`))return null;let e=w(t);return e===null?null:new Set([e])}if(!(!x(i,`CallExpression`)||i.arguments[0]!==t)){if(n(i.callee,`Object`,Cf)){let e=T(i.callee);if(!x(e,`MemberExpression`))return;let t=w(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&&x(n,`Literal`)&&typeof n.value==`string`?new Set([n.value]):null}if(n(i.callee,`Reflect`,wf)){let e=i.arguments[1];return e&&x(e,`Literal`)&&typeof e.value==`string`?new Set([e.value]):null}}}},a=e=>{let t=P(e),n=t.parent;if(x(n,`ForOfStatement`)&&n.right===t)return n.await||Df(n.body,!1);let r=n;if(!x(r,`MemberExpression`)||r.object!==t||w(r)!==`next`)return!1;let i=P(r);return!!(x(i.parent,`CallExpression`)&&i.parent.callee===i)},o=e=>{let t=P(e),n=t.parent;return x(n,`ForOfStatement`)&&!n.await&&n.right===t&&!Df(n.body,!1)?!0:!!(x(n,`SpreadElement`)&&n.parent&&!x(n.parent,`ObjectExpression`))},s=e=>{let t=P(e),n=t.parent;if(!x(n,`ForOfStatement`)||n.await||n.right!==t||Df(n.body,!1))return[];let r=Z(n.body),i=new Set;return z(n.body,e=>{if(Z(e)!==r||!x(e,`BreakStatement`))return;let a=e;if(e.label){for(;a?.parent;){let t=a.parent;if(x(t,`LabeledStatement`)&&t.label.name===e.label.name){If(n,t.body)&&i.add(t);return}a=t}return}for(;a?.parent;){let e=a.parent;if(x(e,`ForStatement`)||x(e,`ForInStatement`)||x(e,`ForOfStatement`)||x(e,`WhileStatement`)||x(e,`DoWhileStatement`)||x(e,`SwitchStatement`)){x(e,`ForOfStatement`)&&e.right===t&&i.add(e);return}a=e}}),[...i]},c=t=>{let n=T(t.callee),r=null;if(k(n))r=n;else if(x(n,`Identifier`)){let t=F(n,e);if(t?.kind===`function`&&k(t.declarationNode))r=t.declarationNode;else if(t?.kind===`const`&&t.initializer){let e=T(t.initializer);k(e)&&(r=e)}}return r&&k(r)?r:null},l=e=>{let t=c(e);return!t||!k(t)?null:t.generator?a(e)||o(e)?t:null:t},u=[],d=new Map;z(e.rootScope.node,t=>{if(x(t,`CallExpression`)){let e=Z(t),n=l(t);n&&!Af(t,e)&&u.push({argumentCall:t,call:t,conditionalExitTargets:k(n)&&n.generator?s(t):[],owner:e,targetOwner:n,yieldCount:k(n)&&n.generator&&a(t)?1:null})}if(!x(t,`Identifier`))return;let n=i(t);if(n===void 0)return;let r=F(t,e);if(!r)return;let o=Z(t);if(Af(t,o))return;let c=d.get(r.id)??[];c.push({node:t,owner:o,propertyNames:n,symbolId:r.id}),d.set(r.id,c)});let f=t=>{let n=Z(t),r=X(t),i=new Set,a=(e,t)=>{for(let n of u)n.owner!==e||X(n.call)>=t||i.has(n.targetOwner)||(i.add(n.targetOwner),a(n.targetOwner,1/0))};return a(n,r),x(n,`Program`)||a(e.rootScope.node,1/0),i},p=e=>{if(x(e,`Program`))return 1/0;let t=u.find(t=>x(t.owner,`Program`)&&t.targetOwner===e);return t?X(t.call):1/0},m=new Map;for(let e of u){let t=m.get(e.owner)??[];t.push(e),m.set(e.owner,t)}let h=new WeakMap,g=(e,t)=>{let n=h.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 m.get(e)??[])r.push(t.targetOwner)}}let o=h.get(e)??new WeakMap;return o.set(t,a),h.set(e,o),a},_=(e,t)=>{let n=new Set,r=e;for(;r?.parent&&r!==t;){let t=r.parent,i=x(t,`DoWhileStatement`)&&x(t.test,`Literal`)&&!t.test.value,a=x(t,`ForStatement`)||x(t,`ForInStatement`)||x(t,`ForOfStatement`)||x(t,`WhileStatement`)||x(t,`DoWhileStatement`)?t.body:null,o=e;for(;a&&x(a,`BlockStatement`)&&o&&o.parent!==a;)o=o.parent??null;let s=a&&x(a,`BlockStatement`)&&o?a.body.findIndex(e=>e===o):-1,c=!!(a&&x(a,`BlockStatement`)&&s>=0&&a.body.slice(s+1).some(e=>Df(e,!1)));a&&!i&&!c&&n.add(t),r=t}return n},v=(e,t,n)=>{let r=_(e,n);return r.size===0?!1:[..._(t,n)].some(e=>r.has(e))},y=new WeakMap,b=e=>{let t=y.get(e);if(t)return t;let n=new Map;for(let t of u){if(!g(t.targetOwner,e))continue;let r=n.get(t.owner)??[];r.push(t),n.set(t.owner,r)}return y.set(e,n),n},ee=(e,t)=>{let n=b(e),r=b(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&&(X(r.call)<X(t.call)||k(e)||v(r.call,t.call,e)))return!0}}return!1},te=e=>{let t=Z(e);if(x(t,`Program`))return!1;let n=u.filter(e=>x(e.owner,`Program`)&&g(e.targetOwner,t));return n.length===0?!1:n.length!==1||n[0]?.targetOwner!==t},ne=e=>{let t=Ef(e.node),n=t.parent;return!!(x(t,`Identifier`)&&n&&(x(n,`AssignmentExpression`)&&n.left===t||x(n,`UpdateExpression`)&&n.argument===t))},re=(t,n)=>{let r=T(t);if(x(r,`Identifier`)){let t=F(r,e);return t&&n.has(t.id)?n.get(t.id)??!1:null}if(x(r,`SequenceExpression`)){let e=r.expressions.at(-1);return e?re(e,n):null}if(x(r,`ConditionalExpression`)){let e=re(r.consequent,n),t=re(r.alternate,n);return e===null&&t===null?null:e===null||t===null?!0:e||t}if(x(r,`LogicalExpression`)){let e=re(r.left,n),t=re(r.right,n);return e===null?t===null?null:!0:r.operator===`&&`?t:e}return null},ie=(e,t)=>{let n=Ef(e.node).parent;if(!n||!x(n,`AssignmentExpression`)){t.delete(e.symbolId);return}let r=t.get(e.symbolId)??!1,i=null;n.operator===`||=`||n.operator===`??=`?i=r:(n.operator===`=`||n.operator===`&&=`)&&(i=re(n.right,t));let a=jf(e.node,e.owner);i===null?a?t.set(e.symbolId,!0):t.delete(e.symbolId):t.set(e.symbolId,a&&r||i)},ae=(t,n)=>{if(!k(t.targetOwner))return n;let r=new Map(n);for(let[i,a]of t.targetOwner.params.entries()){let o=x(a,`AssignmentPattern`)?a.left:a;if(!x(o,`Identifier`))continue;let s=t.argumentCall.arguments[i],c=s&&!x(s,`SpreadElement`)?T(s):null,l=null;if(x(a,`AssignmentPattern`)&&(!c||x(c,`Identifier`)&&c.name===`undefined`&&e.isGlobalReference(c)||x(c,`UnaryExpression`)&&c.operator===`void`)&&x(a,`AssignmentPattern`)?l=T(a.right):c&&(l=c),!x(l,`Identifier`))continue;let u=F(l,e);if(!u||!n.has(u.id))continue;let d=e.symbolFor(o);d&&r.set(d.id,n.get(u.id)??!1)}return r},oe=(t,n)=>{if(!k(t.targetOwner))return{conditionalSuspensions:[],conditionalStartIndex:1/0,cutoffIndex:1/0};let r=new Set;t.targetOwner.async&&(r.add(`AwaitExpression`),r.add(`ForOfStatement`));let i=t.conditionalExitTargets.some(e=>!n||!If(n,e));(t.yieldCount!==null||i)&&r.add(`YieldExpression`);let a=[],o=1/0,s=1/0,c=0;return z(t.targetOwner.body,n=>{if(Z(n)!==t.targetOwner||Af(n,t.targetOwner)||!(r.has(n.type)&&(!x(n,`ForOfStatement`)||n.await)))return;let l=x(n,`YieldExpression`)&&n.argument?T(n.argument):null;if(x(n,`YieldExpression`)&&n.delegate&&l&&(x(l,`ArrayExpression`)&&l.elements.length===0||x(l,`Literal`)&&l.value===``))return;let u=Rf(n);if(x(n,`YieldExpression`)){if(c+=1,i&&c>=1){o=Math.min(o,u);return}if(t.yieldCount===null||c>t.yieldCount)return}Ff(n,t.targetOwner,e)?(a.push(n),o=Math.min(o,u)):s=Math.min(s,u)}),{conditionalSuspensions:a,conditionalStartIndex:Math.min(o,s),cutoffIndex:s}},se=(e,t,n)=>{let r=(e,t,i)=>{if(t.has(e.targetOwner))return!1;let a=new Set(t);a.add(e.targetOwner);let o=new Map(ae(e,i)),s=oe(e),c=[...[...o.keys()].flatMap(e=>d.get(e)??[]).filter(t=>t.owner===e.targetOwner).map(e=>({event:e,index:X(e.node)})),...u.filter(t=>t.owner===e.targetOwner).map(e=>({call:e,index:X(e.call)}))].sort((e,t)=>e.index-t.index);for(let t of c){if(t.index>=s.cutoffIndex)break;let i=`event`in t?t.event.node:t.call.call;if(!s.conditionalSuspensions.some(t=>zf(t,i,e.targetOwner))){if(`event`in t){if(!o.has(t.event.symbolId))continue;if(ne(t.event)){ie(t.event,o);continue}if(n===null||t.event.propertyNames===null||t.event.propertyNames.has(n))return!0;continue}if(r(t.call,a,o))return!0}}return!1};return r(e,new Set,t)},ce={getEventsBefore:(t,n)=>{let r=[],i=(e,t,a,o,s,c,l)=>{if(s.has(e))return;let f=new Set(s);f.add(e);let p=new Map(l),m=[...[...p.keys()].flatMap(e=>d.get(e)??[]).filter(t=>t.owner===e).map(e=>({event:e,index:X(e.node)})),...u.filter(t=>t.owner===e).map(e=>({call:e,index:X(e.call)}))].sort((e,t)=>e.index-t.index);for(let s of m){if(s.index>=t)break;let l=`event`in s?s.event.node:s.call.call;if(o.some(t=>zf(t,l,e)))continue;if(`event`in s){if(!p.has(s.event.symbolId))continue;let e=!!(c||p.get(s.event.symbolId)||jf(s.event.node,s.event.owner)||s.index>a);if(ne(s.event)){ie(s.event,p);continue}r.push({isConditional:e,node:s.event.node});continue}let u=oe(s.call,n);i(s.call.targetOwner,u.cutoffIndex,u.conditionalStartIndex,u.conditionalSuspensions,f,c||jf(s.call.call,s.call.owner)||s.index>a,ae(s.call,p))}},a=Z(n),o=new Map([[t.id,!1]]);return x(a,`Program`)||i(e.rootScope.node,p(a),1/0,[],new Set,!1,o),i(a,X(n),1/0,[],new Set,!1,o),r},getOutermostTarget:Ef,isGlobalNamespaceMethod:n,isExecutionOrderAmbiguous:te,isMutationOrderAmbiguous:(e,t,n)=>{let r=Z(t),i=X(t);if((d.get(e.id)??[]).some(e=>n!==null&&e.propertyNames!==null&&!e.propertyNames.has(n)?!1:e.owner===r?X(e.node)>=i&&(k(r)||v(e.node,t,r)):x(e.owner,`Program`)?(b(r).get(e.owner)??[]).some(t=>v(e.node,t.call,e.owner)):g(e.owner,r)||ee(e.owner,r)))return!0;let a=new Map([[e.id,!1]]);return u.some(e=>e.owner===r&&X(e.call)>=i&&v(e.call,t,r)&&se(e,a,n))},isMutatedBefore:(e,t,n)=>{let r=d.get(e.id);if(!r)return!1;let i=X(t),a=Z(t),o=f(t);return r.some(e=>n!==null&&e.propertyNames!==null&&!e.propertyNames.has(n)?!1:e.owner===a?X(e.node)<i:x(e.owner,`Program`)&&!x(a,`Program`)?X(e.node)<p(a):o.has(e.owner))}};return Tf.set(e,ce),ce},Vf=(e,t)=>t===`katex`?e===`katex`||e.startsWith(`katex/`):e===t,Hf=(e,t,n)=>{let r=T(e);if(!x(r,`CallExpression`))return!1;let i=T(r.callee),a=r.arguments[0];return!!(x(i,`Identifier`)&&i.name===`require`&&n.isGlobalReference(i)&&a&&x(a,`Literal`)&&typeof a.value==`string`&&Vf(a.value,t))},Uf=(e,t)=>{if(e.kind!==`ts-import-equals`)return!1;let n=e.declarationNode;if(!x(n,`TSImportEqualsDeclaration`))return!1;let r=n.moduleReference;return!!(x(r,`TSExternalModuleReference`)&&x(r.expression,`Literal`)&&typeof r.expression.value==`string`&&Vf(r.expression.value,t))},Wf=(e,t)=>{let n=T(e);return!!(x(n,`AwaitExpression`)&&x(n.argument,`ImportExpression`)&&x(n.argument.source,`Literal`)&&typeof n.argument.source.value==`string`&&Vf(n.argument.source.value,t))},Gf=(e,t,n,r,i)=>{let a=F(T(e),i),o=Bf(i);if(!a||o.isExecutionOrderAmbiguous(r)||o.isMutationOrderAmbiguous(a,r,n)||o.isMutatedBefore(a,r,n))return null;let s=me(a);if(typeof s?.source.value==`string`&&Vf(s.source.value,t))return x(a.declarationNode,`ImportDefaultSpecifier`)||x(a.declarationNode,`ImportNamespaceSpecifier`)||S(a.declarationNode)===`default`?a:null;if(Uf(a,t))return a;if(a.kind!==`const`||!a.initializer)return null;let c=T(a.initializer);return Hf(c,t,i)||x(c,`MemberExpression`)&&w(c)===`default`&&(Hf(c.object,t,i)||Wf(c.object,t))||Wf(c,t)?a:null},Kf=(e,t,n,r,i)=>{let a=F(T(e),i);if(!a)return null;let o=me(a),s=Bf(i);return typeof o?.source.value!=`string`||!Vf(o.source.value,t)||S(a.declarationNode)!==n||s.isExecutionOrderAmbiguous(r)||s.isMutationOrderAmbiguous(a,r,null)||s.isMutatedBefore(a,r,null)?null:a},qf=(e,t,n)=>Gf(e,`katex`,`renderToString`,t,n)!==null||Hf(e,`katex`,n),Jf=(e,t,n)=>{if(Kf(e,`katex`,`renderToString`,t,n))return!0;let r=T(e);if(!x(r,`Identifier`))return!1;let i=n.referenceFor(r)?.resolvedSymbol;if(!i||i.kind!==`const`||!i.initializer||Bf(n).isMutatedBefore(i,t,null))return!1;let a=T(i.initializer),o=i.bindingIdentifier.parent;return x(o,`Property`)&&C(o,{allowComputedString:!0})===`renderToString`?qf(a,i.declarationNode,n):x(a,`MemberExpression`)&&w(a)===`renderToString`&&qf(a.object,i.declarationNode,n)?!0:x(a,`Identifier`)?Jf(a,i.declarationNode,n):!1},Yf=(e,t)=>{let n=T(e);if(x(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(!x(n,`MemberExpression`)||w(n)!==`renderToString`)return!1;let r=T(n.object);if(!x(r,`Identifier`)||!/katex/i.test(r.name))return!1;let i=t.referenceFor(r)?.resolvedSymbol;if(!i)return!1;if(i.kind===`import`){if(!Vf(String(me(i)?.source.value??``),`katex`))return!0;let e=Bf(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=T(i.initializer);if(x(a,`ObjectExpression`))return!0;if(x(a,`CallExpression`)){let e=T(a.callee);return x(e,`Identifier`)&&e.name===`require`}return x(a,`AwaitExpression`)&&x(a.argument,`ImportExpression`)},Xf=(e,t)=>{let n=T(e);if(!x(n,`ObjectExpression`))return null;let r;for(let e of n.properties){if(!x(e,`Property`)){r=null;continue}let n=C(e,{allowComputedString:!0});if(n===null){r=null;continue}n===t&&(r=e.kind===`init`?e.value:null)}return r},Zf=e=>{let t=T(e);if(!x(t,`ObjectExpression`))return null;for(let e of t.properties){if(!x(e,`Property`))return null;let t=C(e,{allowComputedString:!0});if(t===null||t===`get`||t===`set`)return null}return Xf(t,`value`)},Qf=new WeakMap,$f=(e,t)=>{let n=T(e);return x(n,`Identifier`)?n.name===`undefined`&&t.isGlobalReference(n):x(n,`Literal`)&&!n.value},ep=(e,t,n)=>{let r=Zf(t);return r===null?`trusted`:r===void 0?e:$f(r,n)?`untrusted`:`trusted`},tp=(e,t)=>e===t?e:e===`trusted`||t===`trusted`?`trusted`:e===`unsupported`||t===`unsupported`?`unsupported`:`untrusted`,np=(e,t,n,r)=>{let i=Bf(n),a=i.getOutermostTarget(t),o=a.parent;if(!o)return`unsupported`;if(x(o,`AssignmentExpression`)&&o.left===a){if(!x(a,`MemberExpression`))return`unsupported`;let t=w(a);return t===null?`trusted`:t===`trust`?$f(o.right,n)?`untrusted`:`trusted`:e}if(x(o,`UnaryExpression`)&&o.operator===`delete`){if(!x(a,`MemberExpression`))return`unsupported`;let t=w(a);return t===null?`trusted`:t===`trust`?`absent`:e}if(x(o,`UpdateExpression`)){if(!x(a,`MemberExpression`))return`unsupported`;let t=w(a);return t===`trust`||t===null?`trusted`:e}if(!x(o,`CallExpression`)||o.arguments[0]!==a)return`unsupported`;if(i.isGlobalNamespaceMethod(o.callee,`Object`,Cf)){let t=T(o.callee);if(!x(t,`MemberExpression`))return`unsupported`;let i=w(t);if(i===`assign`){let t=e;for(let e of o.arguments.slice(1)){let i=rp(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=Xf(t,`trust`);return r===null?`trusted`:r===void 0?e:ep(e,r,n)}let a=o.arguments[1];if(!a||!x(a,`Literal`)||typeof a.value!=`string`)return`trusted`;if(a.value!==`trust`)return e;let s=o.arguments[2];return s?ep(e,s,n):`unsupported`}if(i.isGlobalNamespaceMethod(o.callee,`Reflect`,wf)){let t=T(o.callee);if(!x(t,`MemberExpression`))return`unsupported`;let r=w(t),i=o.arguments[1];if(!i||!x(i,`Literal`)||typeof i.value!=`string`)return`trusted`;if(i.value!==`trust`)return e;let a=o.arguments[2];return a?r===`defineProperty`?ep(e,a,n):$f(a,n)?`untrusted`:`trusted`:`unsupported`}return`unsupported`},rp=(e,t,n,r)=>{if(e===void 0)return`absent`;let i=T(e);if(x(i,`Identifier`)){if(i.name===`undefined`&&n.isGlobalReference(i))return`absent`;let e=F(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=Bf(n);if(o.isMutationOrderAmbiguous(e,t,`trust`))return`unsupported`;let s=rp(e.initializer,t,n,a);for(let r of o.getEventsBefore(e,t)){let e=np(s,r.node,n,a);s=r.isConditional?tp(s,e):e}return s}if(!x(i,`ObjectExpression`))return`unsupported`;let a=`absent`;for(let e of i.properties){if(x(e,`SpreadElement`)){let t=rp(e.argument,e.argument,n,new Set(r));t!==`absent`&&(a=t===`unsupported`?`trusted`:t);continue}if(!x(e,`Property`)){a=`trusted`;continue}let t=C(e,{allowComputedString:!0});if(t===null){a=`trusted`;continue}t===`trust`&&(a=$f(e.value,n)?`untrusted`:`trusted`)}return a},ip=(e,t,n)=>{let r=Qf.get(e),i=new Map(r);for(let[e,n]of t)i.set(e,n);Qf.set(e,i);try{return n()}finally{r?Qf.set(e,r):Qf.delete(e)}},ap=(e,t,n,r)=>{let i=e?T(e):void 0;if(i&&x(i,`Identifier`)){let e=n.referenceFor(i)?.resolvedSymbol,t=e?Qf.get(n)?.get(e.id):void 0;if(t)return t}let a=rp(e,t,n,r);return{isSafe:a===`absent`||a===`untrusted`}},op={containsKatex:!1,isConclusive:!0,isSafe:!0,isSafeInAttributeContext:!0},sp={containsKatex:!1,isConclusive:!0,isSafe:!0,isSafeInAttributeContext:!1},Q={containsKatex:!1,isConclusive:!1,isSafe:!1,isSafeInAttributeContext:!1},cp={containsKatex:!0,isConclusive:!1,isSafe:!1,isSafeInAttributeContext:!1},lp={containsKatex:!0,isConclusive:!0,isSafe:!1,isSafeInAttributeContext:!1},up=new WeakMap,dp=new WeakMap,fp=(e,t,n)=>{up.set(e,t),dp.set(e,n)},pp=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)}),mp=(e,t)=>{let n=T(e);if(!x(n,`ObjectExpression`))return{isKnown:!1,value:null};let r=!0,i=null;for(let e of n.properties){if(!x(e,`Property`)){r=!1,i=null;continue}let n=C(e,{allowComputedString:!0});n===null?(r=!1,i=null):n===t&&(r=!0,i=e.value)}return{isKnown:r,value:i}},hp=(e,t)=>{let n=T(e);if(x(n,`Identifier`)){let e=F(n,t);return!!(e&&e.kind===`import`&&me(e)?.source.value===`react`&&S(e.declarationNode)===`useMemo`)}if(!x(n,`MemberExpression`)||w(n)!==`useMemo`)return!1;let r=F(T(n.object),t);return!!(r&&r.kind===`import`&&me(r)?.source.value===`react`&&(x(r.declarationNode,`ImportDefaultSpecifier`)||x(r.declarationNode,`ImportNamespaceSpecifier`)||S(r.declarationNode)===`default`))},gp=(e,t)=>{let n=e=>{let r=T(e);if(x(r,`Identifier`)){let e=F(r,t);return!e||e.kind!==`const`||!e.initializer||e.references.some(e=>e.flag!==`read`)?null:n(e.initializer)}return!x(r,`Literal`)||!(`regex`in r)||!r.regex?null:r.regex},r=e=>{let t=T(e);if(!k(t))return null;if(!x(t.body,`BlockStatement`))return t.body;if(t.body.body.length!==1)return null;let n=t.body.body[0];return n&&x(n,`ReturnStatement`)?n.argument:null},i=e=>{let n=T(e);if(!k(n)||n.params.length!==1)return!1;let i=n.params[0],a=r(n);if(!i||!x(i,`Identifier`)||!a||!x(a,`MemberExpression`)||!a.computed||!x(T(a.property),`Identifier`))return!1;let o=T(a.property);if(t.referenceFor(o)?.resolvedSymbol!==t.symbolFor(i)||!x(T(a.object),`Identifier`))return!1;let s=F(T(a.object),t);if(!s||s.kind!==`const`||!s.initializer||s.references.some(e=>e.flag!==`read`))return!1;let c=mp(s.initializer,`<`);if(!c.isKnown||!c.value||!x(T(c.value),`Literal`))return!1;let l=T(c.value);return x(l,`Literal`)?typeof l.value==`string`&&!l.value.includes(`<`)&&!l.value.includes(`$`):!1},a=T(e),o=!1;for(;x(a,`CallExpression`);){let e=T(a.callee);if(!x(e,`MemberExpression`))return!1;let t=w(e);if(t!==`replace`&&t!==`replaceAll`)return!1;let r=a.arguments[0],s=a.arguments[1];if(!r||!s||!(x(s,`Literal`)&&typeof s.value==`string`&&!s.value.includes(`<`)&&!s.value.includes(`$`))&&!i(s))return!1;let c=n(r),l=t===`replaceAll`&&x(r,`Literal`)&&r.value===`<`,u=!!c?.flags.includes(`g`)&&(c?.pattern===`<`||/^\[[^\]]*<[^\]]*\]$/.test(c?.pattern??``));(l||u)&&(o=!0),a=T(e.object)}return!o||!x(a,`Identifier`)?!1:t.referenceFor(a)?.resolvedSymbol?.kind===`parameter`},_p=(e,t)=>{let n=T(e.callee);return x(n,`MemberExpression`)&&w(n)===`sanitize`&&(Gf(n.object,`dompurify`,`sanitize`,e,t)||Gf(n.object,`isomorphic-dompurify`,`sanitize`,e,t))?sp:x(n,`MemberExpression`)&&w(n)===`escape`&&Gf(n.object,`html-escaper`,`escape`,e,t)||Kf(n,`html-escaper`,`escape`,e,t)?op:Kf(n,`dompurify`,`sanitize`,e,t)||Kf(n,`isomorphic-dompurify`,`sanitize`,e,t)?sp:null},vp=(e,t)=>{if(!t.isSafe)return null;let n=T(e.callee);if(!x(n,`MemberExpression`))return null;let r=w(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||!x(i,`Literal`)||typeof i.value!=`string`||i.value.includes(`<`)?null:{containsKatex:t.containsKatex,isConclusive:t.isConclusive,isSafe:!0,isSafeInAttributeContext:t.isSafeInAttributeContext&&!/[&>"']/.test(i.value)}},yp=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`},bp=(e,t,n,r)=>{let i=e.expressions.map(e=>$(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=yp(a),r=i[t]??Q;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}},xp=(e,t)=>{let n=e;for(;n.parent&&n!==t;){let e=n.parent;if(x(e,`BlockStatement`)){let t=e.body.findIndex(e=>e===n);if(t>0&&e.body.slice(0,t).some(e=>B(e)))return!0}if(x(e,`SwitchCase`)){let t=e.consequent.findIndex(e=>e===n);if(t>0&&e.consequent.slice(0,t).some(e=>B(e)))return!0}if(x(e,`IfStatement`)&&x(e.test,`Literal`)){let t=e.alternate,r=e.consequent,i=!!e.test.value;if(!i&&r===n||i&&t===n)return!0}if(x(e,`WhileStatement`)&&e.body===n){let t=e.test;if(x(t,`Literal`)&&!t.value)return!0}if(x(e,`ForStatement`)&&e.body===n){let t=e.test;if(t&&x(t,`Literal`)&&!t.value)return!0}n=e}return!1},Sp=(e,t,n,r=new Map)=>{if(!k(e))return Q;if(!x(e.body,`BlockStatement`))return $(e.body,t,n,r);let i=e.body,a=[];return z(i,e=>{if(e!==i&&k(e))return!1;if(x(e,`ReturnStatement`))return xp(e,i)||a.push(e.argument?$(e.argument,t,new Set(n),r):op),!1}),a.length===0?op:pp(a)},Cp=(e,t,n,r,i=new Map)=>{if(!k(e))return Q;let a=[];if(!x(e.body,`BlockStatement`))a.push(e.body);else{let t=e.body;z(t,e=>{if(e!==t&&k(e))return!1;x(e,`ReturnStatement`)&&e.argument&&!xp(e,t)&&a.push(e.argument)})}return a.length===0?Q:pp(a.map(e=>{let a=mp(e,t);if(a.isKnown&&a.value!==null)return $(a.value,n,new Set(r),i);let o=T(e);return x(o,`CallExpression`)?Ep(o,n,t)??Q:Q}))},wp=(e,t)=>{let n=T(e);if(!x(n,`Identifier`))return null;let r=F(n,t);if(!r||r.references.some(e=>e.flag!==`read`))return null;if(r.kind===`function`&&k(r.declarationNode))return{functionNode:r.declarationNode,symbol:r};if(r.kind!==`const`||!r.initializer)return null;let i=T(r.initializer);return k(i)?{functionNode:i,symbol:r}:null},Tp=(e,t,n,r)=>{let i=new Map;if(!k(e))return i;let a=(e,t)=>e===void 0||x(e,`Identifier`)&&e.name===`undefined`&&t.isGlobalReference(e)||x(e,`UnaryExpression`)&&e.operator===`void`,o=(e,t,n,a)=>a?ip(r,i,()=>ap(e,t,n,new Set)):ap(e,t,n,new Set);for(let[s,c]of e.params.entries()){let e=t.arguments[s],l=x(c,`AssignmentPattern`)&&a(e,n),u=l&&x(c,`AssignmentPattern`)?c.right:e,d=l?r:n,f=l?c:t,p=x(c,`AssignmentPattern`)?c.left:c;if(x(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(!(!x(p,`ObjectPattern`)||!u))for(let e of p.properties){if(!x(e,`Property`))continue;let t=C(e,{allowComputedString:!0});if(t===null)continue;let n=mp(u,t),s=x(e.value,`AssignmentPattern`)?e.value.left:e.value;if(!x(s,`Identifier`))continue;let c=r.symbolFor(s);if(!n.isKnown||!c||c.references.some(e=>e.flag!==`read`))continue;let l=x(e.value,`AssignmentPattern`)&&(n.value===null||a(n.value??void 0,d)),p=l&&x(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},Ep=(e,t,n)=>{let r=T(e.callee);if(!x(r,`Identifier`))return null;let i=F(r,t);if(!i||i.kind!==`import`)return null;let a=me(i),o=S(i.declarationNode),s=up.get(t),c=a?.source.value,l=dp.get(t)??0;if(!s||typeof c!=`string`||!o||l>=2)return null;let u=or(s,c,o);if(!u||!k(u.functionNode))return null;let d=_t(u.programNode);return fp(d,u.filePath,l+1),ip(d,Tp(u.functionNode,e,t,d),()=>n?Cp(u.functionNode,n,d,new Set):Sp(u.functionNode,d,new Set))},Dp=(e,t,n,r)=>{if(!x(e,`CallExpression`))return Q;let i=T(e.callee);if(x(i,`MemberExpression`)&&w(i)===`get`){let e=T(i.object);if(x(e,`Identifier`)){let i=F(e,t),a=i?.initializer?T(i.initializer):null,o=a&&x(a,`NewExpression`)?T(a.callee):null;if(i?.kind===`const`&&a&&x(a,`NewExpression`)&&x(o,`Identifier`)&&o.name===`Map`&&t.isGlobalReference(o)&&!n.has(i.id)){let e=new Set(n);e.add(i.id);let a=[],o=!1;for(let n of i.references){let i=n.identifier.parent;if(n.flag!==`read`||!i||!x(i,`MemberExpression`)||i.object!==n.identifier){o=!0;break}let s=w(i);if(s===`size`)continue;let c=i.parent;if(!c||!x(c,`CallExpression`)||c.callee!==i){o=!0;break}if(![`get`,`has`,`keys`,`values`,`entries`,`clear`,`delete`].includes(s??``)){if(s!==`set`||!c.arguments[1]){o=!0;break}a.push($(c.arguments[1],t,new Set(e),r))}}if(!o&&a.length>0)return pp(a)}}}if(x(i,`MemberExpression`)&&w(i)===`renderToString`&&qf(i.object,e,t)||Jf(i,e,t))return{containsKatex:!0,isConclusive:!0,isSafe:ap(e.arguments[1],e,t,new Set).isSafe,isSafeInAttributeContext:!1};let a=Ep(e,t);if(a?.containsKatex)return a;let o=wp(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=T(e);return k(i)?Sp(i,t,new Set(n),r):$(i,t,new Set(n),r)}),s=new Map,c=!1;if(k(o.functionNode))for(let[e,n]of o.functionNode.params.entries()){if(!x(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=ip(t,Tp(o.functionNode,e,t,t),()=>Sp(o.functionNode,t,i,s));return!a.some(e=>e.containsKatex)||l.containsKatex?l:c?cp:lp}if(Yf(i,t))return{containsKatex:!0,isConclusive:!0,isSafe:!1,isSafeInAttributeContext:!1};if(x(i,`MemberExpression`)){let a=$(i.object,t,new Set(n),r);if(a.containsKatex)return vp(e,a)||(a.isConclusive?{containsKatex:!0,isConclusive:!0,isSafe:!1,isSafeInAttributeContext:!1}:cp)}let s=_p(e,t);if(s)return s;if(gp(e,t))return sp;if(hp(i,t)){let i=e.arguments[0];if(!i)return Q;let a=T(i);if(k(a))return Sp(a,t,new Set(n),r);let o=wp(a,t);if(!o||n.has(o.symbol.id))return Q;let s=new Set(n);return s.add(o.symbol.id),Sp(o.functionNode,t,s,r)}return e.arguments.some(e=>{let i=T(e);return(k(i)?Sp(i,t,new Set(n),r):$(i,t,new Set(n),r)).containsKatex})?cp:Q},Op=(e,t)=>{let n=vf(e);if(x(n,`Literal`))return!!n.value;if(x(n,`Identifier`)&&(n.name===`undefined`||n.name===`NaN`)&&t.isGlobalReference(n))return!1;if(x(n,`TemplateLiteral`)){let e=Ht(n);return e===null?null:!!e}if(x(n,`ArrayExpression`)||x(n,`ObjectExpression`)||x(n,`ArrowFunctionExpression`)||x(n,`FunctionExpression`)||x(n,`ClassExpression`)||x(n,`NewExpression`)||x(n,`JSXElement`)||x(n,`JSXFragment`))return!0;if(x(n,`UnaryExpression`)){if(n.operator===`void`)return!1;if(n.operator===`typeof`)return!0;if(n.operator===`!`){let e=Op(n.argument,t);return e===null?null:!e}}return null},$=(e,t,n,r=new Map)=>{let i=T(e);if(x(i,`Literal`)||x(i,`UnaryExpression`)&&i.operator===`void`)return op;if(x(i,`Identifier`)){if((i.name===`undefined`||i.name===`NaN`)&&t.isGlobalReference(i))return op;let e=t.referenceFor(i)?.resolvedSymbol,a=e?r.get(e.id):void 0;if(a)return a;if(!e||n.has(e.id))return Q;let o=new Set(n);if(o.add(e.id),e.kind===`let`||e.kind===`var`){let n=[];e.initializer&&n.push(e.initializer);for(let t of e.references){if(t.flag===`read`)continue;let e=_o(t.identifier);if(!e)return Q;n.push(e)}return n.length===0?Q:pp(n.map(e=>$(e,t,new Set(o),r)))}return e.kind!==`const`||!e.initializer?Q:$(e.initializer,t,o,r)}if(x(i,`CallExpression`))return Dp(i,t,n,r);if(x(i,`MemberExpression`)){let e=w(i),a=T(i.object);if(e&&x(a,`Identifier`)){let i=t.referenceFor(a)?.resolvedSymbol,o=i?.initializer?T(i.initializer):null;if(i?.kind===`const`&&o&&x(o,`CallExpression`)){if(hp(o.callee,t)){let i=o.arguments[0],a=i?T(i):null;if(a&&k(a)){let i=Cp(a,e,t,new Set(n),r);if(i.containsKatex)return i}}let i=Ep(o,t,e);if(i?.containsKatex)return i}}return Q}if(x(i,`TemplateLiteral`))return bp(i,t,n,r);if(x(i,`ConditionalExpression`)){let e=Op(i.test,t);return e===null?pp([$(i.consequent,t,new Set(n),r),$(i.alternate,t,new Set(n),r)]):$(e?i.consequent:i.alternate,t,new Set(n),r)}if(x(i,`LogicalExpression`)){let e=i.operator===`??`?null:Op(i.left,t);if(e!==null)return $(i.operator===`&&`?e?i.right:i.left:e?i.left:i.right,t,new Set(n),r);let a=Sf(i);if(a.length===1)return $(a[0]??i,t,new Set(n),r);let o=[i.left,i.right].map(e=>$(e,t,new Set(n),r));return{...i.operator===`&&`?o[1]??Q:pp(a.map(e=>$(e,t,new Set(n),r))),containsKatex:o.some(e=>e.containsKatex)}}if(x(i,`BinaryExpression`)&&i.operator===`+`)return pp([$(i.left,t,new Set(n),r),$(i.right,t,new Set(n),r)]);if(x(i,`SequenceExpression`)){let e=i.expressions.at(-1);return e?$(e,t,n,r):Q}return Q},kp=e=>{let t=null;if(x(e,`JSXAttribute`)&&x(e.name,`JSXIdentifier`)&&e.name.name===`dangerouslySetInnerHTML`&&x(e.value,`JSXExpressionContainer`)&&x(e.value.expression,`ObjectExpression`)&&(t=e.value.expression),x(e,`Property`)&&C(e,{allowComputedString:!0})===`dangerouslySetInnerHTML`&&x(T(e.value),`ObjectExpression`)&&(t=T(e.value)),!x(t,`ObjectExpression`))return null;let n=null;for(let e of t.properties){if(x(e,`SpreadElement`)){n=null;continue}if(!x(e,`Property`)){n=null;continue}let t=C(e,{allowComputedString:!0});if(t===null){n=null;continue}t===`__html`&&(n=e.value)}return n},Ap=(e,t)=>{let n=mn({filename:t,sourceText:e});if(n===null)return[];let r=_t(n);fp(r,t,0);let i=[];return z(n,e=>{let t=kp(e);if(t===null)return;let n=$(t,r,new Set);if(!n.containsKatex)return;let a=X(e),o=_f(e);a<0||o<0||i.push({endIndex:o,proof:n,startIndex:a})}),i},jp=/dangerouslySetInnerHTML|(?:\.(?:inner|outer)HTML|\[\s*["'](?:inner|outer)HTML["']\s*\])\s*[+]?=(?!=)|\.insertAdjacentHTML\s*\(|\bdocument\.write(?:ln)?\s*\(|\.(?:createContextualFragment|setHTMLUnsafe)\s*\(/,Mp=/(?:__html\s*:|(?:\.(?:inner|outer)HTML|\[\s*["'](?:inner|outer)HTML["']\s*\])\s*[+]?=(?!=)|\.insertAdjacentHTML\s*\(\s*[^,]*,|\bdocument\.write(?:ln)?\s*\(|\.(?:createContextualFragment|setHTMLUnsafe)\s*\()\s*([\s\S]*)/,Np=/searchParams|query|params|request|req\.|response\.|await|fetch|props\.|children|(?:user|untrusted|unsafe|raw|comment|message|cms|remote|external)\.|(?:user|untrusted|unsafe|raw|comment|message|cms|remote|external|content|profile|signature|subtitle)\w*(?:html|markup)|(?:html|markup)\w*(?:input|payload)|\b(?:load|read|receive|decode)\w*\s*\(|\bget\w*(?:Html|Markup|Content|Page|Message)\b|\blocation\b|document\.cookie|\breferrer\b|\blocalStorage\b|\bsessionStorage\b|URLSearchParams|window\.name/i,Pp=/^(?:"(?:\\.|[^"\\\n])*"|'(?:\\.|[^'\\\n])*'|`[^`$]*`)\s*(?:\/\/[^\n]*)?\s*(?:[;,})\n]|$)/,Fp=/^[A-Z][A-Z0-9_]*\s*(?:\/\/[^\n]*)?\s*(?:[;,})\n]|$)/,Ip=/^[\w$]+(?:\??\.[\w$]+)*\??\.(?:inner|outer)HTML\b/,Lp=/\b(?:DOMPurify|sanitize\w*|purify|(?:escape|encode)[A-Za-z]*(?:Html|HTML|Entit\w*)|insane|xss)\b|(?<!un)safe|(?<!un)saniti[sz]/i,Rp=/[:=]\s*[^\n;]*\b(?:DOMPurify\b|sanitize\w*\s*\(|purify\w*\s*\()/i,zp=/=\s*[\w$.?[\]]*\.(?:inner|outer)HTML\s*(?:[;,)\n]|$)/,Bp=/process\.env/,Vp=/\b(?:t|i18n|translate|formatMessage|intl)\s*[.(]/,Hp=/^(?:[\w$.]+\.)?(?:toHtml|render[A-Za-z]*(?:Html|HTML)|renderToString|renderToStaticMarkup|codeToHtml|codeToHast|highlight[A-Za-z]*)\s*\(/,Up=/\b(?:shiki|prism|hljs|highlightjs|getHighlighter|codeToHtml|codeToHast|refractor|lowlight|starry-night)\b|highlight\.js/i,Wp=/[:=]\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,Gp=/\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,Kp=/^[\w$]+\s*(?:[;,})\n]|$)/,qp=/^[\w$]+\s*(?:\|\||\?\?)\s*(?:"[^"\n]*"|'[^'\n]*'|`[^`$]*`)\s*(?:[;,})\n]|$)/,Jp=/^[\w$]+(?:\.[\w$]+|\[[^\]]*\])+\s*(?:[;,})\n]|$)/,Yp=/<style\b[^<>]*$/,Xp=/(?:^|\/)emails(?:\/|$)|email[-_.]templates?(?:\/|$)|RawHtml|[A-Za-z]*[Ee]mail[A-Za-z]*\.(?:t|j)sx?/i,Zp=/(?:^|\/)\.[\w-]+\//,Qp=/(?<!un)saniti[sz]e?d?[\w-]*\.[cm]?[jt]sx?$/i,$p=/(?:^|[^\w$.])([\w$]+(?:\.[\w$]+)*)(?:(?:\.(?:inner|outer)HTML|\[\s*["'](?:inner|outer)HTML["']\s*\])\s*[+]?=(?!=)|\.insertAdjacentHTML\s*\()/,em=/\b(?:appendChild|append|prepend|before|after|replaceWith|replaceChild|replaceChildren|insertBefore|insertAdjacentElement)\s*\(/,tm=5e3,nm=e=>{if(!e.startsWith("`"))return null;let t=e.indexOf("`",1);if(t<0||t>tm)return null;let n=e.slice(1,t).match(/\$\{[^}]*\}/g);return n===null?``:n.join(` `)},rm=(e,t,n)=>{let r=um(e,t,n);return r===null?null:n.slice(r.initializerStartIndex,r.initializerStartIndex+tm)},im=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)},am=(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(`${em.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)},om=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},sm=e=>{let t=e.replace(/[;}]\s*$/,``).trim();if(!t.includes(`+`))return!1;let n=[];for(let e of om(t)){let t=e.trim();t.length>0&&n.push(t)}return n.length<2?!1:n.every(e=>{let t=e.replace(/\(\s*([\w$]+(?:\??\.[\w$]+)*)\s+as\s+[^)]*\)/g,`$1`);return Ip.test(t)?!Np.test(t.replace(Ip,``)):!1})},cm=(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},lm=(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===`
|
|
10
|
-
`&&(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:cm(e,o)},um=(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||lm(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},dm=(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)},fm=(e,t,n)=>{if(!/highlight/i.test(e))return!1;let r=e.match(/^([\w$]+)/)?.[1];if(r===void 0)return!1;let i=um(r,n,t);return i===null?/highlighted/i.test(e)||Up.test(t):dm(r,i,n,t)&&Gp.test(i.initializer)},pm=(e,t,n,r=new Set)=>{let i=e.trim(),a=om(i);if(a.length>1)return a.every(e=>pm(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=>pm(e,t,n,r));let s=i.match(/^([\w$]+)(?:(?:\??\.[\w$]+)|(?:\[\s*(?:"[^"\n]*"|'[^'\n]*'|\d+)\s*\]))*$/)?.[1];if(s&&!r.has(s)){let e=um(s,n,t);if(e&&dm(s,e,n,t)){let n=new Set(r);return n.add(s),pm(e.initializer,t,e.initializerStartIndex,n)}}return!!(Pp.test(`${i};`)||Fp.test(`${i};`)||Lp.test(i)||Bp.test(i)||Vp.test(i)||Hp.test(i)||fm(i,t,n))},mm=(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=um(a,n,r);if(!o?.isImmutable)return!1;let s=new Set(i);return s.add(a),mm(o.initializer,t,o.initializerStartIndex,r,s)},hm=(e,t,n)=>{let r=n.slice(Math.max(0,t-tm),t),i=J(e);return RegExp(`(?:function\\s+[\\w$]+|(?:const|let|var)\\s+[\\w$]+\\s*=)\\s*\\(\\s*\\{[^}]*\\b${i}\\b[^}]*\\}`).test(r)},gm=(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=cm(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},_m=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},vm=(e,t,n,r=new Set)=>{let i=e.trim().match(/^([\w$]+)$/)?.[1];if(i===void 0||r.has(i))return!1;if(gm(i,t,n)!==null)return!0;let a=um(i,t,n);if(!a||!dm(i,a,t,n))return!1;let o=new Set(r);return o.add(i),vm(a.initializer,a.initializerStartIndex,n,o)},ym=(e,t,n,r,i)=>{let a=e.trim();if(pm(a,t,n))return!1;let o=a.match(/^([\w$]+)(?:\.|\s*(?:(?:\|\||\?\?)|[;,})\n]|$))/)?.[1];if(o===void 0)return Np.test(a);if(hm(o,n,t))return!0;if(r.has(o))return!1;r.add(o);let s=um(o,n,t),c=gm(o,n,t);if(s!==null&&(c===null||s.declarationIndex>c.declarationNameIndex))return dm(o,s,n,t)&&pm(s.initializer,t,s.initializerStartIndex)?!1:!dm(o,s,n,t)||ym(s.initializer,t,s.initializerStartIndex,r,i)?!0:vm(s.initializer,s.initializerStartIndex,t)?!1:Np.test(a);if(c!==null&&c.functionName.length>0){let e=RegExp(`\\b${J(c.functionName)}\\s*\\(`,`g`),n=!1;for(let a of t.matchAll(e)){if(a.index===c.declarationNameIndex||i.has(a.index))continue;let e=a.index+a[0].lastIndexOf(`(`),s=gf(t,e);if(s<0)continue;let l=_m(t.slice(e+1,s))[c.parameterIndex];if(l===void 0||a.index>=c.declarationNameIndex&&a.index<=c.bodyEndIndex&&mm(l,o,a.index,t))continue;n=!0;let u=new Set(r);u.delete(o);let d=new Set(i);if(d.add(a.index),ym(l,t,a.index,u,d))return!0}if(n)return!1;let s=t.slice(Math.max(0,c.declarationNameIndex-48),c.declarationNameIndex);return/\bexport\s+(?:(?:default\s+)?(?:async\s+)?function|const|let|var)\s+$/.test(s)?!0:Np.test(a)}return Np.test(a)},bm=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)||Xp.test(e.relativePath)||Zp.test(e.relativePath)||Qp.test(e.relativePath)||!jp.test(e.content))return[];let t=Ap(e.content,e.absolutePath),n=[],r=e.content.split(`
|
|
11
|
-
`);for(let i=0;i<r.length;i+=1){let a=r[i]??``;if(!jp.test(a))continue;let o=a.slice(0,a.search(jp)).replace(/"[^"]*"|'[^']*'|`[^`]*`/g,``);if(/(?:^|[^:])\/\//.test(o)||/^\s*[/*]/.test(a))continue;let s=r.slice(i,i+1+4).join(`
|
|
12
|
-
`),c=Mp.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(`
|
|
13
|
-
`).length+ +(i>0)+a.search(jp),m=t.find(e=>p>=e.startIndex&&p<e.endIndex)?.proof;if(m?.isConclusive&&m.isSafe)continue;let h=m?.isConclusive===!0;if(Pp.test(f)||Fp.test(f))continue;if(Ip.test(f)&&!f.includes(`+`)){let e=f.replace(Ip,``);if(!Np.test(e))continue}if(sm(f))continue;let g=Mp.exec(r.slice(i,i+1+60).join(`
|
|
14
|
-
`))?.[1]?.trimStart(),_=nm(g??l),v=Kp.test(f)||Jp.test(f)||qp.test(f)?f.match(/^[\w$]+/)?.[0]:void 0;if(_===null&&v!==void 0&&Kp.test(f)&&gm(v,p,e.content)===null){let t=rm(v,p,e.content);if(t!==null){if(im(t))continue;_=nm(t)}}if(_===``)continue;let y=_??f,b=om(y).length>1||(_?.match(/\$\{/g)?.length??0)>1;if(!h&&!b&&Lp.test(y)||!b&&Bp.test(y)||!b&&Vp.test(y)||!h&&!ym(y,e.content,p,new Set,new Set)||!h&&Hp.test(f)||!h&&fm(f,e.content,p))continue;if(v!==void 0){let t=J(v),n=um(v,p,e.content),r=n?.initializer;if(!(r!==void 0&&(om(r).length>1||(r.match(/\$\{/g)?.length??0)>1))){let i=RegExp(`\\b${t}\\b\\s*${Wp.source}`,`i`);if(!h&&(r===void 0?i.test(e.content):n!==null&&dm(v,n,p,e.content)&&Gp.test(r)))continue;let a=RegExp(`\\b${t}\\b\\s*${Rp.source}`,`i`);if(!h&&(r===void 0?a.test(e.content):n!==null&&dm(v,n,p,e.content)&&Rp.test(`=${r}`)))continue}if(RegExp(`\\b${t}\\b\\s*${zp.source}`).test(e.content)||RegExp(`highlight[\\w$]*\\s*\\.map\\(\\s*(?:async\\s+)?\\(?\\s*${t}\\b`,`i`).test(e.content)&&Up.test(e.content))continue}if(Jp.test(f)){let t=f.match(/\.([\w$]+)\s*(?:[;,})\n]|$)/)?.[1];if(t!==void 0&&RegExp(`\\b${J(t)}\\s*:\\s*${Vp.source}`).test(e.content))continue}let ee=$p.exec(a),te=ee?.[1]??ee?.[2];if(te!==void 0&&am(te,e.content))continue;let ne=r.slice(Math.max(0,i-5),i+1).join(`
|
|
15
|
-
`).slice(0,-a.length+a.search(jp));Yp.test(ne)||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}}),xm=e=>!(!K(e)||eu.test(e)||nu.test(e)),Sm=/firebase|firestore|supabase|\b(?:setDoc|addDoc)\s*\(/i,Cm=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=>xm(e.relativePath)&&(Sm.test(e.content)||Sm.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.`})}),wm=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=>bu(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.`})}),Tm=W({id:`firebase-query-filter-as-auth`,defaultEnabled:!1,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=>xm(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.`})}),Em=/api\.github\.com|github\.com|gitlab\.com|bitbucket\.org/gi,Dm=/\$\{([^}]*)\}/g,Om=/\b(?:params|searchParams|query|req|request|input|payload)\s*[.[]|\buntrusted|\bdecodeURI\w*/,km=/encodeURIComponent\s*\(/,Am=/^\s*[\w$]+\.toString\(\)\s*$/,jm=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(Em)){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(Dm)).some(e=>{let t=e[1]??``;return Om.test(t)&&!km.test(t)&&!Am.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}}),Mm=/child_process|childProcess|execa|subprocess|Deno\.run/,Nm=/(?:\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*["'])/,Pm=/(?:\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*["'])/,Fm=`Imported metadata, uploads, or plugin manifests appear to reach code execution.`,Im=q({shouldScan:()=>!0,pattern:Nm,ignoreStringLiterals:!0,message:Fm}),Lm=q({shouldScan:()=>!0,pattern:Pm,ignoreStringLiterals:!0,message:Fm}),Rm=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)?Mm.test(e.content)?Im(e):Lm(e):[]}),zm=/createHash\s*\(\s*["'](?:md5|sha1)["']|\bmd5\s*\(/gi,Bm=/\b(?:password|token|secret|signature|signing|auth|credential|session|cookie|csrf|api.?key)\b/i,Vm=/(?<!cipher\.)\bcreate(?:Cipher|Decipher)\s*\(/,Hm=/\bcreate(?:Cipher|Decipher)iv\s*\(\s*["'](?:des|des3|des-?ede3?|rc4|rc2|bf|blowfish)\b/i,Um=/\b(?:DES|RC4|Blowfish)\b/,Wm=/\b(?:cipher|decipher|encrypt|decrypt|crypto)\b/i,Gm=/[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,Km=/(?:===?|!==?)\s*[A-Z](?:[a-z]|[A-Z0-9_]*\b(?!\s*[.(]))|^[A-Z](?:[a-z]|[A-Z0-9_]*\b(?!\s*[.(]))[\w$.]*(?:\([^)]*\))?\s*(?:===?|!==?)/,qm=/signature(?:Method|Type|Status|Algorithm|Kind|Mode|Version)\b/i,Jm=/(?:===?|!==?)\s*(?:true|false|null|undefined)\b/,Ym=/\.(?:length|size|byteLength)\s*(?:===?|!==?)|\.(?:length|size|byteLength)\s*$/,Xm=/\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,Zm=/\.[cm]?[jt]sx$/i,Qm=/timingSafeEqual|timing.?safe/i,$m=/gravatar|digest[-_ ]?auth|oauth[-_ ]?1|pkcs#?12|smime|\b_id\b|\betag\b|checksum|cache[-_ ]?key|fingerprint/i,eh=/token|secret|password|nonce|salt|csrf|credential|otp/i,th=/(?:focus|render|refresh|remount|redraw|animation|layout|cache|update)[-_]?nonce/i,nh=/Math\.random\s*\(/g,rh=/createHash|md5|cipher|encrypt|decrypt|crypto|signature|Math\.random/i,ih=(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},ah=(e,t,n,r)=>{for(let i of e.matchAll(t)){let t=e.lastIndexOf(`
|
|
16
|
-
`,i.index)+1,a=e.indexOf(`
|
|
17
|
-
`,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},oh=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)||iu.test(e.relativePath)||$m.test(e.relativePath)||!rh.test(e.content))return[];let t=Ru(e),n=ih(t,zm,Bm,$m);if(n<0&&(n=t.search(Hm)),n<0&&(n=t.search(Vm)),n<0&&Wm.test(t)&&(n=t.search(Um)),n<0&&!Qm.test(t)&&!Zm.test(e.relativePath)&&Xm.test(t)){let e=Gm.exec(t);e!==null&&!Km.test(e[0])&&!qm.test(e[0])&&!Jm.test(e[0])&&!Ym.test(e[0])&&(n=e.index)}if(n<0&&(n=ah(t,nh,eh,th)),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}]}}),sh=`(?<![A-Za-z0-9])(?:session|sess|sid|connect\\.sid|auth|jwt|access[_-]?token|refresh[_-]?token|id[_-]?token)(?![A-Za-z0-9])`,ch=`[\`"'][^\`"']*?${sh}[^\`"']*[\`"']`,lh=RegExp(`(?:\\.cookies\\.set|cookies\\(\\s*\\)\\.set|\\.cookie)\\s*\\(\\s*${ch}`,`gi`),uh=/httpOnly\s*:\s*false\b/i,dh=/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|`(?:[^`\\]|\\.)*`/g,fh=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!==`
|
|
18
|
-
`&&(t[n]=` `),n+=1;continue}(i===`"`||i===`'`||i==="`")&&(r=i),n+=1}return t.join(``)},ph=/cookie\s*:\s*\{/gi,mh=RegExp(`document\\.cookie\\s*=\\s*[\`"'][^\`"'=;]*?${sh}[^\`"'=;]*=`,`gi`),hh=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},gh=(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})}},_h=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=Ru(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.`;lh.lastIndex=0;for(let e=lh.exec(t);e!==null;e=lh.exec(t)){let i=e.index+e[0].lastIndexOf(`(`),a=gf(t,i);if(a<0)continue;let o=t.slice(i+1,a),s=hh(o)<3,c=o.replace(dh,``);if(!s&&!uh.test(c))continue;let l=G(t,e.index);n.push({message:r,line:l.line,column:l.column})}let i=fh(t);ph.lastIndex=0;for(let e=ph.exec(i);e!==null;e=ph.exec(i)){let t=e.index+e[0].length-1,a=gf(i,t),o=a>=0?i.slice(t,a):i.slice(t,t+400);if(!uh.test(o))continue;let s=G(i,e.index);n.push({message:r,line:s.line,column:s.column})}return gh(t,mh,r,()=>!0,n),n}}),vh=/\b(?:alg|algorithms?)\s*:\s*\[?\s*["'`]none["'`]/gi,yh=(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},bh=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=Ru(e);if(!/\bjwt\b|jsonwebtoken|\bjose\b/i.test(t))return[];let n=[];vh.lastIndex=0;for(let e=vh.exec(t);e!==null;e=vh.exec(t)){if(yh(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}}),xh=/PRIVATE KEY|SSH_PRIVATE_KEY|GPG_PRIVATE_KEY|DEPLOY_KEY|SIGNING_KEY/i,Sh=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=>!tu.test(e.relativePath)&&!au.test(e.relativePath)&&xh.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.`})}),Ch=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(?:Access-Control-Allow-Origin|websocket|WebSocket|(?:127\.0\.0\.1|localhost)(?=[\s\S]{0,700}\b(?:UpdateApp|InstallApp)\b)|(?:127\.0\.0\.1|localhost)[\s\S]{0,350}\b(?:onmessage|message|request|req)\b)\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.`})}),wh=/\bfrom\s+["']@modelcontextprotocol\/sdk[^"']*["']|\bMcpServer\b|\bMcpAgent\b/,Th=/@modelcontextprotocol\/sdk|\bMcpServer\b|\bMcpAgent\b/,Eh=/\bserver\.\s*tool\s*\(|\bregisterTool\s*\(|\bsetRequestHandler\s*\(\s*CallToolRequestSchema/,Dh=/\b(?:tool|registerTool|setRequestHandler)\b/,Oh=W({id:`mcp-tool-capability-risk`,defaultEnabled:!1,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)&&Th.test(e.content)&&Dh.test(e.content)&&lu.test(e.content),pattern:Eh,requireAll:[wh,lu],ignoreStringLiterals:!0,message:`An MCP tool/resource/prompt handler appears to expose file, shell, network, or code-execution capability.`})}),kh=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.`})}),Ah=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=>hu(e.relativePath,$l),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."})}),jh=[...td.filter(e=>!e.test(`service_role`)),nd],Mh=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=kd(e.content)??jh.find(t=>t.test(e.content));if(t===void 0)return[];let n=Jl(e.content,t);return[{message:`Package metadata contains secret-like values or public env secret names.`,line:n.line,column:n.column}]}}),Nh=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)&&!sf(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.`})}),Ph=/\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,Fh=/\b(?:curl|wget)\b(?=(?:[^\r\n]|\\\r?\n)*https?:\/\/)(?:[^\r\n]|\\\r?\n)*?\|\s*(?:bash|sh)\b/i,Ih=/sha(?:256|512|1)sum|--checksum|checksum=|EXPECTED_SHA|gpg\s+--verify|\.sha(?:256|512)\b/i,Lh=/\b(?:child_process|childProcess|execa|os\.system|subprocess\.|Deno\.run|autoUpdater|electron-updater)\b|\b(?:exec(?:File)?(?:Sync)?|spawn(?:Sync)?)\s*\(/,Rh=/.\/\.github\/workflows\//i,zh=/(?:^|\/)[\w-]+[.@-]\d+\.\d+\.\d+(?:[-.][\w.]+)?\//,Bh=e=>pu(e)&&!Rh.test(e)&&!zh.test(e)&&!iu.test(e),Vh=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)&&!Bh(e.relativePath))return[];let t=Ru(e),n=Fh.test(t);if(!n&&!Ph.test(t))return[];let r=n?Fh:Ph;if(Ih.test(t)||Zl.test(e.relativePath)&&!Lh.test(t))return[];let i=Jl(t,r);return[{message:`Code appears to download, install, update, or execute plugin/updater content across a trust boundary.`,line:i.line,column:i.column}]}}),Hh=/origin(?!al)|\.source\s*[!=]==?/i,Uh=/\b(?:event|e|evt|msg|message)\.data\b/,Wh=/\b(?:const|let|var)\s+[^;=]*=\s*$/,Gh=/port\d?\b|worker|channel|broadcast|socket|\bws\b|\bsse\b|eventsource|^_?self\.|^source\./i,Kh=String.raw`=\s*new\s+(?:EventSource|WebSocket|Worker|SharedWorker|BroadcastChannel|MessageChannel)\b`,qh=(e,t)=>{let n=/^[\w$]+/.exec(e)?.[0];return n===void 0?!1:RegExp(`(?<![\\w$.])${J(n)}\\s*${Kh}`).test(t)},Jh=(e,t)=>{let n=/^[\w$]+/.exec(e)?.[0];return n===void 0?!1:RegExp(`(?:^|[(,{;]\\s*)${J(n)}\\s*[?!]?\\s*:\\s*(?:Worker|SharedWorker|MessagePort|BroadcastChannel|WebSocket|EventSource)\\b`,`m`).test(t)},Yh=/worker/i,Xh=(e,t)=>{let n=X(t),r=_f(t);return n<0||r<0?``:e.slice(n,r)},Zh=(e,t)=>{if(t.type===`CallExpression`){let n=O(t.callee)?Xh(e,t.callee):``;if(!n.endsWith(`addEventListener`))return null;let r=t.arguments[0];return O(r)&&r.type===`Literal`&&r.value===`message`?n:null}if(t.type===`AssignmentExpression`&&O(t.left)){let n=Xh(e,t.left);return n.endsWith(`.onmessage`)?n:null}return null},Qh=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)||Yh.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=mn({filename:e.absolutePath,sourceText:e.content,shouldAttachParentReferences:!1});if(r===null)return[];let i=[];return z(r,t=>{let n=Zh(e.content,t);if(n===null||Gh.test(n)||qh(n,e.content)||Jh(n,e.content))return;let r=Xh(e.content,t),a=r.search(Uh);if(a<0)return;let o=r.search(Hh);if(o>=0&&(Wh.test(r.slice(0,a))||o<a))return;let s=G(e.content,X(t));i.push({message:`A message event handler reads cross-window messages without an obvious origin check.`,line:s.line,column:s.column})}),i}}),$h=/(?:^|\/)(?:locales?|i18n|lang|langs|translations?)\//i,eg=/(?:^|\/)(?:\.env(?:\.[^/]*)?|(?:debug|crash|trace|stack[-_]?trace|report|dump|phpinfo)(?:[-_.][^/]*)?\.(?:txt|log|json|html?)|[^/]+\.log)$/i,tg=e=>fu(e,su.test(e))&&!$h.test(e)&&eg.test(e),ng=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(!tg(e.relativePath))return[];let t={message:`A browser-reachable debug, log, dump, report, or env artifact is present.`,line:1,column:1};return[td.some(t=>t.test(e.content))?{...t,severity:`error`}:t]}}),rg=/(?:^|\/)docs?\//i,ig=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(!xm(e.relativePath)||rg.test(e.relativePath))return[];let t=kd(e.content);if(t===void 0)return[];let n=Jl(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}]}}),ag=`(?:"[^"\\n]{0,200}"|'[^'\\n]{0,200}'|\`[^\`$]{0,200}\`)`,og=`\\s*\\(?\\s*(?:${ag}|(?:[\\w\$]+(?:\\.[\\w\$]+)*\\.escape(?:Id|Literal|Identifier)|(?:[\\w\$]+\\.)*(?:connection|conn|client|pool|db|mysql|sqlstring|knex)\\.escape)\\s*\\([^()]{0,200}\\))\\s*\\)?`,sg=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=>cf(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*${ag}(?:\\s*\\+${og})*\\s*\\+(?!${og})`,`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.`})}),cg=e=>Xl.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),lg=e=>/(?:^|\/)\.env(?:\.[^./]+)*\.(?:example|sample|template|dist|defaults?)$|(?:^|\/)[^/]*(?:example|sample|template)[^/]*\.(?:env|json|pem|key)$/i.test(e),ug=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(!cg(e.relativePath)||lg(e.relativePath)||tu.test(e.relativePath))return[];let t=td.find(t=>t.test(e.content))??kd(e.content);if(t===void 0)return[];let n=Jl(e.content,t);return[{message:`A repository credential/config file contains secret-looking values.`,line:n.line,column:n.column}]}}),dg=`(?:req|request|ctx\\.req|ctx\\.request)\\.(?:body|query|params)|await\\s+(?:req|request)\\.json\\(\\s*\\)`,fg=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*(?:${dg})`,`i`),RegExp(`(?:Object\\.assign\\s*\\(|_\\.(?:merge|mergeWith|defaultsDeep)\\s*\\(|(?:^|[^.\\w])(?:merge|defaultsDeep)\\s*\\()[\\s\\S]{0,80}?(?:${dg})`,`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.`})}),pg=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.`})}),mg=(e,t)=>{let n=null;if(x(e,`Program`)?n=e.body:(x(e,`FunctionDeclaration`)||x(e,`FunctionExpression`)||x(e,`ArrowFunctionExpression`))&&x(e.body,`BlockStatement`)&&(n=e.body.body),n===null)return!1;for(let e of n){if(!x(e,`ExpressionStatement`)||e.directive===void 0)return!1;if(e.directive===t)return!0}return!1},hg=(e,t=`source.tsx`)=>{let n=mn({filename:t,sourceText:e,shouldAttachParentReferences:!1});return n===null?!1:mg(n,`use server`)},gg=q({shouldScan:e=>xm(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.`}),_g=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=gg(e);return t.length===0?t:hg(e.content,e.relativePath)?[]:t}}),vg=e=>/(?:^|\/)supabase\/(?:migrations|schemas)\//.test(e),yg=e=>e.endsWith(`.sql`)||vg(e),bg=/^\$[A-Za-z_]?\w*\$/,xg=new Set([`do`,`plpgsql`,`sql`,`plpython3u`,`plpythonu`,`plperl`,`plperlu`,`plv8`]),Sg=(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()},Cg=(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]!==`
|
|
19
|
-
`&&(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]!==`
|
|
20
|
-
`;)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]!==`
|
|
21
|
-
`&&(t[i]=` `),i+=1}continue}i+=1}},wg=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]!==`
|
|
22
|
-
`;)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]!==`
|
|
23
|
-
`&&(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]!==`
|
|
24
|
-
`&&(t[n]=` `),n+=1}continue}if(r===`$`){let r=bg.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=Sg(e,n);if(xg.has(s))Cg(e,t,n+i.length,o);else for(let r=n;r<o;r+=1)e[r]!==`
|
|
25
|
-
`&&(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(``)},Tg=/disable\s+row\s+level\s+security/i,Eg=/auth\.role\(\)\s*=\s*["']service_role["']/i,Dg=/create\s+policy/gi,Og=/;|create\s+policy/i,kg=/\b(?:using|with\s+check)\s*\(\s*true\s*\)/i,Ag=/\bfor\s+select\b/i,jg=/\bto\s+([\s\S]+?)(?=\s+(?:using|with\s+check|as|for)\b|;|$)/i,Mg=new Set([`service_role`,`postgres`,`supabase_admin`]),Ng=e=>{let t=jg.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=>Mg.has(e))},Pg=(e,t)=>Eg.test(t)?!0:!kg.test(e)||Ag.test(e)?!1:!Ng(e),Fg=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(!yg(e.relativePath))return[];let t=wg(e.content),n=t.search(Tg);Dg.lastIndex=0;for(let r=Dg.exec(t);r!==null;r=Dg.exec(t)){let i=r.index+r[0].length,a=t.slice(i).search(Og),o=a<0?t.length:i+a;if(Pg(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}]}}),Ig=/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,Lg=/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,Rg=/\benable\s+row\s+level\s+security\b/gi,zg=e=>{let t=new Map,n=0;for(let r of e.matchAll(Lg)){let e=r[1];e!==void 0&&(n+=1,t.set(e.toLowerCase(),r.index))}return{lastEnableIndexByTable:t,staticEnableCount:n}},Bg=(e,t)=>(e.match(Rg)?.length??0)>t,Vg=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(!vg(e.relativePath))return[];let t=wg(e.content);if(!/create\s+(?:unlogged\s+)?table/i.test(t))return[];let n=[],{lastEnableIndexByTable:r,staticEnableCount:i}=zg(t);if(Bg(t,i))return[];Ig.lastIndex=0;for(let e=Ig.exec(t);e!==null;e=Ig.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}}),Hg=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.`})}),Ug=e=>K(e)?eu.test(e)?!0:/(?:^|\/)(?:middleware|route)\.[cm]?[jt]sx?$/.test(e):!1,Wg=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=>Ug(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.`})}),Gg=[/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],Kg=/\$\{|["'`]\s*\+\s*$/,qg=/^\s*\{(?!\{)/,Jg=/"(?:[^"\\\n]|\\.)*"|'(?:[^'\\\n]|\\.)*'/g,Yg=/\b(?:true|false|null)\b|[\d.]+(?:e[+-]?\d+)?/gi,Xg=e=>{if(e.includes("`")||e.includes("${"))return!1;let t=e.replace(Jg,``).replace(Yg,``);return!/[A-Za-z_$]/.test(t)},Zg=/^[\s)]*\.replace\s*\([^)]*(?:\\u003[cC]|<|<)/,Qg=/(?:\b(?:escapeHtml|escapeJSON|escapeJson|htmlEscape|jsesc)|(?<![.\w])(?:serialize|serializeJavascript|devalue|uneval|superjson))\s*\(\s*$/i,$g=/\bJSON\.stringify\s*\($/i,e_=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=Ru(e);if(!t.includes(`JSON.stringify`))return[];let n=[],r=new Set;for(let[e,i]of Gg.entries()){i.lastIndex=0;for(let a=i.exec(t);a!==null;a=i.exec(t)){let i=a[0].replace($g,``);if(Qg.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(!Kg.test(r)||qg.test(r))continue}}let o=a.index+a[0].length-1,s=gf(t,o);if(s>=0){let e=t.slice(s+1,s+1+160);if(Zg.test(e)||Xg(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}}),t_=/(?:(?<![.\w$])fetch|\baxios\.\s*(?:get|post|put|delete|head)|\bgot|\bgot\.\s*(?:get|post))\s*\(\s*([^,)]+)/,n_=/\b(?:url|targetUrl|callbackUrl|redirectUrl|webhookUrl|companyUrl|websiteUrl|domainUrl|imageUrl|fetchUrl|next|return_to|returnTo|destination|location)\b/i,r_=/\breq\.|\brequest\.(?:query|body|params|nextUrl)|\bsearchParams\b|\bparams\.|\bbody\.|\bquery\./,i_=/\bredirect\s*:\s*["'](?:manual|error)["']/,a_=/\b(params|body|query)\./g,o_=(e,t)=>RegExp(`(?:const|let|var)\\s+${e}\\s*(?::[^=;\\n]{0,80})?=\\s*new\\s+URLSearchParams\\b`).test(t),s_=(e,t)=>{let n=e.replace(a_,(e,n)=>o_(n,t)?``:e);return r_.test(n)},c_=(e,t)=>{if(s_(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)||s_(n,t))return!0}return!1},l_=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(!Ug(e.relativePath)||!t_.test(e.content))return[];let t=[],n=e.content.split(`
|
|
26
|
-
`);for(let r=0;r<n.length;r+=1){let i=n[r]??``,a=i.match(t_),o=a?.[1]??``;if(!a||!n_.test(o)||!c_(o,e.content))continue;let s=n.slice(r,r+5).join(`
|
|
27
|
-
`);i_.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}}),u_=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=>xm(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.`})}),d_=/(?:^|\/)[^/]*webhook[^/]*\/|(?:^|\/)[^/]*webhook[^/]*\.[cm]?[jt]s$|\bwebhook\b/i,f_=/\b(?:export\s+(?:async\s+)?function\s+POST|export\s+const\s+(?:POST|handler|webhook)|webhookHandler|webhookRoute)\b/i,p_=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`),m_=/webhook[\s_-]?ur[il]\w*/gi,h_=/process\.env\.\w*WEBHOOK_URL|\b(?:send|post|dispatch|publish|notify)\w*Webhook/,g_=/\b(?:req|request)\b/,__=/\/\/[^\n]*|\/\*[\s\S]*?\*\/|"(?:\\.|[^"\\\n])*"|'(?:\\.|[^'\\\n])*'|`(?:\\.|[^`\\])*`/g,v_=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)||h_.test(e.content))return!1;let t=e.content.replace(__,``).replace(m_,``);return d_.test(e.relativePath)||d_.test(t)},pattern:f_,requireAll:[g_],suppressWhen:p_,message:`Webhook handler code does not show an obvious signature verification step.`})}),y_=/\.[cm]?[jt]sx?$/i,b_=/\.d\.[cm]?[jt]s$/i,x_=/\.mdx$/i,S_=/\.html?$/i,C_=new Set([`.angular`,`.astro`,`.cache`,`.contentlayer`,`.docusaurus`,`.expo`,`.git`,`.next`,`.nuxt`,`.output`,`.svelte-kit`,`.turbo`,`.vercel`,`build`,`coverage`,`dist`,`node_modules`,`out`,`storybook-static`]),w_=new WeakMap,T_=e=>{let t=w_.get(e);if(t)return t;let n=_t(e);return w_.set(e,n),n},E_=t=>{let r=[],i=[],a=[t],o=!1;for(;a.length>0;){let t=a.pop();if(!t)continue;let s;try{s=e.readdirSync(t,{withFileTypes:!0})}catch{return null}for(let e of s){let s=n.join(t,e.name),c=C_.has(e.name)||e.name.startsWith(`.`)&&e.name!==`.dumi`&&e.name!==`.storybook`;if(!(e.isSymbolicLink()&&c)){if(e.isSymbolicLink())return null;if(e.isDirectory()){if(c)continue;a.push(s);continue}if(!(!e.isFile()||Dl(s))){if(x_.test(e.name)){o=!0;continue}if(S_.test(e.name)){i.push(Ja(s));continue}y_.test(e.name)&&(b_.test(e.name)||r.push(Ja(s)))}}}}return{sourceFilePaths:r,htmlFilePaths:i,hasOpaqueMdxConsumerSurface:o}},D_=(t,n)=>{for(let r of t){let t;try{t=e.readFileSync(r,`utf8`)}catch{return!0}for(let e of n)if(t.includes(`"${e}"`)||t.includes(`'${e}'`))return!0}return!1},O_=e=>{if(x(e,`ImportDeclaration`))return ol(e)?null:typeof e.source.value==`string`?e.source.value:null;if(x(e,`ExportNamedDeclaration`))return e.exportKind===`type`||al(e.specifiers,`ExportSpecifier`,`exportKind`)?null:e.source&&typeof e.source.value==`string`?e.source.value:null;if(x(e,`ExportAllDeclaration`))return e.exportKind===`type`?null:typeof e.source.value==`string`?e.source.value:null;if(x(e,`ImportExpression`))return x(e.source,`Literal`)&&typeof e.source.value==`string`?e.source.value:null;if(x(e,`CallExpression`)&&x(e.callee,`Identifier`)&&e.callee.name===`require`&&e.arguments.length===1){let t=e.arguments[0];return t&&x(t,`Literal`)&&typeof t.value==`string`?t.value:null}return null},k_=(e,t,n,r)=>{z(e.programNode,i=>{let a=O_(i);if(!a)return;let o=tr(e.filePath,a);if(!o){r.add(a);return}let s=Ja(o);n.set(i,s);let c=t.get(s)??new Set;c.add(e),t.set(s,c)})},A_=({rootDirectory:e,currentFilePath:t,currentProgramNode:n,currentScopes:r,requiredModuleSources:i=[],knownModuleSources:a})=>{if(i.length>0&&a!==void 0&&!i.some(e=>a.includes(e)))return null;let o=E_(e);if(!o||i.length>0&&a===void 0&&!D_(o.sourceFilePaths,i))return null;let s=new Map;for(let e of o.sourceFilePaths){if(e===t){s.set(e,{filePath:e,programNode:n,scopes:r});continue}let i=_n(e);if(!i||!x(i,`Program`))return null;s.set(e,{filePath:e,programNode:i,scopes:T_(i)})}let c=new Map,l=new WeakMap,u=new Set;for(let e of s.values())k_(e,c,l,u);return{modulesByFilePath:s,htmlFilePaths:o.htmlFilePaths,consumerModulesByFilePath:c,resolvedSourcePathByNode:l,unresolvedRuntimeSources:u,hasOpaqueMdxConsumerSurface:o.hasOpaqueMdxConsumerSurface}},j_=e=>{if(!e)return null;let t=T(e);return!x(t,`Literal`)||typeof t.value!=`boolean`?null:t.value},M_=(e,t,n={})=>{let r=n.maximumConstAliases===void 0?4:n.maximumConstAliases,i=n.shouldFoldStaticConditions??!1,a=n.shouldKeepKnownValues??!1,o=[],s=[{expression:e,remainingConstAliases:r,resolvingSymbols:new Set}];for(;s.length>0;){let e=s.pop();if(!e)continue;let n=T(e.expression);if(x(n,`Literal`)){if(typeof n.value!=`string`){if(a)continue;return null}o.push(n.value);continue}if(x(n,`TemplateLiteral`)){let e=Ht(n);if(e===null){if(a)continue;return null}o.push(e);continue}if(x(n,`ConditionalExpression`)){let t=i?j_(n.test):null;if(t!==null){s.push({expression:t?n.consequent:n.alternate,remainingConstAliases:e.remainingConstAliases,resolvingSymbols:e.resolvingSymbols});continue}s.push({expression:n.alternate,remainingConstAliases:e.remainingConstAliases,resolvingSymbols:new Set(e.resolvingSymbols)}),s.push({expression:n.consequent,remainingConstAliases:e.remainingConstAliases,resolvingSymbols:new Set(e.resolvingSymbols)});continue}if(a&&x(n,`LogicalExpression`)&&(n.operator===`??`||n.operator===`||`)){s.push({expression:n.right,remainingConstAliases:e.remainingConstAliases,resolvingSymbols:new Set(e.resolvingSymbols)}),s.push({expression:n.left,remainingConstAliases:e.remainingConstAliases,resolvingSymbols:new Set(e.resolvingSymbols)});continue}if(x(n,`Identifier`)){let r=t.referenceFor(n)?.resolvedSymbol;if(!r||r.kind!==`const`||!r.initializer||!x(r.declarationNode,`VariableDeclarator`)||r.declarationNode.id!==r.bindingIdentifier||e.remainingConstAliases===0||e.resolvingSymbols.has(r)){if(a)continue;return null}e.resolvingSymbols.add(r),s.push({expression:r.initializer,remainingConstAliases:e.remainingConstAliases===null?null:e.remainingConstAliases-1,resolvingSymbols:e.resolvingSymbols});continue}if(!a)return null}return o.length>0?o:null},N_=(e,t,n={})=>M_(e,t,n),P_=(e,t)=>M_(e,t,{shouldKeepKnownValues:!0}),F_=(e,t,n,r,i=!1)=>{let a=e.value;return a?x(a,`Literal`)?typeof a.value==`string`?[a.value]:null:x(a,`JSXExpressionContainer`)?N_(a.expression,t,{maximumConstAliases:n,shouldFoldStaticConditions:r,shouldKeepKnownValues:i}):null:null},I_=(e,t)=>F_(e,t,4,!1),L_=(e,t)=>F_(e,t,null,!0),R_=(e,t)=>F_(e,t,4,!1,!0),z_=(e,t)=>{let r=n.relative(t,e);return r===``||!r.startsWith(`..${n.sep}`)&&r!==`..`&&!n.isAbsolute(r)},B_={attribute:null,expression:null,isPresent:!1,isUnknown:!1},V_={attribute:null,expression:null,isPresent:!1,isUnknown:!0},H_=(e,t,n)=>{for(let r=e.properties.length-1;r>=0;--r){let i=e.properties[r];if(!i)return V_;if(x(i,`SpreadElement`)){if(!x(i.argument,`ObjectExpression`))return V_;let e=H_(i.argument,t,n);if(e.isPresent||e.isUnknown)return e;continue}if(!x(i,`Property`))return V_;let a=C(i,{allowComputedString:!0});if(!a)return V_;if((n?a:a.toLowerCase())===t)return{attribute:null,expression:i.value,isPresent:!0,isUnknown:!1}}return B_},U_=(e,t,n=!0)=>{let r=n?t:t.toLowerCase();for(let t=e.length-1;t>=0;--t){let i=e[t];if(!i)return V_;if(x(i,`JSXSpreadAttribute`)){if(!x(i.argument,`ObjectExpression`))return V_;let e=H_(i.argument,r,n);if(e.isPresent||e.isUnknown)return e;continue}if(!x(i,`JSXAttribute`))continue;let a=Ts(i.name);if((n?a:a?.toLowerCase())===r)return{attribute:i,expression:null,isPresent:!0,isUnknown:!1}}return B_},W_=/(?<attributeName>[^\s"'<>/=]+)(?:\s*=\s*(?:"(?<doubleQuoted>[^"]*)"|'(?<singleQuoted>[^']*)'|(?<unquoted>[^\s"'=<>`]+)))?/g,G_=/<!--[\s\S]*?-->|(?<skippedContentOpeningTag><(?<skippedContentTag>script|style|textarea|title|xmp|iframe|noembed|noframes|plaintext|template)\b(?:"[^"]*"|'[^']*'|[^'"<>])*?>)[\s\S]*?(?:<\/\k<skippedContentTag>\s*>|$)|(?<openingTag><[A-Za-z][\w:-]*(?:"[^"]*"|'[^']*'|[^'"<>])*>)/gi,K_=new Map,q_=(e,t,n)=>{if(!e.isPresent)return;let r=e.attribute?R_(e.attribute,t):e.expression?P_(e.expression,t):null;for(let e of r??[]){let t=e?.trim();t&&n.add(t)}},J_=(e,t,n)=>{for(let r of e.properties){if(x(r,`SpreadElement`)){x(r.argument,`ObjectExpression`)&&J_(r.argument,t,n);continue}if(x(r,`Property`)&&C(r,{allowComputedString:!0})?.toLowerCase()===`id`)for(let e of P_(r.value,t)??[]){let t=e.trim();t&&n.add(t)}}},Y_=e=>{let t=e.parent;for(x(t,`JSXElement`)&&t.openingElement===e&&(t=t.parent);t;){if(x(t,`JSXElement`)&&Hs(t.openingElement)===`template`)return!0;t=t.parent}return!1},X_=(e,t,n)=>{z(e,e=>{if(!x(e,`JSXOpeningElement`)||Y_(e))return;let r=U_(e.attributes,`id`,!1);if(r.isUnknown){for(let r of e.attributes)q_(U_([r],`id`,!1),t,n),x(r,`JSXSpreadAttribute`)&&x(r.argument,`ObjectExpression`)&&J_(r.argument,t,n);return}q_(r,t,n)})},Z_=(e,t)=>{for(let n of e.matchAll(G_)){let e=n.groups?.skippedContentOpeningTag??n.groups?.openingTag;if(e)for(let n of e.matchAll(W_)){if(n.groups?.attributeName?.toLowerCase()!==`id`)continue;let e=n.groups?.doubleQuoted??n.groups?.singleQuoted??n.groups?.unquoted??``;e.trim()&&t.add(e.trim())}}},Q_=e=>{if(!n.isAbsolute(e.currentFilePath))return null;let t=e.configuredRootDirectory?Ja(e.configuredRootDirectory):null;return!t||!z_(e.currentFilePath,t)?null:t},$_=()=>{K_.clear()},ev=t=>{let n=new Set;X_(t.currentProgramNode,t.currentScopes,n);let r=Q_(t);if(!r)return n;if(K_.has(r)){let e=K_.get(r);return e?new Set([...e,...n]):null}let i=A_({rootDirectory:r,currentFilePath:Ja(t.currentFilePath),currentProgramNode:t.currentProgramNode,currentScopes:t.currentScopes});if(!i)return K_.set(r,null),null;let a=new Set;for(let e of i.modulesByFilePath.values())X_(e.programNode,e.scopes,a);try{for(let t of i.htmlFilePaths)Z_(e.readFileSync(t,`utf8`),a)}catch{return K_.set(r,null),null}return K_.set(r,a),new Set([...a,...n])},tv=new Map,nv=()=>{tv.clear()},rv=t=>{let n=tv.get(t);if(n!==void 0)return n;let r;try{r=e.realpathSync(t)}catch{r=t}return tv.set(t,r),r},iv=(e,t,n)=>{if(t===void 0||t.length===0)return!1;let r=Ja(rv(e)),i=Ja(t);if(n&&r===i)return!0;let a=i.endsWith(`/`)?i:`${i}/`;return r.startsWith(a)},av=/webpackIgnore\s*:\s*true|@vite-ignore/,ov=new Map,sv=()=>{ov.clear()},cv=e=>{if(!e)return null;let n=ov.get(e);if(n!==void 0)return n===!1?null:n;let r=!1;try{let n=t(e,`utf8`);av.test(n)&&(r=n)}catch{r=!1}return ov.set(e,r),r===!1?null:r},lv=()=>{sv(),rr(),De(),zn(),nv(),$_(),er()},uv=e=>Yl.test(e)||Xl.test(e),dv=e=>{let t=su.test(e);return cg(e)||yg(e)||bu(e)||pu(e)?{bucket:`priority`,isGeneratedBundleByName:t}:fu(e,t)?{bucket:`artifact`,isGeneratedBundleByName:t}:uv(e)?{bucket:`other`,isGeneratedBundleByName:t}:null},fv=(e,t)=>t||uv(e)||pu(e)||cg(e),pv=[`nextjs`,`astro`,`vite`,`cra`,`remix`,`gatsby`,`expo`,`react-native`,`tanstack-start`,`preact`,`unknown`];export{wf as $,bt as $i,Da as $n,li as $r,al as $t,ng as A,ce as Aa,or as Ai,jo as An,Zi as Ar,_d as At,bh as B,m as Ba,Ht as Bi,lo as Bn,ea as Br,Uu as Bt,_g as C,se as Ca,wr as Ci,as as Cn,sa as Cr,ud as Ct,ug as D,ne as Da,z as Di,ns as Dn,wa as Dr,dd as Dt,fg as E,te as Ea,cr as Ei,es as En,la as Er,ed as Et,Ah as F,g as Fa,sn as Fi,Eo as Fn,Xi as Fr,wd as Ft,Tm as G,c as Ga,P as Gi,io as Gn,Wi as Gr,Rl as Gt,oh as H,u as Ha,F as Hi,so as Hn,Ui as Hr,yu as Ht,kh as I,h as Ia,rn as Ii,vo as In,ta as Ir,pd as It,bm as J,M as Ji,Za as Jn,Ki as Jr,Bl as Jt,wm as K,Nt as Ki,ao as Kn,Ji as Kr,zl as Kt,Oh as L,v as La,Gt as Li,_o as Ln,aa as Lr,md as Lt,Vh as M,oe as Ma,tr as Mi,No as Mn,ra as Mr,Sd as Mt,Nh as N,de as Na,Rn as Ni,B as Nn,na as Nr,Cd as Nt,sg as O,ue as Oa,sr as Oi,os as On,da as Or,Dd as Ot,Mh as P,y as Pa,_n as Pi,Do as Pn,Yi as Pr,hd as Pt,Cf as Q,j as Qi,Ua as Qn,ui as Qr,kl as Qt,Ch as R,p as Ra,Ut as Ri,go as Rn,Qi as Rr,ld as Rt,Fg as S,fe as Sa,Cr as Si,ts as Sn,xa as Sr,Td as St,pg as T,ee as Ta,pr as Ti,is as Tn,fa as Tr,vd as Tt,Rm as U,d as Ua,Ft as Ui,ro as Un,Vi as Ur,W as Ut,_h as V,_ as Va,Lt as Vi,co as Vn,Hi as Vr,Hu as Vt,jm as W,l as Wa,Pt as Wi,oo as Wn,Gi as Wr,Fl as Wt,Xf as X,Ct as Xi,Va as Xn,Ri as Xr,jl as Xt,Zf as Y,Dt as Yi,Ja as Yn,Bi as Yr,Vl as Yt,Bf as Z,St as Zi,Ka as Zn,wi as Zr,Dl as Zt,l_ as _,C as _a,br as _i,vs as _n,Sa as _r,Zu as _t,av as a,O as aa,Nr as ai,Mc as an,Pa as ar,of as at,Hg as b,x as ba,hr as bi,V as bn,ca as br,bd as bt,ev as c,ke as ca,xr as ci,Ws as cn,Aa as cr,Jd as ct,L_ as d,D as da,Or as di,zs as dn,ua as dr,Ju as dt,yt as ea,ci as ei,ol as en,ba as er,Sf as et,I_ as f,ye as fa,Ar as fi,Rs as fn,Ea as fr,$u as ft,u_ as g,w as ga,Er as gi,xs as gn,oa as gr,Gu as gt,v_ as h,T as ha,vr as hi,ws as hn,ga as hr,Xu as ht,lv as i,k as ia,Wr as ii,rl as in,va as ir,mf as it,Qh as j,ae as ja,R as ji,Mo as jn,ia as jr,gd as jt,ig as k,ie as ka,ar as ki,Po as kn,ma as kr,xd as kt,U_ as l,Ae as la,Tr as li,Us as ln,ja as lr,qu as lt,A_ as m,he as ma,yr as mi,Ts as mn,ya as mr,Ku as mt,dv as n,_t as na,Kr as ni,tl as nn,Ta as nr,X as nt,cv as o,He as oa,Pr as oi,Ys as on,Ma as or,af as ot,j_ as p,ve as pa,Sr as pi,Os as pn,_a as pr,Yu as pt,Cm as q,At as qi,Qa as qn,qi as qr,Pl as qt,fv as r,vt as ra,Ur as ri,nl as rn,Ca as rr,hf as rt,iv as s,Be as sa,Ir as si,Gs as sn,Na as sr,Yd as st,pv as t,xt as ta,oi as ti,il as tn,Oa as tr,vf as tt,z_ as u,je as ua,Dr as ui,Hs as un,ka as ur,Wu as ut,e_ as v,S as va,mr as vi,ls as vn,Fa as vr,Qu as vt,mg as w,le as wa,kr as wi,rs as wn,pa as wr,Ed as wt,Vg as x,pe as xa,gr as xi,cs as xn,ha as xr,yd as xt,Wg as y,me as ya,jr as yi,ss as yn,Ia as yr,cd as yt,Sh as z,f as za,I as zi,uo as zn,$i as zr,fd as zt};
|
|
28
|
-
//# sourceMappingURL=capability-BE9ryJ2C.js.map
|