@preventive/triage 1.0.0-alpha.66 → 1.0.0-alpha.67

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.
Files changed (64) hide show
  1. package/common/bundle-imports.js +20 -0
  2. package/common/bundle-metadata.js +1 -1
  3. package/common/bundle-reasons.d.ts +4 -0
  4. package/common/bundle-reasons.js +38 -1
  5. package/common/bundle-sources.d.ts +1 -0
  6. package/common/bundle-sources.js +22 -0
  7. package/common/managed/npm-packages.js +3 -3
  8. package/common/managed/routes.js +23 -11
  9. package/common/managed/stasis-config.ts +7 -0
  10. package/out/activity.js +4 -4
  11. package/out/chunk-5F5FPI75.js +3 -0
  12. package/out/chunk-6ATPGDDI.js +1 -0
  13. package/out/chunk-6YGH7BJG.js +42 -0
  14. package/out/{chunk-OVGR4D3M.js → chunk-A5A3LEMV.js} +1 -1
  15. package/out/chunk-CGRIZ5M5.js +1 -0
  16. package/out/chunk-FUHRMY7R.js +247 -0
  17. package/out/{chunk-J2FWBXFV.js → chunk-LBJVV6UB.js} +1 -1
  18. package/out/chunk-LDO42LAC.js +1 -0
  19. package/out/{chunk-24AKGEH3.js → chunk-NB4JBTKK.js} +1 -1
  20. package/out/{chunk-IZ6MYRYB.js → chunk-R3WUYD4F.js} +1 -1
  21. package/out/chunk-U5C2TNNQ.js +52 -0
  22. package/out/chunk-VG5RH6KN.js +2 -0
  23. package/out/{chunk-Z6VEV2QL.js → chunk-VR3NRE5V.js} +1 -1
  24. package/out/chunk-WFDXHPT2.js +12 -0
  25. package/out/client-managed-import.js +2 -2
  26. package/out/client-managed.js +19 -19
  27. package/out/compare.js +12 -12
  28. package/out/dialogs.js +38 -38
  29. package/out/graph.js +8 -8
  30. package/out/index.html +9 -9
  31. package/out/scan.js +2 -2
  32. package/out/view.css +1 -1
  33. package/out/view.js +15 -15
  34. package/package.json +11 -8
  35. package/server-managed/activity.ts +21 -12
  36. package/server-managed/bundle-build-diagnostics.d.ts +1 -1
  37. package/server-managed/bundle-build-worker.js +84 -15
  38. package/server-managed/bundle-build.ts +95 -19
  39. package/server-managed/bundle-cache.ts +28 -6
  40. package/server-managed/bundle-dependency-reviews.ts +38 -22
  41. package/server-managed/commit-lockfiles.ts +2 -1
  42. package/server-managed/db-neon.ts +1 -1
  43. package/server-managed/dependency-review-comments.ts +31 -12
  44. package/server-managed/http.ts +127 -59
  45. package/server-managed/locked-packages.ts +34 -14
  46. package/server-managed/lockfile-scope.ts +10 -1
  47. package/server-managed/npm-kept.ts +10 -0
  48. package/server-managed/npm-patch.ts +127 -50
  49. package/server-managed/public-workspace.ts +3 -2
  50. package/server-managed/pull-dependencies.ts +55 -37
  51. package/server-managed/pull-dependency-reviews.ts +15 -11
  52. package/server-managed/report-sources.ts +6 -3
  53. package/server-managed/repository-issues.ts +14 -11
  54. package/server-managed/stasis-dependencies.ts +153 -0
  55. package/out/chunk-65PLAG3I.js +0 -12
  56. package/out/chunk-DCBXCBLL.js +0 -52
  57. package/out/chunk-F3UI65ZI.js +0 -42
  58. package/out/chunk-FAG6E5RC.js +0 -3
  59. package/out/chunk-OBZWBTZL.js +0 -247
  60. package/out/chunk-PTFQKLKO.js +0 -1
  61. package/out/chunk-QVKFY4FA.js +0 -1
  62. package/out/chunk-SYXT3SFP.js +0 -2
  63. package/out/chunk-WL3SPQB4.js +0 -1
  64. /package/out/{chunk-WCPJDAYA.js → chunk-D6NVKGGG.js} +0 -0
@@ -0,0 +1,3 @@
1
+ import{a as e}from"./chunk-6CCSTJWB.js";import{b as t,c as n,e as r,f as i,g as a}from"./chunk-U5C2TNNQ.js";import{p as o}from"./chunk-6ATPGDDI.js";import{J as s}from"./chunk-QRKFPLA4.js";import{a as c}from"./chunk-TUII34K2.js";var l=[`dependencies`,`security`],u={dependencies:`Dependencies`,security:`Security`},d=e(),f=Object.freeze(d.models),p=d.defaultModel,m=`x-upload-encryption`,h=1,g=1,_={name:`X25519`},v=34,y=1048576,b=65536,x=`deepview-managed-upload.v1.content-key`;function S(e,t){let n=new Uint8Array(12);return new DataView(n.buffer).setUint32(7,e),n[11]=+!!t,n}async function C(e,t,n){let r=await crypto.subtle.importKey(`raw`,e,`HKDF`,!1,[`deriveKey`]);return await crypto.subtle.deriveKey({name:`HKDF`,hash:`SHA-256`,salt:t,info:c(x)},r,{name:`AES-GCM`,length:256},!1,[n])}async function w(e){let t=new Uint8Array(await e.slice(0,b).arrayBuffer());if(t.includes(0))return!1;try{return new TextDecoder(`utf-8`,{fatal:!0}).decode(t,{stream:!0}),!0}catch{return!1}}async function T(e,t,n){let r=await w(e),[i,a]=await Promise.all([crypto.subtle.importKey(`raw`,t,_,!1,[]),crypto.subtle.generateKey(_,!1,[`deriveBits`])]),o=new Uint8Array(v);o[0]=h,o[1]=r?g:0,o.set(new Uint8Array(await crypto.subtle.exportKey(`raw`,a.publicKey)),2);let s=await C(await crypto.subtle.deriveBits({name:`X25519`,public:i},a.privateKey,256),o,`encrypt`),c=[new Blob([o])],l=new Uint8Array(y),u=0,d=0,f=async e=>{c.push(new Blob([await crypto.subtle.encrypt({name:`AES-GCM`,iv:S(d++,e)},s,l.subarray(0,u))])),u=0},p=(r?e.stream().pipeThrough(new CompressionStream(`gzip`)):e.stream()).getReader();try{for(let e=await p.read();!e.done;e=await p.read()){n?.throwIfAborted();for(let t=0;t<e.value.length;){u===y&&await f(!1);let n=Math.min(y-u,e.value.length-t);l.set(e.value.subarray(t,t+n),u),u+=n,t+=n}}}catch(e){throw await p.cancel(e).catch(()=>{}),e}return await f(!0),new Blob(c)}var E=null,D=0;function O(){return E?.user.role??null}function ee(e){if(e!==null&&!i(e))throw TypeError(`Unknown managed preview role: ${e}. Expected ${r.join(`, `)}.`);D++,E=e===null?null:{user:{id:`preview:${e}`,login:e,name:e[0].toUpperCase()+e.slice(1),role:e,avatarUrl:null,lastSeenAt:Date.now(),lastActivityAt:null},csrfToken:null}}function te(e,t){let n=new URL(e,`http://managed-preview.invalid`).pathname,r=(t?.method??`GET`).toUpperCase();if(r===`POST`&&n===`/api/auth/logout`)return Response.json({ok:!0});if(r!==`GET`)throw Error(`Changes are not saved in the managed UI preview`);if(n===`/api/auth/session`)return Response.json(E);if(n===`/api/teams`)return Response.json({teams:[]});if(n.startsWith(`/api/admin/`)&&!a(E.user.role,`manage`)||[`/api/admin/users`,`/api/admin/teams`,`/api/admin/repositories`,`/api/admin/repositories/aliases`,`/api/admin/repositories/risk`].includes(n)&&E.user.role!==`admin`)return Response.json({error:`forbidden`},{status:403});if(n===`/api/admin/repositories/risk`)return new Response(`{"type":"repos","repos":[]}
2
+ {"type":"done"}
3
+ `,{headers:{"content-type":`application/x-ndjson`}});let i={"/api/admin/users":{users:[E.user]},"/api/admin/teams":{teams:[],users:[E.user],repos:[],permissions:l},"/api/admin/links":{shares:[]},"/api/admin/repositories":{repositories:[],total:0,connectedCount:0,installUrl:null,tokenMissing:!1},"/api/admin/repositories/aliases":{aliases:[],repos:[]},"/api/admin/repositories/resolve":{location:null},"/api/admin/reports":{reports:[],repos:[],maxBytes:26214400},"/api/admin/bundles":{bundles:[],repos:[],maxBytes:209715200},"/api/admin/history":{history:[],total:0,page:1,limit:100,filters:{repos:[],users:[]}},"/api/admin/scan/models":{models:f,defaultModel:p},"/api/admin/scan-results":{bundles:[],results:[]},"/api/auth/profile":{profile:{login:E.user.login,name:E.user.name,githubName:E.user.name,nameAccount:null,avatarAccount:null,accounts:[]}}};return Object.hasOwn(i,n)?Response.json(i[n]):Response.json({error:`not-found`},{status:404})}var k=3145728,A=new Set([`/api/admin/reports`,`/api/admin/bundles`,`/api/admin/deduplication`]);async function j(e,t){let n=await t(`/api/admin/uploads/key`,{credentials:`same-origin`,signal:e.signal});if(n.status===404||n.status===405)return e;if(!n.ok)return n;let r=(await n.json())?.key;if(typeof r!=`string`)throw TypeError(`The server sent an invalid upload key`);let i=new Headers(e.headers);return i.set(m,`1`),{...e,headers:i,body:await T(e.body,Uint8Array.fromBase64(r,{alphabet:`base64url`}),e.signal)}}async function M(e,t,n){let r=null;if(e!==`/api/admin/deduplication`&&t.body.size>k){let i=await n(`/api/config`,{credentials:`same-origin`,signal:t.signal});if(!i.ok)return i;let a=(await i.json()).managed,o=a?.uploadMaxBytes?.[e.endsWith(`/reports`)?`reports`:`bundles`];if(Number.isSafeInteger(o)&&o>0&&t.body.size>o)return Response.json({error:`too-large`},{status:413});let s=a?.uploadChunkBytes;Number.isSafeInteger(s)&&s>0&&s<=k&&(r=s)}let i=await j(t,n);return i instanceof Response?i:r==null||i.body.size<=k?await n(e,i):await P(e,i,n,r)}var N=3;async function P(e,t,n,r){let i=t.body,a=crypto.randomUUID(),o=e.endsWith(`/reports`)?`reports`:`bundles`,s=Math.ceil(i.size/r),c=new Headers(t.headers);c.set(`content-type`,`application/octet-stream`);let l=0,u=!1;try{let d=null,f=!1,p=(await Promise.allSettled(Array.from({length:Math.min(N,s)},async()=>{for(;!f&&l<s;){let e=l++;try{let s=await n(`/api/admin/uploads/${o}/${a}/${e}`,{...t,headers:c,body:i.slice(e*r,(e+1)*r)});s.ok||(d??=s,f=!0)}catch(e){throw f=!0,e}}}))).find(e=>e.status===`rejected`);if(p)throw p.reason;if(d)return d;let m=new Headers(t.headers);m.set(`x-upload-id`,a),m.set(`x-upload-parts`,String(s)),m.set(`x-upload-size`,String(i.size));let h=await n(e,{...t,headers:m,body:``});return u=h.ok,h}finally{if(!u&&l>0){let e=new Headers(t.headers);e.set(`x-upload-parts`,String(l)),await n(`/api/admin/uploads/${o}/${a}`,{...t,method:`DELETE`,headers:e,body:void 0,signal:AbortSignal.timeout(1e4)}).catch(()=>{})}}}async function F(e){await e.json().then(e=>e?.error,()=>null)===`view-only`&&globalThis.document?.dispatchEvent(new CustomEvent(`managed-view-only`))}async function I(e,n){if(n?.signal?.throwIfAborted(),E)return te(e,n);let r=D;async function i(e,n){if(r!==D)throw new DOMException(`Managed session changed`,`AbortError`);let i=t();if(i){if(new URL(e,globalThis.location.origin).origin!==globalThis.location.origin)throw Error(`Public workspace requests must be same-origin`);let t=new Headers(n?.headers);t.set(`x-deepview-share`,i.token),n={...n,headers:t,credentials:`omit`,redirect:`error`}}let a=await fetch(e,{...n,cache:`no-store`});if(r!==D)throw new DOMException(`Managed session changed`,`AbortError`);return a.status===403&&![`GET`,`HEAD`].includes((n?.method??`GET`).toUpperCase())&&F(a.clone()),a}return n?.method===`POST`&&A.has(e)&&n.body instanceof Blob?await M(e,n,i):await i(e,n)}var L=new class{constructor(e=()=>{}){this.resources=new Map,this.session=null,this.teamCatalog=null,this.reportCatalog=null,this.bundleCatalog=null,this.generation=0,this.sessionController=new AbortController,this.notify=e}setSession(e){(this.session?.id!==e?.id||this.session?.role!==e?.role)&&this.reset(),this.session=e}reset(){this.generation++,this.sessionController.abort(),this.sessionController=new AbortController,this.invalidate(),this.session=null,this.teamCatalog=null,this.reportCatalog=null,this.bundleCatalog=null}setReportCatalog(e){let t=new Set,n=new Map(e.map(e=>[e.id,JSON.stringify([e.cacheKey??null,e.reports.map(e=>[e.id,e.cacheKey??null,e.visible!==!1]).toSorted(),(e.bundles??[]).map(e=>[e.id,e.filename,e.repoFullName,e.repoDirectory??``]).toSorted()])]));for(let e of new Set([...this.teamCatalog?.keys()??[],...n.keys()]))this.teamCatalog?.get(e)!==n.get(e)&&t.add(`team:${e}`);for(let e of this.resources.keys())if(e.startsWith(`reports:content:team:`)){let[t]=e.slice(21).split(`:`);n.has(t)&&this.teamCatalog?.get(t)===n.get(t)||this.invalidate([e])}this.teamCatalog=n;let r=new Map;for(let t of e)for(let e of t.reports){let n=r.get(e.id)??[];n.push(JSON.stringify([t.id,e.cacheKey??null])),r.set(e.id,n)}let i=new Map([...r].map(([e,t])=>[e,JSON.stringify(t.toSorted())])),a=this.reportCatalog;this.reportCatalog=i;let o=new Set(t);for(let e of new Set([...a?.keys()??[],...i.keys()]))a?.get(e)!==i.get(e)&&o.add(e);for(let e of this.resources.keys()){if(!e.startsWith(`reports:content:`)||e.startsWith(`reports:content:team:`))continue;let t=e.slice(16);(!i.has(t)||o.has(t))&&(this.invalidate([e]),o.add(t))}let s=new Map;for(let t of e)for(let e of t.bundles??[]){let n=s.get(e.id)??[];n.push(JSON.stringify([t.id,t.cacheKey??null,e.filename,e.repoFullName,e.repoDirectory??``])),s.set(e.id,n)}let c=!1,l=new Map([...s].map(([e,t])=>[e,JSON.stringify(t.toSorted())]));for(let e of new Set([...this.bundleCatalog?.keys()??[],...l.keys()]))this.bundleCatalog?.get(e)!==l.get(e)&&(c=!0,o.add(`bundle:${e}`),this.invalidate([`bundle-metadata:${e}`]));this.bundleCatalog=l;for(let e of this.resources.keys()){if(!e.startsWith(`report-sources:`)&&!e.startsWith(`finding-history:`))continue;let[,n,r]=e.split(`:`);(n?t.has(`team:${n}`):c||o.has(r))&&this.invalidate([e])}return o}read(e){return this.resources.get(e)?.data}invalidate(e){for(let[t,n]of this.resources)e&&!e.some(e=>t===e||t.startsWith(`${e}:`))||(n.controller?.abort(),this.resources.delete(t))}async mutate(e,t){let n=this.generation,r;try{r=await e()}catch(e){throw n===this.generation&&e?.name!==`AbortError`&&this.notify(`Couldn't save changes: ${e?.message??e}`),e}if(n!==this.generation)throw new DOMException(`Managed session changed`,`AbortError`);return this.invalidate(t),r}async load(e,t,n,{signal:r,apply:i=()=>{},retryInvalidated:a=!1}={}){let o=this.generation;for(;;){r?.throwIfAborted();let s=this.resources.get(e);if(s||(s={},this.resources.set(e,s)),s.data!==void 0&&i(s.data),!s.pending){let e=s.controller=new AbortController;s.pending=(async()=>{try{let t=await n(e.signal);return e.signal.throwIfAborted(),s.data=t,t}catch(n){throw!e.signal.aborted&&n?.name!==`AbortError`&&this.notify(`Couldn't refresh ${t}: ${n?.message??n}`),n}})().finally(()=>{s.pending=null})}try{let t=await s.pending;if(r?.throwIfAborted(),this.resources.get(e)!==s)throw new DOMException(`Managed data changed`,`AbortError`);return i(t),t}catch(t){if(!a||t?.name!==`AbortError`||r?.aborted||o!==this.generation||this.resources.get(e)===s)throw t}}}}(e=>{document.dispatchEvent(new CustomEvent(`managed-notice`,{detail:{message:e}}))});function R(e){L.setSession(e)}function z(e){return L.setReportCatalog(e)}function B(){L.reset()}var V=[`package`,`repo`],H=e=>Array.isArray(e?.findings)?`findings`:Array.isArray(e?.groups)?`groups`:null;function U(e,t){let n=H(e);if(!n||!Array.isArray(t))return e;for(let r of e[n].flat())if(r&&typeof r==`object`)for(let e of V)Number.isInteger(r[e])&&(r[e]=t[r[e]]);return e}async function W(e,t=null,n={}){let r;try{r=await I(e,{credentials:`same-origin`,headers:{accept:`application/json`},...n})}catch{return t}if(r.status===401||r.status===403)return null;if(!r.ok)return t;try{return await r.json()}catch{return t}}async function G({fallback:e=null,sent:r}={}){let i=t()||O()!==null?void 0:await r;if(i===null)return null;let a=K(i);if(a!==void 0)return a;let o;try{let r=t(),i=await I(r?n(r):`/api/auth/session`,{credentials:`same-origin`,headers:{accept:`application/json`}});if(i.status===401||i.status===403)return null;if(!i.ok)return e;o=await i.json()}catch{return e}let s=K(o);return s===void 0?e:s}function K(e){let n=e?.user;if(n===null)return null;if(n!==void 0&&typeof n.login==`string`)return{id:n.id,login:n.login,name:typeof n.name==`string`?n.name:null,avatarUrl:typeof n.avatarUrl==`string`?n.avatarUrl:null,role:typeof n.role==`string`?n.role:`none`,csrfToken:typeof e.csrfToken==`string`?e.csrfToken:null,...t()?{publicShare:!0}:{},...typeof e.viewer?.login==`string`?{viewer:{id:e.viewer.id,login:e.viewer.login,name:typeof e.viewer.name==`string`?e.viewer.name:null}}:{},...!t()&&e.dependencyReview===!0?{dependencyReview:!0}:{}}}function q(e){let t=t=>Number.isSafeInteger(e?.[t])&&e[t]>=0;return e?.appMode===!1?{appMode:!1,...t(`appReports`)&&{appReports:e.appReports},...t(`findings`)&&{findings:e.findings}}:e?.appMode===!0&&t(`appFindings`)?{appMode:!0,appFindings:e.appFindings}:null}function J(e){if(typeof e?.sha!=`string`||typeof e.github!=`string`||!Array.isArray(e.tags))return null;let t=e.details,n=e=>typeof e==`string`?e:null,r=e=>Number.isSafeInteger(e)?e:null;return{sha:e.sha,github:e.github,tags:e.tags.filter(e=>typeof e==`string`),details:typeof t?.subject==`string`?{subject:t.subject,authorName:n(t.authorName),authorLogin:n(t.authorLogin),authoredAt:r(t.authoredAt),committedAt:r(t.committedAt)}:null}}async function ne({fallback:e=[],signal:r,onRevision:i}={}){let a=t(),o=a?await W(n(a),null,{signal:r}):null,s=a?{teams:o?.team?[o.team]:[]}:await W(`/api/teams`,{teams:e},{signal:r}),c=s?.teams;return Array.isArray(c)?(i?.(typeof s.revision==`string`?s.revision:null),c.filter(e=>e!=null&&typeof e.id==`string`&&typeof e.name==`string`).map(e=>({id:e.id,slug:e.slug,name:e.name,...!a&&e.dependencyReview===!0?{dependencyReview:!0}:{},...e.permissions?{permissions:{dependencies:e.permissions.dependencies===!0,security:e.permissions.security===!0}}:{},...typeof e.cacheKey==`string`?{cacheKey:e.cacheKey}:{},...q(e.app)?{app:q(e.app)}:{},repos:Array.isArray(e.repos)?e.repos.filter(e=>Number.isSafeInteger(e?.repoId)&&e.repoId>0&&typeof e.fullName==`string`).map(e=>({repoId:e.repoId,fullName:e.fullName,path:typeof e.path==`string`&&e.path?e.path:null})):[],reports:Array.isArray(e.reports)?e.reports.filter(e=>e!=null&&typeof e.id==`string`&&typeof e.filename==`string`).map(e=>({id:e.id,slug:e.slug,filename:e.filename,visible:e.visible!==!1,...e.analyzer===null||typeof e.analyzer==`string`?{analyzer:e.analyzer}:{},repoFullName:typeof e.repoFullName==`string`?e.repoFullName:``,repoDirectory:typeof e.repoDirectory==`string`?e.repoDirectory:``,...typeof e.cacheKey==`string`?{cacheKey:e.cacheKey}:{}})):[],bundles:Array.isArray(e.bundles)?e.bundles.filter(e=>e!=null&&typeof e.id==`string`&&typeof e.filename==`string`).map(e=>({id:e.id,slug:e.slug,integrity:e.integrity,byteSize:e.byteSize,repoId:e.repoId,filename:e.filename,kind:e.kind,visible:e.visible!==!1,summary:e.summary??null,summaryRetryAt:Number.isSafeInteger(e.summaryRetryAt)&&e.summaryRetryAt>0?e.summaryRetryAt:null,repoDirectory:typeof e.repoDirectory==`string`?e.repoDirectory:``,repoFullName:typeof e.repoFullName==`string`?e.repoFullName:``,commitInfo:J(e.commitInfo)})):[]}))):s==null?[]:e}function Y(e){return e?.links===void 0?[]:Array.isArray(e.links)&&e.links.every(e=>Array.isArray(e)&&e.length>=2&&e.every(e=>typeof e==`string`))?e.links:null}function X(e,t=null){return s(e?.data)===null||typeof e.repo?.directory!=`string`||e.repo.github!==null&&typeof e.repo.github!=`string`||Y(e)===null?null:{data:U(e.data,t),repo:e.repo,...e.links?{links:e.links}:{}}}async function Z(e,{signal:t}={}){return X(await W(`/api/reports/${encodeURIComponent(e)}`,null,{signal:t}))}async function re(e,{signal:t}={}){let n=[...new Set(e)];if(n.length===0)return[];let r=await W(`/api/reports/query`,null,{method:`POST`,signal:t,headers:{accept:`application/json`,"content-type":`application/json`},body:JSON.stringify({ids:n})});if(!Array.isArray(r?.reports)||r.reports.length!==n.length)return null;let i=new Map;for(let e of r.reports){let t=X(e);if(!t||!n.includes(e.id)||i.has(e.id))return null;i.set(e.id,t)}let a=Y(r);return a===null?null:e.map(e=>({...i.get(e),...a.length>0?{links:a}:{}}))}async function ie(e,{signal:t,reportId:n=null,lite:r=!1}={}){let i=new URLSearchParams(n===null?{}:{reportId:n});r&&i.set(`lite`,`1`);let a=await W(`/api/teams/${encodeURIComponent(e)}/reports${i.size>0?`?${i}`:``}`,null,{signal:t});if(!Array.isArray(a?.reports))return null;let o=[],s=new Set;for(let e of a.reports){let t=X(e,a.values);if(!t||typeof e.id!=`string`||typeof e.filename!=`string`||s.has(e.id))return null;s.add(e.id),o.push({id:e.id,filename:e.filename,...t})}let c=Y(a);return c===null?null:(Object.defineProperties(o,{links:{value:c},...[`rows`,`app`].includes(a.folded)?{folded:{value:a.folded},lens:{value:a.lens??null}}:{}}),o)}function Q(e){return e?`?team=${encodeURIComponent(e)}`:``}async function ae(e,{reportId:t,...n}={}){let r=t==null?``:`?reportId=${encodeURIComponent(t)}`,i=await W(`/api/teams/${encodeURIComponent(e)}/annotations${r}`,null,n),{reports:a,entries:o,comments:s,issues:c={}}=i??{};if(!a||typeof a!=`object`||Array.isArray(a)||!o||typeof o!=`object`||Array.isArray(o)||!Array.isArray(s)||!c||typeof c!=`object`||Array.isArray(c)||Object.values(a).some(e=>!Array.isArray(e)||e.some(e=>typeof e!=`string`))||s.some(e=>!e||typeof e.findingId!=`string`))return null;let l=new Map;for(let[e,t]of s.entries()){let n=t.findingId,r=l.get(n)??[];r.push(e),l.set(n,r)}let u=new Map,d=new Map,f=typeof i.revision==`string`?i.revision:null;return Object.assign(e=>{if(!Object.hasOwn(a,e))return null;if(d.has(e))return d.get(e);let t=JSON.stringify(a[e]),n=u.get(t);if(!n){let r=[...new Set(a[e])],i=r.flatMap(e=>l.get(e)??[]);n={entries:Object.fromEntries(r.filter(e=>Object.hasOwn(o,e)).map(e=>[e,o[e]])),comments:i.toSorted((e,t)=>e-t).map(e=>s[e]),issues:Object.fromEntries(r.filter(e=>Object.hasOwn(c,e)).map(e=>[e,c[e]]))},u.set(t,n)}return d.set(e,n),n},{revision:f})}async function oe(e,t,n){let r=(await W(`/api/reports/${encodeURIComponent(e)}/triage${Q(t)}`,null,n))?.entries;return typeof r==`object`&&r&&!Array.isArray(r)?r:null}async function se(e,n,r=null){if(t())return[];let i=r===null?``:`?reportId=${encodeURIComponent(r)}`,a=await W(`/api/teams/${encodeURIComponent(e)}/fixes${i}`,null,{signal:n});return Array.isArray(a?.fixes)?a.fixes:null}async function ce(e,t,n){let r=await W(`/api/reports/${encodeURIComponent(e)}/comments${Q(t)}`,null,n);return Array.isArray(r?.comments)?r.comments:null}async function le(e,{findingId:t,body:n,commentId:r=null,version:i},a,o){let s=r==null?``:`/${encodeURIComponent(r)}`;try{let c=await I(`/api/reports/${encodeURIComponent(e)}/comments${s}${Q(o)}`,{method:r==null?`POST`:`PATCH`,credentials:`same-origin`,headers:{"content-type":`application/json`,...a?{"x-csrf-token":a}:{}},body:JSON.stringify(r==null?{findingId:t,body:n}:{body:n,version:i})});return{status:c.status,comment:c.ok?(await c.json()).comment:null}}catch{return{status:0,comment:null}}}async function ue(e,t,n,r,i){try{return(await I(`/api/reports/${encodeURIComponent(e)}/comments/${encodeURIComponent(t)}${Q(i)}`,{method:`DELETE`,credentials:`same-origin`,headers:{"content-type":`application/json`,...r?{"x-csrf-token":r}:{}},body:JSON.stringify({version:n})})).status}catch{return 0}}async function de(e,t,n,r){try{return(await I(`/api/reports/${encodeURIComponent(e)}/triage${Q(r)}`,{method:`POST`,credentials:`same-origin`,headers:{"content-type":`application/json`,...n?{"x-csrf-token":n}:{}},body:JSON.stringify({entries:t})})).status}catch{return 0}}function fe(e){e&&(location.href=e)}async function pe(e){if(t())location.href=`/`;else{try{await I(`/api/auth/logout`,{method:`POST`,credentials:`same-origin`,headers:e?{"x-csrf-token":e}:{}})}catch{}location.reload()}}async function $(e,t){let n=await I(`/api/auth/view-as`,{method:`POST`,credentials:`same-origin`,headers:{"content-type":`application/json`,...t?{"x-csrf-token":t}:{}},body:JSON.stringify({userId:e})});if(!n.ok)throw Error(`HTTP ${n.status}`);location.assign(`/`)}async function me(e){try{await I(`/api/auth/view-as`,{method:`DELETE`,credentials:`same-origin`,headers:e?{"x-csrf-token":e}:{}})}catch{}location.assign(o[`admin-users`])}async function he(e){let t=await I(`/api/teams/${encodeURIComponent(e)}/share`,{credentials:`same-origin`});if(!t.ok)throw Error(`Could not load public links (${t.status})`);return(await t.json()).shares}async function ge(e,t,{id:n,revoke:r=!1,dependencies:i=!1,security:a=!1}={}){let o=n?`/${encodeURIComponent(n)}`:``,s=await I(`/api/teams/${encodeURIComponent(e)}/share${o}`,{method:r?`DELETE`:n?`PATCH`:`POST`,credentials:`same-origin`,headers:{"x-csrf-token":t,"content-type":`application/json`},...r?{}:{body:JSON.stringify({dependencies:i,security:a})}});if(!s.ok)throw Error(`Could not ${r?`revoke`:n?`update`:`create`} public link (${s.status})`);return s.json()}async function _e(e,t){let n=await I(`/api/bundles/${encodeURIComponent(e)}/download`,{credentials:`same-origin`});if(!n.ok)throw Error(`Could not download bundle (${n.status})`);let r=URL.createObjectURL(await n.blob()),i=document.createElement(`a`);i.href=r,i.download=t,i.click(),setTimeout(()=>URL.revokeObjectURL(r),6e4)}export{u as a,O as b,ee as c,I as d,L as e,R as f,z as g,B as h,G as i,ne as j,Z as k,re as l,ie as m,Q as n,ae as o,oe as p,se as q,ce as r,le as s,ue as t,de as u,fe as v,pe as w,$ as x,me as y,he as z,ge as A,_e as B};
@@ -0,0 +1 @@
1
+ import{j as e}from"./chunk-QRKFPLA4.js";var t=new Set([`overview`,`graph`,`treemap`,`compare`,`advisories`,`issues`,`code`,`search`,`terminal`]),n=/^\d+$/u;function r(e){for(let t=0;t<e.length;t++){let n=e.codePointAt(t);if(n<32||n===127)return!0}return!1}var i=512;function a(e){return typeof e==`string`&&e.length>0&&e.length<=i&&!r(e)}function o(e){return a(e)&&!n.test(e)}function s(e){return e===`completed`||e===`not_planned`||e===`duplicate`?e:`unknown`}function c(e){let[t,n,r]=e.split(`/`);return r===void 0&&t!==void 0&&n!==void 0&&t.length<=39&&/^[a-zA-Z\d](?:-?[a-zA-Z\d])*$/u.test(t)&&n.length<=100&&n!==`.`&&n!==`..`&&/^[a-zA-Z\d._-]+$/u.test(n)}function l(e,t){if(typeof e!=`string`||e.length>2048)return null;let n;try{n=new URL(e)}catch{return null}if(n.href!==e||n.origin!==`https://github.com`||n.username||n.password)return null;let r=t.exec(n.pathname);if(!r)return null;let i=`${r[1]}/${r[2]}`,a=Number(r[3]);return!c(i)||!Number.isSafeInteger(a)||a<=0?null:{repo:i,number:a}}function u(e){return l(e,/^\/([^/]+)\/([^/]+)\/pull\/(\d+)(?:\/(?:files|commits|checks))?\/?$/u)}function d(e){return l(e,/^\/([^/]+)\/([^/]+)\/issues\/(\d+)\/?$/u)}function f(e){let t=u(e);if(t)return{...t,kind:`pull`};let n=d(e);return n?{...n,kind:`issue`}:null}function p(e){return`${e.repo.toLowerCase()}#${e.kind}:${e.number}`}var m=/^(?=.{1,214}$)(?:@[\w.-]+\/[\w-]|[\dA-Za-z])[\w.-]*$/u,h=/^(?=.{1,256}$)[\dA-Za-z][\w.+-]*$/u,g=/^@[\da-z~-][\w.~-]*$/u,ee=/^[\da-f]{64}$/u;function _(e){return typeof e==`string`&&m.test(e)}function v(e){return typeof e==`string`&&h.test(e)}function y(e){return typeof e==`string`&&ee.test(e)}function b(e){return typeof e==`string`&&e.length>0&&e.length<=1024&&!/[\p{Cc}\\]/u.test(e)&&e.split(`/`).every(e=>e!==``&&e!==`.`&&e!==`..`)}function x(e){if(typeof e!=`string`)return null;let t=e.trim().toLowerCase(),n=t.startsWith(`@`)?t:`@${t}`;return n.length<=214&&g.test(n)?n:null}var S=e=>typeof e==`string`&&e.length>0&&e.length<=256&&!/[\p{Cc}]/u.test(e);function C(t){let n=t.get(`repo`),r=new Set((t.get(`severity`)??``).split(`,`)),i=e.filter(e=>r.has(e)),a={...S(n)?{repo:n}:{},...i.length>0?{severities:i}:{}};return Object.keys(a).length>0?{filters:a}:{}}function w(t){let n=e.filter(e=>t?.severities?.includes(e)),r=[...S(t?.repo)?[`repo=${encodeURIComponent(t.repo).replaceAll(`%2F`,`/`)}`]:[],...n.length>0?[`severity=${n.join(`,`)}`]:[]];return r.length>0?`?${r.join(`&`)}`:``}var T=new Set([`code`,`diff`]),E=e=>T.has(e)?`code`:`overview`,D=e=>T.has(e)?{compareMode:`code`}:{},O=e=>T.has(e)?`/code`:``,k=Object.freeze({manage:`/manage`,"manage-bundles":`/manage/bundle`,"manage-scans":`/manage/scans`,"manage-reports":`/manage/report`,"manage-repos":`/manage/repositories`,"manage-repo-risk":`/manage/repositories/risk`,"admin-users":`/manage/users`,"manage-teams":`/manage/team`,"manage-import":`/manage/import`,"manage-links":`/manage/links`,"manage-deduplication":`/manage/deduplication`,"manage-history":`/manage/history`}),A=new Set([`workspace-reports`,`workspace-bundles`,`workspace-repositories`,`workspace-dependencies`]),j=new Set([`pulls`,`versions`,`branch`,`reviews`]),M=e=>e.view===`workspace-dependencies`&&e.dependencyTab!=null?{dependencyTab:e.dependencyTab}:{};function N(e){if(!o(e)||e===`.`||e===`..`)return null;try{return`/finding/${encodeURIComponent(e)}`}catch{return null}}function P(e){if(!e)return null;if(e.view===`home`)return`/`;if(e.view===`reviews`)return`/my/reviews`;if(e.view===`profile`)return`/my/profile`;if(e.view===`npm`)return L(e);if(e.view===`repository-code`)return J(e);if(A.has(e.view)){let t=M(e).dependencyTab??`pulls`;return!/^[A-Za-z0-9_-]+$/u.test(e.teamSlug??``)||!j.has(t)?null:`/team/${e.teamSlug}/${e.view.slice(10)}${t===`pulls`?``:`/${t}`}`}if(e.view===`bundles`){if(!/^[A-Za-z0-9_-]+$/u.test(e.bundleSlug??``)||[e.teamSlug,e.compareSlug].some(e=>e!=null&&!/^[A-Za-z0-9_-]+$/u.test(e)))return null;let n=e.bundleTab??`overview`;if(!t.has(n))return null;let r=e.teamSlug?`/team/${e.teamSlug}`:`/manage`,i=n===`code`&&X(e.file)?`/${e.file}`:``,a=i&&X(e.line)?`#L${e.line}${X(e.endLine)&&e.endLine>e.line?`-L${e.endLine}`:``}`:``,o=n===`compare`&&e.compareSlug!=null?`/${e.compareSlug}${O(e.compareMode)}`:``;return`${r}/bundle/${e.bundleSlug}${n===`overview`?``:`/${n}`}${i}${o}${a}`}if(Object.hasOwn(k,e.view)){let t=k[e.view];return e.view===`manage-deduplication`&&e.linkId?`${t}?report=${encodeURIComponent(e.linkId)}`:e.view===`manage-bundles`&&Number.isSafeInteger(e.createRepoId)&&e.createRepoId>0?`${t}?createRepo=${e.createRepoId}`:e.view===`manage-scans`&&e.scanMode===`link`?`${t}?mode=link`:e.view===`manage-scans`&&e.bundleId?`${t}?bundle=${encodeURIComponent(e.bundleId)}${e.scanMode===`dependencies`?`&mode=dependencies`:``}`:e.view===`manage-history`&&e.actor?`${t}?actor=${encodeURIComponent(e.actor)}`:t}if(![`findings`,`files`].includes(e.view)||!e.teamSlug||[e.teamSlug,e.reportSlug].some(e=>e!=null&&!/^[A-Za-z0-9_-]+$/u.test(e)))return null;let n=`/team/${encodeURIComponent(e.teamSlug)}`,r=e.reportSlug?`/report/${encodeURIComponent(e.reportSlug)}`:``;if(e.finding){let t=N(e.finding.id);return e.view===`findings`&&t?`${n}${r}${t}`:null}return e.view===`files`?`${n}${r}/files`:`${n}${r}${r?``:w(e.filters)}`}var F=new Set([`overview`,`code`,`search`,`compare`,`review`,`treemap`]),I=e=>y(e?.hash)&&(K(e.repoId)||typeof e.repoId==`string`&&c(e.repoId))&&W.test(e.commit??``)&&b(e.path);function L(e){if(e.packageName==null)return`/npm`;let t=e.bundleTab??`overview`;if(!_(e.packageName)||e.packageSpec!=null&&!v(e.packageSpec)||!F.has(t)||e.compareSpec!=null&&!v(e.compareSpec))return null;if(t===`review`){if(e.reviewPackage!=null&&!_(e.reviewPackage)||e.reviewSpec!=null&&!v(e.reviewSpec)||e.patch!=null&&!I(e.patch))return null;let t=e.reviewPackage==null?``:`/${e.reviewPackage}${e.reviewSpec==null?``:`@${e.reviewSpec}`}`,n=e.patch==null?``:`?patch=${e.patch.hash}&repo=${e.patch.repoId}&commit=${e.patch.commit}&path=${e.patch.path.split(`/`).map(encodeURIComponent).join(`/`)}`;return`/npm/${e.packageName}${e.packageSpec==null?``:`@${e.packageSpec}`}/review${t}${n}`}let n=t===`code`&&X(e.file)?`/${e.file}`:``,r=n&&X(e.line)?`#L${e.line}${X(e.endLine)&&e.endLine>e.line?`-L${e.endLine}`:``}`:``,i=t===`compare`&&e.compareSpec!=null?`/${e.compareSpec}${O(e.compareMode)}`:``;return`/npm/${e.packageName}${e.packageSpec==null?``:`@${e.packageSpec}`}${t===`overview`?``:`/${t}`}${n}${i}${r}`}function R(e,t,n){let r=/^\/npm\/((?:@[^/@]+\/)?[^/@]+)(?:@([^/]+))?\/review(?:\/((?:@[^/@]+\/)?[^/@]+)(?:@([^/]+))?)?$/u.exec(e);if(r){if(!_(r[1])||r[2]!=null&&!v(r[2])||r[3]!=null&&!_(r[3])||r[4]!=null&&!v(r[4]))return null;let e=r[3]&&/^\d+\.\d+\.\d+(?:[-+].*)?$/u.test(r[3])&&r[4]==null,t=n.has(`patch`)?{hash:n.get(`patch`),repoId:/^[1-9]\d*$/u.test(n.get(`repo`)??``)?Number(n.get(`repo`)):n.get(`repo`),commit:n.get(`commit`),path:n.get(`path`)}:null;return t&&!I(t)?null:{view:`npm`,packageName:r[1],packageSpec:r[2]??null,bundleTab:`review`,...r[3]?{reviewPackage:e?r[1]:r[3],reviewSpec:e?r[3]:r[4]??null}:{},...t?{patch:t}:{}}}let i=/^\/npm(?:\/((?:@[^/@]+\/)?[^/@]+)(?:@([^/]+))?(?:\/(code|search|compare|treemap)(?:\/([^/]+)(?:\/([a-z]+))?)?)?)?$/u.exec(e);if(!i)return;if(i[1]==null)return{view:`npm`};if(!_(i[1])||i[2]!=null&&!v(i[2]))return null;let a={view:`npm`,packageName:i[1],packageSpec:i[2]??null,bundleTab:i[3]??`overview`};if(i[4]==null)return a;if(a.bundleTab===`compare`)return v(i[4])&&(i[5]==null||T.has(i[5]))?{...a,compareSpec:i[4],...D(i[5])}:null;if(a.bundleTab!==`code`)return null;let o=Number(i[4]);return!i[5]&&/^[1-9]\d*$/u.test(i[4])&&Number.isSafeInteger(o)?{...a,file:o,...Z(t)}:null}var z=new Set([`code`,`search`,`treemap`,`compare`,`commits`,`issues`,`pulls`,`agents`,`pulse`,`replay`]),B=new Set([`commits`,`issues`,`pulls`,`agents`,`pulse`,`replay`]),V=new Map([[`issues`,new Set([`closed`])],[`pulls`,new Set([`closed`])],[`pulse`,new Set([`week`,`quarter`,`year`])],[`replay`,new Set([`100`,`1000`])]]),H=/^[a-z][a-z\d-]{0,31}$/u,U=(e,t)=>e===`agents`?typeof t==`string`&&H.test(t)&&t!==`all`:V.get(e)?.has(t)===!0,W=/^[a-f\d]{40}$/u,G=500,K=e=>Number.isSafeInteger(e)&&e>0;function q(e){return typeof e==`string`&&(e===``||e.length<=G&&!/[\p{Cc}\\]/u.test(e)&&e.split(`/`).every(e=>e!==``&&e!==`.`&&e!==`..`&&e===e.trim()))}function J(e){let t=e.bundleTab??`code`,n=e.path??``;if(!K(e.repoId)||e.commit!=null&&!W.test(e.commit)||!q(n)||!z.has(t)||e.compareCommit!=null&&!W.test(e.compareCommit))return null;let r=n?`?path=${n.split(`/`).map(encodeURIComponent).join(`/`)}`:``;if(e.commit==null)return`/repo/${e.repoId}${r}`;let i=t===`code`&&X(e.file)?`/code/${e.file}`:t===`code`?``:`/${t}`,a=t===`compare`&&e.compareCommit!=null?`/${e.compareCommit}${O(e.compareMode)}`:``,o=U(t,e.subtab)?`/${e.subtab}`:``,s=t===`code`&&X(e.file)&&X(e.line)?`#L${e.line}${X(e.endLine)&&e.endLine>e.line?`-L${e.endLine}`:``}`:``;return`/repo/${e.repoId}/${e.commit}${i}${a}${o}${r}${s}`}function Y(e){let t=/^\/(?:repo|manage\/code)\/([1-9]\d*)(?:\/([a-f\d]{40})(?:\/(code|search|treemap|compare|commits|history|issues|pulls|agents|pulse|replay)(?:\/([^/]+)(?:\/([a-z]+))?)?)?)?$/u.exec(e.pathname.replace(/\/$/u,``));if(!t)return;let n=Number(t[1]),r=e.searchParams.get(`path`)??``,i=t[3]===`history`?`commits`:t[3]??`code`;if(!K(n)||!q(r))return null;let a={view:`repository-code`,repoId:n,commit:t[2]??null,path:r,bundleTab:i};if(t[4]==null)return a;if(i===`compare`)return W.test(t[4])&&(t[5]==null||T.has(t[5]))?{...a,compareCommit:t[4],...D(t[5])}:null;if(B.has(i))return t[5]==null&&U(i,t[4])?{...a,subtab:t[4]}:null;let o=Number(t[4]);return i===`code`&&t[5]==null&&/^[1-9]\d*$/u.test(t[4])&&Number.isSafeInteger(o)?{...a,file:o,...Z(e.hash)}:null}function X(e){return Number.isSafeInteger(e)&&e>0}function Z(e){let t=/^#L([1-9]\d*)(?:-L([1-9]\d*))?$/u.exec(e),[n,r]=t?[Number(t[1]),Number(t[2]??t[1])]:[];return!X(n)||!X(r)?{}:n===r?{line:n}:{line:Math.min(n,r),endLine:Math.max(n,r)}}function Q(e){let n=e.pathname.replace(/\/$/u,``)||`/`;if(n===`/`||n===`/index.html`)return{view:`home`};if(n===`/my/reviews`)return{view:`reviews`};if(n===`/my/profile`){let t=e.searchParams.get(`link-error`);return{view:`profile`,...t&&/^[a-z-]{1,64}$/u.test(t)?{linkError:t}:{}}}let r=Object.keys(k).find(e=>k[e]===n);if(r){let t=Number(e.searchParams.get(`createRepo`));return{view:r,...r===`manage-deduplication`&&e.searchParams.get(`report`)?{linkId:e.searchParams.get(`report`)}:{},...r===`manage-bundles`&&Number.isSafeInteger(t)&&t>0?{createRepoId:t}:{},...r===`manage-history`&&e.searchParams.get(`actor`)?{actor:e.searchParams.get(`actor`)}:{},...r===`manage-scans`?e.searchParams.get(`mode`)===`link`?{scanMode:`link`}:e.searchParams.get(`bundle`)?{bundleId:e.searchParams.get(`bundle`),...e.searchParams.get(`mode`)===`dependencies`?{scanMode:`dependencies`}:{}}:{}:{}}}let a=/^(?:\/team\/([A-Za-z0-9_-]+)|\/manage)\/bundle\/([A-Za-z0-9_-]+)(?:\/([a-z]+)(?:\/([A-Za-z0-9_-]+)(?:\/([a-z]+))?)?)?$/u.exec(n);if(a){let n=a[3]??`overview`;if(!t.has(n))return null;let r={view:`bundles`,teamSlug:a[1]??null,bundleSlug:a[2],bundleTab:n};if(a[4]==null)return r;if(n===`compare`)return a[5]==null||T.has(a[5])?{...r,compareSlug:a[4],...D(a[5])}:null;let i=Number(a[4]);return n!==`code`||a[5]||!/^[1-9]\d*$/u.test(a[4])||!Number.isSafeInteger(i)?null:{...r,file:i,...Z(e.hash)}}let o=R(n,e.hash,e.searchParams);if(o!==void 0)return o;let s=Y(e);if(s!==void 0)return s;let c=/^\/team\/([A-Za-z0-9_-]+)\/(reports|bundles|repositories|dependencies)$/u.exec(n);if(c)return{view:`workspace-${c[2]}`,teamSlug:c[1]};let l=/^\/team\/([A-Za-z0-9_-]+)\/dependencies\/([a-z]+)$/u.exec(n);if(l)return j.has(l[2])?{view:`workspace-dependencies`,teamSlug:l[1],dependencyTab:l[2]}:null;let u=/^\/team\/([^/]+)(?:\/report\/([^/]+))?(?:\/(files)|\/finding\/([^/]+))?$/u.exec(n);if(!u)return null;try{let t=decodeURIComponent(u[1]),n=u[2]?decodeURIComponent(u[2]):null;if([t,n].some(e=>e!=null&&!/^[A-Za-z0-9_-]+$/u.test(e))||u[4]?.length>i*9)return null;let r=u[4]?decodeURIComponent(u[4]):null;return r!=null&&!N(r)?null:u[3]?{view:`files`,teamSlug:t,reportSlug:n}:r==null?{view:`findings`,teamSlug:t,reportSlug:n,...n==null?C(e.searchParams):{}}:{view:`findings`,teamSlug:t,reportSlug:n,finding:{id:r}}}catch{return null}}function $(e,t,n=[]){if(A.has(e.view)){let n=t.filter(t=>t.slug===e.teamSlug);return n.length===1?{view:e.view,teamId:n[0].id,...M(e)}:null}if(e.view===`bundles`){let{teamSlug:r,bundleSlug:i,compareSlug:a,compareMode:o,...s}=e,c=r==null?[]:t.filter(e=>e.slug===r);if(r!=null&&c.length!==1)return null;let l=c[0],u=r==null?n:t.flatMap(e=>e.bundles??[]),d=e=>new Set(u.filter(t=>t.slug===e).map(e=>e.id)),f=d(i),p=(l?.bundles??n).find(e=>e.slug===i);if(!i||!p||f.size!==1)return null;let m=a==null?null:d(a),h=m?.size===1?{compareId:[...m][0],...D(o)}:{};return{...s,teamId:l?.id??null,bundleId:p.id,...h}}if(![`findings`,`files`].includes(e.view))return e;let{teamSlug:r,reportSlug:i,...a}=e,o=t.filter(e=>e.slug===r),s=r&&o.length===1?o[0]:null,c=new Set(t.flatMap(e=>e.reports??[]).filter(e=>e.slug===i).map(e=>e.id)),l=i!=null&&c.size===1?[...c][0]:null;return a.finding?{...a,teamId:s?.id??null,reportId:l,teamOnly:i==null}:s?i==null?{...a,teamId:s.id,reportId:null}:(s.reports??[]).some(e=>e.id===l)?{...a,teamId:s.id,reportId:l}:null:null}function te(e,t,n=[]){if(A.has(e.view)){let n=t.find(t=>t.id===e.teamId),r={view:e.view,teamSlug:n?.slug,...M(e)};return n?.slug&&$(r,t)?r:null}if(e.view===`bundles`){let{teamId:r,bundleId:i,compareId:a,compareMode:o,...s}=e,c=t.find(e=>e.id===r);if(r!=null&&!c?.slug)return null;let l=(c?.bundles??n).find(e=>e.id===i);if(!l?.slug)return null;let u=a==null?null:(r==null?n:t.flatMap(e=>e.bundles??[])).find(e=>e.id===a),d={...s,teamSlug:c?.slug??null,bundleSlug:l.slug,...u?.slug?{compareSlug:u.slug,...D(o)}:{}},f=$(d,t,n);if(!f)return null;if(d.compareSlug!=null&&f.compareId!==a){let{compareSlug:e,compareMode:t,...n}=d;return n}return d}if(![`findings`,`files`].includes(e.view))return e;let{teamId:r,reportId:i,...a}=e,o=t.find(e=>e.id===r),s=i==null?null:o?.reports?.find(e=>e.id===i);if(!o?.slug||i!=null&&!s?.slug)return null;let c={...a,teamSlug:o.slug,reportSlug:s?.slug??null},l=$(c,t);return l?.teamId===o.id&&l.reportId===(s?.id??null)?c:null}export{t as a,i as b,o as c,s as d,u as e,d as f,f as g,p as h,_ as i,v as j,y as k,b as l,x as m,E as n,D as o,k as p,j as q,P as r,F as s,z as t,B as u,U as v,Q as w,$ as x,te as y};
@@ -0,0 +1,42 @@
1
+ import{b as e,h as t}from"./chunk-R3WUYD4F.js";import{a as n}from"./chunk-D6NVKGGG.js";import{a as r,b as i,e as a}from"./chunk-IYPY47MC.js";import{A as o,B as s,D as c,E as l,b as u,c as d,d as f,j as p,m,p as h,s as g,t as _,w as v,z as y}from"./chunk-QRKFPLA4.js";import{B as b,b as x,c as S,i as C,x as ee,z as w}from"./chunk-74AEKRES.js";import{a as T,b as E,c as D}from"./chunk-C4Z6ZBXV.js";import{c as O,f as k,g as A,i as te}from"./chunk-2XUEZHIP.js";var ne=E(class extends D{constructor(e){if(super(e),e.type!==T.ATTRIBUTE||e.name!==`class`||e.strings?.length>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(e){return` `+Object.keys(e).filter(t=>e[t]).join(` `)+` `}update(e,[t]){if(this.st===void 0){this.st=new Set,e.strings!==void 0&&(this.nt=new Set(e.strings.join(` `).split(/\s/).filter(e=>e!==``)));for(let e in t)t[e]&&!this.nt?.has(e)&&this.st.add(e);return this.render(t)}let n=e.element.classList;for(let e of this.st)e in t||(n.remove(e),this.st.delete(e));for(let e in t){let r=!!t[e];r===this.st.has(e)||this.nt?.has(e)||(r?(n.add(e),this.st.add(e)):(n.remove(e),this.st.delete(e)))}return k}});function re(e){let t=typeof e==`string`?e.trim():``;return/^[0-9a-f]{7,64}$/iu.test(t)?t:``}function ie(e){return re(e?.commit)}function j(e,t){return typeof e==`string`&&typeof t==`string`&&e!==``&&e.toLowerCase()===t.toLowerCase()}function ae(e,t){return j(t,c(e))?ie(e?.repo):``}function oe(e,t){let n=e?.advisory?.package,r=e?.repo?.github;if(typeof n!=`string`||n===``||typeof r!=`string`||r===``)return!1;let i=c({repo:{github:r}}),a=i?.split(`/`)[1].toLowerCase();return a!==n.toLowerCase()&&a!==n.replace(/^@[^/]+\//u,``).toLowerCase()?!1:!j(i,typeof t==`string`&&t!==``?c({repo:{github:t}})??t:``)}function se(e,t){if(!oe(e,t))return e;let{repo:n,...r}=e;return{...r,_repoIgnored:!0}}var ce=e=>e.replaceAll(`&`,`&amp;`).replaceAll(`<`,`&lt;`).replaceAll(`>`,`&gt;`),le=e=>x(e)?e:ce(S(String(e))),M=globalThis.trustedTypes?.createPolicy(`deepview`,{createHTML:le,createScriptURL:e=>{let t=new URL(e,globalThis.location.href);if(t.origin!==globalThis.location.origin)throw TypeError(`Not a same-origin script: ${t.href}`);return t.href}}),N=e=>M?M.createHTML(e):le(e),ue=e=>M?M.createScriptURL(String(e)):e,P={showAll:!1,packagesView:!1,dependencyPackagesView:!1,flowPackagesView:!1,bundleIssues:!1,bundleLayout:`graph`,lockfileLayout:`dependencies`,bundleReason:null,bundleReasonFor:null,selected:null,focusedPkg:null,topPkgsTab:`issues`,edgeOpacity:.22,nodeSize:1,showLabels:!1,selectedSeverities:new Set,selectedColors:new Set,pathFilter:``,hidden:new Set,solo:null,graphState:null,layoutCache:null,keptViewport:null};function de({keepViewport:e=!1}={}){P.graphState?._cleanup?P.graphState._cleanup({keepViewport:e}):e||(P.keptViewport=null),P.graphState=null}function F(e){return e.id??String(e._id)}function fe(e){let t=h(e);return t!==``&&t!==`revalidation`}var pe=[{value:`confirmed`,label:`Confirmed`,kinds:[`confirmed`,`partial`,`revalidation`]},{value:`unreachable`,label:`Unreachable`,kinds:[`unreachable`]},{value:`refuted`,label:`Refuted`,kinds:[`refuted`]}];function me(e){return pe.find(t=>t.value===e)?.kinds??null}var he=[``,`exclude`,`only`];function ge(e,t){let n=me(e);return n?.includes(`partial`)?t===`only`?[`partial`]:t===`exclude`?[`confirmed`]:n:n}function I(e){if(e.confidence!==void 0)return e.confidence;if(e.critical===!0||e._source)return 10}var _e=e=>e.confidence!==void 0||e.critical===!0;function ve(e){return e.every(e=>e.every(e=>I(e)!==void 0))&&e.some(e=>e.some(_e))}function ye(e,t,n){return e.some(e=>{let r=[`refuted`,`unreachable`].includes(n(e))?0:I(e);return r===void 0?t===0:r>=t})}function be(e,t){let n=e.map(t).filter(e=>e.length>0);if(!n.some(e=>e.some(e=>I(e)!==void 0)))return 0;let r=e=>n.reduce((t,n)=>t+ +!!n.some(t=>(I(t)??-1)>=e),0),i;for(i=r(6)<=25?6:r(7)<=25?7:8;i>0&&r(i-1)===r(i);)i--;return i}function xe(e,t){return ve(e)?t:0}function Se(e,t,n){let r=new Set(e.ruledOutIds??[]);for(let t of e)for(let e of t)[`refuted`,`unreachable`].includes(n(e))&&r.add(F(e));for(let i of e){let e=t(i);if(e.length!==0&&e.some(e=>ge(`confirmed`,``).includes(n(e)||(e._source&&!e._sourcePass?`revalidation`:``)))){for(let e of i)if(r.add(F(e)),e.isApp&&Array.isArray(e.revalidateInputs))for(let t of e.revalidateInputs)t&&r.add(t)}}return r}function Ce(e,t,n,r){let i=xe(e,t),a=e.filter(e=>ye(e,i,r));if(a.length===0)return!1;let o=new Set(ge(`confirmed`,``));return e.some(e=>e.some(e=>o.has(r(e))))?a.every(e=>e.every(e=>n.has(F(e)))):!1}function we(e,{tabs:t,kindOf:n,severityMode:r}){let i=e.map(t).filter(e=>e.length>0),a=Se(e,t,n);if(!Ce(i,be(e,t),a,n))return!1;let o=xe(i,6);return i.every(e=>!ye(e,o,n)||!e.some(e=>m(e,r)!==`low`)||e.every(e=>a.has(F(e))))}function Te(e){if(!e)return e;let t="`".repeat(Math.max(0,...[...e.matchAll(/`+/gu)].map(e=>e[0].length))+1),n=/^`|`$/u.test(e)||e.startsWith(` `)&&e.endsWith(` `)&&e.trim()!==``?` `:``;return`${t}${n}${e}${n}${t}`}var L=!0;function Ee(e,t=!1){L=e!==!1&&!t}function De(){return L}function R(e){return L?h(e):``}function Oe(e){return h(e)!==``}function ke(e){return e.some(e=>(e.groups??[]).some(e=>e.some(fe)))}function Ae(e){let t=R(e);return t&&t!==`revalidation`?t:null}function je(e){return R(e)===`revalidation`}var Me=new Set([`refuted`,`unreachable`]);function Ne(e){return Me.has(R(e))}function Pe(e){return Me.has(R(e))}function Fe(e){let t=new Set(e);return pe.filter(e=>e.kinds.some(e=>t.has(e)))}function z(e){return RegExp(`(^|/)${e}/`,`u`)}function Ie(e){return RegExp(`^(?:.*/)?${e}/(?:@[^/]+/[^/]+|[^/]+)/(.*)$`,`u`)}var Le=z(`node_modules`),Re=z(`vendor`),B=`node_modules`,ze=z(B),Be=Ie(B);function Ve(e){e!==B&&(B=e,ze=z(e),Be=Ie(e))}var He=null;function Ue(t){He?.length===t.length&&He.every((e,n)=>e===t[n])||(He=[...t],Ve(e(t)))}function We(){return B}function V(e){return ze.test(e)}var Ge=new WeakSet;function Ke(e){let t=!1;for(let n of e??[])for(let e of n.groups??[])for(let n of e){if(n.isApp!==!1)continue;let e=Ge.has(n);`isUpstream`in n&&!e||(V(n.file)?(n.isUpstream!==!0&&(t=!0),n.isUpstream=!0,Ge.add(n)):e&&(t=!0,delete n.isUpstream,Ge.delete(n)))}return t}function qe(e){let t=typeof e==`string`?e:``;return Le.test(t)||Re.test(t)||ze.test(t)}var Je=/^(.*(?:^|\/)node_modules\/(?:@[^/]+\/[^/]+|[^/]+))(?:\/|$)/u;function Ye(e){return Je.exec(typeof e==`string`?e:``)?.[1]??null}function Xe(e){if(typeof e!=`object`||!e)return null;for(let[t,n]of Object.entries(e))if(typeof n?.name==`string`&&n.name!==``)return`${t}:${n.name}@${typeof n.version==`string`?n.version:``}`;return null}var Ze=null,Qe={byRoot:new Map,byPackage:new Map},$e=e=>`${e?._managedReportId??``}\0${e?._reportName??``}`,et=(e,t)=>`${$e(e)}\0${t}`,tt=e=>c({repo:{github:e.id}})??e.id;function nt(e,t){if(e===null)return null;let n=U(t),r=U(e),[i,a]=[r.commit.toLowerCase(),n.commit.toLowerCase()];return!j(tt(r),tt(n))||r.prefix!==n.prefix||!(i.startsWith(a)||a.startsWith(i))?null:a.length>i.length?t:e}function rt(e){let t=Array.isArray(e)?e:[];if(Ze?.length===t.length&&Ze.every(([e,n],r)=>e===t[r]&&n===e?.groups))return;Ze=t.map(e=>[e,e?.groups]);let n=new Map,r=new Map,i=(e,t,n)=>e.set(t,e.has(t)?nt(e.get(t),n):n);for(let e of t)for(let t of e?.groups??[])for(let e of t){if(!e||e._repoIgnored||oe(e,e._repoFallback))continue;let t=U(e.repo);if(!t.id||!t.commit)continue;let a=Ye(e.file),o=Xe(e.package);if(a!==null){let t=et(e,a),n=r.get(t),i=n===void 0?e.repo:n&&n.pkg===o?nt(n.repo,e.repo):null;r.set(t,i&&{repo:i,pkg:o})}o!==null&&!o.endsWith(`@`)&&i(n,o,e.repo)}Qe={byRoot:r,byPackage:n}}function it(e){return typeof e!=`number`||!Number.isFinite(e)?null:n(e)}function at(e){if(e.length<=1)return{prefix:``,stripped:[...e]};let t=e.map(e=>e.split(`/`)),n=Math.min(...t.map(e=>e.length)),r=0;for(let e=0;e<n-1&&t.every(n=>n[e]===t[0][e]);e++)r=e+1;return r>0&&t[0][r-1].startsWith(`@`)&&r--,r>0&&t[0][r-1]===`node_modules`&&r--,r===0?{prefix:``,stripped:[...e]}:{prefix:`${t[0].slice(0,r).join(`/`)}/`,stripped:t.map(e=>e.slice(r).join(`/`))}}function ot(e){return e.match(Be)?.[1]??e}var H={on:new WeakMap,off:new WeakMap};function st(e){let t=L?H.on:H.off,n=t.get(e);if(n===void 0){let r=L?[Ae(e),e.revalidateVerdict,e.revalidateRecommendation]:[];n=[e.file,e.title,e.description,e.impact,e.reproduction,tn(e),e.recommendation,e.confidenceReason,...r,e.discoveredIn,e.repo?.github].filter(Boolean).join(`
2
+ `).toLowerCase(),t.set(e,n)}return n}function ct(e){H.on.delete(e),H.off.delete(e)}function lt(e){return[typeof e?.category==`string`?e.category.trim():``,g(e,L)].filter(Boolean).join(` · `)}function ut(e){if(e.length===0)return``;let t=e[0];for(let n=1;n<e.length;n++){for(;t&&!e[n].startsWith(t);)t=t.slice(0,-1);if(!t)return``}return t}function dt(e){if(!e)return``;let t=e.match(/github\.com\/([^/?#]+\/[^/?#]+?)(?:\.git)?(?:[/?#]|$)/iu);return t?t[1]:e}function ft(e){if(!e)return null;let t=e.trim().replace(/\/$/u,``);return t?/^https?:\/\//iu.test(t)?t:/^github\.com\//iu.test(t)?`https://${t}`:`https://github.com/${t}`:null}var pt=/^(?:@[\w.-]+\/)?[\w.-]+@[^/\s@]+$/u;function mt(e){return pt.test(e||``)}function U(e){if(e==null||typeof e==`string`)return{id:e??``,prefix:``,commit:``};let t=l(e);return{id:typeof e.github==`string`?e.github:``,prefix:t?`${t}/`:``,commit:ie(e)}}function ht(e,t,n,r=``){if(mt(e))return null;let i=U(t),a=U(n),o=re(r);if(i.id){let t=c({repo:{github:i.id}}),n=ft(t??i.id),r=j(t,c({repo:{github:a.id}}));return`${n}/blob/${i.commit||(r?a.commit:``)||(r||!qe(e)?o:``)||`HEAD`}/${i.prefix}${ot(e)}`}if(V(e))return null;let s=ft(a.id);return s?`${s}/blob/${a.commit||o||`HEAD`}/${a.prefix}${e}`:null}function gt(e,t){let n=e?.file??``,r=W(e,t);return r?O`<a href="${_t(r)}" target="_blank" rel="noopener">${n}</a>`:n}function _t(e){return e.replace(/#L\d+(?:-L?\d+)?$/u,``)}function vt({start:e,end:t}){return t>e?`#L${e}-L${t}`:`#L${e}`}function W(e,t){if(!e)return null;if(s(e.location))return e.location;let n=ht(e.file,e.repo,t,e.auditedCommit);if(!n)return null;let r=q(e.line);if(r)return`${n}${vt(r)}`;let i=parseInt(e.line,10);return Number.isFinite(i)?`${n}#L${i}`:n}var yt=/^https?:\/\/(?:www\.)?github\.com\/([^/\s]+\/[^/\s]+)\/(?:blob|tree|blame)\/[^/\s]+\/(\S+)$/u,bt=/#L(\d+)(?:-L?(\d+))?$/u;function xt(e){let t=typeof e==`string`?yt.exec(e):null;if(!t)return``;let n=t[2],r=bt.exec(n);if(!r)return`${t[1]}/${n}`;n=n.slice(0,r.index);let i=r[2]?`${r[1]}-${r[2]}`:r[1];return`${t[1]}/${n}:${i}`}var St=/^(?:\s+\S|[-*+] |\d+[.)] |>|#{1,6}(?:[ \t]|$)|\||`{3}|~{3})/u;function Ct(e){return e.split(/(\n{2,})/u).map(e=>{if(/^\n+$/u.test(e))return e;let t=e.split(`
3
+ `);return t.some(e=>St.test(e)||K.test(e))?e:t.map(e=>e.trim()).filter(Boolean).join(` `)}).join(``)}function wt(e,t,n){let r=t?/^\n*/u.exec(e)[0]:``,i=e.slice(r.length),a=n?/\n*$/u.exec(i)[0]:``;return r+Ct(i.slice(0,i.length-a.length))+a}function Tt(e){if(!e)return e;let t=e.replaceAll(`\r
4
+ `,`
5
+ `),n=u(t);if(n.length===0)return Ct(t);let r=[],i=0;for(let[e,a]of n)e>i&&r.push(wt(t.slice(i,e),i>0,!0)),r.push(t.slice(e,a)),i=a;return i<t.length&&r.push(wt(t.slice(i),!0,!1)),r.join(``)}var Et=/^( *)(`{3,}|~{3,})(.*)$/u,Dt=/^[a-z0-9+#._-]{1,20}$/u;function Ot(e,t){let n=0;for(;n<t&&e[n]===` `;)n++;return e.slice(n)}function kt(e){let t=e.split(`
6
+ `),n=Et.exec(t[0]),r=(n?.[2]??"```").slice(0,3),i=(n?.[3]??``).trim().split(/\s+/u)[0].toLowerCase(),a=!!(t.length>1?Et.exec(t.at(-1)):null)?.[2].startsWith(r),o=n?.[1].length??0,s=t.slice(1,a?-1:void 0);return{lang:Dt.test(i)?i:``,code:(o>0?s.map(e=>Ot(e,o)):s).join(`
7
+ `)}}function At(e){let t=u(e||``);if(t.length===0)return[e];let n=[],r=0,i=(e,t)=>{let r=(t?e.replace(/^\n+/u,``):e).replace(/\n+$/u,``);r&&n.push(r)};for(let[a,o]of t)a>r&&i(e.slice(r,a),r>0),n.push(kt(e.slice(a,o))),r=o;return r<e.length&&i(e.slice(r),!0),n}var G=/^( *)(?:[-*+]|(\d{1,9})[.)]) +(?=\S)/u,K=/^ {0,3}([-*_])(?:[ \t]*\1){2,}[ \t]*$/u;function jt(e){return/^ */u.exec(e)[0].length}function Mt(e){let t=e.length;for(;t>0&&!e[t-1].trim();)t--;return e.slice(0,t).join(`
8
+ `)}function Nt(e){let t=[],n=0;for(let r of e)t.push(n),n+=r.length+1;return t}function Pt(e){let t=typeof e==`string`?e:``;if(!t)return[e];let n=u(t),r=t.split(`
9
+ `),i=Nt(r),a=e=>!d(n,i[e])&&!K.test(r[e])&&G.test(r[e]),o=[],s=0,c=0,l=e=>{let t=r.slice(s,e).join(`
10
+ `).replace(/^\n+/u,``).replace(/\n+$/u,``);t.trim()&&o.push(t)};for(;c<r.length;){if(!a(c)){c++;continue}l(c);let e=G.exec(r[c]),t=!!e[2],u=[],f=null,p=!1;for(;c<r.length;){let e=r[c];if(!d(n,i[c])){if(!e.trim()){f.lines.push(``),p=!0,c++;continue}let n=jt(e),r=K.test(e)?null:G.exec(e);if(r&&(!f||n<f.column)){if(!!r[2]!==t)break;f&&u.push(Mt(f.lines)),f={column:r[0].length,lines:[e.slice(r[0].length)]},p=!1,c++;continue}if(n<f.column&&(p||Ft.test(e)||K.test(e)||Rt.test(e)))break}f.lines.push(Ot(e,f.column)),p=!1,c++}f&&u.push(Mt(f.lines)),o.push({ordered:t,start:t?Number(e[2]):null,items:u}),s=c}return o.length===0?[e]:(l(r.length),o)}var Ft=/^ {0,3}(#{1,6})[ \t]+(\S.*?)(?:[ \t]+#+)?[ \t]*$/u,It=/^ {0,3}-+[ \t]*$/u;function Lt(e){let t=e.split(`
11
+ `),n=[],r=0,i=e=>{let i=t.slice(r,e).join(`
12
+ `).replaceAll(/^(?:[ \t]*\n)+|(?:\n[ \t]*)+$/gu,``);i.trim()&&n.push(i)};return t.forEach((e,a)=>{let o=Ft.exec(e),s=K.test(e)&&(a===r||!t[a-1].trim()||!It.test(e));!o&&!s||(i(a),n.push(o?{level:o[1].length,text:o[2]}:{rule:!0}),r=a+1)}),n.length===0?[e]:(i(t.length),n)}var Rt=/^ {0,3}>/u,zt=/^ {0,3}> ?/u,Bt=/^[ \t]*\[!(note|tip|important|warning|caution)\][ \t]*$/iu,Vt=/^ {0,3}(?:`{3}|~{3})/u,Ht=/^(?: {0,3}> ?| *(?:[-*+]|\d{1,9}[.)])(?: +|$))*/u,Ut=16,Wt=e=>Ft.test(e)||K.test(e)||Vt.test(e);function Gt(e,t){let n=Et.exec(t);return n?e?n[2][0]===e[0]&&n[2].length>=e.length&&!n[3].trim()?``:e:n[2][0]==="`"&&n[3].includes("`")?``:n[2]:e}function Kt(e){let t=0,n=e.length;for(;t<n&&!e[t].trim();)t++;for(;n>t&&!e[n-1].trim();)n--;return e.slice(t,n).join(`
13
+ `)}function qt(e,{alerts:t=!0}={}){let n=typeof e==`string`?e:``;if(!/^ {0,3}>/mu.test(n))return[e];let r=u(n),i=n.split(`
14
+ `),a=Nt(i),o=e=>Rt.test(i[e])&&!d(r,a[e]),s=[],c=0,l=0;for(;l<i.length;){if(!o(l)){l++;continue}l>c&&s.push(i.slice(c,l).join(`
15
+ `));let e=[],n=``,r=!1;for(;l<i.length;l++){let t=i[l];if(o(l)){let i=t.replace(zt,``),a=n!==``;n=Gt(n,i);let o=i.replace(Ht,``);r=!a&&!n&&o.trim()!==``&&!Wt(o),e.push(i)}else if(r&&t.trim()&&!Wt(t)&&!G.test(t))e.push(t);else break}let a=t?Bt.exec(e[0]):null,u=a?Kt(e.slice(1)):``;s.push({quote:!0,alert:u?a[1].toLowerCase():null,body:u||Kt(e)}),c=l}return c<i.length&&s.push(i.slice(c).join(`
16
+ `)),s}function Jt(e,t=Ut){return t<=0?e:qt(e).map(e=>typeof e==`string`?e:Jt(e.body,t-1)).join(`
17
+ `)}var Yt=/^(\d+)(?:\s*-\s*(\d+))?$/u;function q(e){if(typeof e==`number`)return Number.isFinite(e)&&e>=1?{start:Math.floor(e),end:Math.floor(e)}:null;let t=Yt.exec(String(e??``).trim());if(!t)return null;let n=parseInt(t[1],10),r=t[2]===void 0?n:parseInt(t[2],10);return!Number.isFinite(n)||n<1||!Number.isFinite(r)||r<1?null:{start:Math.min(n,r),end:Math.max(n,r)}}function Xt(e){return e?e.start===e.end?String(e.start):`${e.start}-${e.end}`:``}function Zt(e){if(e&&typeof e==`object`){let t=q(e.start);if(!t)return null;let n=q(e.end)??t;return{start:t.start,end:Math.max(t.start,n.end)}}return q(e)}function Qt(e,t,n=4){let r=typeof e==`string`&&e!==``?e.split(`
18
+ `):[];if(r.length===0)return{text:``,startLine:1,lines:[]};let i=Zt(t),a=i&&{start:Math.min(i.start,r.length),end:Math.min(i.end,r.length)},o=a?Math.max(1,a.start-n):1,s=a?Math.min(r.length,a.end+n):Math.min(r.length,n*2+1),c=r.slice(o-1,s);return{text:c.join(`
19
+ `),startLine:o,lines:c}}function $t(e,t,n,r,i=null){if(s(e?.url))return e.url;let a=e?.file;if(typeof a!=`string`||a===``)return null;let o=t?.file??``,c=t?.repo?.github,l=t?.auditedCommit,u=()=>c?W({file:a,line:e?.line,repo:t.repo,auditedCommit:l},n):null;if(r===0&&a===o)return W(String(e?.line??``).trim()===String(t?.line??``).trim()?t:{file:a,line:e?.line,repo:t.repo,auditedCommit:l},n);if(U(e?.repo).id)return W({file:a,line:e?.line,repo:e.repo},n);let d=Ye(a),f=Xe(e?.package),p=f===null?d!==null&&d===Ye(o):f===Xe(t?.package);if(c&&p)return u();let m=d===null?null:Qe.byRoot.get(et(t,d)),h=(f===null?null:Qe.byPackage.get(f))??(m&&(f===null||m.pkg===f)?m.repo:null);if(h)return W({file:a,line:e?.line,repo:h},n);if(qe(a)){let t=i?.(e);return t?W({file:t.file,line:e?.line,repo:t.repo},n):null}return c&&!qe(o)?u():W({file:a,line:e?.line,auditedCommit:l},n)}function en(e,{spaced:t=!1,link:n=e=>e.url,lineLinks:r=!1}={}){let i=Array.isArray(e?.evidence)?e.evidence:[];return i.length===0?``:i.map((e,t)=>{let i=y(e),a=n(e,t),s=[`${t+1}. ${a?`[${i}](${a})`:r?Te(i):i}`],c=r?rn(o(e),a):o(e);if(c)for(let e of c.split(`
20
+ `))s.push(` ${e}`);return s.join(`
21
+ `)}).join(t?`
22
+
23
+ `:`
24
+ `)}function tn(e,{repoFallback:t,shipped:n=null}={}){let r=t!==void 0,i=en(e,{link:r?(r,i)=>$t(r,e,t,i,n):void 0,lineLinks:r});return i?`**Evidence:**
25
+ ${i}`:``}var nn=/\(\s*(?:lines?|L)\s*(\d+)(?:\s*(?:-|–|—|to)\s*L?(\d+))?\s*\)/giu;function rn(e,t){if(!e||!t||!yt.test(t)||!/\(\s*(?:lines?|L)\s*\d/iu.test(e))return e;let n=_t(t),r=e=>{let t=an(e);return e.replaceAll(nn,(e,r,i,a)=>{let o=d(t,a)?null:q(i?`${r}-${i}`:r);return o?`([${e.slice(1,-1).trim()}](${n}${vt(o)}))`:e})},i=``,a=0;for(let[t,n]of u(e))i+=r(e.slice(a,t))+e.slice(t,n),a=n;return i+r(e.slice(a))}function an(e){let t=[],n=[...e.matchAll(/`+/gu)].map(e=>[e.index,e.index+e[0].length]),r=[],i=new Map;for(let e=n.length-1;e>=0;e--){let t=n[e][1]-n[e][0];r[e]=i.get(t),i.set(t,e)}for(let e=0;e<n.length;e++)r[e]!==void 0&&(t.push([n[e][0],n[r[e]][1]]),e=r[e]);let[a,o,s,c]=[`
26
+ `,`]`,`)`,`>`].map(t=>{let n=Array.from({length:e.length+1},()=>1/0);for(let r=e.length-1;r>=0;r--)n[r]=e[r]===t?r:n[r+1];return n}),l=t.length,u=0;for(let n=0;n<e.length;n++){for(;u<l&&t[u][1]<=n;)u++;if(u<l&&t[u][0]<=n){n=t[u][1]-1;continue}let r=-1;if(e[n]===`[`&&o[n+1]<a[n]){r=o[n+1]+1;let t=e[r]===`(`?s[r]:e[r]===`[`?o[r+1]:1/0;t<a[r]&&(r=t+1)}else if(e[n]===`<`&&c[n+1]<a[n])r=c[n+1]+1;else if((e[n]===`h`||e[n]===`H`)&&/^https?:\/\//iu.test(e.slice(n,n+8))&&!/\w/u.test(e[n-1]??``))for(r=n;r<e.length&&!/\s/u.test(e[r]);)r++;r>n&&(t.push([n,r]),n=r-1)}t.sort((e,t)=>e[0]-t[0]);let d=[];for(let[e,n]of t){let t=d.at(-1);t&&e<t[1]?t[1]=Math.max(t[1],n):d.push([e,n])}return d}function on(e){let t=/^\[([^\]]+)\]\(([^)\s]+)\)$/u.exec(e);return!t||!s(t[2])?null:{label:f(t[1].trim())||t[2],url:t[2]}}function sn(e,t){let n=parseInt(e?.line,10);if(!Number.isFinite(n))return A;let r=W(e,t),i=`line ${n}`;return r?O`<a href="${r}" target="_blank" rel="noopener">${i}</a>`:i}function cn(e,t){return!e||!t?null:`${/^https?:/iu.test(e)?e.replace(/\/$/u,``):`https://github.com/${e}`}/commit/${t}`}var ln=[[`Impact`,`impact`],[`Reproduction`,`reproduction`],[`Recommendation`,`recommendation`],[`Confidence reason`,`confidenceReason`],[`Revalidation verdict`,`revalidateVerdict`],[`Revalidation recommendation`,`revalidateRecommendation`]];function un(e,t){let n=[];t&&n.push(`Repo: ${t}`);let r=y(e);r&&n.push(`Location: ${r}`),e?.confidence!=null&&n.push(`Confidence: ${e.confidence}/10`);let i=R(e);i&&n.push(`Revalidation: ${i}`);let a=[];n.length>0&&a.push(n.join(`
27
+ `));let{title:o,body:s}=v(e);o&&a.push(`# ${o}`),s&&a.push(s.trim());let c=en(e,{spaced:!0});c&&a.push(`# Evidence
28
+
29
+ ${c}`);for(let[t,n]of ln){if(!L&&n.startsWith(`revalidate`))continue;let r=_(e?.[n],e)?.trim();r&&a.push(`# ${t}
30
+
31
+ ${r}`)}return a.join(`
32
+
33
+ `)}function dn(e,{title:t,body:n,labels:r=[]}={}){let i=ft(e);if(!i)return null;let a;try{a=new URL(i).host.toLowerCase()}catch{return null}if(a!==`github.com`)return null;let o=new URLSearchParams;t&&o.set(`title`,t),n&&o.set(`body`,n),r.length>0&&o.set(`labels`,r.join(`,`));let s=o.toString();return s?`${i}/issues/new?${s}`:`${i}/issues/new`}var fn=/^[a-zA-Z\d](?:-?[a-zA-Z\d])*$/u,pn=/^[a-zA-Z\d._-]+$/u,mn=/^[1-9]\d{0,9}$/u,hn=/^[a-fA-F\d]{7,40}$/u,gn=/^#[\w-]+$/u,_n=/^GHSA(?:-[0-9a-z]{4}){3}$/u;function vn(e){return e.length<=39&&fn.test(e)}function yn(e){return e.length<=100&&e!==`.`&&e!==`..`&&pn.test(e)}function bn(e){let t;try{t=new URL(e)}catch{return null}if(t.href!==e||t.protocol!==`https:`||t.hostname.toLowerCase()!==`github.com`||t.port||t.username||t.password)return null;let n=t.pathname.split(`/`);if(n.at(-1)===``&&n.pop(),n.length===3&&n[1]===`advisories`){let e=n[2];return _n.test(e)?{url:`https://github.com/advisories/${e}`,label:e}:null}if(n.length===6&&n[3]===`security`&&n[4]===`advisories`){let[,e,t,,,r]=n;return!vn(e)||!yn(t)||!_n.test(r)?null:{url:`https://github.com/${e}/${t}/security/advisories/${r}`,label:r}}if(n.length!==5)return null;let[,r,i,a,o]=n;if(!vn(r)||!yn(i))return null;let s;if(a===`issues`||a===`pull`){if(!mn.test(o))return null;s=`${r}/${i}#${o}`}else if(a===`commit`){if(!hn.test(o))return null;s=`${r}/${i}@${o.slice(0,7)}`}else return null;return{url:`https://github.com/${r}/${i}/${a}/${o}${gn.test(t.hash)?t.hash:``}`,label:s}}var xn=/^[\da-f]{8}(?:-[\da-f]{4}){3}-[\da-f]{12}$/u;function Sn(e){if(typeof e!=`string`)return null;let t=Cn(e);return t!==e||xn.test(e)?t.slice(0,8):null}function Cn(e){let t=String(e);return t.startsWith(`https://chatgpt.com/codex/cloud/security/findings/`)?t.slice(50):t}function wn(e,n){let r=t(e,{managed:n});if(!r)return null;let i=Sn(r.id);return{url:n?r.path:`#${r.fragment}`,label:i?`finding ${i}`:`finding`,self:!0}}var Tn=/https?:\/\/[^\s<>"'`(){}[\]|\\^]+/giu,En=new Set([`)`,`.`,`,`,`!`,`?`,`;`,`:`,`'`,`"`,`*`,`]`,`}`,`>`]);function Dn(e){let t=e.length;for(;t>0&&En.has(e[t-1]);)t--;return t===e.length?e:e.slice(0,t)}function On(e,{managed:t=!1}={}){if(typeof e!=`string`||e.length===0)return[];let n=[],r=0;Tn.lastIndex=0;let i;for(;(i=Tn.exec(e))!==null;){let a=Dn(i[0]),o=a?bn(a)??wn(a,t):null;o&&(i.index>r&&n.push(e.slice(r,i.index)),n.push(o),r=i.index+a.length,Tn.lastIndex=r)}return r<e.length&&n.push(e.slice(r)),n}var kn={commit:w},An=8;function jn(e){let t;try{t=e?JSON.parse(e):null}catch{return null}let n=e=>typeof e==`string`&&e?e:null;return t&&{tags:Array.isArray(t.tags)?t.tags.filter(n):[],details:typeof t.title==`string`?{title:t.title,authorName:n(t.authorName),authorLogin:n(t.authorLogin),date:Number.isSafeInteger(t.date)?t.date:null}:null}}function Mn({title:e,authorName:t,authorLogin:n,date:r}){let i=document.createElement(`div`);i.className=`tooltip-commit-details`;let a=document.createElement(`span`);a.className=`tooltip-commit-message`,a.textContent=e;let o=document.createElement(`span`);return o.className=`tooltip-commit-meta`,o.textContent=[t&&n&&t!==n?`${t} (@${n})`:t??(n&&`@${n}`),r===null?``:new Date(r).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`})].filter(Boolean).join(` · `),i.append(...e?[a]:[],o),i}var J;function Nn(){return J||(J=document.createElement(`div`),J.id=`styled-tooltip`,J.setAttribute(`popover`,`manual`),document.body.append(J),J)}function Pn(e){typeof e.showPopover==`function`&&(e.matches(`:popover-open`)&&e.hidePopover(),e.showPopover())}var Y=null,Fn=``,X=null,Z=null,In=0,Ln=0,Rn=!1;function zn(){if(!Rn){Rn=!0,document.addEventListener(`mousemove`,e=>{In=e.clientX,Ln=e.clientY},{passive:!0});for(let e of[`pointerdown`,`wheel`,`scroll`])document.addEventListener(e,()=>$(),{capture:!0,passive:!0});document.addEventListener(`keydown`,e=>{e.key===`Escape`&&$()}),window.addEventListener(`blur`,()=>$())}}var Bn=100,Vn=14,Hn=8,Q=8;function Un(e,{placement:t=`cursor`}={}){zn(),clearTimeout(X),X=null,Z=null,e.prepareTooltip?.(e),t=e.dataset.tooltipPlacement??t;let n=Nn(),i=e.dataset.tooltip??``,a=Object.hasOwn(kn,e.dataset.tooltipIcon??``)?e.dataset.tooltipIcon:``,o=e.dataset.tooltipRepo??``,s=r(e.dataset.tooltipCommit),c=jn(e.dataset.tooltipCommitInfo),l=[`stasis`,`sourcemap`].includes(e.dataset.tooltipBundle)?e.dataset.tooltipBundle:``,u=e.dataset.tooltipStats??``,d=e.dataset.tooltipBuilt===`true`,f=e.dataset.tooltipPackage??``,p=e.dataset.tooltipEcosystem??``,m=e.dataset.tooltipVersion??``,h=e.dataset.tooltipFiles??``,g=e.dataset.tooltipLoc??``,_=e.dataset.tooltipSize??``,v=e.tooltipContent??null,y=v??JSON.stringify([i,a,o,s,c,l,u,d,f,p,m,h,g,_]);if(!i){$();return}if(Y===e&&Fn===y)return;if(n.textContent=a||v?``:i,v){let e=document.createElement(`div`);e.className=`tooltip-rich`,te(v,e),n.append(e)}if(a){let e=document.createElement(`span`);e.className=`tooltip-text`,e.innerHTML=N(kn[a]);let t=document.createElement(`span`);t.textContent=i,e.append(t),n.append(e)}if(f){let t=document.createElement(`div`);t.className=`tooltip-package`;let r=(e.querySelector(`[data-tooltip-package-icon] svg`)??e.querySelector(`svg`))?.cloneNode(!0);r&&t.append(r);let i=document.createElement(`span`);i.className=`tooltip-package-details`;let a=(e,t)=>/^\d+$/u.test(e)?`${Number(e).toLocaleString()} ${t}`:``;for(let e of[f,m,a(h,h===`1`?`file`:`files`),a(g,`LoC`),_].filter(Boolean)){let t=document.createElement(`span`);t.textContent=e,i.append(t)}t.append(i),n.append(t)}if(o||s){let e=document.createElement(`div`);if(e.className=`tooltip-repo`,o){e.innerHTML=N(ee);let t=document.createElement(`span`);t.textContent=o,e.append(t)}if(s){let t=document.createElement(`span`);t.className=`tooltip-commit`,t.innerHTML=N(w);let n=document.createElement(`span`);n.textContent=s.slice(0,7),t.append(n),e.append(t)}if(n.append(e),s&&c?.tags.length){let e=document.createElement(`div`);e.className=`tooltip-tags`;for(let t of c.tags.slice(0,An)){let n=document.createElement(`span`);n.className=`tooltip-tag`,n.innerHTML=N(b);let r=document.createElement(`span`);r.textContent=t,n.append(r),e.append(n)}if(c.tags.length>An){let t=document.createElement(`span`);t.className=`tooltip-tag-more`,t.textContent=`+${(c.tags.length-An).toLocaleString()} more`,e.append(t)}n.append(e)}}if(c?.details&&n.append(Mn(c.details)),l||u||d){let e=document.createElement(`div`);if(e.className=`tooltip-bundle`,l===`stasis`){let t=document.createElement(`img`);t.src=`./stasis.svg`,t.alt=``,e.append(t)}else e.innerHTML=N(C);let t=document.createElement(`span`);t.textContent=[l===`stasis`?`Stasis`:l===`sourcemap`?`Sourcemap`:``,d?`Built on server`:``,u].filter(Boolean).join(` · `),e.append(t),n.append(e)}Pn(n),n.style.left=`0px`,n.style.top=`0px`,n.style.transform=`none`,n.classList.add(`visible`);let x=In,S=Ln+Vn;if(t===`right`||t===`right-start`){let n=e.getBoundingClientRect();x=n.right+Hn,S=n.top+(t===`right`?n.height/2:0)}let T=window.innerWidth-n.offsetWidth-Q,E=Math.max(Q,Math.min(x,T));n.style.left=`${Math.round(E)}px`;let D=n.offsetHeight,O=t===`right`?S-D/2:S,k=window.innerHeight-D-Q,A=Math.max(Q,Math.min(O,k));n.style.top=`${Math.round(A)}px`,Y=e,Fn=y}function $(e){e&&!e.contains(Y)&&!e.contains(Z)||(clearTimeout(X),X=null,Z=null,J&&(J.classList.remove(`visible`),typeof J.hidePopover==`function`&&J.matches(`:popover-open`)&&J.hidePopover()),Y=null)}function Wn(e,{gate:t,placement:n}={}){zn();let r=()=>e.isConnected!==!1&&(!Object.hasOwn(e.dataset,`tooltipTruncated`)||e.scrollWidth>e.clientWidth||e.scrollHeight>e.clientHeight)&&(!t||t(e));r()?e===Y||e===Z||($(),Z=e,X=setTimeout(()=>{X=null,Z=null,r()&&Un(e,{placement:n})},Bn)):$()}var Gn=new WeakSet;function Kn(e,t){for(let n of e.composedPath()){if(n===t)break;if(n.nodeType===1&&Object.hasOwn(n.dataset,`tooltip`))return n}return null}function qn(e,t){!e||Gn.has(e)||(Gn.add(e),e.ownerDocument&&zn(),e.addEventListener(`mouseover`,n=>{if(n.buttons){$();return}let r=Kn(n,e);r?r!==Y&&Wn(r,t):$()}),e.addEventListener(`mouseout`,t=>{let n=Kn(t,e),r=t.relatedTarget?.closest?.(`[data-tooltip]`)??null;n&&n===r||$()}),e.addEventListener(`scroll`,()=>$(e),{capture:!0,passive:!0}))}var Jn=!1;function Yn(){Jn||(Jn=!0,zn(),document.addEventListener(`tooltip-root-connected`,e=>{qn(e.composedPath()[0]?.shadowRoot)}),document.body.addEventListener(`mouseover`,e=>{if(e.target.closest(`[data-tooltip-managed]`))return;if(e.buttons){$();return}let t=e.target.closest(`[data-tooltip]`);!t||t===Y||Wn(t)}),document.body.addEventListener(`mouseout`,e=>{e.target.closest(`[data-tooltip-managed]`)||e.relatedTarget?.closest?.(`[data-tooltip-managed]`)||!Y&&!X||(Y??Z)?.contains(e.relatedTarget)||$()}))}function Xn(e){return`tree-`+e.replaceAll(/[^\w-]+/gu,`_`)}var Zn=()=>Object.fromEntries(p.map(e=>[e,0]));function Qn(e,t){let n=new Map;for(let r of e)for(let e of r){n.has(e.file)||n.set(e.file,Zn());let r=n.get(e.file),i=m(e,t);r[i]!==void 0&&r[i]++}return n}var $n={trees:[],merged:null};function er(e){let t=e.map(e=>e?.tree??null);return t.length===$n.trees.length&&t.every((e,t)=>e===$n.trees[t])||($n={trees:t,merged:tr(e)}),$n.merged}function tr(e){let t=null;for(let n of e)if(n?.tree){t||={};for(let e of Object.keys(n.tree)){let r=n.tree[e];if(!t[e]){t[e]={...r,imports:[...r.imports??[]]};continue}let i=new Set(t[e].imports);for(let n of r.imports??[])i.has(n)||(i.add(n),t[e].imports.push(n));t[e].size==null&&r.size!=null&&(t[e].size=r.size)}}return t}function nr(e,t){let n=Object.keys(e),r=new Map(n.map((e,t)=>[e,t])),i=n.map(()=>Zn()),a=n.map(()=>[]);for(let[t,i]of n.entries())for(let n of e[i].imports??[]){let e=r.get(n);e!==void 0&&a[e].push(t)}let o=new Uint32Array(n.length),s=0;for(let[e,n]of t){let t=r.get(e);if(t===void 0||!n)continue;let c=p.map(e=>[e,n[e]??0]).filter(([,e])=>e!==0);if(c.length===0)continue;let l=++s,u=[],d=e=>{o[e]!==l&&(o[e]=l,u.push(e))};for(let e of a[t])d(e);for(;u.length>0;){let e=u.pop();for(let[t,n]of c)i[e][t]+=n;for(let t of a[e])d(t)}}return new Map(n.map((e,t)=>[e,i[t]]))}function rr(e,t,n){let r=t.get(e),i=n.get(e);return ir(r)>0||ir(i)>0}function ir(e){if(!e)return 0;let t=0;for(let n of p)t+=e[n]??0;return t}function ar(e){if(!e)return null;let t=We(),n=RegExp(`^(?:.*/)?${t}/(@[^/]+/[^/]+|[^/]+)`,`u`),r=e.match(n);return r?r[1]:`__own__`}function or(e){return new Set(e.filter(e=>!V(e)))}var sr=[`#4e9af1`,`#f28e2b`,`#59a14f`,`#e15759`,`#76b7b2`,`#edc948`,`#b07aa1`,`#ff9da7`,`#9c755f`,`#5cd1e5`,`#f1ce63`,`#d37295`,`#a0cbe8`,`#86bcb6`,`#8cd17d`,`#b6992d`,`#499894`,`#e15759`,`#e879c7`,`#d4a6c8`],cr=[`#2f8aef`,`#d2691e`,`#2ea043`,`#e63946`,`#2e9a92`,`#b88817`,`#9560e8`,`#d24a9c`,`#8a5d40`,`#0891b2`,`#a07a14`,`#c14e8e`,`#1f7ad0`,`#549b94`,`#3fb95f`,`#a07a14`,`#2a8278`,`#cb2c40`,`#c026d3`,`#965f93`];function lr(){if(typeof document>`u`)return!1;let e=document.body?.classList;return!!e&&(e.contains(`theme-light`)||e.contains(`theme-pink`)||e.contains(`theme-w95`)||e.contains(`theme-paper`))}var ur=new Map;function dr(e){let t=lr()?cr:sr;return t[e%t.length]}var fr=()=>lr()?`#8c959f`:`#6e7681`;function pr(e){let t=lr(),n=t?cr:sr,r=e??`__own__`,i=`${t?`l`:`d`}:${r}`;if(ur.has(i))return ur.get(i);let a=0;for(let e of r)a=a*37+e.codePointAt(0)|0;let o=n[((a%n.length+n.length)%n.length*7+3)%n.length];return ur.set(i,o),o}function mr(e,t){if(!t||t===`/`||t===`__own__`)return e;for(let n of[`node_modules`,`dependencies`,We()]){let r=n+`/`+t+`/`,i=e.indexOf(r);if(i>=0)return e.slice(i+r.length)}return e.startsWith(t+`/`)?e.slice(t.length+1):e}function hr(e){let t=e.origFile??e.file,n=mr(t,e.pkg),r=n===t?t:`${a(e.pkg)}/${n}`;return r===t?e.file:r}var gr={package:`@babel/core`,path:/^lib\/config\//u},_r={package:`@babel/core`,path:/^lib\/config\/files\/(?:module-types|plugins)\.js$/u},vr=Object.freeze([{id:`react-native-codegen-discovery`,reason:`Codegen discovers package metadata and React Native configuration.`,from:{package:`react-native`,path:/^scripts\/codegen\/generate-artifacts-executor\.js$/u},to:{path:/(?:^|\/)(?:package\.json|react-native\.config\.js)$/u}},{id:`react-native-release-version`,reason:`The CLI release checker reads the installed React Native version.`,from:{package:`@react-native-community/cli-tools`,path:/^build\/releaseChecker\/index\.js$/u},to:{package:`react-native`,path:/^package\.json$/u}},{id:`react-native-platform-config`,reason:`React Native configuration loads platform CLIs supplied by the host project.`,from:{package:`react-native`,path:/^react-native\.config\.js$/u},to:{package:/^@react-native-community\/cli-platform-(?:android|ios)$/u,path:/^build\/index\.js$/u}},{id:`babel-project-config`,reason:`Babel discovers project configuration.`,from:gr,to:{path:/(?:^|\/)babel\.config\.js$/u}},{id:`babel-typescript-preset`,reason:`Babel configuration loads the TypeScript preset.`,from:gr,to:{package:`@babel/preset-typescript`,path:/./u}},{id:`babel-react-native-preset`,reason:`Babel config loaders load the configured React Native preset.`,from:_r,to:{package:`@react-native/babel-preset`,path:/^(?:src\/)?index\.js$/u}},{id:`babel-reanimated-plugin`,reason:`Babel config loaders load the configured Reanimated plugin, including scoped copies.`,from:_r,to:{package:/^(?:@[^/]+\/)?react-native-reanimated$/u,path:/^plugin\/index\.js$/u}},{id:`babel-transform-plugin`,reason:`Babel config loaders load configured transform plugins.`,from:_r,to:{package:/^@babel\/plugin-transform-[^/]+$/u,path:/^lib\/index\.js$/u}},{id:`cosmiconfig-config`,reason:`Cosmiconfig loads discovered configuration, including dependency configuration.`,from:{package:`cosmiconfig`,path:/^dist\/loaders\.js$/u},to:{path:/\.config\.js$/u}},{id:`import-fresh-own-config`,reason:`import-fresh loads host-project configuration.`,from:{package:`import-fresh`,path:/./u},to:{path:/\.config\.js$/u},ownSourceOnly:!0}].map(e=>Object.freeze({...e,from:Object.freeze(e.from),to:Object.freeze(e.to)})));function yr(e){return typeof e==`string`&&!e.includes(`\\`)&&!e.includes(`:`)&&e.split(`/`).every(e=>e!==``&&e!==`.`&&e!==`..`&&e!==`node_modules`)}function br(e,t){let n=e.package;return n!==void 0&&t.ownSource===!0?!1:(n===void 0||(typeof n==`string`?n===t.package:n.test(t.package??``)))&&e.path.test(t.path)}function xr(e,t){if(e?.ownSource!==!0&&yr(e?.path)&&yr(t?.path))return vr.find(n=>(!n.ownSourceOnly||t.ownSource===!0)&&br(n.from,e)&&br(n.to,t))}function Sr(e,t){let n=e.split(/(?:^|\/)node_modules\//u).slice(1).at(-1)?.match(/^(@[^/]+\/[^/]+|[^/]+)\/(.+)$/u);return{package:n?.[1],path:n?.[2]??e.replace(/^\/+/u,``),ownSource:t??i(e)===`__own__`}}function Cr(e,t,n,r){return!xr(Sr(e,r),Sr(t,n))}function wr(e,t=e=>e.file){let n=new Map(e.nodes.map(e=>[e.file,e])),r=new Map(e.nodes.map(e=>[t(e),new Set]));for(let[i,a]of e.importsOf){let o=n.get(i);if(o)for(let s of a){let a=n.get(s);a&&Cr(o.origFile??i,a.origFile??s,e.ownSourceFiles?.has(s),e.ownSourceFiles?.has(i))&&r.get(t(o)).add(t(a))}}return r}var Tr=class{constructor(e){this.nodes=[...e];for(let[e,t]of this.nodes.entries())t.position=e;for(let e=(this.nodes.length>>1)-1;e>=0;e--)this.down(e)}before(e,t){return Math.abs(e.balance)>Math.abs(t.balance)||Math.abs(e.balance)===Math.abs(t.balance)&&(e.balance>t.balance||e.balance===t.balance&&e.tie<t.tie)}swap(e,t){let n=this.nodes,r=n[e];n[e]=n[t],n[t]=r,n[e].position=e,n[t].position=t}down(e){let t=this.nodes;for(;2*e+1<t.length;){let n=2*e+1;if(n+1<t.length&&this.before(t[n+1],t[n])&&n++,!this.before(t[n],t[e]))break;this.swap(e,n),e=n}}update(e){if(e.position<0)return;let t=e.position;for(;t>0;){let n=t-1>>1;if(!this.before(e,this.nodes[n]))break;this.swap(t,n),t=n}this.down(t)}take(){let e=this.nodes[0],t=this.nodes.pop();return e.position=-1,this.nodes.length>0&&(this.nodes[0]=t,t.position=0,this.down(0)),e}};function Er(e,t){for(let n=0;n<8;n++){let r=!1;for(let i=0;i<e.length-1;i++){let a=n%2?e.length-2-i:i,o=e[a],s=e[a+1];(t.get(s)?.get(o)?.cycleCount??0)<=(t.get(o)?.get(s)?.cycleCount??0)||(e[a]=s,e[a+1]=o,r=!0)}if(!r)break}return e}function Dr(e){let t=[],n=new Set;for(let t of e.values())t.outgoing.sort((e,t)=>t[1]-e[1]||e[0].tie-t[0].tie);for(let r of e.values()){if(n.has(r))continue;let e=[{node:r,next:0}];for(n.add(r);e.length>0;){let r=e.at(-1);if(r.next===r.node.outgoing.length){t.push(r.node.id),e.pop();continue}let i=r.node.outgoing[r.next++][0];n.has(i)||(n.add(i),e.push({node:i,next:0}))}}return t.toReversed()}function Or(e,t){let n=new Map(e.map((e,t)=>[e,t])),r=0;for(let e of t.values())for(let[t,i]of e.outgoing)n.get(e.id)<n.get(t.id)&&(r+=i);return r}function kr(e,t){let n=Or(e,t),r=n,i=0;for(let a=0;a<e.length-1;a++)n-=t.get(e[a]).originalBalance,n>r&&(r=n,i=a+1);return[...e.slice(i),...e.slice(0,i)]}function Ar(e,t){if(e.length<2)return e;let n=new Map(e.map((e,t)=>[e,{id:e,tie:t,balance:0,incoming:[],outgoing:[]}]));for(let e of n.values())for(let r of t.get(e.id)?.values()??[]){let t=n.get(r.to);!t||t===e||!r.cycleCount||(e.outgoing.push([t,r.cycleCount]),t.incoming.push([e,r.cycleCount]),e.balance+=r.cycleCount,t.balance-=r.cycleCount)}for(let e of n.values())e.originalBalance=e.balance;let r=[],i=new Tr(n.values()),a=[];for(;i.nodes.length>0;){let e=i.take();e.balance>=0?r.push(e.id):a.push(e.id);for(let[t,n]of e.outgoing)t.position<0||(t.balance+=n,i.update(t));for(let[t,n]of e.incoming)t.position<0||(t.balance-=n,i.update(t))}let o=e,s=Or(e,n);for(let i of[[...r,...a.toReversed()],Dr(n),e,e.toReversed()]){let e=Er(kr(i,n),t),r=Or(e,n);r>s&&(o=e,s=r)}return o}function jr(e,t){let n=new Set(e),r=new Map(e.map(e=>[e,[]]));for(let[e,i]of t)for(let t of i)n.has(e)&&n.has(t)&&r.get(t).push(e);let i=[],a=new Set;for(let r of e){if(a.has(r))continue;a.add(r);let e=[[r,(t.get(r)??[])[Symbol.iterator]()]];for(;e.length>0;){let[r,o]=e.at(-1),s=o.next();s.done?(i.push(r),e.pop()):n.has(s.value)&&!a.has(s.value)&&(a.add(s.value),e.push([s.value,(t.get(s.value)??[])[Symbol.iterator]()]))}}let o=new Map,s=[];for(let e of i.toReversed()){if(o.has(e))continue;let t=[],n=s.length,i=[e];for(o.set(e,n);i.length>0;){let e=i.pop();t.push(e);for(let t of r.get(e))o.has(t)||(o.set(t,n),i.push(t))}s.push(t.toSorted())}return{groups:s,componentOf:o}}function Mr(e,{expanded:t=new Set,order:n=`structure`,query:r=``,neighborhood:i=null,cyclesOnly:o=!1}={}){let s=new Map,c=new Map,l=new Map;for(let n of e.nodes){let e=t.has(n.pkg),r=`${e?`f`:`p`}:${e?n.file:n.pkg}`;s.has(r)||s.set(r,{id:r,pkg:n.pkg,file:e?n.file:null,label:e?hr(n):a(n.pkg),files:[],size:0,issues:0,incoming:0,outgoing:0,importers:0,dependencies:0});let i=s.get(r);i.files.push(n.file),i.size+=n.size??0,i.issues+=n.totalIssues??0,c.set(n.file,r),l.set(n.file,n.origFile??n.file)}let u=new Map,d=new Set,f=new Set,p=new Map([...s.keys()].map(e=>[e,new Set])),m=0;for(let[t,n]of e.importsOf){let r=c.get(t);if(r)for(let i of new Set(n)){let n=c.get(i);if(!n)continue;u.has(r)||u.set(r,new Map),u.get(r).has(n)||u.get(r).set(n,{from:r,to:n,count:0,cycleCount:0,examples:[]});let a=u.get(r).get(n);a.count++;let h=Cr(l.get(t),l.get(i),e.ownSourceFiles?.has(i),e.ownSourceFiles?.has(t));a.examples.length<80&&(!o||h)&&a.examples.push([t,i]),m++,s.get(r).outgoing++,s.get(n).incoming++,r!==n&&(f.add(r),d.add(n)),h&&(a.cycleCount++,(r!==n||s.get(r).file)&&p.get(r).add(n))}}let h=[...s.keys()].toSorted(),{groups:g,componentOf:_}=jr(h,p),v=new Set(g.flatMap(e=>e.length>1||p.get(e[0]).has(e[0])?e:[]));for(let e of s.values())e.cyclic=v.has(e.id),e.component=_.get(e.id);let y=e.ownSourcePackages??new Set(e.layerRoots?.roots??[]),b=e=>e.pkg===`__own__`?0:y.has(e.pkg)?1:2,x=e=>d.has(e.id)&&f.has(e.id)?0:1,S=new Map(g.map((e,t)=>[t,e.reduce((e,t)=>Math.min(e,b(s.get(t))),2)])),C=(e,t)=>e.pkg.localeCompare(t.pkg)||e.label.localeCompare(t.label),ee=new Map;if(n===`structure`){for(let e of g)if(!(e.length<2))for(let t of Map.groupBy(e,e=>b(s.get(e))).values())Ar(t.toSorted((e,t)=>C(s.get(e),s.get(t))),u).forEach((e,t)=>ee.set(e,t))}if(o){m=0,d.clear(),f.clear();for(let e of s.values())e.incoming=0,e.outgoing=0}for(let[e,t]of u){for(let n of t.values())if(n.cyclic=n.cycleCount>0&&v.has(e)&&_.get(e)===_.get(n.to)&&(e!==n.to||s.get(e).file!==null),o){if(!n.cyclic){t.delete(n.to);continue}n.count=n.cycleCount,m+=n.count,s.get(e).outgoing+=n.count,s.get(n.to).incoming+=n.count,e!==n.to&&(f.add(e),d.add(n.to))}t.size===0&&u.delete(e)}for(let[e,t]of u)for(let n of t.keys())e!==n&&(s.get(e).dependencies++,s.get(n).importers++);let w=r.trim().toLowerCase(),T=new Set(h.filter(e=>!w||s.get(e).files.some(e=>e.toLowerCase().includes(w))||s.get(e).label.toLowerCase().includes(w))),E=new Set(i?[i]:T);if(w||i)for(let[e,t]of u)for(let n of t.keys())(i?e===i:T.has(e))&&E.add(n),(i?n===i:T.has(n))&&E.add(e);let D=(e,t)=>{if(n===`structure`){let n=S.get(e.component)-S.get(t.component);if(n)return n;let r=x(e)-x(t);if(r)return r;let i=e.component-t.component;if(i)return i}let r=b(e)-b(t);if(r)return r;if(n===`importers`)return t.importers-e.importers||C(e,t);if(n===`imports`)return t.dependencies-e.dependencies||C(e,t);let i=x(e)-x(t);if(i)return i;if(n===`structure`&&e.component===t.component){let n=(ee.get(e.id)??0)-(ee.get(t.id)??0);if(n)return n}return C(e,t)},O=[...s.values()].filter(e=>E.has(e.id)&&(!o||e.cyclic)).toSorted(D),k=new Map(O.map((e,t)=>[e.id,t])),A=[];for(let[e,t]of u)if(k.has(e))for(let n of t.values())k.has(n.to)&&A.push({...n,row:k.get(e),col:k.get(n.to)});return{rows:O,byId:s,cells:u,visibleCells:A,index:k,matches:T,importCount:m,totalRows:s.size,cycleCount:g.filter(e=>v.has(e[0])).length}}export{ne as a,ae as b,oe as c,se as d,N as e,ue as f,P as g,de as h,F as i,fe as j,pe as k,me as l,he as m,ge as n,I as o,ve as p,be as q,Se as r,Ce as s,we as t,Te as u,Ee as v,De as w,R as x,Oe as y,ke as z,Ae as A,je as B,Ne as C,Pe as D,Fe as E,Ue as F,We as G,V as H,Ke as I,rt as J,it as K,at as L,st as M,ct as N,lt as O,ut as P,dt as Q,gt as R,W as S,xt as T,Tt as U,At as V,Pt as W,Lt as X,Ut as Y,qt as Z,Jt as _,q as $,Xt as aa,Qt as ba,$t as ca,tn as da,on as ea,sn as fa,cn as ga,un as ha,dn as ia,Sn as ja,Cn as ka,On as la,Un as ma,$ as na,Wn as oa,qn as pa,Yn as qa,Xn as ra,Qn as sa,er as ta,nr as ua,rr as va,ir as wa,ar as xa,or as ya,dr as za,fr as Aa,pr as Ba,Ar as Ca,mr as Da,hr as Ea,Cr as Fa,wr as Ga,jr as Ha,Mr as Ia};
34
+ /*! Bundled license information:
35
+
36
+ lit-html/directives/class-map.js:
37
+ (**
38
+ * @license
39
+ * Copyright 2018 Google LLC
40
+ * SPDX-License-Identifier: BSD-3-Clause
41
+ *)
42
+ */
@@ -1,4 +1,4 @@
1
- import{Fb as e,Gb as t,Hb as n,Jb as r,Kb as i,Lb as a,Qb as o,fc as s,lc as c,w as l}from"./chunk-OBZWBTZL.js";import{j as u,k as d}from"./chunk-F3UI65ZI.js";import{e as f,f as p,g as m,j as h}from"./chunk-QRKFPLA4.js";import{c as g}from"./chunk-2XUEZHIP.js";var _=`.md-quote,.md-alert{margin:0;&:not(:first-child),+*{margin-top:.5lh}>:first-child{margin-top:0}>:last-child{margin-bottom:0}}.md-quote{padding-inline-start:.85em;border-inline-start:.25em solid rgb(from currentcolor r g b / .3);color:rgb(from currentcolor r g b / calc(alpha*.78));.md-quote{color:inherit}}.md-alert{--md-alert: var(--info);padding:.35lh .85em;border-inline-start:.25em solid var(--md-alert);background:rgb(from var(--md-alert) r g b / .06);border-radius:0 var(--ui-radius, 4px) var(--ui-radius, 4px) 0}.md-alert-tip{--md-alert: var(--green)}.md-alert-important{--md-alert: var(--purple)}.md-alert-warning{--md-alert: var(--warning)}.md-alert-caution{--md-alert: var(--critical)}.md-alert-title{display:flex;align-items:center;gap:.45em;margin-bottom:.2lh;color:var(--md-alert);font-weight:600}.md-alert-icon{flex:none;width:1.05em;height:1.05em}
1
+ import{Db as e,Eb as t,Fb as n,Hb as r,Ib as i,Jb as a,Ob as o,dc as s,jc as c,w as l}from"./chunk-FUHRMY7R.js";import{k as u,l as d}from"./chunk-6YGH7BJG.js";import{e as f,f as p,g as m,j as h}from"./chunk-QRKFPLA4.js";import{c as g}from"./chunk-2XUEZHIP.js";var _=`.md-quote,.md-alert{margin:0;&:not(:first-child),+*{margin-top:.5lh}>:first-child{margin-top:0}>:last-child{margin-bottom:0}}.md-quote{padding-inline-start:.85em;border-inline-start:.25em solid rgb(from currentcolor r g b / .3);color:rgb(from currentcolor r g b / calc(alpha*.78));.md-quote{color:inherit}}.md-alert{--md-alert: var(--info);padding:.35lh .85em;border-inline-start:.25em solid var(--md-alert);background:rgb(from var(--md-alert) r g b / .06);border-radius:0 var(--ui-radius, 4px) var(--ui-radius, 4px) 0}.md-alert-tip{--md-alert: var(--green)}.md-alert-important{--md-alert: var(--purple)}.md-alert-warning{--md-alert: var(--warning)}.md-alert-caution{--md-alert: var(--critical)}.md-alert-title{display:flex;align-items:center;gap:.45em;margin-bottom:.2lh;color:var(--md-alert);font-weight:600}.md-alert-icon{flex:none;width:1.05em;height:1.05em}
2
2
  `,v=`.token.comment,.token.prolog,.token.cdata{color:var(--code-comment);font-style:italic}.token.punctuation{color:var(--muted)}.token.string,.token.attr-value,.token.char,.token.regex{color:var(--code-string)}.token.number,.token.boolean,.token.constant,.token.symbol{color:var(--code-number)}.token.keyword,.token.builtin,.token.important,.token.atrule{color:var(--code-keyword)}.token.function,.token.class-name,.token.tag{color:var(--code-function)}.token.operator,.token.entity,.token.url,.token.attr-name,.token.selector{color:var(--code-operator)}.token.variable,.token.property,.token.parameter{color:var(--code-variable)}.token.annotation{color:var(--code-function)}.token.deleted{color:var(--code-deleted)}.token.inserted{color:var(--code-inserted)}.token.italic{font-style:italic}.token.bold{font-weight:700}.code-control{padding:0 .3em;margin:0 .1em;border-radius:3px;font-size:.8em;line-height:0;font-style:normal;font-weight:400;color:var(--warning);background:rgb(from var(--warning) r g b / .14);box-shadow:inset 0 0 0 1px rgb(from var(--warning) r g b / .45);white-space:nowrap;user-select:none}
3
3
  `,y=g`<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" x2="12" y1="15" y2="3"/></svg>`,b=g`<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="1.8" y="5" width="20.4" height="14" rx="2"/><path d="M5.6 15.6V8.4l3.1 3.6 3.1-3.6v7.2"/><path d="M16.9 8.4v7.2m-2.6-2.9 2.6 2.9 2.6-2.9"/></svg>`,x=g`<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path d="M6 9V2h12v7"/><path d="M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2"/><rect x="6" y="14" width="12" height="8"/></svg>`;function S(e,t){let n=u.find(t=>t.value===e)?.label??e;return d(e)?.includes(`partial`)?t===`exclude`?`${n} (full only)`:t===`only`?`${n} (partial only)`:n:n}function C(e){return h.filter(t=>e.has(t)).map(e=>f[e]??e).join(`, `)}function w(r=l){let i=[];if(r.filterSeverities.size>0&&i.push({key:`severity`,label:`Severity`,value:C(r.filterSeverities),clear:{filterSeverities:new Set}}),r.filterColors.size>0&&i.push({key:`marks`,label:`Marks`,value:[...r.filterColors].map(e=>m[e]??e).join(`, `),clear:{filterColors:new Set}}),r.filterSources.size===1&&i.push({key:`source`,label:`Source`,value:r.filterSources.has(`own`)?`Sources only`:`Dependencies only`,clear:{filterSources:new Set}}),r.filterAnalyzer&&i.push({key:`analyzer`,label:`Analyzer`,value:r.filterAnalyzer===e?`(none)`:r.filterAnalyzer,clear:{filterAnalyzer:``}}),r.filterModel&&i.push({key:`model`,label:`Model`,value:r.filterModel===n?`(none)`:r.filterModel,clear:{filterModel:``}}),r.filterValidationModel&&i.push({key:`validationModel`,label:`Validation model`,value:r.filterValidationModel===n?`(none)`:r.filterValidationModel,clear:{filterValidationModel:``}}),r.filterRepo&&i.push({key:`repo`,label:`Repository`,value:r.filterRepo===t?`(no repo)`:r.filterRepo,clear:{filterRepo:``}}),d(r.filterRevalidate)&&i.push({key:`revalidate`,label:`Revalidation`,value:S(r.filterRevalidate,r.filterPartial),clear:{filterRevalidate:``,filterPartial:``}}),!r.filterRevalidate&&(r.filterConfMin>0||r.filterConfMax<10)){let e;e=r.filterConfMin>0&&r.filterConfMax<10?`${r.filterConfMin}\u2013${r.filterConfMax}`:r.filterConfMin>0?`\u2265 ${r.filterConfMin}`:`\u2264 ${r.filterConfMax}`,i.push({key:`confidence`,label:`Confidence`,value:e,clear:{filterConfMin:0,filterConfMax:10}})}r.filterInclude&&i.push({key:`search`,label:r.filterIncludeNegate?`Excluding`:`Search`,value:`"${r.filterInclude}"`,clear:{filterInclude:``,filterIncludeNegate:!1}});for(let[e,t]of[[`filterComment`,`comment`],[`filterIssue`,`issue`],[`filterFix`,`fix`],[`filterFlagged`,`flag`]]){let n=r[e];n&&i.push({key:`annotation:${t}`,label:`Annotation`,value:`${n===`with`?`With`:`Without`} ${t}`,clear:{[e]:``}})}return!l.currentWorkspace&&r.filterDuplicates&&i.push({key:`duplicates`,label:`Duplicates`,value:r.filterDuplicates===`with`?`Only rows linked to other reports`:`Exclude rows linked to other reports`,clear:{filterDuplicates:``}}),r.filterCrossContext&&i.push({key:`cross-context`,label:`Context`,value:r.filterCrossContext===`with`?`Only rows across multiple repos or packages`:`Exclude rows across multiple repos or packages`,clear:{filterCrossContext:``}}),r.filterAppStacked&&i.push({key:`app-stacked`,label:`App stack`,value:r.filterAppStacked===`with`?`Only rows with multiple App findings`:`Exclude rows with multiple App findings`,clear:{filterAppStacked:``}}),r.filterSecurity&&i.push({key:`security`,label:`Security`,value:r.filterSecurity===`with`?`Only security-related rows`:`Exclude security-related rows`,clear:{filterSecurity:``}}),i}function T(){return c().filter(e=>s(e).commonTriage===l.shownTriage)}function E(){return l.shownTriage?p[l.shownTriage]??l.shownTriage:null}function D(e,t=r()){let n=T(),s=n.length;i(t);let c;try{c=o(n).length}finally{a()}return{included:c,total:s,excluded:s-c,fields:t,filters:w(t),bucketLabel:E(),focusedOnly:e===`print`&&l.viewMode===`focus`}}var O=`.managed-comment{container:managed-comment / inline-size;white-space:normal}.managed-comment-row{display:grid;grid-template-columns:minmax(0,max-content) minmax(0,1fr) auto;align-items:start;gap:.35rem .65rem;line-height:1.5}.managed-comment-author{grid-column:1;grid-row:1;display:flex;align-items:center;gap:.45rem;min-width:0;max-width:14rem;& strong{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:600}}.managed-comment-avatar{position:relative;display:inline-flex;align-items:center;justify-content:center;flex:none;width:1.3rem;height:1.3rem;overflow:hidden;border-radius:50%;background:rgb(from var(--muted) r g b / .15);color:var(--muted);font-size:.65rem;font-weight:600;& img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover}& img[hidden]{display:none}}.managed-comment-body{grid-column:2;grid-row:1;min-width:0;white-space:pre-wrap;overflow-wrap:anywhere;& a{color:var(--accent);text-decoration:none}& a:hover{text-decoration:underline}& a.comment-self-ref{text-decoration:underline dotted;text-underline-offset:2px}& a.comment-self-ref:hover{text-decoration:underline solid}}.managed-comment-time{color:var(--muted);font-size:.7rem;font-weight:400;white-space:nowrap;text-align:right}.managed-comment-meta{grid-column:3;grid-row:1;justify-self:end;display:flex;align-items:center;gap:.5rem;min-height:1.3rem}.managed-comment-actions{display:flex;align-items:center;gap:.15rem}.managed-comment-row:not(:has(.managed-comment-author)){grid-template-columns:minmax(0,1fr) auto;.managed-comment-body{grid-column:1}.managed-comment-meta{grid-column:2}}@container managed-comment (max-width: 28rem){.managed-comment-row:has(.managed-comment-meta){grid-template-columns:minmax(0,max-content) minmax(0,1fr);.managed-comment-meta{grid-column:1 / -1;grid-row:1}.managed-comment-author,.managed-comment-body{grid-row:2}}.managed-comment-row:not(:has(.managed-comment-author)){grid-template-columns:minmax(0,1fr)}.managed-comment-author{max-width:9rem}}
4
4
  `;export{_ as a,v as b,y as c,b as d,x as e,w as f,T as g,E as h,D as i,O as j};
@@ -0,0 +1 @@
1
+ import{a as e}from"./chunk-GO7FT4OD.js";import{c as t,d as n,e as r,h as i,i as a,j as o,m as s,n as c,o as l,p as u}from"./chunk-NB4JBTKK.js";import{a as d}from"./chunk-7GJNLCXF.js";import"./chunk-PXK7EU4V.js";import{a as f,c as p}from"./chunk-JCIIBLKR.js";import{m,q as h,s as g,w as _}from"./chunk-WFDXHPT2.js";import{b as v}from"./chunk-IYPY47MC.js";import"./chunk-QRKFPLA4.js";import"./chunk-TUII34K2.js";import"./chunk-OOJM4CTU.js";function y(e){if(e instanceof Uint8Array)return{proven:!1,reason:`unsupported`,at:null};if(typeof e!=`string`)throw TypeError(`a text must be a string or its UTF-8 bytes, not ${typeof e}`);if(!e.isWellFormed())throw TypeError(`a text must be a well-formed string`);return{proven:!1,reason:`unsupported`,at:null}}var b=e=>e.subarray(0,8e3).includes(0),x=(e,t)=>(e+Math.imul(t,97)>>>0)%107927,S=e=>Uint8Array.from({length:256},(t,n)=>Number(n===10||e.includes(String.fromCodePoint(n)))),C=S(``),w=S(`,;={}`);function T(e,t=C){let n=!b(e),r=new Map,i=(e,t)=>r.set(e,(r.get(e)??0)+t),a=0,o=0,s=0;for(let r=0;r<e.length;r++){let c=e[r];if(n&&c===13&&e[r+1]===10)continue;let l=a;a=(a<<7^o>>>25)+c>>>0,o=(o<<7^l>>>25)>>>0,!(++s<64&&t[c]===0)&&(i(x(a,o),s),s=0,a=0,o=0)}s>0&&i(x(a,o),s);let c=Uint32Array.from(r.keys()).sort();return{hashes:c,bytes:Float64Array.from(c,e=>r.get(e)),total:r.values().reduce((e,t)=>e+t,0)}}function E(e,t){let n=0;for(let r=0,i=0;r<e.hashes.length&&i<t.hashes.length;)e.hashes[r]<t.hashes[i]?r++:e.hashes[r]>t.hashes[i]?i++:n+=Math.min(e.bytes[r++],t.bytes[i++]);return n}function D(e,t,n){let r=0,i=e.total,a=t.total;for(let o=0,s=0;o<e.hashes.length&&s<t.hashes.length;)if(e.hashes[o]<t.hashes[s]?i-=e.bytes[o++]:(e.hashes[o]>t.hashes[s]||(r+=Math.min(e.bytes[o],t.bytes[s]),i-=e.bytes[o++]),a-=t.bytes[s++]),(r+Math.min(i,a))*6e4<n)return 0;return r}function O(e,t,n,r,i=!1){if(e===null||t===null||t.length===0)return 0;let a=Math.abs(e.length-t.length),o=Math.max(e.length,t.length);if(o*(6e4-n)<a*6e4)return 0;let s=r(e),c=r(t),l=i?D(s,c,n*o):E(s,c);return Math.trunc(l*6e4/o)}var k=/^[\w-]{6,}$/u,A=/[\dA-Z]/u,ee=/^(?:\.[\w-]+)+$/u,te=/^[\w-]{8,32}$/u;function j(e){let t=[];for(let n=e.length-1;n>0;n--){if(e[n]!==`-`&&e[n]!==`.`)continue;let r=e.indexOf(`.`,n+1),i=e.slice(r),a=e.slice(n+1,r);r!==-1&&te.test(a)&&ee.test(i)&&/[A-Za-z]/u.test(a)&&A.test(a)&&t.push([e.slice(0,n),a,i])}return t}var M=e=>e.replaceAll(/\d/gu,`0`).replaceAll(/[a-z]/gu,`a`).replaceAll(/[A-Z]/gu,`A`);function ne(e,t){let n=j(t);for(let[t,r,i]of j(e)){let e=n.find(e=>e[2]===i);if(e&&e[1]!==r)return e[0]===t&&M(e[1])!==M(r)}return!1}function re(e){let t=e.lastIndexOf(`/`),n=e.slice(t+1),r=n.lastIndexOf(`.`),i=r>0?n.slice(r):``;return{name:n,key:`${e.slice(0,t+1)}\0${i}\0${n.length}`}}function ie(e,t){let n=e.length,r=0;for(;r<e.length&&e[r]===t[r];)r++;for(;n>r&&e[n-1]===t[n-1];)n--;for(;r>0&&!`-._`.includes(e[r-1]);)r--;for(;n<e.length&&e[n]!==`.`;)n++;let i=e.slice(r,n),a=t.slice(r,n);return r>0&&k.test(i)&&k.test(a)&&(A.test(i)||A.test(a))}function ae({sources:e,dests:t,pairs:n,used:r,record:i,punctuatedScoreOf:a},{remaining:o,open:s},c,l){let u=(e,t)=>new Map(t.filter(t=>e[t].type===`file`).map(t=>[t,re(e[t].path)])),d=u(t,s),f=u(e,o),p=Map.groupBy(f.keys(),e=>f.get(e).key),m=Map.groupBy(d.keys(),e=>d.get(e).key),h=[];for(let[e,t]of m){let n=p.get(e)??[];for(let e of t)for(let t of n)ie(f.get(t).name,d.get(e).name)&&h.push({s:t,d:e})}let g=Map.groupBy(h,({d:e})=>e),_=Map.groupBy(h,({s:e})=>e),v=[];for(let{s:e,d:t}of h){let n=_.get(e).length===1&&g.get(t).length===1&&ne(f.get(e).name,d.get(t).name),r=a(e,t,n?0:c);(n||r>=c)&&v.push({s:e,d:t,score:r})}let y=[],b=new Set,x=new Set;for(let e of v.sort((e,t)=>t.score-e.score))n.has(e.d)||r.has(e.s)||(x.has(e.s)||b.has(e.d)||l(e)?(y.push(e),x.add(e.s),b.add(e.d)):i(e.d,e.s,e.score));return y}function oe(e,t){let n=e.length;if(n!==t.length)return!1;let r=0;if(n>=32&&(e.byteOffset&3)==(t.byteOffset&3)){for(let n=4-(e.byteOffset&3)&3;r<n;r++)if(e[r]!==t[r])return!1;let i=n-r>>>2,a=new Int32Array(e.buffer,e.byteOffset+r,i),o=new Int32Array(t.buffer,t.byteOffset+r,i);for(let e=0;e<i;e++)if(a[e]!==o[e])return!1;r+=i*4}for(;r<n;r++)if(e[r]!==t[r])return!1;return!0}var N=class extends Error{constructor(e,t,n){let r=n===void 0?``:` in the ${n} tree`;super(t===void 0?e:`${e}: ${JSON.stringify(t)}${r}`),this.name=`CompareError`,this.path=t,this.tree=n}},se=new Set([`file`,`contiguous-file`]),ce=new Set([`fifo`,`character-device`,`block-device`]),le=/(?:^|\/)\.{0,2}(?:\/|$)/u;function ue(e){if(!Number.isInteger(e)||e<0||e>4095)throw RangeError(`a mode must be an integer from 0 to 0o7777, not ${e}`)}function de(e,t,n,r){if(typeof e!=`string`)throw TypeError(`an entry's name must be a string, not ${typeof e}`);if(e!==`.`||t!==`directory`){if(r?e===``:le.test(e))throw new N(r?`a name must not be empty`:"a name must be a relative path with no empty, `.` or `..` segment",e,n);if(!e.isWellFormed())throw new N(`a name must be well-formed Unicode`,e,n)}}function fe(e,t,n){if(typeof e!=`string`||e===``)throw new N(`a link must name its target`,t,n);if(!e.isWellFormed())throw new N(`a link target must be well-formed Unicode`,t,n);return e}function pe(e){if(e===void 0)return new Uint8Array;if(e instanceof Uint8Array)return e;if(typeof e!=`string`)throw TypeError(`a file's data must be a string or a Uint8Array, not ${typeof e}`);if(!e.isWellFormed())throw TypeError(`a file's text must be well-formed Unicode`);return e}var P=e=>typeof e==`string`?d(e):e;function me(e,t,n){if(typeof e!=`object`||!e)throw TypeError(`an entry must be an object, not ${e===null?`null`:typeof e}`);let{name:r,type:i=`file`,mode:a,linkname:o,data:s}=e;if(de(r,i,t,n),a!==void 0&&ue(a),se.has(i))return{path:r,type:`file`,mode:a??420,data:pe(s)};if(i===`symlink`||i===`hardlink`)return{path:r,type:i,target:fe(o,r,t)};if(i===`directory`)return{path:r,type:i};throw ce.has(i)?new N(`a ${i} is neither a file nor a link`,r,t):TypeError(`${JSON.stringify(i)} is not an entry type`)}function F(e,t){return e.type===t.type?e.type===`symlink`?e.target===t.target:e.data===t.data?!0:typeof e.data==`string`&&typeof t.data==`string`?!1:oe(P(e.data),P(t.data)):!1}function he(e,t,n){let r=new Set([e.path]),i=t.get(e.target);for(;i?.type===`hardlink`;){if(r.has(i.path))throw new N(`a hard link leads back to itself`,e.path,n);r.add(i.path),i=t.get(i.target)}if(i===void 0||i.type===`directory`)throw new N(`a hard link must name a file or a link in the tree`,e.path,n);return{...i,path:e.path}}function I(e,t,n){let r=new Map;for(let i of e){let e=me(i,t,n);if(e.type!==`directory`||e.path!==`.`){if(r.has(e.path))throw new N(`a name is given twice`,e.path,t);r.set(e.path,e)}}let i=new Map;for(let[e,a]of r){for(let i=n?-1:e.lastIndexOf(`/`);i>0;i=e.lastIndexOf(`/`,i-1)){let n=r.get(e.slice(0,i));if(n!==void 0&&n.type!==`directory`)throw new N(`a path lies under a ${n.type===`symlink`?`link`:`file`}`,e,t)}a.type===`hardlink`?i.set(e,he(a,r,t)):a.type!==`directory`&&i.set(e,a)}return i}var ge=100,_e=4,L=e=>e.slice(e.lastIndexOf(`/`)+1);function R(t,n){if(t.type===`symlink`)return`l${t.target}`;let r=n(t);return`f${r.length}:${e(r)}`}function ve({sources:e,dests:t,sourceNames:n,destNames:r,used:i,record:a,bytes:o}){let s=Map.groupBy(e.keys(),t=>R(e[t],o));for(let c=0;c<t.length;c++){let l=-1,u=ge;for(let a of s.get(R(t[c],o))??[])if(!i.has(a)&&F(e[a],t[c])&&((l===-1||n[a]===r[c])&&(l=a),n[a]===r[c]||--u===0))break;l!==-1&&a(c,l,6e4)}}var ye=new Map([[`.ts`,`.js`],[`.mts`,`.mjs`],[`.cts`,`.cjs`],[`.tsx`,`.jsx`]]),be=new Map([...[`.js`,`.mjs`,`.cjs`,`.jsx`,`.ts`,`.mts`,`.cts`,`.tsx`].map(e=>[e,`script`]),...[`.css`,`.scss`,`.sass`,`.less`].map(e=>[e,`style`])]);function z(e){let t=e.split(`/`),n=t.pop(),r=n.lastIndexOf(`.`);return r>0?{dirs:t,stem:n.slice(0,r),extension:n.slice(r)}:{dirs:t,stem:n,extension:``}}function B(e){let{dirs:t,stem:n,extension:r}=z(e);return JSON.stringify([t.map(e=>e===`lib`||e===`src`?null:e),n,ye.get(r)??r])}function xe(e){let{dirs:t,stem:n,extension:r}=z(e),i=[n,be.get(r)??r],a=t.lastIndexOf(`node_modules`),o=a===-1?0:a+(t[a+1]?.startsWith(`@`)?3:2),s=[JSON.stringify([...i,t])];for(let e=o;e<t.length;e++)s.push(JSON.stringify([...i,t.toSpliced(e,1,null)]));return s}var V=(e,t)=>Math.max(t,e+Math.trunc((6e4-e)/2));function H({pairs:e,used:t,scoreOf:n},{remaining:r,open:i},{s:a,d:o,score:s},c){let l=V(s,c);return i.some(t=>t!==o&&!e.has(t)&&n(a,t,l)>=l)||r.some(e=>e!==a&&!t.has(e)&&n(e,o,l)>=l)}function Se(e,t,n,r){let{sources:i,dests:a,pairs:o,used:s,record:c,scoreOf:l}=e,u=Map.groupBy(t.remaining.filter(e=>i[e].type===`file`),e=>B(i[e].path)),d=t.open.filter(e=>a[e].type===`file`).flatMap(e=>(u.get(B(a[e].path))??[]).map(t=>({s:t,d:e,score:l(t,e,0)})));for(let i of d.sort((e,t)=>t.score-e.score))o.has(i.d)||s.has(i.s)||n&&H(e,t,i,r)||c(i.d,i.s,i.score)}function Ce(e,t,n,r){let{sources:i,dests:a,pairs:o,used:s,record:c,scoreOf:l}=e,u=new Map,d=(e,t,n)=>new Map(t.filter(t=>e[t].type===`file`).map(t=>{let r=xe(e[t].path);for(let e of r)(u.get(e)??u.set(e,{sources:[],dests:[]}).get(e))[n].push(t);return[t,r]})),f=d(a,t.open.filter(e=>!o.has(e)),`dests`),p=d(i,t.remaining.filter(e=>!s.has(e)),`sources`),m=(e,t)=>{let n=new Set(e.flatMap(e=>u.get(e)[t]));return n.size===1?[...n][0]:-1};for(let[i,a]of p){let o=m(a,`dests`);if(o===-1||m(f.get(o),`sources`)!==i)continue;let s={s:i,d:o,score:l(i,o,0)};n&&H(e,t,s,r)||c(o,i,s.score)}}function we(e,t,n){let r=G(e),i=t<6e4&&r.remaining.length*r.open.length<=n*n;Se(e,r,i,t),Ce(e,r,i,t)}function U(e,t){let n=new Map;for(let r of t)n.set(e[r],n.has(e[r])?-1:r);return n}function Te({sourceNames:e,destNames:t,record:n,scoreOf:r},{remaining:i,open:a},o){let s=U(t,a),c=U(e,i);for(let t of i){let i=s.get(e[t]);if(i===void 0||i===-1||c.get(e[t])===-1)continue;let a=r(t,i,o);a>=o&&n(i,t,a)}}var W=(e,t)=>t.score-e.score||t.nameScore-e.nameScore;function Ee(e,t){if(e.length<_e){e.push(t);return}let n=0;for(let t=1;t<e.length;t++)W(e[t],e[n])>0&&(n=t);W(e[n],t)>0&&(e[n]=t)}function De({sourceNames:e,destNames:t,pairs:n,used:r,record:i,scoreOf:a},{remaining:o,open:s},c,l){let u=[];for(let n of s){let r=[];for(let i of o)Ee(r,{score:a(i,n,c),nameScore:+(e[i]===t[n]),dst:n,src:i});u.push(...r)}let d=0,f=e=>{for(;d<l.length&&V(l[d].score,c)>e;d++){let{s:e,d:t,score:a}=l[d];!n.has(t)&&!r.has(e)&&i(t,e,a)}};for(let{dst:e,src:t,score:a}of u.sort(W)){if(a<c)break;f(a),!n.has(e)&&!r.has(t)&&i(e,t,a)}f(-1/0)}var G=({sources:e,dests:t,pairs:n,used:r})=>({remaining:e.keys().filter(e=>!r.has(e)).toArray(),open:t.keys().filter(e=>!n.has(e)).toArray()}),K=e=>V(e,e);function q(e,t,{minimum:n,limit:r,byPath:i}){let a=new Map,o=new Set;if(e.length===0||t.length===0)return a;let s=new Map,c=new Map,l=new Map,u=e=>e.type===`file`?c.get(e)??c.set(e,P(e.data)).get(e):null,d=e=>s.get(e)??s.set(e,T(e)).get(e),f=e=>l.get(e)??l.set(e,T(e,w)).get(e),p={sources:e,dests:t,pairs:a,used:o,sourceNames:e.map(e=>L(e.path)),destNames:t.map(e=>L(e.path)),record(e,t,n){a.set(e,{source:t,score:n}),o.add(t)},bytes:u,scoreOf:(n,r,i)=>O(u(e[n]),u(t[r]),i,d),punctuatedScoreOf:(n,r,i)=>O(u(e[n]),u(t[r]),i,f,!0)};if(ve(p),i&&we(p,n,r),n>=6e4)return a;Te(p,G(p),K(n));let m=G(p);if(m.remaining.length*m.open.length>r*r)return a;let h=i?ae(p,m,K(n),e=>H(p,m,e,n)):[];return De(p,G(p),n,h),a}var Oe=50,ke=1e3;function J(e,t){let n=Math.min(e.length,t.length);for(let r=0;r<n;r++)if(e[r]!==t[r])return e.codePointAt(r)-t.codePointAt(r);return e.length-t.length}function Ae(e){if(e===!1)return null;let t=e===!0?Oe:e;if(typeof t!=`number`)throw TypeError(`renames must be a boolean or a percentage, not ${typeof e}`);if(!(t>0&&t<=100))throw RangeError(`renames must be a percentage above 0 and at most 100, not ${e}`);return Math.max(1,Math.trunc(6e4*t/100))}function je({renamesByPath:e,renameLimit:t,renameGroup:n,paths:r,lines:i}){if(typeof e!=`boolean`)throw TypeError(`renamesByPath must be a boolean, not ${typeof e}`);if(t!==1/0&&!(Number.isSafeInteger(t)&&t>=0))throw RangeError(`renameLimit must be a whole number or Infinity, not ${t}`);if(n!==null&&typeof n!=`function`)throw TypeError(`renameGroup must be a function, not ${typeof n}`);if(r!==`tree`&&r!==`keys`)throw RangeError(`paths must be 'tree' or 'keys', not ${r}`);if(typeof i!=`boolean`)throw TypeError(`lines must be a boolean, not ${typeof i}`)}var Me=(e,t)=>F(e,t)&&(e.type!==`file`||e.mode===t.mode),Y=(e,t,n,r=null)=>({status:e,old:t,new:n,similarity:r}),Ne=/\.d\.(?:[^./]+\.)?[cm]?ts$/u,Pe=e=>e.endsWith(`.mts`)?`module`:e.endsWith(`.cts`)?`commonjs`:null,Fe=/^export\s*\{\s*\}\s*;?$/u;function Ie(e){if(e===null)return{proven:!0,runtime:``,loads:!1};try{return t(e)===void 0?{proven:!1}:y(e.data)}catch{return{proven:!1}}}function Le(e){if(![e.old,e.new].filter(e=>e!==null).every(e=>e.type===`file`&&Ne.test(e.path))||e.old&&e.new&&e.old.mode!==e.new.mode)return e;let t=Ie(e.new),n=Ie(e.old);return!n.proven||!t.proven||n.runtime!==t.runtime&&!(e.old===null&&Fe.test(t.runtime))||n.loads&&e.old&&e.new&&e.old.path!==e.new.path&&Pe(e.old.path)!==Pe(e.new.path)?e:{...e,typeOnly:!0}}function Re(e,t){let n=[],r=[],i=[];for(let[n,a]of e){let e=t.get(n);e===void 0?i.push(a):e.type===a.type?Me(a,e)||r.push(Y(`modified`,a,e)):r.push(Y(`type-changed`,a,e))}for(let[r,i]of t)e.has(r)||n.push(i);return i.sort((e,t)=>J(e.path,t.path)),n.sort((e,t)=>J(e.path,t.path)),{changes:r,deleted:i,added:n}}function ze(e,t,{group:n,...r}){if(n===null)return q(e,t,r);let i=new Map,a=e=>Map.groupBy(e.keys(),t=>n(e[t].path)),o=a(e);for(let[n,s]of a(t)){let a=o.get(n);if(a!==void 0)for(let[n,{source:o,score:c}]of q(a.map(t=>e[t]),s.map(e=>t[e]),r))i.set(s[n],{source:a[o],score:c})}return i}function Be(e,t,{renames:i=!0,renamesByPath:a=!0,renameLimit:o=ke,renameGroup:s=null,paths:c=`tree`,lines:l=!0,horizon:u,whitespace:d,ignoreCase:f}={}){let p=Ae(i);je({renamesByPath:a,renameLimit:o,renameGroup:s,paths:c,lines:l});let m=n({horizon:u,whitespace:d,ignoreCase:f}),h=c===`keys`,{changes:g,deleted:_,added:v}=Re(I(e,`old`,h),I(t,`new`,h)),y=p===null?new Map:ze(_,v,{minimum:p,limit:o,byPath:a,group:s});for(let[e,t]of v.entries()){let n=y.get(e);g.push(n===void 0?Y(`added`,null,t):Y(`renamed`,_[n.source],t,Math.trunc(n.score*100/6e4)))}let b=new Set(y.values().map(({source:e})=>e));for(let[e,t]of _.entries())b.has(e)||g.push(Y(`deleted`,t,null));return g.sort((e,t)=>J((e.new??e.old).path,(t.new??t.old).path)),(l?g.map(e=>({...e,...r(e.old,e.new,m)})):g).map(Le)}function X(e,t,n){let r=new Map,o=new Set,s=0;for(let a of e){let e=i(n,a);e===null||!t.has(e)||(r.set(a,e),o.add(e),e!==a&&s++)}for(let n of e)r.has(n)||!t.has(n)||o.has(n)||(r.set(n,n),o.add(n));let c=r.size;for(let s of e){if(r.has(s))continue;let e=i(n,s)??a(n,s);for(;t.has(e)||o.has(e);)e=`../${e}`;r.set(s,e),o.add(e)}return{paths:r,paired:c,moved:s}}function Ve(e,t){let n=new Set(e),r=new Set(t),i=(e,t)=>{let n=new Map;for(let r of e)for(let e=r.indexOf(`/`);e!==-1;e=r.indexOf(`/`,e+1)){let i=r.slice(0,e+1);t.has(r.slice(e+1))&&n.set(i,(n.get(i)??0)+1)}let r=null,i=!1;for(let[e,t]of n)t>(n.get(r)??0)?[r,i]=[e,!1]:t===n.get(r)&&(i=!0);return i?null:r},a=X(n,r,null).paired,o=[[{base:``,other:i(r,n)},n],[{base:i(n,r),other:``},r]].filter(([e])=>e.base!==null&&e.other!==null).map(([e,t])=>({root:e,side:t,...X(n,r,e)})).filter(({side:e,paired:t,moved:n})=>t>a&&n*2>=e.size);return o.length===2&&o[0].paired===o[1].paired?null:o.toSorted((e,t)=>t.paired-e.paired)[0]?.root??null}function He(e,t){let n=[...e],r=new Set(t),i=Ve(n,r);return{root:i,paths:X(n,r,i).paths}}function Ue(e,t,n){if(!e&&!t)return null;let r=[...e??[]],i=Map.groupBy(r,([,e])=>e),a=new Map(i.entries().map(([e,t])=>[e,o(n,e,t.map(([t])=>t.slice(e.length+1)))]));return new Map([...r.map(([e,t])=>[n.paths.get(e)??e,a.get(t)]),...t??[]])}function We(e,t,n=new Map,r=new Map,i=null,a=()=>!1){let o=e=>{let t=n.get(e)??r.get(e);return t===void 0?[...new Set([e,Ze(i,e)??e])]:[t]},s=[],c=[],u=[],d=new Set;for(let n of e.values()){let e=o(n.parent).map(e=>t.get(l(e,n.specifier,n.conditions,n.platform))).find(Boolean),i=r.get(n.target)??n.target;if(e){if(d.add(e.key),!o(n.target).includes(e.target)){let{target:t,...n}=e;s.push({...n,baseTarget:i,otherTarget:t})}continue}let u=o(n.parent).find(a);if(u===void 0)continue;let{specifier:f,conditions:p,platform:m}=n;c.push({key:l(u,f,p,m),parent:u,specifier:f,conditions:p,platform:m,baseTarget:i,otherTarget:null})}for(let e of t.values()){if(d.has(e.key)||!a(e.parent))continue;let{target:t,...n}=e;u.push({...n,baseTarget:null,otherTarget:t})}for(let e of[s,c,u])e.sort((e,t)=>e.key.localeCompare(t.key));return{changed:s,onlyBase:c,onlyOther:u,totalChanges:s.length+c.length+u.length}}function Z(e){return m(e)??0}function Ge(e,t){return e===t||e?.format===`base64`&&t?.format===`base64`&&e.data===t.data||e?.format===`digest`&&t?.format===`digest`&&e.digest===t.digest}function Q(e){if(e?.kind!==`stasis`||!e.bundle)return null;let{formats:t,executable:n,entries:r}=e.bundle;return e=>({format:t?.get(e),executable:n?.has(e)??!1,entry:r?.has(e)??!1})}function Ke(e,t){return!e||!t?[]:[`format`,`executable`,`entry`].filter(n=>e[n]!==t[n]).map(n=>({field:n,from:e[n],to:t[n]}))}function qe(e){return(t,n)=>Math.abs(n.delta)-Math.abs(t.delta)||t[e].localeCompare(n[e])}function $(e){return(t,n)=>n.bytes-t.bytes||t[e].localeCompare(n[e])}function Je(e,t){return typeof e==`string`?`\0text\0${e.toWellFormed()}`:e?.format===`base64`?`\0base64\0${e.data}`:e?.format===`digest`?`\0digest\0${e.digest}`:`\0none\0${t}`}var Ye=250;function Xe(e,t,n,r,i){let a=(e,t,n)=>e.filter(({path:e})=>e!==``&&e.isWellFormed()).map(({path:e},r)=>({name:e,data:Je(t.get(e),`${n}${r}`)})),o={paths:`keys`,renameGroup:i,renameLimit:Ye,lines:!1},s=Be(a(e,n,`a`),a(t,r,`b`),o);return new Map(s.filter(({status:e})=>e===`renamed`).map(e=>[e.old.path,e.new.path]))}function Ze(e,t){return e?e.base===``?`${e.other}${t}`:t.startsWith(e.base)?t.slice(e.base.length):null:t}function Qe(){return{baseBytes:0,otherBytes:0,onlyBaseFiles:0,onlyOtherFiles:0,changedFiles:0}}function $e(e,t,n,r=He(e.keys(),t.keys()),i=[]){let{root:a,paths:o}=r,s=new Map([...o].map(([e,t])=>[t,e]));e=new Map([...e].map(([e,t])=>[o.get(e),t]));let c=e=>s.get(e)===e?{}:{basePath:s.get(e)},l=(e,t)=>{let n=Ke(i[0]?.(e),i[1]?.(t));return n.length>0?{meta:n}:{}},u=[],d=[],f=[],p=0,m=0,h=0,g=0,_=0,v=0,y=new Map,b=e=>{let t=n(e),r=y.get(t);return r||(r=Qe(),y.set(t,r)),r},x=new Set([...e.keys(),...t.keys()]);for(let n of x){let r=e.has(n),i=t.has(n),a=b(n);if(r&&i){let r=e.get(n),i=t.get(n),o=Ge(r,i),u=l(s.get(n),n),d=Z(r),h=o?d:Z(i);if(p+=d,m+=h,a.baseBytes+=d,a.otherBytes+=h,o&&!u.meta)v++;else{let e=h-d;f.push({path:n,...c(n),baseBytes:d,otherBytes:h,delta:e,...u,...o?{modified:!1}:{}}),_+=e,a.changedFiles++}}else if(r){let t=Z(e.get(n));p+=t,h+=t,a.baseBytes+=t,a.onlyBaseFiles++,u.push({path:n,...c(n),bytes:t})}else{let e=Z(t.get(n));m+=e,g+=e,a.otherBytes+=e,a.onlyOtherFiles++,d.push({path:n,bytes:e})}}let S=Xe(u,d,e,t,n);if(S.size>0){let n=new Set(S.values());for(let[n,r]of S){let i=e.get(n),a=t.get(r),o=Ge(i,a),c=Z(i),u=o?c:Z(a);h-=c,g-=u,f.push({path:r,renamedFrom:n,basePath:s.get(n),baseBytes:c,otherBytes:u,delta:u-c,modified:!o,...l(s.get(n),r)}),_+=u-c;let d=b(n);d.onlyBaseFiles--,d.onlyOtherFiles--,d.changedFiles++}u.splice(0,u.length,...u.filter(e=>!S.has(e.path))),d.splice(0,d.length,...d.filter(e=>!n.has(e.path)))}let C=[],w=[],T=[],E=[];for(let[e,t]of y){let n=t.baseBytes>0||t.onlyBaseFiles>0||t.changedFiles>0,r=t.otherBytes>0||t.onlyOtherFiles>0||t.changedFiles>0,i=t.onlyBaseFiles+t.onlyOtherFiles+t.changedFiles;n&&!r?C.push({pkg:e,bytes:t.baseBytes}):r&&!n?w.push({pkg:e,bytes:t.otherBytes}):i>0||t.baseBytes!==t.otherBytes?T.push({pkg:e,baseBytes:t.baseBytes,otherBytes:t.otherBytes,delta:t.otherBytes-t.baseBytes}):E.push({pkg:e,bytes:t.baseBytes})}return u.sort($(`path`)),d.sort($(`path`)),f.sort(qe(`path`)),C.sort($(`pkg`)),w.sort($(`pkg`)),T.sort(qe(`pkg`)),{totals:{baseFiles:e.size,baseBytes:p,otherFiles:t.size,otherBytes:m,onlyBaseFiles:u.length,onlyBaseBytes:h,onlyOtherFiles:d.length,onlyOtherBytes:g,changedFiles:f.length,renamedFiles:S.size,changedDelta:_,unchangedFiles:v,fileDelta:t.size-e.size,byteDelta:m-p,identical:u.length===0&&d.length===0&&f.length===0},files:{onlyBase:u,onlyOther:d,changed:f,root:a,basePaths:o},packages:{onlyBase:C,onlyOther:w,changed:T,unchanged:E}}}function et(e,t,n=null){let[r,i]=[e,t],[a,o]=s(r,i,n),l=c(r,a),d=c(i,o),m=He(l.keys(),d.keys()),y=Ue(h(r),h(i),m),b=$e(l,d,e=>v(e,{packageDir:y?.get(e)}),m,[Q(r),Q(i)]),x=_(r),S=_(i),C=(e,t)=>{let n=0;for(let r of t)n+=e.get(r)??0;return n};Object.assign(b.totals,{baseLines:C(x,l.keys()),otherLines:C(S,d.keys())});for(let e of b.files.onlyBase)e.lines=x.get(e.basePath??e.path)??0;for(let e of b.files.onlyOther)e.lines=S.get(e.path)??0;for(let e of b.files.changed)Object.assign(e,{baseLines:x.get(e.basePath??e.path)??0,otherLines:S.get(e.path)??0});let w=new Set([...b.files.onlyOther,...b.files.changed.filter(e=>e.modified!==!1)].map(e=>e.path));b.resolutions=We(u(r,a),u(i,o),new Map(b.files.changed.filter(e=>e.renamedFrom!=null).map(e=>[e.basePath,e.path])),b.files.basePaths,b.files.root,e=>d.has(e)&&!w.has(e));let T=e=>v(``,{packageDir:e}),E=g(r,a?l.keys():null,T),D=g(i,o?d.keys():null,T);return b.versionUpdates=p(E,D),b.packageRows=f(b.packages,E,D),b.scope=n??``,b}export{et as prepareComparison};