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