@preventive/triage 1.0.0-alpha.45 → 1.0.0-alpha.47

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 (110) hide show
  1. package/client/linked-findings.js +3 -0
  2. package/common/bundle-metadata.d.ts +1 -0
  3. package/common/bundle-metadata.js +1 -1
  4. package/common/bundle-sources.js +5 -1
  5. package/common/line-diff.js +5 -4
  6. package/common/managed/agent-tasks.ts +5 -3
  7. package/common/managed/github-agents.ts +28 -10
  8. package/out/activity.js +4 -0
  9. package/out/{chunk-NPW52BM2.js → chunk-4HI2MSAV.js} +13 -13
  10. package/out/chunk-5AHIQFFG.js +36 -0
  11. package/out/chunk-6ANSHRFQ.js +6 -0
  12. package/out/chunk-6WF3KNTL.js +3 -0
  13. package/out/chunk-7BKKYVWR.js +7 -0
  14. package/out/{chunk-HMAJDVXN.js → chunk-FH24VHSJ.js} +1 -1
  15. package/out/chunk-NOZJULWS.js +52 -0
  16. package/out/{chunk-OKRLLE5I.js → chunk-PWFUOLZK.js} +1 -1
  17. package/out/chunk-S6U2J62U.js +232 -0
  18. package/out/chunk-SPEFPML6.js +2 -0
  19. package/out/chunk-UENXT2HK.js +3 -0
  20. package/out/chunk-VL43BTSO.js +1 -0
  21. package/out/{chunk-3PS4KWD2.js → chunk-WCPJDAYA.js} +1 -1
  22. package/out/chunk-ZCS4UYHI.js +1 -0
  23. package/out/chunk-ZGNMDGSB.js +1 -0
  24. package/out/client-managed-import.js +1 -1
  25. package/out/client-managed.js +15 -15
  26. package/out/client-sync.js +2 -2
  27. package/out/compare.js +12 -12
  28. package/out/dialogs.js +28 -28
  29. package/out/graph.js +11 -11
  30. package/out/index.html +11 -11
  31. package/out/scan.js +2 -2
  32. package/out/terminal.js +6 -6
  33. package/out/view.css +1 -1
  34. package/out/view.js +15 -15
  35. package/package.json +4 -1
  36. package/risk/actions/findings.js +14 -9
  37. package/risk/actions/scripts/shell.js +5 -1
  38. package/risk/index.d.ts +9 -4
  39. package/risk/npm/assess.js +15 -4
  40. package/risk/npm/registry.js +6 -1
  41. package/server-e2e/app.ts +5 -4
  42. package/server-e2e/http.ts +5 -2
  43. package/server-managed/activity.ts +24 -11
  44. package/server-managed/app-agents.ts +10 -21
  45. package/server-managed/bundle-build-worker.js +7 -3
  46. package/server-managed/bundle-build.ts +5 -3
  47. package/server-managed/bundle-cache.ts +16 -4
  48. package/server-managed/bundle.ts +3 -4
  49. package/server-managed/combined.ts +3 -2
  50. package/server-managed/commit-coauthors.ts +5 -9
  51. package/server-managed/commit-lockfiles.ts +21 -11
  52. package/server-managed/config.ts +6 -0
  53. package/server-managed/db-methods.ts +321 -156
  54. package/server-managed/db-neon.ts +71 -24
  55. package/server-managed/db-schema.ts +4 -0
  56. package/server-managed/db.ts +2 -1
  57. package/server-managed/dependency-reviews.ts +13 -3
  58. package/server-managed/github-app.ts +12 -6
  59. package/server-managed/github-issue-links.ts +11 -5
  60. package/server-managed/github-pulls.ts +2 -2
  61. package/server-managed/github-requests.ts +39 -0
  62. package/server-managed/http-response.ts +10 -2
  63. package/server-managed/http.ts +269 -143
  64. package/server-managed/index.ts +8 -7
  65. package/server-managed/kept-briefly.ts +37 -0
  66. package/server-managed/link-reports.ts +5 -1
  67. package/server-managed/npm-delta.ts +11 -6
  68. package/server-managed/npm-kept.ts +51 -7
  69. package/server-managed/npm-loads.ts +117 -35
  70. package/server-managed/npm-packages.ts +107 -14
  71. package/server-managed/npm-risk.ts +68 -18
  72. package/server-managed/pretty-print.ts +112 -35
  73. package/server-managed/pull-dependencies.ts +29 -9
  74. package/server-managed/pull-dependency-reviews.ts +8 -8
  75. package/server-managed/queue.ts +16 -0
  76. package/server-managed/rename-diff.ts +22 -13
  77. package/server-managed/report-sources.ts +1 -1
  78. package/server-managed/report-store.ts +50 -12
  79. package/server-managed/repository-actions.ts +15 -6
  80. package/server-managed/repository-agents.ts +1 -1
  81. package/server-managed/repository-browser.ts +123 -33
  82. package/server-managed/repository-code.ts +28 -11
  83. package/server-managed/repository-dependency-reviews.ts +41 -19
  84. package/server-managed/repository-history.ts +24 -8
  85. package/server-managed/repository-pulse.ts +9 -2
  86. package/server-managed/repository-risk-audit.ts +13 -0
  87. package/server-managed/repository-risk-read.ts +11 -6
  88. package/server-managed/repository-risk.ts +27 -20
  89. package/server-managed/session.ts +18 -4
  90. package/server-managed/solidity-entry-points.ts +5 -3
  91. package/server-managed/sql-postgres.ts +3 -0
  92. package/server-managed/sql.ts +6 -2
  93. package/server-managed/storage-db.ts +11 -3
  94. package/server-managed/storage-encryption.ts +7 -4
  95. package/server-managed/storage.ts +8 -4
  96. package/server-managed/team-feed.ts +3 -1
  97. package/server-managed/team-reports.ts +30 -13
  98. package/server-managed/uploads.ts +29 -9
  99. package/server-managed/upstream-cache.ts +12 -0
  100. package/server.ts +14 -5
  101. package/out/chunk-5DHL5NG3.js +0 -2
  102. package/out/chunk-6HNXNIQY.js +0 -52
  103. package/out/chunk-AFLZH7WG.js +0 -1
  104. package/out/chunk-NV7ES4EW.js +0 -1
  105. package/out/chunk-PTGDYLNS.js +0 -36
  106. package/out/chunk-Q6MVYGYV.js +0 -3
  107. package/out/chunk-QRD6GIG5.js +0 -229
  108. package/out/chunk-WI7Z5A2T.js +0 -6
  109. package/out/chunk-WQ74ZBZF.js +0 -7
  110. package/out/chunk-XVBEOGOS.js +0 -3
@@ -0,0 +1,36 @@
1
+ import{b as e,h as t}from"./chunk-I2MDGSQX.js";import{a as n}from"./chunk-WCPJDAYA.js";import{a as r,b as i,e as a}from"./chunk-IYPY47MC.js";import{A as o,B as s,E as c,b as l,c as u,d,j as f,m as p,p as m,s as h,t as g,w as _,z as v}from"./chunk-SXV2T5C4.js";import{A as ee,b as y,c as b,i as te,w as x,y as S}from"./chunk-WFYLMF6Z.js";import{a as C,b as w,c as T}from"./chunk-C4Z6ZBXV.js";import{c as E,f as D,g as O,i as k}from"./chunk-2XUEZHIP.js";var ne=w(class extends T{constructor(e){if(super(e),e.type!==C.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 D}}),re=e=>e.replaceAll(`&`,`&amp;`).replaceAll(`<`,`&lt;`).replaceAll(`>`,`&gt;`),ie=e=>y(e)?e:re(b(String(e))),A=globalThis.trustedTypes?.createPolicy(`deepview`,{createHTML:ie,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}}),j=e=>A?A.createHTML(e):ie(e),ae=e=>A?A.createScriptURL(String(e)):e,M={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 oe({keepViewport:e=!1}={}){M.graphState?._cleanup?M.graphState._cleanup({keepViewport:e}):e||(M.keptViewport=null),M.graphState=null}function N(e){return e.id??String(e._id)}function se(e){let t=m(e);return t!==``&&t!==`revalidation`}var ce=[{value:`confirmed`,label:`Confirmed`,kinds:[`confirmed`,`partial`,`revalidation`]},{value:`unreachable`,label:`Unreachable`,kinds:[`unreachable`]},{value:`refuted`,label:`Refuted`,kinds:[`refuted`]}];function le(e){return ce.find(t=>t.value===e)?.kinds??null}var ue=[``,`exclude`,`only`];function de(e,t){let n=le(e);return n?.includes(`partial`)?t===`only`?[`partial`]:t===`exclude`?[`confirmed`]:n:n}function P(e){if(e.confidence!==void 0)return e.confidence;if(e.critical===!0||e._source)return 10}var fe=e=>e.confidence!==void 0||e.critical===!0;function pe(e){return e.every(e=>e.every(e=>P(e)!==void 0))&&e.some(e=>e.some(fe))}function me(e,t,n){return e.some(e=>{let r=[`refuted`,`unreachable`].includes(n(e))?0:P(e);return r===void 0?t===0:r>=t})}function he(e,t){let n=e.map(t).filter(e=>e.length>0);if(!n.some(e=>e.some(e=>P(e)!==void 0)))return 0;let r=e=>n.reduce((t,n)=>t+ +!!n.some(t=>(P(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 ge(e,t){return pe(e)?t:0}function _e(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(N(e));for(let i of e){let e=t(i);if(e.length!==0&&e.some(e=>de(`confirmed`,``).includes(n(e)||(e._source&&!e._sourcePass?`revalidation`:``)))){for(let e of i)if(r.add(N(e)),e.isApp&&Array.isArray(e.revalidateInputs))for(let t of e.revalidateInputs)t&&r.add(t)}}return r}function ve(e,t,n,r){let i=ge(e,t),a=e.filter(e=>me(e,i,r));if(a.length===0)return!1;let o=new Set(de(`confirmed`,``));return e.some(e=>e.some(e=>o.has(r(e))))?a.every(e=>e.every(e=>n.has(N(e)))):!1}function ye(e,{tabs:t,kindOf:n,severityMode:r}){let i=e.map(t).filter(e=>e.length>0),a=_e(e,t,n);if(!ve(i,he(e,t),a,n))return!1;let o=ge(i,6);return i.every(e=>!me(e,o,n)||!e.some(e=>p(e,r)!==`low`)||e.every(e=>a.has(N(e))))}var F=!0;function be(e,t=!1){F=e!==!1&&!t}function xe(){return F}function I(e){return F?m(e):``}function Se(e){return m(e)!==``}function Ce(e){return e.some(e=>(e.groups??[]).some(e=>e.some(se)))}function we(e){let t=I(e);return t&&t!==`revalidation`?t:null}function Te(e){return I(e)===`revalidation`}var Ee=new Set([`refuted`,`unreachable`]);function De(e){return Ee.has(I(e))}function Oe(e){return Ee.has(I(e))}function ke(e){let t=new Set(e);return ce.filter(e=>e.kinds.some(e=>t.has(e)))}function L(e){return RegExp(`(^|/)${e}/`,`u`)}function Ae(e){return RegExp(`^(?:.*/)?${e}/(?:@[^/]+/[^/]+|[^/]+)/(.*)$`,`u`)}var je=L(`node_modules`),Me=L(`vendor`),R=`node_modules`,z=L(R),Ne=Ae(R);function Pe(e){e!==R&&(R=e,z=L(e),Ne=Ae(e))}var B=null;function Fe(t){B?.length===t.length&&B.every((e,n)=>e===t[n])||(B=[...t],Pe(e(t)))}function Ie(){return R}function V(e){return z.test(e)}var Le=new WeakSet;function Re(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=Le.has(n);`isUpstream`in n&&!e||(V(n.file)?(n.isUpstream!==!0&&(t=!0),n.isUpstream=!0,Le.add(n)):e&&(t=!0,delete n.isUpstream,Le.delete(n)))}return t}function ze(e){let t=typeof e==`string`?e:``;return je.test(t)||Me.test(t)||z.test(t)}var Be=/^(.*(?:^|\/)node_modules\/(?:@[^/]+\/[^/]+|[^/]+))(?:\/|$)/u;function Ve(e){return Be.exec(typeof e==`string`?e:``)?.[1]??null}function He(e){return typeof e!=`number`||!Number.isFinite(e)?null:n(e)}function Ue(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 We(e){return e.match(Ne)?.[1]??e}var Ge={on:new WeakMap,off:new WeakMap};function Ke(e){let t=F?Ge.on:Ge.off,n=t.get(e);if(n===void 0){let r=F?[we(e),e.revalidateVerdict,e.revalidateRecommendation]:[];n=[e.file,e.title,e.description,e.impact,e.reproduction,Ot(e),e.recommendation,e.confidenceReason,...r,e.discoveredIn,e.repo?.github].filter(Boolean).join(`
2
+ `).toLowerCase(),t.set(e,n)}return n}function qe(e){return[typeof e?.category==`string`?e.category.trim():``,h(e,F)].filter(Boolean).join(` · `)}function Je(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 Ye(e){if(!e)return``;let t=e.match(/github\.com\/([^/?#]+\/[^/?#]+?)(?:\.git)?(?:[/?#]|$)/iu);return t?t[1]:e}function Xe(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 Ze=/^(?:@[\w.-]+\/)?[\w.-]+@[^/\s@]+$/u;function Qe(e){return Ze.test(e||``)}function $e(e){if(e==null||typeof e==`string`)return{id:e??``,prefix:``};let t=c(e);return{id:typeof e.github==`string`?e.github:``,prefix:t?`${t}/`:``}}function et(e,t,n){if(Qe(e))return null;let r=$e(t);if(r.id)return`https://github.com/${r.id}/blob/HEAD/${r.prefix}${We(e)}`;if(V(e))return null;let i=$e(n),a=Xe(i.id);return a?`${a}/blob/HEAD/${i.prefix}${e}`:null}function tt(e,t){let n=e?.file??``,r=H(e,t);return r?E`<a href="${nt(r)}" target="_blank" rel="noopener">${n}</a>`:n}function nt(e){return e.replace(/#L\d+(?:-L?\d+)?$/u,``)}function H(e,t){if(!e)return null;if(s(e.location))return e.location;let n=et(e.file,e.repo,t);if(!n)return null;let r=parseInt(e.line,10);return Number.isFinite(r)?`${n}#L${r}`:n}var rt=/^https?:\/\/(?:www\.)?github\.com\/([^/\s]+\/[^/\s]+)\/(?:blob|tree|blame)\/[^/\s]+\/(\S+)$/u,it=/#L(\d+)(?:-L?(\d+))?$/u;function at(e){let t=typeof e==`string`?rt.exec(e):null;if(!t)return``;let n=t[2],r=it.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 ot=/^(?:\s+\S|[-*+] |\d+[.)] |>|#{1,6}(?:[ \t]|$)|\||`{3}|~{3})/u;function st(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=>ot.test(e)||U.test(e))?e:t.map(e=>e.trim()).filter(Boolean).join(` `)}).join(``)}function ct(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+st(i.slice(0,i.length-a.length))+a}function lt(e){if(!e)return e;let t=e.replaceAll(`\r
4
+ `,`
5
+ `),n=l(t);if(n.length===0)return st(t);let r=[],i=0;for(let[e,a]of n)e>i&&r.push(ct(t.slice(i,e),i>0,!0)),r.push(t.slice(e,a)),i=a;return i<t.length&&r.push(ct(t.slice(i),!0,!1)),r.join(``)}var ut=/^( *)(`{3,}|~{3,})(.*)$/u,dt=/^[a-z0-9+#._-]{1,20}$/u;function ft(e,t){let n=0;for(;n<t&&e[n]===` `;)n++;return e.slice(n)}function pt(e){let t=e.split(`
6
+ `),n=ut.exec(t[0]),r=(n?.[2]??"```").slice(0,3),i=(n?.[3]??``).trim().split(/\s+/u)[0].toLowerCase(),a=!!(t.length>1?ut.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=>ft(e,o)):s).join(`
7
+ `)}}function mt(e){let t=l(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(pt(e.slice(a,o))),r=o;return r<e.length&&i(e.slice(r),!0),n}var ht=/^( *)(?:[-*+]|(\d{1,9})[.)]) +(?=\S)/u,U=/^ {0,3}([-*_])(?:[ \t]*\1){2,}[ \t]*$/u;function gt(e){return/^ */u.exec(e)[0].length}function _t(e){let t=e.length;for(;t>0&&!e[t-1].trim();)t--;return e.slice(0,t).join(`
8
+ `)}function vt(e){let t=typeof e==`string`?e:``;if(!t)return[e];let n=l(t),r=t.split(`
9
+ `),i=[],a=0;for(let e of r)i.push(a),a+=e.length+1;let o=e=>!u(n,i[e])&&!U.test(r[e])&&ht.test(r[e]),s=[],c=0,d=0,f=e=>{let t=r.slice(c,e).join(`
10
+ `).replace(/^\n+/u,``).replace(/\n+$/u,``);t.trim()&&s.push(t)};for(;d<r.length;){if(!o(d)){d++;continue}f(d);let e=ht.exec(r[d]),t=!!e[2],a=[],l=null,p=!1;for(;d<r.length;){let e=r[d];if(!u(n,i[d])){if(!e.trim()){l.lines.push(``),p=!0,d++;continue}let n=gt(e),r=U.test(e)?null:ht.exec(e);if(r&&(!l||n<l.column)){if(!!r[2]!==t)break;l&&a.push(_t(l.lines)),l={column:r[0].length,lines:[e.slice(r[0].length)]},p=!1,d++;continue}if(n<l.column&&(p||yt.test(e)||U.test(e)))break}l.lines.push(ft(e,l.column)),p=!1,d++}l&&a.push(_t(l.lines)),s.push({ordered:t,start:t?Number(e[2]):null,items:a}),c=d}return s.length===0?[e]:(f(r.length),s)}var yt=/^ {0,3}(#{1,6})[ \t]+(\S.*?)(?:[ \t]+#+)?[ \t]*$/u,bt=/^ {0,3}-+[ \t]*$/u;function xt(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=yt.exec(e),s=U.test(e)&&(a===r||!t[a-1].trim()||!bt.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 St=/^(\d+)(?:\s*-\s*(\d+))?$/u;function W(e){if(typeof e==`number`)return Number.isFinite(e)&&e>=1?{start:Math.floor(e),end:Math.floor(e)}:null;let t=St.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 Ct(e){return e?e.start===e.end?String(e.start):`${e.start}-${e.end}`:``}function wt(e){if(e&&typeof e==`object`){let t=W(e.start);if(!t)return null;let n=W(e.end)??t;return{start:t.start,end:Math.max(t.start,n.end)}}return W(e)}function Tt(e,t,n=4){let r=typeof e==`string`&&e!==``?e.split(`
13
+ `):[];if(r.length===0)return{text:``,startLine:1,lines:[]};let i=wt(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(`
14
+ `),startLine:o,lines:c}}function Et(e,t,n,r){if(s(e?.url))return e.url;let i=e?.file;if(typeof i!=`string`||i===``)return null;let a=t?.file??``,o=t?.repo?.github,c=()=>o?H({file:i,line:e?.line,repo:t.repo},null):null;if(r===0&&i===a)return c();let l=Ve(i);return l!==null&&l===Ve(a)?c():ze(i)?null:o&&!ze(a)?c():H({file:i,line:e?.line},n)}function Dt(e,{spaced:t=!1}={}){let n=Array.isArray(e?.evidence)?e.evidence:[];return n.length===0?``:n.map((e,t)=>{let n=v(e),r=[`${t+1}. ${e.url?`[${n}](${e.url})`:n}`],i=o(e);if(i)for(let e of i.split(`
15
+ `))r.push(` ${e}`);return r.join(`
16
+ `)}).join(t?`
17
+
18
+ `:`
19
+ `)}function Ot(e){let t=Dt(e);return t?`**Evidence:**
20
+ ${t}`:``}function kt(e){let t=/^\[([^\]]+)\]\(([^)\s]+)\)$/u.exec(e);return!t||!s(t[2])?null:{label:d(t[1].trim())||t[2],url:t[2]}}function At(e,t){let n=parseInt(e?.line,10);if(!Number.isFinite(n))return O;let r=H(e,t),i=`line ${n}`;return r?E`<a href="${r}" target="_blank" rel="noopener">${i}</a>`:i}function jt(e,t){return!e||!t?null:`${/^https?:/iu.test(e)?e.replace(/\/$/u,``):`https://github.com/${e}`}/commit/${t}`}var Mt=[[`Impact`,`impact`],[`Reproduction`,`reproduction`],[`Recommendation`,`recommendation`],[`Confidence reason`,`confidenceReason`],[`Revalidation verdict`,`revalidateVerdict`],[`Revalidation recommendation`,`revalidateRecommendation`]];function Nt(e,t){let n=[];t&&n.push(`Repo: ${t}`);let r=v(e);r&&n.push(`Location: ${r}`),e?.confidence!=null&&n.push(`Confidence: ${e.confidence}/10`);let i=I(e);i&&n.push(`Revalidation: ${i}`);let a=[];n.length>0&&a.push(n.join(`
21
+ `));let{title:o,body:s}=_(e);o&&a.push(`# ${o}`),s&&a.push(s.trim());let c=Dt(e,{spaced:!0});c&&a.push(`# Evidence
22
+
23
+ ${c}`);for(let[t,n]of Mt){if(!F&&n.startsWith(`revalidate`))continue;let r=g(e?.[n],e)?.trim();r&&a.push(`# ${t}
24
+
25
+ ${r}`)}return a.join(`
26
+
27
+ `)}function Pt(e,{title:t,body:n,labels:r=[]}={}){let i=Xe(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 Ft=/^[a-zA-Z\d](?:-?[a-zA-Z\d])*$/u,It=/^[a-zA-Z\d._-]+$/u,Lt=/^[1-9]\d{0,9}$/u,Rt=/^[a-fA-F\d]{7,40}$/u,zt=/^#[\w-]+$/u,Bt=/^GHSA(?:-[0-9a-z]{4}){3}$/u;function Vt(e){return e.length<=39&&Ft.test(e)}function Ht(e){return e.length<=100&&e!==`.`&&e!==`..`&&It.test(e)}function Ut(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 Bt.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!Vt(e)||!Ht(t)||!Bt.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(!Vt(r)||!Ht(i))return null;let s;if(a===`issues`||a===`pull`){if(!Lt.test(o))return null;s=`${r}/${i}#${o}`}else if(a===`commit`){if(!Rt.test(o))return null;s=`${r}/${i}@${o.slice(0,7)}`}else return null;return{url:`https://github.com/${r}/${i}/${a}/${o}${zt.test(t.hash)?t.hash:``}`,label:s}}var Wt=/^[\da-f]{8}(?:-[\da-f]{4}){3}-[\da-f]{12}$/u;function Gt(e){if(typeof e!=`string`)return null;let t=Kt(e);return t!==e||Wt.test(e)?t.slice(0,8):null}function Kt(e){let t=String(e);return t.startsWith(`https://chatgpt.com/codex/cloud/security/findings/`)?t.slice(50):t}function qt(e,n){let r=t(e,{managed:n});if(!r)return null;let i=Gt(r.id);return{url:n?r.path:`#${r.fragment}`,label:i?`finding ${i}`:`finding`,self:!0}}var Jt=/https?:\/\/[^\s<>"'`(){}[\]|\\^]+/giu,Yt=new Set([`)`,`.`,`,`,`!`,`?`,`;`,`:`,`'`,`"`,`*`,`]`,`}`,`>`]);function Xt(e){let t=e.length;for(;t>0&&Yt.has(e[t-1]);)t--;return t===e.length?e:e.slice(0,t)}function Zt(e,{managed:t=!1}={}){if(typeof e!=`string`||e.length===0)return[];let n=[],r=0;Jt.lastIndex=0;let i;for(;(i=Jt.exec(e))!==null;){let a=Xt(i[0]),o=a?Ut(a)??qt(a,t):null;o&&(i.index>r&&n.push(e.slice(r,i.index)),n.push(o),r=i.index+a.length,Jt.lastIndex=r)}return r<e.length&&n.push(e.slice(r)),n}var Qt={commit:S},$t=8;function en(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 tn({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 G;function nn(){return G||(G=document.createElement(`div`),G.id=`styled-tooltip`,G.setAttribute(`popover`,`manual`),document.body.append(G),G)}function rn(e){typeof e.showPopover==`function`&&(e.matches(`:popover-open`)&&e.hidePopover(),e.showPopover())}var K=null,an=``,q=null,J=null,on=0,sn=0,cn=!1;function Y(){if(!cn){cn=!0,document.addEventListener(`mousemove`,e=>{on=e.clientX,sn=e.clientY},{passive:!0});for(let e of[`pointerdown`,`wheel`,`scroll`])document.addEventListener(e,()=>Z(),{capture:!0,passive:!0});document.addEventListener(`keydown`,e=>{e.key===`Escape`&&Z()}),window.addEventListener(`blur`,()=>Z())}}var ln=100,un=14,dn=8,X=8;function fn(e,{placement:t=`cursor`}={}){Y(),clearTimeout(q),q=null,J=null,e.prepareTooltip?.(e),t=e.dataset.tooltipPlacement??t;let n=nn(),i=e.dataset.tooltip??``,a=Object.hasOwn(Qt,e.dataset.tooltipIcon??``)?e.dataset.tooltipIcon:``,o=e.dataset.tooltipRepo??``,s=r(e.dataset.tooltipCommit),c=en(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){Z();return}if(K===e&&an===y)return;if(n.textContent=a||v?``:i,v){let e=document.createElement(`div`);e.className=`tooltip-rich`,k(v,e),n.append(e)}if(a){let e=document.createElement(`span`);e.className=`tooltip-text`,e.innerHTML=j(Qt[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=j(x);let t=document.createElement(`span`);t.textContent=o,e.append(t)}if(s){let t=document.createElement(`span`);t.className=`tooltip-commit`,t.innerHTML=j(S);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,$t)){let n=document.createElement(`span`);n.className=`tooltip-tag`,n.innerHTML=j(ee);let r=document.createElement(`span`);r.textContent=t,n.append(r),e.append(n)}if(c.tags.length>$t){let t=document.createElement(`span`);t.className=`tooltip-tag-more`,t.textContent=`+${(c.tags.length-$t).toLocaleString()} more`,e.append(t)}n.append(e)}}if(c?.details&&n.append(tn(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=j(te);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)}rn(n),n.style.left=`0px`,n.style.top=`0px`,n.style.transform=`none`,n.classList.add(`visible`);let b=on,C=sn+un;if(t===`right`||t===`right-start`){let n=e.getBoundingClientRect();b=n.right+dn,C=n.top+(t===`right`?n.height/2:0)}let w=window.innerWidth-n.offsetWidth-X,T=Math.max(X,Math.min(b,w));n.style.left=`${Math.round(T)}px`;let E=n.offsetHeight,D=t===`right`?C-E/2:C,O=window.innerHeight-E-X,ne=Math.max(X,Math.min(D,O));n.style.top=`${Math.round(ne)}px`,K=e,an=y}function Z(e){e&&!e.contains(K)&&!e.contains(J)||(clearTimeout(q),q=null,J=null,G&&(G.classList.remove(`visible`),typeof G.hidePopover==`function`&&G.matches(`:popover-open`)&&G.hidePopover()),K=null)}function pn(e,{gate:t,placement:n}={}){Y();let r=()=>e.isConnected!==!1&&(!Object.hasOwn(e.dataset,`tooltipTruncated`)||e.scrollWidth>e.clientWidth||e.scrollHeight>e.clientHeight)&&(!t||t(e));if(!r()){Z();return}e===K||e===J||(Z(),J=e,q=setTimeout(()=>{q=null,J=null,r()&&fn(e,{placement:n})},ln))}var mn=new WeakSet;function hn(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 gn(e,t){!e||mn.has(e)||(mn.add(e),e.ownerDocument&&Y(),e.addEventListener(`mouseover`,n=>{if(n.buttons){Z();return}let r=hn(n,e);if(!r){Z();return}r!==K&&pn(r,t)}),e.addEventListener(`mouseout`,t=>{let n=hn(t,e),r=t.relatedTarget?.closest?.(`[data-tooltip]`)??null;n&&n===r||Z()}),e.addEventListener(`scroll`,()=>Z(e),{capture:!0,passive:!0}))}var _n=!1;function vn(){_n||(_n=!0,Y(),document.addEventListener(`tooltip-root-connected`,e=>{gn(e.composedPath()[0]?.shadowRoot)}),document.body.addEventListener(`mouseover`,e=>{if(e.target.closest(`[data-tooltip-managed]`))return;if(e.buttons){Z();return}let t=e.target.closest(`[data-tooltip]`);!t||t===K||pn(t)}),document.body.addEventListener(`mouseout`,e=>{e.target.closest(`[data-tooltip-managed]`)||e.relatedTarget?.closest?.(`[data-tooltip-managed]`)||!K&&!q||(K??J)?.contains(e.relatedTarget)||Z()}))}function yn(e){return`tree-`+e.replaceAll(/[^\w-]+/gu,`_`)}var bn=()=>Object.fromEntries(f.map(e=>[e,0]));function xn(e,t){let n=new Map;for(let r of e)for(let e of r){n.has(e.file)||n.set(e.file,bn());let r=n.get(e.file),i=p(e,t);r[i]!==void 0&&r[i]++}return n}var Q={trees:[],merged:null};function Sn(e){let t=e.map(e=>e?.tree??null);return t.length===Q.trees.length&&t.every((e,t)=>e===Q.trees[t])||(Q={trees:t,merged:Cn(e)}),Q.merged}function Cn(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 wn(e,t){let n=Object.keys(e),r=new Map(n.map((e,t)=>[e,t])),i=n.map(()=>bn()),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=f.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 Tn(e,t,n){let r=t.get(e),i=n.get(e);return En(r)>0||En(i)>0}function En(e){if(!e)return 0;let t=0;for(let n of f)t+=e[n]??0;return t}function Dn(e){if(!e)return null;let t=Ie(),n=RegExp(`^(?:.*/)?${t}/(@[^/]+/[^/]+|[^/]+)`,`u`),r=e.match(n);return r?r[1]:`__own__`}function On(e){return new Set(e.filter(e=>!V(e)))}var kn=[`#4e9af1`,`#f28e2b`,`#59a14f`,`#e15759`,`#76b7b2`,`#edc948`,`#b07aa1`,`#ff9da7`,`#9c755f`,`#5cd1e5`,`#f1ce63`,`#d37295`,`#a0cbe8`,`#86bcb6`,`#8cd17d`,`#b6992d`,`#499894`,`#e15759`,`#e879c7`,`#d4a6c8`],An=[`#2f8aef`,`#d2691e`,`#2ea043`,`#e63946`,`#2e9a92`,`#b88817`,`#9560e8`,`#d24a9c`,`#8a5d40`,`#0891b2`,`#a07a14`,`#c14e8e`,`#1f7ad0`,`#549b94`,`#3fb95f`,`#a07a14`,`#2a8278`,`#cb2c40`,`#c026d3`,`#965f93`];function jn(){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 $=new Map;function Mn(e){let t=jn()?An:kn;return t[e%t.length]}var Nn=()=>jn()?`#8c959f`:`#6e7681`;function Pn(e){let t=jn(),n=t?An:kn,r=e??`__own__`,i=`${t?`l`:`d`}:${r}`;if($.has(i))return $.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 $.set(i,o),o}var Fn={package:`@babel/core`,path:/^lib\/config\//u},In={package:`@babel/core`,path:/^lib\/config\/files\/(?:module-types|plugins)\.js$/u},Ln=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:Fn,to:{path:/(?:^|\/)babel\.config\.js$/u}},{id:`babel-typescript-preset`,reason:`Babel configuration loads the TypeScript preset.`,from:Fn,to:{package:`@babel/preset-typescript`,path:/./u}},{id:`babel-react-native-preset`,reason:`Babel config loaders load the configured React Native preset.`,from:In,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:In,to:{package:/^(?:@[^/]+\/)?react-native-reanimated$/u,path:/^plugin\/index\.js$/u}},{id:`babel-transform-plugin`,reason:`Babel config loaders load configured transform plugins.`,from:In,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 Rn(e){return typeof e==`string`&&!e.includes(`\\`)&&!e.includes(`:`)&&e.split(`/`).every(e=>e!==``&&e!==`.`&&e!==`..`&&e!==`node_modules`)}function zn(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 Bn(e,t){if(e?.ownSource!==!0&&Rn(e?.path)&&Rn(t?.path))return Ln.find(n=>(!n.ownSourceOnly||t.ownSource===!0)&&zn(n.from,e)&&zn(n.to,t))}function Vn(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 Hn(e,t,n,r){return!Bn(Vn(e,r),Vn(t,n))}function Un(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&&Hn(o.origFile??i,a.origFile??s,e.ownSourceFiles?.has(s),e.ownSourceFiles?.has(i))&&r.get(t(o)).add(t(a))}}return r}var Wn=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 Gn(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 Kn(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 qn(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 Jn(e,t){let n=qn(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 Yn(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 Wn(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=qn(e,n);for(let i of[[...r,...a.toReversed()],Kn(n),e,e.toReversed()]){let e=Gn(Jn(i,n),t),r=qn(e,n);r>s&&(o=e,s=r)}return o}function Xn(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();if(s.done){i.push(r),e.pop();continue}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 Zn(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?n.file: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=Hn(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:_}=Xn(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 ee=e.ownSourcePackages??new Set(e.layerRoots?.roots??[]),y=e=>e.pkg===`__own__`?0:ee.has(e.pkg)?1:2,b=e=>d.has(e.id)&&f.has(e.id)?0:1,te=new Map(g.map((e,t)=>[t,e.reduce((e,t)=>Math.min(e,y(s.get(t))),2)])),x=(e,t)=>e.pkg.localeCompare(t.pkg)||e.label.localeCompare(t.label),S=new Map;if(n===`structure`){for(let e of g)if(!(e.length<2))for(let t of Map.groupBy(e,e=>y(s.get(e))).values())Yn(t.toSorted((e,t)=>x(s.get(e),s.get(t))),u).forEach((e,t)=>S.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 C=r.trim().toLowerCase(),w=new Set(h.filter(e=>!C||s.get(e).files.some(e=>e.toLowerCase().includes(C))||s.get(e).label.toLowerCase().includes(C))),T=new Set(i?[i]:w);if(C||i)for(let[e,t]of u)for(let n of t.keys())(i?e===i:w.has(e))&&T.add(n),(i?n===i:w.has(n))&&T.add(e);let E=(e,t)=>{if(n===`structure`){let n=te.get(e.component)-te.get(t.component);if(n)return n;let r=b(e)-b(t);if(r)return r;let i=e.component-t.component;if(i)return i}let r=y(e)-y(t);if(r)return r;if(n===`importers`)return t.importers-e.importers||x(e,t);if(n===`imports`)return t.dependencies-e.dependencies||x(e,t);let i=b(e)-b(t);if(i)return i;if(n===`structure`&&e.component===t.component){let n=(S.get(e.id)??0)-(S.get(t.id)??0);if(n)return n}return x(e,t)},D=[...s.values()].filter(e=>T.has(e.id)&&(!o||e.cyclic)).toSorted(E),O=new Map(D.map((e,t)=>[e.id,t])),k=[];for(let[e,t]of u)if(O.has(e))for(let n of t.values())O.has(n.to)&&k.push({...n,row:O.get(e),col:O.get(n.to)});return{rows:D,byId:s,cells:u,visibleCells:k,index:O,matches:w,importCount:m,totalRows:s.size,cycleCount:g.filter(e=>v.has(e[0])).length}}export{ne as a,j as b,ae as c,M as d,oe as e,N as f,se as g,ce as h,le as i,ue as j,de as k,P as l,pe as m,he as n,_e as o,ve as p,ye as q,be as r,xe as s,I as t,Se as u,Ce as v,we as w,Te as x,De as y,Oe as z,ke as A,Fe as B,Ie as C,V as D,Re as E,He as F,Ue as G,Ke as H,qe as I,Je as J,Ye as K,tt as L,H as M,at as N,lt as O,mt as P,vt as Q,xt as R,W as S,Ct as T,Tt as U,Et as V,Ot as W,kt as X,At as Y,jt as Z,Nt as _,Pt as $,Gt as aa,Kt as ba,Zt as ca,fn as da,Z as ea,pn as fa,gn as ga,vn as ha,yn as ia,xn as ja,Sn as ka,wn as la,Tn as ma,En as na,Dn as oa,On as pa,Mn as qa,Nn as ra,Pn as sa,Yn as ta,Hn as ua,Un as va,Xn as wa,Zn as xa};
28
+ /*! Bundled license information:
29
+
30
+ lit-html/directives/class-map.js:
31
+ (**
32
+ * @license
33
+ * Copyright 2018 Google LLC
34
+ * SPDX-License-Identifier: BSD-3-Clause
35
+ *)
36
+ */
@@ -0,0 +1,6 @@
1
+ import{a as e}from"./chunk-SXV2T5C4.js";import{b as t}from"./chunk-TUII34K2.js";var n=new Set([`module`,`commonjs`,`json`,`module-typescript`,`commonjs-typescript`]),r=new Set([`solidity`,`php`,`shell`,`rust`]),i=new Set([`java`,`kotlin`,`gradle`,`objc`,`objcpp`,`swift`,`c`,`cpp`,`c-header`,`cpp-header`,`ruby`,`python`,`cmake`,`podspec`,`podfile`,`podfile-lock`,`template`,`xml`,`env`,`fastlane`,`pbxproj`]),a=new Set([`resource`,`resource:base64`]),o=new Set([`stat:file`,`stat:directory`]),s=new Set([...n,...r,...i,...a,`patch`,`directory`,...o]),c=e=>o.has(e),l=e=>e===`directory`||e===`stat:directory`?`directory`:`file`;function u(e,t,n){if(e===t)return e;let r=c(e);if(r!==c(t)&&l(e)===l(t))return r?t:e;throw Error(`format conflict for '${n}' ('${t}' vs '${e}')`)}function d(e,t){return t===``?e:e===`.`?t:`${e}/${t}`}var f=/^(?=[A-Za-z0-9-]{1,39}\/)[A-Za-z0-9](?:-?[A-Za-z0-9])*\/(?!\.\.?$)[\w.-]{1,100}$/u,p=/^(?!\.\.?(?:\/|$))[\w.~@+-]+(?:\/(?!\.\.?(?:\/|$))[\w.~@+-]+)*$/u,m=/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/u,h={github:e=>typeof e==`string`&&f.test(e),directory:e=>typeof e==`string`&&e.length<=1024&&(e===``||p.test(e)),commit:e=>typeof e==`string`&&m.test(e)},ee=(e,t)=>e?.toLowerCase()===t?.toLowerCase(),g=(e,t,n)=>{if(e===void 0)return;x(e)||y(!1,`${n} must be an object`);for(let r of Object.keys(e))Object.hasOwn(t,r)||y(!1,`unknown ${n} key '${r}'`);let r=Object.entries(t).map(([t,r])=>typeof r==`object`?[t,g(e[t],r,`${n}.${t}`)]:(e[t]!==void 0&&!r(e[t])&&y(!1,`invalid ${n}.${t}: ${JSON.stringify(e[t])}`),[t,e[t]])).filter(([,e])=>e!==void 0);return r.length===0?void 0:Object.freeze(S(r))},_=(e,t=`bundle repo`)=>g(e,h,t),te=(e,t)=>t??(k(e)?`npm`:void 0),ne=(e,{ecosystem:t,repo:n},r)=>{if(n===void 0)return;te(e,t)===void 0&&y(!1,`${r}: '${e}' is no dependency's bucket, and carries no repo`);let i=_(n,`${r} module '${e}' repo`);return i?.github===void 0&&y(!1,`${r} module '${e}' repo has no github`),i},v=({name:e,version:t,ecosystem:n,repo:r,files:i})=>({name:e,version:t,...n===void 0?{}:{ecosystem:n},...r===void 0?{}:{repo:r},files:i});function re({name:e,version:t,ecosystem:n,repo:r,files:i},a,o){return y(n===void 0||typeof n==`string`),v({name:e,version:t??void 0,ecosystem:n,repo:ne(a,{ecosystem:n,repo:r},o),files:S(Object.entries(i))})}function ie(e,{scope:t=`full`}={}){let n=new Set;for(let[r,{files:i}]of e)if(t===`full`||k(r))for(let e of Object.keys(i))n.add(d(r,e));return n}function ae(e,{what:t,files:n,formats:r,scope:i}){if(e.includes(`\\`))return`holds a '\\'`;if(T(e))return`escapes the root`;if(i!==`full`&&!k(e))return`is outside node_modules, which a '${i}'-scope ${t} does not record`;if(!n.has(e))return`names no file the ${t} records`;let a=r.get(e);return a===`directory`?`is a directory capture, not a file`:c(a)?`is a payload-free '${a}' record, not a file`:null}function oe(e,{what:t,files:n,formats:r,scope:i}){for(let a of e){let e=ae(a,{what:t,files:n,formats:r,scope:i});y(e===null,`${t}: executable entry '${a}' ${e}`)}}function se(e,{what:t,files:n,formats:r,scope:i=`full`}){if(e===void 0)return new Set;let a=`${t}: executable`;y(Array.isArray(e),`${a} must be an array of file paths`);let o=new Set;for(let t of e)y(typeof t==`string`&&t!==``,`${a} entry must be a non-empty string`),y(!o.has(t),`${a} entry '${t}' is listed twice`),o.add(t);return oe(o,{what:t,files:n,formats:r,scope:i}),o}function ce(e,{what:t,modules:n,formats:r,scope:i}){if(e.size!==0)return oe(e,{what:t,files:ie(n,{scope:i}),formats:r,scope:i}),C(e)}function y(e,t){if(!e)throw Error(t)}function le(e,t){let[n,r]=[e.split(`/`),t.split(`/`)];for(;n.length>0&&n[0]===r[0];)n.shift(),r.shift();if(n.length===0&&r.length===0)return 0;if(n.length<2)return r.length<2&&n>r?1:-1;if(r.length<2)return 1;if(n[0]===`*`)return-1;if(r[0]===`*`||n[0]===`node_modules`)return 1;if(r[0]===`node_modules`)return-1;let[i,a]=[n,r].map(e=>e.join(String.fromCodePoint(0)));if(i<a)return-1;if(i>a)return 1;throw Error(`Unreachable`)}var b=(e,t)=>le(e[0],t[0]),x=e=>e&&[null,Object.prototype].includes(Object.getPrototypeOf(e)),S=e=>Object.setPrototypeOf(Object.fromEntries(e),null),C=e=>[...e].toSorted(le),w=(e,{sorted:t=!0}={})=>S((t?[...e].toSorted(b):[...e]).map(([e,n])=>[e,n instanceof Map?w(n,{sorted:t}):n])),ue=(e,t)=>e.get(t)??e.set(t,new Map).get(t),de=e=>new Map(Object.entries(e).map(([e,t])=>[e,x(t)?de(t):t]));function T(e){if(e.startsWith(`/`))return!0;if(!e.includes(`..`))return!1;let t=0;for(let n of e.split(`/`))if(n!==`.`&&n!==``){if(n!==`..`)t++;else if(--t<0)return!0}return!1}var fe=e=>e.includes(`\\`)||T(e),E=(e,t)=>y(!fe(e),`${t}: path '${e}' escapes the root or holds a '\\'`),pe=(e,t)=>y(typeof e==`string`&&e!==``&&!fe(e),`${t}: invalid entry ${JSON.stringify(e)}`);function me(e,t){y(Array.isArray(e),`${t}: entries must be an array of file paths`);let n=new Set;for(let r of e)pe(r,t),y(!n.has(r),`${t}: entry '${r}' is listed twice`),n.add(r);return n}function he(e,t){for(let n of e)pe(n,t);return C(e)}function ge(e,t){E(e,`formats`),y(s.has(t),`unknown format '${t}' for ${e}`)}function _e(e){y(x(e));let t=new Map;for(let[n,r]of Object.entries(e)){ge(n,r);let e=n===``?`.`:n;y(!t.has(e),`duplicate format key '${e}'`),t.set(e,r)}return t}function ve(e){for(let[t,n]of e)ge(t,n);return w(e)}function ye(e){for(let[,t]of e){y(t instanceof Map);for(let[e,n]of t){E(e,`imports`),y(n instanceof Map);for(let[,e]of n){if(typeof e==`string`){E(e,`imports`);continue}y(e instanceof Map&&e.size>0,`import target must be a file or a non-empty {platform: file} map`);for(let[t,n]of e)y(typeof t==`string`&&t.length>0&&!t.includes(`/`),`invalid platform key '${t}'`),y(typeof n==`string`),E(n,`imports`)}}}}function be(e){y(x(e));let t=de(e);return ye(t),t}function xe(e){return ye(e),w(e)}function Se(e,{skipEmpty:t=!1,repo:n=!0,what:r}={}){let i={modules:[],sources:[]};for(let[a,o]of e){if(t&&Object.keys(o.files).length===0)continue;let e=k(a);e&&y(o.name&&o.version&&o.files);let s=S(Object.entries(o.files).toSorted(b));i[e?`modules`:`sources`].push([a,v({...o,repo:n?ne(a,o,r):void 0,files:s})])}return{modules:S(i.modules.toSorted(b)),sources:S(i.sources.toSorted(b))}}function Ce(e,t){let n=e instanceof Map;if(n!==t instanceof Map)return!1;if(!n)return e===t;if(e.size!==t.size)return!1;for(let[n,r]of e)if(t.get(n)!==r)return!1;return!0}var we=e=>e instanceof Map?`{${[...e].map(([e,t])=>`${e}: ${t}`).join(`, `)}}`:e;function Te(e,t,n){let r=new Map,i=e=>{for(let[t,i]of e){let e=ue(r,t);for(let[t,r]of i){let i=ue(e,t);for(let[e,a]of r)i.has(e)?y(Ce(i.get(e),a),`${n}: import '${e}' from '${t}' resolves differently ('${we(i.get(e))}' vs '${we(a)}')`):i.set(e,a instanceof Map?new Map(a):a)}}};return i(e),i(t),r}function Ee(e,t,n){let r=new Map,i=e=>{for(let[t,i]of e){let e=r.get(t);if(e===void 0){r.set(t,i);continue}try{r.set(t,u(i,e,t))}catch(e){throw Error(`${n}: ${e.message}`,{cause:e})}}};return i(e),i(t),r}function De(e,t,n,r){if(e.size===0)return new Set(t);let i=ie(n,{scope:r}),a=new Set(t);for(let t of e)i.has(t)||a.add(t);return a}var Oe=/(?:^|\/)\.{0,2}(?:\/|$)/u;function D(e,t,n){let r=d(e,t);return(r!==`.`||t!==``)&&Oe.test(r)&&y(!1,`${n}: non-canonical file key ${JSON.stringify(r)}`),r.includes(`\\`)&&y(!1,`${n}: file key '${r}' holds a '\\', which no path may`),r}function O(e,t,n){let r=new Map;for(let[i,{files:a}]of e){typeof i!=`string`&&y(!1,`${t}: bucket dir ${String(i)} is not a string`),E(i,t);for(let e of Object.keys(a)){let a=D(i,e,t),o=r.get(a);o!==void 0&&n(a,o,i),r.set(a,i)}}return r}var ke=(e,t)=>n=>y(!1,`duplicate file key '${n}' across ${e} buckets -- module bucketing changed between writes (a workspace package without a version now owns its own bucket); regenerate the ${t}`);function Ae(e,t,n){let r=new Map,i=e=>{for(let[t,i]of e){let e=r.get(t);if(e===void 0){r.set(t,v({...i,files:Object.assign(Object.create(null),i.files)}));continue}y(e.name===i.name,`${n}: module '${t}' name mismatch ('${e.name}' vs '${i.name}')`),y(e.version===i.version,`${n}: module '${t}' version mismatch ('${e.version}' vs '${i.version}')`+(e.version==null==(i.version==null)?``:` -- an artifact from an older stasis may record a placeholder version for a workspace package without one; regenerate it (bundle=replace / lock=replace)`)),y(e.ecosystem===i.ecosystem,`${n}: module '${t}' ecosystem mismatch ('${e.ecosystem??`(none)`}' vs '${i.ecosystem??`(none)`}')`),e.repo===void 0&&i.repo!==void 0&&r.set(t,v({...e,repo:i.repo}));for(let[r,a]of Object.entries(i.files))Object.hasOwn(e.files,r)?y(e.files[r]===a,`${n}: content mismatch for '${d(t,r)}'`):e.files[r]=a}};return i(e),i(t),O(r,n,(e,t,r)=>y(!1,`${n}: file '${e}' is bucketed under both '${t}' and '${r}' -- module bucketing changed between the artifacts (a workspace package without a version now owns its own bucket); regenerate the artifact (bundle=replace / lock=replace)`)),r}function k(e){return e.split(`/`).includes(`node_modules`)}function je(e){let t=e.length;for(;(t=e.lastIndexOf(`node_modules/`,t-1))!==-1;)if(t===0||e[t-1]===`/`)return t;return-1}function Me(e){let t=je(e);if(t===-1)return null;let n=t+13,r=e.slice(n).split(`/`),i=r[0].startsWith(`@`)?2:1;if(r.length<=i||r.slice(0,i).some(e=>!e))return null;let a=r.slice(0,i).join(`/`);return{dir:e.slice(0,n)+a,rel:r.slice(i).join(`/`),name:a}}var A=1,Ne=0,Pe=ke(`bundle`,`artifact (bundle=replace)`),Fe=e=>Me(e)??{dir:`.`,rel:e===`.`?``:e,name:null};function Ie(){throw Error(`bundle: file contents are not retained by this contents-free Bundle`)}var Le=(e,{files:t,...n})=>{let r=Object.create(null);for(let[n,i]of Object.entries(t))typeof i!=`symbol`&&y(!1,`bundle: file '${d(e,n)}' is not a placeholder`),Object.defineProperty(r,n,{get:Ie,enumerable:!0});return{...n,files:Object.freeze(r)}},j=(e,t)=>{if(e===void 0&&t===void 0)return;let n=new Map;for(let r of[e,t])for(let[e,t]of Object.entries(r??{})){if(!Array.isArray(t))continue;let r=n.get(e);r===void 0&&n.set(e,r=new Set);for(let e of t)r.add(e)}return S([...n.keys()].toSorted().map(e=>[e,C(n.get(e))]))},Re=(e,t)=>Object.hasOwn(h,e)&&h[e](t),ze=(e,t)=>e?.github===void 0||!ee(e.github,t?.github)?void 0:S(Object.keys(h).filter(n=>e[n]!==void 0&&(n===`github`||e[n]===t[n])).map(t=>[t,e[t]])),Be=e=>{if(!x(e)||e.root!==!0||Object.hasOwn(e,`directory`))return e;let{root:t,...n}=e;return n},Ve=e=>typeof e==`string`&&/^[\w.+@/~'!()*-]+$/u.test(e),M={name:Ve,version:Ve},He={npm:M,composer:M,cargo:M},Ue=(e,t)=>S(Object.keys(He).map(n=>{let[r,i]=[e?.[n],t?.[n]];return[n,r?.name!==void 0&&r.name===i?.name?S(Object.entries(r).filter(([e,t])=>t===i[e])):void 0]})),N=class e{static VERSION=A;version=A;config;entries;modules;formats;imports;executable;reason;#e;get repo(){return this.#e}set repo(e){this.#e=_(e)}#t;get package(){return this.#t}set package(e){this.#t=g(e,He,`bundle package`)}constructor({config:e={scope:`full`},entries:t,modules:n,formats:r,imports:i,executable:a,reason:o,repo:s,package:c,version:l=A}={}){y([Ne,A].includes(l)),y([`node_modules`,`full`].includes(e.scope)),this.version=l,this.config=e,this.entries=t??new Set,this.modules=n??new Map,this.formats=r??new Map,this.imports=i??new Map,this.executable=a??new Set,this.reason=o,this.repo=_(s),this.package=c}get sources(){let e=new Map;for(let[t,{files:n}]of this.modules)for(let[r,i]of Object.entries(n))e.set(d(t,r),i);return e}static isResourceFormat(e){return e===`resource`||e===`resource:base64`||e===`directory`}get hasCode(){for(let[t,{files:n}]of this.modules)for(let r of Object.keys(n))if(!e.isResourceFormat(this.formats.get(d(t,r))))return!0;return!1}static parse(t){return e.fromJSON(JSON.parse(t))}static fileKeyAt(e){let[t,n,r,i]=e;if(typeof n==`string`){if(e.length===2&&t===`sources`){let e=Fe(n);return D(e.dir,e.rel,`bundle`)}if(e.length===4&&(t===`sources`||t===`modules`)&&r===`files`&&typeof i==`string`)return D(n,i,`bundle`)}}static fromJSON(t,{contents:n=!0}={}){y(t.version===A||t.version===Ne),y([`node_modules`,`full`].includes(t.config?.scope));let r=_e(t.formats),i=new Map,a=new Set;if(t.version===A){let e=t.config.scope===`full`;if(t.modules!==void 0){y(typeof t.modules==`object`&&t.modules!==null);for(let[e,n]of Object.entries(t.modules))y(k(e)),E(e,`bundle`),y(n?.name&&n.version&&n.files),i.set(e,re(n,e,`bundle`))}if(e){y(t.sources&&typeof t.sources==`object`);for(let[e,n]of Object.entries(t.sources))y(!k(e)),E(e,`bundle`),y(n?.name&&n.files),i.set(e,re(n,e,`bundle`));t.entries!==void 0&&(a=me(t.entries,`bundle`))}else y(t.entries===void 0),y(t.sources===void 0)}else{y(t.sources);for(let[e,n]of Object.entries(t.sources)){E(e,`bundle`);let{dir:t,rel:r,name:a}=Fe(e);y(!T(t)&&!T(r)),i.has(t)||i.set(t,{name:a,version:null,files:Object.create(null)});let{files:o}=i.get(t);y(!Object.hasOwn(o,r),`bundle: duplicate file key '.' (v0 '' and '.')`),o[r]=n}}let o=O(i,`bundle`,Pe),s=be(t.imports);if(!n)for(let[e,t]of i)i.set(e,Le(e,t));return new e({version:t.version,config:t.config,entries:a,modules:i,formats:r,imports:s,executable:t.version===A?se(t.executable,{what:`bundle`,files:o,formats:r,scope:t.config.scope}):new Set,reason:x(t.reason)?t.reason:void 0,repo:Be(t.repo),package:t.package})}serialize(){O(this.modules,`bundle`,Pe);let{modules:e,sources:t}=Se(this.modules,{skipEmpty:!0,what:`bundle`}),n=this.config.scope===`full`,r={version:A,config:this.config};this.repo!==void 0&&(r.repo=this.repo),this.package!==void 0&&(r.package=this.package),n&&(r.entries=he(this.entries,`bundle`)),r.formats=ve(this.formats),r.imports=xe(this.imports);let i=ce(this.executable,{what:`bundle`,modules:this.modules,formats:this.formats,scope:this.config.scope});return i!==void 0&&(r.executable=i),this.reason!==void 0&&(r.reason=j(this.reason,void 0)),n&&(r.sources=t),r.modules=e,JSON.stringify(r,void 0,2)}withReason(t){let{version:n,config:r,entries:i,modules:a,formats:o,imports:s,executable:c,repo:l,package:u}=this,d=j(this.reason,{[t]:[...this.sources.keys()]});return new e({version:n,config:r,entries:i,modules:a,formats:o,imports:s,executable:c,reason:d,repo:l,package:u})}merge(t){return y(this.config.scope===t.config.scope,`bundle merge: scope mismatch ('${this.config.scope}' vs '${t.config.scope}')`),new e({config:{scope:this.config.scope},entries:new Set([...this.entries,...t.entries]),modules:Ae(this.modules,t.modules,`bundle merge`),formats:Ee(this.formats,t.formats,`bundle merge`),imports:Te(this.imports,t.imports,`bundle merge`),executable:De(this.executable,t.executable,t.modules,this.config.scope),reason:j(this.reason,t.reason),repo:ze(this.repo,t.repo),package:Ue(this.package,t.package)})}},We={__proto__:null,js:`javascript`,mjs:`javascript`,cjs:`javascript`,jsx:`jsx`,ts:`typescript`,mts:`typescript`,cts:`typescript`,tsx:`tsx`,json:`json`,css:`css`,html:`markup`,htm:`markup`,xml:`markup`,svg:`markup`,yml:`yaml`,yaml:`yaml`,sh:`bash`,bash:`bash`,md:`markdown`,markdown:`markdown`,sol:`solidity`,php:`php`,phtml:`php`,rs:`rust`,rb:`ruby`,py:`python`,pyw:`python`,pyi:`python`,java:`java`,cpp:`cpp`,cc:`cpp`,cxx:`cpp`,"c++":`cpp`,hpp:`cpp`,hh:`cpp`,hxx:`cpp`,"h++":`cpp`,h:`cpp`,c:`c`,m:`objectivec`,mm:`objectivec`},Ge={__proto__:null,module:`javascript`,commonjs:`javascript`,"module-typescript":`typescript`,"commonjs-typescript":`typescript`,json:`json`,solidity:`solidity`,php:`php`,shell:`bash`,rust:`rust`,java:`java`,objc:`objectivec`,objcpp:`objectivec`,c:`c`,"c-header":`c`,cpp:`cpp`,"cpp-header":`cpp`,ruby:`ruby`,podspec:`ruby`,podfile:`ruby`,fastlane:`ruby`,"podfile-lock":`yaml`,xml:`markup`};function Ke(e){if(typeof e!=`string`)return!1;let t=e.length-1,n=0;for(;n<t&&/\s/u.test(e[n]);)n++;for(;t>n&&/\s/u.test(e[t]);)t--;return n<t&&e[n]===`{`&&e[t]===`}`}function qe(e,t,n){if(typeof t==`string`&&Ge[t])return Ge[t];if(typeof e!=`string`)return null;let r=e.slice(e.lastIndexOf(`/`)+1),i=r.lastIndexOf(`.`);if(i<=0)return null;let a=r.slice(i+1).toLowerCase();return a===`map`?Ke(n)?`json`:null:We[a]??null}var Je=/^webpack(?:-internal)?:\/\/[^/]*\//u,Ye=/^[a-z][\d+.a-z-]*:/iu,Xe=/^file:/iu,Ze=/^(?:file|ftp|https?|wss?):/iu,Qe=/^(?:[a-z][\d+.a-z-]*:\/\/[^/]*\/?|\/\/[^/]+\/|[a-z]:\/|\/)?/iu,P=e=>Qe.exec(e)[0],F=e=>P(e).includes(`://`),I=e=>e.replace(F(e)?/[#?].*$/su:/\?.*$/su,``),$e=e=>e.slice(e.lastIndexOf(`/`)+1),L=(e,t)=>URL.parse(e,t)?.href??null;function R(e){let t=P(e),n=t.includes(`://`)&&L(e);if(n)return n;let r=[];for(let n of e.slice(t.length).split(`/`))n===``||n===`.`||(n===`..`?r.length>0&&r.at(-1)!==`..`?r.pop():t||r.push(`..`):r.push(n));let i=/^[a-z]:\/$/iu.test(t)?t.toUpperCase():t.startsWith(`//`)?t.toLowerCase():t;return i?i.replace(/\/?$/u,`/`)+r.join(`/`):r.join(`/`)||`.`}function et(e,t){let n=P(t);return F(e)&&!n.includes(`:`)?L(t,e)??R(`${e}/../${t}`):R(n===`/`?P(e).replace(/\/?$/u,``)+t:n?t:`${e}/../${t}`)}function tt(e){try{return decodeURIComponent(e)}catch{return e}}function z(e,t){let n=e.replaceAll(`\\`,`/`);if(Je.test(n))return R(n.replace(Je,``));let r=Ze.test(n)?L(n)??n:n,i=/^file:\/\/([^/#]*)([^#]*)/isu.exec(r);if(i){let[,e,t]=i;return R(tt(e&&e.toLowerCase()!==`localhost`?`//${e}${t}`:t).replace(/^\/(?=[a-z]:\/)/iu,``))}if(Ye.test(r)&&!P(r).includes(`:`))return r;if(t===void 0)return R(r);if(Xe.test(t)&&!P(r))return z(L(r,t)??r);let a=z(t);return P(r)&&!F(a)?R(r):et(a,r)}var nt=/^(?:@[\dA-Za-z~-][\w.~-]*\/)?[\dA-Za-z~-][\w.~-]*$/u;function B(e){let t=e.split(`/`).slice(0,e.startsWith(`@`)?2:1).join(`/`);return nt.test(t)?t:null}var rt=new Set([`.pnpm`,`.bun`,`.deno`]),it=/^\d+\.\d+\.\d+(?:-[\d.a-z-]+)?(?:\+[\d.a-z-]+)?$/iu;function at(e,t){let n=`${t.replace(`/`,`+`)}@`,r=e.startsWith(n)?e.slice(n.length).split(/[(_]/u)[0]:null;return it.test(r)?r:null}function ot(e){let t=I(e).split(`/`),n=t.lastIndexOf(`node_modules`),r=n<0?null:B(t.slice(n+1).join(`/`));if(r===null)return null;let i=n+1+r.split(`/`).length;if(i>=t.length||t.slice(i).includes(``))return null;let a=t.slice(0,i).join(`/`);return{name:r,version:rt.has(t[n-2])?at(t[n-1],r):null,root:a,path:e.slice(a.length+1)}}var st=new Map([[`js`,`jsx`],[`mjs`,`jsx`],[`cjs`,`jsx`],[`jsx`,`jsx`],[`es`,`jsx`],[`es6`,`jsx`],[`ts`,`ts`],[`mts`,`ts`],[`cts`,`ts`],[`tsx`,`tsx`],[`json`,`json`]]);function ct(e){let t=$e(I(e));return/^[\w-]+$/u.test(t)?`jsx`:st.get(/\.([\da-z]+)$/iu.exec(t)?.[1].toLowerCase())??null}var lt=[`.js`,`.mjs`,`.cjs`,`.jsx`,`.ts`,`.tsx`,`.mts`,`.cts`,`.json`],ut=[`.ios`,`.android`,`.web`];function dt(e){let t=e.map(e=>/\.[a-z]+(?=\.\w+$)/u.exec($e(I(e.path??``)))?.[0]),[[n,r],[,i]]=ut.map(e=>[e,t.filter(t=>t===e).length]).toSorted((e,t)=>t[1]-e[1]);return[...r===i?[]:[n],`.native`,``,`.browser`,`.node`]}var ft=new Map([[`.js`,[`.ts`,`.tsx`]],[`.jsx`,[`.tsx`]],[`.mjs`,[`.mts`]],[`.cjs`,[`.cts`]]]),pt=[`index`,`main`,`browser`,`node`],mt=[``,`src/`,`lib/`,`dist/`,`build/`],ht=new Set([`lib`,`dist`,`build`,`out`,`esm`,`cjs`]);function*gt(e,t){yield e;let n=/\.[^./]+$/u.exec(e)?.[0];for(let t of ft.get(n)??[])yield e.slice(0,-n.length)+t;for(let n of e.endsWith(`/`)?[`${e}index`]:[e,`${e}/index`])for(let e of lt)for(let r of t)yield n+r+e;if(n)for(let r of t.filter(Boolean))yield e.slice(0,-n.length)+r+n}function*_t(e){let t=e;for(;;){t.startsWith(`src/`)||(yield`src/${t}`),t!==e&&(yield t);let n=t.indexOf(`/`);if(n<0||!ht.has(t.slice(0,n)))return;t=t.slice(n+1)}}function vt(e){let t=new Map,n=new Map,r=new Map;for(let i of e)i.path!==null&&t.set(i.path,i),i.package&&(n.set(i.package.name,(n.get(i.package.name)??new Set).add(i.package.root)),(r.get(i.package.root)??r.set(i.package.root,[]).get(i.package.root)).push(i));return{byPath:t,roots:n,byRoot:r,platforms:dt(e),found:new Map}}function V(e,t){if(!e.found.has(t)){let n=I(t),r=gt(n,e.platforms).map(e=>e+t.slice(n.length));e.found.set(t,e.byPath.get(r.find(t=>e.byPath.has(t)))??null)}return e.found.get(t)}function yt(e,t,n){let r=e.roots.get(n);if(!r)return null;let i=t.path.split(`/`);for(let e=i.length-1;e>=0;e--){let t=[...i.slice(0,e),`node_modules`,n].join(`/`);if(r.has(t))return t}return r.size===1?[...r][0]:null}var bt=new Set(`assert.async_hooks.buffer.child_process.cluster.console.constants.crypto.dgram.diagnostics_channel.dns.domain.events.fs.http.http2.https.inspector.module.net.os.path.perf_hooks.process.punycode.querystring.readline.repl.stream.string_decoder.sys.timers.tls.trace_events.tty.url.util.v8.vm.wasi.worker_threads.zlib._http_agent._http_client._http_common._http_incoming._http_outgoing._http_server._stream_duplex._stream_passthrough._stream_readable._stream_transform._stream_wrap._stream_writable._tls_common._tls_wrap.assert/strict.dns/promises.fs/promises.inspector/promises.path/posix.path/win32.readline/promises.stream/consumers.stream/promises.stream/web.timers/promises.util/types`.split(`.`));function xt(e){if(e.startsWith(`node:`)||bt.has(e))return{builtin:!0};let t=B(I(e));return t===null?{}:{package:t}}function St(){let e=[],t=new Map,n=(n,r,i)=>{let a=t.get(n)??t.set(n,new Set).get(n);a.has(r)||(a.add(r),e.push(i))};return{edges:e,add:n,link:(e,t,r)=>{e&&t&&t!==e&&n(e,t,{from:e,to:t,kind:r})}}}function Ct(e,t){for(let n of pt)for(let r of mt){let i=V(e,`${t}/${r}${n}`);if(i)return i}let n=e.byRoot.get(t);return n?.length===1?n[0]:null}function wt(e,t,n,r){return/^\/[^?]/u.test(n)?V(e,t+n)??_t(n.slice(1)).map(n=>V(e,`${t}/${n}`)).find(Boolean):V(e,t+n)??r(e,t)}function Tt(e,t,n,r=Ct){let i=/^(?:\.{1,2}|[a-z]:)?\\/iu.test(n)?n.replaceAll(`\\`,`/`):n,a=Ze.test(i);if(a||/^(?:\.{1,2}(?:\/|$)|\/|[a-z]:\/)/iu.test(i)||F(i)){let n=a?z(i):et(t.path,i),r=V(e,n);return r?{to:r}:{to:null,path:n}}if(Ye.test(i)&&e.byPath.has(i))return{to:e.byPath.get(i)};let o=B(I(n)),s=o===null?null:yt(e,t,o);if(s===null)return{to:null,...xt(n)};let c=wt(e,s,n.slice(o.length),r);return c?{to:c}:{to:null,package:o}}var H=class extends Error{name=`SourceMapError`},Et=new Uint8Array(128).fill(255);for(let[e,t]of[...`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/,;`].entries())Et[t.codePointAt(0)]=e;function U(e){let t=new Int32Array(e.length*2);return t.set(e),t}function Dt(e){let{starts:t,columns:n,sources:r,names:i}=e;for(let e=0;e+1<t.length;e++){let[a,o]=[t[e],t[e+1]],s=a+1;for(;s<o&&n[s-1]<=n[s];)s++;if(s>=o)continue;let c=Array.from(n.subarray(a,o),(e,t)=>[e,r[a+t],i[a+t]]).sort((e,t)=>e[0]-t[0]);for(let[e,[t,o,s]]of c.entries())[n[a+e],r[a+e],i[a+e]]=[t,o,s]}return e}function Ot(e){let t=[0],n=new Int32Array(1024),r=new Int32Array(1024),i=new Int32Array(1024),a=0;for(let{mappings:o,files:s,line:c,column:l,names:u,nameCount:d}of e){if(typeof o!=`string`)throw new H(`mappings is not a string`);for(;t.length<=c;)t.push(a);let e=[0,0,0,0,0],f=0,p=0,m=1,h=l;for(let c=0;c<=o.length;c++){let l=c<o.length?Et[o.codePointAt(c)]??255:64;if(l<32){if(p+=l*m,f===5)throw new H(`mappings: a segment of more than 5 fields at ${c}`);e[f++]+=p%2?(1-p)/2:p/2,p=0,m=1;continue}if(l<64){if(p+=(l-32)*m,m*=32,m>2**30)throw new H(`mappings: a value at ${c} runs past 32 bits`);continue}if(l===255)throw new H(`mappings: ${JSON.stringify(o[c])} at ${c} is not a base64 digit`);if(m!==1)throw new H(`mappings: the value before ${c} is cut off`);if(f>0){if(f===2||f===3)throw new H(`mappings: a segment of ${f} fields before ${c}`);let t=f===1?-1:s[e[1]];if(t===void 0)throw new H(`mappings: source ${e[1]} before ${c} is not in sources`);if(e[0]<0)throw new H(`mappings: a negative generated column before ${c}`);a===n.length&&([n,r,i]=[U(n),U(r),U(i)]),n[a]=e[0]+h,r[a]=t,i[a++]=f===5&&e[4]>=0&&e[4]<d?u+e[4]:-1,f=0}l===65&&(t.push(a),e[0]=0,h=0)}}return t.push(a),Dt({starts:Int32Array.from(t),columns:n.slice(0,a),sources:r.slice(0,a),names:i.slice(0,a)})}var kt=new WeakMap,At=e=>kt.get(e),W=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function G(e,t){if(!e)throw new H(t)}function jt(e,t){if(e===void 0)return[];G(Array.isArray(e),`${t} is not an array`);for(let n of e)G(typeof n==`string`||n===null,`${t} holds ${JSON.stringify(n)}`);return e}function Mt(e,t,n,r){let i=e.bySource.get(t);if(i!==void 0)return e.files[i].content??=n,e.files[i].ignored||=r,i;let a=t===null?null:z(t,e.mapPath);return e.files.push({source:t,path:a,package:a===null?null:ot(a),content:n,ignored:r}),t!==null&&e.bySource.set(t,e.files.length-1),e.files.length-1}function Nt(e,t,n,r){G(e.version===3,`version ${JSON.stringify(e.version)} is not 3`),G(e.sourceRoot===void 0||typeof e.sourceRoot==`string`,`sourceRoot is not a string`);let i=jt(e.sources,`sources`),a=jt(e.sourcesContent,`sourcesContent`),o=e.ignoreList??e.x_google_ignoreList??[];G(Array.isArray(o)&&o.every(e=>Number.isInteger(e)&&e>=0&&e<i.length),`ignoreList is not a list of indices into sources`);let s=new Set(o),c=e.sourceRoot?e.sourceRoot.replace(/\/?$/u,`/`):``,l=i.map((e,n)=>Mt(t,e===null?null:c+e,a[n]??null,s.has(n))),u=Array.isArray(e.names)?e.names:[];t.parts.push({mappings:e.mappings,files:l,line:n,column:r,names:t.names.length,nameCount:u.length}),t.names.push(...u)}function Pt(e,t){G(e.version===3,`version ${JSON.stringify(e.version)} is not 3`),G(Array.isArray(e.sections),`sections is not an array`);for(let[n,r]of e.sections.entries()){let{offset:i,map:a}=W(r)?r:{};G(W(i)&&[i.line,i.column].every(e=>Number.isInteger(e)&&e>=0),`sections[${n}].offset is not a line and a column`),G(W(a)&&a.sections===void 0,`sections[${n}].map is not a plain source map`);let o=e.sections[n-1]?.offset;G(!o||o.line<i.line||o.line===i.line&&o.column<=i.column,`sections[${n}] starts before sections[${n-1}]`),Nt(a,t,i.line,i.column)}}function Ft(e,t={}){if(!W(t))throw TypeError(`readSourceMap: options is not an object`);if(t.path!==void 0&&typeof t.path!=`string`)throw TypeError(`readSourceMap: options.path is not a string`);let n=e;if(typeof e==`string`||e instanceof Uint8Array)try{let t=typeof e==`string`?e:new TextDecoder(`utf-8`,{fatal:!0}).decode(e);n=JSON.parse(t.replace(/^\)\]\}'[^\n]*\n/u,``))}catch(e){throw new H(`not JSON: ${e.message}`,{cause:e})}G(W(n),`not a JSON object`);let r={files:[],bySource:new Map,mapPath:t.path,parts:[],names:[]};n.sections===void 0?Nt(n,r,0,0):Pt(n,r);let i={files:r.files};return kt.set(i,{...Ot(r.parts),nameList:r.names}),i}var It=/\r\n?|[\n\u2028\u2029]/gu;function Lt(e){let t=[0];for(let n of e.matchAll(It))t.push(n.index+n[0].length);return t}function Rt(e,t,n,r){let[i,a]=[t,n];for(;i<a;){let t=i+a>>1;e[t]<=r?i=t+1:a=t}return i-1}function K(e,t){let n=Rt(e,0,e.length,t);return[n,t-e[n]]}function zt(e,[t,n]){if(t>=e.starts.length-1)return-1;let r=e.starts[t],i=Rt(e.columns,r,e.starts[t+1],n);return i<r?-1:i}function Bt(e,t,n,r){let i=At(e),a=K(t,n),[o,s]=K(t,r),c=new Map,l=zt(i,a);for(let e=a[0];e<=o&&e<i.starts.length-1;e++){let t=e===a[0]&&l>=0?l:i.starts[e];for(let n=t;n<i.starts[e+1];n++){let t=i.sources[n];if(e===o&&i.columns[n]>=s)break;t>=0&&c.set(t,(c.get(t)??0)+1)}}let[u]=[...c].reduce((e,t)=>t[1]>e[1]?t:e,[-1,0]);return u<0?null:e.files[u]}var q=/\s+/uy,Vt=`
2
+ \r\u2028\u2029`,Ht=/[\n\r\u2028\u2029]/gu,Ut=/[\n\r\u2028\u2029]/u,J=/[\w$\u0080-￿]+/uy,Wt=new Set([`return`,`typeof`,`instanceof`,`in`,`of`,`new`,`delete`,`void`,`throw`,`case`,`default`,`extends`,`do`,`else`,`yield`,`await`]),Gt=new Set([`if`,`while`,`for`,`with`]),Kt=new Set([`break`,`continue`,`debugger`]),qt=new Set([`(`,`[`,"${",`,`,`=`,`:`,`?`,`!`,`~`,`+`,`-`,`*`,`/`,`%`,`&`,`|`,`^`,`<`,`>`]);function Jt(e,t){return e?.type===`word`?t&&[`return`,`yield`].includes(e.value)?!1:Wt.has(e.value)&&![`do`,`else`].includes(e.value):qt.has(e?.value)}function Yt(e){let t=e.at(-1);return t?.type===`word`&&(Gt.has(t.value)||t.value===`await`&&e.at(-2)?.value===`for`)}function Xt(e){return e?e.type===`word`?Wt.has(e.value)||Kt.has(e.value)||e.label===!0:e.value===`)`?e.control:e.value===`}`?!e.object:e.type===`punctuator`&&![`++`,`--`,`]`].includes(e.value):!0}var Zt=(e,t)=>e.startsWith(`\r
3
+ `,t+1)?3:2,Qt=/\\(?:u\{([\da-f]+)\}|u([\da-f]{4})|x([\da-f]{2})|([0-3][0-7]{0,2}|[4-7][0-7]?)|(\r\n|[\n\r\u2028\u2029])|(.))/giu,$t={b:`\b`,f:`\f`,n:`
4
+ `,r:`\r`,t:` `,v:`\v`};function en(e){return e.includes(`\\`)?e.replace(Qt,(e,t,n,r,i,a,o)=>{if(a!==void 0)return``;if(i!==void 0)return String.fromCodePoint(Number.parseInt(i,8));let s=Number.parseInt(t??n??r,16);return Number.isNaN(s)?$t[o]??o:String.fromCodePoint(Math.min(s,1114111))}):e}function tn(e,t){let n=e[t],r=t+1;for(;r<e.length&&e[r]!==n&&!Vt.includes(e[r]);)r+=e[r]===`\\`?Zt(e,r):1;return[e[r]===n?en(e.slice(t+1,r)):null,r+1]}function nn(e,t){let n=t+1,r=!1;for(;n<e.length&&!Vt.includes(e[n])&&(r||e[n]!==`/`);)e[n]===`\\`?n++:e[n]===`[`?r=!0:e[n]===`]`&&(r=!1),n++;return J.lastIndex=n+1,J.test(e)?J.lastIndex:n+1}function rn(e,t,n){for(let r=t;r<e.length;r++)if(e[r]===`\\`)r++;else{if(e[r]==="`")return r+1;if(e[r]===`$`&&e[r+1]===`{`)return n.push(`template`),r+2}return e.length}function an(e){let t=[],n=[],r=[],i=0,a=0;for(;i<e.length;){let o=t.length;if(q.lastIndex=i,q.test(e)&&(i=q.lastIndex),i>=e.length)break;let s=e[i],c=e[i+1];if(J.lastIndex=i,s===`/`&&c===`/`)Ht.lastIndex=i+2,i=Ht.test(e)?Ht.lastIndex-1:e.length;else if(s===`/`&&c===`*`){let t=e.indexOf(`*/`,i+2);i=t<0?e.length:t+2}else if(s===`"`||s===`'`){let[n,r]=tn(e,i);t.push({type:`string`,value:n}),i=r}else if(s==="`"||s===`}`&&n.at(-1)===`template`){s===`}`&&n.pop();let r=n.length,a=rn(e,i+1,n),o=s==="`"&&n.length===r&&e[a-1]==="`";t.push({type:`string`,value:o?en(e.slice(i+1,a-1)):null}),n.length>r&&t.push({type:`punctuator`,value:"${"}),i=a}else if(s===`/`&&Xt(t.at(-1)))i=nn(e,i),t.push({type:`regex`});else if(J.test(e)){let n=Kt.has(t.at(-1)?.value)&&!Ut.test(e.slice(a,i));t.push({type:`word`,value:e.slice(i,J.lastIndex),...n&&{label:n}}),i=J.lastIndex}else{s===`{`&&n.push(Jt(t.at(-1),Ut.test(e.slice(a,i)))?`object`:`block`);let o=s===`}`?n.pop():void 0;s===`(`&&r.push(Yt(t));let l=(s===`+`||s===`-`)&&c===s||s===`=`&&c===`>`?s+c:s;t.push({type:`punctuator`,value:l,...s===`)`&&{control:r.pop()===!0},...s===`}`&&{object:o===`object`}}),i+=l.length}t.length>o&&(a=i)}return t}var on=e=>e?.type===`string`&&e.value!==null,sn=new Set([`type`,`typeof`]),cn=(e,t)=>e[t+1]?.type===`word`&&(e[t+1].value!==`as`||e[t+2]?.type!==`word`||e[t+2].value===`as`);function ln(e,t){let n=!1;for(let r=t+1;r<e.length&&e[r].value!==`}`;r++)if(!(r>t+1&&e[r-1].value!==`,`)){if(!sn.has(e[r].value)||!cn(e,r))return!1;n=!0}return n}function un(e,t){for(let n=t;n<e.length;n++){let{value:r}=e[n];if(r===`;`||n>t&&(r===`import`||r===`export`))return null;if(r===`from`&&on(e[n+1]))return e[n+1].value}return null}function dn(e,t){let[n,r,i]=[e[t].value,e[t+1],e[t+2]],a=n===`import`?`import`:`export-from`;if(n===`import`&&on(r))return{kind:a,specifier:r.value};if(sn.has(r?.value)&&![`,`,`from`].includes(i?.value)||r?.value===`{`&&ln(e,t+1)||n===`export`&&![`{`,`*`].includes(r?.value)||n===`import`&&r?.type!==`word`&&![`{`,`*`].includes(r?.value))return null;let o=un(e,t+1);return o===null?null:{kind:a,specifier:o}}function fn(e,t){let[n,r]=[e[t+2],e[t+3]];if(n?.value!==`)`)return on(n)&&[`)`,`,`].includes(r?.value)?n.value:null}function pn(e,t=new Set){let n=an(e),r=[];for(let[e,i]of n.entries()){if(i.type!==`word`||[`.`,`#`,`function`].includes(n[e-1]?.value)||n[e-1]?.value===`=`&&n[e-3]?.value===`type`&&n[e-4]?.value===`import`)continue;let a=n[e+1]?.value===`(`,o=a?fn(n,e):void 0;if((i.value===`require`||t.has(i.value))&&o!==void 0)r.push({kind:`require`,specifier:o,...i.value!==`require`&&{callee:i.value}});else if(i.value===`import`&&a)o!==void 0&&r.push({kind:`dynamic-import`,specifier:o});else if(i.value===`import`||i.value===`export`){let t=dn(n,e);t&&r.push(t)}}return r}var mn=/^[\w$]*__d\(/gmu,hn=([e,t,n,...r])=>(typeof e==`number`||typeof e==`string`)&&(t===void 0||typeof t==`object`)&&(n===void 0||typeof n==`string`)&&r.length===0;function gn(e){let t=/\);?\s*$/u.exec(e)?.index,n=null,r=t===void 0?-1:e.lastIndexOf(`},`,t);for(;r>=0&&/[\d"]/u.test(e[r+2]);){let i;try{i=JSON.parse(`[${e.slice(r+2,t)}]`)}catch{break}if(!hn(i))break;n=i,r=r>0?e.lastIndexOf(`},`,r-1):-1}return n}function _n(e){let t=/^[^(]*\(\s*(?:function\s*[\w$]*\s*)?\(([^)]*)\)/u.exec(e)?.[1].split(`,`).slice(1,4).map(e=>e.trim().replaceAll(`$`,`\\$`));if(!t?.length)return[];let n=e.matchAll(RegExp(`(?<=[^\\w$.#]|\\.\\.\\.)(?:${t.join(`|`)})\\((\\d+|"(?:[^"\\\\]|\\\\.)*")[,)]`,`gu`));return[...new Set([...n].map(e=>JSON.parse(e[1])))]}function vn(e,t){if(Array.isArray(e))return e;let n=Object.entries(e??{}).filter(([e])=>/^\d+$/u.test(e)).map(([,e])=>e);return n.length>0?n:_n(t)}function yn(e,t){let n=new Map(t.files.map((e,t)=>[e,t])),r=e.flatMap((e,t)=>e.file?[{k:t,at:n.get(e.file)}]:[]);for(let n=0;n<(r[0]?.k??0);n++)e[n].file=t.files[r[0].at-r[0].k+n]??null;for(let[n,{k:i,at:a}]of r.entries()){let o=r[n+1];if(!(o&&o.at-a!==o.k-i))for(let n=i+1;n<(o?.k??e.length);n++)e[n].file=t.files[a+n-i]??null}}function bn(e,t){let n=[...e.matchAll(mn)].map(e=>e.index);if(n.length===0)return null;let r=Lt(e),i=t=>e.slice(r[t],r[t+1]),a=[];for(let[o,s]of n.entries()){let[c]=K(r,s),[l]=K(r,(n[o+1]??e.length)-1),u=gn(i(l));for(;!u&&l>c;)u=gn(i(--l));if(!u)throw Error(`bundleEdges: the Metro module at line ${c+1} ends in no define params`);let d=r[l+1]??e.length;a.push({id:u[0],file:Bt(t,r,s,d),dependencies:vn(u[1],e.slice(s,d))})}yn(a,t);let o=new Map(a.map(e=>[e.id,e])),{edges:s,link:c}=St();for(let{file:e,dependencies:t}of a)for(let n of t)c(e,o.get(n)?.file,`dependency`);return s}var xn=e=>e.path!==null&&![`json`,null].includes(ct(e.path)),Sn=e=>e.path!==null&&ct(e.path)===null;function Cn(e){let t=/^_([A-Za-z]+)\d+$/u.exec(e)?.[1];if(t)return[t,`interopRequireDefault`];let n=/^_(interopRequire(?:Default|Wildcard)|jsx(?:Dev)?Runtime|callSuper)$/u.exec(e)?.[1];return n===`callSuper`?[`getPrototypeOf`,`possibleConstructorReturn`,`interopRequireDefault`]:n?[n]:[]}var wn={jsxRuntime:`react/jsx-runtime`,jsxDevRuntime:`react/jsx-dev-runtime`};function Tn(e){let{sources:t,names:n,nameList:r}=At(e),i=new Map,a=new Map,o=e.files.map(()=>new Set);for(let e=0;e<n.length;e++)n[e]<0||t[e]<0||(a.has(n[e])||a.set(n[e],Cn(r[n[e]]).length>0),a.get(n[e])&&o[t[e]].add(r[n[e]]));for(let[t,n]of o.entries()){if(n.size===0)continue;let r=e.files[t],a=new Set(Array.from((r.content??``).matchAll(/(?:function|var|let|const)\s+(_[A-Za-z]+\d*)\b/gu),e=>e[1])),o=[...n].filter(e=>!a.has(e)&&!a.has(e.replace(/\d+$/u,``))).flatMap(Cn);o.length>0&&i.set(r,o.map(e=>wn[e]??`@babel/runtime/helpers/${e}`))}return i}function En(e,t){let n=new Map;for(let[r,i]of e){let e=n.get(r)??n.set(r,new Map).get(r);for(let n of i)e.set(n,Tt(t,r,n,()=>null))}let r=new Set([...n.values()].flatMap(e=>[...e.values()].map(e=>e.to))),i=(e,n)=>t.byRoot.get(n).find(e=>!r.has(e))??t.byRoot.get(n)[0];return(e,r)=>{let a=n.get(e)?.get(r);return a?.to?a:Tt(t,e,r,i)}}var Dn=e=>/(?:^|\/)__prelude__$/u.test(e.source??``),On=e=>e?.package?.name===`metro-runtime`&&e.package.path===`src/polyfills/require.js`;function kn(e){if(!e.files.some(Dn)&&!On(e.files[0]))return null;if(!e.files.some(e=>e.content!==null&&!Dn(e)&&!On(e)))throw Error("bundleEdges: the Metro map carries no sourcesContent, which its edges are read from; pass the bundle as `code`");let t=vt(e.files),n=e.files[e.files.findIndex(Sn)+1],r=e.files.find(e=>e.package?.name===`metro-runtime`&&e.package.path===`src/modules/asyncRequire.js`),i=new Map(e.files.filter(e=>e.content!==null&&xn(e)).map(e=>[e,pn(e.content)])),a=Tn(e),o=En([...[...i].map(([e,t])=>[e,t.flatMap(({specifier:e})=>e===null?[]:[e])]),...a],t),{edges:s,add:c,link:l}=St();for(let t of e.files){Sn(t)&&l(t,n,`dependency`);for(let{kind:e,specifier:n}of i.get(t)??[]){let i=n===null?{to:null}:o(t,n);i.to!==t&&c(t,`${e}\0${JSON.stringify(n)}`,{from:t,kind:e,specifier:n,...i}),e===`dynamic-import`&&l(t,r,`dependency`)}for(let e of a.get(t)??[])l(t,o(t,e).to,`dependency`)}return s}var An=(e,t)=>t==null?kn(e):bn(t,e);function jn(e,t){let n=An(e,t);if(!n)throw Error(`bundleEdges: not a Metro ${t==null?`map`:`bundle`}; edges-lite.js reads only those, edges.js reads others`);return{edges:n}}function Mn(e){let t=JSON.parse(e.replace(/^\)\]\}'[^\n]*\n/u,``)),n=Ft(t),r=t.sections?t.sections.reduce((e,t)=>e+(t.map.names?.length??0),0):t.names?.length??null;return{json:{version:t.version,file:t.file,sourceRoot:t.sourceRoot},map:n,namesCount:r}}function Nn(e){if(e.map)return e.map.files.flatMap(e=>e.source===null?[]:[[e.source,e.content]]);let t=e.json?.sourcesContent??[];return(e.json?.sources??[]).map((e,n)=>[e,t[n]??null])}function Pn(e,t){let n=new Map;for(let{from:r,to:i,specifier:a}of t(e).edges){if(r.source===null||i?.source==null||i.source===r.source)continue;let e=typeof a==`string`?[r.source,i.source,a]:[r.source,i.source];n.set(e.join(`\0`),e)}return[...n.values()]}function Fn(e){try{return jn(e)}catch{return{edges:[]}}}var In=Object.freeze([]);function Ln(e){return e?.edges?e.edges:e?.map?(e.edges=Pn(e.map,Fn),e.edges):In}var Rn=new WeakMap,zn=new WeakMap;function Bn(e){let t=Ln(e);if(!Rn.has(t)){let e=new Map;for(let[n,r]of t)e.has(n)||e.set(n,new Set),e.get(n).add(r);Rn.set(t,e)}return Rn.get(t)}function Vn(e){let t=Ln(e);if(!zn.has(t)){let e=new Map;for(let[n,r,i]of t)i!==void 0&&(e.has(n)||e.set(n,new Map),e.get(n).set(i,r));zn.set(t,e)}return zn.get(t)}var Hn=new WeakMap,Un=new WeakMap,Wn=new WeakMap,Gn=new WeakMap,Kn=new WeakMap,Y=new WeakMap;function X(e){if(e?.metadataOnly)return new Map;let t=e?.bundle??e?.json;if(t&&Hn.has(t))return Hn.get(t);let n=new Map;if(!e)return n;if(e.kind===`stasis`){if(!e.bundle)return n;let t=e.bundle.formats;for(let[r,i]of e.bundle.sources)typeof i==`string`&&(N.isResourceFormat(t?.get(r))||n.set(r,i))}else if(e.kind===`sourcemap`)for(let[t,r]of Nn(e))typeof r==`string`&&n.set(t,r);return t&&Hn.set(t,n),n}function qn(e){let t=1;for(let n=e.indexOf(`
5
+ `);n!==-1;n=e.indexOf(`
6
+ `,n+1))t++;return t}var Jn=new WeakMap;function Yn(e){let t=Jn.get(e);if(!t){let n=[...e.keys()].toSorted();t={paths:n,numbers:new Map(n.map((e,t)=>[e,t+1]))},Jn.set(e,t)}return t}function Xn(e,t){let n=Array.isArray(t)?t:[];return{integrity:e.integrity,kind:`sourcemap`,size:e.size,json:{version:3,sources:n.map(([e])=>e),sourcesContent:n.map(([,,e])=>typeof e==`string`?e:null)},fileSizes:new Map(n.map(([e,t])=>[e,t])),npmBinaries:new Map(n.filter(([,,e,t])=>typeof e!=`string`&&typeof t==`string`).map(([e,t,,n])=>[e,{size:t,digest:n}]))}}function Zn(e){let t=e?.bundle??e?.json;if(t&&Un.has(t))return Un.get(t);let n=new Map(X(e));for(let[t,r]of e?.npmBinaries??[])n.set(t,{format:`digest`,...r});if(e?.kind===`stasis`&&e.bundle){let t=e.bundle.formats;for(let[r,i]of e.bundle.sources){if(typeof i!=`string`)continue;let e=t?.get(r);e===`resource`?n.set(r,i):e===`resource:base64`&&n.set(r,{format:`base64`,data:i})}}return t&&Un.set(t,n),n}var Qn=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`;function $n(e){let t=e.endsWith(`=`);if(t?e.length%4!=0||e.at(-3)===`=`:e.length%4==1)return null;let n=t?e.slice(0,e.endsWith(`==`)?-2:-1):e;if(/[^A-Za-z0-9+/]/u.test(n))return null;let r=n.length%4;return r>1&&Qn.indexOf(n.at(-1))&(r===2?15:3)?null:Math.floor(n.length*3/4)}function er(e){return typeof e==`string`?t(e):e?.format===`digest`?e.size:e?.format===`base64`?$n(e.data):null}function Z(e){if(e?.fileSizes)return e.fileSizes;let t=e?.bundle??e?.json;if(t&&Wn.has(t))return Wn.get(t);let n=new Map,r=Zn(e),i=e?.kind===`stasis`?e.bundle?.sources.keys():e&&Nn(e).map(([e])=>e);for(let e of i??[])n.set(e,er(r.get(e)));return t&&Wn.set(t,n),n}function tr(e){if(e?.metadataOnly)return e.unsizedFiles??new Set;let t=Z(e);if(Y.has(t))return Y.get(t);let n=new Set;for(let r of Zn(e).keys())t.get(r)===null&&n.add(r);return Y.set(t,n),n}function nr(e){let t=Z(e);if(Kn.has(t))return Kn.get(t);let n=tr(e),r=e?.kind===`stasis`?e.bundle?.formats:null,i=new Map;for(let[a,o]of t)o===null&&!n.has(a)||i.set(a,N.isResourceFormat(r?.get(a))||e?.npmBinaries?.has(a)?`resource`:`source`);return Kn.set(t,i),i}function rr(e){let t=Z(e),n=e?.kind===`stasis`?e.bundle?.formats:null;if(!n||n.size===0)return t;if(Gn.has(t))return Gn.get(t);let r=new Map;for(let[e,i]of t)N.isResourceFormat(n.get(e))||r.set(e,i);return Gn.set(t,r),r}var ir=new WeakMap;function ar(e){if(e?.kind!==`stasis`||!e.bundle?.modules)return null;if(ir.has(e.bundle))return ir.get(e.bundle);let t=new Map;for(let[n,r]of e.bundle.modules)for(let e of Object.keys(r.files))t.set(n===`.`?e:`${n}/${e}`,n);return ir.set(e.bundle,t),t}function or(e,t=null,n=(e,t)=>t.name){let r=new Map;if(e?.kind!==`stasis`||!e.bundle?.modules)return r;let i=t===null?null:ar(e),a=t===null?null:new Set([...t].map(e=>i?.get(e)));for(let[t,i]of e.bundle.modules){if(a&&!a.has(t)||!t.includes(`node_modules`)||!i?.name||typeof i.version!=`string`||!i.version)continue;let e=n(t,i),o=r.get(e);o||(o=new Set,r.set(e,o)),o.add(i.version)}return r}var sr=Object.freeze({javascript:`JavaScript`,jsx:`JSX`,typescript:`TypeScript`,tsx:`TSX`,json:`JSON`,css:`CSS`,markup:`HTML`,yaml:`YAML`,bash:`Shell`,markdown:`Markdown`,solidity:`Solidity`,php:`PHP`,rust:`Rust`,ruby:`Ruby`,java:`Java`,cpp:`C++`,c:`C`,objectivec:`Objective-C`,python:`Python`,go:`Go`,kotlin:`Kotlin`,swift:`Swift`,dart:`Dart`,sql:`SQL`,lua:`Lua`,csharp:`C#`,scala:`Scala`,vue:`Vue`,svelte:`Svelte`}),cr=Object.freeze({py:`python`,pyw:`python`,go:`go`,kt:`kotlin`,kts:`kotlin`,swift:`swift`,dart:`dart`,sql:`sql`,lua:`lua`,cs:`csharp`,scala:`scala`,sc:`scala`,vue:`vue`,svelte:`svelte`});function lr(e){let t=typeof e==`string`?e.slice(e.lastIndexOf(`/`)+1):``,n=t.lastIndexOf(`.`),r=n>0?t.slice(n+1).trim().toLowerCase():``,i=qe(e)??cr[r];return i?{key:i,label:sr[i]??i}:r?{key:`extension:${r}`,label:`.${r}`}:{key:`other`,label:`Other`}}function ur(e,t){let n=new Map,r=0,i=0;for(let[a,o]of e){let e=lr(a),s=n.get(e.key)??{...e,files:0,lines:0,bytes:0};s.files++,s.lines+=o,s.bytes+=t.get(a)??0,n.set(e.key,s),i+=o,r+=t.get(a)??0}return{files:e.size,lines:i,bytes:r,languages:[...n.values()].toSorted((e,t)=>t.lines-e.lines||e.label.localeCompare(t.label))}}var dr=6,Q=new WeakMap,fr=new Set([`terminal`,`code`,`search`,`compare`]);function pr(e,t=null){return!!t||fr.has(e)}var mr=/^sha512-[A-Za-z0-9+/]{86}==$/u;function hr(t){if(t.fileHashes)return Promise.resolve(t.fileHashes);if(Q.has(t))return Q.get(t);let n=(async()=>{let n=[...X(t)],r=new Map;for(let t=0;t<n.length;t+=32){let i=await Promise.all(n.slice(t,t+32).map(async([t,n])=>[t,await e(n)]));for(let[e,t]of i)r.set(e,t)}return t.fileHashes=r,r})();return Q.set(t,n),n.catch(()=>Q.delete(t)),n}function gr(e){if(typeof e!=`string`)return 0;let t=/\S/gu,n=/[\r\n]/gu,r=0;for(;t.test(e)&&(r++,n.lastIndex=t.lastIndex,n.test(e));)t.lastIndex=n.lastIndex;return r}function _r(e){return e.lineCounts??=new Map([...X(e)].map(([e,t])=>[e,gr(t)]))}function $(e){return e instanceof Map?Object.fromEntries([...e].map(([e,t])=>[e,$(t)])):e}async function vr(e){let n=await hr(e),r=Z(e),i=_r(e),a={version:dr,integrity:e.integrity,kind:e.kind,size:e.size,codeStats:ur(i,r),files:[...r].map(([e,t])=>[e,t,n.get(e)??null,i.get(e)??null])},o=tr(e);if(o.size>0&&(a.unsized=[...o]),e.kind===`sourcemap`){let{version:n,file:r,sourceRoot:i,names:o}=e.json,s=Nn(e);a.json={version:n,file:r,sourceRoot:i,sources:s.map(([e])=>e)},a.sourceSizes=s.map(([,e])=>typeof e==`string`?t(e):null),a.namesCount=e.namesCount??o?.length??null;let c=new Map(a.files.map(([e],t)=>[e,t]));a.edges=Ln(e).map(([e,t,...n])=>[c.get(e),c.get(t),...n])}else{let t=e.bundle,n={version:t.version,config:t.config,repo:t.repo,package:t.package,formats:$(t.formats),imports:$(t.imports),reason:t.reason,executable:[...t.executable]};if(t.version===0)n.sources=Object.fromEntries([...r.keys()].map(e=>[e,null]));else{let e={},r={};for(let[n,i]of t.modules){let t=n.split(`/`).includes(`node_modules`)?e:r;Object.defineProperty(t,n,{enumerable:!0,value:{name:i.name,version:i.version,ecosystem:i.ecosystem,repo:i.repo,files:Object.fromEntries(Object.keys(i.files).map(e=>[e,null]))}})}n.modules=e,t.config.scope===`full`&&(n.sources=r,n.entries=[...t.entries])}a.bundle=n}return a}function yr(e,t){if(![1,2,3,4,5,dr].includes(e?.version)||e.integrity!==t||![`stasis`,`sourcemap`].includes(e.kind)||!Number.isSafeInteger(e.size)||e.size<0||!Array.isArray(e.files))throw Error(`Invalid bundle metadata`);let n=e.version!==dr,r=e.version===1,i=new Map,a=new Map,o=new Map;for(let t of e.files){if(!Array.isArray(t)||t.length!==4&&!(r&&t.length===3))throw Error(`Invalid bundle metadata file`);let[e,n,s,c]=t;if(typeof e!=`string`||a.has(e)||n!==null&&(!Number.isSafeInteger(n)||n<0)||s!==null&&(typeof s!=`string`||!mr.test(s))||n===null&&s!==null||r&&n!==null&&s===null||c!=null&&(!Number.isSafeInteger(c)||c<0))throw Error(`Invalid bundle metadata file`);a.set(e,n),s!==null&&i.set(e,s),c!=null&&o.set(e,c)}let s=new Set(e.unsized??[]);if(e.unsized!==void 0&&(r||!Array.isArray(e.unsized)||s.size!==e.unsized.length)||[...s].some(e=>typeof e!=`string`||!a.has(e)||a.get(e)!==null))throw Error(`Invalid bundle metadata`);let c={integrity:t,kind:e.kind,size:e.size,metadataOnly:!0,fileSizes:a,fileHashes:i,lineCounts:o,unsizedFiles:s,stale:n};if(e.kind===`stasis`){c.bundle=N.fromJSON(e.bundle);let t=c.bundle.sources;if(t.size!==a.size||[...t.keys()].some(e=>!a.has(e)))throw Error(`Invalid bundle metadata inventory`);let n=c.bundle.formats;if(!r&&[...a].some(([e,t])=>i.has(e)!==(t!==null&&!N.isResourceFormat(n.get(e))))||[...s].some(e=>n.get(e)!==`resource:base64`))throw Error(`Invalid bundle metadata inventory`)}else{if(!e.json||typeof e.json!=`object`||![null,void 0].includes(e.namesCount)&&(!Number.isSafeInteger(e.namesCount)||e.namesCount<0))throw Error(`Invalid sourcemap metadata`);if(!Array.isArray(e.json.sources)||e.json.sources.some(e=>!a.has(e))||!Array.isArray(e.sourceSizes)||e.sourceSizes.length!==e.json.sources.length||e.sourceSizes.some(e=>e!==null&&(!Number.isSafeInteger(e)||e<0))||[...a].some(([e,t])=>i.has(e)!==(t!==null))||s.size>0)throw Error(`Invalid sourcemap inventory`);c.json=e.json,c.sourceSizes=e.sourceSizes,c.namesCount=e.namesCount,e.edges!==void 0&&(c.edges=br(e.edges,e.files))}if(e.codeStats===void 0)c.codeStats=ur(o,a);else{let t=e.codeStats,n=e=>Number.isSafeInteger(e)&&e>=0;if(!t||![t.files,t.lines,t.bytes].every(n)||!Array.isArray(t.languages)||t.languages.some(e=>!e||typeof e.key!=`string`||typeof e.label!=`string`||![e.files,e.lines,e.bytes].every(n)))throw Error(`Invalid bundle code stats`);c.codeStats=t}return c}function br(e,t){if(!Array.isArray(e))throw Error(`Invalid sourcemap edges`);return e.map(e=>{if(!Array.isArray(e)||![2,3].includes(e.length)||e[0]===e[1]||e.length===3&&typeof e[2]!=`string`||e.slice(0,2).some(e=>!Number.isSafeInteger(e)||e<0||e>=t.length))throw Error(`Invalid sourcemap edges`);return[t[e[0]][0],t[e[1]][0],...e.slice(2)]})}function xr(e,{integrity:t,kind:n,size:r}){if(n===`stasis`)return{integrity:t,kind:n,size:r,bundle:N.parse(e)};if(n!==`sourcemap`)throw Error(`Unsupported bundle format`);return{integrity:t,kind:n,size:r,...Mn(e)}}export{Re as a,N as b,qe as c,Bn as d,Vn as e,X as f,qn as g,Yn as h,Xn as i,Zn as j,er as k,Z as l,nr as m,rr as n,ar as o,or as p,ur as q,pr as r,hr as s,gr as t,_r as u,vr as v,yr as w,xr as x};
@@ -0,0 +1,3 @@
1
+ import{a as e}from"./chunk-QB4CBOX2.js";import{b as t,c as n,e as r,f as i,g as a}from"./chunk-NOZJULWS.js";import{i as o}from"./chunk-BC2UCLFJ.js";import{J as s}from"./chunk-SXV2T5C4.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 k(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 ee(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 A=3145728,j=new Set([`/api/admin/reports`,`/api/admin/bundles`,`/api/admin/deduplication`]);async function M(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 Error(`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 N(e,t,n){let r=null;if(e!==`/api/admin/deduplication`&&t.body.size>A){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<=A&&(r=s)}let i=await M(t,n);return i instanceof Response?i:r==null||i.body.size<=A?await n(e,i):await F(e,i,n,r)}var P=3;async function F(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(P,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 I(e){await e.json().then(e=>e?.error,()=>null)===`view-only`&&globalThis.document?.dispatchEvent(new CustomEvent(`managed-view-only`))}async function L(e,n){if(n?.signal?.throwIfAborted(),E)return ee(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())&&I(a.clone()),a}return n?.method===`POST`&&j.has(e)&&n.body instanceof Blob?await N(e,n,i):await i(e,n)}var R=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 z(e){R.setSession(e)}function B(e){return R.setReportCatalog(e)}function V(){R.reset()}async function H(e,t=null,n={}){let r;try{r=await L(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 U({fallback:e=null,sent:r}={}){let i=t()||O()!==null?void 0:await r;if(i===null)return null;let a=W(i);if(a!==void 0)return a;let o;try{let r=t(),i=await L(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=W(o);return s===void 0?e:s}function W(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 G(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 te(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 K({fallback:e=[],signal:r,onRevision:i}={}){let a=t(),o=a?await H(n(a),null,{signal:r}):null,s=a?{teams:o?.team?[o.team]:[]}:await H(`/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}:{},...G(e.app)?{app:G(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:te(e.commitInfo)})):[]}))):s==null?[]:e}function q(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 J(e){return s(e?.data)===null||typeof e.repo?.directory!=`string`||e.repo.github!==null&&typeof e.repo.github!=`string`||q(e)===null?null:{data:e.data,repo:e.repo,...e.links?{links:e.links}:{}}}async function Y(e,{signal:t}={}){return J(await H(`/api/reports/${encodeURIComponent(e)}`,null,{signal:t}))}async function X(e,{signal:t}={}){let n=[...new Set(e)];if(n.length===0)return[];let r=await H(`/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=J(e);if(!t||!n.includes(e.id)||i.has(e.id))return null;i.set(e.id,t)}let a=q(r);return a===null?null:e.map(e=>({...i.get(e),...a.length>0?{links:a}:{}}))}async function Z(e,{signal:t,reportId:n=null}={}){let r=n===null?``:`?reportId=${encodeURIComponent(n)}`,i=await H(`/api/teams/${encodeURIComponent(e)}/reports${r}`,null,{signal:t});if(!Array.isArray(i?.reports))return null;let a=[],o=new Set;for(let e of i.reports){let t=J(e);if(!t||typeof e.id!=`string`||typeof e.filename!=`string`||o.has(e.id))return null;o.add(e.id),a.push({id:e.id,filename:e.filename,...t})}let s=q(i);return s===null?null:(Object.defineProperty(a,"links",{value:s}),a)}function Q(e){return e?`?team=${encodeURIComponent(e)}`:``}async function ne(e,{reportId:t,...n}={}){let r=t==null?``:`?reportId=${encodeURIComponent(t)}`,{reports:i,entries:a,comments:o,issues:s={}}=await H(`/api/teams/${encodeURIComponent(e)}/annotations${r}`,null,n)??{};if(!i||typeof i!=`object`||Array.isArray(i)||!a||typeof a!=`object`||Array.isArray(a)||!Array.isArray(o)||!s||typeof s!=`object`||Array.isArray(s)||Object.values(i).some(e=>!Array.isArray(e)||e.some(e=>typeof e!=`string`))||o.some(e=>!e||typeof e.findingId!=`string`))return null;let c=new Map;for(let[e,t]of o.entries()){let n=t.findingId,r=c.get(n)??[];r.push(e),c.set(n,r)}let l=new Map,u=new Map;return e=>{if(!Object.hasOwn(i,e))return null;if(u.has(e))return u.get(e);let t=JSON.stringify(i[e]),n=l.get(t);if(!n){let r=[...new Set(i[e])],u=r.flatMap(e=>c.get(e)??[]);n={entries:Object.fromEntries(r.filter(e=>Object.hasOwn(a,e)).map(e=>[e,a[e]])),comments:u.toSorted((e,t)=>e-t).map(e=>o[e]),issues:Object.fromEntries(r.filter(e=>Object.hasOwn(s,e)).map(e=>[e,s[e]]))},l.set(t,n)}return u.set(e,n),n}}async function re(e,t,n){let r=(await H(`/api/reports/${encodeURIComponent(e)}/triage${Q(t)}`,null,n))?.entries;return typeof r==`object`&&r&&!Array.isArray(r)?r:null}async function ie(e,n,r=null){if(t())return[];let i=r===null?``:`?reportId=${encodeURIComponent(r)}`,a=await H(`/api/teams/${encodeURIComponent(e)}/fixes${i}`,null,{signal:n});return Array.isArray(a?.fixes)?a.fixes:null}async function ae(e,t,n){let r=await H(`/api/reports/${encodeURIComponent(e)}/comments${Q(t)}`,null,n);return Array.isArray(r?.comments)?r.comments:null}async function oe(e,{findingId:t,body:n,commentId:r=null,version:i},a,o){let s=r==null?``:`/${encodeURIComponent(r)}`;try{let c=await L(`/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 $(e,t,n,r,i){try{return(await L(`/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 se(e,t,n,r){try{return(await L(`/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 ce(e){e&&(location.href=e)}async function le(e){if(t()){location.href=`/`;return}try{await L(`/api/auth/logout`,{method:`POST`,credentials:`same-origin`,headers:e?{"x-csrf-token":e}:{}})}catch{}location.reload()}async function ue(e,t){let n=await L(`/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 de(e){try{await L(`/api/auth/view-as`,{method:`DELETE`,credentials:`same-origin`,headers:e?{"x-csrf-token":e}:{}})}catch{}location.assign(o[`admin-users`])}async function fe(e){let t=await L(`/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 pe(e,t,{id:n,revoke:r=!1,dependencies:i=!1,security:a=!1}={}){let o=n?`/${encodeURIComponent(n)}`:``,s=await L(`/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 me(e,t){let n=await L(`/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,k as c,L as d,R as e,z as f,B as g,V as h,U as i,K as j,Y as k,X as l,Z as m,Q as n,ne as o,re as p,ie as q,ae as r,oe as s,$ as t,se as u,ce as v,le as w,ue as x,de as y,fe as z,pe as A,me as B};
@@ -0,0 +1,7 @@
1
+ import{a as e}from"./chunk-TUII34K2.js";var t=`/api/config`,n=`http://127.0.0.1:3123/`;function r(e){if(typeof e!=`string`||!e.trim())return null;try{let t=new URL(e);return![`http:`,`https:`].includes(t.protocol)||t.username||t.password||t.search||t.hash?null:(t.pathname=t.pathname.replace(/\/+$/u,``)+`/`,t.href)}catch{return null}}var i=`deepview.sync.serverInfo`,a=`deepview.sync.standaloneProbe`;function o(){try{return localStorage.getItem(a)===`1`}catch{return!1}}function s(){try{localStorage.setItem(a,`1`)}catch{}}function c(e){return e===`managed+e2e`||e===`e2e+managed`}function l(e,t){return(e===`managed`||c(e))&&/^\/(?:team|manage|npm|my|repo)(?:\/|$)/u.test(t)}function u(e,t=null){return t&&(c(e)||e===t)?t:e===`managed`||e===`managed+e2e`?`managed`:`e2e`}function d(e,t){return e&&c(e.mode)&&t.mode===`e2e`?{...e,githubNewIssueLabels:t.githubNewIssueLabels??``,...t.deepviewScanServer?{deepviewScanServer:t.deepviewScanServer}:{}}:t}function f(e){if(typeof e!=`object`||!e)return null;let t=e.mode;if(t!==`e2e`&&t!==`managed`&&t!==`managed+e2e`&&t!==`e2e+managed`)return null;let n=null,i=e.managed;if(typeof i==`object`&&i){let e=i.loginPath,t=i.cookieName;typeof e==`string`&&typeof t==`string`&&(n={loginPath:e,cookieName:t},i.allowShare===!0&&(n.allowShare=!0))}let a=t===`managed`?null:r(e.deepviewScanServer),o=e.githubNewIssueLabels;return{mode:t,managed:n,...a?{deepviewScanServer:a}:{},...typeof o==`string`&&o.length<=4096?{githubNewIssueLabels:o}:{}}}async function p(){try{let e=await fetch(t,{credentials:`same-origin`,cache:`no-store`,headers:{accept:`application/json`}});if(e.status===404)return`standalone`;if(!e.ok)return null;let n=await e.json(),r=f(n);return r&&n.session!==void 0?{...r,session:n.session}:r}catch{return null}}async function m(e,t=3e3){let n;try{return await Promise.race([e,new Promise(e=>{n=setTimeout(()=>e(null),t)})])}catch{return null}finally{clearTimeout(n)}}function h(){try{let e=localStorage.getItem(i);if(e==null)return null;let t=f(JSON.parse(e));return t?{mode:t.mode,managed:t.managed}:null}catch{return null}}function g(e){try{localStorage.setItem(i,JSON.stringify({mode:e.mode,managed:e.managed})),localStorage.removeItem(a)}catch{}}var _=`deepview.objstore-presence.`;function v(e){return _+e}function y(e){try{let t=localStorage.getItem(v(e));if(!t)return null;let n=JSON.parse(t);return!n||typeof n!=`object`?null:{names:n.names&&typeof n.names==`object`?n.names:{},bundles:n.bundles&&typeof n.bundles==`object`?n.bundles:{},bundleNames:n.bundleNames&&typeof n.bundleNames==`object`?n.bundleNames:{},baselines:b(n.baselines,n.localVersions)}}catch{return null}}function b(e,t){let n={};if(t&&typeof t==`object`)for(let[e,r]of Object.entries(t))Number.isSafeInteger(r)&&r>=0&&(n[e]={version:r,incarnation:null,synced:!0,hash:null});if(e&&typeof e==`object`)for(let[t,r]of Object.entries(e))!r||typeof r!=`object`||!Number.isSafeInteger(r.version)||r.version<0||r.incarnation!=null&&typeof r.incarnation!=`string`||(n[t]={version:r.version,incarnation:r.incarnation??null,synced:r.synced===!0,hash:typeof r.hash==`string`?r.hash:null});return n}function x(e,t,n,r){let i=y(e),a=Object.entries((t===`bundle`?i?.bundles:i?.names)??{}).find(([,e])=>e===n)?.[0],o=i?.baselines?.[a];return{synced:a!==void 0&&(t===`bundle`||o?.synced===!0&&o.hash===r),cached:!0}}var S=`deepview-objstore.v1.put`,C=`deepview-objstore.v1.delete`,w=`deepview-objstore.v1.fetch`,T=`deepview-objstore.v1.fetch-rest`,E=`deepview-objstore.v1.put-rest`,D=`deepview-objstore.v1.delete-rest`;function O(e){return e==null?``:String(e)}function k(e){return e??``}function A(t,n){return e([S,t.workspaceTag,t.resourceTag,O(t.prevVersion),k(t.prevIncarnation),t.contentHash,String(t.expectedLength),n].join(`
2
+ `))}function j(t,n){return e([C,t.workspaceTag,t.resourceTag,O(t.prevVersion),k(t.prevIncarnation),n].join(`
3
+ `))}function M(t,n,r){return e([w,t,n,r].join(`
4
+ `))}async function N(e,t){return new Uint8Array(await crypto.subtle.sign({name:`Ed25519`},e,t)).toBase64({alphabet:`base64url`,omitPadding:!0})}function P(e,t,n){return N(e,A(t,n))}function F(e,t,n){return N(e,j(t,n))}function I(e,t,n,r){return N(e,M(t,n,r))}function L(t,n,r){return e([T,t,n,String(r)].join(`
5
+ `))}function R(e,t,n,r){return N(e,L(t,n,r))}function z(t,n){return e([E,t.workspaceTag,t.resourceTag,O(t.prevVersion),k(t.prevIncarnation),t.contentHash,String(t.expectedLength),String(n)].join(`
6
+ `))}function B(e,t,n){return N(e,z(t,n))}function V(t,n){return e([D,t.workspaceTag,t.resourceTag,O(t.prevVersion),k(t.prevIncarnation),String(n)].join(`
7
+ `))}function H(e,t,n){return N(e,V(t,n))}async function U(e){let t=await crypto.subtle.digest(`SHA-256`,e);return new Uint8Array(t).toBase64({alphabet:`base64url`,omitPadding:!0})}export{n as a,r as b,o as c,s as d,c as e,l as f,u as g,d as h,f as i,p as j,m as k,h as l,g as m,v as n,y as o,x as p,P as q,F as r,I as s,R as t,B as u,H as v,U as w};
@@ -1 +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}from"./chunk-5DHL5NG3.js";import{j as u}from"./chunk-NPW52BM2.js";import"./chunk-PXK7EU4V.js";import{a as d,c as f}from"./chunk-JCIIBLKR.js";import{l as p,p as m,q as h,u as g}from"./chunk-WI7Z5A2T.js";import{b as _}from"./chunk-IYPY47MC.js";import"./chunk-SXV2T5C4.js";import"./chunk-TUII34K2.js";import"./chunk-OOJM4CTU.js";function v(e){if(typeof e!=`string`)throw TypeError(`a text must be a string, not ${typeof e}`);if(!e.isWellFormed())throw TypeError(`a text must be a well-formed string`);return{proven:!1,reason:`unsupported`,at:null}}var y=e=>e.subarray(0,8e3).includes(0),b=(e,t)=>(e+Math.imul(t,97)>>>0)%107927,x=e=>Uint8Array.from({length:256},(t,n)=>Number(n===10||e.includes(String.fromCodePoint(n)))),S=x(``),C=x(`,;={}`);function w(e,t=S){let n=!y(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(b(a,o),s),s=0,a=0,o=0)}s>0&&i(b(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 T(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 E(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 ee(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?E(s,c,n*o):T(s,c);return Math.trunc(l*6e4/o)}var D=/^[\w-]{6,}$/u,O=/[\dA-Z]/u,te=/^(?:\.[\w-]+)+$/u,ne=/^[\w-]{8,32}$/u;function k(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&&ne.test(a)&&te.test(i)&&/[A-Za-z]/u.test(a)&&O.test(a)&&t.push([e.slice(0,n),a,i])}return t}var re=e=>e.replaceAll(/\d/gu,`0`).replaceAll(/[a-z]/gu,`a`).replaceAll(/[A-Z]/gu,`A`);function ie(e,t){let n=k(t);for(let[t,r,i]of k(e)){let e=n.find(e=>e[2]===i);if(e&&e[1]!==r)return e[0]===t&&re(e[1])!==re(r)}return!1}function ae(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 oe(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&&D.test(i)&&D.test(a)&&(O.test(i)||O.test(a))}function se({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,ae(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)oe(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&&ie(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 ce(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 A=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}},le=new Set([`file`,`contiguous-file`]),ue=new Set([`fifo`,`character-device`,`block-device`]),de=/(?:^|\/)\.{0,2}(?:\/|$)/u;function fe(e){if(!Number.isInteger(e)||e<0||e>4095)throw RangeError(`a mode must be an integer from 0 to 0o7777, not ${e}`)}function pe(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===``:de.test(e))throw new A(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 A(`a name must be well-formed Unicode`,e,n)}}function me(e,t,n){if(typeof e!=`string`||e===``)throw new A(`a link must name its target`,t,n);if(!e.isWellFormed())throw new A(`a link target must be well-formed Unicode`,t,n);return e}function he(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 j=e=>typeof e==`string`?u(e):e;function ge(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(pe(r,i,t,n),a!==void 0&&fe(a),le.has(i))return{path:r,type:`file`,mode:a??420,data:he(s)};if(i===`symlink`||i===`hardlink`)return{path:r,type:i,target:me(o,r,t)};if(i===`directory`)return{path:r,type:i};throw ue.has(i)?new A(`a ${i} is neither a file nor a link`,r,t):TypeError(`${JSON.stringify(i)} is not an entry type`)}function M(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:ce(j(e.data),j(t.data)):!1}function _e(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 A(`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 A(`a hard link must name a file or a link in the tree`,e.path,n);return{...i,path:e.path}}function N(e,t,n){let r=new Map;for(let i of e){let e=ge(i,t,n);if(e.type!==`directory`||e.path!==`.`){if(r.has(e.path))throw new A(`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 A(`a path lies under a ${n.type===`symlink`?`link`:`file`}`,e,t)}a.type===`hardlink`?i.set(e,_e(a,r,t)):a.type!==`directory`&&i.set(e,a)}return i}var ve=100,ye=4,P=e=>e.slice(e.lastIndexOf(`/`)+1);function F(t,n){if(t.type===`symlink`)return`l${t.target}`;let r=n(t);return`f${r.length}:${e(r)}`}function be({sources:e,dests:t,sourceNames:n,destNames:r,used:i,record:a,bytes:o}){let s=Map.groupBy(e.keys(),t=>F(e[t],o));for(let c=0;c<t.length;c++){let l=-1,u=ve;for(let a of s.get(F(t[c],o))??[])if(!i.has(a)&&M(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 xe=new Map([[`.ts`,`.js`],[`.mts`,`.mjs`],[`.cts`,`.cjs`],[`.tsx`,`.jsx`]]),Se=new Map([...[`.js`,`.mjs`,`.cjs`,`.jsx`,`.ts`,`.mts`,`.cts`,`.tsx`].map(e=>[e,`script`]),...[`.css`,`.scss`,`.sass`,`.less`].map(e=>[e,`style`])]);function I(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 L(e){let{dirs:t,stem:n,extension:r}=I(e);return JSON.stringify([t.map(e=>e===`lib`||e===`src`?null:e),n,xe.get(r)??r])}function Ce(e){let{dirs:t,stem:n,extension:r}=I(e),i=[n,Se.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 R=(e,t)=>Math.max(t,e+Math.trunc((6e4-e)/2));function z({pairs:e,used:t,scoreOf:n},{remaining:r,open:i},{s:a,d:o,score:s},c){let l=R(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 we(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=>L(i[e].path)),d=t.open.filter(e=>a[e].type===`file`).flatMap(e=>(u.get(L(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&&z(e,t,i,r))&&c(i.d,i.s,i.score)}function Te(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=Ce(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&&z(e,t,s,r)||c(o,i,s.score)}}function Ee(e,t,n){let r=H(e),i=t<6e4&&r.remaining.length*r.open.length<=n*n;we(e,r,i,t),Te(e,r,i,t)}function B(e,t){let n=new Map;for(let r of t)n.set(e[r],n.has(e[r])?-1:r);return n}function De({sourceNames:e,destNames:t,record:n,scoreOf:r},{remaining:i,open:a},o){let s=B(t,a),c=B(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 V=(e,t)=>t.score-e.score||t.nameScore-e.nameScore;function Oe(e,t){if(e.length<ye){e.push(t);return}let n=0;for(let t=1;t<e.length;t++)V(e[t],e[n])>0&&(n=t);V(e[n],t)>0&&(e[n]=t)}function ke({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)Oe(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&&R(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(V)){if(a<c)break;f(a),!n.has(e)&&!r.has(t)&&i(e,t,a)}f(-1/0)}var H=({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()}),U=e=>e+Math.trunc(.5*(6e4-e));function W(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,j(e.data)).get(e):null,d=e=>s.get(e)??s.set(e,w(e)).get(e),f=e=>l.get(e)??l.set(e,w(e,C)).get(e),p={sources:e,dests:t,pairs:a,used:o,sourceNames:e.map(e=>P(e.path)),destNames:t.map(e=>P(e.path)),record(e,t,n){a.set(e,{source:t,score:n}),o.add(t)},bytes:u,scoreOf:(n,r,i)=>ee(u(e[n]),u(t[r]),i,d),punctuatedScoreOf:(n,r,i)=>ee(u(e[n]),u(t[r]),i,f,!0)};if(be(p),i&&Ee(p,n,r),n>=6e4)return a;De(p,H(p),U(n));let m=H(p);if(m.remaining.length*m.open.length>r*r)return a;let h=i?se(p,m,U(n),e=>z(p,m,e,n)):[];return ke(p,H(p),n,h),a}var Ae=50,je=1e3;function G(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 Me(e){if(e===!1)return null;let t=e===!0?Ae: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 Ne({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 Pe=(e,t)=>M(e,t)&&(e.type!==`file`||e.mode===t.mode),K=(e,t,n,r=null)=>({status:e,old:t,new:n,similarity:r}),Fe=/\.d\.(?:[^./]+\.)?[cm]?ts$/u,q=e=>e.endsWith(`.mts`)?`module`:e.endsWith(`.cts`)?`commonjs`:null,Ie=/^export\s*\{\s*\}\s*;?$/u;function J(e){if(e===null)return{proven:!0,runtime:``,loads:!1};let n=t(e);try{return n===void 0?{proven:!1}:v(n)}catch{return{proven:!1}}}function Le(e){if(![e.old,e.new].filter(e=>e!==null).every(e=>e.type===`file`&&Fe.test(e.path))||e.old&&e.new&&e.old.mode!==e.new.mode)return e;let t=J(e.new),n=J(e.old);return!n.proven||!t.proven||n.runtime!==t.runtime&&!(e.old===null&&Ie.test(t.runtime))||n.loads&&e.old&&e.new&&e.old.path!==e.new.path&&q(e.old.path)!==q(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?Pe(a,e)||r.push(K(`modified`,a,e)):r.push(K(`type-changed`,a,e))}for(let[r,i]of t)e.has(r)||n.push(i);return i.sort((e,t)=>G(e.path,t.path)),n.sort((e,t)=>G(e.path,t.path)),{changes:r,deleted:i,added:n}}function ze(e,t,{group:n,...r}){if(n===null)return W(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 W(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=je,renameGroup:s=null,paths:c=`tree`,lines:l=!0,horizon:u,whitespace:d,ignoreCase:f}={}){let p=Me(i);Ne({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(N(e,`old`,h),N(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?K(`added`,null,t):K(`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(K(`deleted`,t,null));return g.sort((e,t)=>G((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 Y(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))t.has(r.slice(e+1))&&n.set(r.slice(0,e+1),(n.get(r.slice(0,e+1))??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=Y(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,...Y(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 X(e,t){let n=[...e],r=new Set(t),i=Ve(n,r);return{root:i,paths:Y(n,r,i).paths}}function He(e,t,n){if(!e&&!t)return null;let r=Map.groupBy([...e??[]],([,e])=>e),i=new Map([...r].map(([e,t])=>[e,o(n,e,t.map(([t])=>t.slice(e.length+1)))]));return new Map([...[...e??[]].map(([e,t])=>[n.paths.get(e)??e,i.get(t)]),...t??[]])}function Ue(e,t,n=new Map,r=new Map,i=null){let a=e=>{let t=n.get(e)??r.get(e);return t===void 0?[...new Set([e,Xe(i,e)??e])]:[t]},o=[];for(let n of e.values()){let e=a(n.parent).map(e=>t.get(c(e,n.specifier,n.conditions,n.platform))).find(Boolean);if(e&&!a(n.target).includes(e.target)){let{target:t,...i}=e;o.push({...i,baseTarget:r.get(n.target)??n.target,otherTarget:t})}}return o.sort((e,t)=>e.key.localeCompare(t.key)),{changed:o,totalChanges:o.length}}function Z(e){return p(e)??0}function Q(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 We(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 Ge(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 Ke(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 qe(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 Je=250;function Ye(e,t,n,r,i){let a=(e,t,n)=>e.filter(({path:e})=>e!==``&&e.isWellFormed()).map(({path:e},r)=>({name:e,data:qe(t.get(e),`${n}${r}`)})),o={paths:`keys`,renameGroup:i,renameLimit:Je,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 Xe(e,t){return e?e.base===``?`${e.other}${t}`:t.startsWith(e.base)?t.slice(e.base.length):null:t}function Ze(){return{baseBytes:0,otherBytes:0,onlyBaseFiles:0,onlyOtherFiles:0,changedFiles:0}}function Qe(e,t,n,r=X(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=Ge(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=Ze(),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=Q(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=Ye(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=Q(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(Ke(`path`)),C.sort($(`pkg`)),w.sort($(`pkg`)),T.sort(Ke(`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 $e(e,t,n=null){let[r,i]=[e,t],a=s(r,n),o=s(i,n),c=X(a.keys(),o.keys()),u=He(m(r),m(i),c),p=Qe(a,o,e=>_(e,{packageDir:u?.get(e)}),c,[We(r),We(i)]),v=g(r),y=g(i),b=(e,t)=>{let n=0;for(let r of t)n+=e.get(r)??0;return n};Object.assign(p.totals,{baseLines:b(v,a.keys()),otherLines:b(y,o.keys())});for(let e of p.files.onlyBase)e.lines=v.get(e.basePath??e.path)??0;for(let e of p.files.onlyOther)e.lines=y.get(e.path)??0;for(let e of p.files.changed)Object.assign(e,{baseLines:v.get(e.basePath??e.path)??0,otherLines:y.get(e.path)??0});p.resolutions=Ue(l(r,n),l(i,n),new Map(p.files.changed.filter(e=>e.renamedFrom!=null).map(e=>[e.basePath,e.path])),p.files.basePaths,p.files.root);let x=e=>_(``,{packageDir:e}),S=h(r,n?a.keys():null,x),C=h(i,n?o.keys():null,x);return p.versionUpdates=f(S,C),p.packageRows=d(p.packages,S,C),p.scope=n??``,p}export{$e as prepareComparison};
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}from"./chunk-SPEFPML6.js";import{i as u}from"./chunk-4HI2MSAV.js";import"./chunk-PXK7EU4V.js";import{a as d,c as f}from"./chunk-JCIIBLKR.js";import{k as p,o as m,p as h,u as g}from"./chunk-6ANSHRFQ.js";import{b as _}from"./chunk-IYPY47MC.js";import"./chunk-SXV2T5C4.js";import"./chunk-TUII34K2.js";import"./chunk-OOJM4CTU.js";function v(e){if(typeof e!=`string`)throw TypeError(`a text must be a string, not ${typeof e}`);if(!e.isWellFormed())throw TypeError(`a text must be a well-formed string`);return{proven:!1,reason:`unsupported`,at:null}}var y=e=>e.subarray(0,8e3).includes(0),b=(e,t)=>(e+Math.imul(t,97)>>>0)%107927,x=e=>Uint8Array.from({length:256},(t,n)=>Number(n===10||e.includes(String.fromCodePoint(n)))),S=x(``),C=x(`,;={}`);function w(e,t=S){let n=!y(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(b(a,o),s),s=0,a=0,o=0)}s>0&&i(b(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 T(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 E(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 ee(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?E(s,c,n*o):T(s,c);return Math.trunc(l*6e4/o)}var D=/^[\w-]{6,}$/u,O=/[\dA-Z]/u,te=/^(?:\.[\w-]+)+$/u,ne=/^[\w-]{8,32}$/u;function k(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&&ne.test(a)&&te.test(i)&&/[A-Za-z]/u.test(a)&&O.test(a)&&t.push([e.slice(0,n),a,i])}return t}var re=e=>e.replaceAll(/\d/gu,`0`).replaceAll(/[a-z]/gu,`a`).replaceAll(/[A-Z]/gu,`A`);function ie(e,t){let n=k(t);for(let[t,r,i]of k(e)){let e=n.find(e=>e[2]===i);if(e&&e[1]!==r)return e[0]===t&&re(e[1])!==re(r)}return!1}function ae(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 oe(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&&D.test(i)&&D.test(a)&&(O.test(i)||O.test(a))}function se({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,ae(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)oe(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&&ie(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 ce(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 A=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}},le=new Set([`file`,`contiguous-file`]),ue=new Set([`fifo`,`character-device`,`block-device`]),de=/(?:^|\/)\.{0,2}(?:\/|$)/u;function fe(e){if(!Number.isInteger(e)||e<0||e>4095)throw RangeError(`a mode must be an integer from 0 to 0o7777, not ${e}`)}function pe(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===``:de.test(e))throw new A(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 A(`a name must be well-formed Unicode`,e,n)}}function me(e,t,n){if(typeof e!=`string`||e===``)throw new A(`a link must name its target`,t,n);if(!e.isWellFormed())throw new A(`a link target must be well-formed Unicode`,t,n);return e}function he(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 j=e=>typeof e==`string`?u(e):e;function ge(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(pe(r,i,t,n),a!==void 0&&fe(a),le.has(i))return{path:r,type:`file`,mode:a??420,data:he(s)};if(i===`symlink`||i===`hardlink`)return{path:r,type:i,target:me(o,r,t)};if(i===`directory`)return{path:r,type:i};throw ue.has(i)?new A(`a ${i} is neither a file nor a link`,r,t):TypeError(`${JSON.stringify(i)} is not an entry type`)}function M(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:ce(j(e.data),j(t.data)):!1}function _e(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 A(`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 A(`a hard link must name a file or a link in the tree`,e.path,n);return{...i,path:e.path}}function N(e,t,n){let r=new Map;for(let i of e){let e=ge(i,t,n);if(e.type!==`directory`||e.path!==`.`){if(r.has(e.path))throw new A(`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 A(`a path lies under a ${n.type===`symlink`?`link`:`file`}`,e,t)}a.type===`hardlink`?i.set(e,_e(a,r,t)):a.type!==`directory`&&i.set(e,a)}return i}var ve=100,ye=4,P=e=>e.slice(e.lastIndexOf(`/`)+1);function F(t,n){if(t.type===`symlink`)return`l${t.target}`;let r=n(t);return`f${r.length}:${e(r)}`}function be({sources:e,dests:t,sourceNames:n,destNames:r,used:i,record:a,bytes:o}){let s=Map.groupBy(e.keys(),t=>F(e[t],o));for(let c=0;c<t.length;c++){let l=-1,u=ve;for(let a of s.get(F(t[c],o))??[])if(!i.has(a)&&M(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 xe=new Map([[`.ts`,`.js`],[`.mts`,`.mjs`],[`.cts`,`.cjs`],[`.tsx`,`.jsx`]]),Se=new Map([...[`.js`,`.mjs`,`.cjs`,`.jsx`,`.ts`,`.mts`,`.cts`,`.tsx`].map(e=>[e,`script`]),...[`.css`,`.scss`,`.sass`,`.less`].map(e=>[e,`style`])]);function I(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 L(e){let{dirs:t,stem:n,extension:r}=I(e);return JSON.stringify([t.map(e=>e===`lib`||e===`src`?null:e),n,xe.get(r)??r])}function Ce(e){let{dirs:t,stem:n,extension:r}=I(e),i=[n,Se.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 R=(e,t)=>Math.max(t,e+Math.trunc((6e4-e)/2));function z({pairs:e,used:t,scoreOf:n},{remaining:r,open:i},{s:a,d:o,score:s},c){let l=R(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 we(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=>L(i[e].path)),d=t.open.filter(e=>a[e].type===`file`).flatMap(e=>(u.get(L(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&&z(e,t,i,r))&&c(i.d,i.s,i.score)}function Te(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=Ce(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&&z(e,t,s,r)||c(o,i,s.score)}}function Ee(e,t,n){let r=H(e),i=t<6e4&&r.remaining.length*r.open.length<=n*n;we(e,r,i,t),Te(e,r,i,t)}function B(e,t){let n=new Map;for(let r of t)n.set(e[r],n.has(e[r])?-1:r);return n}function De({sourceNames:e,destNames:t,record:n,scoreOf:r},{remaining:i,open:a},o){let s=B(t,a),c=B(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 V=(e,t)=>t.score-e.score||t.nameScore-e.nameScore;function Oe(e,t){if(e.length<ye){e.push(t);return}let n=0;for(let t=1;t<e.length;t++)V(e[t],e[n])>0&&(n=t);V(e[n],t)>0&&(e[n]=t)}function ke({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)Oe(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&&R(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(V)){if(a<c)break;f(a),!n.has(e)&&!r.has(t)&&i(e,t,a)}f(-1/0)}var H=({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()}),U=e=>e+Math.trunc(.5*(6e4-e));function W(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,j(e.data)).get(e):null,d=e=>s.get(e)??s.set(e,w(e)).get(e),f=e=>l.get(e)??l.set(e,w(e,C)).get(e),p={sources:e,dests:t,pairs:a,used:o,sourceNames:e.map(e=>P(e.path)),destNames:t.map(e=>P(e.path)),record(e,t,n){a.set(e,{source:t,score:n}),o.add(t)},bytes:u,scoreOf:(n,r,i)=>ee(u(e[n]),u(t[r]),i,d),punctuatedScoreOf:(n,r,i)=>ee(u(e[n]),u(t[r]),i,f,!0)};if(be(p),i&&Ee(p,n,r),n>=6e4)return a;De(p,H(p),U(n));let m=H(p);if(m.remaining.length*m.open.length>r*r)return a;let h=i?se(p,m,U(n),e=>z(p,m,e,n)):[];return ke(p,H(p),n,h),a}var Ae=50,je=1e3;function G(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 Me(e){if(e===!1)return null;let t=e===!0?Ae: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 Ne({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 Pe=(e,t)=>M(e,t)&&(e.type!==`file`||e.mode===t.mode),K=(e,t,n,r=null)=>({status:e,old:t,new:n,similarity:r}),Fe=/\.d\.(?:[^./]+\.)?[cm]?ts$/u,q=e=>e.endsWith(`.mts`)?`module`:e.endsWith(`.cts`)?`commonjs`:null,Ie=/^export\s*\{\s*\}\s*;?$/u;function J(e){if(e===null)return{proven:!0,runtime:``,loads:!1};let n=t(e);try{return n===void 0?{proven:!1}:v(n)}catch{return{proven:!1}}}function Le(e){if(![e.old,e.new].filter(e=>e!==null).every(e=>e.type===`file`&&Fe.test(e.path))||e.old&&e.new&&e.old.mode!==e.new.mode)return e;let t=J(e.new),n=J(e.old);return!n.proven||!t.proven||n.runtime!==t.runtime&&!(e.old===null&&Ie.test(t.runtime))||n.loads&&e.old&&e.new&&e.old.path!==e.new.path&&q(e.old.path)!==q(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?Pe(a,e)||r.push(K(`modified`,a,e)):r.push(K(`type-changed`,a,e))}for(let[r,i]of t)e.has(r)||n.push(i);return i.sort((e,t)=>G(e.path,t.path)),n.sort((e,t)=>G(e.path,t.path)),{changes:r,deleted:i,added:n}}function ze(e,t,{group:n,...r}){if(n===null)return W(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 W(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=je,renameGroup:s=null,paths:c=`tree`,lines:l=!0,horizon:u,whitespace:d,ignoreCase:f}={}){let p=Me(i);Ne({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(N(e,`old`,h),N(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?K(`added`,null,t):K(`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(K(`deleted`,t,null));return g.sort((e,t)=>G((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 Y(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))t.has(r.slice(e+1))&&n.set(r.slice(0,e+1),(n.get(r.slice(0,e+1))??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=Y(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,...Y(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 X(e,t){let n=[...e],r=new Set(t),i=Ve(n,r);return{root:i,paths:Y(n,r,i).paths}}function He(e,t,n){if(!e&&!t)return null;let r=Map.groupBy([...e??[]],([,e])=>e),i=new Map([...r].map(([e,t])=>[e,o(n,e,t.map(([t])=>t.slice(e.length+1)))]));return new Map([...[...e??[]].map(([e,t])=>[n.paths.get(e)??e,i.get(t)]),...t??[]])}function Ue(e,t,n=new Map,r=new Map,i=null){let a=e=>{let t=n.get(e)??r.get(e);return t===void 0?[...new Set([e,Xe(i,e)??e])]:[t]},o=[];for(let n of e.values()){let e=a(n.parent).map(e=>t.get(c(e,n.specifier,n.conditions,n.platform))).find(Boolean);if(e&&!a(n.target).includes(e.target)){let{target:t,...i}=e;o.push({...i,baseTarget:r.get(n.target)??n.target,otherTarget:t})}}return o.sort((e,t)=>e.key.localeCompare(t.key)),{changed:o,totalChanges:o.length}}function Z(e){return p(e)??0}function Q(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 We(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 Ge(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 Ke(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 qe(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 Je=250;function Ye(e,t,n,r,i){let a=(e,t,n)=>e.filter(({path:e})=>e!==``&&e.isWellFormed()).map(({path:e},r)=>({name:e,data:qe(t.get(e),`${n}${r}`)})),o={paths:`keys`,renameGroup:i,renameLimit:Je,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 Xe(e,t){return e?e.base===``?`${e.other}${t}`:t.startsWith(e.base)?t.slice(e.base.length):null:t}function Ze(){return{baseBytes:0,otherBytes:0,onlyBaseFiles:0,onlyOtherFiles:0,changedFiles:0}}function Qe(e,t,n,r=X(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=Ge(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=Ze(),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=Q(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=Ye(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=Q(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(Ke(`path`)),C.sort($(`pkg`)),w.sort($(`pkg`)),T.sort(Ke(`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 $e(e,t,n=null){let[r,i]=[e,t],a=s(r,n),o=s(i,n),c=X(a.keys(),o.keys()),u=He(m(r),m(i),c),p=Qe(a,o,e=>_(e,{packageDir:u?.get(e)}),c,[We(r),We(i)]),v=g(r),y=g(i),b=(e,t)=>{let n=0;for(let r of t)n+=e.get(r)??0;return n};Object.assign(p.totals,{baseLines:b(v,a.keys()),otherLines:b(y,o.keys())});for(let e of p.files.onlyBase)e.lines=v.get(e.basePath??e.path)??0;for(let e of p.files.onlyOther)e.lines=y.get(e.path)??0;for(let e of p.files.changed)Object.assign(e,{baseLines:v.get(e.basePath??e.path)??0,otherLines:y.get(e.path)??0});p.resolutions=Ue(l(r,n),l(i,n),new Map(p.files.changed.filter(e=>e.renamedFrom!=null).map(e=>[e.basePath,e.path])),p.files.basePaths,p.files.root);let x=e=>_(``,{packageDir:e}),S=h(r,n?a.keys():null,x),C=h(i,n?o.keys():null,x);return p.versionUpdates=f(S,C),p.packageRows=d(p.packages,S,C),p.scope=n??``,p}export{$e as prepareComparison};