@preventive/triage 1.0.0-alpha.71 → 1.0.0-alpha.72
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/activity.js +4 -4
- package/out/{chunk-45HTR22K.js → chunk-27Y75UQR.js} +1 -1
- package/out/chunk-4LZK6C6N.js +11 -0
- package/out/chunk-4XSH6ZLT.js +1 -0
- package/out/{chunk-QPGM3DTI.js → chunk-7CHIFYQW.js} +1 -1
- package/out/chunk-7YFJUT2P.js +1 -0
- package/out/chunk-CZ3U2LI4.js +2 -0
- package/out/chunk-ETL5ZPPR.js +259 -0
- package/out/{chunk-CQIT5UNK.js → chunk-L6VIWL2Y.js} +1 -1
- package/out/{chunk-MPXVKVPF.js → chunk-OSHR3N4S.js} +1 -1
- package/out/chunk-PQPKHAI5.js +15 -0
- package/out/chunk-UD33S2MG.js +52 -0
- package/out/{chunk-GZ46SSTF.js → chunk-WKFBZYJX.js} +1 -1
- package/out/client-managed.js +28 -27
- package/out/compare.js +12 -14
- package/out/dialogs.js +28 -28
- package/out/graph.js +1 -1
- package/out/index.html +6 -6
- package/out/scan.js +2 -2
- package/out/terminal.js +1 -1
- package/out/view.css +1 -1
- package/out/view.js +11 -11
- package/package.json +2 -1
- package/risk/actions/resolve.js +9 -3
- package/risk/files/characters.js +11 -0
- package/risk/files/source-map-link.js +43 -0
- package/risk/npm/compare.js +4 -26
- package/server-managed/http.ts +105 -54
- package/server-managed/npm-delta.ts +16 -1
- package/server-managed/npm-kept.ts +6 -0
- package/server-managed/pull-dependencies.ts +4 -1
- package/server-managed/repository-issues.ts +15 -9
- package/server-managed/stasis-dependencies.ts +7 -4
- package/out/chunk-2HGKTQ5Q.js +0 -52
- package/out/chunk-7GJNLCXF.js +0 -15
- package/out/chunk-CGRIZ5M5.js +0 -1
- package/out/chunk-D6NVKGGG.js +0 -10
- package/out/chunk-DTAR2BB6.js +0 -247
- package/out/chunk-NB4JBTKK.js +0 -2
- package/out/chunk-VFWMQ3LG.js +0 -2
package/out/compare.js
CHANGED
|
@@ -1,34 +1,32 @@
|
|
|
1
|
-
import{a as e,b as t,f as n,g as r,j as i,k as a,l as o}from"./chunk-NB4JBTKK.js";import{k as s}from"./chunk-7GJNLCXF.js";import"./chunk-PXK7EU4V.js";import"./chunk-R3NZFXVR.js";import{$d as c,Ad as l,Af as u,Bd as d,Cd as f,Dd as p,Ed as m,Fd as h,Fe as g,Ge as _,Ja as v,Ka as y,Kd as b,La as x,Ld as S,Lf as C,Ma as ee,Md as te,Mf as ne,Nc as re,Nd as w,Oc as ie,Pc as T,Qc as ae,Qd as oe,Rc as se,Rd as ce,Sa as le,Sc as ue,Sd as de,Ta as fe,Td as pe,Ua as me,Va as he,Wa as ge,Zc as _e,_d as ve,ae as ye,bd as be,be as xe,cd as Se,ce as Ce,dd as we,de as Te,ed as Ee,ee as De,fd as Oe,fe as ke,gd as Ae,ge as je,hd as Me,he as Ne,id as Pe,ja as Fe,jd as Ie,je as Le,kd as Re,ld as ze,md as Be,nc as Ve,oc as He,od as Ue,of as We,pc as Ge,pd as Ke,pf as qe,qd as Je,qf as Ye,rd as Xe,rf as Ze,sd as Qe,sf as $e,td as et,tf as tt,ud as nt,uf as rt,vd as it,vf as at,w as E,wd as ot,wf as D,xd as st,xf as O,yd as ct,yf as lt,zd as ut,zf as dt}from"./chunk-DTAR2BB6.js";import"./chunk-JCIIBLKR.js";import"./chunk-E3LFSUDJ.js";import"./chunk-JMG5DXII.js";import"./chunk-2F3CYNPZ.js";import{$ as ft,_ as k,aa as pt,ba as mt,ea as ht,qa as gt,s as _t,ta as vt}from"./chunk-2HGKTQ5Q.js";import{b as yt,c as bt,l as A,m as j}from"./chunk-WFDXHPT2.js";import"./chunk-NRPC74AM.js";import"./chunk-7BKKYVWR.js";import"./chunk-7C7DWL7I.js";import"./chunk-PNHBZGDD.js";import"./chunk-VFWMQ3LG.js";import{Ba as xt,K as M,L as St,a as N}from"./chunk-QPGM3DTI.js";import"./chunk-HETCVNO4.js";import"./chunk-D6NVKGGG.js";import{e as Ct}from"./chunk-IYPY47MC.js";import{a as P,d as F}from"./chunk-PWFUOLZK.js";import{k as wt,n as Tt,r as Et}from"./chunk-4RS3NDOG.js";import{a as Dt}from"./chunk-QRKFPLA4.js";import{D as Ot,d as kt}from"./chunk-74AEKRES.js";import"./chunk-C4Z6ZBXV.js";import{c as I,g as L,j as At}from"./chunk-2XUEZHIP.js";import"./chunk-TUII34K2.js";import"./chunk-OOJM4CTU.js";function jt(e){return e===0?`±0`:`${e>0?`+`:`−`}${Math.abs(e).toLocaleString()}`}function Mt(e){return e===0?`±0 B`:`${e>0?`+`:`−`}${M(Math.abs(e))}`}function R(e){return e>0?`up`:e<0?`down`:``}function Nt({onlyBase:e,onlyOther:t,changed:n}){return[[`removed`,`−`,e],[`added`,`+`,t],[`repointed`,``,n]].filter(([,,e])=>e.length>0).map(([e,t,n])=>I`<span class="${`bundle-compare-chip ${e===`repointed`?`changed`:e}`}">${t}${n.length.toLocaleString()} ${e} ${n.length===1?`resolution`:`resolutions`}</span>`)}function Pt(e,t){if(!t)return``;let n=e/t*100;return`${n>0?`+`:n<0?`−`:`±`}${Math.abs(n).toFixed(1)}%`}function Ft(e){let t=e.totals,n=e.versionUpdates?.totals??{baseDeps:0,otherDeps:0},r=n.baseDeps>0||n.otherDeps>0,i=n.otherDeps-n.baseDeps,a=Pt(t.byteDelta,t.baseBytes);return I`<div class="bundle-compare-stats">${r?I`<div class="bundle-compare-metric"><span class="bundle-compare-metric-label">Deps</span> <span class="bundle-compare-metric-value">${n.baseDeps.toLocaleString()} → ${n.otherDeps.toLocaleString()}</span> <span class="${`bundle-compare-metric-delta ${R(i)}`}">${jt(i)}</span></div>`:L}<div class="bundle-compare-metric"><span class="bundle-compare-metric-label">Size</span> <span class="bundle-compare-metric-value">${M(t.baseBytes)} → ${M(t.otherBytes)}</span> <span class="${`bundle-compare-metric-delta ${R(t.byteDelta)}`}">${Mt(t.byteDelta)}${a?I`${` `}<span class="bundle-compare-pct">(${a})</span>`:L}</span></div>${t.baseLines>0||t.otherLines>0?I`<div class="bundle-compare-metric"><span class="bundle-compare-metric-label">LoC</span> <span class="bundle-compare-metric-value">${t.baseLines.toLocaleString()} → ${t.otherLines.toLocaleString()}</span> <span class="${`bundle-compare-metric-delta ${R(t.otherLines-t.baseLines)}`}">${jt(t.otherLines-t.baseLines)}</span></div>`:L}<div class="bundle-compare-files"><div class="bundle-compare-metric"><span class="bundle-compare-metric-label">Files</span> <span class="bundle-compare-metric-value">${t.baseFiles.toLocaleString()} → ${t.otherFiles.toLocaleString()}</span> <span class="${`bundle-compare-metric-delta ${R(t.fileDelta)}`}">${jt(t.fileDelta)}</span></div><div class="bundle-compare-chips">${t.onlyBaseFiles>0?I`<span class="bundle-compare-chip removed">−${t.onlyBaseFiles.toLocaleString()} removed</span>`:L} ${t.onlyOtherFiles>0?I`<span class="bundle-compare-chip added">+${t.onlyOtherFiles.toLocaleString()} added</span>`:L} ${t.changedFiles>0?I`<span class="bundle-compare-chip changed">${t.changedFiles.toLocaleString()} changed${t.renamedFiles>0?` (${t.renamedFiles.toLocaleString()} renamed)`:``}</span>`:L} <span class="bundle-compare-chip unchanged">${t.unchangedFiles.toLocaleString()} unchanged</span> ${e.resolutions?Nt(e.resolutions):L}</div></div></div>`}var It=24;function z(e,t=e=>e.id){return e.map(e=>({id:t(e),integrity:t(e),kind:e.format,format:e.format,detail:e.detail,...e.date&&{date:e.date},...e.dateWarning&&{dateWarning:e.dateWarning},filename:e.name,displayLabel:e.displayLabel,size:`—`,summary:null}))}function Lt(e){if(!e)return L;let t=({name:e=``,detail:t=``,detailNote:n=null}={})=>e.length+Math.min(t.length,It)*.87+(n?3:1),n=(e.choices??[]).reduce((e,n)=>Math.max(e,t(n)),Math.max(`Choose a ${e.noun??`bundle`}\u2026`.length,t(e.widest)));return P({"--compare-select-chars":`${Math.ceil(n)}`})}function Rt({source:e,label:t=`Compare`,from:n,to:r,clear:i,swap:a,extras:o=L,comparison:s=null,disabled:c=!1,openLine:l}){let u=e?.noun??`bundle`,d=`${u[0].toUpperCase()}${u.slice(1)}`,f=(t,n)=>e?.select?e.select(t,t.label??n):I`<bundle-selector .bundles="${t.options}" .value="${t.value}" .noun="${u}" .versions="${!!e}" label="${t.label??n}" placeholder="${t.placeholder??`Choose a ${u}\u2026`}" ?disabled="${c}" @bundle-change="${e=>{e.stopPropagation(),t.pick(e.detail.value)}}"></bundle-selector>`;return I`<div class="${e?`bundle-compare-picker is-versions`:`bundle-compare-picker`}" style="${Lt(e)}" @compare-open-line="${e=>l?.(e.detail)}"><div class="bundle-compare-select-wrap"><span class="bundle-compare-select-hint">${t}</span> ${f(n,`${d} to compare with`)} ${i?I`<button type="button" class="bundle-compare-clear" aria-label="${i.label??`Clear comparison`}" ?disabled="${c}" @click="${i.run}">×</button>`:L}</div><span class="bundle-compare-arrow" aria-hidden="true">→</span><div class="bundle-compare-select-wrap">${f(r,`${d} to compare`)} ${a?I`<button type="button" class="bundle-compare-swap" ?disabled="${c}" @click="${a}" aria-label="${`Swap the two ${u}s`}"><span class="bundle-compare-swap-icon" aria-hidden="true">↔</span>Swap</button>`:L}</div>${o}${s?e?.badges?.(s.base,s.other,s.files)??L:L}</div>`}function zt(e,t=L){return I`<div class="bundle-compare-summary">${Ft(e)}${t}</div>`}function Bt(e,t=L){return I`<header class="bundle-compare-head">${e}${t}</header>`}var Vt=4,Ht=5e3,Ut=3e5,Wt=e=>!(e>=400&&e<500&&e!==429),Gt=e=>e?.integrity===`(empty)`,B=new Map;function Kt(){for(let[e,t]of B){if(B.size<=Vt)break;t.state.status!==`loading`&&B.delete(e)}}function qt(e){e.notify?.();for(let t of e.waiting.splice(0))t()}var Jt=null,Yt=(e,t)=>!!(e.managedId&&t.managedId)||!(!t.npm&&!t.npmPatch||!e.npm&&!Gt(e));function Xt(e,t,n){if(e.managedId&&t.managedId)return x(e.managedId,t.managedId,{scope:n});if(Yt(e,t)){let{name:n,version:r,patch:i}=t.npm??t.npmPatch;return ee(n,r,e.npm?.version??`(empty)`,{otherName:e.npm?.name??n,...i?{patch:i}:{},...e.npmPatch?{otherPatch:e.npmPatch.patch}:{}})}return import(`./chunk-CGRIZ5M5.js`).then(r=>(Jt=r,r.prepareComparison(e,t,n)))}async function Zt(e,t,n,r,i){let a;try{a={status:`ready`,diff:await Xt(n,r,i)}}catch(n){if(n?.name===`AbortError`){B.get(e)===t&&B.delete(e),qt(t);return}if(a={status:`error`,message:n?.message??String(n)},Wt(n?.status)){let e=Math.min(Ht*2**t.failures,Ut);Object.assign(t,{retryAt:Date.now()+e,failures:t.failures+1}),setTimeout(()=>{t.notify?.()},e)?.unref?.()}}a.status===`ready`&&(t.failures=0),t.state=a,qt(t),Kt()}var Qt=new WeakMap,$t=0,en=e=>(Qt.has(e)||Qt.set(e,++$t),Qt.get(e));function tn(e,t,n,r=!1){let i=Yt(e,t)?`${e.integrity}\0${t.integrity}\0${n??``}`:`${en(e)}\0${en(t)}\0${n??``}\0here`,a=B.get(i);return B.delete(i),(!a||r&&a.state.status===`error`||a.retryAt!==void 0&&Date.now()>=a.retryAt)&&(a={state:{status:`loading`},notify:a?.notify??null,waiting:[],failures:a?.failures??0},Jt&&!Yt(e,t)?a.state={status:`ready`,diff:Jt.prepareComparison(e,t,n??``)}:Zt(i,a,e,t,n??``)),B.set(i,a),Kt(),a}function nn(e,t,n,r){let i=tn(e,t,n);return i.notify=r,i.state}function rn(e,t,n=null){return new Promise((r,i)=>{let a=(o=!1)=>{let s=tn(e,t,n,o),{state:c}=s;c.status===`loading`?s.waiting.push(()=>a()):c.status===`ready`?r(c.diff):i(Error(c.message))};a(!0)})}function an(e,t){let{head:n,from:i,to:a,tail:o}=r(e,t);return I`${n}{<span class="bundle-compare-rename-from">${i}</span> → <span class="bundle-compare-rename-to">${a}</span>}${o}`}function on({from:e,to:t}){return I`<span class="bundle-compare-rename-from">${e}</span> → <span class="bundle-compare-rename-to">${t}</span>`}function sn(e){let t=new Map;if(!e)return t;for(let n of e.onlyBase)t.set(n.path,{kind:`removed`,basePath:n.basePath,baseBytes:n.bytes,otherBytes:null});for(let n of e.onlyOther)t.set(n.path,{kind:`added`,baseBytes:null,otherBytes:n.bytes});for(let n of e.changed){let e={...n.meta?{meta:n.meta}:{}};t.set(n.path,n.renamedFrom==null?{kind:`changed`,basePath:n.basePath,baseBytes:n.baseBytes,otherBytes:n.otherBytes,...n.modified===!1?{modified:!1}:{},...e}:{kind:`renamed`,basePath:n.basePath,renamedFrom:n.renamedFrom,modified:n.modified,baseBytes:n.baseBytes,otherBytes:n.otherBytes,...e})}return t}function V(e,t,n,{kind:r,basePath:i=n}){let a=r===`added`?``:A(e).get(i),o=r===`removed`?``:A(t).get(n);return r===`repointed`&&(a=o??=a),{before:a,after:o}}var cn=new WeakMap,ln=Object.freeze([]);function un(e){if(!e)return ln;let t=cn.get(e);return t||cn.set(e,t=[...e.onlyBase,...e.onlyOther,...e.changed]),t}function dn(e){return e.baseTarget===null?`added`:e.otherTarget===null?`removed`:`repointed`}function fn(e,t,n,r=[]){let i=sn(n);if(!n)return i;for(let n of r){if(!i.has(n.parent)){let r=j(A(t).get(n.parent)??A(e).get(n.parent));i.set(n.parent,{kind:`repointed`,baseBytes:r,otherBytes:r})}let r=i.get(n.parent);r.repointed=[...r.repointed??[],n]}return i}function pn(e,t,n){return[...fn(e,t,n.files,un(n.resolutions))].map(([n,r])=>({path:n,...r,...V(e,t,n,r)}))}function mn(e,{maxBytes:t,maxLines:n}){let r=0,i=0;for(let{before:a,after:o}of e)for(let e of[a,o])if(r+=j(e)??0,r>=t||(typeof e==`string`&&e!==``&&(i+=(e.match(/\n/gu)?.length??0)+ +!e.endsWith(`
|
|
2
|
-
`)),i>=n))return!1;return!0}function
|
|
3
|
-
`);return t.at(-1)===``&&t.pop(),t}var hn=e=>e===``||e.endsWith(`
|
|
4
|
-
`),gn=e=>e.replace(/[ \t\n\v\f\r]+$/u,``).replaceAll(/[ \t\n\v\f\r]+/gu,` `);function U(e,t,n=!1){return s(e,t,{horizon:0,whitespace:n?`change`:`none`}).map(({a0:e,a1:t,b0:n,b1:r})=>({a0:e,a1:t,b0:n,b1:r}))}function _n(e,t,n,r=!1){if(!Array.isArray(n))return!1;let i=H(e),a=H(t),o=r?(e,t)=>gn(e)===gn(t):(e,t)=>e===t,s=0,c=0;for(let l of[...n,{a0:i.length,a1:i.length,b0:a.length,b1:a.length,last:!0}]){let{a0:n,a1:u,b0:d,b1:f}=l??{};if(![n,u,d,f].every(Number.isInteger)||n<s||d<c||u<n||f<d||u>i.length||f>a.length||!l.last&&u===n&&f===d||n-s!==d-c||l.last&&n>s&&!r&&hn(e)!==hn(t))return!1;for(;s<n;s++,c++)if(!o(i[s],a[c]))return!1;s=u,c=f}return!0}var vn=3,W=20,yn=4;function bn(e,t,{ignoreWhitespace:n=!1,changes:r=null,marks:i=null}={}){let a=H(e),o=H(t),s=r?.blocks??U(e,t,n),c={a:e!==``&&!e.endsWith(`
|
|
1
|
+
import{a as e,b as t,f as n,g as r,j as i,k as a,l as o}from"./chunk-CZ3U2LI4.js";import"./chunk-7YFJUT2P.js";import"./chunk-PXK7EU4V.js";import"./chunk-R3NZFXVR.js";import{Ad as s,Af as c,Bd as l,Bf as u,Cd as d,Cf as f,Dd as p,Df as m,Ed as h,Ef as g,Fd as _,Ff as v,Gd as y,Gf as b,Hd as x,Id as S,Ja as C,Jd as w,Ka as T,Kd as ee,Ke as te,La as ne,Le as E,Ma as D,Nc as re,Oc as ie,Pc as O,Pd as ae,Qc as oe,Qd as se,Qf as ce,Rc as le,Rd as ue,Rf as de,Sa as fe,Sc as pe,Sd as me,Ta as he,Ua as ge,Va as _e,Vd as ve,Wa as ye,Wd as be,Xd as xe,Yd as Se,Zc as Ce,bd as we,cd as Te,dd as Ee,de as De,ed as Oe,ee as ke,fd as Ae,fe as je,gd as Me,ge as Ne,hd as Pe,he as Fe,id as Ie,ie as Le,ja as Re,jd as ze,je as Be,kd as Ve,ke as He,ld as Ue,le as We,md as Ge,me as Ke,nc as qe,oc as Je,od as Ye,oe as Xe,pc as Ze,pd as Qe,qd as k,rd as A,sd as $e,td as et,ud as tt,uf as nt,vd as rt,vf as it,w as j,wd as at,wf as ot,xd as st,xf as ct,yd as lt,yf as ut,zd as dt,zf as ft}from"./chunk-ETL5ZPPR.js";import"./chunk-JCIIBLKR.js";import"./chunk-E3LFSUDJ.js";import"./chunk-JMG5DXII.js";import"./chunk-PQPKHAI5.js";import"./chunk-2F3CYNPZ.js";import{$ as M,aa as pt,ba as mt,ca as ht,ea as gt,ra as _t,s as vt,ua as yt}from"./chunk-UD33S2MG.js";import{b as bt,c as xt,l as N,m as P}from"./chunk-WFDXHPT2.js";import"./chunk-NRPC74AM.js";import"./chunk-7BKKYVWR.js";import"./chunk-7C7DWL7I.js";import"./chunk-PNHBZGDD.js";import{Ba as St,K as F,L as Ct,a as I}from"./chunk-7CHIFYQW.js";import"./chunk-HETCVNO4.js";import"./chunk-4LZK6C6N.js";import{e as wt}from"./chunk-IYPY47MC.js";import{a as L,d as R}from"./chunk-PWFUOLZK.js";import{k as Tt,n as Et,r as Dt}from"./chunk-4RS3NDOG.js";import{a as Ot}from"./chunk-QRKFPLA4.js";import{D as kt,d as At}from"./chunk-74AEKRES.js";import"./chunk-C4Z6ZBXV.js";import{c as z,g as B,j as jt}from"./chunk-2XUEZHIP.js";import"./chunk-TUII34K2.js";import"./chunk-OOJM4CTU.js";function Mt(e){return e===0?`±0`:`${e>0?`+`:`−`}${Math.abs(e).toLocaleString()}`}function Nt(e){return e===0?`±0 B`:`${e>0?`+`:`−`}${F(Math.abs(e))}`}function Pt(e){return e>0?`up`:e<0?`down`:``}function Ft({onlyBase:e,onlyOther:t,changed:n}){return[[`removed`,`−`,e],[`added`,`+`,t],[`repointed`,``,n]].filter(([,,e])=>e.length>0).map(([e,t,n])=>z`<span class="${`bundle-compare-chip ${e===`repointed`?`changed`:e}`}">${t}${n.length.toLocaleString()} ${e} ${n.length===1?`resolution`:`resolutions`}</span>`)}function It(e,t){if(!t)return``;let n=e/t*100;return`${n>0?`+`:n<0?`−`:`±`}${Math.abs(n).toFixed(1)}%`}function Lt(e){let t=e.totals,n=e.versionUpdates?.totals??{baseDeps:0,otherDeps:0},r=n.baseDeps>0||n.otherDeps>0,i=n.otherDeps-n.baseDeps,a=It(t.byteDelta,t.baseBytes);return z`<div class="bundle-compare-stats">${r?z`<div class="bundle-compare-metric"><span class="bundle-compare-metric-label">Deps</span> <span class="bundle-compare-metric-value">${n.baseDeps.toLocaleString()} → ${n.otherDeps.toLocaleString()}</span> <span class="${`bundle-compare-metric-delta ${Pt(i)}`}">${Mt(i)}</span></div>`:B}<div class="bundle-compare-metric"><span class="bundle-compare-metric-label">Size</span> <span class="bundle-compare-metric-value">${F(t.baseBytes)} → ${F(t.otherBytes)}</span> <span class="${`bundle-compare-metric-delta ${Pt(t.byteDelta)}`}">${Nt(t.byteDelta)}${a?z`${` `}<span class="bundle-compare-pct">(${a})</span>`:B}</span></div>${t.baseLines>0||t.otherLines>0?z`<div class="bundle-compare-metric"><span class="bundle-compare-metric-label">LoC</span> <span class="bundle-compare-metric-value">${t.baseLines.toLocaleString()} → ${t.otherLines.toLocaleString()}</span> <span class="${`bundle-compare-metric-delta ${Pt(t.otherLines-t.baseLines)}`}">${Mt(t.otherLines-t.baseLines)}</span></div>`:B}<div class="bundle-compare-files"><div class="bundle-compare-metric"><span class="bundle-compare-metric-label">Files</span> <span class="bundle-compare-metric-value">${t.baseFiles.toLocaleString()} → ${t.otherFiles.toLocaleString()}</span> <span class="${`bundle-compare-metric-delta ${Pt(t.fileDelta)}`}">${Mt(t.fileDelta)}</span></div><div class="bundle-compare-chips">${t.onlyBaseFiles>0?z`<span class="bundle-compare-chip removed">−${t.onlyBaseFiles.toLocaleString()} removed</span>`:B} ${t.onlyOtherFiles>0?z`<span class="bundle-compare-chip added">+${t.onlyOtherFiles.toLocaleString()} added</span>`:B} ${t.changedFiles>0?z`<span class="bundle-compare-chip changed">${t.changedFiles.toLocaleString()} changed${t.renamedFiles>0?` (${t.renamedFiles.toLocaleString()} renamed)`:``}</span>`:B} <span class="bundle-compare-chip unchanged">${t.unchangedFiles.toLocaleString()} unchanged</span> ${e.resolutions?Ft(e.resolutions):B}</div></div></div>`}var Rt=24;function V(e,t=e=>e.id){return e.map(e=>({id:t(e),integrity:t(e),kind:e.format,format:e.format,detail:e.detail,...e.date&&{date:e.date},...e.dateWarning&&{dateWarning:e.dateWarning},filename:e.name,displayLabel:e.displayLabel,size:`—`,summary:null}))}function zt(e){if(!e)return B;let t=({name:e=``,detail:t=``,detailNote:n=null}={})=>e.length+Math.min(t.length,Rt)*.87+(n?3:1),n=(e.choices??[]).reduce((e,n)=>Math.max(e,t(n)),Math.max(`Choose a ${e.noun??`bundle`}\u2026`.length,t(e.widest)));return L({"--compare-select-chars":`${Math.ceil(n)}`})}function Bt({source:e,label:t=`Compare`,from:n,to:r,clear:i,swap:a,extras:o=B,comparison:s=null,disabled:c=!1,openLine:l}){let u=e?.noun??`bundle`,d=`${u[0].toUpperCase()}${u.slice(1)}`,f=(t,n)=>e?.select?e.select(t,t.label??n):z`<bundle-selector .bundles="${t.options}" .value="${t.value}" .noun="${u}" .versions="${!!e}" label="${t.label??n}" placeholder="${t.placeholder??`Choose a ${u}\u2026`}" ?disabled="${c}" @bundle-change="${e=>{e.stopPropagation(),t.pick(e.detail.value)}}"></bundle-selector>`;return z`<div class="${e?`bundle-compare-picker is-versions`:`bundle-compare-picker`}" style="${zt(e)}" @compare-open-line="${e=>l?.(e.detail)}"><div class="bundle-compare-select-wrap"><span class="bundle-compare-select-hint">${t}</span> ${f(n,`${d} to compare with`)} ${i?z`<button type="button" class="bundle-compare-clear" aria-label="${i.label??`Clear comparison`}" ?disabled="${c}" @click="${i.run}">×</button>`:B}</div><span class="bundle-compare-arrow" aria-hidden="true">→</span><div class="bundle-compare-select-wrap">${f(r,`${d} to compare`)} ${a?z`<button type="button" class="bundle-compare-swap" ?disabled="${c}" @click="${a}" aria-label="${`Swap the two ${u}s`}"><span class="bundle-compare-swap-icon" aria-hidden="true">↔</span>Swap</button>`:B}</div>${o}${s?e?.badges?.(s.base,s.other,s.files)??B:B}</div>`}function Vt(e,t=B){return z`<div class="bundle-compare-summary">${Lt(e)}${t}</div>`}function Ht(e,t=B){return z`<header class="bundle-compare-head">${e}${t}</header>`}var Ut=4,Wt=5e3,Gt=3e5,Kt=e=>!(e>=400&&e<500&&e!==429),qt=e=>e?.integrity===`(empty)`,H=new Map;function Jt(){for(let[e,t]of H){if(H.size<=Ut)break;t.state.status!==`loading`&&H.delete(e)}}function Yt(e){e.notify?.();for(let t of e.waiting.splice(0))t()}var Xt=null,Zt=(e,t)=>!!(e.managedId&&t.managedId)||!(!t.npm&&!t.npmPatch||!e.npm&&!qt(e));function Qt(e,t,n){if(e.managedId&&t.managedId)return ne(e.managedId,t.managedId,{scope:n});if(Zt(e,t)){let{name:n,version:r,patch:i}=t.npm??t.npmPatch;return D(n,r,e.npm?.version??`(empty)`,{otherName:e.npm?.name??n,...i?{patch:i}:{},...e.npmPatch?{otherPatch:e.npmPatch.patch}:{}})}return import(`./chunk-4XSH6ZLT.js`).then(r=>(Xt=r,r.prepareComparison(e,t,n)))}async function $t(e,t,n,r,i){let a;try{a={status:`ready`,diff:await Qt(n,r,i)}}catch(n){if(n?.name===`AbortError`){H.get(e)===t&&H.delete(e),Yt(t);return}if(a={status:`error`,message:n?.message??String(n)},Kt(n?.status)){let e=Math.min(Wt*2**t.failures,Gt);Object.assign(t,{retryAt:Date.now()+e,failures:t.failures+1}),setTimeout(()=>{t.notify?.()},e)?.unref?.()}}a.status===`ready`&&(t.failures=0),t.state=a,Yt(t),Jt()}var en=new WeakMap,tn=0,nn=e=>(en.has(e)||en.set(e,++tn),en.get(e));function rn(e,t,n,r=!1){let i=Zt(e,t)?`${e.integrity}\0${t.integrity}\0${n??``}`:`${nn(e)}\0${nn(t)}\0${n??``}\0here`,a=H.get(i);return H.delete(i),(!a||r&&a.state.status===`error`||a.retryAt!==void 0&&Date.now()>=a.retryAt)&&(a={state:{status:`loading`},notify:a?.notify??null,waiting:[],failures:a?.failures??0},Xt&&!Zt(e,t)?a.state={status:`ready`,diff:Xt.prepareComparison(e,t,n??``)}:$t(i,a,e,t,n??``)),H.set(i,a),Jt(),a}function an(e,t,n,r){let i=rn(e,t,n);return i.notify=r,i.state}function on(e,t,n=null){return new Promise((r,i)=>{let a=(o=!1)=>{let s=rn(e,t,n,o),{state:c}=s;c.status===`loading`?s.waiting.push(()=>a()):c.status===`ready`?r(c.diff):i(Error(c.message))};a(!0)})}function sn(e,t){let{head:n,from:i,to:a,tail:o}=r(e,t);return z`${n}{<span class="bundle-compare-rename-from">${i}</span> → <span class="bundle-compare-rename-to">${a}</span>}${o}`}function cn({from:e,to:t}){return z`<span class="bundle-compare-rename-from">${e}</span> → <span class="bundle-compare-rename-to">${t}</span>`}function ln(e){let t=new Map;if(!e)return t;for(let n of e.onlyBase)t.set(n.path,{kind:`removed`,basePath:n.basePath,baseBytes:n.bytes,otherBytes:null});for(let n of e.onlyOther)t.set(n.path,{kind:`added`,baseBytes:null,otherBytes:n.bytes});for(let n of e.changed){let e={...n.meta?{meta:n.meta}:{}};t.set(n.path,n.renamedFrom==null?{kind:`changed`,basePath:n.basePath,baseBytes:n.baseBytes,otherBytes:n.otherBytes,...n.modified===!1?{modified:!1}:{},...e}:{kind:`renamed`,basePath:n.basePath,renamedFrom:n.renamedFrom,modified:n.modified,baseBytes:n.baseBytes,otherBytes:n.otherBytes,...e})}return t}function U(e,t,n,{kind:r,basePath:i=n}){let a=r===`added`?``:N(e).get(i),o=r===`removed`?``:N(t).get(n);return r===`repointed`&&(a=o??=a),{before:a,after:o}}var un=new WeakMap,dn=Object.freeze([]);function fn(e){if(!e)return dn;let t=un.get(e);return t||un.set(e,t=[...e.onlyBase,...e.onlyOther,...e.changed]),t}function pn(e){return e.baseTarget===null?`added`:e.otherTarget===null?`removed`:`repointed`}function mn(e,t,n,r=[]){let i=ln(n);if(!n)return i;for(let n of r){if(!i.has(n.parent)){let r=P(N(t).get(n.parent)??N(e).get(n.parent));i.set(n.parent,{kind:`repointed`,baseBytes:r,otherBytes:r})}let r=i.get(n.parent);r.repointed=[...r.repointed??[],n]}return i}function hn(e,t,n){return[...mn(e,t,n.files,fn(n.resolutions))].map(([n,r])=>({path:n,...r,...U(e,t,n,r)}))}function gn(e,{maxBytes:t,maxLines:n}){let r=0,i=0;for(let{before:a,after:o}of e)for(let e of[a,o])if(r+=P(e)??0,r>=t||(typeof e==`string`&&e!==``&&(i+=(e.match(/\n/gu)?.length??0)+ +!e.endsWith(`
|
|
2
|
+
`)),i>=n))return!1;return!0}var _n=3,W=20,vn=4;function yn(e,t,{ignoreWhitespace:n=!1,changes:r=null,marks:i=null}={}){let a=k(e),o=k(t),s=r?.blocks??A(e,t,n),c={a:e!==``&&!e.endsWith(`
|
|
5
3
|
`),b:t!==``&&!t.endsWith(`
|
|
6
|
-
`)};return{a,b:o,blocks:s,...
|
|
4
|
+
`)};return{a,b:o,blocks:s,...bn(s,i),noEol:c,words:new Map}}function bn(e,t){let n=new Set((t??[]).map(({a0:e,a1:t,b0:n,b1:r})=>`${e},${t},${n},${r}`)),r=new Set,i=0,a=0,o=0;return e.forEach(({a0:e,a1:t,b0:s,b1:c},l)=>{n.has(`${e},${t},${s},${c}`)&&t-e===c-s?(r.add(l),o+=c-s):(i+=c-s,a+=t-e)}),{additions:i,deletions:a,renamed:o,marked:r}}function xn(e,t,{runs:n,otherRuns:r}){let i=(e,t)=>{let n=[],r=k(e);for(let[e,i]of t)for(let t=e;t<Math.min(i,r.length);t++)n.push(t);let i=n.map(e=>r[e]),a=new Set(n),o=e!==``&&!e.endsWith(`
|
|
7
5
|
`)&&n.at(-1)===r.length-1;return{text:i.length===0?``:`${i.join(`
|
|
8
6
|
`)}${o?``:`
|
|
9
7
|
`}`,lineOf:n,lines:r.length,run:i.join(`
|
|
10
8
|
`),types:r.filter((e,t)=>!a.has(t)).join(`
|
|
11
|
-
`)}},a=i(e,n),o=i(t,r);return a.types===o.types||a.run===o.run?null:{before:a.text,after:o.text,lineOf:{a:a.lineOf,b:o.lineOf},lines:{a:a.lines,b:o.lines}}}function
|
|
9
|
+
`)}},a=i(e,n),o=i(t,r);return a.types===o.types||a.run===o.run?null:{before:a.text,after:o.text,lineOf:{a:a.lineOf,b:o.lineOf},lines:{a:a.lines,b:o.lines}}}function Sn(e,{lineOf:t,lines:n}){let r={a:0,b:0},i=[],a=e=>{let[t,n]=[`a`,`b`].map(t=>e[t]>r[t]?{from:r[t],to:e[t]}:null);(t||n)&&i.push({kind:`types`,a:t,b:n}),r.a=Math.max(r.a,e.a),r.b=Math.max(r.b,e.b)};for(let[n,o]of e.entries()){let s=o.kind===`change`?{a:o.left,b:o.right}:o,c=null;if(o.kind===`del`&&e[n-1]?.kind!==`del`){let r=n+1;for(;e[r]?.kind===`del`;)r++;e[r]?.kind===`add`&&(c=t.b[e[r].b])}let l={a:s.a==null?r.a:t.a[s.a],b:s.b==null?c??r.b:t.b[s.b]};a(l),s.a!=null&&(r.a=l.a+1),s.b!=null&&(r.b=l.b+1),i.push(o)}return a(n),i}var Cn=2e6,wn=2e4,Tn=e=>{let t=+(e!==``&&!e.endsWith(`
|
|
12
10
|
`));for(let n=e.indexOf(`
|
|
13
11
|
`);n!==-1;n=e.indexOf(`
|
|
14
|
-
`,n+1))t++;return t};function
|
|
15
|
-
`,1)[0])}function Pn(e,t=new Map,{context:n=e.typeFolds?1/0:vn,split:r=!1}={}){let{a:i,blocks:a}=e,o=[],s=0,c=0;for(let l=0;l<=a.length;l++){let u=a[l],d=(u?u.a0:i.length)-s,f=l===0,p=l===a.length,m=t.get(l),h=f?0:n+(m?.top??0),g=p?0:n+(m?.bottom??0);if(m?.all||d-h-g<yn)for(let e=0;e<d;e++)o.push({kind:`ctx`,a:s+e,b:c+e});else{for(let e=0;e<h;e++)o.push({kind:`ctx`,a:s+e,b:c+e});o.push({kind:`fold`,run:l,a:s+h,b:c+h,count:d-h-g,up:!p,down:!f});for(let e=d-g;e<d;e++)o.push({kind:`ctx`,a:s+e,b:c+e})}if(!u)break;let _=Ln(e,l);if(r)for(let[e,t,n]of _)o.push({kind:`change`,change:l,left:e,right:t,paired:n});else{let e=new Map,t=new Map;for(let[n,r,i]of _)i&&(e.set(n,r),t.set(r,n));for(let t=u.a0;t<u.a1;t++)o.push({kind:`del`,a:t,change:l,pair:e.get(t)??null});for(let e=u.b0;e<u.b1;e++)o.push({kind:`add`,b:e,change:l,pair:t.get(e)??null})}s=u.a1,c=u.b1}return e.typeFolds?Cn(o,e.typeFolds):o}function Fn(e,t){return In(e.a,e.b,t)}function In(e,n,r){let i=t(e.slice(r.a0,r.a1),n.slice(r.b0,r.b1)).map(([e,t])=>[r.a0+e,r.b0+t]),a=[],o=r.a0,s=r.b0;for(let[e,t]of[...i,[r.a1,r.b1]]){for(;o<e||s<t;)a.push([o<e?o++:null,s<t?s++:null,!1]);e<r.a1&&(a.push([e,t,!0]),o=e+1,s=t+1)}return a}function Ln(e,t){return e.aligned??=new Map,e.aligned.has(t)||e.aligned.set(t,Fn(e,e.blocks[t])),e.aligned.get(t)}function Rn(e,t,n=`<mark class="diff-word">`,r=`</mark>`){if(!t||t.length===0)return e;let i=!1,a=``,o=0,s=0,c=()=>{for(;s<t.length&&o>=t[s][1];)i&&=(a+=r,!1),s++};for(let l=0;l<e.length;){if(c(),e[l]===`<`){let t=e.indexOf(`>`,l),o=t===-1?e.slice(l):e.slice(l,t+1);a+=i?r+o+n:o,l+=o.length;continue}!i&&s<t.length&&o>=t[s][0]&&(a+=n,i=!0);let u=e[l]===`&`?e.indexOf(`;`,l):-1,d=u===-1||u-l>10?e[l]:e.slice(l,u+1);a+=d,l+=d.length,o++}return c(),i?a+r:a}function zn(e,t){if(!t||t.length===0)return[{text:e,marked:!1}];let n=[],r=0;for(let[i,a]of t)i>r&&n.push({text:e.slice(r,i),marked:!1}),a>i&&n.push({text:e.slice(i,a),marked:!0}),r=a;return r<e.length&&n.push({text:e.slice(r),marked:!1}),n}var Bn=100,Vn=20;function G(e,t,n=Vn,r=0,i=e.length){let a=[];for(let o=r;o<Math.min(i,e.length)&&a.length<n;o++){let n=t.ranges(e[o]);n.length>0&&a.push({line:o,text:e[o],ranges:n})}return a}var Hn=(e,t,n,r)=>In(e,t,r);function Un(e,t,n,r,{split:i=!1,align:a=Hn}={}){return e===t?G(H(t),n).map(e=>({...e,side:`b`,sign:` `})):e===``?G(H(t),n).map(e=>({...e,side:`b`,sign:`+`})):t===``?G(H(e),n).map(e=>({...e,side:`a`,sign:`−`})):Wn(H(e),H(t),n,r,i,a)}function Wn(e,t,n,r,i,a){let o=G(t,n);if(!r)return o.map(e=>({...e,side:`b`,sign:null}));let s=(e,t)=>{let[n,i]=e===`a`?[`a0`,`a1`]:[`b0`,`b1`],a=r.length,o=0;for(;o<a;){let e=o+a>>1;r[e][i]<=t?o=e+1:a=e}return o<r.length&&r[o][n]<=t?r[o]:null},c=[];for(let{a0:t,a1:i}of r){if(c.length===Vn)break;c.push(...G(e,n,Vn-c.length,t,i))}let l=new Map;if(i){let n=new Set([...o.map(({line:e})=>s(`b`,e)),...c.map(({line:e})=>s(`a`,e))]);for(let i of n)i&&a(e,t,r,i).forEach(([e,t],n)=>{e!==null&&l.set(`a${e}`,n),t!==null&&l.set(`b${t}`,n)})}let u=e=>{let t=s(e.side,e.line);return t?i?[t.b0,0,l.get(`${e.side}${e.line}`),e.side===`a`?0:1]:e.side===`a`?[t.b0,0,0,e.line]:[e.line,1,0,0]:[e.line,1,0,0]};return[...o.map(e=>({...e,side:`b`,sign:s(`b`,e.line)?`+`:` `})),...c.map(e=>({...e,side:`a`,sign:`−`}))].toSorted((e,t)=>{let n=u(e),r=u(t);return n[0]-r[0]||n[1]-r[1]||n[2]-r[2]||n[3]-r[3]}).slice(0,Vn)}function Gn(e,t,n,{split:r=!1,align:i=Hn}={}){let a=[],o=0,s=e=>e!==``&&t.ranges(e).length>0;for(let{path:c,before:l,after:u}of e){if(typeof l!=`string`||typeof u!=`string`||!s(l)&&(l===u||!s(u)))continue;let e;if(l===u||l===``||u===``)e=Un(l,u,t,null);else{let a=H(l),o=H(u),s=n(c,l,u);if(s?.length===0)continue;e=Wn(a,o,t,s,r,i)}if(e.length!==0){if(a.length===Bn)return{files:a,hits:o,truncated:!0};a.push({path:c,hits:e}),o+=e.length}}return{files:a,hits:o,truncated:!1}}var Kn=2,qn=5e3,Jn=3e5,Yn=new Set([`ts`,`mts`,`cts`]),Xn=e=>e!==501&&!(e>=400&&e<500&&e!==429),Zn=e=>e?.integrity===`(empty)`,Qn=(e,t)=>ot(e,t)||Zn(e)&&!!t?.npm,$n=(e,t)=>`${e??``}\0${t??``}`,K=new Map,er=new Map;function tr(){for(let[e,t]of K){if(K.size<=Kn)break;t.ended&&K.delete(e)}}async function nr(e,t,n){if(t===null)return n===null;let r=typeof t==`string`?A(e).get(t):void 0;return typeof r==`string`&&n===await(e.fileHashes?.get(t)??Dt(r))}var rr=(e,t)=>Array.isArray(e)&&(t||e.length===0)&&e.every((t,n)=>Array.isArray(t)&&t.length===2&&t.every(Number.isSafeInteger)&&t[0]>=(n>0?e[n-1][1]:0)&&t[0]<t[1]);async function ir(e,t,n,r,i){let a=!1,o=new Map;try{let e=async({path:e,hash:t,otherPath:i,otherHash:a,runs:s,otherRuns:c})=>{if(e===void 0||i===void 0||(e??i)===null)return;let l=s===void 0&&c===void 0||rr(s,e!==null)&&rr(c,i!==null)&&{runs:s,otherRuns:c};l&&await nr(n,e,t)&&await nr(r,i,a)&&o.set($n(e,i),l)};await(n.npm?y(n.npm.name,n.npm.version,r.npm.version,e):Zn(n)?y(r.npm.name,r.npm.version,`(empty)`,e):v(n.managedId,r.managedId,e,{scope:i}))}catch(n){if(n?.name===`AbortError`){K.get(e)===t&&K.delete(e);return}a=Xn(n?.status)}if(Object.assign(t,{files:o,ended:!0}),a){let n=er.get(e)??0;er.set(e,n+1),setTimeout(()=>{K.get(e)===t&&(K.delete(e),t.notify?.())},Math.min(qn*2**n,Jn))?.unref?.()}else er.delete(e);t.notify?.(),tr()}function ar(e,t,n,{kind:r,basePath:i=n},{before:a,after:o},s,c=``){if(r===`repointed`||!Qn(e,t))return;let l=[r===`added`?null:i,r===`removed`?null:n];if(!l.every(e=>e===null||Yn.has(Ke(e)))||l[0]!==null&&a!==A(e).get(i)||l[1]!==null&&o!==A(t).get(n))return;let u=`${e.integrity}\0${t.integrity}\0${c}`,d=K.get(u);return K.delete(u),d||(d={files:new Map,notify:null,ended:!1},ir(u,d,e,t,c)),K.set(u,d),tr(),d.notify=s,d.files.get($n(...l))}function or(e,t){let n=t===void 0?`The bundle records no format for it now`:`The bundle loads it as ${t}`,r=e===void 0?`no format recorded before`:t===void 0?`${e} before`:`as ${e} before`,[i,a]=[yt.isResourceFormat(e),yt.isResourceFormat(t)];return`${n}, ${r}${i===a?``:i?`, carried as data before, run as code now`:`, run as code before, carried as data now`}`}function sr(e=[],t=!1){return e.map(({field:e,from:n,to:r})=>e===`format`?I`<span class="bundle-compare-code-meta">${t?`format`:`${n??`none`} \u2192 ${r??`none`}`}</span>`:I`<span class="${`bundle-compare-code-meta${r?``:` is-dropped`}`}">${e===`executable`?r?`+x`:`−x`:r?`new entry`:`entry`}</span>`)}var cr=(e=[])=>e.filter(({field:e,to:t})=>e===`format`||t).map(({field:e,from:t,to:n})=>({name:e===`format`?`${t??`none`} \u2192 ${n??`none`}`:e===`executable`?`+x`:`new entry`,severity:`high`}));function lr(e=[]){return e.map(({field:e,from:t,to:n})=>e===`format`?`${or(t,n)}.`:e===`executable`?n?`It is now executable.`:`It is no longer executable.`:n?`It is now an entry point of the bundle.`:`It is no longer an entry point of the bundle.`).join(` `)}var ur=[{kind:`changed`,label:`Modified`,letter:`M`},{kind:`renamed`,label:`Renamed`,letter:`→`},{kind:`added`,label:`Added`,letter:`A`},{kind:`removed`,label:`Removed`,letter:`D`},{kind:`repointed`,label:`Repointed`,letter:`R`}],dr=Object.fromEntries(ur.map(e=>[e.kind,e])),q=2e3,fr=1e5,pr=16777216,mr=24,hr=3,gr=300,_r=30,vr=[{mode:`files`,label:`Filter files`,placeholder:`Filter changed files`,icon:se},{mode:`code`,label:`Search code`,placeholder:`Search changed code`,icon:ue}],yr=W/2,br=65536,xr=new WeakSet,Sr={large:`A large diff, not shown yet: the lines it removed aren't searched.`,printed:`Shown pretty-printed: its lines as published, unsigned, the lines it removed not searched.`,numbered:`Shown pretty-printed: its lines numbered as published.`},Cr={"+":{name:`add`,label:`Added`},"−":{name:`del`,label:`Removed`}," ":{name:`ctx`,label:`Unchanged`}},J={layout:`unified`,ignoreWhitespace:!1,ignoreRenames:!1,ignoreTypes:!1},wr=()=>`${J.ignoreWhitespace}\0${J.ignoreRenames}`,Tr=`Hide renamed names`,Er=`Hide type-only changes`,Dr=`Hide whitespace changes`,Or=e=>`${Ue(e)?E.bundleSourcePretty:!!E.bundleSourcePretty}\0${J.ignoreWhitespace}\0${J.ignoreRenames}\0${J.ignoreTypes}`,kr=({pretty:e,spacesHidden:t,hiding:n,typesHidden:r,typesFolded:i})=>[e?.status===`ready`&&`Pretty-print`,t&&Dr,n&&Tr,(r||i)&&Er].filter(Boolean),Ar={mixed:`Whitespace changes are shown: hiding them would hide blanks of more than one kind changing.`},jr=(e,t)=>e?.kind===`stasis`?e.bundle?.formats?.get(t):void 0,Mr=e=>/\.[cm]?js$/iu.test(e),Nr=(e,{ignoreRenames:t}=J)=>t&&Mr(e),Pr=(e,t,n)=>Xe(e,t,n).category===`minified`,Fr=`A license file`,Ir=new WeakMap;function Lr(e){let t=Ir.get(e);if(t)return t;t=new Map;let n=(e,n,r)=>{e&&t.set(e,[...t.get(e)??[],{label:n,note:r}])};if(e?.kind===`stasis`)for(let t of e.bundle?.entries??[])n(t,`entry`,`An entry point of the bundle`);let r=e?.npm?.manifest;if(r){let t=new Set(A(e).keys());for(let e of[`main`,`module`,`types`])typeof r[e]==`string`&&n(S(r[e],t),e,`package.json "${e}": ${r[e]}`);for(let[e,i]of Object.entries(r.bin??{}))typeof i==`string`&&n(S(i,t),`bin`,`package.json "bin" ${e}: ${i}`);let i=Map.groupBy(typeof r.license==`string`?w(r.license,[...t]).filter(e=>e.file):[],e=>e.file);for(let e of t)te.test(e)&&n(e,`license`,i.has(e)?`License: ${i.get(e).map(e=>e.text).join(`, `)}`:Fr)}else for(let t of A(e).keys())te.test(t.slice(t.lastIndexOf(`/`)+1))&&n(t,`license`,Fr);return Ir.set(e,t),t}var Rr=/(?:^|\/)package\.json$/u,zr=new WeakMap;function Br(e,t,n){let r=zr.get(e);return r||zr.set(e,r=new Map),r.has(t)||r.set(t,b(n,A(e).has(`${t.slice(0,-12)}binding.gyp`))),r.get(t)}var Vr={unparsed:`the file couldn't be parsed`,dynamic:`the file reads names by their spelling (eval or with)`,jsx:`the file holds JSX`,"block-function":`the file declares a function in a block outside strict code`,unverified:`the old side with the new names couldn't be checked to read as before`},Hr=e=>`Renamed names are hidden, though the file reads ${e.map(e=>`.${e}`).join(`, `)}, which a rename may change.`,Ur=(e,t,n=J)=>`${e}\0${n.ignoreWhitespace}\0${Nr(e,n)}\0${!!n.markRenames}\0${t}`,Wr=new Map,Gr=new Set,Kr=new WeakMap,qr=new WeakMap;function Jr(e,{before:t,after:n}){let r=qr.get(e);return r?.before===t&&r.after===n||qr.set(e,r={before:t,after:n,folds:Sn(t,n,e)}),r.folds}var Yr=(e,t,n)=>(e.typeFolds?.lineOf[t][n]??n)+1;function Xr(e){let t=0;for(let n=e.indexOf(`
|
|
12
|
+
`,n+1))t++;return t};function En(e,t){if(typeof e!=`string`||typeof t!=`string`)return null;if(e===t)return{additions:0,deletions:0};if(e===``)return{additions:Tn(t),deletions:0};if(t===``)return{additions:0,deletions:Tn(e)};if(e.length+t.length>Cn||Tn(e)+Tn(t)>wn)return null;let n=0,r=0;for(let{a0:i,a1:a,b0:o,b1:s}of A(e,t))n+=s-o,r+=a-i;return{additions:n,deletions:r}}var Dn=(e,t,n=A(e,t,!0))=>!$e(e,t,n);function On(e,t){let r=A(e,t,!0);return{hides:Dn(e,t,r),mixed:n(e,t,r)}}var kn=new Set([`module`,`commonjs`,`module-typescript`,`commonjs-typescript`,`json`,`solidity`,`php`,`shell`,`rust`,`java`,`kotlin`,`gradle`,`objc`,`objcpp`,`swift`,`c`,`cpp`,`c-header`,`cpp-header`,`xml`,`cmake`,`pbxproj`]),An=/\.(?:[cm]?js|jsx|[cm]?ts|tsx|json5?|jsonc|css|scss|less|html?|xhtml|xml|svg|c|h|cc|cpp|cxx|hh|hpp|hxx|java|kts?|go|rs|cs|swift|php|sh|bash|zsh)$/u,jn=new Set([`#!/usr/bin/env node`,`#! /usr/bin/env node`,`#!/usr/bin/node`,`#!/usr/local/bin/node`,`#!/usr/bin/env nodejs`,`#!/usr/bin/env deno`,`#!/usr/bin/env bun`,`#!/bin/sh`,`#! /bin/sh`,`#!/bin/sh -e`,`#!/usr/bin/env sh`,`#!/bin/bash`,`#! /bin/bash`,`#!/bin/bash -e`,`#!/usr/bin/env bash`,`#!/bin/zsh`,`#!/usr/bin/env zsh`,`#!/bin/dash`]);function Mn(e,t=``,n=void 0){return typeof n==`string`?kn.has(n):An.test(e.toLowerCase())||typeof t==`string`&&jn.has(t.split(`
|
|
13
|
+
`,1)[0])}function Nn(e,t=new Map,{context:n=e.typeFolds?1/0:_n,split:r=!1}={}){let{a:i,blocks:a}=e,o=[],s=0,c=0;for(let l=0;l<=a.length;l++){let u=a[l],d=(u?u.a0:i.length)-s,f=l===0,p=l===a.length,m=t.get(l),h=f?0:n+(m?.top??0),g=p?0:n+(m?.bottom??0);if(m?.all||d-h-g<vn)for(let e=0;e<d;e++)o.push({kind:`ctx`,a:s+e,b:c+e});else{for(let e=0;e<h;e++)o.push({kind:`ctx`,a:s+e,b:c+e});o.push({kind:`fold`,run:l,a:s+h,b:c+h,count:d-h-g,up:!p,down:!f});for(let e=d-g;e<d;e++)o.push({kind:`ctx`,a:s+e,b:c+e})}if(!u)break;let _=In(e,l);if(r)for(let[e,t,n]of _)o.push({kind:`change`,change:l,left:e,right:t,paired:n});else{let e=new Map,t=new Map;for(let[n,r,i]of _)i&&(e.set(n,r),t.set(r,n));for(let t=u.a0;t<u.a1;t++)o.push({kind:`del`,a:t,change:l,pair:e.get(t)??null});for(let e=u.b0;e<u.b1;e++)o.push({kind:`add`,b:e,change:l,pair:t.get(e)??null})}s=u.a1,c=u.b1}return e.typeFolds?Sn(o,e.typeFolds):o}function Pn(e,t){return Fn(e.a,e.b,t)}function Fn(e,n,r){let i=t(e.slice(r.a0,r.a1),n.slice(r.b0,r.b1)).map(([e,t])=>[r.a0+e,r.b0+t]),a=[],o=r.a0,s=r.b0;for(let[e,t]of[...i,[r.a1,r.b1]]){for(;o<e||s<t;)a.push([o<e?o++:null,s<t?s++:null,!1]);e<r.a1&&(a.push([e,t,!0]),o=e+1,s=t+1)}return a}function In(e,t){return e.aligned??=new Map,e.aligned.has(t)||e.aligned.set(t,Pn(e,e.blocks[t])),e.aligned.get(t)}function Ln(e,t,n=`<mark class="diff-word">`,r=`</mark>`){if(!t||t.length===0)return e;let i=!1,a=``,o=0,s=0,c=()=>{for(;s<t.length&&o>=t[s][1];)i&&=(a+=r,!1),s++};for(let l=0;l<e.length;){if(c(),e[l]===`<`){let t=e.indexOf(`>`,l),o=t===-1?e.slice(l):e.slice(l,t+1);a+=i?r+o+n:o,l+=o.length;continue}!i&&s<t.length&&o>=t[s][0]&&(a+=n,i=!0);let u=e[l]===`&`?e.indexOf(`;`,l):-1,d=u===-1||u-l>10?e[l]:e.slice(l,u+1);a+=d,l+=d.length,o++}return c(),i?a+r:a}function Rn(e,t){if(!t||t.length===0)return[{text:e,marked:!1}];let n=[],r=0;for(let[i,a]of t)i>r&&n.push({text:e.slice(r,i),marked:!1}),a>i&&n.push({text:e.slice(i,a),marked:!0}),r=a;return r<e.length&&n.push({text:e.slice(r),marked:!1}),n}var zn=100,Bn=20;function Vn(e,t,n=Bn,r=0,i=e.length){let a=[];for(let o=r;o<Math.min(i,e.length)&&a.length<n;o++){let n=t.ranges(e[o]);n.length>0&&a.push({line:o,text:e[o],ranges:n})}return a}var Hn=(e,t,n,r)=>Fn(e,t,r);function Un(e,t,n,r,{split:i=!1,align:a=Hn}={}){return e===t?Vn(k(t),n).map(e=>({...e,side:`b`,sign:` `})):e===``?Vn(k(t),n).map(e=>({...e,side:`b`,sign:`+`})):t===``?Vn(k(e),n).map(e=>({...e,side:`a`,sign:`−`})):Wn(k(e),k(t),n,r,i,a)}function Wn(e,t,n,r,i,a){let o=Vn(t,n);if(!r)return o.map(e=>({...e,side:`b`,sign:null}));let s=(e,t)=>{let[n,i]=e===`a`?[`a0`,`a1`]:[`b0`,`b1`],a=r.length,o=0;for(;o<a;){let e=o+a>>1;r[e][i]<=t?o=e+1:a=e}return o<r.length&&r[o][n]<=t?r[o]:null},c=[];for(let{a0:t,a1:i}of r){if(c.length===Bn)break;c.push(...Vn(e,n,Bn-c.length,t,i))}let l=new Map;if(i){let n=new Set([...o.map(({line:e})=>s(`b`,e)),...c.map(({line:e})=>s(`a`,e))]);for(let i of n)i&&a(e,t,r,i).forEach(([e,t],n)=>{e!==null&&l.set(`a${e}`,n),t!==null&&l.set(`b${t}`,n)})}let u=e=>{let t=s(e.side,e.line);return t?i?[t.b0,0,l.get(`${e.side}${e.line}`),e.side===`a`?0:1]:e.side===`a`?[t.b0,0,0,e.line]:[e.line,1,0,0]:[e.line,1,0,0]};return[...o.map(e=>({...e,side:`b`,sign:s(`b`,e.line)?`+`:` `})),...c.map(e=>({...e,side:`a`,sign:`−`}))].toSorted((e,t)=>{let n=u(e),r=u(t);return n[0]-r[0]||n[1]-r[1]||n[2]-r[2]||n[3]-r[3]}).slice(0,Bn)}function Gn(e,t,n,{split:r=!1,align:i=Hn}={}){let a=[],o=0,s=e=>e!==``&&t.ranges(e).length>0;for(let{path:c,before:l,after:u}of e){if(typeof l!=`string`||typeof u!=`string`||!s(l)&&(l===u||!s(u)))continue;let e;if(l===u||l===``||u===``)e=Un(l,u,t,null);else{let a=k(l),o=k(u),s=n(c,l,u);if(s?.length===0)continue;e=Wn(a,o,t,s,r,i)}if(e.length!==0){if(a.length===zn)return{files:a,hits:o,truncated:!0};a.push({path:c,hits:e}),o+=e.length}}return{files:a,hits:o,truncated:!1}}var Kn=2,qn=5e3,Jn=3e5,Yn=new Set([`ts`,`mts`,`cts`]),Xn=e=>e!==501&&!(e>=400&&e<500&&e!==429),Zn=e=>e?.integrity===`(empty)`,Qn=(e,t)=>s(e,t)||Zn(e)&&!!t?.npm,$n=(e,t)=>`${e??``}\0${t??``}`,G=new Map,er=new Map;function tr(){for(let[e,t]of G){if(G.size<=Kn)break;t.ended&&G.delete(e)}}async function nr(e,t,n){if(t===null)return n===null;let r=typeof t==`string`?N(e).get(t):void 0;return typeof r==`string`&&n===await(e.fileHashes?.get(t)??Ot(r))}var rr=(e,t)=>Array.isArray(e)&&(t||e.length===0)&&e.every((t,n)=>Array.isArray(t)&&t.length===2&&t.every(Number.isSafeInteger)&&t[0]>=(n>0?e[n-1][1]:0)&&t[0]<t[1]);async function ir(e,t,n,r,i){let a=!1,o=new Map;try{let e=async({path:e,hash:t,otherPath:i,otherHash:a,runs:s,otherRuns:c})=>{if(e===void 0||i===void 0||(e??i)===null)return;let l=s===void 0&&c===void 0||rr(s,e!==null)&&rr(c,i!==null)&&{runs:s,otherRuns:c};l&&await nr(n,e,t)&&await nr(r,i,a)&&o.set($n(e,i),l)};await(n.npm?T(n.npm.name,n.npm.version,r.npm.version,e):Zn(n)?T(r.npm.name,r.npm.version,`(empty)`,e):C(n.managedId,r.managedId,e,{scope:i}))}catch(n){if(n?.name===`AbortError`){G.get(e)===t&&G.delete(e);return}a=Xn(n?.status)}if(Object.assign(t,{files:o,ended:!0}),a){let n=er.get(e)??0;er.set(e,n+1),setTimeout(()=>{G.get(e)===t&&(G.delete(e),t.notify?.())},Math.min(qn*2**n,Jn))?.unref?.()}else er.delete(e);t.notify?.(),tr()}function ar(e,t,n,{kind:r,basePath:i=n},{before:a,after:o},s,c=``){if(r===`repointed`||!Qn(e,t))return;let l=[r===`added`?null:i,r===`removed`?null:n];if(!l.every(e=>e===null||Yn.has(Qe(e)))||l[0]!==null&&a!==N(e).get(i)||l[1]!==null&&o!==N(t).get(n))return;let u=`${e.integrity}\0${t.integrity}\0${c}`,d=G.get(u);return G.delete(u),d||(d={files:new Map,notify:null,ended:!1},ir(u,d,e,t,c)),G.set(u,d),tr(),d.notify=s,d.files.get($n(...l))}function or(e,t){let n=t===void 0?`The bundle records no format for it now`:`The bundle loads it as ${t}`,r=e===void 0?`no format recorded before`:t===void 0?`${e} before`:`as ${e} before`,[i,a]=[bt.isResourceFormat(e),bt.isResourceFormat(t)];return`${n}, ${r}${i===a?``:i?`, carried as data before, run as code now`:`, run as code before, carried as data now`}`}function sr(e=[],t=!1){return e.map(({field:e,from:n,to:r})=>e===`format`?z`<span class="bundle-compare-code-meta">${t?`format`:`${n??`none`} \u2192 ${r??`none`}`}</span>`:z`<span class="${`bundle-compare-code-meta${r?``:` is-dropped`}`}">${e===`executable`?r?`+x`:`−x`:r?`new entry`:`entry`}</span>`)}var cr=(e=[])=>e.filter(({field:e,to:t})=>e===`format`||t).map(({field:e,from:t,to:n})=>({name:e===`format`?`${t??`none`} \u2192 ${n??`none`}`:e===`executable`?`+x`:`new entry`,severity:`high`}));function lr(e=[]){return e.map(({field:e,from:t,to:n})=>e===`format`?`${or(t,n)}.`:e===`executable`?n?`It is now executable.`:`It is no longer executable.`:n?`It is now an entry point of the bundle.`:`It is no longer an entry point of the bundle.`).join(` `)}var ur=[{kind:`changed`,label:`Modified`,letter:`M`},{kind:`renamed`,label:`Renamed`,letter:`→`},{kind:`added`,label:`Added`,letter:`A`},{kind:`removed`,label:`Removed`,letter:`D`},{kind:`repointed`,label:`Repointed`,letter:`R`}],dr=Object.fromEntries(ur.map(e=>[e.kind,e])),K=2e3,fr=1e5,pr=16777216,mr=24,hr=3,gr=300,_r=30,vr=[{mode:`files`,label:`Filter files`,placeholder:`Filter changed files`,icon:le},{mode:`code`,label:`Search code`,placeholder:`Search changed code`,icon:pe}],yr=W/2,br=65536,xr=new WeakSet,Sr={large:`A large diff, not shown yet: the lines it removed aren't searched.`,printed:`Shown pretty-printed: its lines as published, unsigned, the lines it removed not searched.`,numbered:`Shown pretty-printed: its lines numbered as published.`},Cr={"+":{name:`add`,label:`Added`},"−":{name:`del`,label:`Removed`}," ":{name:`ctx`,label:`Unchanged`}},q={layout:`unified`,ignoreWhitespace:!1,ignoreRenames:!1,ignoreTypes:!1},wr=()=>`${q.ignoreWhitespace}\0${q.ignoreRenames}`,Tr=`Hide renamed names`,Er=`Hide type-only changes`,Dr=`Hide whitespace changes`,Or=e=>`${Ye(e)?j.bundleSourcePretty:!!j.bundleSourcePretty}\0${q.ignoreWhitespace}\0${q.ignoreRenames}\0${q.ignoreTypes}`,kr=({pretty:e,spacesHidden:t,hiding:n,typesHidden:r,typesFolded:i})=>[e?.status===`ready`&&`Pretty-print`,t&&Dr,n&&Tr,(r||i)&&Er].filter(Boolean),Ar={mixed:`Whitespace changes are shown: hiding them would hide blanks of more than one kind changing.`},jr=(e,t)=>e?.kind===`stasis`?e.bundle?.formats?.get(t):void 0,Mr=e=>/\.[cm]?js$/iu.test(e),Nr=(e,{ignoreRenames:t}=q)=>t&&Mr(e),Pr=(e,t,n)=>rt(e,t,n).category===`minified`,Fr=`A license file`,Ir=new WeakMap;function Lr(e){let t=Ir.get(e);if(t)return t;t=new Map;let n=(e,n,r)=>{e&&t.set(e,[...t.get(e)??[],{label:n,note:r}])};if(e?.kind===`stasis`)for(let t of e.bundle?.entries??[])n(t,`entry`,`An entry point of the bundle`);let r=e?.npm?.manifest;if(r){let t=new Set(N(e).keys());for(let e of[`main`,`module`,`types`])typeof r[e]==`string`&&n(se(r[e],t),e,`package.json "${e}": ${r[e]}`);for(let[e,i]of Object.entries(r.bin??{}))typeof i==`string`&&n(se(i,t),`bin`,`package.json "bin" ${e}: ${i}`);let i=Map.groupBy(typeof r.license==`string`?me(r.license,[...t]).filter(e=>e.file):[],e=>e.file);for(let e of t)ue.test(e)&&n(e,`license`,i.has(e)?`License: ${i.get(e).map(e=>e.text).join(`, `)}`:Fr)}else for(let t of N(e).keys())ue.test(t.slice(t.lastIndexOf(`/`)+1))&&n(t,`license`,Fr);return Ir.set(e,t),t}var Rr=/(?:^|\/)package\.json$/u,zr=new WeakMap;function Br(e,t,n){let r=zr.get(e);return r||zr.set(e,r=new Map),r.has(t)||r.set(t,ae(n,N(e).has(`${t.slice(0,-12)}binding.gyp`))),r.get(t)}var Vr={unparsed:`the file couldn't be parsed`,dynamic:`the file reads names by their spelling (eval or with)`,jsx:`the file holds JSX`,"block-function":`the file declares a function in a block outside strict code`,unverified:`the old side with the new names couldn't be checked to read as before`},Hr=e=>`Renamed names are hidden, though the file reads ${e.map(e=>`.${e}`).join(`, `)}, which a rename may change.`,Ur=(e,t,n=q)=>`${e}\0${n.ignoreWhitespace}\0${Nr(e,n)}\0${!!n.markRenames}\0${t}`,Wr=new Map,Gr=new Set,Kr=new WeakMap,qr=new WeakMap;function Jr(e,{before:t,after:n}){let r=qr.get(e);return r?.before===t&&r.after===n||qr.set(e,r={before:t,after:n,folds:xn(t,n,e)}),r.folds}var Yr=(e,t,n)=>(e.typeFolds?.lineOf[t][n]??n)+1;function Xr(e){let t=0;for(let n=e.indexOf(`
|
|
16
14
|
`);n!==-1;n=e.indexOf(`
|
|
17
15
|
`,n+1))t++;return t}var Zr=e=>e.printing?.applies?{...e.pretty??{status:`off`},json:e.printing.json}:null,Qr=5,$r=e=>e?e.length>Qr?`
|
|
18
16
|
Affects files: ${e.length.toLocaleString()}`:`
|
|
19
17
|
Affects files:
|
|
20
18
|
${e.join(`
|
|
21
|
-
`)}`:``,ei=(e,t)=>I`<span class="bundle-compare-code-counts" aria-label="${`${e} added, ${t} removed lines`}"><span class="add">+${e.toLocaleString()}</span><span class="del">−${t.toLocaleString()}</span></span>`,ti=(e,t,n)=>e.hideable??=On(t,n,e.blocks),Y=(e,t)=>e.length+t.length>pr||Xr(e)+Xr(t)>fr;function ni(e){let t=Map.groupBy(e,dn);return t.size===1&&t.has(`repointed`)?{title:`Repointed ${e.length===1?`import`:`imports`}`,note:`${e.length} repointed ${e.length===1?`import`:`imports`}`}:{title:`Import resolutions`,note:`Import resolutions: ${[`removed`,`added`,`repointed`].filter(e=>t.has(e)).map(e=>`${t.get(e).length} ${e}`).join(`, `)}`}}var ri=e=>e.kind===`repointed`||e.kind===`renamed`&&!e.modified&&!!e.repointed&&!e.meta,ii=e=>Array.isArray(e)?e.some(ii):e?.strings?e.strings.some(e=>e.trim()!==``)||e.values.some(ii):e!=null&&e!==L&&e!==!1&&e!==``,ai=new WeakMap;function oi(e,t){if(ai.has(e))return ai.get(e);let n=new Set;for(let e of t)for(let t=e.lastIndexOf(`/`);t>0&&!n.has(e.slice(0,t));t=e.lastIndexOf(`/`,t-1))n.add(e.slice(0,t));return ai.set(e,n),n}function si(e){let t=A(e);return oi(t,t.keys())}function ci(e,t){for(let n of e.files.values())if(n===t)return!0;for(let n of e.dirs.values())if(ci(n,t))return!0;return!1}var li=class extends At{static properties={base:{attribute:!1},other:{attribute:!1},files:{attribute:!1},scope:{attribute:!1},resolutions:{attribute:!1},baseAlerts:{attribute:!1},otherAlerts:{attribute:!1},alertTags:{attribute:!1},newHosts:{attribute:!1},newHostTag:{attribute:!1},dependencies:{attribute:!1},openDependency:{attribute:!1},dependencyTags:{attribute:!1},extensions:{attribute:!1},baseName:{},otherName:{},path:{},seek:{attribute:!1},_query:{state:!0},_kinds:{state:!0},_mode:{state:!0}};createRenderRoot(){return this}constructor(){super(),this.base=null,this.other=null,this.files=null,this.scope=``,this.resolutions=[],this.baseAlerts=null,this.otherAlerts=null,this.alertTags=null,this.newHosts=null,this.newHostTag=null,this.extensions=null,this._treeLimit=300,this._treeRemaining=1/0,this.path=null,this._query=``,this._kinds=new Set(ur.map(e=>e.kind)),this._mode=`files`,this._blocks=new Map,this._found=null,this._rowless=new Map,this._rowlessCount=0,this._aligned=new WeakMap,this._sought=null,this._soughtRow=null,this._open=new Map,this._models=new Map,this._modelCap=mr,this._counted=new Map,this._countModels=new Map,this._drawnCounts=new Map,this._drawnTotals=new Map,this._spaced=new Map,this._shorter=new Map,this._larges=new Map,this._expansions=new Map,this._limits=new Map,this._forced=new Set,this._shownPath=null}willUpdate(e){let t=`${this.base?.integrity}|${this.other?.integrity}`;if((t!==this._pair||e.has(`files`))&&(this._pair=t,this._models.clear(),this._spaced.clear(),this._shorter.clear(),this._larges.clear(),this._expansions.clear(),this._limits.clear(),this._forced.clear()),[`files`,`resolutions`,`base`,`other`].some(t=>e.has(t))&&(this._entries=fn(this.base,this.other,this.files,this.resolutions??[]),this._counted=new Map,this._countModels=new Map,this._drawnCounts=new Map,this._drawnTotals=new Map,this._treeLimit=this.extensions?.treePageSize??1/0,this._blocks.clear(),this._rowless.clear(),this._sought=this._soughtRow=null,this._soughtSettling=!1),e.has(`seek`)&&this.seek&&!xr.has(this.seek)){xr.add(this.seek);let{path:e,line:t,query:n}=this.seek,r=this._entries?.get(e),i=r?V(this.base,this.other,e,r).after:null,a=typeof i==`string`?H(i)[t]?.toLowerCase().indexOf(n.toLowerCase())??-1:-1;this._sought={path:e,side:`b`,line:t,at:Math.max(a,0),query:n},this._soughtRow=null,this._soughtSettling=!1}}updated(){if(this._current!==this._shownPath){this._shownPath=this._current;let e=this.querySelector(`.bundle-compare-diff`);e&&(e.scrollTop=0),this.querySelector(`.bundle-compare-code-tree .bundle-code-tree-link.current`)?.scrollIntoView({block:`nearest`})}this._scrollSought()}_scrollSought(){if(this._sought?.path===this._current&&!this._soughtSettling&&(this._sought=null),!this._soughtRow)return;let{path:e,index:t}=this._soughtRow;this._soughtRow=null;let n=[...this.querySelectorAll(`.bundle-compare-diff-table`)].find(t=>t.dataset.path===e)?.children[t];if(!n)return;let r=n.closest(`.bundle-compare-diff`);n.scrollIntoView({block:r&&n.offsetHeight>r.clientHeight/2?`start`:`center`}),n.classList.remove(`is-sought`),n.offsetWidth,n.classList.add(`is-sought`),n.addEventListener(`animationend`,()=>n.classList.remove(`is-sought`),{once:!0})}_shown(e){return this._kinds.has(e.kind)||!!e.modified&&this._kinds.has(`changed`)||!!e.repointed&&this._kinds.has(`repointed`)}_modules(){let e=this.base?.kind===`stasis`?this.base.bundle?.modules:null,t=this.other?.kind===`stasis`?this.other.bundle?.modules:null,n={root:this.files?.root,paths:this.files?.basePaths??new Map};return e||t?new Map([...[...e??[]].map(([e,t])=>[i(n,e,Object.keys(t.files??{})),t]),...t??[]]):null}_baseDirs(){let e=this.files?.root?this.files.basePaths:null;return e?oi(e,e.values()):si(this.base)}_format(e){let t=this._entries.get(e),n=pt(this.base,t?.basePath??e),r=pt(this.other,e);return[n,r].find(ft)??(t?.kind===`removed`?n:r)}_tree(){let e=[this._entries,`${[...this._kinds].join()}:${!!this.extensions?.fullPaths}`];if(this._treeKey?.[0]===e[0]&&this._treeKey[1]===e[1])return this._treeMemo;let t=[...this._entries.keys()],n=this._modules(),r=a(this.files?.root,this.extensions?.fullPaths?``:Ee(St(t).prefix,n,t)),{prefix:i}=r,o=t.filter(e=>this._shown(this._entries.get(e))),s=we(o.map(e=>i&&e.startsWith(i)?e.slice(i.length):e),o,n);return this._treeKey=e,this._treeMemo={prefix:i,root:r,tree:s,shown:o.length,allOrder:Re(s)},this._treeMemo}_select(e){!e||e===this._current||this.extensions?.canSelect?.()===!1||this.dispatchEvent(new CustomEvent(`compare-code-select`,{detail:{path:e},bubbles:!0,composed:!0}))}_reveal(e,t){let n=(t&&e.startsWith(t)?e.slice(t.length):e).split(`/`);for(let e=1;e<n.length;e++)this._open.set(n.slice(0,e).join(`/`),!0)}_pathQuery(){return this._query.trim()}_railState(){let{prefix:e,root:t,tree:n,shown:r,allOrder:i}=this._tree(),a=Oe(n,this._mode===`files`?this._pathQuery():``,e,this.extensions?.fileFilter);return{prefix:e,root:t,tree:n,shown:r,filtered:a,order:a===n?i:a?Re(a):[],allOrder:i}}_renderRail({prefix:e,root:t,tree:n,shown:r,filtered:i,order:a},o){this._countUntil=null,this._treeRemaining=this.extensions?.treePageSize?this._treeLimit:1/0,this._treeTruncated=!1;let s=!!this._pathQuery()||r<=(this.extensions?.openAllMax??gr),c=this._mode===`code`?L:i?this._renderTree(i,o,0,s,s?null:Me(i)):I`<div class="bundle-code-search-empty">No changed files match.</div>`,l=Object.fromEntries(ur.map(({kind:e})=>[e,0]));for(let e of this._entries.values())e.kind!==`repointed`&&l[e.kind]++,e.modified&&l.changed++,e.repointed&&l.repointed++;let u=vr.find(({mode:e})=>e===this._mode);return I`<aside class="bundle-code-rail"><div class="bundle-code-rail-head"><span class="bundle-code-rail-label">${this.extensions?.railLabel??`Changes`}</span> <span class="bundle-code-rail-count">${this._entries.size.toLocaleString()}</span> <span class="bundle-code-rail-actions"><button type="button" class="bundle-code-rail-action" aria-label="${this.extensions?.collapseLabel??`Collapse directories`}" data-tooltip="Collapse directories" ?disabled="${this._mode!==`files`||!!this._pathQuery()&&!this.extensions?.collapseClearsSearch||n.dirs.size===0}" @click="${()=>this._collapseAll(n)}">${ae}</button></span></div>${t.from?I`<div class="bundle-code-rail-prefix mono" data-tooltip="${`Root moved: ${t.from} \u2192 ${t.to}`}">${on(t)}</div>`:e?I`<div class="bundle-code-rail-prefix mono" data-tooltip-truncated data-tooltip="${e}">${e}</div>`:L}<div class="bundle-compare-code-filter"><label class="bundle-compare-code-search"><svg viewBox="0 0 16 16" width="12" height="12" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" aria-hidden="true"><circle cx="7" cy="7" r="4.5"/><path d="m10.5 10.5 3.5 3.5"/></svg> <input type="search" placeholder="${this._mode===`files`?this.extensions?.searchPlaceholder??u.placeholder:u.placeholder}" aria-label="${this._mode===`files`?this.extensions?.searchLabel??u.placeholder:u.placeholder}" spellcheck="false" autocomplete="off" .value="${k(this._query)}" @input="${e=>{this._query=e.target.value,this._treeLimit=this.extensions?.treePageSize??1/0}}"> <span class="bundle-code-search-modes" role="tablist">${vr.map(({mode:e,label:t,icon:n})=>I`<button type="button" class="${N({"bundle-code-search-mode":!0,active:e===this._mode})}" role="tab" aria-selected="${String(e===this._mode)}" aria-label="${t}" data-tooltip="${t}" @click="${()=>{this._mode=e}}">${n}</button>`)}</span></label> ${this.extensions?.filters??I`<div class="bundle-compare-code-kinds" role="group" aria-label="Show changes">${ur.filter(({kind:e})=>l[e]>0).map(({kind:e,label:t})=>I`<button type="button" class="${`bundle-compare-code-kind ${e}`}" aria-pressed="${String(this._kinds.has(e))}" data-tooltip="${`${this._kinds.has(e)?`Hide`:`Show`} ${t.toLowerCase()} files`}" @click="${()=>this._toggleKind(e)}">${t.toLowerCase()}</button>`)}</div>`}</div><div class="bundle-code-rail-body bundle-compare-code-tree">${this._mode===`code`?this._renderSearch(a,o,e):c} ${this._mode===`files`&&this._treeTruncated?I`<button type="button" class="bundle-compare-code-action" @click="${()=>{this._treeLimit+=this.extensions.treePageSize,this.requestUpdate()}}">Show more files</button>`:L}</div>${this.extensions?.footer?.(e=>{this._query=``,this._select(e)})??L}</aside><bundle-code-splitter role="separator" tabindex="0" aria-orientation="vertical" aria-label="Resize file tree" data-tooltip="Drag to resize · double-click to reset"></bundle-code-splitter>`}_arrived=0;_renamesAlone=!0;_repaint=()=>{this._arrived++,this.isConnected&&this.requestUpdate()};disconnectedCallback(){super.disconnectedCallback(),clearTimeout(this._countLater),clearTimeout(this._searchLater),this._countLater=this._searchLater=null}render(){let e=this._railState(),t=this._entries.has(this.path)?this.path:e.order[0]??null;t&&t!==this._current&&this._reveal(t,e.prefix),this._current=t,this._order=this.extensions?.filterContent===!1?e.allOrder:e.order;let n=t?I`${this._renderFile(t,this.extensions?.fullPaths?``:e.prefix)}${this.extensions?.fileActions?.(t,!1)??L}`:I`<div class="bundle-code-placeholder">No files differ in this comparison.</div>`;return I`<div class="bundle-code-view bundle-compare-code">${this._renderRail(e,t)}<div class="bundle-code-main">${n}</div></div>`}_toggleKind(e){let t=new Set(this._kinds);t.has(e)?t.delete(e):t.add(e),this._kinds=t}_collapseAll(e){this.extensions?.collapseClearsSearch&&(this._query=``),this._treeLimit=this.extensions?.treePageSize??1/0;let t=e=>{for(let n of e.dirs.values())this._open.set(n.path,!1),t(n)};t(e),this.requestUpdate()}_renderSearch(e,t,n){if(!this._query)return I`<div class="bundle-code-search-hint">Type to search the code of the changed files.</div>`;let{files:r,hits:i,truncated:a,unsigned:o}=this._searchResults(e);if(r.length===0)return I`<div class="bundle-code-search-empty">No matches.</div>`;let s=e=>n&&e.startsWith(n)?e.slice(n.length):e;return I`<div class="bundle-code-search-results bundle-compare-search"><div class="bundle-code-search-summary">${i.toLocaleString()} ${i===1?`hit`:`hits`} in ${r.length.toLocaleString()} ${r.length===1?`file`:`files`}${a?`, the first ${Bn}`:``}</div>${F(r,e=>e.path,({path:e,hits:n})=>I`<div class="${N({"bundle-code-search-file":!0,current:e===t})}"><button type="button" class="${`bundle-code-search-file-name bundle-compare-code-name ${this._entries.get(e).kind}`}" data-tooltip-truncated data-tooltip="${e}" @click="${()=>this._select(e)}">${s(e)}</button> ${o.has(e)?I`<p class="bundle-compare-search-note">${Sr[o.get(e)]}</p>`:L}<ul class="bundle-code-search-hits">${n.map(t=>I`<li class="bundle-code-search-hit"><button type="button" class="bundle-code-search-hit-link" aria-label="${`${Cr[t.sign]?.label??`Line`} ${t.line+1}${t.side===`a`?` of the old text`:``}: ${t.text.trim().slice(0,80)}`}" @click="${()=>this._seek(e,t)}"><span class="bundle-code-search-hit-ln">${t.line+1}</span> <span class="${`bundle-compare-search-sign ${Cr[t.sign]?.name??``}`}" aria-hidden="true">${t.sign??``}</span> <span class="bundle-code-search-hit-text mono">${_(t.text,t.ranges)}</span></button></li>`)}</ul></div>`)}</div>`}_searchResults(e){let t=wr(),r=`${this._query}\0${this._forced.size}\0${t}\0${J.layout}\0${E.bundleSourcePretty}\0${f()}\0${this._rowlessCount}\0${e.join(`\0`)}`;if(this._found?.key===r&&this._found.entries===this._entries)return this._found.result;let i=null,a=!0,o=new Map,s={...Gn(e.flatMap(e=>{let n=this._entries.get(e);if(!this._searchable(n))return[];let r=V(this.base,this.other,e,n),{before:i,after:a}=r;if(this._prettyShown(e,n,r)){if(!/\S/u.test(this._query))return[];let n=i!==``&&a!==``&&i!==a;if(n&&this._rowless.get(e)===t)return[];o.set(e,n?`printed`:`numbered`)}return[{path:e,...r}]}),g(this._query,!1,!1),(e,t,r)=>{if(o.get(e)===`printed`)return null;let s=`${J.ignoreWhitespace}\0${e}`;if(this._blocks.has(s))return this._blocks.get(s);if(!this._forced.has(e)&&Y(t,r))return o.set(e,`large`),null;let c=performance.now();if(i??=c+_r,c>i)return a=!1,null;let l=J.ignoreWhitespace&&!this._unlisted(e,this._entries.get(e),{before:t,after:r}),u=U(t,r,l);return l&&n(t,r,u)&&(u=U(t,r)),this._blocks.set(s,u),u},{split:J.layout===`split`,align:(e,t,n,r)=>{let i=this._aligned.get(n);return i||this._aligned.set(n,i={a:e,b:t,blocks:n}),Ln(i,n.indexOf(r))}}),unsigned:o};return a?this._found={key:r,entries:this._entries,result:s}:this._searchLater??=setTimeout(()=>{this._searchLater=null,this.requestUpdate()}),s}_searchable(e){return e.modified!==!1||ri(e)}_prettyShown(e,t,n){if(!E.bundleSourcePretty)return!1;let r=this._printing(e,t,n);return!!r?.applies&&r.copies.status!==`error`}_noteRowless(e,t){let n=t?wr():void 0;this._rowless.get(e)!==n&&(n===void 0?this._rowless.delete(e):this._rowless.set(e,n),this._rowlessCount++)}_seek(e,t){this._sought={path:e,side:t.side,line:t.line,at:t.ranges[0]?.[0]??0,query:this._query},e===this._current?this.requestUpdate():this._select(e,!1)}_soughtLine(e,t,n,r){let{side:i,line:a,at:o,query:s}=this._sought;if(n?.status!==`ready`)return{side:i,line:a};let c=e=>e.replaceAll(/\s+/gu,``),l=H(V(this.base,this.other,e,t)[i===`a`?`before`:`after`]??``),u=l.slice(0,a).reduce((e,t)=>e+c(t).length,0)+c(l[a]?.slice(0,o)??``).length,d=c(s).toLowerCase(),f=(e,t)=>{if(!d)return null;let n=0,r=0,i=0,a=``;for(let o of e)for(let e=0;e<o.length;e+=br){a+=c(o.slice(e,e+br)).toLowerCase();for(let e=a.indexOf(d,n);e!==-1;e=a.indexOf(d,n),r++){if(t(r,i+e))return{index:r,start:i+e};n=e+d.length}let s=Math.max(n,a.length-d.length+1);a=a.slice(s),i+=s,n=Math.max(0,n-s)}return null},p=f(l,(e,t)=>t>=u),m=(p&&f(r[i],e=>e===p.index)?.start)??u;for(let e=0;e<r[i].length;e++)if(m-=c(r[i][e]).length,m<0)return{side:i,line:e};return null}_seekRows(e,t,{side:n,line:r},i){let a=t.typeFolds,o=a?a.lineOf[n].indexOf(r):r,s=e=>e.kind===`types`?o===-1&&!!e[n]&&r>=e[n].from&&r<e[n].to:n===`b`?(e.kind===`ctx`||e.kind===`add`)&&e.b===o||e.kind===`change`&&e.right===o:(e.kind===`ctx`||e.kind===`del`)&&e.a===o||e.kind===`change`&&e.left===o,c=this._expansions.get(e)??new Map,l=Pn(t,c,{split:i}),u=l.findIndex(s);if(u===-1){let r=l.find(e=>e.kind===`fold`&&o>=e[n]&&o<e[n]+e.count);if(r){let a=c.get(r.run)??{},d=o-r[n];c=new Map(c).set(r.run,r.down?{...a,top:(a.top??0)+d+1+yr}:r.up?{...a,bottom:(a.bottom??0)+r.count-d+yr}:{all:!0}),this._expansions.set(e,c),l=Pn(t,c,{split:i}),u=l.findIndex(s)}}let d=this._limits.get(e)??q;return u>=d&&this._limits.set(e,Math.ceil((u+1)/q)*q),{rows:l,index:u}}_takeTreeRow(e=!1){return this._treeRemaining-->0||(this._treeTruncated=!0,e)}_renderTree(e,t,n,i,a){let o=[...e.dirs.entries()].toSorted(Ie),s=[...e.files.entries()].toSorted(([e],[t])=>e.localeCompare(t)),c=o.flatMap(([e,r])=>{let o=Ae(e,r,n),s=r.package,c=s?.ecosystem===`cargo`||s?.ecosystem===`composer`||s?.ecosystem===`soldeer`,l=this._pathQuery()?!0:this._open.get(r.path)??(i||!!a?.has(r.path)||ci(r,t)),u=this._baseDirs().has(r.sourcePath)?si(this.other).has(r.sourcePath)?null:`removed`:`added`;if(!this._takeTreeRow(ci(r,t)))return[];let d=I`<li class="bundle-code-tree-dir"><details .open="${k(l)}" @toggle="${e=>{let t=e.currentTarget.open;this._open.get(r.path)!==t&&(this._open.set(r.path,t),this.extensions?.treePageSize&&this.requestUpdate())}}"><summary aria-label="${this.extensions?.directoryLabel?.(o.node)??L}"><span class="bundle-code-tree-chevron" aria-hidden="true"></span> ${s||r.dependencyRoot?ht(s?.ecosystem??r.dependencyRoot):L} <span class="${N({"bundle-code-tree-dirname":!0,"bundle-code-tree-package":!!s,"bundle-code-tree-package-vendored":c,"bundle-compare-code-name":!0,removed:u===`removed`})}" data-tooltip-truncated data-tooltip="${o.node.sourcePath}">${s?I`<span class="bundle-code-tree-package-name">${s.name}</span>${s.version?I`<span class="bundle-code-tree-package-version">${c?`- `:`@`}${s.version}</span>`:L}`:o.names.map((e,t)=>I`${t>0?I`<span class="bundle-code-tree-separator">/</span>`:L}${e}`)} </span>${s?.variant?I`<span class="bundle-code-tree-variant">variant ${s.variant}</span>`:L} <span class="bundle-compare-code-dir-count" data-tooltip="${`${r.fileCount} changed ${r.fileCount===1?`file`:`files`}`}">${this.extensions?.directorySummary?.(o.node)??r.fileCount}</span> ${u?I`<span class="${`bundle-compare-code-letter ${u}`}" data-tooltip="${`${s?`Package`:`Directory`} ${u}`}">${dr[u].letter}</span>`:L}</summary>${l||!this.extensions?.treePageSize?this._renderTree(o.node,t,n+1,i,a):L}</details></li>`;return[{key:r.path,content:d}]}),l=s.flatMap(([e,n])=>{if(!this._takeTreeRow(n===t))return[];let{kind:i,repointed:a,renamedFrom:o,modified:s}=this._entries.get(n),c=a?ni(a).note:``;return[{key:n,content:I`<li class="bundle-code-tree-file"><button type="button" class="${N({"bundle-code-tree-link":!0,current:n===t})}" aria-label="${this.extensions?.fileLabel?.(n)??L}" aria-current="${n===t?`true`:L}" @click="${()=>this._select(n)}">${this.extensions?.filePrefix?.(n)??L}${mt(n,this._format(n))}<span class="${`bundle-code-tree-name bundle-compare-code-name ${i}`}" data-tooltip-truncated data-tooltip="${n}">${e}</span> ${this.extensions?.fileSuffix?.(n)??L} ${o?I`<span class="bundle-compare-code-oldname" data-tooltip-truncated data-tooltip="${`Renamed from ${o}`}">← ${r(o,n,{extension:!1}).from}</span>`:L} ${this._fileTags(n,this._entries.get(n),!0)} ${this._treeCounts(n,this._entries.get(n))} ${a&&i!==`repointed`?I`<span class="bundle-compare-code-letter repointed" data-tooltip="${c}">R</span>`:L} <span class="${N({"bundle-compare-code-letter":!0,[i]:!0,pure:i===`renamed`&&!s})}" data-tooltip="${i===`repointed`?c:o?`Renamed${s?` and modified`:``} from ${o}`:dr[i].label}">${dr[i].letter}</span></button></li>`}]});return I`<ul class="${N({"bundle-code-tree":!0,root:n===0})}" aria-label="${n===0?this.extensions?.treeLabel??`Changed files`:L}" @keydown="${n===0?Pe:L}">${F(c,e=>e.key,e=>e.content)}${F(l,e=>e.key,e=>e.content)}</ul>`}_treeCounts(e,t){if(t.kind===`repointed`)return L;let n=this._lineCounts(e,t),r;if(n===null&&this._counted.has(e)?{published:n,shown:r}=this._largeCounts(e,t):r=n&&this._shownCounts(e,t),!(n||r)||r===void 0)return L;let{additions:i,deletions:a}=r??n,o=!n||n.additions>0||n.deletions>0,s=t.kind===`renamed`,c=r?.renamed>0?`
|
|
19
|
+
`)}`:``,ei=(e,t)=>z`<span class="bundle-compare-code-counts" aria-label="${`${e} added, ${t} removed lines`}"><span class="add">+${e.toLocaleString()}</span><span class="del">−${t.toLocaleString()}</span></span>`,ti=(e,t,n)=>e.hideable??=Dn(t,n,e.blocks),J=(e,t)=>e.length+t.length>pr||Xr(e)+Xr(t)>fr;function ni(e){let t=Map.groupBy(e,pn);return t.size===1&&t.has(`repointed`)?{title:`Repointed ${e.length===1?`import`:`imports`}`,note:`${e.length} repointed ${e.length===1?`import`:`imports`}`}:{title:`Import resolutions`,note:`Import resolutions: ${[`removed`,`added`,`repointed`].filter(e=>t.has(e)).map(e=>`${t.get(e).length} ${e}`).join(`, `)}`}}var ri=e=>e.kind===`repointed`||e.kind===`renamed`&&!e.modified&&!!e.repointed&&!e.meta,ii=e=>Array.isArray(e)?e.some(ii):e?.strings?e.strings.some(e=>e.trim()!==``)||e.values.some(ii):e!=null&&e!==B&&e!==!1&&e!==``,ai=new WeakMap;function oi(e,t){if(ai.has(e))return ai.get(e);let n=new Set;for(let e of t)for(let t=e.lastIndexOf(`/`);t>0&&!n.has(e.slice(0,t));t=e.lastIndexOf(`/`,t-1))n.add(e.slice(0,t));return ai.set(e,n),n}function si(e){let t=N(e);return oi(t,t.keys())}function ci(e,t){for(let n of e.files.values())if(n===t)return!0;for(let n of e.dirs.values())if(ci(n,t))return!0;return!1}var li=class extends jt{static properties={base:{attribute:!1},other:{attribute:!1},files:{attribute:!1},scope:{attribute:!1},resolutions:{attribute:!1},baseAlerts:{attribute:!1},otherAlerts:{attribute:!1},alertTags:{attribute:!1},newHosts:{attribute:!1},newHostTag:{attribute:!1},dependencies:{attribute:!1},openDependency:{attribute:!1},dependencyTags:{attribute:!1},extensions:{attribute:!1},baseName:{},otherName:{},path:{},seek:{attribute:!1},_query:{state:!0},_kinds:{state:!0},_mode:{state:!0}};createRenderRoot(){return this}constructor(){super(),this.base=null,this.other=null,this.files=null,this.scope=``,this.resolutions=[],this.baseAlerts=null,this.otherAlerts=null,this.alertTags=null,this.newHosts=null,this.newHostTag=null,this.extensions=null,this._treeLimit=300,this._treeRemaining=1/0,this.path=null,this._query=``,this._kinds=new Set(ur.map(e=>e.kind)),this._mode=`files`,this._blocks=new Map,this._found=null,this._rowless=new Map,this._rowlessCount=0,this._aligned=new WeakMap,this._sought=null,this._soughtRow=null,this._open=new Map,this._models=new Map,this._modelCap=mr,this._counted=new Map,this._countModels=new Map,this._drawnCounts=new Map,this._drawnTotals=new Map,this._spaced=new Map,this._shorter=new Map,this._unrebuilt=new Map,this._larges=new Map,this._expansions=new Map,this._limits=new Map,this._forced=new Set,this._shownPath=null}willUpdate(e){let t=`${this.base?.integrity}|${this.other?.integrity}`;if((t!==this._pair||e.has(`files`))&&(this._pair=t,this._models.clear(),this._spaced.clear(),this._shorter.clear(),this._unrebuilt.clear(),this._larges.clear(),this._expansions.clear(),this._limits.clear(),this._forced.clear()),[`files`,`resolutions`,`base`,`other`].some(t=>e.has(t))&&(this._entries=mn(this.base,this.other,this.files,this.resolutions??[]),this._counted=new Map,this._countModels=new Map,this._drawnCounts=new Map,this._drawnTotals=new Map,this._treeLimit=this.extensions?.treePageSize??1/0,this._blocks.clear(),this._rowless.clear(),this._sought=this._soughtRow=null,this._soughtSettling=!1),e.has(`seek`)&&this.seek&&!xr.has(this.seek)){xr.add(this.seek);let{path:e,line:t,query:n}=this.seek,r=this._entries?.get(e),i=r?U(this.base,this.other,e,r).after:null,a=typeof i==`string`?k(i)[t]?.toLowerCase().indexOf(n.toLowerCase())??-1:-1;this._sought={path:e,side:`b`,line:t,at:Math.max(a,0),query:n},this._soughtRow=null,this._soughtSettling=!1}}updated(){if(this._current!==this._shownPath){this._shownPath=this._current;let e=this.querySelector(`.bundle-compare-diff`);e&&(e.scrollTop=0),this.querySelector(`.bundle-compare-code-tree .bundle-code-tree-link.current`)?.scrollIntoView({block:`nearest`})}this._scrollSought()}_scrollSought(){if(this._sought?.path===this._current&&!this._soughtSettling&&(this._sought=null),!this._soughtRow)return;let{path:e,index:t}=this._soughtRow;this._soughtRow=null;let n=[...this.querySelectorAll(`.bundle-compare-diff-table`)].find(t=>t.dataset.path===e)?.children[t];if(!n)return;let r=n.closest(`.bundle-compare-diff`);n.scrollIntoView({block:r&&n.offsetHeight>r.clientHeight/2?`start`:`center`}),n.classList.remove(`is-sought`),n.offsetWidth,n.classList.add(`is-sought`),n.addEventListener(`animationend`,()=>n.classList.remove(`is-sought`),{once:!0})}_shown(e){return this._kinds.has(e.kind)||!!e.modified&&this._kinds.has(`changed`)||!!e.repointed&&this._kinds.has(`repointed`)}_modules(){let e=this.base?.kind===`stasis`?this.base.bundle?.modules:null,t=this.other?.kind===`stasis`?this.other.bundle?.modules:null,n={root:this.files?.root,paths:this.files?.basePaths??new Map};return e||t?new Map([...[...e??[]].map(([e,t])=>[i(n,e,Object.keys(t.files??{})),t]),...t??[]]):null}_baseDirs(){let e=this.files?.root?this.files.basePaths:null;return e?oi(e,e.values()):si(this.base)}_format(e){let t=this._entries.get(e),n=mt(this.base,t?.basePath??e),r=mt(this.other,e);return[n,r].find(pt)??(t?.kind===`removed`?n:r)}_tree(){let e=[this._entries,`${[...this._kinds].join()}:${!!this.extensions?.fullPaths}`];if(this._treeKey?.[0]===e[0]&&this._treeKey[1]===e[1])return this._treeMemo;let t=[...this._entries.keys()],n=this._modules(),r=a(this.files?.root,this.extensions?.fullPaths?``:Oe(Ct(t).prefix,n,t)),{prefix:i}=r,o=t.filter(e=>this._shown(this._entries.get(e))),s=Ee(o.map(e=>i&&e.startsWith(i)?e.slice(i.length):e),o,n);return this._treeKey=e,this._treeMemo={prefix:i,root:r,tree:s,shown:o.length,allOrder:Ve(s)},this._treeMemo}_select(e){!e||e===this._current||this.extensions?.canSelect?.()===!1||this.dispatchEvent(new CustomEvent(`compare-code-select`,{detail:{path:e},bubbles:!0,composed:!0}))}_reveal(e,t){let n=(t&&e.startsWith(t)?e.slice(t.length):e).split(`/`);for(let e=1;e<n.length;e++)this._open.set(n.slice(0,e).join(`/`),!0)}_pathQuery(){return this._query.trim()}_railState(){let{prefix:e,root:t,tree:n,shown:r,allOrder:i}=this._tree(),a=Ae(n,this._mode===`files`?this._pathQuery():``,e,this.extensions?.fileFilter);return{prefix:e,root:t,tree:n,shown:r,filtered:a,order:a===n?i:a?Ve(a):[],allOrder:i}}_renderRail({prefix:e,root:t,tree:n,shown:r,filtered:i,order:a},o){this._countUntil=null,this._treeRemaining=this.extensions?.treePageSize?this._treeLimit:1/0,this._treeTruncated=!1;let s=!!this._pathQuery()||r<=(this.extensions?.openAllMax??gr),c=this._mode===`code`?B:i?this._renderTree(i,o,0,s,s?null:Pe(i)):z`<div class="bundle-code-search-empty">No changed files match.</div>`,l=Object.fromEntries(ur.map(({kind:e})=>[e,0]));for(let e of this._entries.values())e.kind!==`repointed`&&l[e.kind]++,e.modified&&l.changed++,e.repointed&&l.repointed++;let u=vr.find(({mode:e})=>e===this._mode);return z`<aside class="bundle-code-rail"><div class="bundle-code-rail-head"><span class="bundle-code-rail-label">${this.extensions?.railLabel??`Changes`}</span> <span class="bundle-code-rail-count">${this._entries.size.toLocaleString()}</span> <span class="bundle-code-rail-actions"><button type="button" class="bundle-code-rail-action" aria-label="${this.extensions?.collapseLabel??`Collapse directories`}" data-tooltip="Collapse directories" ?disabled="${this._mode!==`files`||!!this._pathQuery()&&!this.extensions?.collapseClearsSearch||n.dirs.size===0}" @click="${()=>this._collapseAll(n)}">${oe}</button></span></div>${t.from?z`<div class="bundle-code-rail-prefix mono" data-tooltip="${`Root moved: ${t.from} \u2192 ${t.to}`}">${cn(t)}</div>`:e?z`<div class="bundle-code-rail-prefix mono" data-tooltip-truncated data-tooltip="${e}">${e}</div>`:B}<div class="bundle-compare-code-filter"><label class="bundle-compare-code-search"><svg viewBox="0 0 16 16" width="12" height="12" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" aria-hidden="true"><circle cx="7" cy="7" r="4.5"/><path d="m10.5 10.5 3.5 3.5"/></svg> <input type="search" placeholder="${this._mode===`files`?this.extensions?.searchPlaceholder??u.placeholder:u.placeholder}" aria-label="${this._mode===`files`?this.extensions?.searchLabel??u.placeholder:u.placeholder}" spellcheck="false" autocomplete="off" .value="${M(this._query)}" @input="${e=>{this._query=e.target.value,this._treeLimit=this.extensions?.treePageSize??1/0}}"> <span class="bundle-code-search-modes" role="tablist">${vr.map(({mode:e,label:t,icon:n})=>z`<button type="button" class="${I({"bundle-code-search-mode":!0,active:e===this._mode})}" role="tab" aria-selected="${String(e===this._mode)}" aria-label="${t}" data-tooltip="${t}" @click="${()=>{this._mode=e}}">${n}</button>`)}</span></label> ${this.extensions?.filters??z`<div class="bundle-compare-code-kinds" role="group" aria-label="Show changes">${ur.filter(({kind:e})=>l[e]>0).map(({kind:e,label:t})=>z`<button type="button" class="${`bundle-compare-code-kind ${e}`}" aria-pressed="${String(this._kinds.has(e))}" data-tooltip="${`${this._kinds.has(e)?`Hide`:`Show`} ${t.toLowerCase()} files`}" @click="${()=>this._toggleKind(e)}">${t.toLowerCase()}</button>`)}</div>`}</div><div class="bundle-code-rail-body bundle-compare-code-tree">${this._mode===`code`?this._renderSearch(a,o,e):c} ${this._mode===`files`&&this._treeTruncated?z`<button type="button" class="bundle-compare-code-action" @click="${()=>{this._treeLimit+=this.extensions.treePageSize,this.requestUpdate()}}">Show more files</button>`:B}</div>${this.extensions?.footer?.(e=>{this._query=``,this._select(e)})??B}</aside><bundle-code-splitter role="separator" tabindex="0" aria-orientation="vertical" aria-label="Resize file tree" data-tooltip="Drag to resize · double-click to reset"></bundle-code-splitter>`}_arrived=0;_renamesAlone=!0;_repaint=()=>{this._arrived++,this.isConnected&&this.requestUpdate()};disconnectedCallback(){super.disconnectedCallback(),clearTimeout(this._countLater),clearTimeout(this._searchLater),this._countLater=this._searchLater=null}render(){let e=this._railState(),t=this._entries.has(this.path)?this.path:e.order[0]??null;t&&t!==this._current&&this._reveal(t,e.prefix),this._current=t,this._order=this.extensions?.filterContent===!1?e.allOrder:e.order;let n=t?z`${this._renderFile(t,this.extensions?.fullPaths?``:e.prefix)}${this.extensions?.fileActions?.(t,!1)??B}`:z`<div class="bundle-code-placeholder">No files differ in this comparison.</div>`;return z`<div class="bundle-code-view bundle-compare-code">${this._renderRail(e,t)}<div class="bundle-code-main">${n}</div></div>`}_toggleKind(e){let t=new Set(this._kinds);t.has(e)?t.delete(e):t.add(e),this._kinds=t}_collapseAll(e){this.extensions?.collapseClearsSearch&&(this._query=``),this._treeLimit=this.extensions?.treePageSize??1/0;let t=e=>{for(let n of e.dirs.values())this._open.set(n.path,!1),t(n)};t(e),this.requestUpdate()}_renderSearch(e,t,n){if(!this._query)return z`<div class="bundle-code-search-hint">Type to search the code of the changed files.</div>`;let{files:r,hits:i,truncated:a,unsigned:o}=this._searchResults(e);if(r.length===0)return z`<div class="bundle-code-search-empty">No matches.</div>`;let s=e=>n&&e.startsWith(n)?e.slice(n.length):e;return z`<div class="bundle-code-search-results bundle-compare-search"><div class="bundle-code-search-summary">${i.toLocaleString()} ${i===1?`hit`:`hits`} in ${r.length.toLocaleString()} ${r.length===1?`file`:`files`}${a?`, the first ${zn}`:``}</div>${R(r,e=>e.path,({path:e,hits:n})=>z`<div class="${I({"bundle-code-search-file":!0,current:e===t})}"><button type="button" class="${`bundle-code-search-file-name bundle-compare-code-name ${this._entries.get(e).kind}`}" data-tooltip-truncated data-tooltip="${e}" @click="${()=>this._select(e)}">${s(e)}</button> ${o.has(e)?z`<p class="bundle-compare-search-note">${Sr[o.get(e)]}</p>`:B}<ul class="bundle-code-search-hits">${n.map(t=>z`<li class="bundle-code-search-hit"><button type="button" class="bundle-code-search-hit-link" aria-label="${`${Cr[t.sign]?.label??`Line`} ${t.line+1}${t.side===`a`?` of the old text`:``}: ${t.text.trim().slice(0,80)}`}" @click="${()=>this._seek(e,t)}"><span class="bundle-code-search-hit-ln">${t.line+1}</span> <span class="${`bundle-compare-search-sign ${Cr[t.sign]?.name??``}`}" aria-hidden="true">${t.sign??``}</span> <span class="bundle-code-search-hit-text mono">${E(t.text,t.ranges)}</span></button></li>`)}</ul></div>`)}</div>`}_searchResults(e){let t=wr(),r=`${this._query}\0${this._forced.size}\0${t}\0${q.layout}\0${j.bundleSourcePretty}\0${y()}\0${this._rowlessCount}\0${e.join(`\0`)}`;if(this._found?.key===r&&this._found.entries===this._entries)return this._found.result;let i=null,a=!0,o=new Map,s={...Gn(e.flatMap(e=>{let n=this._entries.get(e);if(!this._searchable(n))return[];let r=U(this.base,this.other,e,n),{before:i,after:a}=r;if(this._prettyShown(e,n,r)){if(!/\S/u.test(this._query))return[];let n=i!==``&&a!==``&&i!==a;if(n&&this._rowless.get(e)===t)return[];o.set(e,n?`printed`:`numbered`)}return[{path:e,...r}]}),te(this._query,!1,!1),(e,t,r)=>{if(o.get(e)===`printed`)return null;let s=`${q.ignoreWhitespace}\0${e}`;if(this._blocks.has(s))return this._blocks.get(s);if(!this._forced.has(e)&&J(t,r))return o.set(e,`large`),null;let c=performance.now();if(i??=c+_r,c>i)return a=!1,null;let l=q.ignoreWhitespace&&!this._unlisted(e,this._entries.get(e),{before:t,after:r}),u=A(t,r,l);return l&&n(t,r,u)&&(u=A(t,r)),this._blocks.set(s,u),u},{split:q.layout===`split`,align:(e,t,n,r)=>{let i=this._aligned.get(n);return i||this._aligned.set(n,i={a:e,b:t,blocks:n}),In(i,n.indexOf(r))}}),unsigned:o};return a?this._found={key:r,entries:this._entries,result:s}:this._searchLater??=setTimeout(()=>{this._searchLater=null,this.requestUpdate()}),s}_searchable(e){return e.modified!==!1||ri(e)}_prettyShown(e,t,n){if(!j.bundleSourcePretty)return!1;let r=this._printing(e,t,n);return!!r?.applies&&r.copies.status!==`error`}_noteRowless(e,t){let n=t?wr():void 0;this._rowless.get(e)!==n&&(n===void 0?this._rowless.delete(e):this._rowless.set(e,n),this._rowlessCount++)}_seek(e,t){this._sought={path:e,side:t.side,line:t.line,at:t.ranges[0]?.[0]??0,query:this._query},e===this._current?this.requestUpdate():this._select(e,!1)}_soughtLine(e,t,n,r){let{side:i,line:a,at:o,query:s}=this._sought;if(n?.status!==`ready`)return{side:i,line:a};let c=e=>e.replaceAll(/\s+/gu,``),l=k(U(this.base,this.other,e,t)[i===`a`?`before`:`after`]??``),u=l.slice(0,a).reduce((e,t)=>e+c(t).length,0)+c(l[a]?.slice(0,o)??``).length,d=c(s).toLowerCase(),f=(e,t)=>{if(!d)return null;let n=0,r=0,i=0,a=``;for(let o of e)for(let e=0;e<o.length;e+=br){a+=c(o.slice(e,e+br)).toLowerCase();for(let e=a.indexOf(d,n);e!==-1;e=a.indexOf(d,n),r++){if(t(r,i+e))return{index:r,start:i+e};n=e+d.length}let s=Math.max(n,a.length-d.length+1);a=a.slice(s),i+=s,n=Math.max(0,n-s)}return null},p=f(l,(e,t)=>t>=u),m=(p&&f(r[i],e=>e===p.index)?.start)??u;for(let e=0;e<r[i].length;e++)if(m-=c(r[i][e]).length,m<0)return{side:i,line:e};return null}_seekRows(e,t,{side:n,line:r},i){let a=t.typeFolds,o=a?a.lineOf[n].indexOf(r):r,s=e=>e.kind===`types`?o===-1&&!!e[n]&&r>=e[n].from&&r<e[n].to:n===`b`?(e.kind===`ctx`||e.kind===`add`)&&e.b===o||e.kind===`change`&&e.right===o:(e.kind===`ctx`||e.kind===`del`)&&e.a===o||e.kind===`change`&&e.left===o,c=this._expansions.get(e)??new Map,l=Nn(t,c,{split:i}),u=l.findIndex(s);if(u===-1){let r=l.find(e=>e.kind===`fold`&&o>=e[n]&&o<e[n]+e.count);if(r){let a=c.get(r.run)??{},d=o-r[n];c=new Map(c).set(r.run,r.down?{...a,top:(a.top??0)+d+1+yr}:r.up?{...a,bottom:(a.bottom??0)+r.count-d+yr}:{all:!0}),this._expansions.set(e,c),l=Nn(t,c,{split:i}),u=l.findIndex(s)}}let d=this._limits.get(e)??K;return u>=d&&this._limits.set(e,Math.ceil((u+1)/K)*K),{rows:l,index:u}}_takeTreeRow(e=!1){return this._treeRemaining-->0||(this._treeTruncated=!0,e)}_renderTree(e,t,n,i,a){let o=[...e.dirs.entries()].toSorted(ze),s=[...e.files.entries()].toSorted(([e],[t])=>e.localeCompare(t)),c=o.flatMap(([e,r])=>{let o=Me(e,r,n),s=r.package,c=s?.ecosystem===`cargo`||s?.ecosystem===`composer`||s?.ecosystem===`soldeer`,l=this._pathQuery()?!0:this._open.get(r.path)??(i||!!a?.has(r.path)||ci(r,t)),u=this._baseDirs().has(r.sourcePath)?si(this.other).has(r.sourcePath)?null:`removed`:`added`;if(!this._takeTreeRow(ci(r,t)))return[];let d=z`<li class="bundle-code-tree-dir"><details .open="${M(l)}" @toggle="${e=>{let t=e.currentTarget.open;this._open.get(r.path)!==t&&(this._open.set(r.path,t),this.extensions?.treePageSize&&this.requestUpdate())}}"><summary aria-label="${this.extensions?.directoryLabel?.(o.node)??B}"><span class="bundle-code-tree-chevron" aria-hidden="true"></span> ${s||r.dependencyRoot?gt(s?.ecosystem??r.dependencyRoot):B} <span class="${I({"bundle-code-tree-dirname":!0,"bundle-code-tree-package":!!s,"bundle-code-tree-package-vendored":c,"bundle-compare-code-name":!0,removed:u===`removed`})}" data-tooltip-truncated data-tooltip="${o.node.sourcePath}">${s?z`<span class="bundle-code-tree-package-name">${s.name}</span>${s.version?z`<span class="bundle-code-tree-package-version">${c?`- `:`@`}${s.version}</span>`:B}`:o.names.map((e,t)=>z`${t>0?z`<span class="bundle-code-tree-separator">/</span>`:B}${e}`)} </span>${s?.variant?z`<span class="bundle-code-tree-variant">variant ${s.variant}</span>`:B} <span class="bundle-compare-code-dir-count" data-tooltip="${`${r.fileCount} changed ${r.fileCount===1?`file`:`files`}`}">${this.extensions?.directorySummary?.(o.node)??r.fileCount}</span> ${u?z`<span class="${`bundle-compare-code-letter ${u}`}" data-tooltip="${`${s?`Package`:`Directory`} ${u}`}">${dr[u].letter}</span>`:B}</summary>${l||!this.extensions?.treePageSize?this._renderTree(o.node,t,n+1,i,a):B}</details></li>`;return[{key:r.path,content:d}]}),l=s.flatMap(([e,n])=>{if(!this._takeTreeRow(n===t))return[];let{kind:i,repointed:a,renamedFrom:o,modified:s}=this._entries.get(n),c=a?ni(a).note:``;return[{key:n,content:z`<li class="bundle-code-tree-file"><button type="button" class="${I({"bundle-code-tree-link":!0,current:n===t})}" aria-label="${this.extensions?.fileLabel?.(n)??B}" aria-current="${n===t?`true`:B}" @click="${()=>this._select(n)}">${this.extensions?.filePrefix?.(n)??B}${ht(n,this._format(n))}<span class="${`bundle-code-tree-name bundle-compare-code-name ${i}`}" data-tooltip-truncated data-tooltip="${n}">${e}</span> ${this.extensions?.fileSuffix?.(n)??B} ${o?z`<span class="bundle-compare-code-oldname" data-tooltip-truncated data-tooltip="${`Renamed from ${o}`}">← ${r(o,n,{extension:!1}).from}</span>`:B} ${this._fileTags(n,this._entries.get(n),!0)} ${this._treeCounts(n,this._entries.get(n))} ${a&&i!==`repointed`?z`<span class="bundle-compare-code-letter repointed" data-tooltip="${c}">R</span>`:B} <span class="${I({"bundle-compare-code-letter":!0,[i]:!0,pure:i===`renamed`&&!s})}" data-tooltip="${i===`repointed`?c:o?`Renamed${s?` and modified`:``} from ${o}`:dr[i].label}">${dr[i].letter}</span></button></li>`}]});return z`<ul class="${I({"bundle-code-tree":!0,root:n===0})}" aria-label="${n===0?this.extensions?.treeLabel??`Changed files`:B}" @keydown="${n===0?Ie:B}">${R(c,e=>e.key,e=>e.content)}${R(l,e=>e.key,e=>e.content)}</ul>`}_treeCounts(e,t){if(t.kind===`repointed`)return B;let n=this._lineCounts(e,t),r;if(n===null&&this._counted.has(e)?{published:n,shown:r}=this._largeCounts(e,t):r=n&&this._shownCounts(e,t),!(n||r)||r===void 0)return B;let{additions:i,deletions:a}=r??n,o=!n||n.additions>0||n.deletions>0,s=t.kind===`renamed`,c=r?.renamed>0?`
|
|
22
20
|
\u2248${r.renamed.toLocaleString()} lines differing in renamed names alone, marked`:``,l=n?`
|
|
23
|
-
As published: +${n.additions.toLocaleString()} \u2212${n.deletions.toLocaleString()}`:``,u=r?`${r.aside.join(`, `)}${c}${l}`:null;if(i===0&&a===0){if((s||t.modified===!1)&&!o)return I`<span class="bundle-compare-code-line-counts unchanged" aria-label="No line changes">=</span>`;if(r&&o)return I`<span class="bundle-compare-code-line-counts unchanged" aria-label="${`No line changes with ${r.aside.join(`, `)}`}" data-tooltip="${`No line changes with ${u}`}">≈</span>`}let d=r&&(!n||i!==n.additions||a!==n.deletions);return I`<span class="bundle-compare-code-line-counts" aria-label="${`${i} added, ${a} removed lines`}" data-tooltip="${d?`With ${u}`:L}"><span class="${N({add:!0,empty:s&&i===0})}">+${i.toLocaleString()}</span> <span class="${N({del:!0,empty:t.kind===`added`||s&&a===0})}">−${a.toLocaleString()}</span></span>`}_countingState(e,t){return this._fileState(e,t,!0)}_shownCounts(e,t){if(!(E.bundleSourcePretty||J.ignoreWhitespace||J.ignoreRenames||J.ignoreTypes))return null;let n=`${Or(e)}\0${this._arrived}\0${this._forced.size}`,r=this._drawnCounts.get(e);if(r?.settings===n)return r.counts;let i=performance.now();if(this._countUntil??=i+_r,i>this._countUntil){this._countLater??=setTimeout(()=>{this._countLater=null,this.requestUpdate()});return}let a=this._countingState(e,t),{model:o}=a,s=kr(a),c=o&&s.length>0?{additions:o.additions,deletions:o.deletions,renamed:o.renamed,aside:s}:null;return this._drawnCounts.set(e,{settings:n,counts:c}),c}_lineCounts(e,t){if(this._counted.has(e))return this._counted.get(e);let n=performance.now();if(this._countUntil??=n+_r,n>this._countUntil)return this._countLater??=setTimeout(()=>{this._countLater=null,this.requestUpdate()}),null;let{before:r,after:i}=V(this.base,this.other,e,t),a=Dn(r,i);return this._counted.set(e,a),a}_noteDrawn(e,t){let{model:n}=t;return n&&this._drawnTotals.set(e,{settings:Or(e),counts:{additions:n.additions,deletions:n.deletions,renamed:n.renamed,aside:kr(t)}}),t}_largeCounts(e,t){let n=this._drawnTotals.get(e);if(n?.settings===Or(e))return n.counts.aside.length===0?{published:n.counts,shown:null}:{published:null,shown:n.counts};let r=J.ignoreTypes?V(this.base,this.other,e,t):null;return{published:null,shown:typeof r?.before==`string`&&typeof r.after==`string`&&ar(this.base,this.other,e,t,r,this._repaint,this.scope)===!0?{additions:0,deletions:0,renamed:0,aside:[Er]}:null}}_model(e,t,n,r={},i=J.ignoreWhitespace){let a=r.changes?.blocks??r.marks??null,o=this._models.get(e);return this._models.delete(e),o?.before===t&&o.after===n&&o.given===a||(o={model:bn(t,n,{...r,ignoreWhitespace:i}),before:t,after:n,given:a}),this._models.set(e,o),this._models.size>this._modelCap&&this._models.delete(this._models.keys().next().value),o.model}_counts(e,t,n,r,i){let a=r.changes?.blocks??r.marks??null,o=this._countModels.get(e);if(o?.before===t&&o.after===n&&o.given===a)return o.model;let s=r.changes?.blocks??U(t,n,i),c={blocks:s,...xn(s,r.marks)};return this._countModels.set(e,{model:c,before:t,after:n,given:a}),c}_fileState(e,t,r=!1){let i=V(this.base,this.other,e,t),a=typeof i.before==`string`&&typeof i.after==`string`,o=a?ar(this.base,this.other,e,t,i,this._repaint,this.scope):void 0,s=o===!0;if(s&&J.ignoreTypes){let t={a:[],b:[],blocks:[],additions:0,deletions:0,renamed:0,marked:new Set,noEol:{a:!1,b:!1},words:new Map};return r?{pretty:null,hiding:!1,model:t,spacesHidden:!1,typesHidden:!0}:this._noteDrawn(e,{...i,textual:a,large:!1,printing:null,pretty:null,key:null,generated:!1,renamed:!1,warned:[],hiding:!1,changes:null,model:t,whitespace:null,spacesHidden:!1,types:s,typesHidden:!0})}let c=o&&o!==!0?Jr(o,i):null,l=!!c&&J.ignoreTypes,u=a&&!l&&(!r||E.bundleSourcePretty)?this._printing(e,t,i):null,d=E.bundleSourcePretty&&u?.applies?u.copies:null,{before:f,after:p}=l?c:d?.status===`ready`?d:i,m=a&&Mr(e)&&Mr(t.basePath??e)&&[`ready`,`loading`,`error`].includes(d?.status)&&this._generated(e,t,i),h=m&&d.status===`ready`;!r&&a&&this._sought?.path===e&&!this._forced.has(e)&&this._large(e,f,p)&&this._forced.add(e);let g=a&&!this._forced.has(e)&&this._large(e,f,p),{basePath:_=e}=t,v=t=>{let n=h&&!g?st(this.base,_,i.before,this.other,e,i.after,t,this._repaint,d.hashes,!r&&this._renamesAlone,this.scope):null,o=n?.status===`ready`,s=o&&J.ignoreRenames,u=o&&!s,v=s&&n.reason===null?n.reads:[],y=o&&n.reason===null?n.marks.length>0||J.ignoreRenames&&n.before!==f:J.ignoreRenames&&m,b=`${Ur(e,d?.status===`ready`,{...J,ignoreWhitespace:t,ignoreRenames:s,markRenames:u})}${l?`\0types`:``}`,x=s?n.before:f,S=s?{changes:{blocks:n.blocks}}:u?{marks:n.marks}:{},C=a&&!g&&(!n||o||!J.ignoreRenames)?r?this._counts(b,x,p,S,t):this._model(b,x,p,S,t):null;return l&&C&&(C.typeFolds=c),{key:b,changes:n,warned:v,renamed:y,hiding:s,shown:x,model:C,ignoreWhitespace:t}},y=this._unlisted(e,t,i),b=v(J.ignoreWhitespace&&!y),x=J.ignoreWhitespace&&!y&&!!b.model&&(b.model.mixed??=n(b.shown,p,b.model.blocks));x&&(b=v(!1));let{key:S,changes:C,warned:ee,renamed:te,hiding:ne,shown:re,model:w}=b;if(r)return{pretty:d,hiding:ne,model:w,spacesHidden:b.ignoreWhitespace,typesFolded:l};d?.status===`ready`&&w?this._noteRowless(e,w.blocks.length===0):w&&!l&&(this._blocks.set(`${J.ignoreWhitespace}\0${e}`,w.blocks),this._aligned.set(w.blocks,w));let ie=w&&!y&&!J.ignoreWhitespace?this._whitespaceHidden(`${e}\0${d?.status===`ready`}\0${ne}`,re,p):null,T=w===null||y?null:x?`mixed`:J.ignoreWhitespace?ti(w,re,p)?`hideable`:null:ie.hides&&!ie.mixed?`hideable`:null;return this._sought?.path===e&&(this._soughtSettling=d?.status===`loading`||J.ignoreRenames&&(C?.status===`loading`||C?.status===`error`)),this._noteDrawn(e,{...l?i:{before:re,after:p},textual:a,large:g,printing:u,pretty:d,key:S,generated:m,renamed:te,warned:ee,hiding:ne,changes:C,model:w,whitespace:T,spacesHidden:b.ignoreWhitespace,types:s||!!c,typesFolded:l})}_unlisted(e,{basePath:t=e},{before:n,after:r}){return!Nn(e,r,jr(this.other,e))||!Nn(t,n,jr(this.base,t))}_whitespaceHidden(e,t,n){let r=this._spaced.get(e);return r?.before===t&&r.after===n||(r={before:t,after:n,hidden:kn(t,n)}),this._spaced.delete(e),this._spaced.set(e,r),this._spaced.size>this._modelCap&&this._spaced.delete(this._spaced.keys().next().value),r.hidden}_generated(e,{kind:t,basePath:n=e},{before:r,after:i}){return t!==`repointed`&&ot(this.base,this.other)&&Pr(this.base,n,r)&&Pr(this.other,e,i)}_printing(e,t,n){let{kind:r,basePath:i=e,modified:a}=t,{before:o,after:s}=n;if(r===`repointed`||a===!1||typeof o!=`string`||typeof s!=`string`||o===s)return null;let c=[[`base`,this.base,i,o],[`other`,this.other,e,s]];if(!c.every(([e,,t,n])=>n===``||p(this.base,this.other,e,t,n)))return null;let l=c.every(([,,e,t])=>t===``||Ue(e)),u=!l&&c.some(([,e,t,n])=>n!==``&&Pr(e,t,n)),d=c.map(([e,,t,n])=>n===``?{status:`ready`,text:n}:m(this.base,this.other,e,t,n,this._repaint)),f=d.find(e=>e.status===`error`)??d.find(e=>e.status===`loading`)??d.find(e=>e.status===`off`)??{status:`ready`,before:d[0].text,after:d[1].text,hashes:d.map(e=>e.hash)},h=!l&&!u&&o!==``&&s!==``&&f.status===`ready`&&this._smaller(e,n,f);return{copies:f,json:l,minified:u,smaller:h,applies:l||u||h}}_large(e,t,n){let r=this._larges.get(e);if(r?.before===t&&r.after===n)return r.large;let i=Y(t,n);return this._larges.set(e,{before:t,after:n,large:i}),i}_smaller(e,{before:t,after:n},r){let i=this._shorter.get(e);if(i?.before===t&&i.after===n&&i.printed===r.before&&i.printedAfter===r.after)return i.smaller;let a=(e,t)=>U(e,t).reduce((e,{a0:t,a1:n,b0:r,b1:i})=>e+n-t+i-r,0),o=!Y(t,n)&&!Y(r.before,r.after)&&a(r.before,r.after)<a(t,n);return this._shorter.set(e,{before:t,after:n,printed:r.before,printedAfter:r.after,smaller:o}),o}_fileMessage(e,{kind:t,modified:n,meta:r},{before:i,after:a,textual:o,large:s,model:c,pretty:l,hiding:u,warned:d=[],changes:f,whitespace:p,typesHidden:m=!1,typesFolded:h=!1}){let g=e=>M(e??0),_=lr(r),v=`${t===`renamed`?_?`Renamed, its contents the same.`:`Renamed without changes.`:`The contents are the same.`}${_?` ${_}`:``}`;if(o&&n===!1)return I`<div class="bundle-compare-code-message"><p>${v}</p></div>`;if(!o){if(t===`changed`&&n===!1)return I`<div class="bundle-compare-code-message">Binary file, its bytes the same · ${g(j(a))}. ${_}</div>`;let e=t===`added`?g(j(a)):t===`removed`?g(j(i)):`${g(j(i))} \u2192 ${g(j(a))}`;return I`<div class="bundle-compare-code-message">Binary file ${t} · ${e}. A text diff is not available.${_?` ${_}`:``}</div>`}if(s)return I`<div class="bundle-compare-code-message"><p>This diff is large (${(Xr(i)+Xr(a)).toLocaleString()} lines across both sides) and may take a few seconds to compute.</p><button type="button" class="bundle-compare-code-action" @click="${()=>{this._forced.add(e),this.requestUpdate()}}">Show diff</button></div>`;if(m)return I`<div class="bundle-compare-code-message"><p>Only types changed in this file.${_?` ${_}`:``}</p><button type="button" class="bundle-compare-code-action" @click="${()=>this._setTypes(!1)}">Show type-only changes</button></div>`;if(f?.status===`loading`&&J.ignoreRenames)return I`<div class="bundle-compare-code-message" aria-busy="true">Hiding renamed names…</div>`;if(f?.status===`error`&&J.ignoreRenames)return I`<div class="bundle-compare-code-message"><p>Couldn't hide renamed names: ${f.message}</p><button type="button" class="bundle-compare-code-action" @click="${()=>this._setRenames(!1)}">Show renamed names</button></div>`;if(c.blocks.length>0)return null;let y=l?.status===`ready`&&l.before===l.after,b=!y&&J.ignoreWhitespace&&p===`hideable`,x=!y&&u,S=[h&&`types`,b&&`whitespace`,x&&`renamed names`].filter(Boolean),C=y?`No actual code changes in this file.`:S.length>0?`Only ${S.join(` and `)} changed in this file.`:null;return I`<div class="bundle-compare-code-message"><p>${C?`${C}${_?` ${_}`:``}`:v}</p>${d.length>0?I`<p>${Hr(d)}</p>`:L} ${y?I`<button type="button" class="bundle-compare-code-action" @click="${()=>{E.bundleSourcePretty=!1,this.requestUpdate()}}">Show as published</button>`:L} ${h?I`<button type="button" class="bundle-compare-code-action" @click="${()=>this._setTypes(!1)}">Show type-only changes</button>`:L} ${b?I`<button type="button" class="bundle-compare-code-action" @click="${()=>this._setWhitespace(!1)}">Show whitespace changes</button>`:L} ${x?I`<button type="button" class="bundle-compare-code-action" @click="${()=>this._setRenames(!1)}">Show renamed names</button>`:L}</div>`}_fileName(e,t,n,r=L){let i=e=>n&&e.startsWith(n)?e.slice(n.length):e;return I`<span class="${N({"bundle-compare-code-pill":!0,[t.kind]:!0,pure:t.kind===`renamed`&&!t.modified})}">${dr[t.kind].label}</span> ${mt(e,this._format(e))} <span class="bundle-code-main-path mono" data-tooltip-truncated data-tooltip="${t.renamedFrom?`${t.renamedFrom} \u2192 ${e}`:e}">${t.renamedFrom?an(i(t.renamedFrom),i(e)):i(e)}</span> ${r}${this._githubLink(e,t)}${this._fileTags(e,t)}`}_fileTags(e,t,n=!1){if(!n)return I`${this._entryTags(e,t)}${this._alertTags(e,t)}${this._runsTags(e,t)}${this._newHostTags(e,t)}${this._flagTags(e,t)}${this._readability(e,t)}${this._installTags(e,t)}${sr(t.meta)}`;let r=[this._alertTags(e,t),this._runsTags(e,t),this._newHostTags(e,t),this._flagTags(e,t,!1),this._treeTag(e,t),this._installTags(e,t,!0),sr(t.meta,!0)];return ii(r)?r:this._flagTags(e,t)}_githubLink(e,{kind:t,basePath:n=e}){let r=t===`removed`?ze(this.base,n):ze(this.other,e);return r?Be(r):L}_alertTags(e,{kind:t,basePath:n=e}){let r=t===`removed`?this.baseAlerts?.get(n):this.otherAlerts?.get(e);return r?.length>0&&this.alertTags?this.alertTags(r):L}_newHostTags(e,{kind:t}){let n=t===`removed`?null:this.newHosts?.get(e);return n&&this.newHostTag?this.newHostTag(n):L}_runsTags(e,t){return[[ve,c],[ye,xe]].map(([n,r])=>{let{was:i,now:a}=this._reads(e,t,n);return t.kind===`removed`?r(i):r(a,i)})}_entryTags(e,{kind:t,basePath:n=e}){let r=Lr(t===`removed`?this.base:this.other).get(t===`removed`?n:e)??[];return[...Map.groupBy(r,({label:e})=>e)].map(([e,t])=>I`<span class="${`bundle-compare-code-entry${e===`license`?` is-license`:``}`}" data-tooltip="${t.map(({note:e})=>e).join(` · `)}">${e}</span>`)}_installTags(e,t,n=!1){if(!Rr.test(e))return L;let{kind:r,basePath:i=e}=t,{before:a,after:o}=V(this.base,this.other,e,t),s=new Map(r===`added`||a===void 0?[]:Br(this.base,i,a)),c=new Map(r===`removed`||o===void 0?[]:Br(this.other,e,o)),l=[...r===`removed`?s:c].map(([e,t])=>{let n=r===`removed`?t:s.get(e),i=n===void 0?`, new`:n===t?``:`, was: ${n}`;return I`<span class="bundle-compare-code-install" data-tooltip="${`${t}${i}`}">${e}</span>`});if(!n&&r!==`removed`)for(let[e,t]of s)c.has(e)||l.push(I`<span class="bundle-compare-code-install is-dropped" data-tooltip="${`No longer run on install: ${t}`}">${e}</span>`);return l}_reads(e,t,n=Je){let{kind:r,basePath:i=e}=t,{before:a,after:o}=V(this.base,this.other,e,t);return{was:r===`added`?null:a===void 0?void 0:n(this.base,i,a),now:r===`removed`||o===void 0?null:n(this.other,e,o)}}_readability(e,t){let{was:n,now:r}=this._reads(e,t),i=e=>I`${Qe(e)}${et(e)}`,a=!n||!r||gt(n)===gt(r)&&n.kind===r.kind?i(r??n):I`<span class="bundle-compare-code-readability">${i(n)}<span aria-hidden="true">→</span>${i(r)}</span>`;return I`${nt(r??n)}${a}`}_flagTags(e,t,n=!0){return t.kind===`removed`?it(this.base,t.basePath??e,t.baseBytes,n):it(this.other,e,t.otherBytes,n)}_treeTag(e,t){let{was:n,now:r}=this._reads(e,t),i=r??n;if(!i)return L;let a=i.category!==`map`&&vt.get(gt(i)).mark;return I`${nt(i,[`warn`])}${a?Qe(i,!0):L}`}_fileFigures({kind:e,baseBytes:t,otherBytes:n},r){let i=e=>M(e??0);return I`${r?.blocks.length>(r?.marked?.size??0)?ei(r.additions,r.deletions):L} ${r?.renamed>0?I`<span class="bundle-compare-code-renamed" aria-label="${`${r.renamed} lines differing in renamed names alone`}" data-tooltip="Lines differing in renamed names alone, marked">≈${r.renamed}</span>`:L} <span class="bundle-code-main-stats">${e===`added`?i(n):e===`removed`?i(t):`${i(t)} \u2192 ${i(n)}`}</span>`}_highlighted(e,t,n,r=``){if(!n)return null;let i=bt(t,jr(e,t),n);if(!i)return null;let a=`${e.integrity}\0${t}${r?`\0${r}`:``}`,o=Wr.get(a);return o?.text===n?o.lines:(Gr.has(a)||(Gr.add(a),(async()=>{let e=await Ve(n,i),t=typeof e==`string`?He(e):null;Wr.set(a,{text:n,lines:t?.length===n.split(`
|
|
24
|
-
`).length?t:null}),Gr.delete(a),this.isConnected&&this.requestUpdate()})()),null)}_renderFile(e,t){let n=this._entries.get(e),{kind:r}=n,i=this._fileState(e,n),{after:a,before:o,textual:s,model:c}=i,l=ri(n),u=s&&(!l||c?.blocks.length>0),d=this._order.indexOf(e),f=t&&e.startsWith(t)?e.slice(t.length):e,p=r===`repointed`&&o===void 0?
|
|
25
|
-
`):[],a=n?this._highlighted(this._textSide(e),e,n):null,o=this._importLines(t,i),s=e=>e===null?I`<code class="is-none">(none)</code>`:I`<code data-tooltip-truncated data-tooltip="${e||`(empty target)`}">${e||`(empty target)`}</code>`,{title:c}=ni(t);return I`<section class="bundle-compare-code-repointed" aria-label="${c}"><h4>${c} <b>${t.length}</b></h4><ul>${t.map(e=>{let t=o.get(e.specifier),n=`${e.conditions}${e.platform===null?``:` \xB7 Platform: ${e.platform}`}`;return I`<li><div class="bundle-compare-code-repointed-spec"><code data-tooltip-truncated data-tooltip="${e.specifier}">${e.specifier}</code> <span data-tooltip-truncated data-tooltip="${n}">${n}</span></div><div class="bundle-compare-code-repointed-targets"><span class="before"><span>Before</span>${s(e.baseTarget)}</span> <span aria-hidden="true">→</span> <span class="after"><span>After</span>${s(e.otherTarget)}</span></div>${t.slice(0,hr).map(t=>this._importLine(t,i[t],a?.[t],e.specifier,r))} ${t.length>hr?I`<span class="bundle-compare-code-repointed-more">and ${t.length-hr} more ${t.length-hr===1?`line`:`lines`}</span>`:L}</li>`})}</ul></section>`}_importLine(e,t,n,r,i){let a=t.length>240?Math.max(0,t.indexOf(r)-80):0;return I`<button type="button" class="bundle-compare-code-repointed-line bundle-compare-diff-table" ?disabled="${!i}" aria-label="${`Go to line ${e+1}`}" @click="${()=>this._goToLine(e+1)}"><span class="diff-num">${e+1}</span> <code>${t.length<=240&&typeof n==`string`?kt(Ge(n,!0)):Se(`${a>0?`…`:``}${t.slice(a,a+240)}${t.length>a+240?`…`:``}`,!0)}</code></button>`}_goToLine(e){let t=`${this._current}\0source`;e>(this._limits.get(t)??q)&&(this._limits.set(t,Math.ceil(e/q)*q),this.requestUpdate()),this.updateComplete.then(()=>this.querySelector(`.bundle-compare-diff [data-line="${e}"]`)?.scrollIntoView({block:`center`}))}_renderSource(e,t,n,{key:r,pretty:i}){let a=this._model(r,t,t),o={model:a,b:this._highlighted(this._textSide(e),e,t,i?.status===`ready`?`pretty`:``)},s=new Set([...this._importLines(n,a.b).values()].flat()),c=`${e}\0source`,l=this._sought?.path===e&&this._sought.key!==r?this._soughtLine(e,this._entries.get(e),i,a):null;this._sought?.path===e&&(this._sought.key=r),l&&l.line<a.b.length&&(l.line>=(this._limits.get(c)??q)&&this._limits.set(c,Math.ceil((l.line+1)/q)*q),this._soughtRow={path:e,index:l.line});let u=this._limits.get(c)??q,d=a.b.length>u?a.b.slice(0,u):a.b;return I`<div class="bundle-compare-diff-table single" data-path="${e}" style="${P({"--diff-num-width":`${String(a.b.length).length+1}ch`})}" role="table" aria-label="Source">${F(d,(e,t)=>t,(e,t)=>I`<div class="${N({"diff-row":!0,ctx:!0,"is-import":s.has(t)})}" role="row" data-line="${t+1}"><span class="diff-num">${t+1}</span>${this._codeCell(o,`b`,t,null)}</div>`)}</div>${a.b.length>d.length?I`<div class="bundle-compare-code-more"><button type="button" class="bundle-compare-code-action" @click="${()=>{this._limits.set(c,u+q),this.requestUpdate()}}">Show ${Math.min(q,a.b.length-d.length).toLocaleString()} more lines</button> <span>${(a.b.length-d.length).toLocaleString()} not shown</span></div>`:L}`}_hides(e,t,n){let r=[e&&[`Renames`,Tr,J.ignoreRenames,()=>this._setRenames(!J.ignoreRenames)],t&&[`Whitespace`,Dr,J.ignoreWhitespace,()=>this._setWhitespace(!J.ignoreWhitespace)],n&&[`Type-only`,Er,J.ignoreTypes,()=>this._setTypes(!J.ignoreTypes)]].filter(Boolean);return r.length===0?L:I`<span class="bundle-compare-code-hide" role="group" aria-label="Hide"><span class="bundle-compare-code-hide-label" aria-hidden="true">Hide:</span>${r.map(([e,t,n,r])=>I`<mode-switch compact="compact" borderless .checked="${n}" accessible-label="${t}" label="${e}" @click="${r}"></mode-switch>`)}</span>`}_setWhitespace(e){J.ignoreWhitespace=e,this.requestUpdate()}_setTypes(e){J.ignoreTypes=e,this.requestUpdate()}_setRenames(e){J.ignoreRenames=e,e&&ct(),this.requestUpdate()}_renderDiff(e,t,{after:n,before:r,key:i,model:a,pretty:o,changes:s,hiding:c,warned:l=[],whitespace:u=null}){let{kind:d,basePath:f=e}=t,p=J.layout===`split`,m=this._sought?.path===e&&this._sought.key!==i?this._soughtLine(e,t,o,a):null;this._sought?.path===e&&(this._sought.key=i);let h=a.typeFolds,g=m?this._seekRows(i,a,m,p):null;g?.index>=0&&(this._soughtRow={path:e,index:g.index+ +!!p});let _=this._expansions.get(i)??new Map,v=g?.rows??Pn(a,_,{split:p}),y=this._limits.get(i)??q,b=v.length>y?v.slice(0,y):v,x=(e,t)=>e&&h?h.lineOf[t].map(t=>e[t]):e,S={model:a,a:d===`added`?null:x(this._highlighted(this.base,f,r,c?`renamed\0${this.other.integrity}\0${e}`:o?.status===`ready`?`pretty`:``),`a`),b:d===`removed`?null:x(this._highlighted(this.other,e,n,o?.status===`ready`?`pretty`:``),`b`),expand:(e,t)=>{let n=new Map(_);n.set(e,t===`all`?{all:!0}:{...n.get(e),[t]:(n.get(e)?.[t]??0)+W}),this._expansions.set(i,n),this.requestUpdate()}},C=h?.lines??{a:a.a.length,b:a.b.length},ee=String(Math.max(C.a,C.b,1)).length;return I`${J.ignoreRenames&&s?.reason?I`<p class="bundle-compare-code-note">Renamed names are shown: ${Vr[s.reason]??s.reason}.</p>`:L} ${Ar[u]?I`<p class="bundle-compare-code-note">${Ar[u]}</p>`:L} ${l.length>0?I`<p class="bundle-compare-code-note">${Hr(l)} <button type="button" @click="${()=>this._setRenames(!1)}">Show them marked</button></p>`:L}<div class="${N({"bundle-compare-diff-table":!0,split:p,unified:!p})}" data-path="${e}" style="${P({"--diff-num-width":`${ee+1}ch`})}" role="table" aria-label="Diff">${p?I`<div class="diff-row diff-split-head" role="row"><span class="diff-half">Before<strong data-tooltip-truncated data-tooltip="${this.baseName}">${this.baseName}</strong></span> <span class="diff-half">After<strong data-tooltip-truncated data-tooltip="${this.otherName}">${this.otherName}</strong></span></div>`:L} ${F(b,e=>this._rowKey(e),e=>p?this._splitRow(e,S):this._unifiedRow(e,S))}</div>${v.length>b.length?I`<div class="bundle-compare-code-more"><button type="button" class="bundle-compare-code-action" @click="${()=>{this._limits.set(i,y+q),this.requestUpdate()}}">Show ${Math.min(q,v.length-b.length).toLocaleString()} more rows</button> <span>${(v.length-b.length).toLocaleString()} not shown</span></div>`:L}`}_rowKey(e){return e.kind===`fold`?`f${e.run}:${e.a}`:e.kind===`types`?`t${e.a?.from??``}:${e.b?.from??``}`:e.kind===`change`?`c${e.left??``}:${e.right??``}`:`${e.kind}${e.a??``}:${e.b??``}`}_words(t,n,r){if(n==null||r==null)return null;let i=`${n}:${r}`;return t.words.has(i)||t.words.set(i,e(t.a[n],t.b[r])),t.words.get(i)}_code(e,t,n,r){let i=r&&!(e.endsWith(`\r`)&&n?.at(-1)?.[1]===e.length);if(typeof t==`string`)return kt(Ge(Rn(t,n),i));if(n){let t=zn(e,n);return t.map((e,n)=>{let r=Se(e.text,i&&n===t.length-1);return e.marked?I`<mark class="diff-word">${r}</mark>`:r})}return Se(e,i)}_cell(e,t,n,r,i){return n==null?I`<span class="diff-num"></span><span class="diff-sign"></span><span class="diff-code diff-empty"></span>`:I`<span class="diff-num">${Yr(e.model,t,n)}</span><span class="diff-sign">${r}</span>${this._codeCell(e,t,n,i)}`}_types({a:e,b:t}){let{from:n,to:r}=t??e;return I`<div class="diff-row diff-types" role="row"><span>Only types here · ${r-n===1?`line ${n+1}`:`lines ${n+1}\u2013${r}`}${t?``:` before`}</span> <button type="button" class="bundle-compare-code-action" @click="${()=>this._setTypes(!1)}">Show type-only changes</button></div>`}_noEol(e,t,n){return n!=null&&e.noEol[t]&&n===e[t].length-1}_fold(e,t){let n=e.count<=W;return I`<div class="diff-row diff-fold" role="row"><span class="diff-fold-actions">${!n&&e.down?I`<button type="button" aria-label="${`Show ${W} more lines below`}" data-tooltip="${`Show ${W} more lines`}" @click="${()=>t.expand(e.run,`top`)}"><svg viewBox="0 0 16 16" width="12" height="12" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M8 3v9m-4-4 4 4 4-4"/></svg></button>`:L} ${!n&&e.up?I`<button type="button" aria-label="${`Show ${W} more lines above`}" data-tooltip="${`Show ${W} more lines`}" @click="${()=>t.expand(e.run,`bottom`)}"><svg viewBox="0 0 16 16" width="12" height="12" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M8 13V4M4 8l4-4 4 4"/></svg></button>`:L} <button type="button" aria-label="${`Show all ${e.count} unchanged lines`}" data-tooltip="Show all" @click="${()=>t.expand(e.run,`all`)}"><svg viewBox="0 0 16 16" width="12" height="12" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m4 6 4-4 4 4M4 10l4 4 4-4"/></svg></button> </span><span class="diff-fold-label">${e.count.toLocaleString()} unchanged ${e.count===1?`line`:`lines`} · ${e.b+1}–${e.b+e.count}</span></div>`}_unifiedRow(e,t){let{model:n}=t;if(e.kind===`fold`)return this._fold(e,t);if(e.kind===`types`)return this._types(e);if(e.kind===`ctx`)return I`<div class="diff-row ctx" role="row"><span class="diff-num">${Yr(n,`a`,e.a)}</span>${this._cell(t,`b`,e.b,` `,null)}</div>`;let r=e.kind===`del`,i=r?this._words(n,e.a,e.pair)?.a:this._words(n,e.pair,e.b)?.b,a=n.marked?.has(e.change);return I`<div class="${`diff-row ${e.kind}${a?` renamed`:``}`}" role="row" data-tooltip="${a?`Renamed names alone`:L}">${r?I`<span class="diff-num">${Yr(n,`a`,e.a)}</span><span class="diff-num"></span><span class="diff-sign">−</span>${this._codeCell(t,`a`,e.a,i)}`:I`<span class="diff-num"></span><span class="diff-num">${Yr(n,`b`,e.b)}</span><span class="diff-sign">+</span>${this._codeCell(t,`b`,e.b,i)}`}</div>`}_codeCell(e,t,n,r){let i=e.model[t],a=e[t]?.[n],o=i[n],s=this._noEol(e.model,t,n),c=Kr.get(i);c||Kr.set(i,c=new Map);let l=c.get(n);return l&&l.markup===a&&l.ranges===r&&l.noEol===s||c.set(n,l={markup:a,ranges:r,noEol:s,drawn:this._code(o,a,r,!s)}),I`<span class="${N({"diff-code":!0,"diff-long":o.length>be})}">${l.drawn}${s?I`<span class="diff-no-eol" data-tooltip="No newline at end of file" aria-label="No newline at end of file">⊘</span>`:L}</span>`}_splitRow(e,t){let{model:n}=t;if(e.kind===`fold`)return this._fold(e,t);if(e.kind===`types`)return this._types(e);if(e.kind===`ctx`)return I`<div class="diff-row ctx" role="row"><span class="diff-half">${this._cell(t,`a`,e.a,` `,null)}</span> <span class="diff-half">${this._cell(t,`b`,e.b,` `,null)}</span></div>`;let r=e.paired?this._words(n,e.left,e.right):null,i=n.marked?.has(e.change);return I`<div class="${`diff-row change${i?` renamed`:``}`}" role="row" data-tooltip="${i?`Renamed names alone`:L}"><span class="${N({"diff-half":!0,del:e.left!==null,blank:e.left===null})}">${this._cell(t,`a`,e.left,`−`,r?.a)}</span> <span class="${N({"diff-half":!0,add:e.right!==null,blank:e.right===null})}">${this._cell(t,`b`,e.right,`+`,r?.b)}</span></div>`}};customElements.define(`bundle-compare-code`,li);var ui=Symbol.for(``),di=e=>{if(e?.r===ui)return e?._$litStatic$},fi=(e,...t)=>({_$litStatic$:t.reduce((t,n,r)=>t+(e=>{if(e._$litStatic$!==void 0)return e._$litStatic$;throw Error(`Value passed to 'literal' function must be a 'literal' result: ${e}. Use 'unsafeStatic' to pass non-literal values, but
|
|
26
|
-
take care to ensure page security.`)})(n)+e[r+1],e[0]),r:ui}),pi=new Map,mi=(e=>(t,...n)=>{let r=n.length,i,a,o=[],s=[],c,l=0,u=!1;for(;l<r;){for(c=t[l];l<r&&(a=n[l],(i=di(a))!==void 0);)c+=i+t[++l],u=!0;l!==r&&s.push(a),o.push(c),l++}if(l===r&&o.push(t[r]),u){let e=o.join(`$$lit$$`);(t=pi.get(e))===void 0&&(o.raw=o,pi.set(e,t=o)),n=s}return e(t,...n)})(
|
|
21
|
+
As published: +${n.additions.toLocaleString()} \u2212${n.deletions.toLocaleString()}`:``,u=r?`${r.aside.join(`, `)}${c}${l}`:null;if(i===0&&a===0){if((s||t.modified===!1)&&!o)return z`<span class="bundle-compare-code-line-counts unchanged" aria-label="No line changes">=</span>`;if(r&&o)return z`<span class="bundle-compare-code-line-counts unchanged" aria-label="${`No line changes with ${r.aside.join(`, `)}`}" data-tooltip="${`No line changes with ${u}`}">≈</span>`}let d=r&&(!n||i!==n.additions||a!==n.deletions);return z`<span class="bundle-compare-code-line-counts" aria-label="${`${i} added, ${a} removed lines`}" data-tooltip="${d?`With ${u}`:B}"><span class="${I({add:!0,empty:s&&i===0})}">+${i.toLocaleString()}</span> <span class="${I({del:!0,empty:t.kind===`added`||s&&a===0})}">−${a.toLocaleString()}</span></span>`}_countingState(e,t){return this._fileState(e,t,!0)}_shownCounts(e,t){if(!(j.bundleSourcePretty||q.ignoreWhitespace||q.ignoreRenames||q.ignoreTypes))return null;let n=`${Or(e)}\0${this._arrived}\0${this._forced.size}`,r=this._drawnCounts.get(e);if(r?.settings===n)return r.counts;let i=performance.now();if(this._countUntil??=i+_r,i>this._countUntil){this._countLater??=setTimeout(()=>{this._countLater=null,this.requestUpdate()});return}let a=this._countingState(e,t),{model:o}=a,s=kr(a),c=o&&s.length>0?{additions:o.additions,deletions:o.deletions,renamed:o.renamed,aside:s}:null;return this._drawnCounts.set(e,{settings:n,counts:c}),c}_lineCounts(e,t){if(this._counted.has(e))return this._counted.get(e);let n=performance.now();if(this._countUntil??=n+_r,n>this._countUntil)return this._countLater??=setTimeout(()=>{this._countLater=null,this.requestUpdate()}),null;let{before:r,after:i}=U(this.base,this.other,e,t),a=En(r,i);return this._counted.set(e,a),a}_noteDrawn(e,t){let{model:n}=t;return n&&this._drawnTotals.set(e,{settings:Or(e),counts:{additions:n.additions,deletions:n.deletions,renamed:n.renamed,aside:kr(t)}}),t}_largeCounts(e,t){let n=this._drawnTotals.get(e);if(n?.settings===Or(e))return n.counts.aside.length===0?{published:n.counts,shown:null}:{published:null,shown:n.counts};let r=q.ignoreTypes?U(this.base,this.other,e,t):null;return{published:null,shown:typeof r?.before==`string`&&typeof r.after==`string`&&ar(this.base,this.other,e,t,r,this._repaint,this.scope)===!0?{additions:0,deletions:0,renamed:0,aside:[Er]}:null}}_model(e,t,n,r={},i=q.ignoreWhitespace){let a=r.changes?.blocks??r.marks??null,o=this._models.get(e);return this._models.delete(e),o?.before===t&&o.after===n&&o.given===a||(o={model:yn(t,n,{...r,ignoreWhitespace:i}),before:t,after:n,given:a}),this._models.set(e,o),this._models.size>this._modelCap&&this._models.delete(this._models.keys().next().value),o.model}_counts(e,t,n,r,i){let a=r.changes?.blocks??r.marks??null,o=this._countModels.get(e);if(o?.before===t&&o.after===n&&o.given===a)return o.model;let s=r.changes?.blocks??A(t,n,i),c={blocks:s,...bn(s,r.marks)};return this._countModels.set(e,{model:c,before:t,after:n,given:a}),c}_fileState(e,t,r=!1){let i=U(this.base,this.other,e,t),a=typeof i.before==`string`&&typeof i.after==`string`,o=a?ar(this.base,this.other,e,t,i,this._repaint,this.scope):void 0,s=o===!0;if(s&&q.ignoreTypes){let t={a:[],b:[],blocks:[],additions:0,deletions:0,renamed:0,marked:new Set,noEol:{a:!1,b:!1},words:new Map};return r?{pretty:null,hiding:!1,model:t,spacesHidden:!1,typesHidden:!0}:this._noteDrawn(e,{...i,textual:a,large:!1,printing:null,pretty:null,key:null,generated:!1,renamed:!1,warned:[],hiding:!1,changes:null,model:t,whitespace:null,spacesHidden:!1,types:s,typesHidden:!0})}let c=o&&o!==!0?Jr(o,i):null,u=!!c&&q.ignoreTypes,d=a&&!u&&(!r||j.bundleSourcePretty)?this._printing(e,t,i):null,f=j.bundleSourcePretty&&d?.applies?d.copies:null,{before:p,after:m}=u?c:f?.status===`ready`?f:i,h=a&&Mr(e)&&Mr(t.basePath??e)&&[`ready`,`loading`,`error`].includes(f?.status)&&this._generated(e,t,i),g=h&&f.status===`ready`;!r&&a&&this._sought?.path===e&&!this._forced.has(e)&&this._large(e,p,m)&&this._forced.add(e);let _=a&&!this._forced.has(e)&&this._large(e,p,m),{basePath:v=e}=t,y=t=>{let n=g&&!_?l(this.base,v,i.before,this.other,e,i.after,t,this._repaint,f.hashes,!r&&this._renamesAlone,this.scope):null,o=n?.status===`ready`,s=o&&q.ignoreRenames,d=o&&!s,y=s&&n.reason===null?n.reads:[],b=o&&n.reason===null?n.marks.length>0||q.ignoreRenames&&n.before!==p:q.ignoreRenames&&h,x=`${Ur(e,f?.status===`ready`,{...q,ignoreWhitespace:t,ignoreRenames:s,markRenames:d})}${u?`\0types`:``}`,S=s?n.before:p,C=s?{changes:{blocks:n.blocks}}:d?{marks:n.marks}:{},w=a&&!_&&(!n||o||!q.ignoreRenames)?r?this._counts(x,S,m,C,t):this._model(x,S,m,C,t):null;return u&&w&&(w.typeFolds=c),{key:x,changes:n,warned:y,renamed:b,hiding:s,shown:S,model:w,ignoreWhitespace:t}},b=this._unlisted(e,t,i),x=y(q.ignoreWhitespace&&!b),S=q.ignoreWhitespace&&!b&&!!x.model&&(x.model.mixed??=n(x.shown,m,x.model.blocks));S&&(x=y(!1));let{key:C,changes:T,warned:ee,renamed:te,hiding:ne,shown:E,model:D}=x;if(d?.map&&f?.status===`ready`&&D&&(Object.hasOwn(D,`listingRefusal`)||(D.listingRefusal=w(this.base,this.other,v,e,i,{a:D.a??k(E),b:D.b??k(m),blocks:D.blocks})),D.listingRefusal!==null))return this._unrebuilt.set(`${v}\0${e}`,{status:`error`,message:`Its listings' diff wouldn't show every change: ${D.listingRefusal}`,retry:!1}),this._fileState(e,t,r);if(r)return{pretty:f,hiding:ne,model:D,spacesHidden:x.ignoreWhitespace,typesFolded:u};f?.status===`ready`&&D?this._noteRowless(e,D.blocks.length===0):D&&!u&&(this._blocks.set(`${q.ignoreWhitespace}\0${e}`,D.blocks),this._aligned.set(D.blocks,D));let re=D&&!b&&!q.ignoreWhitespace?this._whitespaceHidden(`${e}\0${f?.status===`ready`}\0${ne}`,E,m):null,ie=D===null||b?null:S?`mixed`:q.ignoreWhitespace?ti(D,E,m)?`hideable`:null:re.hides&&!re.mixed?`hideable`:null;return this._sought?.path===e&&(this._soughtSettling=f?.status===`loading`||q.ignoreRenames&&(T?.status===`loading`||T?.status===`error`)),this._noteDrawn(e,{...u?i:{before:E,after:m},textual:a,large:_,printing:d,pretty:f,key:C,generated:h,renamed:te,warned:ee,hiding:ne,changes:T,model:D,whitespace:ie,spacesHidden:x.ignoreWhitespace,types:s||!!c,typesFolded:u})}_unlisted(e,{basePath:t=e},{before:n,after:r}){return!Mn(e,r,jr(this.other,e))||!Mn(t,n,jr(this.base,t))}_whitespaceHidden(e,t,n){let r=this._spaced.get(e);return r?.before===t&&r.after===n||(r={before:t,after:n,hidden:On(t,n)}),this._spaced.delete(e),this._spaced.set(e,r),this._spaced.size>this._modelCap&&this._spaced.delete(this._spaced.keys().next().value),r.hidden}_generated(e,{kind:t,basePath:n=e},{before:r,after:i}){return t!==`repointed`&&s(this.base,this.other)&&Pr(this.base,n,r)&&Pr(this.other,e,i)}_printing(e,t,n){let{kind:r,basePath:i=e,modified:a}=t,{before:o,after:s}=n;if(r===`repointed`||a===!1||typeof o!=`string`||typeof s!=`string`||o===s)return null;let c=[[`base`,this.base,i,o],[`other`,this.other,e,s]];if(!c.every(([e,,t,n])=>n===``||x(this.base,this.other,e,t,n)))return null;let l=c.every(([,,e,t])=>t===``||Ye(e)),u=c.every(([,,e,t])=>t===``||et(e)),d=!l&&!u&&c.some(([,e,t,n])=>n!==``&&Pr(e,t,n)),f=c.map(([e,,t,n])=>n===``?{status:`ready`,text:n}:S(this.base,this.other,e,t,n,this._repaint)),p=this._unrebuilt.get(`${i}\0${e}`)??f.find(e=>e.status===`error`)??f.find(e=>e.status===`loading`)??f.find(e=>e.status===`off`)??{status:`ready`,before:f[0].text,after:f[1].text,hashes:f.map(e=>e.hash)},m=!l&&!u&&!d&&o!==``&&s!==``&&p.status===`ready`&&this._smaller(e,n,p);return{copies:p,json:l,map:u,minified:d,smaller:m,applies:l||u||d||m}}_large(e,t,n){let r=this._larges.get(e);if(r?.before===t&&r.after===n)return r.large;let i=J(t,n);return this._larges.set(e,{before:t,after:n,large:i}),i}_smaller(e,{before:t,after:n},r){let i=this._shorter.get(e);if(i?.before===t&&i.after===n&&i.printed===r.before&&i.printedAfter===r.after)return i.smaller;let a=(e,t)=>A(e,t).reduce((e,{a0:t,a1:n,b0:r,b1:i})=>e+n-t+i-r,0),o=!J(t,n)&&!J(r.before,r.after)&&a(r.before,r.after)<a(t,n);return this._shorter.set(e,{before:t,after:n,printed:r.before,printedAfter:r.after,smaller:o}),o}_fileMessage(e,{kind:t,modified:n,meta:r},{before:i,after:a,textual:o,large:s,model:c,pretty:l,hiding:u,warned:d=[],changes:f,whitespace:p,typesHidden:m=!1,typesFolded:h=!1}){let g=e=>F(e??0),_=lr(r),v=`${t===`renamed`?_?`Renamed, its contents the same.`:`Renamed without changes.`:`The contents are the same.`}${_?` ${_}`:``}`;if(o&&n===!1)return z`<div class="bundle-compare-code-message"><p>${v}</p></div>`;if(!o){if(t===`changed`&&n===!1)return z`<div class="bundle-compare-code-message">Binary file, its bytes the same · ${g(P(a))}. ${_}</div>`;let e=t===`added`?g(P(a)):t===`removed`?g(P(i)):`${g(P(i))} \u2192 ${g(P(a))}`;return z`<div class="bundle-compare-code-message">Binary file ${t} · ${e}. A text diff is not available.${_?` ${_}`:``}</div>`}if(s)return z`<div class="bundle-compare-code-message"><p>This diff is large (${(Xr(i)+Xr(a)).toLocaleString()} lines across both sides) and may take a few seconds to compute.</p><button type="button" class="bundle-compare-code-action" @click="${()=>{this._forced.add(e),this.requestUpdate()}}">Show diff</button></div>`;if(m)return z`<div class="bundle-compare-code-message"><p>Only types changed in this file.${_?` ${_}`:``}</p><button type="button" class="bundle-compare-code-action" @click="${()=>this._setTypes(!1)}">Show type-only changes</button></div>`;if(f?.status===`loading`&&q.ignoreRenames)return z`<div class="bundle-compare-code-message" aria-busy="true">Hiding renamed names…</div>`;if(f?.status===`error`&&q.ignoreRenames)return z`<div class="bundle-compare-code-message"><p>Couldn't hide renamed names: ${f.message}</p><button type="button" class="bundle-compare-code-action" @click="${()=>this._setRenames(!1)}">Show renamed names</button></div>`;if(c.blocks.length>0)return null;let y=l?.status===`ready`&&l.before===l.after,b=!y&&q.ignoreWhitespace&&p===`hideable`,x=!y&&u,S=[h&&`types`,b&&`whitespace`,x&&`renamed names`].filter(Boolean),C=y?`No actual code changes in this file.`:S.length>0?`Only ${S.join(` and `)} changed in this file.`:null;return z`<div class="bundle-compare-code-message"><p>${C?`${C}${_?` ${_}`:``}`:v}</p>${d.length>0?z`<p>${Hr(d)}</p>`:B} ${y?z`<button type="button" class="bundle-compare-code-action" @click="${()=>{j.bundleSourcePretty=!1,this.requestUpdate()}}">Show as published</button>`:B} ${h?z`<button type="button" class="bundle-compare-code-action" @click="${()=>this._setTypes(!1)}">Show type-only changes</button>`:B} ${b?z`<button type="button" class="bundle-compare-code-action" @click="${()=>this._setWhitespace(!1)}">Show whitespace changes</button>`:B} ${x?z`<button type="button" class="bundle-compare-code-action" @click="${()=>this._setRenames(!1)}">Show renamed names</button>`:B}</div>`}_fileName(e,t,n,r=B){let i=e=>n&&e.startsWith(n)?e.slice(n.length):e;return z`<span class="${I({"bundle-compare-code-pill":!0,[t.kind]:!0,pure:t.kind===`renamed`&&!t.modified})}">${dr[t.kind].label}</span> ${ht(e,this._format(e))} <span class="bundle-code-main-path mono" data-tooltip-truncated data-tooltip="${t.renamedFrom?`${t.renamedFrom} \u2192 ${e}`:e}">${t.renamedFrom?sn(i(t.renamedFrom),i(e)):i(e)}</span> ${r}${this._githubLink(e,t)}${this._fileTags(e,t)}`}_fileTags(e,t,n=!1){if(!n)return z`${this._entryTags(e,t)}${this._alertTags(e,t)}${this._runsTags(e,t)}${this._newHostTags(e,t)}${this._flagTags(e,t)}${this._readability(e,t)}${this._installTags(e,t)}${sr(t.meta)}`;let r=[this._alertTags(e,t),this._runsTags(e,t),this._newHostTags(e,t),this._flagTags(e,t,!1),this._treeTag(e,t),this._installTags(e,t,!0),sr(t.meta,!0)];return ii(r)?r:this._flagTags(e,t)}_githubLink(e,{kind:t,basePath:n=e}){let r=t===`removed`?Ue(this.base,n):Ue(this.other,e);return r?Ge(r):B}_alertTags(e,{kind:t,basePath:n=e}){let r=t===`removed`?this.baseAlerts?.get(n):this.otherAlerts?.get(e);return r?.length>0&&this.alertTags?this.alertTags(r):B}_newHostTags(e,{kind:t}){let n=t===`removed`?null:this.newHosts?.get(e);return n&&this.newHostTag?this.newHostTag(n):B}_runsTags(e,t){return[[De,ke],[je,Ne]].map(([n,r])=>{let{was:i,now:a}=this._reads(e,t,n);return t.kind===`removed`?r(i):r(a,i)})}_entryTags(e,{kind:t,basePath:n=e}){let r=Lr(t===`removed`?this.base:this.other).get(t===`removed`?n:e)??[];return[...Map.groupBy(r,({label:e})=>e)].map(([e,t])=>z`<span class="${`bundle-compare-code-entry${e===`license`?` is-license`:``}`}" data-tooltip="${t.map(({note:e})=>e).join(` · `)}">${e}</span>`)}_installTags(e,t,n=!1){if(!Rr.test(e))return B;let{kind:r,basePath:i=e}=t,{before:a,after:o}=U(this.base,this.other,e,t),s=new Map(r===`added`||a===void 0?[]:Br(this.base,i,a)),c=new Map(r===`removed`||o===void 0?[]:Br(this.other,e,o)),l=[...r===`removed`?s:c].map(([e,t])=>{let n=r===`removed`?t:s.get(e),i=n===void 0?`, new`:n===t?``:`, was: ${n}`;return z`<span class="bundle-compare-code-install" data-tooltip="${`${t}${i}`}">${e}</span>`});if(!n&&r!==`removed`)for(let[e,t]of s)c.has(e)||l.push(z`<span class="bundle-compare-code-install is-dropped" data-tooltip="${`No longer run on install: ${t}`}">${e}</span>`);return l}_reads(e,t,n=tt){let{kind:r,basePath:i=e}=t,{before:a,after:o}=U(this.base,this.other,e,t);return{was:r===`added`?null:a===void 0?void 0:n(this.base,i,a),now:r===`removed`||o===void 0?null:n(this.other,e,o)}}_readability(e,t){let{was:n,now:r}=this._reads(e,t),i=e=>z`${at(e)}${st(e)}`,a=!n||!r||_t(n)===_t(r)&&n.kind===r.kind?i(r??n):z`<span class="bundle-compare-code-readability">${i(n)}<span aria-hidden="true">→</span>${i(r)}</span>`;return z`${lt(r??n)}${a}`}_flagTags(e,t,n=!0){return t.kind===`removed`?dt(this.base,t.basePath??e,t.baseBytes,n):dt(this.other,e,t.otherBytes,n)}_treeTag(e,t){let{was:n,now:r}=this._reads(e,t),i=r??n;if(!i)return B;let a=i.category!==`map`&&yt.get(_t(i)).mark;return z`${lt(i,[`warn`])}${a?at(i,!0):B}`}_fileFigures({kind:e,baseBytes:t,otherBytes:n},r){let i=e=>F(e??0);return z`${r?.blocks.length>(r?.marked?.size??0)?ei(r.additions,r.deletions):B} ${r?.renamed>0?z`<span class="bundle-compare-code-renamed" aria-label="${`${r.renamed} lines differing in renamed names alone`}" data-tooltip="Lines differing in renamed names alone, marked">≈${r.renamed}</span>`:B} <span class="bundle-code-main-stats">${e===`added`?i(n):e===`removed`?i(t):`${i(t)} \u2192 ${i(n)}`}</span>`}_highlighted(e,t,n,r=``){if(!n)return null;let i=xt(t,jr(e,t),n);if(!i)return null;let a=`${e.integrity}\0${t}${r?`\0${r}`:``}`,o=Wr.get(a);return o?.text===n?o.lines:(Gr.has(a)||(Gr.add(a),(async()=>{let e=await qe(n,i),t=typeof e==`string`?Je(e):null;Wr.set(a,{text:n,lines:t?.length===n.split(`
|
|
22
|
+
`).length?t:null}),Gr.delete(a),this.isConnected&&this.requestUpdate()})()),null)}_renderFile(e,t){let n=this._entries.get(e),{kind:r}=n,i=this._fileState(e,n),{after:a,before:o,textual:s,model:c}=i,l=ri(n),u=s&&(!l||c?.blocks.length>0),d=this._order.indexOf(e),f=t&&e.startsWith(t)?e.slice(t.length):e,p=r===`repointed`&&o===void 0?z`<div class="bundle-compare-code-message">Neither bundle carries this importer's source.</div>`:l&&c?.blocks.length===0?this._renderSource(e,a,n.repointed,i):this._fileMessage(e,n,i)??this._renderDiff(e,n,i);return z`<header class="bundle-code-main-bar bundle-compare-code-bar"><span class="bundle-code-file-nav"><button type="button" class="focus-code-nav-btn" aria-label="Previous file" data-tooltip="Previous file" ?disabled="${d<=0}" @click="${()=>this._select(this._order[d-1])}">${ie}</button> <button type="button" class="focus-code-nav-btn" aria-label="Next file" data-tooltip="Next file" ?disabled="${d===-1?this._order.length===0:d>=this._order.length-1}" @click="${()=>this._select(this._order[d+1])}">${O}</button> </span>${this._fileName(e,n,t,z`<button type="button" class="bundle-code-copy-path" data-copy-path="${e}" aria-label="Copy file path">${re}</button>`)} <span class="bundle-code-main-spacer"></span> ${this._fileFigures(n,c)} ${this._toggles(u,Zr(i),i.renamed,i.whitespace===`hideable`,i.types)}</header><div class="bundle-compare-diff" tabindex="0" aria-label="${`Changes in ${f}`}">${this._dependencyChanges(e)} ${n.repointed?this._renderRepointed(e,n.repointed,[a,o].find(e=>typeof e==`string`&&e!==``)??null,s&&!u):B} ${p}</div>`}_toggles(e,t=null,n=!1,r=!1,i=!1){return z`${e?this._hides(n,r,i):B} ${t?z`<button type="button" class="${I({"bundle-compare-code-toggle":!0,"is-loading":t.status===`loading`,"is-error":t.status===`error`,"is-folded":_(t.json)})}" aria-pressed="${String(!!j.bundleSourcePretty)}" aria-busy="${t.status===`loading`?`true`:B}" aria-label="Pretty-print" data-tooltip="${`${h(t,t.json)}${$r(t.affects)}`}" @click="${()=>{ee(t.json),this.requestUpdate()}}">${p}</button>`:B} ${e?z`<span class="bundles-overview-sort bundle-compare-code-layout" role="group" aria-label="Diff layout">${[[`unified`,`Unified`],[`split`,`Split`]].map(([e,t])=>z`<button type="button" aria-pressed="${String(q.layout===e)}" @click="${()=>{q.layout=e,this.requestUpdate()}}">${t}</button>`)}</span>`:B}`}_importLines(e,t){let n=new Map;for(let{specifier:r}of e){if(n.has(r))continue;let e=[`'`,`"`,"`"].map(e=>`${e}${r}${e}`);n.set(r,t.flatMap((t,n)=>e.some(e=>t.includes(e))?[n]:[]))}return n}_textSide(e){return N(this.other).has(e)?this.other:this.base}_dependencyChanges(e){if(e!==`package.json`||!this.dependencies)return B;let{added:t,changed:n,removed:r}=this.dependencies,i=[...t.map(e=>[`added`,e]),...n.map(e=>[`changed`,e]),...r.map(e=>[`removed`,e])];if(i.length===0)return B;let a=[[t,`new`],[n,`updated`],[r,`removed`]].filter(([e])=>e.length>0).map(([e,t])=>`${e.length} ${t}`),o=Map.groupBy(i.flatMap(([,e])=>e.flags??[]),({label:e})=>e),s=this.openDependency;return z`<section class="bundle-compare-code-deps" aria-label="Dependency changes"><h4>Dependencies <span>${a.join(` · `)}</span>${[...o].map(([e,t])=>z`<span class="bundle-compare-code-deps-flagged">${t.length} ${e}</span>`)}</h4><ul>${i.map(([e,t])=>{let n=e===`changed`?z`<span class="bundle-compare-code-dep-range">${t.from} → <b>${t.to}</b></span>`:z`<span class="bundle-compare-code-dep-range">${t.range}</span>`,r=z`<span class="bundle-compare-code-dep-name">${t.name}</span>${t.kind?z`<span class="npm-dependency-kind">${t.kind}</span>`:B}${n}${this.dependencyTags?.(t,e)??B}`,i=`${{added:`New`,changed:`Updated`,removed:`Removed`}[e]}: ${t.name}`;return z`<li>${s&&t.opens?z`<button type="button" class="${`bundle-compare-code-dep is-${e}`}" aria-label="${i}" @click="${()=>s(t)}">${r}</button>`:z`<span class="${`bundle-compare-code-dep is-${e}`}" aria-label="${i}">${r}</span>`}</li>`})}</ul></section>`}_renderRepointed(e,t,n,r){let i=n?n.split(`
|
|
23
|
+
`):[],a=n?this._highlighted(this._textSide(e),e,n):null,o=this._importLines(t,i),s=e=>e===null?z`<code class="is-none">(none)</code>`:z`<code data-tooltip-truncated data-tooltip="${e||`(empty target)`}">${e||`(empty target)`}</code>`,{title:c}=ni(t);return z`<section class="bundle-compare-code-repointed" aria-label="${c}"><h4>${c} <b>${t.length}</b></h4><ul>${t.map(e=>{let t=o.get(e.specifier),n=`${e.conditions}${e.platform===null?``:` \xB7 Platform: ${e.platform}`}`;return z`<li><div class="bundle-compare-code-repointed-spec"><code data-tooltip-truncated data-tooltip="${e.specifier}">${e.specifier}</code> <span data-tooltip-truncated data-tooltip="${n}">${n}</span></div><div class="bundle-compare-code-repointed-targets"><span class="before"><span>Before</span>${s(e.baseTarget)}</span> <span aria-hidden="true">→</span> <span class="after"><span>After</span>${s(e.otherTarget)}</span></div>${t.slice(0,hr).map(t=>this._importLine(t,i[t],a?.[t],e.specifier,r))} ${t.length>hr?z`<span class="bundle-compare-code-repointed-more">and ${t.length-hr} more ${t.length-hr===1?`line`:`lines`}</span>`:B}</li>`})}</ul></section>`}_importLine(e,t,n,r,i){let a=t.length>240?Math.max(0,t.indexOf(r)-80):0;return z`<button type="button" class="bundle-compare-code-repointed-line bundle-compare-diff-table" ?disabled="${!i}" aria-label="${`Go to line ${e+1}`}" @click="${()=>this._goToLine(e+1)}"><span class="diff-num">${e+1}</span> <code>${t.length<=240&&typeof n==`string`?At(Ze(n,!0)):Te(`${a>0?`…`:``}${t.slice(a,a+240)}${t.length>a+240?`…`:``}`,!0)}</code></button>`}_goToLine(e){let t=`${this._current}\0source`;e>(this._limits.get(t)??K)&&(this._limits.set(t,Math.ceil(e/K)*K),this.requestUpdate()),this.updateComplete.then(()=>this.querySelector(`.bundle-compare-diff [data-line="${e}"]`)?.scrollIntoView({block:`center`}))}_renderSource(e,t,n,{key:r,pretty:i}){let a=this._model(r,t,t),o={model:a,b:this._highlighted(this._textSide(e),e,t,i?.status===`ready`?`pretty`:``)},s=new Set([...this._importLines(n,a.b).values()].flat()),c=`${e}\0source`,l=this._sought?.path===e&&this._sought.key!==r?this._soughtLine(e,this._entries.get(e),i,a):null;this._sought?.path===e&&(this._sought.key=r),l&&l.line<a.b.length&&(l.line>=(this._limits.get(c)??K)&&this._limits.set(c,Math.ceil((l.line+1)/K)*K),this._soughtRow={path:e,index:l.line});let u=this._limits.get(c)??K,d=a.b.length>u?a.b.slice(0,u):a.b;return z`<div class="bundle-compare-diff-table single" data-path="${e}" style="${L({"--diff-num-width":`${String(a.b.length).length+1}ch`})}" role="table" aria-label="Source">${R(d,(e,t)=>t,(e,t)=>z`<div class="${I({"diff-row":!0,ctx:!0,"is-import":s.has(t)})}" role="row" data-line="${t+1}"><span class="diff-num">${t+1}</span>${this._codeCell(o,`b`,t,null)}</div>`)}</div>${a.b.length>d.length?z`<div class="bundle-compare-code-more"><button type="button" class="bundle-compare-code-action" @click="${()=>{this._limits.set(c,u+K),this.requestUpdate()}}">Show ${Math.min(K,a.b.length-d.length).toLocaleString()} more lines</button> <span>${(a.b.length-d.length).toLocaleString()} not shown</span></div>`:B}`}_hides(e,t,n){let r=[e&&[`Renames`,Tr,q.ignoreRenames,()=>this._setRenames(!q.ignoreRenames)],t&&[`Whitespace`,Dr,q.ignoreWhitespace,()=>this._setWhitespace(!q.ignoreWhitespace)],n&&[`Type-only`,Er,q.ignoreTypes,()=>this._setTypes(!q.ignoreTypes)]].filter(Boolean);return r.length===0?B:z`<span class="bundle-compare-code-hide" role="group" aria-label="Hide"><span class="bundle-compare-code-hide-label" aria-hidden="true">Hide:</span>${r.map(([e,t,n,r])=>z`<mode-switch compact="compact" borderless .checked="${n}" accessible-label="${t}" label="${e}" @click="${r}"></mode-switch>`)}</span>`}_setWhitespace(e){q.ignoreWhitespace=e,this.requestUpdate()}_setTypes(e){q.ignoreTypes=e,this.requestUpdate()}_setRenames(e){q.ignoreRenames=e,e&&d(),this.requestUpdate()}_renderDiff(e,t,{after:n,before:r,key:i,model:a,pretty:o,changes:s,hiding:c,warned:l=[],whitespace:u=null}){let{kind:d,basePath:f=e}=t,p=q.layout===`split`,m=this._sought?.path===e&&this._sought.key!==i?this._soughtLine(e,t,o,a):null;this._sought?.path===e&&(this._sought.key=i);let h=a.typeFolds,g=m?this._seekRows(i,a,m,p):null;g?.index>=0&&(this._soughtRow={path:e,index:g.index+ +!!p});let _=this._expansions.get(i)??new Map,v=g?.rows??Nn(a,_,{split:p}),y=this._limits.get(i)??K,b=v.length>y?v.slice(0,y):v,x=(e,t)=>e&&h?h.lineOf[t].map(t=>e[t]):e,S={model:a,a:d===`added`?null:x(this._highlighted(this.base,f,r,c?`renamed\0${this.other.integrity}\0${e}`:o?.status===`ready`?`pretty`:``),`a`),b:d===`removed`?null:x(this._highlighted(this.other,e,n,o?.status===`ready`?`pretty`:``),`b`),expand:(e,t)=>{let n=new Map(_);n.set(e,t===`all`?{all:!0}:{...n.get(e),[t]:(n.get(e)?.[t]??0)+W}),this._expansions.set(i,n),this.requestUpdate()}},C=h?.lines??{a:a.a.length,b:a.b.length},w=String(Math.max(C.a,C.b,1)).length;return z`${q.ignoreRenames&&s?.reason?z`<p class="bundle-compare-code-note">Renamed names are shown: ${Vr[s.reason]??s.reason}.</p>`:B} ${Ar[u]?z`<p class="bundle-compare-code-note">${Ar[u]}</p>`:B} ${l.length>0?z`<p class="bundle-compare-code-note">${Hr(l)} <button type="button" @click="${()=>this._setRenames(!1)}">Show them marked</button></p>`:B}<div class="${I({"bundle-compare-diff-table":!0,split:p,unified:!p})}" data-path="${e}" style="${L({"--diff-num-width":`${w+1}ch`})}" role="table" aria-label="Diff">${p?z`<div class="diff-row diff-split-head" role="row"><span class="diff-half">Before<strong data-tooltip-truncated data-tooltip="${this.baseName}">${this.baseName}</strong></span> <span class="diff-half">After<strong data-tooltip-truncated data-tooltip="${this.otherName}">${this.otherName}</strong></span></div>`:B} ${R(b,e=>this._rowKey(e),e=>p?this._splitRow(e,S):this._unifiedRow(e,S))}</div>${v.length>b.length?z`<div class="bundle-compare-code-more"><button type="button" class="bundle-compare-code-action" @click="${()=>{this._limits.set(i,y+K),this.requestUpdate()}}">Show ${Math.min(K,v.length-b.length).toLocaleString()} more rows</button> <span>${(v.length-b.length).toLocaleString()} not shown</span></div>`:B}`}_rowKey(e){return e.kind===`fold`?`f${e.run}:${e.a}`:e.kind===`types`?`t${e.a?.from??``}:${e.b?.from??``}`:e.kind===`change`?`c${e.left??``}:${e.right??``}`:`${e.kind}${e.a??``}:${e.b??``}`}_words(t,n,r){if(n==null||r==null)return null;let i=`${n}:${r}`;return t.words.has(i)||t.words.set(i,e(t.a[n],t.b[r])),t.words.get(i)}_code(e,t,n,r){let i=r&&!(e.endsWith(`\r`)&&n?.at(-1)?.[1]===e.length);if(typeof t==`string`)return At(Ze(Ln(t,n),i));if(n){let t=Rn(e,n);return t.map((e,n)=>{let r=Te(e.text,i&&n===t.length-1);return e.marked?z`<mark class="diff-word">${r}</mark>`:r})}return Te(e,i)}_cell(e,t,n,r,i){return n==null?z`<span class="diff-num"></span><span class="diff-sign"></span><span class="diff-code diff-empty"></span>`:z`<span class="diff-num">${Yr(e.model,t,n)}</span><span class="diff-sign">${r}</span>${this._codeCell(e,t,n,i)}`}_types({a:e,b:t}){let{from:n,to:r}=t??e;return z`<div class="diff-row diff-types" role="row"><span>Only types here · ${r-n===1?`line ${n+1}`:`lines ${n+1}\u2013${r}`}${t?``:` before`}</span> <button type="button" class="bundle-compare-code-action" @click="${()=>this._setTypes(!1)}">Show type-only changes</button></div>`}_noEol(e,t,n){return n!=null&&e.noEol[t]&&n===e[t].length-1}_fold(e,t){let n=e.count<=W;return z`<div class="diff-row diff-fold" role="row"><span class="diff-fold-actions">${!n&&e.down?z`<button type="button" aria-label="${`Show ${W} more lines below`}" data-tooltip="${`Show ${W} more lines`}" @click="${()=>t.expand(e.run,`top`)}"><svg viewBox="0 0 16 16" width="12" height="12" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M8 3v9m-4-4 4 4 4-4"/></svg></button>`:B} ${!n&&e.up?z`<button type="button" aria-label="${`Show ${W} more lines above`}" data-tooltip="${`Show ${W} more lines`}" @click="${()=>t.expand(e.run,`bottom`)}"><svg viewBox="0 0 16 16" width="12" height="12" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M8 13V4M4 8l4-4 4 4"/></svg></button>`:B} <button type="button" aria-label="${`Show all ${e.count} unchanged lines`}" data-tooltip="Show all" @click="${()=>t.expand(e.run,`all`)}"><svg viewBox="0 0 16 16" width="12" height="12" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m4 6 4-4 4 4M4 10l4 4 4-4"/></svg></button> </span><span class="diff-fold-label">${e.count.toLocaleString()} unchanged ${e.count===1?`line`:`lines`} · ${e.b+1}–${e.b+e.count}</span></div>`}_unifiedRow(e,t){let{model:n}=t;if(e.kind===`fold`)return this._fold(e,t);if(e.kind===`types`)return this._types(e);if(e.kind===`ctx`)return z`<div class="diff-row ctx" role="row"><span class="diff-num">${Yr(n,`a`,e.a)}</span>${this._cell(t,`b`,e.b,` `,null)}</div>`;let r=e.kind===`del`,i=r?this._words(n,e.a,e.pair)?.a:this._words(n,e.pair,e.b)?.b,a=n.marked?.has(e.change);return z`<div class="${`diff-row ${e.kind}${a?` renamed`:``}`}" role="row" data-tooltip="${a?`Renamed names alone`:B}">${r?z`<span class="diff-num">${Yr(n,`a`,e.a)}</span><span class="diff-num"></span><span class="diff-sign">−</span>${this._codeCell(t,`a`,e.a,i)}`:z`<span class="diff-num"></span><span class="diff-num">${Yr(n,`b`,e.b)}</span><span class="diff-sign">+</span>${this._codeCell(t,`b`,e.b,i)}`}</div>`}_codeCell(e,t,n,r){let i=e.model[t],a=e[t]?.[n],o=i[n],s=this._noEol(e.model,t,n),c=Kr.get(i);c||Kr.set(i,c=new Map);let l=c.get(n);return l&&l.markup===a&&l.ranges===r&&l.noEol===s||c.set(n,l={markup:a,ranges:r,noEol:s,drawn:this._code(o,a,r,!s)}),z`<span class="${I({"diff-code":!0,"diff-long":o.length>we})}">${l.drawn}${s?z`<span class="diff-no-eol" data-tooltip="No newline at end of file" aria-label="No newline at end of file">⊘</span>`:B}</span>`}_splitRow(e,t){let{model:n}=t;if(e.kind===`fold`)return this._fold(e,t);if(e.kind===`types`)return this._types(e);if(e.kind===`ctx`)return z`<div class="diff-row ctx" role="row"><span class="diff-half">${this._cell(t,`a`,e.a,` `,null)}</span> <span class="diff-half">${this._cell(t,`b`,e.b,` `,null)}</span></div>`;let r=e.paired?this._words(n,e.left,e.right):null,i=n.marked?.has(e.change);return z`<div class="${`diff-row change${i?` renamed`:``}`}" role="row" data-tooltip="${i?`Renamed names alone`:B}"><span class="${I({"diff-half":!0,del:e.left!==null,blank:e.left===null})}">${this._cell(t,`a`,e.left,`−`,r?.a)}</span> <span class="${I({"diff-half":!0,add:e.right!==null,blank:e.right===null})}">${this._cell(t,`b`,e.right,`+`,r?.b)}</span></div>`}};customElements.define(`bundle-compare-code`,li);var ui=Symbol.for(``),di=e=>{if(e?.r===ui)return e?._$litStatic$},fi=(e,...t)=>({_$litStatic$:t.reduce((t,n,r)=>t+(e=>{if(e._$litStatic$!==void 0)return e._$litStatic$;throw Error(`Value passed to 'literal' function must be a 'literal' result: ${e}. Use 'unsafeStatic' to pass non-literal values, but
|
|
24
|
+
take care to ensure page security.`)})(n)+e[r+1],e[0]),r:ui}),pi=new Map,mi=(e=>(t,...n)=>{let r=n.length,i,a,o=[],s=[],c,l=0,u=!1;for(;l<r;){for(c=t[l];l<r&&(a=n[l],(i=di(a))!==void 0);)c+=i+t[++l],u=!0;l!==r&&s.push(a),o.push(c),l++}if(l===r&&o.push(t[r]),u){let e=o.join(`$$lit$$`);(t=pi.get(e))===void 0&&(o.raw=o,pi.set(e,t=o)),n=s}return e(t,...n)})(z),hi=25e3,Y=40,gi=e=>[...e].toSorted(([e],[t])=>e.localeCompare(t));function _i(e,t,n,{resolutions:r=[],max:i=hi}={}){let a=new Map,o=ln(n);if(o.size*2>=i)return{rows:1/0,models:a};let s=new Set(r.map(e=>e.parent).filter(e=>!o.has(e))),c=r.length*2+s.size;for(let[n,r]of gi(o)){c++;let{before:o,after:s}=U(e,t,n,r);if(r.modified===!1)c++;else if(typeof o==`string`&&typeof s==`string`){if(J(o,s))return{rows:1/0,models:a};let e=yn(o,s);a.set(n,e),c+=Math.max(Nn(e).length,1)}else c++;if(c>=i)break}return{rows:c,models:a}}var vi=class extends li{static properties={...li.properties,models:{attribute:!1}};constructor(){super(),this.models=null,this._modelCap=1/0,this._fileLimit=Y}_renamesAlone=!1;willUpdate(e){if(super.willUpdate(e),e.has(`models`))for(let[e,t]of this.models??[]){let n=this._entries.get(e);if(!n)continue;let{before:r,after:i}=U(this.base,this.other,e,n);this._models.set(Ur(e,!1,{ignoreWhitespace:!1,ignoreRenames:!1}),{model:t,before:r,after:i,given:null})}e.has(`files`)&&(this._fileLimit=Y,this._current=this._picked=null),(e.has(`path`)||e.has(`files`))&&this.path&&this.path!==this._current&&(this._goTo=this.path),e.has(`files`)&&(this._toTop=!0)}updated(){let e=this._goTo&&this._section(this._goTo);if(e)this._picked=this._goTo,e.scrollIntoView({block:`start`});else if(this._toTop){let e=this.querySelector(`.bundle-compare-diff`);e&&(e.scrollTop=0)}this._goTo=null,this._toTop=!1,this._current!==this._shownPath&&(this._shownPath=this._current,this.querySelector(`.bundle-compare-code-tree .bundle-code-tree-link.current`)?.scrollIntoView({block:`nearest`})),this._scrollSought()}_select(e,t=!0){!e||this.extensions?.canSelect?.()===!1||(this._current=this._picked=e,this.requestUpdate(),t&&this.updateComplete.then(()=>this._section(e)?.scrollIntoView({block:`start`})),this.dispatchEvent(new CustomEvent(`compare-code-select`,{detail:{path:e},bubbles:!0,composed:!0})))}_more(){this._fileLimit+=Y,this.requestUpdate()}_searchable(e){return e.modified!==!1&&e.kind!==`repointed`}_countingState(e,t){return this._states?.get(e)??super._countingState(e,t)}_section(e){return[...this.querySelectorAll(`.bundle-compare-all-file`)].find(t=>t.dataset.path===e)??null}_spy(){this._spying||this.extensions?.canSelect?.()===!1||(this._spying=requestAnimationFrame(()=>{this._spying=0;let e=this.querySelector(`.bundle-compare-diff`);if(!e||this.extensions?.canSelect?.()===!1)return;this._fileLimit<this._order.length&&e.scrollTop+2*e.clientHeight>=e.scrollHeight&&this._more();let{top:t,bottom:n}=e.getBoundingClientRect(),r=this._picked&&this._section(this._picked)?.getBoundingClientRect();if(r&&r.bottom>t&&r.top<n)return;this._picked=null;let i=null;for(let n of e.querySelectorAll(`:scope > .bundle-compare-all-file`)){if(n.getBoundingClientRect().top>t+4)break;i=n}let a=i?.dataset.path??this._order[0]??null;a!==this._current&&(this._current=a,this.requestUpdate(),this.dispatchEvent(new CustomEvent(`compare-code-select`,{detail:{path:a},bubbles:!0,composed:!0})))}))}_fileBody(e,t,n){let r=t.repointed?this._renderRepointed(e,t.repointed,[n.after,n.before].find(e=>typeof e==`string`&&e!==``)??null,!1):B,i=t.kind===`repointed`||t.kind===`renamed`&&!t.modified&&!!t.repointed&&!t.meta&&!(n.model?.blocks.length>0);return z`${this._dependencyChanges(e)}${r}${i?B:this._fileMessage(e,t,n)??this._renderDiff(e,t,n)}`}_fileContent(e,t,n,r){return z`<header class="bundle-code-main-bar bundle-compare-all-file-head">${this._fileName(e,t,r)} <span class="bundle-code-main-spacer"></span> ${this._fileFigures(t,n.model)}</header>${this._fileBody(e,t,n)}`}_layout(e,t){return z`<div class="bundle-code-view bundle-compare-code">${this._renderRail(e,this._current)}<div class="bundle-code-main">${t}</div></div>`}render(){let e=this._railState(),t=this.extensions?.fullPaths?``:e.prefix,n=this.extensions?.filterContent===!1?e.allOrder:e.order;this._order=n,this._goTo&&n.includes(this._goTo)&&(this._current=this._goTo),n.includes(this._current)||(this._current=n[0]??null),this._current&&(this._goTo||this._current!==this._shownPath)&&this._reveal(this._current,e.prefix);let r=n.indexOf(this._current);r>=this._fileLimit&&(this._fileLimit=Math.ceil((r+1)/Y)*Y);let i=n.map(e=>[e,this._entries.get(e)]),a=i.map(([e,t])=>({path:e,entry:t,file:this._fileState(e,t)})),o=a.reduce((e,{file:t})=>e+(t.model?.additions??0),0),s=a.reduce((e,{file:t})=>e+(t.model?.deletions??0),0);this._states=new Map(a.map(({path:e,file:t})=>[e,t]));let c=a.filter(({file:e})=>Zr(e)),l=c.map(({file:e})=>Zr(e)),u=l.filter(e=>e.status===`error`),d=u.length>0?{...u[0],failed:u.length,of:l.length}:l.find(e=>e.status===`loading`)??l[0]??null,f=d&&{...d,json:l.some(e=>e.json),affects:c.map(({path:e})=>e)},p=a.some(({file:e})=>e.model?.blocks.length>0||e.whitespace||e.hiding||e.types);return this._layout(e,z`<header class="bundle-code-main-bar bundle-compare-code-bar"><span class="bundle-compare-all-title">${i.length.toLocaleString()} ${i.length===1?`file`:`files`} changed</span> ${o+s>0?ei(o,s):B} <span class="bundle-code-main-spacer"></span> ${this._toggles(p,f,a.some(({file:e})=>e.renamed),a.some(({file:e})=>e.whitespace===`hideable`),a.some(({file:e})=>e.types))}</header><div class="bundle-compare-diff" tabindex="0" aria-label="Every change" @scroll="${()=>this._spy()}">${i.length===0?z`<div class="bundle-code-placeholder">${this._entries.size===0?`No files differ in this comparison.`:`No changed files match.`}</div>`:R(a.slice(0,this._fileLimit),({path:e})=>e,({path:e,entry:n,file:r})=>z`<section class="bundle-compare-all-file" aria-label="${e}" data-path="${e}">${this.extensions?.fileActions?z`<div class="bundle-compare-file-content">${this._fileContent(e,n,r,t)}</div>${this.extensions.fileActions(e,!0)}`:this._fileContent(e,n,r,t)}</section>`)} ${a.length>this._fileLimit?z`<button type="button" class="bundle-compare-code-action bundle-compare-all-more" @click="${()=>this._more()}">Show more files (${(a.length-this._fileLimit).toLocaleString()} remaining)</button>`:B}</div>`)}};customElements.define(`bundle-compare-all`,vi);function yi({base:e,other:t,diff:n,source:r,path:i,seek:a,baseName:o,otherName:s,select:c,extensions:l=null,mode:u}){let d=fn(n.resolutions),f=u?null:n.combined??=_i(e,t,n.files,{resolutions:d});u??=f.rows<hi?`diff`:`code`;let p=u===`diff`?fi`bundle-compare-all`:fi`bundle-compare-code`;return mi`<${p} .base=${e} .other=${t} .files=${n.files} .scope=${n.scope??``} .resolutions=${d}
|
|
27
25
|
.baseAlerts=${r?.files?.alerts?.(e)??null} .otherAlerts=${r?.files?.alerts?.(t)??null} .alertTags=${r?.files?.alertTags??null}
|
|
28
26
|
.newHosts=${r?.files?.newHosts?.(e,t)??null} .newHostTag=${r?.files?.newHostTag??null}
|
|
29
27
|
.dependencies=${r?.dependencies?.(e,t)??null} .openDependency=${r?.openDependency??null} .dependencyTags=${r?.dependencyTags??null}
|
|
30
28
|
.models=${f?.models??null} .path=${i} .seek=${a} .extensions=${l} baseName=${o} otherName=${s}
|
|
31
|
-
@compare-code-select=${e=>{e.stopPropagation(),c(e.detail.path)}}></${p}>`}var xi=400,Si=24,Ci=[`removed`,`added`,`changed`],X=null;function Z(e){return e.join(`, `)}var wi=class extends At{static properties={details:{attribute:!1},integrity:{attribute:!1},request:{attribute:!1},source:{attribute:!1},review:{attribute:!1},_targetIntegrity:{state:!0},_otherDetails:{state:!0},_status:{state:!0},_scope:{state:!0},_fileSort:{state:!0},_pkgSort:{state:!0},_openSections:{state:!0},_mode:{state:!0},_codePath:{state:!0},_codeSeek:{state:!0}};createRenderRoot(){return this}constructor(){super(),this.details=null,this.integrity=null,this.request=null,this.source=null,this._targetIntegrity=null,this._otherDetails=null,this._status=`idle`,this._scope=``,this._fileSort={removed:`name`,added:`name`,changed:`name`},this._pkgSort={removed:`size`,added:`size`,changed:`size`},this._openSections=new Set,this._mode=`overview`,this._codePath=null,this._codeSeek=null,this._repaint=()=>this.requestUpdate(),this._fitBody=null,this._fitObserver=null}connectedCallback(){super.connectedCallback(),this._fitBody&&this._fitObserver?.observe(this._fitBody)}disconnectedCallback(){super.disconnectedCallback(),this._fitObserver?.disconnect()}willUpdate(e){e.has(`source`)&&this.source&&!e.get(`source`)&&(this._openSections=new Set([...this._openSections,`files`])),(e.has(`_otherDetails`)||e.has(`details`))&&this._status===`ready`&&!o(this._otherDetails,this.details).some(e=>e.id===this._scope)&&(this._scope=``),e.has(`integrity`)&&this._rebase(),(e.has(`request`)||e.has(`integrity`))&&this.integrity&&this.request?.bundle===this.integrity?(this.request.target!==this._targetIntegrity&&this._choose(this.request.target),this._mode=Tt(this.request.mode)):e.has(`request`)&&!e.has(`integrity`)&&e.get(`request`)?.bundle===this.integrity&&(this._targetIntegrity&&this._choose(null),this._mode=`overview`)}updated(){let e=this.querySelector(`.bundle-compare-body`);e!==this._fitBody&&typeof ResizeObserver==`function`&&(this._fitObserver??=new ResizeObserver(()=>this._fitLists()),this._fitObserver.disconnect(),e&&this._fitObserver.observe(e),this._fitBody=e),this._fitLists()}_fitLists(){let e=this._fitBody;if(!e)return;let t=getComputedStyle(e),n=e.getBoundingClientRect().top+e.clientTop+parseFloat(t.paddingTop)-e.scrollTop,r=e=>{let t=e.getBoundingClientRect();return t.top-n+e.parentElement.getBoundingClientRect().bottom-t.bottom},i=e.querySelector(`.bundle-compare-rows--fill`);if(i){let t=r(i),n=i.closest(`.bundle-compare-section`);for(let e=n;e;e=e.nextElementSibling){let r=e.matches(`details[open]`)&&e.querySelector(`:scope > summary`),i=e===n?0:r?r.getBoundingClientRect().bottom+parseFloat(getComputedStyle(r).marginBottom)-e.getBoundingClientRect().top:e.getBoundingClientRect().height;t+=i+parseFloat(getComputedStyle(e).marginBottom)}e.style.setProperty(`--compare-fill-around`,`${t}px`)}let a=[...e.querySelectorAll(`.bundle-compare-rows--scroll:not(.bundle-compare-rows--fill)`)];if(a.length===0)return;let o=e.lastElementChild,s=new Map(a.filter(e=>o.contains(e)).map(e=>[e,e.parentElement.getBoundingClientRect().top])),c=Math.max(...s.values()),l=e.clientHeight-parseFloat(t.paddingTop)-parseFloat(t.paddingBottom),u=parseFloat(getComputedStyle(o).marginBottom);for(let e of a)s.get(e)>=c-1?e.style.setProperty(`--compare-rest`,`${l-r(e)-u}px`):e.style.removeProperty(`--compare-rest`)}_rebase(){let e=this._baseKey;if(X&&e&&e!==X.base&&(X=null),X&&e===X.base){let{target:e}=X;if(this._scope=X.scope,this._mode=X.mode,this._codePath=X.codePath,X=null,!e){this._targetIntegrity=null,this._otherDetails=null,this._status=`idle`;return}this._targetIntegrity=e;let t=this.source?null:C(e,e=>!!(e.json||e.bundle));t?(this._otherDetails=t,this._status=`ready`):(this._otherDetails=null,this._status=`loading`,this._loadOther(e))}else this._targetIntegrity=null,this._otherDetails=null,this._status=`idle`,this._scope=``,this._codePath=null}get _baseKey(){return this.source?this.source.base:this.integrity}_swap(){let e=this._targetIntegrity;e&&e!==this._baseKey&&this._reopen(e,this._baseKey)}_pickBase(e){!e||e===this._baseKey||(e===this._targetIntegrity?this._swap():this._reopen(e,this._targetIntegrity))}_reopen(e,t){if(this.source){X={base:e,target:t,scope:this._scope,mode:this._mode,codePath:this._codePath},this.source.open(e,t,this._mode);return}if(!_e(E.bundles??[],this.integrity).some(t=>t.integrity===e))return;X={base:e,target:t,scope:this._scope,mode:this._mode,codePath:this._codePath};let n=[this._otherDetails,this._baseReady?this.details:null].filter(n=>n&&!n.error&&(n.json||n.bundle)&&[e,t].includes(n.integrity));this.dispatchEvent(new CustomEvent(`bundle-swap`,{bubbles:!0,composed:!0,detail:{integrity:e,target:t,bundles:n,mode:this._mode}}))}_nameFor(e){return this.source?this.source.name(e):(E.bundles??[]).find(t=>t.integrity===e)?.name??`${e.slice(0,15)}\u2026`}_pick(e){this._choose(e),this._notify()}_notify(){this.dispatchEvent(new CustomEvent(`bundle-compare-change`,{bubbles:!0,composed:!0,detail:{base:this.integrity,target:this._targetIntegrity,mode:this._mode}}))}_choose(e){let t=e||null;this._targetIntegrity=t,this._otherDetails=null,this._codePath=null,t?(this._status=`loading`,this._loadOther(t)):(this._status=`idle`,this._scope=``)}async _loadOther(e){if(this.source){let t;try{t=await this.source.load(e)}catch(e){if(e.name===`AbortError`)return;t={error:e.message}}if(this._targetIntegrity!==e)return;this._otherDetails=t,this._status=`ready`,t?.compareId&&t.compareId!==e&&(this._targetIntegrity=t.compareId,this._notify());return}let t=_e(E.bundles??[],this.integrity).find(t=>t.integrity===e);if(!t){this._status=`idle`,this._targetIntegrity=null,this._notify();return}let n;try{n=await ne(e,t)}catch(e){if(e.name===`AbortError`)return;throw e}this._targetIntegrity===e&&(this._otherDetails=n,this._status=`ready`)}get _baseReady(){return!!(this.details&&this.details.integrity===this.integrity&&(this.details.json||this.details.bundle))}_openFile(e){this._codePath=e,this._mode=`code`,this._notify()}_openLine({path:e,line:t,query:n}){this._codeSeek={path:e,line:t-1,query:n},this._openFile(e)}_fileRow(e,t,n,r=e,i=!1,a=void 0,o=e,s=void 0){let c=this.source?.files;return I`<li><button type="button" class="bundle-compare-row bundle-compare-row-link" @click="${()=>this._openFile(e)}">${c?c.icon(e,[[this._otherDetails,o],[this.details,e]]):L}<span class="bundle-compare-row-path mono" data-tooltip-truncated data-tooltip="${r}">${t}</span>${i?c?.tag?.(this.details,e,s)??L:L}${sr(a)}${n}</button></li>`}_group(e,t,n,r,i,a=L,{fill:o=!1,lanes:s=Ci,style:c={}}={}){return t.length===0?L:I`<section class="${`bundle-compare-group bundle-compare-${n}`}" style="${P({"--compare-lane":String(s.indexOf(n)+1),...c})}"><header class="bundle-compare-group-head"><span class="bundle-compare-dot" aria-hidden="true"></span> <span class="bundle-compare-group-title" data-tooltip-truncated data-tooltip="${e}">${e}</span> <span class="bundle-compare-group-count">${t.length}</span> ${a}</header><ul class="${o?`bundle-compare-rows bundle-compare-rows--scroll bundle-compare-rows--fill`:`bundle-compare-rows bundle-compare-rows--scroll`}">${F(t,r,i)}</ul></section>`}_sizeCells(e){let t=e=>e==null?`—`:M(e),n=e=>`${e.toLocaleString()} LoC`;return e.delta===void 0?I`<span class="bundle-compare-row-size" data-tooltip="${e.lines>0?n(e.lines):L}">${t(e.bytes)}</span>`:I`<span class="${`bundle-compare-row-delta ${e.delta===null?``:R(e.delta)}`}" data-tooltip="${`${t(e.baseBytes)} \u2192 ${t(e.otherBytes)}${e.baseLines>0||e.otherLines>0?` \xB7 ${e.baseLines.toLocaleString()} \u2192 ${n(e.otherLines)}`:``}`}">${e.delta===null?`—`:Mt(e.delta)}</span>`}_sortActions(e,t,n,r=!1,i=this[e][t]){return I`<span class="bundles-overview-sort" role="group" aria-label="${`${t} ${n} order`}">${[[`name`,`Name`],[`size`,`Size`],...r?[[`flags`,`Flags`]]:[]].map(([n,r])=>I`<button type="button" aria-pressed="${String(i===n)}" @click="${()=>{this[e]={...this[e],[t]:n}}}">${r}</button>`)}</span>`}_fileGroup(e,t,n,r,i){let a=this.source?.files,o=n!==`removed`,s=e=>n===`added`?null:{details:this._otherDetails,path:e.basePath??e.path},c=e=>[...o&&a?.flags?a.flags(this.details,e.path,s(e)):[],...cr(e.meta)],l=t.some(e=>c(e).length>0),u=this._fileSort[n]===`flags`&&!l?`name`:this._fileSort[n],d=e=>n===`changed`?Math.abs(e.delta):e.bytes,f=u===`flags`?je(t,c,e=>e.path):t.toSorted((e,t)=>(u===`size`?d(t)-d(e):0)||e.path.localeCompare(t.path));return this._group(e,f,n,e=>e.path,e=>e.renamedFrom==null?this._fileRow(e.path,r(e.path),this._sizeCells(e),e.path,o,e.meta,e.basePath??e.path,s(e)):this._fileRow(e.path,an(r(e.renamedFrom),r(e.path)),this._sizeCells(e),`${e.renamedFrom} \u2192 ${e.path}`,o,e.meta,e.basePath??e.path,s(e)),this._sortActions(`_fileSort`,n,`file`,l,u),{lanes:i})}_pkgGroup(e,t,n,r){let i=this._pkgSort[n],a=e=>{let t=n===`changed`?e.delta:e.bytes;return t==null?-1:Math.abs(t)},o=t.toSorted((e,t)=>(i===`size`?a(t)-a(e):0)||Ct(e.pkg).localeCompare(Ct(t.pkg))),s=n===`changed`?0:Math.min(Si,Math.max(0,...t.map(e=>Z(e.versions).length)));return this._group(e,o,n,e=>e.pkg,e=>I`<li><div class="bundle-compare-row"><span class="bundle-compare-pkg-dot" style="${P({background:xt(e.pkg)})}"></span> <span class="bundle-compare-row-path" data-tooltip-truncated data-tooltip="${Ct(e.pkg)}">${Ct(e.pkg)}</span> ${n===`changed`?this._versionCell(e):s>0?I`<span class="bundle-compare-dep-ver" data-tooltip-truncated data-tooltip="${Z(e.versions)}">${Z(e.versions)}</span>`:L} ${this._sizeCells(n===`changed`?e:{bytes:e.bytes})}</div></li>`,this._sortActions(`_pkgSort`,n,`package`),{fill:!0,lanes:r,style:s>0?{"--compare-version-width":`${s}ch`}:{}})}_versionCell(e){let t=e.otherVersions,n=e.baseVersions;if(n.join()===t.join())return n.length>0?I`<span class="bundle-compare-dep-ver">${Z(n)}</span>`:L;let r=e.direction??`changed`,i=r===`up`?`↑`:r===`down`?`↓`:`±`;return I`<span class="bundle-compare-ver" aria-label="${`${r===`up`?`Upgraded`:r===`down`?`Downgraded`:`Changed`}: ${Z(n)||`none`} to ${Z(t)||`none`}`}"><span class="bundle-compare-ver-from">${Z(n)||`—`}</span> <span class="bundle-compare-ver-arrow" aria-hidden="true">→</span> <span class="${`bundle-compare-ver-to ${r}`}">${Z(t)||`—`}</span> <span class="${`bundle-compare-ver-dir ${r}`}" aria-hidden="true">${i}</span></span>`}_depGroup(e,t,n,r){let i=n===`changed`?0:Math.min(Si,Math.max(0,...t.map(e=>e.range.length))),a=e=>I`<span class="bundle-compare-row-path" data-tooltip-truncated data-tooltip="${e.name}">${e.name}</span> ${this.source?.dependencyTags?.(e,n)??L}${e.kind?I`<span class="npm-dependency-kind">${e.kind}</span>`:L} ${n===`changed`?I`<span class="bundle-compare-ver" aria-label="${`Changed: ${e.from} to ${e.to}`}"><span class="bundle-compare-ver-from">${e.from}</span> <span class="bundle-compare-ver-arrow" aria-hidden="true">→</span> <span class="bundle-compare-ver-to changed">${e.to}</span></span>`:I`<span class="bundle-compare-dep-ver" data-tooltip-truncated data-tooltip="${e.range}">${e.range}</span>`}`,o=this.source?.openDependency;return this._group(e,t,n,e=>e.key,e=>I`<li>${o&&e.opens?I`<button type="button" class="bundle-compare-row bundle-compare-row-link" @click="${()=>o(e)}">${a(e)}</button>`:I`<div class="bundle-compare-row">${a(e)}</div>`}</li>`,L,{fill:!0,lanes:r,style:i>0?{"--compare-version-width":`${i}ch`}:{}})}_renderDependencies(e,t,n,r){return r.length===0?L:I`<section class="bundle-compare-section"><h3 class="bundle-compare-section-head">Dependencies</h3>${this._cols(r,I`${this._depGroup(`Removed \xB7 only in ${t}`,e.removed,`removed`,r)} ${this._depGroup(`Added \xB7 only in ${n}`,e.added,`added`,r)} ${this._depGroup(`Changed`,e.changed,`changed`,r)}`,`dependencies`)}</section>`}_renderPackages(e,t,n,r=Ci){return e.removed.length===0&&e.added.length===0&&e.changed.length===0?L:I`<section class="bundle-compare-section"><h3 class="bundle-compare-section-head">Packages</h3>${this._cols(r,I`${this._pkgGroup(`Removed \xB7 only in ${t}`,e.removed,`removed`,r)} ${this._pkgGroup(`Added \xB7 only in ${n}`,e.added,`added`,r)} ${this._pkgGroup(`Changed`,e.changed,`changed`,r)}`,`packages`)}</section>`}_cols(e,t,n){let r=e.map(e=>e===`changed`?`minmax(0, 5fr)`:`minmax(0, 4fr)`).join(` `);return I`<div class="bundle-compare-cols" data-lanes="${e.length}" data-section="${n}" style="${P({"--compare-lanes":r})}">${t}</div>`}_collapsible(e,t,n,r,i=``){let a=this._openSections.has(e);return I`<details class="bundle-compare-section bundle-compare-collapsible" .open="${k(a)}" @toggle="${t=>this._setSection(e,t.currentTarget.open)}"><summary class="bundle-compare-section-head" @click="${t=>{t.preventDefault(),this._setSection(e,!a)}}">${t} <span class="bundle-compare-section-count">${n.toLocaleString()}</span>${i?I`<span class="bundle-compare-section-note" data-tooltip-truncated data-tooltip="${i}">${i}</span>`:L}</summary>${a?r():L}</details>`}_setSection(e,t){if(t===this._openSections.has(e))return;let n=new Set(this._openSections);t?n.add(e):n.delete(e),this._openSections=n}_renderResolutions(e,t,n){if(e.totalChanges===0)return L;let r=[{title:`Removed \xB7 only in ${t}`,rows:e.onlyBase,kind:`removed`},{title:`Added \xB7 only in ${n}`,rows:e.onlyOther,kind:`added`},{title:`Repointed`,rows:e.changed,kind:`changed`}].filter(({rows:e})=>e.length>0).map(e=>({...e,shown:e.rows.slice(0,xi)})),i=(e,t=``)=>I`<td class="${t}"><code data-tooltip-truncated data-tooltip="${e}">${e}</code></td>`,a=(e,t)=>e===null?I`<td class="bundle-compare-resolution-none"><span>(none)</span></td>`:i(e||`(empty target)`,t),o=e=>`${e.conditions}${e.platform===null?``:` \xB7 Platform: ${e.platform}`}`,s=r.some(({shown:e})=>e.some(e=>o(e)!==`*`));return this._collapsible(`resolutions`,`Import resolutions`,e.totalChanges,()=>r.map(({title:e,rows:t,kind:n,shown:r})=>I`<section class="${`bundle-compare-group bundle-compare-${n} bundle-compare-resolutions`}"><header class="bundle-compare-group-head"><span class="bundle-compare-dot" aria-hidden="true"></span> <span class="bundle-compare-group-title">${e}</span> <span class="bundle-compare-group-count">${t.length}</span></header><table class="${s?``:`bundle-compare-resolutions--no-context`}"><thead><tr><th>File</th><th>Import</th><th>Before</th><th>After</th>${s?I`<th>Conditions</th>`:L}</tr></thead><tbody>${F(r,e=>e.key,e=>{let t=o(e);return I`<tr><td><button type="button" class="bundle-compare-resolution-parent" data-tooltip-truncated data-tooltip="${e.parent}" @click="${()=>this._openFile(e.parent)}">${e.parent}</button></td>${i(e.specifier)} ${a(e.baseTarget,`bundle-compare-resolution-before`)} ${a(e.otherTarget,`bundle-compare-resolution-after`)} ${s?I`<td class="bundle-compare-resolution-context"><span data-tooltip-truncated data-tooltip="${t}">${t}</span></td>`:L}</tr>`})}</tbody></table>${t.length>r.length?I`<div class="bundle-compare-more">and ${(t.length-r.length).toLocaleString()} more…</div>`:L}</section>`))}_comparison(){return nn(this._otherDetails,this.details,this._scope,this._repaint)}_renderSummary(e){return zt(e,I`<div class="bundle-compare-modes" role="tablist" aria-label="Comparison view">${[[`overview`,`Overview`],[`code`,`Code`]].map(([e,t])=>I`<button type="button" role="tab" aria-selected="${String(this._mode===e)}" @click="${()=>{this._mode=e,this._notify()}}">${t}</button>`)}</div>`)}_renderPicker(e,t,n,r){return Rt({source:this.source,from:{options:e,value:this._targetIntegrity,pick:e=>this._pick(e)},to:{options:this._baseOptions(),value:this._baseKey,placeholder:this._nameFor(this.integrity),pick:e=>this._pickBase(e)},clear:t?{run:()=>this._pick(null)}:null,swap:t&&this.source?.canSwap?.(this._targetIntegrity)!==!1?()=>this._swap():null,extras:n,comparison:r,openLine:e=>this._openLine(e)})}_baseOptions(){if(this.source)return z(this.source.choices??[]);let e=(E.bundles??[]).find(e=>e.integrity===this.integrity),t=_e(E.bundles??[],this.integrity);return this._bundleOptions(e?[e,...t]:t)}_otherOptions(){return this.source?z(this.source.options):this._bundleOptions(_e(E.bundles??[],this.integrity))}_bundleOptions(e){let t=new Map;for(let n of e)t.set(n.name,(t.get(n.name)??0)+1);return e.map(e=>({id:e.integrity,integrity:e.integrity,kind:e.kind??(e.name.toLowerCase().endsWith(`.map`)?`sourcemap`:`stasis`),summary:e.summary,size:typeof e.size==`number`?M(e.size):`—`,filename:t.get(e.name)>1?`${e.name} \xB7 ${e.integrity.slice(7,13)}\u2026`:e.name}))}render(){let e=this._otherOptions(),t=!!this._targetIntegrity&&(!!this.source||e.some(e=>e.integrity===this._targetIntegrity)),n=this._baseReady?o(t?this._otherDetails:null,this.details):[],r=n.length>0?I`<bundle-scope-selector .reasons="${n}" .value="${this._scope}" label="Compare scope" @scope-change="${e=>{this._scope=e.detail.value}}"></bundle-scope-selector>`:L,i=this.source?.noun??`bundle`,a=t&&this._status===`ready`&&this._otherDetails&&(this._otherDetails.json||this._otherDetails.bundle)&&!this._otherDetails.error,s=this._baseReady&&a?this._comparison():null,c=s?.status===`ready`?s.diff:null,l=c?{base:this._otherDetails,other:this.details,files:c.files}:null,u=e.length>0||this.source?this._renderPicker(e,t,r,l):r,d=c?this._mode:`overview`,f;return this._baseReady?this.source&&!t&&(this.source.pending||this.source.error||!this.source.select&&e.length===0)?f=I`<div class="${`bundle-compare-empty${this.source.error?` is-error`:``}`}">${this.source.pending?`Loading ${i}s\u2026`:this.source.error??I`No other ${i}s to compare <strong>${this._nameFor(this.integrity)}</strong> with.`}</div>`:e.length===0&&!this.source?f=I`<div class="bundle-compare-empty">No other bundles to compare with. Drop a second <code>.map</code> or <code>.stasis.code.br</code> bundle to diff against this one.</div>`:t?this._status===`loading`||!this._otherDetails?f=I`<div class="bundle-compare-empty">Comparing…</div>`:this._otherDetails.error?f=I`<div class="bundle-compare-empty is-error">Couldn't read the selected ${i}: ${this._otherDetails.error}</div>`:!this._otherDetails.json&&!this._otherDetails.bundle?f=I`<div class="bundle-compare-empty is-error">The selected ${i} couldn't be parsed.</div>`:s?.status===`error`?f=I`<div class="bundle-compare-empty is-error">Couldn't compare the ${i}s: ${s.message}</div>`:c?d!==`code`&&(f=this._renderDiff(c)):f=I`<div class="bundle-compare-empty">Comparing…</div>`:f=I`<div class="bundle-compare-empty">Pick a ${i} above to compare <strong>${this._nameFor(this.integrity)}</strong> against.</div>`:f=I`<div class="bundle-compare-empty">Loading bundle…</div>`,I`<div class="bundle-compare">${Bt(u,c?this._renderSummary(c):L)} ${d===`code`?bi({base:this._otherDetails,other:this.details,diff:c,source:this.source,path:this._codePath,seek:this._codeSeek,baseName:this._nameFor(this._targetIntegrity),otherName:this._nameFor(this.integrity),select:e=>{this._codePath=e}}):I`<div class="bundle-compare-body">${f}</div>`}</div>`}_renderDiff(e){let t=this._nameFor(this._targetIntegrity),n=this._nameFor(this.integrity),r=[...e.files.onlyBase.map(e=>e.path),...e.files.onlyOther.map(e=>e.path),...e.files.changed.flatMap(e=>e.renamedFrom==null?[e.path]:[e.path,e.renamedFrom])],i=a(e.files.root,St(r).prefix),{prefix:o}=i,s=e=>o&&e.startsWith(o)?e.slice(o.length):e,c=e.files.onlyBase.length+e.files.onlyOther.length+e.files.changed.length,l={removed:e.files.onlyBase,added:e.files.onlyOther,changed:e.files.changed},u=!e.totals.identical,d=this.source?.dependencies?.(this._otherDetails,this.details)??null,f=Ci.filter(t=>(d??e.packageRows)[t].length>0),p=u?Ci.filter(e=>l[e].length>0):[],m=p.every(e=>f.includes(e))?f:p,h=u?this.source?.files?.warning?.(this.details,[...l.added,...l.changed].map(e=>e.path)):L;return I`${d?this._renderDependencies(d,t,n,f):this._renderPackages(e.packageRows,t,n,f)} ${h??L} ${e.totals.identical?e.resolutions.totalChanges>0?I`<div class="bundle-compare-caption">File contents are unchanged; import resolutions differ.</div>`:I`<div class="bundle-compare-identical">These two ${this.source?.noun??`bundle`}s carry identical files (${e.totals.unchangedFiles.toLocaleString()} ${e.totals.unchangedFiles===1?`file`:`files`})${i.from?I`, moved <span class="mono">${on(i)}</span>`:``}.</div>`:this._collapsible(`files`,`Files`,c,()=>this._cols(m,I`${this._fileGroup(`Removed \xB7 only in ${t}`,l.removed,`removed`,s,m)} ${this._fileGroup(`Added \xB7 only in ${n}`,l.added,`added`,s,m)} ${this._fileGroup(`Changed`,l.changed,`changed`,s,m)}`,`files`),i.from?`${i.from} \u2192 ${i.to}`:o)} ${this._renderResolutions(e.resolutions,t,n)}`}};customElements.define(`bundle-compare`,wi);var Q=e=>e._blocked||e._loading,Ti=e=>e._shownReview?.publishedAt!=null,Ei=e=>e.coverage===`full`?`Full`:`Partial`,Di=e=>e._error?I`<p class="npm-review-error" role="alert">${e._error}</p>`:L,Oi=e=>e._saveBlocked?I`<div class="npm-review-saving" role="status">Saving changes…</div>`:L,ki=e=>[e._continuation?.review,...e._reviews].filter(Boolean).toSorted((e,t)=>+(e.publishedAt!==null)-(t.publishedAt!==null)||(t.publishedAt??t.time)-(e.publishedAt??e.time)),Ai=e=>`npm-review-button npm-review-primary npm-review-finalize ${e._allowedVerdicts[0]}`,ji=(e,t,n,r,i=Object.keys(We),a=!1)=>I`<div class="npm-review-verdict-options" role="group" aria-label="Verdict">${Object.entries(a?{"":`Not checked`,...We}:We).map(([a,o])=>I`<label class="${`npm-review-verdict-choice ${a||`unchecked`}`}"><input type="radio" name="${e}" aria-label="${o}" value="${a}" .checked="${k(t===a)}" ?disabled="${r||a!==``&&!i.includes(a)}" @change="${()=>n(a)}">${o}</label>`)}</div>`;function Mi(e){let t=Ti(e),n=e._shownReview,r=e._summary,i=e._canEdit?{label:`Finalize review`,run:()=>e._beginPublish(),disabled:!r.checkedFiles}:!t||!e._writable?null:e._activeReview||e._ownPublished.length===0?{label:`Resume your review`,run:()=>e._resume()}:n.user===e.session?.id?{label:`Revise review`,run:()=>e._change({action:`continue`,reviewId:n.id,revision:n.revision})}:null;return I`<div class="npm-review-summary-actions">${t||e._draftStarted?Ze(n??{publishedAt:null,revokedAt:null}):L}<div class="npm-review-progress-block"><span>${e._unsaved&&(e._saveBlocked||e._error)?I`<button type="button" class="npm-review-button npm-review-text-button" @click="${()=>e._openPanel(`unsaved`)}">Unsaved changes</button>`:I`<strong>${r.checkedFiles} of ${r.totalFiles}</strong> files checked`}</span> ${rt(r.checkedFiles,r.totalFiles)}</div>${i?I`<button type="button" class="${e._canEdit?Ai(e):`npm-review-button`}" ?disabled="${Q(e)||i.disabled}" @click="${i.run}">${i.label} ${T}</button>`:L}</div>`}function Ni(e){let t=e.source??Ne(e.entry),n=!!(e._target&&e._target!==`(empty)`),r=z(t.options,t=>`${e.entry.npm.name}@${t.id}`);n&&!r.some(t=>t.id===e._target)&&r.push(...z([{id:e._target,name:e._target,format:`npm`}]));let i=z(t.choices);i.some(t=>t.id===e.entry.npm.version)||i.push(...z([{id:e.entry.npm.version,name:e.entry.npm.version,format:`npm`}]));let a=i.findIndex(t=>t.id===e.entry.npm.version),o=`${e.entry.npm.version} unpatched`,s=e._patch&&{name:`${e.entry.npm.name}@${e.entry.npm.version}`,detail:`patch:${e._patch.hash.slice(0,5)}`,detailNote:Fi(Pi(e))};s&&i.splice(a,1,{...i[a],detail:s.detail,detailNote:s.detailNote},{...i[a],id:o});let c=r.findIndex(t=>t.id===e._target),l=`${e._target} unpatched`,u=n&&e._basePatch&&{name:e._target,detail:`patch:${e._basePatch.slice(0,5)}`,detailNote:Fi(e._base?.npmPatch?.patch)};return u&&r.splice(c,1,{...r[c],detail:u.detail,detailNote:u.detailNote},{...r[c],id:l}),Bt(Rt({source:s||u?{...t,widest:s||u}:t,label:`Review`,disabled:Q(e),from:{options:r,value:n?e._target:null,label:`Review base`,pick:t=>{e._navigate(t===l?e._target:t,t===e._target?e._basePatch:null)}},to:{options:i,value:e.entry.npm.version,label:`Version to review`,pick:t=>{e._navigateTo({view:`npm`,packageName:e.entry.npm.name,packageSpec:t===o?e.entry.npm.version:t,bundleTab:`review`,...e._location(e._target,t===e.entry.npm.version)})}},clear:n?{label:`Clear review base`,run:()=>{e._navigate(`(empty)`)}}:null,openLine:t=>e._openLine(t),comparison:e._base?{base:e._base,other:e._other,files:e._diff.files}:null}),e._base?zt(e._diff):L)}var Pi=e=>e._patched?.npmPatch?.patch??e._patch,Fi=e=>`As pnpm\u2019s patch${e?.path?` ${e.path}`:``} changes it`,Ii=e=>e._patch?I`<span class="npm-review-patched" data-tooltip="${`${Fi(Pi(e))}${Pi(e).commit?`, read at ${Pi(e).commit.slice(0,7)}`:``}`}">patch:${e._patch.hash}</span>`:L;function Li(e){return I`<div class="npm-review-toolbar"><nav class="npm-review-toolbar-group" aria-label="Review breadcrumbs"><button type="button" class="npm-review-button npm-review-text-button" ?disabled="${Q(e)}" @click="${()=>{e._navigateTo({view:`reviews`})}}">My reviews</button> ${T}<button type="button" class="npm-review-button npm-review-text-button npm-review-package" aria-haspopup="dialog" ?disabled="${e._blocked}" @click="${()=>e._openPanel(`reviews`)}"><span>${e.entry.npm.name}@${e.entry.npm.version}</span><span class="npm-review-count">${ki(e).length}</span></button> ${Ii(e)}</nav>${Mi(e)}</div>`}function Ri(e,t=e._file,n=!1){let r=e._editorState(t),i=e._shownReview?.entries.find(e=>e.file===t),a=e._nonTextFiles.includes(t),o=!a&&[`accept-with-nits`,`request-changes`,`reject`].includes(r.status);return I`<section class="${`npm-review-decision${n?` npm-review-inline-decision`:``}`}" aria-label="File decision">${e._canEdit?I`${ji(`file:${t}`,a?``:r.status,n=>{e._setFileStatus(t,n)},Q(e)||a,void 0,!0)} ${a?I`<p class="npm-review-help">Non-text file. Verdicts are not supported yet; this file remains unchecked.</p>`:L} ${o?I`<textarea aria-label="File note" rows="2" maxlength="20000" placeholder="Add a note (optional)…" .value="${k(r.comment)}" ?disabled="${Q(e)}" @input="${n=>e._editFile(t,{comment:n.target.value})}" @blur="${()=>{e._saveFile(t)}}"></textarea>`:L}`:I`${n?L:I`<header><strong>File review</strong><span class="npm-review-muted">${Ti(e)?`Frozen`:`Read only`}</span></header>`} ${i?.status&&!a?I`${Ye(i.status)}${D(i.comment)}`:I`<p class="npm-review-muted">This file was not reviewed.</p>`} ${e._reviewer||e._loading?L:I`<p class="npm-review-help">${e._writable?`Reviewing needs a team that reviews dependencies, where you manage or have Dependencies.`:`Triage access is required to add a review.`}</p>`}`}</section>`}function zi(e,t,n,r,i,a){return I`<fieldset class="npm-review-team-options"><legend>${t}</legend>${n.map(t=>I`<mode-switch label="${t.name}" .checked="${r.has(t.id)}" .disabled="${Q(e)}" @click="${()=>{if(Q(e))return;let n=new Set(r);n.has(t.id)?n.delete(t.id):n.add(t.id),i(n)}}"></mode-switch>`)}${a}</fieldset>`}function Bi(e,t){let n=e._allowedVerdicts,r=Te(t.entries,e._files,e._nonTextFiles),i=t.entries.filter(t=>t.status&&t.comment.trim()&&!e._nonTextFiles.includes(t.file));return I`<form class="npm-review-publish-form" @submit="${t=>{t.preventDefault(),e._publish()}}"><div class="npm-review-dialog-body"><section class="npm-review-coverage"><div><strong>${Ei(r)} review</strong><span>${r.checkedFiles} of ${r.totalFiles} files checked</span></div>${rt(r.checkedFiles,r.totalFiles)}<p>${r.totalFiles>r.checkedFiles?I`${r.totalFiles-r.checkedFiles} files not checked. <button type="button" class="npm-review-button npm-review-text-button" @click="${()=>{e._unchecked=!0,e._closePanel()}}">View files</button>`:`Every file has a verdict.`}</p>${e._needsPackageJson?I`<p class="npm-review-error">Review ${e._files.includes(`package.json`)?I`<button type="button" class="npm-review-button npm-review-text-button" @click="${()=>{e._closePanel(),e._selectFile(`package.json`)}}">package.json</button>`:`package.json`} before publishing a partial review.</p>`:L}</section>${i.length>0?I`<section aria-label="File notes"><strong>File notes</strong><ul class="npm-review-publish-notes" tabindex="0" aria-label="Saved file notes">${i.map(e=>I`<li><span class="dependency-review-entry-file">${mt(e.file)}<span>${e.file}</span></span> ${D(e.comment)}</li>`)}</ul></section>`:L}<div><strong>Final verdict</strong>${ji(`final-verdict`,e._finalStatus,t=>{e._finalStatus=t},Q(e),n)}</div>${e._securityLimit===`reject`?I`<p class="npm-review-help">Malware detected. Only Reject is available.</p>`:e._securityLimit===`request-changes`?I`<p class="npm-review-help">Critical vulnerabilities detected.</p>`:L} <label>Final note <span class="npm-review-muted">· optional</span><textarea aria-label="Final comment" rows="3" maxlength="20000" .value="${k(e._finalComment)}" placeholder="Summarize your findings or explain what remains…" ?disabled="${Q(e)}" @input="${t=>{e._finalComment=t.target.value}}"></textarea></label> ${e._unchangedContinuation?I`<p class="npm-review-help">Change a verdict or note to publish a new review.</p>`:L} ${zi(e,`Publish to teams`,e._teams,e._selectedTeams,t=>{e._selectedTeams=t},e._selectedTeams.size>0?L:I`<p class="npm-review-error">${e._teams.length===0?`No teams you belong to have dependency review enabled.`:`Select at least one team to publish.`}</p>`)} ${Di(e)}</div><footer class="npm-review-dialog-footer"><p>Publishing freezes your verdicts and notes.<br>You can continue in a new review to make changes.</p><button type="submit" class="${Ai(e)}" ?disabled="${Q(e)||!e._canPublish}">Publish to ${e._selectedTeams.size} ${e._selectedTeams.size===1?`team`:`teams`} ${T}</button></footer></form>`}function Vi(e,t){let n=t===e._shownReview,r=t.publishedAt!==null,i=r?t:O(t,e._context)?Te(t.entries,e._files,e._nonTextFiles):{checkedFiles:t.entries.filter(e=>e.status).length,totalFiles:null},a=[e._continuation?.review,...e._reviews].some(n=>n?.publishedAt===null&&n.user===e.session?.id&&O(n,t)),o=t.user===e.session?.id,s=e._teams.filter(e=>!t.teams.some(t=>t.id===e.id)),c=e._additionalTeams.get(t.id)??new Set(s.length===1?s.map(e=>e.id):[]),l=s.filter(e=>c.has(e.id)).map(e=>e.id);return I`<section class="npm-review-entry" aria-current="${String(n)}"><div class="npm-review-history-heading"><strong>${$e(t)}</strong>${n?I`<span class="npm-review-current">Current</span>`:L}${Ze(t)}</div><p class="npm-review-help">${t.basePackage?`${t.basePackage===t.package?t.baseVersion:`${t.basePackage}@${t.baseVersion}`} \u2192 ${t.version}`:`All package files`}</p><div class="npm-review-entry-result">${r?Ye(t.status):L}<span class="dependency-review-coverage"> ${r?I`${i.coverage===`full`?`Full`:I`<span class="dependency-review-partial">Partial</span>`} · `:L}${i.checkedFiles}${i.totalFiles===null?L:`/${i.totalFiles}`} files checked</span></div><p class="npm-review-help">${t.teams.length>0?`${t.teams.map(e=>e.name).join(`, `)} \xB7 `:``}${tt(t.publishedAt??t.time)}</p>${D(t.comment)}<div class="npm-review-entry-actions"><button type="button" class="npm-review-button" ?disabled="${Q(e)}" @click="${()=>{e._openReview(t)}}">Open ${T}</button> ${r&&o&&!a&&e._reviewer?I`<button type="button" class="npm-review-button" aria-label="Revise in a new draft" ?disabled="${Q(e)}" @click="${()=>{e._openReview(t,!0)}}">Revise</button>`:L} ${r&&o&&e._writable&&t.revokedAt===null?I`<button type="button" class="npm-review-button npm-review-danger" ?disabled="${Q(e)}" @click="${()=>e._change({action:`revoke`,reviewId:t.id,revision:t.revision})}">Revoke</button>`:L} ${o?I`<dependency-review-copy .text="${t.formatted}"></dependency-review-copy>`:L} ${!r&&o&&e._writable?I`<button type="button" class="dependency-review-discard" aria-label="Discard review" ?disabled="${Q(e)}" @click="${()=>{e._discard(t)}}">${kt(Ot)}</button>`:L}</div>${r&&o&&e._writable&&t.revokedAt===null&&s.length>0?I`<details class="npm-review-share"><summary>Publish to more teams</summary>${zi(e,`Teams`,s,c,n=>{e._additionalTeams=new Map(e._additionalTeams).set(t.id,n)},I`<button type="button" class="npm-review-button" ?disabled="${Q(e)||l.length===0}" @click="${()=>e._change({action:`publish`,reviewId:t.id,revision:t.revision,teamIds:l})}">Publish to more teams</button>`)}</details>`:L} ${t.revokedAt===null?L:I`<p class="npm-review-help">Revoked ${tt(t.revokedAt)}. Content and team links remain frozen.</p>`}</section>`}function Hi(e){if(!e._panel)return L;let t={publish:`Publish review`,reviews:`Reviews`,unsaved:`Unsaved changes`};return I`<dialog class="npm-review-dialog" aria-label="${t[e._panel]}" @cancel="${t=>{t.preventDefault(),e._closePanel()}}"><button type="button" class="detail-action npm-review-close" aria-label="Close panel" ?disabled="${e._blocked}" @click="${()=>e._closePanel()}">×</button><header class="npm-review-dialog-head"><h2>${t[e._panel]}</h2><p>${e._panel===`reviews`?`${e.entry.npm.name}@${e.entry.npm.version}${e._patch?` (patched)`:``}`:u(e._context)}</p></header>${e._panel===`publish`?Bi(e,e._activeReview):I`<div class="${`npm-review-dialog-body${e._panel===`reviews`?` npm-review-entries`:``}`}">${e._panel===`unsaved`?I`${e._dirtyFiles.map(t=>I`<button type="button" class="npm-review-button" @click="${()=>{e._closePanel(),e._selectFile(t)}}">${t} ${T}</button>`)}`:ki(e).map(t=>Vi(e,t))} ${e._panel===`reviews`&&ki(e).length===0?I`<p class="npm-review-muted">No reviews yet.</p>`:L}${Di(e)}</div>`} ${Oi(e)}</dialog>`}function Ui(e){let t=e._shownReview?.entries,n=e._files,r=e._nonTextFiles;if(e._treeProgress?.entries!==t||e._treeProgress?.files!==n||e._treeProgress?.nonTextFiles!==r){let i=at(t,r),a=new Map,o=0;for(let t of e._files){let e=t.split(`/`),n=+!!i.get(t)?.status;o+=n;for(let t=1;t<e.length;t++){let r=e.slice(0,t).join(`/`),i=a.get(r)??{total:0,checked:0};i.total++,i.checked+=n,a.set(r,i)}}e._treeProgress={entries:t,files:n,nonTextFiles:r,states:i,directories:a,checked:o}}let{states:i,directories:a,checked:o}=e._treeProgress;return{railLabel:`Files`,treeLabel:`Review files`,collapseLabel:`Collapse folders`,searchLabel:`Find a file`,searchPlaceholder:`Find a file…`,treePageSize:300,filterContent:!1,fullPaths:!0,collapseClearsSearch:!0,canSelect:()=>!e._blocked&&!e._panel,fileFilter:e._unchecked?e=>!i.get(e)?.status:null,fileLabel:e=>`${e}, ${We[i.get(e)?.status]??`Not reviewed`}`,filePrefix:e=>qe(i.get(e)?.status),fileSuffix:e=>i.get(e)?.notes?I`<span class="npm-review-note-dot" aria-label="Has notes">•</span>`:L,directoryLabel:e=>{let t=a.get(e.sourcePath);return`${e.sourcePath}, ${t?.checked??0} of ${t?.total??0} checked`},directorySummary:e=>{let t=a.get(e.sourcePath);return`${t?.checked??0}/${t?.total??0}`},filters:I`<div class="npm-review-filters" aria-label="Filter review files"><button type="button" class="npm-review-button" aria-pressed="${String(!e._unchecked)}" @click="${()=>{e._unchecked=!1}}">All ${e._files.length}</button> <button type="button" class="npm-review-button" aria-pressed="${String(!!e._unchecked)}" @click="${()=>{e._unchecked=!0}}">Unchecked ${e._files.length-o}</button></div>`,fileActions:(t,n)=>Ri(e,t,n)}}function Wi(e){if(!e._base){let t=I`<div class="npm-review-empty" role="${e._baseError?`alert`:`status`}">${e._baseError??`Loading comparison…`} ${e._baseError?I`<button type="button" class="npm-review-button" @click="${()=>{e._baseKey=null,e._loadBase(e._target,e.request?.resume)}}">Retry</button>`:L}</div>`;return e._baseError&&e._basePatch?I`${Ni(e)}${t}`:t}return I`${Ni(e)}${Li(e)}${e._panel?L:Di(e)} ${bi({base:e._base,other:e._other,diff:e._diff,source:e.source,path:e._path,seek:e._seek,baseName:e._base.npm?`${e._base.npm.name}@${e._base.npm.version}${e._base.npmPatch?` (patched)`:``}`:`Empty package`,otherName:`${e.entry.npm.name}@${e.entry.npm.version}${e._patch?` (patched)`:``}`,select:t=>e._selectFile(t),extensions:Ui(e),mode:e._mode})} <span class="npm-review-announcement" role="status">${e._notice??``}</span>${e._panel?L:Oi(e)}${Hi(e)}`}var Gi={maxLines:5e4,maxBytes:2097152},Ki={integrity:`(empty)`,kind:`sourcemap`,json:{version:3,sources:[],sourcesContent:[]},fileSizes:new Map},qi=(e,t,n=null)=>({ecosystem:`npm`,package:e.npm.name,version:e.npm.version,integrity:e.integrity,patchHash:n?.hash??null,basePackage:t?.npm?.name??null,baseVersion:t?.npm?.version??null,baseIntegrity:t?.npm?t.npmPatch?.integrity??t.integrity:null,basePatchHash:t?.npmPatch?.patch.hash??null}),$=(e,t)=>`${e}@${t??`latest`}`,Ji=class extends At{static properties={entry:{attribute:!1},details:{attribute:!1},request:{attribute:!1},session:{attribute:!1},source:{attribute:!1},_teams:{state:!0},_selectedTeams:{state:!0},_additionalTeams:{state:!0},_reviews:{state:!0},_loading:{state:!0},_error:{state:!0},_saving:{state:!0},_saveBlocked:{state:!0},_file:{state:!0},_seek:{state:!0},_finalStatus:{state:!0},_finalComment:{state:!0},_base:{state:!0},_baseError:{state:!0},_panel:{state:!0},_path:{state:!0},_selectedReview:{state:!0},_unchecked:{state:!0},_notice:{state:!0},_continuation:{state:!0}};createRenderRoot(){return this}constructor(){super(),this._teams=[],this._reviews=[],this._files=[],this._nonTextFiles=[],this._selectedTeams=new Set,this._additionalTeams=new Map,this._editors=new Map,this._file=null,this._path=null,this._patch=null,this._patched=null,this._basePatch=null,this._loading=!1,this._saving=!1,this._error=null,this._context=null,this._key=null,this._controller=new AbortController,this._mode=`code`,this._panel=null,this._selectedReview=null,this._unchecked=!1,this._pendingSaves=[],this._saveBlocked=!1}disconnectedCallback(){super.disconnectedCallback(),this._controller.abort(),this._cancelSaves(),this._dismissLoading?.(),this._key=null,this._baseKey=null}updated(){let e=this.querySelector(`dialog`);e&&!e.open&&e.showModal(),this._rememberBase()}_rememberBase(){E.bundleDetailsTab!==`review`||E.selectedBundle!==this.entry?.integrity||!this._context||!this._activeReview&&this._ownPublished.length===0&&!this._unsaved||(E.npmReview={bundle:this.entry.integrity,...this._context.basePackage?{reviewPackage:this._context.basePackage,reviewSpec:this._context.baseVersion}:{},...this._patch?{patch:this._patch}:{},...this._context.basePatchHash?{basePatch:this._context.basePatchHash}:{},started:!0,user:this.session?.id})}get _writable(){return[`triage`,`manage`,`admin`].includes(this.session?.role)&&!this.session?.viewer}get _other(){return this._patched??this.details}get _reviewer(){return this._writable&&this._teams.length>0}get _activeReview(){return this._reviews.find(e=>e.user===this.session?.id&&e.publishedAt===null&&O(e,this._context))??(this._continuation&&this._continuation.review.user===this.session?.id?this._continuation.review:null)}get _ownPublished(){return this._reviews.filter(e=>e.user===this.session?.id&&e.publishedAt!==null&&O(e,this._context)).toSorted((e,t)=>t.publishedAt-e.publishedAt)}get _shownReview(){return this._selectedReview?this._reviews.find(e=>e.id===this._selectedReview):this._activeReview??this._ownPublished[0]??null}get _canEdit(){return this._reviewer&&!this._selectedReview&&(this._activeReview!==null||this._ownPublished.length===0)}_isDirty(e,t){return!this._nonTextFiles.includes(e)&&(t.comment!==(t.edit?.comment??``)||t.status!==(t.edit?.status??``))}get _dirtyFiles(){return[...this._editors].filter(([e,t])=>this._isDirty(e,t)).map(([e])=>e)}get _blocked(){return this._saving||this._saveBlocked}get _unsaved(){return this._pendingSaves.length>0||this._dirtyFiles.length>0}get _draftStarted(){return this._canEdit&&(this._unsaved||this._activeReview&&!this._continuation||this._continuation&&this._publishRevision!=null&&!this._unchangedContinuation)}get _summary(){return Te(this._shownReview?.entries??[],this._files,this._nonTextFiles)}get _securityLimit(){return this.source?.reviewVerdictLimit?.(this.entry,this._base)??`accept`}get _allowedVerdicts(){let e=new Map((this._shownReview?.entries??[]).map(e=>[e.file,e]));if(this._canEdit)for(let[t,n]of this._editors)e.set(t,{file:t,status:n.status||null});return De([...e.values()].filter(e=>!this._nonTextFiles.includes(e.file)),this._securityLimit)}get _needsPackageJson(){return ke(this._activeReview?.entries??[],this._files,this._nonTextFiles)}get _unchangedContinuation(){let e=this._continuation?.source;return!!(e&&this._finalStatus===e.status&&this._finalComment===e.comment)}get _canPublish(){return this._canEdit&&this._panel===`publish`&&this._activeReview?.revision===this._publishRevision&&this._summary.checkedFiles>0&&!this._needsPackageJson&&!this._unchangedContinuation&&this._selectedTeams.size>0&&!this._unsaved&&this._allowedVerdicts.includes(this._finalStatus)}_location(e,t=!0,n=e===this._target?this._basePatch:null){let r=e&&e!==`(empty)`?oe(e):null;return{...r?{reviewPackage:r.name,reviewSpec:r.spec}:{},...t&&this._patch?{patch:this._patch}:{},...r&&n?{basePatch:n}:{}}}_asked(e=this._context){let t=Object.fromEntries(Object.keys(this._context).map(t=>[t,e[t]??null])),n=(e===this._context?null:e.patchSource)??this._patch;return t.patchHash&&n?.repoId!=null?{...t,patchRepoId:n.repoId,patchCommit:n.commit,...n.path==null?{}:{patchPath:n.path}}:t}_navigate(e,t=e===this._target?this._basePatch:null){return this._navigateTo(ce(this.entry,`review`,this._location(e,!0,t)))}async _navigateTo(e){if(this._blocked||this._loading)return;let t=this._key,n=this._navigation={};this._unsaved&&!await this._saveAll()||t===this._key&&n===this._navigation&&!this._unsaved&&await Fe?.navigate(e)}async _loadBase(e,t=!1){let n=JSON.stringify([this.entry.integrity,e,this._patch,this._basePatch,this.session?.id,this.session?.role]);if(this._baseKey!==n){this._baseKey=n,this._base=null,this._baseError=null,this._controller.abort(),this._cancelSaves(),this._key=null,this._controller=new AbortController;try{let r=this._controller.signal,i=this._patch?pe(this.entry,this._patch,{signal:r}):Promise.resolve(this.details);i.catch(()=>{});let a=t?await ge(qi(this.entry,null,this._patch),r):null;if(this._baseKey!==n)return;a&&([e,this._basePatch]=[a.basePackage?$(a.basePackage,a.baseVersion):`(empty)`,a.basePatchHash??null]);let o=e===`(empty)`?null:oe(e),s=o?await de(o.name,o.spec??`latest`):null,c=s&&this._basePatch?{...await pe(s.entry,{hash:this._basePatch},{signal:r}),npm:s.details.npm}:s?.details??Ki,l=await i;if(this._baseKey!==n)return;let u=await rn(c,l);if(this._baseKey!==n)return;t&&(a&<(a),this._target=e,this.request={bundle:this.entry.integrity,...this._location(e)},this._baseKey=JSON.stringify([this.entry.integrity,e,this._patch,this._basePatch,this.session?.id,this.session?.role])),this._patched=this._patch?l:null,this._base=c,this._ensureContext(c,u)}catch(e){this._baseKey===n&&(this._baseError=e.message)}}}_ensureContext(e,t){let n=qi(this.entry,e,this._patch),r=JSON.stringify([this.session?.id,this.session?.role,n]);if(r===this._key)return;this._controller.abort(),this._cancelSaves(),this._controller=new AbortController,this._context=n,this._diff=t;let i=pn(e,this._other,this._diff);this._files=Re(we(i.map(e=>e.path)));let a=new Set(i.filter(e=>!Ce(e.before,e.after)).map(e=>e.path));if(this._nonTextFiles=this._files.filter(e=>a.has(e)),this._mode=mn(i,Gi)?`diff`:`code`,this._key=r,this._teams=[],this._reviews=[],this._selectedTeams=new Set,this._additionalTeams=new Map,this._selectedReview=null,this._continuation=null,this._editors.clear(),this._path=this._files[0]??null,this._panel=null,this._notice=``,this._resetEditor(this._path),this._saving=!1,this._refresh(!0),E.bundleDetailsTab===`review`&&E.selectedBundle===this.entry.integrity){let t=this._location(e.npm?$(e.npm.name,e.npm.version):`(empty)`,!0,e.npmPatch?.patch.hash??null);E.npmReview={bundle:this.entry.integrity,...t},this._baseKey=JSON.stringify([this.entry.integrity,e.npm?$(e.npm.name,e.npm.version):`(empty)`,this._patch,this._basePatch,this.session?.id,this.session?.role]),Fe?.replaceRoute(ce(this.entry,`review`,t))}}async _refresh(e=!1){let t=this._key;for(;t===this._key&&this._pendingSaves.length>0;)if((await Promise.all(this._pendingSaves.map(e=>e.promise))).some(e=>!e))return;if(t!==this._key)return;this._dismissLoading?.();let n=this._dismissLoading=Le(`Loading reviews…`,{duration:0});this._loading=!0,this._error=null;try{let{reviews:n,teams:r}=await le({...this._context,allBases:!0},null,null,this._controller.signal);if(t===this._key){let t=this._unsaved;this._reviews=n,this._teams=r,n.some(e=>e.user===this.session?.id&&e.publishedAt===null&&O(e,this._context))&&(this._continuation=null),this._rememberBase();let i=dt(this._context),a=i&&n.find(e=>e.id===i.review.id);a?.publishedAt!=null&&(i.continueReview?this._continue(a.id,a.revision):this._selectedReview=a.id),this._selectedTeams=new Set(r.filter(t=>e?r.length===1:this._selectedTeams.has(t.id)).map(e=>e.id)),t||(this._editors.clear(),this._resetEditor(this._file))}}catch(e){t===this._key&&e.name!==`AbortError`&&(this._error=e.message)}finally{n(),t===this._key&&(this._loading=!1)}}_resetEditor(e=null){this._publishRevision=null,this._file=e,this._editorState(e)}_editorState(e){let t=this._canEdit?this._editors.get(e):null;if(!t){let n=this._shownReview?.entries.find(t=>t.file===e&&t.status)??null;t={edit:n,revision:this._activeReview?.revision??null,comment:this._nonTextFiles.includes(e)?``:n?.comment??``,status:this._nonTextFiles.includes(e)?``:n?.status??``},this._canEdit&&this._editors.set(e,t)}return{...t,dirty:this._isDirty(e,t)}}_editFile(e,t){!this._canEdit||this._blocked||(this._resetEditor(e),Object.assign(this._editors.get(e),t),this.requestUpdate())}_setFileStatus(e,t){if(!(this._blocked||this._nonTextFiles.includes(e)))return this._editFile(e,{status:t,...t?{}:{comment:``}}),this._saveFile(e)}_selectFile(e){this._blocked||!this._files.includes(e)||(this._path=e,this._resetEditor(e))}_openLine({path:e,line:t,query:n}){this._blocked||!this._files.includes(e)||(this._seek={path:e,line:t-1,query:n},this._selectFile(e))}_openPanel(e){this._panel=e}async _openReview(e,t=!1){if(this._blocked||this._loading)return;if(O(e,this._context)){t?this._continue(e.id,e.revision):e.publishedAt===null?this._resume():this._showPublished(e);return}let n=this._key;this._unsaved&&!await this._saveAll()||n!==this._key||(lt(e,t),await this._navigate(e.basePackage?$(e.basePackage,e.baseVersion):`(empty)`,e.basePatchHash??null))}_closePanel(){this._blocked||(this.querySelector(`dialog`)?.close(),this._panel=null)}_showPublished(e){this._selectedReview=e.id,this._panel=null,this._file=this._path}_resume(){this._selectedReview=null,this._panel=null,this._resetEditor(this._path)}async _discard(e){if(this._blocked||this._loading||!this._writable||e.user!==this.session.id||e.publishedAt!==null)return;let t=e===this._activeReview,n=this._key,r=this._controller.signal;this._saving=!0,this._error=null;try{let{confirmed:i}=await _t({reviewTitle:u(e),signal:r});if(!i||r.aborted||n!==this._key||(await Promise.all(this._pendingSaves.map(e=>e.promise)),r.aborted||n!==this._key||!this._writable)||(e=t?this._activeReview:this._reviews.find(t=>t.id===e.id),!e||e.user!==this.session.id||e.publishedAt!==null))return;let a=e===this._continuation?.review;if(a||await he(e.id,e.revision,this.session.csrfToken,r),r.aborted||n!==this._key)return;a||(this._reviews=this._reviews.filter(t=>t.id!==e.id)),O(e,this._context)&&(this._continuation=null,this._selectedReview=null,this._editors.clear(),this._resetEditor(this._path),this._finalStatus=null,this._finalComment=``,this._panel=null,this._ownPublished.length===0&&E.npmReview?.bundle===this.entry.integrity&&delete E.npmReview.started),this._notice=`Draft discarded.`}catch(e){n===this._key&&e.name!==`AbortError`&&(this._error=e.message)}finally{n===this._key&&(this._saving=!1)}}_continue(e,t){let n=this._reviews.find(n=>n.id===e&&n.revision===t&&n.user===this.session?.id&&n.publishedAt!==null&&O(n,this._context));return!n||this._activeReview||!this._reviewer?null:(this._continuation={source:n,review:{...n,publishedAt:null,revokedAt:null,status:null,teams:[]}},this._selectedTeams=new Set(this._teams.length===1?this._teams.map(e=>e.id):[]),this._selectedReview=null,this._panel=null,this._editors.clear(),this._resetEditor(this._path),this._notice=`A new draft will be saved when you make a change.`,this._activeReview)}async _persistContinuation(e){let t=this._continuation,n=this._key,{review:r}=await le(this._asked(),{action:`continue`,reviewId:t.source.id,revision:t.source.revision},this.session.csrfToken,this._controller.signal);return n!==this._key||this._continuation!==t||e&&this._pendingSaves[0]!==e?null:(this._acceptSave(r,{revision:t.source.revision}),r)}_cancelSaves(){for(let e of this._pendingSaves)clearTimeout(e.timer),e.resolve(null);this._pendingSaves=[],this._saveBlocked=!1}_queueSave(e){let t=this._pendingSaves.findLast(t=>t.change.file===e.file);if(t&&t.change.comment===e.comment&&t.change.status===e.status)return t.promise;let n={change:e,slow:!1};return n.promise=new Promise(e=>{n.resolve=e}),n.timer=setTimeout(()=>{n.slow=!0,this._saveBlocked=!0},3e3),this._pendingSaves.push(n),this.requestUpdate(),this._pendingSaves.length===1&&this._flushSaves(),n.promise}_acceptSave(e,t){this._reviews=[...this._reviews.filter(t=>t.id!==e.id),e],this._continuation=null;for(let[n,r]of this._editors)r.revision===t.revision&&(r.revision=e.revision,r.edit=e.entries.find(e=>e.file===n&&e.status)??null);for(let{change:n}of this._pendingSaves.slice(1))n.revision===t.revision&&(n.revision=e.revision,n.reviewId=e.id,n.entryId=e.entries.find(e=>e.file===n.file)?.id??null);this._canEdit&&this._resetEditor(this._file),this._notice=`Saved privately.`,this._rememberBase()}async _flushSaves(){for(;this._pendingSaves.length>0;){let e=this._pendingSaves[0];this._error=null;try{if(this._continuation){let t=await this._persistContinuation(e);if(!t||this._pendingSaves[0]!==e)return;Object.assign(e.change,{reviewId:t.id,revision:t.revision,entryId:t.entries.find(t=>t.file===e.change.file)?.id??null})}let{review:t}=await le(this._asked(),e.change,this.session.csrfToken,this._controller.signal);if(this._pendingSaves[0]!==e)return;this._acceptSave(t,e.change),clearTimeout(e.timer),this._pendingSaves.shift(),e.resolve(t),this._saveBlocked=this._pendingSaves.some(e=>e.slow),this.requestUpdate()}catch(t){if(this._pendingSaves[0]!==e)return;this._cancelSaves(),t.name!==`AbortError`&&(this._error=t.message),this.requestUpdate();return}}}async _change(e){if(this._blocked||this._pendingSaves.length>0||this._loading||!this._writable)return null;if(e.action===`continue`)return this._continue(e.reviewId,e.revision);let t=this._key;this._saving=!0,this._error=null;try{if(e.action===`publish`&&e.finalStatus&&this._continuation){let t=await this._persistContinuation();if(!t)return null;e={...e,reviewId:t.id,revision:t.revision}}let n=this._reviews.find(t=>t.id===e.reviewId)??this._context,{review:r}=await le(this._asked(n),e,this.session.csrfToken,this._controller.signal);return t===this._key?(this._reviews=[...this._reviews.filter(e=>e.id!==r.id),r],e.action===`publish`&&e.finalStatus&&O(r,this._context)&&(this._selectedReview=r.id,this._panel=null,this._editors.clear(),this._notice=`Published. Verdicts and notes are now frozen.`),this._rememberBase(),r):null}catch(e){return t===this._key&&e.name!==`AbortError`&&(this._error=e.message),null}finally{t===this._key&&(this._saving=!1)}}_saveFile(e){if(!this._canEdit||this._saving||this._loading)return null;let t=this._editorState(e),n=this._pendingSaves.some(t=>t.change.file===e),r=this._activeReview;return!t.dirty&&!n?r:!t.status&&!t.comment.trim()&&!t.edit?.id&&!n?(this._editors.delete(e),e===this._file&&this._resetEditor(e),r):this._queueSave({action:`save`,reviewId:r?.id??null,revision:t.revision,entryId:t.edit?.id??null,file:e,comment:t.comment,status:this._nonTextFiles.includes(e)?null:t.status||null})}async _saveAll(){let e=this._key;for(;e===this._key&&this._canEdit;){if(this._pendingSaves.length>0){if((await Promise.all(this._pendingSaves.map(e=>e.promise))).some(e=>!e))return!1;continue}let e=this._dirtyFiles;if(e.length===0)return!0;if(!await this._saveFile(e[0]))return!1}return!1}async _beginPublish(){if(!this._canEdit||this._saving||this._loading||this._finalizing||!this._summary.checkedFiles)return;let e=this._key;this._finalizing=!0;try{if(this._unsaved&&!await this._saveAll()||e!==this._key||!this._canEdit||this._unsaved||!this._summary.checkedFiles)return;let t=this._activeReview;if(!t)return;let n=this._allowedVerdicts,r=this._continuation?.source.status;this._finalStatus=n.includes(r)?r:n[0],this._finalComment=t.comment??``,this._publishRevision=t.revision,this._panel=`publish`}finally{this._finalizing=!1}}_publish(){if(this._canPublish)return this._change({action:`publish`,reviewId:this._activeReview.id,revision:this._publishRevision,teamIds:[...this._selectedTeams],finalStatus:this._finalStatus,finalComment:this._finalComment})}render(){if(!this.entry?.npm||!this.details)return L;let e=this.request?.bundle===this.entry.integrity?this.request:{};return this._target=e.reviewPackage?$(e.reviewPackage,e.reviewSpec):`(empty)`,JSON.stringify(e.patch??null)!==JSON.stringify(this._patch)&&(this._patch=e.patch??null),this._basePatch=e.basePatch??null,this._loadBase(this._target,e.resume),Wi(this)}};customElements.define(`npm-review`,Ji);var Yi=e=>({view:`npm`,packageName:e.package,packageSpec:e.version,bundleTab:`review`,...e.basePackage===null?{}:{reviewPackage:e.basePackage,reviewSpec:e.baseVersion},...wt(e.patchHash)&&e.patchSource?{patch:{hash:e.patchHash,...e.patchSource}}:{},...wt(e.basePatchHash)&&e.basePackage!==null?{basePatch:e.basePatchHash}:{}}),Xi=e=>{let t=new Date(e);return I`<time class="dependency-review-date" datetime="${t.toISOString()}" data-tooltip="${t.toLocaleString()}">${t.toLocaleDateString(void 0,{month:`short`,day:`numeric`,...t.getFullYear()===new Date().getFullYear()?{}:{year:`numeric`}})} <span>${t.toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`})}</span></time>`},Zi=class extends At{static properties={session:{attribute:!1},team:{attribute:!1},_reviews:{state:!0},_loading:{state:!0},_error:{state:!0},_next:{state:!0},_discarding:{state:!0},_expanded:{state:!0}};constructor(){super(),this._reviews=[],this._next=null,this._expanded=new Set,this._controller=new AbortController}createRenderRoot(){return this}disconnectedCallback(){super.disconnectedCallback(),this._controller.abort(),this._dismissLoading?.(),this._key=null}_canDiscard(e){return e.publishedAt===null&&e.user===this.session?.id&&[`triage`,`manage`,`admin`].includes(this.session?.role)}async _discard(e){if(!this._canDiscard(e)||this._discarding||this._loading)return;let t=this._key,n=this._controller.signal;this._discarding=e.id,this._error=null;try{let{confirmed:r}=await _t({reviewTitle:u(e),signal:n});if(!r||n.aborted||t!==this._key||!this._canDiscard(e)||(await he(e.id,e.revision,this.session.csrfToken,n),t!==this._key||n.aborted))return;this._reviews=this._reviews.filter(t=>t.id!==e.id)}catch(e){t===this._key&&e.name!==`AbortError`&&(this._error=e.message)}finally{t===this._key&&(this._discarding=null)}}async _load(e=!1){let t=this._key;this._dismissLoading?.();let n=this._dismissLoading=Le(`Loading reviews…`,{duration:0});this._loading=!0,this._error=null;try{let n=e?this._next:null,{reviews:r,next:i}=await(this.team?me(this.team,n,this._controller.signal):fe(n,this._controller.signal));if(t!==this._key)return;this._reviews=[...new Map([...e?this._reviews:[],...r].map(e=>[e.id,e])).values()],this._next=i}catch(e){t===this._key&&e.name!==`AbortError`&&(this._error=e.message)}finally{n(),t===this._key&&(this._loading=!1)}}_toggleDetails(e){let t=new Set(this._expanded);t.has(e)?t.delete(e):t.add(e),this._expanded=t}_details(e){let t=e.entries.filter(e=>e.status);return I`<section id="${`review-details-${e.id}`}" class="dependency-review-details" aria-label="${`Details for ${u(e)}`}">${e.comment?I`<div class="dependency-review-final-note" role="note" aria-label="Final note">${D(e.comment)}</div>`:L} ${t.length>0?I`<ul class="dependency-review-entries">${t.map(e=>I`<li><span class="dependency-review-entry-file">${mt(e.file)}<span>${e.file}</span></span> ${Ye(e.status)}<div>${D(e.comment)}</div></li>`)}</ul>`:I`<p class="npm-review-muted">No file reviews yet.</p>`}</section>`}_row(e){let t=Yi(e),n=this._expanded.has(e.id),r=e.publishedAt!==null,i=new Set(e.entries.filter(e=>e.status).map(e=>e.file)).size,a=e.entries.filter(e=>e.status&&e.comment.trim()).length+ +!!e.comment.trim(),o=e.teams.filter(e=>e.id!==this.team).map(e=>e.name).join(`, `),s=o&&this.team?`also ${o}`:o,c=n=>{n.button!==0||n.metaKey||n.ctrlKey||n.shiftKey||n.altKey||!Fe?.active||(n.preventDefault(),lt(e),Fe.navigate(t))};return I`<li class="${`dependency-review-row${n?` is-expanded`:``}${e.revokedAt===null?``:` is-revoked`}`}"><div class="dependency-review-row-main"><a class="dependency-review-title" href="${Et(t)}" @click="${c}">${ht(e.ecosystem)} ${e.basePackage!==null&&e.basePackage!==e.package?I`<span>${e.basePackage} ${e.baseVersion} →</span>`:L} <strong>${e.package}</strong> <span>${e.basePackage===e.package?`${e.baseVersion} \u2192 `:``}${e.version}${e.patchHash?I`<span class="dependency-review-patched">patch:${e.patchHash}</span>`:L}</span></a> <span class="dependency-review-result">${r?Ye(e.status):I`<span class="dependency-review-checked">${i} ${i===1?`file`:`files`} checked</span>`}</span> <button type="button" class="dependency-review-coverage" aria-expanded="${n}" aria-controls="${`review-details-${e.id}`}" data-tooltip="${r?`${e.checkedFiles} of ${e.totalFiles} files checked`:L}" @click="${()=>this._toggleDetails(e.id)}">${r?I`${e.coverage===`full`?`Full`:I`<span class="dependency-review-partial">Partial</span>`} · ${e.checkedFiles}/${e.totalFiles}`:a?`${a} ${a===1?`note`:`notes`}`:`No notes`}</button> ${this.team?I`<span class="dependency-review-author">${$e(e)}</span>`:L} <span class="dependency-review-meta">${r&&s?I`<span class="dependency-review-teams" data-tooltip-truncated data-tooltip="${s}">${s}</span>`:L} ${r&&a>0?I`<span class="dependency-review-note-count">${a} ${a===1?`note`:`notes`}</span>`:L} ${e.revokedAt===null?L:Ze(e)}</span> ${Xi(e.publishedAt??e.time)}<div class="dependency-review-row-actions">${this.team?L:I`<dependency-review-copy .text="${e.formatted}"></dependency-review-copy>`} ${this._canDiscard(e)?I`<button type="button" class="dependency-review-discard" aria-label="Discard review" ?disabled="${this._loading||!!this._discarding}" @click="${()=>this._discard(e)}">${kt(Ot)}</button>`:L} <a class="dependency-review-open" href="${Et(t)}" @click="${c}" aria-label="${`${r?`Open`:`Continue`} review for ${u(e)}`}"><span aria-hidden="true">→</span></a></div></div>${n?this._details(e):L}</li>`}render(){let e=JSON.stringify([this.session?.id,this.session?.role,this.team??null]);return e!==this._key&&(this._controller.abort(),this._controller=new AbortController,this._key=e,this._reviews=[],this._next=null,this._discarding=null,this._expanded=new Set,this._load()),this.team?I`<section class="dependency-review-list is-team">${this._error?I`<p role="alert">${this._error}</p>`:L} ${!this._loading&&!this._error&&this._reviews.length===0?I`<p class="npm-review-muted">No reviews are published to this team yet.</p>`:L}<ol>${this._reviews.map(e=>this._row(e))}</ol>${this._next?I`<button type="button" class="npm-review-button" ?disabled="${this._loading}" @click="${()=>this._load(!0)}">Load more</button>`:L}</section>`:I`<section class="dependency-review-list"><header><h1>My reviews</h1></header><p>Your private work and the reviews you’ve shared with teams.</p>${this._error?I`<p role="alert">${this._error}</p>`:L} ${!this._loading&&!this._error&&this._reviews.length===0?I`<p>No reviews yet. Open a package’s Review tab to begin.</p>`:L} ${[[`Drafts`,!1],[`Published reviews`,!0]].map(([e,t])=>{let n=this._reviews.filter(e=>e.publishedAt!==null===t);return I`<section class="dependency-review-section"><h2>${e}<span class="npm-review-count">${n.length}</span></h2><ol>${n.map(e=>this._row(e))}</ol>${n.length===0&&!this._loading?I`<p class="npm-review-muted">${t?`No published reviews yet.`:`No drafts.`}</p>`:L}</section>`})} ${this._next?I`<button type="button" class="npm-review-button" ?disabled="${this._loading||!!this._discarding}" @click="${()=>this._load(!0)}">Load more</button>`:L}</section>`}};customElements.define(`dependency-review-list`,Zi);
|
|
29
|
+
@compare-code-select=${e=>{e.stopPropagation(),c(e.detail.path)}}></${p}>`}var bi=400,xi=24,Si=[`removed`,`added`,`changed`],X=null;function Z(e){return e.join(`, `)}var Ci=class extends jt{static properties={details:{attribute:!1},integrity:{attribute:!1},request:{attribute:!1},source:{attribute:!1},review:{attribute:!1},_targetIntegrity:{state:!0},_otherDetails:{state:!0},_status:{state:!0},_scope:{state:!0},_fileSort:{state:!0},_pkgSort:{state:!0},_openSections:{state:!0},_mode:{state:!0},_codePath:{state:!0},_codeSeek:{state:!0}};createRenderRoot(){return this}constructor(){super(),this.details=null,this.integrity=null,this.request=null,this.source=null,this._targetIntegrity=null,this._otherDetails=null,this._status=`idle`,this._scope=``,this._fileSort={removed:`name`,added:`name`,changed:`name`},this._pkgSort={removed:`size`,added:`size`,changed:`size`},this._openSections=new Set,this._mode=`overview`,this._codePath=null,this._codeSeek=null,this._repaint=()=>this.requestUpdate(),this._fitBody=null,this._fitObserver=null}connectedCallback(){super.connectedCallback(),this._fitBody&&this._fitObserver?.observe(this._fitBody)}disconnectedCallback(){super.disconnectedCallback(),this._fitObserver?.disconnect()}willUpdate(e){e.has(`source`)&&this.source&&!e.get(`source`)&&(this._openSections=new Set([...this._openSections,`files`])),(e.has(`_otherDetails`)||e.has(`details`))&&this._status===`ready`&&!o(this._otherDetails,this.details).some(e=>e.id===this._scope)&&(this._scope=``),e.has(`integrity`)&&this._rebase(),(e.has(`request`)||e.has(`integrity`))&&this.integrity&&this.request?.bundle===this.integrity?(this.request.target!==this._targetIntegrity&&this._choose(this.request.target),this._mode=Et(this.request.mode)):e.has(`request`)&&!e.has(`integrity`)&&e.get(`request`)?.bundle===this.integrity&&(this._targetIntegrity&&this._choose(null),this._mode=`overview`)}updated(){let e=this.querySelector(`.bundle-compare-body`);e!==this._fitBody&&typeof ResizeObserver==`function`&&(this._fitObserver??=new ResizeObserver(()=>this._fitLists()),this._fitObserver.disconnect(),e&&this._fitObserver.observe(e),this._fitBody=e),this._fitLists()}_fitLists(){let e=this._fitBody;if(!e)return;let t=getComputedStyle(e),n=e.getBoundingClientRect().top+e.clientTop+parseFloat(t.paddingTop)-e.scrollTop,r=e=>{let t=e.getBoundingClientRect();return t.top-n+e.parentElement.getBoundingClientRect().bottom-t.bottom},i=e.querySelector(`.bundle-compare-rows--fill`);if(i){let t=r(i),n=i.closest(`.bundle-compare-section`);for(let e=n;e;e=e.nextElementSibling){let r=e.matches(`details[open]`)&&e.querySelector(`:scope > summary`),i=e===n?0:r?r.getBoundingClientRect().bottom+parseFloat(getComputedStyle(r).marginBottom)-e.getBoundingClientRect().top:e.getBoundingClientRect().height;t+=i+parseFloat(getComputedStyle(e).marginBottom)}e.style.setProperty(`--compare-fill-around`,`${t}px`)}let a=[...e.querySelectorAll(`.bundle-compare-rows--scroll:not(.bundle-compare-rows--fill)`)];if(a.length===0)return;let o=e.lastElementChild,s=new Map(a.filter(e=>o.contains(e)).map(e=>[e,e.parentElement.getBoundingClientRect().top])),c=Math.max(...s.values()),l=e.clientHeight-parseFloat(t.paddingTop)-parseFloat(t.paddingBottom),u=parseFloat(getComputedStyle(o).marginBottom);for(let e of a)s.get(e)>=c-1?e.style.setProperty(`--compare-rest`,`${l-r(e)-u}px`):e.style.removeProperty(`--compare-rest`)}_rebase(){let e=this._baseKey;if(X&&e&&e!==X.base&&(X=null),X&&e===X.base){let{target:e}=X;if(this._scope=X.scope,this._mode=X.mode,this._codePath=X.codePath,X=null,!e){this._targetIntegrity=null,this._otherDetails=null,this._status=`idle`;return}this._targetIntegrity=e;let t=this.source?null:ce(e,e=>!!(e.json||e.bundle));t?(this._otherDetails=t,this._status=`ready`):(this._otherDetails=null,this._status=`loading`,this._loadOther(e))}else this._targetIntegrity=null,this._otherDetails=null,this._status=`idle`,this._scope=``,this._codePath=null}get _baseKey(){return this.source?this.source.base:this.integrity}_swap(){let e=this._targetIntegrity;e&&e!==this._baseKey&&this._reopen(e,this._baseKey)}_pickBase(e){!e||e===this._baseKey||(e===this._targetIntegrity?this._swap():this._reopen(e,this._targetIntegrity))}_reopen(e,t){if(this.source){X={base:e,target:t,scope:this._scope,mode:this._mode,codePath:this._codePath},this.source.open(e,t,this._mode);return}if(!Ce(j.bundles??[],this.integrity).some(t=>t.integrity===e))return;X={base:e,target:t,scope:this._scope,mode:this._mode,codePath:this._codePath};let n=[this._otherDetails,this._baseReady?this.details:null].filter(n=>n&&!n.error&&(n.json||n.bundle)&&[e,t].includes(n.integrity));this.dispatchEvent(new CustomEvent(`bundle-swap`,{bubbles:!0,composed:!0,detail:{integrity:e,target:t,bundles:n,mode:this._mode}}))}_nameFor(e){return this.source?this.source.name(e):(j.bundles??[]).find(t=>t.integrity===e)?.name??`${e.slice(0,15)}\u2026`}_pick(e){this._choose(e),this._notify()}_notify(){this.dispatchEvent(new CustomEvent(`bundle-compare-change`,{bubbles:!0,composed:!0,detail:{base:this.integrity,target:this._targetIntegrity,mode:this._mode}}))}_choose(e){let t=e||null;this._targetIntegrity=t,this._otherDetails=null,this._codePath=null,t?(this._status=`loading`,this._loadOther(t)):(this._status=`idle`,this._scope=``)}async _loadOther(e){if(this.source){let t;try{t=await this.source.load(e)}catch(e){if(e.name===`AbortError`)return;t={error:e.message}}if(this._targetIntegrity!==e)return;this._otherDetails=t,this._status=`ready`,t?.compareId&&t.compareId!==e&&(this._targetIntegrity=t.compareId,this._notify());return}let t=Ce(j.bundles??[],this.integrity).find(t=>t.integrity===e);if(!t){this._status=`idle`,this._targetIntegrity=null,this._notify();return}let n;try{n=await de(e,t)}catch(e){if(e.name===`AbortError`)return;throw e}this._targetIntegrity===e&&(this._otherDetails=n,this._status=`ready`)}get _baseReady(){return!!(this.details&&this.details.integrity===this.integrity&&(this.details.json||this.details.bundle))}_openFile(e){this._codePath=e,this._mode=`code`,this._notify()}_openLine({path:e,line:t,query:n}){this._codeSeek={path:e,line:t-1,query:n},this._openFile(e)}_fileRow(e,t,n,r=e,i=!1,a=void 0,o=e,s=void 0){let c=this.source?.files;return z`<li><button type="button" class="bundle-compare-row bundle-compare-row-link" @click="${()=>this._openFile(e)}">${c?c.icon(e,[[this._otherDetails,o],[this.details,e]]):B}<span class="bundle-compare-row-path mono" data-tooltip-truncated data-tooltip="${r}">${t}</span>${i?c?.tag?.(this.details,e,s)??B:B}${sr(a)}${n}</button></li>`}_group(e,t,n,r,i,a=B,{fill:o=!1,lanes:s=Si,style:c={}}={}){return t.length===0?B:z`<section class="${`bundle-compare-group bundle-compare-${n}`}" style="${L({"--compare-lane":String(s.indexOf(n)+1),...c})}"><header class="bundle-compare-group-head"><span class="bundle-compare-dot" aria-hidden="true"></span> <span class="bundle-compare-group-title" data-tooltip-truncated data-tooltip="${e}">${e}</span> <span class="bundle-compare-group-count">${t.length}</span> ${a}</header><ul class="${o?`bundle-compare-rows bundle-compare-rows--scroll bundle-compare-rows--fill`:`bundle-compare-rows bundle-compare-rows--scroll`}">${R(t,r,i)}</ul></section>`}_sizeCells(e){let t=e=>e==null?`—`:F(e),n=e=>`${e.toLocaleString()} LoC`;return e.delta===void 0?z`<span class="bundle-compare-row-size" data-tooltip="${e.lines>0?n(e.lines):B}">${t(e.bytes)}</span>`:z`<span class="${`bundle-compare-row-delta ${e.delta===null?``:Pt(e.delta)}`}" data-tooltip="${`${t(e.baseBytes)} \u2192 ${t(e.otherBytes)}${e.baseLines>0||e.otherLines>0?` \xB7 ${e.baseLines.toLocaleString()} \u2192 ${n(e.otherLines)}`:``}`}">${e.delta===null?`—`:Nt(e.delta)}</span>`}_sortActions(e,t,n,r=!1,i=this[e][t]){return z`<span class="bundles-overview-sort" role="group" aria-label="${`${t} ${n} order`}">${[[`name`,`Name`],[`size`,`Size`],...r?[[`flags`,`Flags`]]:[]].map(([n,r])=>z`<button type="button" aria-pressed="${String(i===n)}" @click="${()=>{this[e]={...this[e],[t]:n}}}">${r}</button>`)}</span>`}_fileGroup(e,t,n,r,i){let a=this.source?.files,o=n!==`removed`,s=e=>n===`added`?null:{details:this._otherDetails,path:e.basePath??e.path},c=e=>[...o&&a?.flags?a.flags(this.details,e.path,s(e)):[],...cr(e.meta)],l=t.some(e=>c(e).length>0),u=this._fileSort[n]===`flags`&&!l?`name`:this._fileSort[n],d=e=>n===`changed`?Math.abs(e.delta):e.bytes,f=u===`flags`?We(t,c,e=>e.path):t.toSorted((e,t)=>(u===`size`?d(t)-d(e):0)||e.path.localeCompare(t.path));return this._group(e,f,n,e=>e.path,e=>e.renamedFrom==null?this._fileRow(e.path,r(e.path),this._sizeCells(e),e.path,o,e.meta,e.basePath??e.path,s(e)):this._fileRow(e.path,sn(r(e.renamedFrom),r(e.path)),this._sizeCells(e),`${e.renamedFrom} \u2192 ${e.path}`,o,e.meta,e.basePath??e.path,s(e)),this._sortActions(`_fileSort`,n,`file`,l,u),{lanes:i})}_pkgGroup(e,t,n,r){let i=this._pkgSort[n],a=e=>{let t=n===`changed`?e.delta:e.bytes;return t==null?-1:Math.abs(t)},o=t.toSorted((e,t)=>(i===`size`?a(t)-a(e):0)||wt(e.pkg).localeCompare(wt(t.pkg))),s=n===`changed`?0:Math.min(xi,Math.max(0,...t.map(e=>Z(e.versions).length)));return this._group(e,o,n,e=>e.pkg,e=>z`<li><div class="bundle-compare-row"><span class="bundle-compare-pkg-dot" style="${L({background:St(e.pkg)})}"></span> <span class="bundle-compare-row-path" data-tooltip-truncated data-tooltip="${wt(e.pkg)}">${wt(e.pkg)}</span> ${n===`changed`?this._versionCell(e):s>0?z`<span class="bundle-compare-dep-ver" data-tooltip-truncated data-tooltip="${Z(e.versions)}">${Z(e.versions)}</span>`:B} ${this._sizeCells(n===`changed`?e:{bytes:e.bytes})}</div></li>`,this._sortActions(`_pkgSort`,n,`package`),{fill:!0,lanes:r,style:s>0?{"--compare-version-width":`${s}ch`}:{}})}_versionCell(e){let t=e.otherVersions,n=e.baseVersions;if(n.join()===t.join())return n.length>0?z`<span class="bundle-compare-dep-ver">${Z(n)}</span>`:B;let r=e.direction??`changed`,i=r===`up`?`↑`:r===`down`?`↓`:`±`;return z`<span class="bundle-compare-ver" aria-label="${`${r===`up`?`Upgraded`:r===`down`?`Downgraded`:`Changed`}: ${Z(n)||`none`} to ${Z(t)||`none`}`}"><span class="bundle-compare-ver-from">${Z(n)||`—`}</span> <span class="bundle-compare-ver-arrow" aria-hidden="true">→</span> <span class="${`bundle-compare-ver-to ${r}`}">${Z(t)||`—`}</span> <span class="${`bundle-compare-ver-dir ${r}`}" aria-hidden="true">${i}</span></span>`}_depGroup(e,t,n,r){let i=n===`changed`?0:Math.min(xi,Math.max(0,...t.map(e=>e.range.length))),a=e=>z`<span class="bundle-compare-row-path" data-tooltip-truncated data-tooltip="${e.name}">${e.name}</span> ${this.source?.dependencyTags?.(e,n)??B}${e.kind?z`<span class="npm-dependency-kind">${e.kind}</span>`:B} ${n===`changed`?z`<span class="bundle-compare-ver" aria-label="${`Changed: ${e.from} to ${e.to}`}"><span class="bundle-compare-ver-from">${e.from}</span> <span class="bundle-compare-ver-arrow" aria-hidden="true">→</span> <span class="bundle-compare-ver-to changed">${e.to}</span></span>`:z`<span class="bundle-compare-dep-ver" data-tooltip-truncated data-tooltip="${e.range}">${e.range}</span>`}`,o=this.source?.openDependency;return this._group(e,t,n,e=>e.key,e=>z`<li>${o&&e.opens?z`<button type="button" class="bundle-compare-row bundle-compare-row-link" @click="${()=>o(e)}">${a(e)}</button>`:z`<div class="bundle-compare-row">${a(e)}</div>`}</li>`,B,{fill:!0,lanes:r,style:i>0?{"--compare-version-width":`${i}ch`}:{}})}_renderDependencies(e,t,n,r){return r.length===0?B:z`<section class="bundle-compare-section"><h3 class="bundle-compare-section-head">Dependencies</h3>${this._cols(r,z`${this._depGroup(`Removed \xB7 only in ${t}`,e.removed,`removed`,r)} ${this._depGroup(`Added \xB7 only in ${n}`,e.added,`added`,r)} ${this._depGroup(`Changed`,e.changed,`changed`,r)}`,`dependencies`)}</section>`}_renderPackages(e,t,n,r=Si){return e.removed.length===0&&e.added.length===0&&e.changed.length===0?B:z`<section class="bundle-compare-section"><h3 class="bundle-compare-section-head">Packages</h3>${this._cols(r,z`${this._pkgGroup(`Removed \xB7 only in ${t}`,e.removed,`removed`,r)} ${this._pkgGroup(`Added \xB7 only in ${n}`,e.added,`added`,r)} ${this._pkgGroup(`Changed`,e.changed,`changed`,r)}`,`packages`)}</section>`}_cols(e,t,n){let r=e.map(e=>e===`changed`?`minmax(0, 5fr)`:`minmax(0, 4fr)`).join(` `);return z`<div class="bundle-compare-cols" data-lanes="${e.length}" data-section="${n}" style="${L({"--compare-lanes":r})}">${t}</div>`}_collapsible(e,t,n,r,i=``){let a=this._openSections.has(e);return z`<details class="bundle-compare-section bundle-compare-collapsible" .open="${M(a)}" @toggle="${t=>this._setSection(e,t.currentTarget.open)}"><summary class="bundle-compare-section-head" @click="${t=>{t.preventDefault(),this._setSection(e,!a)}}">${t} <span class="bundle-compare-section-count">${n.toLocaleString()}</span>${i?z`<span class="bundle-compare-section-note" data-tooltip-truncated data-tooltip="${i}">${i}</span>`:B}</summary>${a?r():B}</details>`}_setSection(e,t){if(t===this._openSections.has(e))return;let n=new Set(this._openSections);t?n.add(e):n.delete(e),this._openSections=n}_renderResolutions(e,t,n){if(e.totalChanges===0)return B;let r=[{title:`Removed \xB7 only in ${t}`,rows:e.onlyBase,kind:`removed`},{title:`Added \xB7 only in ${n}`,rows:e.onlyOther,kind:`added`},{title:`Repointed`,rows:e.changed,kind:`changed`}].filter(({rows:e})=>e.length>0).map(e=>({...e,shown:e.rows.slice(0,bi)})),i=(e,t=``)=>z`<td class="${t}"><code data-tooltip-truncated data-tooltip="${e}">${e}</code></td>`,a=(e,t)=>e===null?z`<td class="bundle-compare-resolution-none"><span>(none)</span></td>`:i(e||`(empty target)`,t),o=e=>`${e.conditions}${e.platform===null?``:` \xB7 Platform: ${e.platform}`}`,s=r.some(({shown:e})=>e.some(e=>o(e)!==`*`));return this._collapsible(`resolutions`,`Import resolutions`,e.totalChanges,()=>r.map(({title:e,rows:t,kind:n,shown:r})=>z`<section class="${`bundle-compare-group bundle-compare-${n} bundle-compare-resolutions`}"><header class="bundle-compare-group-head"><span class="bundle-compare-dot" aria-hidden="true"></span> <span class="bundle-compare-group-title">${e}</span> <span class="bundle-compare-group-count">${t.length}</span></header><table class="${s?``:`bundle-compare-resolutions--no-context`}"><thead><tr><th>File</th><th>Import</th><th>Before</th><th>After</th>${s?z`<th>Conditions</th>`:B}</tr></thead><tbody>${R(r,e=>e.key,e=>{let t=o(e);return z`<tr><td><button type="button" class="bundle-compare-resolution-parent" data-tooltip-truncated data-tooltip="${e.parent}" @click="${()=>this._openFile(e.parent)}">${e.parent}</button></td>${i(e.specifier)} ${a(e.baseTarget,`bundle-compare-resolution-before`)} ${a(e.otherTarget,`bundle-compare-resolution-after`)} ${s?z`<td class="bundle-compare-resolution-context"><span data-tooltip-truncated data-tooltip="${t}">${t}</span></td>`:B}</tr>`})}</tbody></table>${t.length>r.length?z`<div class="bundle-compare-more">and ${(t.length-r.length).toLocaleString()} more…</div>`:B}</section>`))}_comparison(){return an(this._otherDetails,this.details,this._scope,this._repaint)}_renderSummary(e){return Vt(e,z`<div class="bundle-compare-modes" role="tablist" aria-label="Comparison view">${[[`overview`,`Overview`],[`code`,`Code`]].map(([e,t])=>z`<button type="button" role="tab" aria-selected="${String(this._mode===e)}" @click="${()=>{this._mode=e,this._notify()}}">${t}</button>`)}</div>`)}_renderPicker(e,t,n,r){return Bt({source:this.source,from:{options:e,value:this._targetIntegrity,pick:e=>this._pick(e)},to:{options:this._baseOptions(),value:this._baseKey,placeholder:this._nameFor(this.integrity),pick:e=>this._pickBase(e)},clear:t?{run:()=>this._pick(null)}:null,swap:t&&this.source?.canSwap?.(this._targetIntegrity)!==!1?()=>this._swap():null,extras:n,comparison:r,openLine:e=>this._openLine(e)})}_baseOptions(){if(this.source)return V(this.source.choices??[]);let e=(j.bundles??[]).find(e=>e.integrity===this.integrity),t=Ce(j.bundles??[],this.integrity);return this._bundleOptions(e?[e,...t]:t)}_otherOptions(){return this.source?V(this.source.options):this._bundleOptions(Ce(j.bundles??[],this.integrity))}_bundleOptions(e){let t=new Map;for(let n of e)t.set(n.name,(t.get(n.name)??0)+1);return e.map(e=>({id:e.integrity,integrity:e.integrity,kind:e.kind??(e.name.toLowerCase().endsWith(`.map`)?`sourcemap`:`stasis`),summary:e.summary,size:typeof e.size==`number`?F(e.size):`—`,filename:t.get(e.name)>1?`${e.name} \xB7 ${e.integrity.slice(7,13)}\u2026`:e.name}))}render(){let e=this._otherOptions(),t=!!this._targetIntegrity&&(!!this.source||e.some(e=>e.integrity===this._targetIntegrity)),n=this._baseReady?o(t?this._otherDetails:null,this.details):[],r=n.length>0?z`<bundle-scope-selector .reasons="${n}" .value="${this._scope}" label="Compare scope" @scope-change="${e=>{this._scope=e.detail.value}}"></bundle-scope-selector>`:B,i=this.source?.noun??`bundle`,a=t&&this._status===`ready`&&this._otherDetails&&(this._otherDetails.json||this._otherDetails.bundle)&&!this._otherDetails.error,s=this._baseReady&&a?this._comparison():null,c=s?.status===`ready`?s.diff:null,l=c?{base:this._otherDetails,other:this.details,files:c.files}:null,u=e.length>0||this.source?this._renderPicker(e,t,r,l):r,d=c?this._mode:`overview`,f;return this._baseReady?this.source&&!t&&(this.source.pending||this.source.error||!this.source.select&&e.length===0)?f=z`<div class="${`bundle-compare-empty${this.source.error?` is-error`:``}`}">${this.source.pending?`Loading ${i}s\u2026`:this.source.error??z`No other ${i}s to compare <strong>${this._nameFor(this.integrity)}</strong> with.`}</div>`:e.length===0&&!this.source?f=z`<div class="bundle-compare-empty">No other bundles to compare with. Drop a second <code>.map</code> or <code>.stasis.code.br</code> bundle to diff against this one.</div>`:t?this._status===`loading`||!this._otherDetails?f=z`<div class="bundle-compare-empty">Comparing…</div>`:this._otherDetails.error?f=z`<div class="bundle-compare-empty is-error">Couldn't read the selected ${i}: ${this._otherDetails.error}</div>`:!this._otherDetails.json&&!this._otherDetails.bundle?f=z`<div class="bundle-compare-empty is-error">The selected ${i} couldn't be parsed.</div>`:s?.status===`error`?f=z`<div class="bundle-compare-empty is-error">Couldn't compare the ${i}s: ${s.message}</div>`:c?d!==`code`&&(f=this._renderDiff(c)):f=z`<div class="bundle-compare-empty">Comparing…</div>`:f=z`<div class="bundle-compare-empty">Pick a ${i} above to compare <strong>${this._nameFor(this.integrity)}</strong> against.</div>`:f=z`<div class="bundle-compare-empty">Loading bundle…</div>`,z`<div class="bundle-compare">${Ht(u,c?this._renderSummary(c):B)} ${d===`code`?yi({base:this._otherDetails,other:this.details,diff:c,source:this.source,path:this._codePath,seek:this._codeSeek,baseName:this._nameFor(this._targetIntegrity),otherName:this._nameFor(this.integrity),select:e=>{this._codePath=e}}):z`<div class="bundle-compare-body">${f}</div>`}</div>`}_renderDiff(e){let t=this._nameFor(this._targetIntegrity),n=this._nameFor(this.integrity),r=[...e.files.onlyBase.map(e=>e.path),...e.files.onlyOther.map(e=>e.path),...e.files.changed.flatMap(e=>e.renamedFrom==null?[e.path]:[e.path,e.renamedFrom])],i=a(e.files.root,Ct(r).prefix),{prefix:o}=i,s=e=>o&&e.startsWith(o)?e.slice(o.length):e,c=e.files.onlyBase.length+e.files.onlyOther.length+e.files.changed.length,l={removed:e.files.onlyBase,added:e.files.onlyOther,changed:e.files.changed},u=!e.totals.identical,d=this.source?.dependencies?.(this._otherDetails,this.details)??null,f=Si.filter(t=>(d??e.packageRows)[t].length>0),p=u?Si.filter(e=>l[e].length>0):[],m=p.every(e=>f.includes(e))?f:p,h=u?this.source?.files?.warning?.(this.details,[...l.added,...l.changed].map(e=>e.path)):B;return z`${d?this._renderDependencies(d,t,n,f):this._renderPackages(e.packageRows,t,n,f)} ${h??B} ${e.totals.identical?e.resolutions.totalChanges>0?z`<div class="bundle-compare-caption">File contents are unchanged; import resolutions differ.</div>`:z`<div class="bundle-compare-identical">These two ${this.source?.noun??`bundle`}s carry identical files (${e.totals.unchangedFiles.toLocaleString()} ${e.totals.unchangedFiles===1?`file`:`files`})${i.from?z`, moved <span class="mono">${cn(i)}</span>`:``}.</div>`:this._collapsible(`files`,`Files`,c,()=>this._cols(m,z`${this._fileGroup(`Removed \xB7 only in ${t}`,l.removed,`removed`,s,m)} ${this._fileGroup(`Added \xB7 only in ${n}`,l.added,`added`,s,m)} ${this._fileGroup(`Changed`,l.changed,`changed`,s,m)}`,`files`),i.from?`${i.from} \u2192 ${i.to}`:o)} ${this._renderResolutions(e.resolutions,t,n)}`}};customElements.define(`bundle-compare`,Ci);var Q=e=>e._blocked||e._loading,wi=e=>e._shownReview?.publishedAt!=null,Ti=e=>e.coverage===`full`?`Full`:`Partial`,Ei=e=>e._error?z`<p class="npm-review-error" role="alert">${e._error}</p>`:B,Di=e=>e._saveBlocked?z`<div class="npm-review-saving" role="status">Saving changes…</div>`:B,Oi=e=>[e._continuation?.review,...e._reviews].filter(Boolean).toSorted((e,t)=>+(e.publishedAt!==null)-(t.publishedAt!==null)||(t.publishedAt??t.time)-(e.publishedAt??e.time)),ki=e=>`npm-review-button npm-review-primary npm-review-finalize ${e._allowedVerdicts[0]}`,Ai=(e,t,n,r,i=Object.keys(nt),a=!1)=>z`<div class="npm-review-verdict-options" role="group" aria-label="Verdict">${Object.entries(a?{"":`Not checked`,...nt}:nt).map(([a,o])=>z`<label class="${`npm-review-verdict-choice ${a||`unchecked`}`}"><input type="radio" name="${e}" aria-label="${o}" value="${a}" .checked="${M(t===a)}" ?disabled="${r||a!==``&&!i.includes(a)}" @change="${()=>n(a)}">${o}</label>`)}</div>`;function ji(e){let t=wi(e),n=e._shownReview,r=e._summary,i=e._canEdit?{label:`Finalize review`,run:()=>e._beginPublish(),disabled:!r.checkedFiles}:!t||!e._writable?null:e._activeReview||e._ownPublished.length===0?{label:`Resume your review`,run:()=>e._resume()}:n.user===e.session?.id?{label:`Revise review`,run:()=>e._change({action:`continue`,reviewId:n.id,revision:n.revision})}:null;return z`<div class="npm-review-summary-actions">${t||e._draftStarted?ct(n??{publishedAt:null,revokedAt:null}):B}<div class="npm-review-progress-block"><span>${e._unsaved&&(e._saveBlocked||e._error)?z`<button type="button" class="npm-review-button npm-review-text-button" @click="${()=>e._openPanel(`unsaved`)}">Unsaved changes</button>`:z`<strong>${r.checkedFiles} of ${r.totalFiles}</strong> files checked`}</span> ${c(r.checkedFiles,r.totalFiles)}</div>${i?z`<button type="button" class="${e._canEdit?ki(e):`npm-review-button`}" ?disabled="${Q(e)||i.disabled}" @click="${i.run}">${i.label} ${O}</button>`:B}</div>`}function Mi(e){let t=e.source??Ke(e.entry),n=!!(e._target&&e._target!==`(empty)`),r=V(t.options,t=>`${e.entry.npm.name}@${t.id}`);n&&!r.some(t=>t.id===e._target)&&r.push(...V([{id:e._target,name:e._target,format:`npm`}]));let i=V(t.choices);i.some(t=>t.id===e.entry.npm.version)||i.push(...V([{id:e.entry.npm.version,name:e.entry.npm.version,format:`npm`}]));let a=i.findIndex(t=>t.id===e.entry.npm.version),o=`${e.entry.npm.version} unpatched`,s=e._patch&&{name:`${e.entry.npm.name}@${e.entry.npm.version}`,detail:`patch:${e._patch.hash.slice(0,5)}`,detailNote:Pi(Ni(e))};s&&i.splice(a,1,{...i[a],detail:s.detail,detailNote:s.detailNote},{...i[a],id:o});let c=r.findIndex(t=>t.id===e._target),l=`${e._target} unpatched`,u=n&&e._basePatch&&{name:e._target,detail:`patch:${e._basePatch.slice(0,5)}`,detailNote:Pi(e._base?.npmPatch?.patch)};return u&&r.splice(c,1,{...r[c],detail:u.detail,detailNote:u.detailNote},{...r[c],id:l}),Ht(Bt({source:s||u?{...t,widest:s||u}:t,label:`Review`,disabled:Q(e),from:{options:r,value:n?e._target:null,label:`Review base`,pick:t=>{e._navigate(t===l?e._target:t,t===e._target?e._basePatch:null)}},to:{options:i,value:e.entry.npm.version,label:`Version to review`,pick:t=>{e._navigateTo({view:`npm`,packageName:e.entry.npm.name,packageSpec:t===o?e.entry.npm.version:t,bundleTab:`review`,...e._location(e._target,t===e.entry.npm.version)})}},clear:n?{label:`Clear review base`,run:()=>{e._navigate(`(empty)`)}}:null,openLine:t=>e._openLine(t),comparison:e._base?{base:e._base,other:e._other,files:e._diff.files}:null}),e._base?Vt(e._diff):B)}var Ni=e=>e._patched?.npmPatch?.patch??e._patch,Pi=e=>`As pnpm\u2019s patch${e?.path?` ${e.path}`:``} changes it`,Fi=e=>e._patch?z`<span class="npm-review-patched" data-tooltip="${`${Pi(Ni(e))}${Ni(e).commit?`, read at ${Ni(e).commit.slice(0,7)}`:``}`}">patch:${e._patch.hash}</span>`:B;function Ii(e){return z`<div class="npm-review-toolbar"><nav class="npm-review-toolbar-group" aria-label="Review breadcrumbs"><button type="button" class="npm-review-button npm-review-text-button" ?disabled="${Q(e)}" @click="${()=>{e._navigateTo({view:`reviews`})}}">My reviews</button> ${O}<button type="button" class="npm-review-button npm-review-text-button npm-review-package" aria-haspopup="dialog" ?disabled="${e._blocked}" @click="${()=>e._openPanel(`reviews`)}"><span>${e.entry.npm.name}@${e.entry.npm.version}</span><span class="npm-review-count">${Oi(e).length}</span></button> ${Fi(e)}</nav>${ji(e)}</div>`}function Li(e,t=e._file,n=!1){let r=e._editorState(t),i=e._shownReview?.entries.find(e=>e.file===t),a=e._nonTextFiles.includes(t),o=!a&&[`accept-with-nits`,`request-changes`,`reject`].includes(r.status);return z`<section class="${`npm-review-decision${n?` npm-review-inline-decision`:``}`}" aria-label="File decision">${e._canEdit?z`${Ai(`file:${t}`,a?``:r.status,n=>{e._setFileStatus(t,n)},Q(e)||a,void 0,!0)} ${a?z`<p class="npm-review-help">Non-text file. Verdicts are not supported yet; this file remains unchecked.</p>`:B} ${o?z`<textarea aria-label="File note" rows="2" maxlength="20000" placeholder="Add a note (optional)…" .value="${M(r.comment)}" ?disabled="${Q(e)}" @input="${n=>e._editFile(t,{comment:n.target.value})}" @blur="${()=>{e._saveFile(t)}}"></textarea>`:B}`:z`${n?B:z`<header><strong>File review</strong><span class="npm-review-muted">${wi(e)?`Frozen`:`Read only`}</span></header>`} ${i?.status&&!a?z`${ot(i.status)}${f(i.comment)}`:z`<p class="npm-review-muted">This file was not reviewed.</p>`} ${e._reviewer||e._loading?B:z`<p class="npm-review-help">${e._writable?`Reviewing needs a team that reviews dependencies, where you manage or have Dependencies.`:`Triage access is required to add a review.`}</p>`}`}</section>`}function Ri(e,t,n,r,i,a){return z`<fieldset class="npm-review-team-options"><legend>${t}</legend>${n.map(t=>z`<mode-switch label="${t.name}" .checked="${r.has(t.id)}" .disabled="${Q(e)}" @click="${()=>{if(Q(e))return;let n=new Set(r);n.has(t.id)?n.delete(t.id):n.add(t.id),i(n)}}"></mode-switch>`)}${a}</fieldset>`}function zi(e,t){let n=e._allowedVerdicts,r=Le(t.entries,e._files,e._nonTextFiles),i=t.entries.filter(t=>t.status&&t.comment.trim()&&!e._nonTextFiles.includes(t.file));return z`<form class="npm-review-publish-form" @submit="${t=>{t.preventDefault(),e._publish()}}"><div class="npm-review-dialog-body"><section class="npm-review-coverage"><div><strong>${Ti(r)} review</strong><span>${r.checkedFiles} of ${r.totalFiles} files checked</span></div>${c(r.checkedFiles,r.totalFiles)}<p>${r.totalFiles>r.checkedFiles?z`${r.totalFiles-r.checkedFiles} files not checked. <button type="button" class="npm-review-button npm-review-text-button" @click="${()=>{e._unchecked=!0,e._closePanel()}}">View files</button>`:`Every file has a verdict.`}</p>${e._needsPackageJson?z`<p class="npm-review-error">Review ${e._files.includes(`package.json`)?z`<button type="button" class="npm-review-button npm-review-text-button" @click="${()=>{e._closePanel(),e._selectFile(`package.json`)}}">package.json</button>`:`package.json`} before publishing a partial review.</p>`:B}</section>${i.length>0?z`<section aria-label="File notes"><strong>File notes</strong><ul class="npm-review-publish-notes" tabindex="0" aria-label="Saved file notes">${i.map(e=>z`<li><span class="dependency-review-entry-file">${ht(e.file)}<span>${e.file}</span></span> ${f(e.comment)}</li>`)}</ul></section>`:B}<div><strong>Final verdict</strong>${Ai(`final-verdict`,e._finalStatus,t=>{e._finalStatus=t},Q(e),n)}</div>${e._securityLimit===`reject`?z`<p class="npm-review-help">Malware detected. Only Reject is available.</p>`:e._securityLimit===`request-changes`?z`<p class="npm-review-help">Critical vulnerabilities detected.</p>`:B} <label>Final note <span class="npm-review-muted">· optional</span><textarea aria-label="Final comment" rows="3" maxlength="20000" .value="${M(e._finalComment)}" placeholder="Summarize your findings or explain what remains…" ?disabled="${Q(e)}" @input="${t=>{e._finalComment=t.target.value}}"></textarea></label> ${e._unchangedContinuation?z`<p class="npm-review-help">Change a verdict or note to publish a new review.</p>`:B} ${Ri(e,`Publish to teams`,e._teams,e._selectedTeams,t=>{e._selectedTeams=t},e._selectedTeams.size>0?B:z`<p class="npm-review-error">${e._teams.length===0?`No teams you belong to have dependency review enabled.`:`Select at least one team to publish.`}</p>`)} ${Ei(e)}</div><footer class="npm-review-dialog-footer"><p>Publishing freezes your verdicts and notes.<br>You can continue in a new review to make changes.</p><button type="submit" class="${ki(e)}" ?disabled="${Q(e)||!e._canPublish}">Publish to ${e._selectedTeams.size} ${e._selectedTeams.size===1?`team`:`teams`} ${O}</button></footer></form>`}function Bi(e,t){let n=t===e._shownReview,r=t.publishedAt!==null,i=r?t:m(t,e._context)?Le(t.entries,e._files,e._nonTextFiles):{checkedFiles:t.entries.filter(e=>e.status).length,totalFiles:null},a=[e._continuation?.review,...e._reviews].some(n=>n?.publishedAt===null&&n.user===e.session?.id&&m(n,t)),o=t.user===e.session?.id,s=e._teams.filter(e=>!t.teams.some(t=>t.id===e.id)),c=e._additionalTeams.get(t.id)??new Set(s.length===1?s.map(e=>e.id):[]),l=s.filter(e=>c.has(e.id)).map(e=>e.id);return z`<section class="npm-review-entry" aria-current="${String(n)}"><div class="npm-review-history-heading"><strong>${ut(t)}</strong>${n?z`<span class="npm-review-current">Current</span>`:B}${ct(t)}</div><p class="npm-review-help">${t.basePackage?`${t.basePackage===t.package?t.baseVersion:`${t.basePackage}@${t.baseVersion}`} \u2192 ${t.version}`:`All package files`}</p><div class="npm-review-entry-result">${r?ot(t.status):B}<span class="dependency-review-coverage"> ${r?z`${i.coverage===`full`?`Full`:z`<span class="dependency-review-partial">Partial</span>`} · `:B}${i.checkedFiles}${i.totalFiles===null?B:`/${i.totalFiles}`} files checked</span></div><p class="npm-review-help">${t.teams.length>0?`${t.teams.map(e=>e.name).join(`, `)} \xB7 `:``}${ft(t.publishedAt??t.time)}</p>${f(t.comment)}<div class="npm-review-entry-actions"><button type="button" class="npm-review-button" ?disabled="${Q(e)}" @click="${()=>{e._openReview(t)}}">Open ${O}</button> ${r&&o&&!a&&e._reviewer?z`<button type="button" class="npm-review-button" aria-label="Revise in a new draft" ?disabled="${Q(e)}" @click="${()=>{e._openReview(t,!0)}}">Revise</button>`:B} ${r&&o&&e._writable&&t.revokedAt===null?z`<button type="button" class="npm-review-button npm-review-danger" ?disabled="${Q(e)}" @click="${()=>e._change({action:`revoke`,reviewId:t.id,revision:t.revision})}">Revoke</button>`:B} ${o?z`<dependency-review-copy .text="${t.formatted}"></dependency-review-copy>`:B} ${!r&&o&&e._writable?z`<button type="button" class="dependency-review-discard" aria-label="Discard review" ?disabled="${Q(e)}" @click="${()=>{e._discard(t)}}">${At(kt)}</button>`:B}</div>${r&&o&&e._writable&&t.revokedAt===null&&s.length>0?z`<details class="npm-review-share"><summary>Publish to more teams</summary>${Ri(e,`Teams`,s,c,n=>{e._additionalTeams=new Map(e._additionalTeams).set(t.id,n)},z`<button type="button" class="npm-review-button" ?disabled="${Q(e)||l.length===0}" @click="${()=>e._change({action:`publish`,reviewId:t.id,revision:t.revision,teamIds:l})}">Publish to more teams</button>`)}</details>`:B} ${t.revokedAt===null?B:z`<p class="npm-review-help">Revoked ${ft(t.revokedAt)}. Content and team links remain frozen.</p>`}</section>`}function Vi(e){if(!e._panel)return B;let t={publish:`Publish review`,reviews:`Reviews`,unsaved:`Unsaved changes`};return z`<dialog class="npm-review-dialog" aria-label="${t[e._panel]}" @cancel="${t=>{t.preventDefault(),e._closePanel()}}"><button type="button" class="detail-action npm-review-close" aria-label="Close panel" ?disabled="${e._blocked}" @click="${()=>e._closePanel()}">×</button><header class="npm-review-dialog-head"><h2>${t[e._panel]}</h2><p>${e._panel===`reviews`?`${e.entry.npm.name}@${e.entry.npm.version}${e._patch?` (patched)`:``}`:b(e._context)}</p></header>${e._panel===`publish`?zi(e,e._activeReview):z`<div class="${`npm-review-dialog-body${e._panel===`reviews`?` npm-review-entries`:``}`}">${e._panel===`unsaved`?z`${e._dirtyFiles.map(t=>z`<button type="button" class="npm-review-button" @click="${()=>{e._closePanel(),e._selectFile(t)}}">${t} ${O}</button>`)}`:Oi(e).map(t=>Bi(e,t))} ${e._panel===`reviews`&&Oi(e).length===0?z`<p class="npm-review-muted">No reviews yet.</p>`:B}${Ei(e)}</div>`} ${Di(e)}</dialog>`}function Hi(e){let t=e._shownReview?.entries,n=e._files,r=e._nonTextFiles;if(e._treeProgress?.entries!==t||e._treeProgress?.files!==n||e._treeProgress?.nonTextFiles!==r){let i=u(t,r),a=new Map,o=0;for(let t of e._files){let e=t.split(`/`),n=+!!i.get(t)?.status;o+=n;for(let t=1;t<e.length;t++){let r=e.slice(0,t).join(`/`),i=a.get(r)??{total:0,checked:0};i.total++,i.checked+=n,a.set(r,i)}}e._treeProgress={entries:t,files:n,nonTextFiles:r,states:i,directories:a,checked:o}}let{states:i,directories:a,checked:o}=e._treeProgress;return{railLabel:`Files`,treeLabel:`Review files`,collapseLabel:`Collapse folders`,searchLabel:`Find a file`,searchPlaceholder:`Find a file…`,treePageSize:300,filterContent:!1,fullPaths:!0,collapseClearsSearch:!0,canSelect:()=>!e._blocked&&!e._panel,fileFilter:e._unchecked?e=>!i.get(e)?.status:null,fileLabel:e=>`${e}, ${nt[i.get(e)?.status]??`Not reviewed`}`,filePrefix:e=>it(i.get(e)?.status),fileSuffix:e=>i.get(e)?.notes?z`<span class="npm-review-note-dot" aria-label="Has notes">•</span>`:B,directoryLabel:e=>{let t=a.get(e.sourcePath);return`${e.sourcePath}, ${t?.checked??0} of ${t?.total??0} checked`},directorySummary:e=>{let t=a.get(e.sourcePath);return`${t?.checked??0}/${t?.total??0}`},filters:z`<div class="npm-review-filters" aria-label="Filter review files"><button type="button" class="npm-review-button" aria-pressed="${String(!e._unchecked)}" @click="${()=>{e._unchecked=!1}}">All ${e._files.length}</button> <button type="button" class="npm-review-button" aria-pressed="${String(!!e._unchecked)}" @click="${()=>{e._unchecked=!0}}">Unchecked ${e._files.length-o}</button></div>`,fileActions:(t,n)=>Li(e,t,n)}}function Ui(e){if(!e._base){let t=z`<div class="npm-review-empty" role="${e._baseError?`alert`:`status`}">${e._baseError??`Loading comparison…`} ${e._baseError?z`<button type="button" class="npm-review-button" @click="${()=>{e._baseKey=null,e._loadBase(e._target,e.request?.resume)}}">Retry</button>`:B}</div>`;return e._baseError&&e._basePatch?z`${Mi(e)}${t}`:t}return z`${Mi(e)}${Ii(e)}${e._panel?B:Ei(e)} ${yi({base:e._base,other:e._other,diff:e._diff,source:e.source,path:e._path,seek:e._seek,baseName:e._base.npm?`${e._base.npm.name}@${e._base.npm.version}${e._base.npmPatch?` (patched)`:``}`:`Empty package`,otherName:`${e.entry.npm.name}@${e.entry.npm.version}${e._patch?` (patched)`:``}`,select:t=>e._selectFile(t),extensions:Hi(e),mode:e._mode})} <span class="npm-review-announcement" role="status">${e._notice??``}</span>${e._panel?B:Di(e)}${Vi(e)}`}var Wi={maxLines:5e4,maxBytes:2097152},Gi={integrity:`(empty)`,kind:`sourcemap`,json:{version:3,sources:[],sourcesContent:[]},fileSizes:new Map},Ki=(e,t,n=null)=>({ecosystem:`npm`,package:e.npm.name,version:e.npm.version,integrity:e.integrity,patchHash:n?.hash??null,basePackage:t?.npm?.name??null,baseVersion:t?.npm?.version??null,baseIntegrity:t?.npm?t.npmPatch?.integrity??t.integrity:null,basePatchHash:t?.npmPatch?.patch.hash??null}),$=(e,t)=>`${e}@${t??`latest`}`,qi=class extends jt{static properties={entry:{attribute:!1},details:{attribute:!1},request:{attribute:!1},session:{attribute:!1},source:{attribute:!1},_teams:{state:!0},_selectedTeams:{state:!0},_additionalTeams:{state:!0},_reviews:{state:!0},_loading:{state:!0},_error:{state:!0},_saving:{state:!0},_saveBlocked:{state:!0},_file:{state:!0},_seek:{state:!0},_finalStatus:{state:!0},_finalComment:{state:!0},_base:{state:!0},_baseError:{state:!0},_panel:{state:!0},_path:{state:!0},_selectedReview:{state:!0},_unchecked:{state:!0},_notice:{state:!0},_continuation:{state:!0}};createRenderRoot(){return this}constructor(){super(),this._teams=[],this._reviews=[],this._files=[],this._nonTextFiles=[],this._selectedTeams=new Set,this._additionalTeams=new Map,this._editors=new Map,this._file=null,this._path=null,this._patch=null,this._patched=null,this._basePatch=null,this._loading=!1,this._saving=!1,this._error=null,this._context=null,this._key=null,this._controller=new AbortController,this._mode=`code`,this._panel=null,this._selectedReview=null,this._unchecked=!1,this._pendingSaves=[],this._saveBlocked=!1}disconnectedCallback(){super.disconnectedCallback(),this._controller.abort(),this._cancelSaves(),this._dismissLoading?.(),this._key=null,this._baseKey=null}updated(){let e=this.querySelector(`dialog`);e&&!e.open&&e.showModal(),this._rememberBase()}_rememberBase(){j.bundleDetailsTab!==`review`||j.selectedBundle!==this.entry?.integrity||!this._context||!this._activeReview&&this._ownPublished.length===0&&!this._unsaved||(j.npmReview={bundle:this.entry.integrity,...this._context.basePackage?{reviewPackage:this._context.basePackage,reviewSpec:this._context.baseVersion}:{},...this._patch?{patch:this._patch}:{},...this._context.basePatchHash?{basePatch:this._context.basePatchHash}:{},started:!0,user:this.session?.id})}get _writable(){return[`triage`,`manage`,`admin`].includes(this.session?.role)&&!this.session?.viewer}get _other(){return this._patched??this.details}get _reviewer(){return this._writable&&this._teams.length>0}get _activeReview(){return this._reviews.find(e=>e.user===this.session?.id&&e.publishedAt===null&&m(e,this._context))??(this._continuation&&this._continuation.review.user===this.session?.id?this._continuation.review:null)}get _ownPublished(){return this._reviews.filter(e=>e.user===this.session?.id&&e.publishedAt!==null&&m(e,this._context)).toSorted((e,t)=>t.publishedAt-e.publishedAt)}get _shownReview(){return this._selectedReview?this._reviews.find(e=>e.id===this._selectedReview):this._activeReview??this._ownPublished[0]??null}get _canEdit(){return this._reviewer&&!this._selectedReview&&(this._activeReview!==null||this._ownPublished.length===0)}_isDirty(e,t){return!this._nonTextFiles.includes(e)&&(t.comment!==(t.edit?.comment??``)||t.status!==(t.edit?.status??``))}get _dirtyFiles(){return[...this._editors].filter(([e,t])=>this._isDirty(e,t)).map(([e])=>e)}get _blocked(){return this._saving||this._saveBlocked}get _unsaved(){return this._pendingSaves.length>0||this._dirtyFiles.length>0}get _draftStarted(){return this._canEdit&&(this._unsaved||this._activeReview&&!this._continuation||this._continuation&&this._publishRevision!=null&&!this._unchangedContinuation)}get _summary(){return Le(this._shownReview?.entries??[],this._files,this._nonTextFiles)}get _securityLimit(){return this.source?.reviewVerdictLimit?.(this.entry,this._base)??`accept`}get _allowedVerdicts(){let e=new Map((this._shownReview?.entries??[]).map(e=>[e.file,e]));if(this._canEdit)for(let[t,n]of this._editors)e.set(t,{file:t,status:n.status||null});return Be([...e.values()].filter(e=>!this._nonTextFiles.includes(e.file)),this._securityLimit)}get _needsPackageJson(){return He(this._activeReview?.entries??[],this._files,this._nonTextFiles)}get _unchangedContinuation(){let e=this._continuation?.source;return!!(e&&this._finalStatus===e.status&&this._finalComment===e.comment)}get _canPublish(){return this._canEdit&&this._panel===`publish`&&this._activeReview?.revision===this._publishRevision&&this._summary.checkedFiles>0&&!this._needsPackageJson&&!this._unchangedContinuation&&this._selectedTeams.size>0&&!this._unsaved&&this._allowedVerdicts.includes(this._finalStatus)}_location(e,t=!0,n=e===this._target?this._basePatch:null){let r=e&&e!==`(empty)`?ve(e):null;return{...r?{reviewPackage:r.name,reviewSpec:r.spec}:{},...t&&this._patch?{patch:this._patch}:{},...r&&n?{basePatch:n}:{}}}_asked(e=this._context){let t=Object.fromEntries(Object.keys(this._context).map(t=>[t,e[t]??null])),n=(e===this._context?null:e.patchSource)??this._patch;return t.patchHash&&n?.repoId!=null?{...t,patchRepoId:n.repoId,patchCommit:n.commit,...n.path==null?{}:{patchPath:n.path}}:t}_navigate(e,t=e===this._target?this._basePatch:null){return this._navigateTo(be(this.entry,`review`,this._location(e,!0,t)))}async _navigateTo(e){if(this._blocked||this._loading)return;let t=this._key,n=this._navigation={};this._unsaved&&!await this._saveAll()||t===this._key&&n===this._navigation&&!this._unsaved&&await Re?.navigate(e)}async _loadBase(e,t=!1){let n=JSON.stringify([this.entry.integrity,e,this._patch,this._basePatch,this.session?.id,this.session?.role]);if(this._baseKey!==n){this._baseKey=n,this._base=null,this._baseError=null,this._controller.abort(),this._cancelSaves(),this._key=null,this._controller=new AbortController;try{let r=this._controller.signal,i=this._patch?Se(this.entry,this._patch,{signal:r}):Promise.resolve(this.details);i.catch(()=>{});let a=t?await ye(Ki(this.entry,null,this._patch),r):null;if(this._baseKey!==n)return;a&&([e,this._basePatch]=[a.basePackage?$(a.basePackage,a.baseVersion):`(empty)`,a.basePatchHash??null]);let o=e===`(empty)`?null:ve(e),s=o?await xe(o.name,o.spec??`latest`):null,c=s&&this._basePatch?{...await Se(s.entry,{hash:this._basePatch},{signal:r}),npm:s.details.npm}:s?.details??Gi,l=await i;if(this._baseKey!==n)return;let u=await on(c,l);if(this._baseKey!==n)return;t&&(a&&g(a),this._target=e,this.request={bundle:this.entry.integrity,...this._location(e)},this._baseKey=JSON.stringify([this.entry.integrity,e,this._patch,this._basePatch,this.session?.id,this.session?.role])),this._patched=this._patch?l:null,this._base=c,this._ensureContext(c,u)}catch(e){this._baseKey===n&&(this._baseError=e.message)}}}_ensureContext(e,t){let n=Ki(this.entry,e,this._patch),r=JSON.stringify([this.session?.id,this.session?.role,n]);if(r===this._key)return;this._controller.abort(),this._cancelSaves(),this._controller=new AbortController,this._context=n,this._diff=t;let i=hn(e,this._other,this._diff);this._files=Ve(Ee(i.map(e=>e.path)));let a=new Set(i.filter(e=>!Fe(e.before,e.after)).map(e=>e.path));if(this._nonTextFiles=this._files.filter(e=>a.has(e)),this._mode=gn(i,Wi)?`diff`:`code`,this._key=r,this._teams=[],this._reviews=[],this._selectedTeams=new Set,this._additionalTeams=new Map,this._selectedReview=null,this._continuation=null,this._editors.clear(),this._path=this._files[0]??null,this._panel=null,this._notice=``,this._resetEditor(this._path),this._saving=!1,this._refresh(!0),j.bundleDetailsTab===`review`&&j.selectedBundle===this.entry.integrity){let t=this._location(e.npm?$(e.npm.name,e.npm.version):`(empty)`,!0,e.npmPatch?.patch.hash??null);j.npmReview={bundle:this.entry.integrity,...t},this._baseKey=JSON.stringify([this.entry.integrity,e.npm?$(e.npm.name,e.npm.version):`(empty)`,this._patch,this._basePatch,this.session?.id,this.session?.role]),Re?.replaceRoute(be(this.entry,`review`,t))}}async _refresh(e=!1){let t=this._key;for(;t===this._key&&this._pendingSaves.length>0;)if((await Promise.all(this._pendingSaves.map(e=>e.promise))).some(e=>!e))return;if(t!==this._key)return;this._dismissLoading?.();let n=this._dismissLoading=Xe(`Loading reviews…`,{duration:0});this._loading=!0,this._error=null;try{let{reviews:n,teams:r}=await fe({...this._context,allBases:!0},null,null,this._controller.signal);if(t===this._key){let t=this._unsaved;this._reviews=n,this._teams=r,n.some(e=>e.user===this.session?.id&&e.publishedAt===null&&m(e,this._context))&&(this._continuation=null),this._rememberBase();let i=v(this._context),a=i&&n.find(e=>e.id===i.review.id);a?.publishedAt!=null&&(i.continueReview?this._continue(a.id,a.revision):this._selectedReview=a.id),this._selectedTeams=new Set(r.filter(t=>e?r.length===1:this._selectedTeams.has(t.id)).map(e=>e.id)),t||(this._editors.clear(),this._resetEditor(this._file))}}catch(e){t===this._key&&e.name!==`AbortError`&&(this._error=e.message)}finally{n(),t===this._key&&(this._loading=!1)}}_resetEditor(e=null){this._publishRevision=null,this._file=e,this._editorState(e)}_editorState(e){let t=this._canEdit?this._editors.get(e):null;if(!t){let n=this._shownReview?.entries.find(t=>t.file===e&&t.status)??null;t={edit:n,revision:this._activeReview?.revision??null,comment:this._nonTextFiles.includes(e)?``:n?.comment??``,status:this._nonTextFiles.includes(e)?``:n?.status??``},this._canEdit&&this._editors.set(e,t)}return{...t,dirty:this._isDirty(e,t)}}_editFile(e,t){!this._canEdit||this._blocked||(this._resetEditor(e),Object.assign(this._editors.get(e),t),this.requestUpdate())}_setFileStatus(e,t){if(!(this._blocked||this._nonTextFiles.includes(e)))return this._editFile(e,{status:t,...t?{}:{comment:``}}),this._saveFile(e)}_selectFile(e){this._blocked||!this._files.includes(e)||(this._path=e,this._resetEditor(e))}_openLine({path:e,line:t,query:n}){this._blocked||!this._files.includes(e)||(this._seek={path:e,line:t-1,query:n},this._selectFile(e))}_openPanel(e){this._panel=e}async _openReview(e,t=!1){if(this._blocked||this._loading)return;if(m(e,this._context)){t?this._continue(e.id,e.revision):e.publishedAt===null?this._resume():this._showPublished(e);return}let n=this._key;this._unsaved&&!await this._saveAll()||n!==this._key||(g(e,t),await this._navigate(e.basePackage?$(e.basePackage,e.baseVersion):`(empty)`,e.basePatchHash??null))}_closePanel(){this._blocked||(this.querySelector(`dialog`)?.close(),this._panel=null)}_showPublished(e){this._selectedReview=e.id,this._panel=null,this._file=this._path}_resume(){this._selectedReview=null,this._panel=null,this._resetEditor(this._path)}async _discard(e){if(this._blocked||this._loading||!this._writable||e.user!==this.session.id||e.publishedAt!==null)return;let t=e===this._activeReview,n=this._key,r=this._controller.signal;this._saving=!0,this._error=null;try{let{confirmed:i}=await vt({reviewTitle:b(e),signal:r});if(!i||r.aborted||n!==this._key||(await Promise.all(this._pendingSaves.map(e=>e.promise)),r.aborted||n!==this._key||!this._writable)||(e=t?this._activeReview:this._reviews.find(t=>t.id===e.id),!e||e.user!==this.session.id||e.publishedAt!==null))return;let a=e===this._continuation?.review;if(a||await _e(e.id,e.revision,this.session.csrfToken,r),r.aborted||n!==this._key)return;a||(this._reviews=this._reviews.filter(t=>t.id!==e.id)),m(e,this._context)&&(this._continuation=null,this._selectedReview=null,this._editors.clear(),this._resetEditor(this._path),this._finalStatus=null,this._finalComment=``,this._panel=null,this._ownPublished.length===0&&j.npmReview?.bundle===this.entry.integrity&&delete j.npmReview.started),this._notice=`Draft discarded.`}catch(e){n===this._key&&e.name!==`AbortError`&&(this._error=e.message)}finally{n===this._key&&(this._saving=!1)}}_continue(e,t){let n=this._reviews.find(n=>n.id===e&&n.revision===t&&n.user===this.session?.id&&n.publishedAt!==null&&m(n,this._context));return!n||this._activeReview||!this._reviewer?null:(this._continuation={source:n,review:{...n,publishedAt:null,revokedAt:null,status:null,teams:[]}},this._selectedTeams=new Set(this._teams.length===1?this._teams.map(e=>e.id):[]),this._selectedReview=null,this._panel=null,this._editors.clear(),this._resetEditor(this._path),this._notice=`A new draft will be saved when you make a change.`,this._activeReview)}async _persistContinuation(e){let t=this._continuation,n=this._key,{review:r}=await fe(this._asked(),{action:`continue`,reviewId:t.source.id,revision:t.source.revision},this.session.csrfToken,this._controller.signal);return n!==this._key||this._continuation!==t||e&&this._pendingSaves[0]!==e?null:(this._acceptSave(r,{revision:t.source.revision}),r)}_cancelSaves(){for(let e of this._pendingSaves)clearTimeout(e.timer),e.resolve(null);this._pendingSaves=[],this._saveBlocked=!1}_queueSave(e){let t=this._pendingSaves.findLast(t=>t.change.file===e.file);if(t&&t.change.comment===e.comment&&t.change.status===e.status)return t.promise;let n={change:e,slow:!1};return n.promise=new Promise(e=>{n.resolve=e}),n.timer=setTimeout(()=>{n.slow=!0,this._saveBlocked=!0},3e3),this._pendingSaves.push(n),this.requestUpdate(),this._pendingSaves.length===1&&this._flushSaves(),n.promise}_acceptSave(e,t){this._reviews=[...this._reviews.filter(t=>t.id!==e.id),e],this._continuation=null;for(let[n,r]of this._editors)r.revision===t.revision&&(r.revision=e.revision,r.edit=e.entries.find(e=>e.file===n&&e.status)??null);for(let{change:n}of this._pendingSaves.slice(1))n.revision===t.revision&&(n.revision=e.revision,n.reviewId=e.id,n.entryId=e.entries.find(e=>e.file===n.file)?.id??null);this._canEdit&&this._resetEditor(this._file),this._notice=`Saved privately.`,this._rememberBase()}async _flushSaves(){for(;this._pendingSaves.length>0;){let e=this._pendingSaves[0];this._error=null;try{if(this._continuation){let t=await this._persistContinuation(e);if(!t||this._pendingSaves[0]!==e)return;Object.assign(e.change,{reviewId:t.id,revision:t.revision,entryId:t.entries.find(t=>t.file===e.change.file)?.id??null})}let{review:t}=await fe(this._asked(),e.change,this.session.csrfToken,this._controller.signal);if(this._pendingSaves[0]!==e)return;this._acceptSave(t,e.change),clearTimeout(e.timer),this._pendingSaves.shift(),e.resolve(t),this._saveBlocked=this._pendingSaves.some(e=>e.slow),this.requestUpdate()}catch(t){if(this._pendingSaves[0]!==e)return;this._cancelSaves(),t.name!==`AbortError`&&(this._error=t.message),this.requestUpdate();return}}}async _change(e){if(this._blocked||this._pendingSaves.length>0||this._loading||!this._writable)return null;if(e.action===`continue`)return this._continue(e.reviewId,e.revision);let t=this._key;this._saving=!0,this._error=null;try{if(e.action===`publish`&&e.finalStatus&&this._continuation){let t=await this._persistContinuation();if(!t)return null;e={...e,reviewId:t.id,revision:t.revision}}let n=this._reviews.find(t=>t.id===e.reviewId)??this._context,{review:r}=await fe(this._asked(n),e,this.session.csrfToken,this._controller.signal);return t===this._key?(this._reviews=[...this._reviews.filter(e=>e.id!==r.id),r],e.action===`publish`&&e.finalStatus&&m(r,this._context)&&(this._selectedReview=r.id,this._panel=null,this._editors.clear(),this._notice=`Published. Verdicts and notes are now frozen.`),this._rememberBase(),r):null}catch(e){return t===this._key&&e.name!==`AbortError`&&(this._error=e.message),null}finally{t===this._key&&(this._saving=!1)}}_saveFile(e){if(!this._canEdit||this._saving||this._loading)return null;let t=this._editorState(e),n=this._pendingSaves.some(t=>t.change.file===e),r=this._activeReview;return!t.dirty&&!n?r:!t.status&&!t.comment.trim()&&!t.edit?.id&&!n?(this._editors.delete(e),e===this._file&&this._resetEditor(e),r):this._queueSave({action:`save`,reviewId:r?.id??null,revision:t.revision,entryId:t.edit?.id??null,file:e,comment:t.comment,status:this._nonTextFiles.includes(e)?null:t.status||null})}async _saveAll(){let e=this._key;for(;e===this._key&&this._canEdit;){if(this._pendingSaves.length>0){if((await Promise.all(this._pendingSaves.map(e=>e.promise))).some(e=>!e))return!1;continue}let e=this._dirtyFiles;if(e.length===0)return!0;if(!await this._saveFile(e[0]))return!1}return!1}async _beginPublish(){if(!this._canEdit||this._saving||this._loading||this._finalizing||!this._summary.checkedFiles)return;let e=this._key;this._finalizing=!0;try{if(this._unsaved&&!await this._saveAll()||e!==this._key||!this._canEdit||this._unsaved||!this._summary.checkedFiles)return;let t=this._activeReview;if(!t)return;let n=this._allowedVerdicts,r=this._continuation?.source.status;this._finalStatus=n.includes(r)?r:n[0],this._finalComment=t.comment??``,this._publishRevision=t.revision,this._panel=`publish`}finally{this._finalizing=!1}}_publish(){if(this._canPublish)return this._change({action:`publish`,reviewId:this._activeReview.id,revision:this._publishRevision,teamIds:[...this._selectedTeams],finalStatus:this._finalStatus,finalComment:this._finalComment})}render(){if(!this.entry?.npm||!this.details)return B;let e=this.request?.bundle===this.entry.integrity?this.request:{};return this._target=e.reviewPackage?$(e.reviewPackage,e.reviewSpec):`(empty)`,JSON.stringify(e.patch??null)!==JSON.stringify(this._patch)&&(this._patch=e.patch??null),this._basePatch=e.basePatch??null,this._loadBase(this._target,e.resume),Ui(this)}};customElements.define(`npm-review`,qi);var Ji=e=>({view:`npm`,packageName:e.package,packageSpec:e.version,bundleTab:`review`,...e.basePackage===null?{}:{reviewPackage:e.basePackage,reviewSpec:e.baseVersion},...Tt(e.patchHash)&&e.patchSource?{patch:{hash:e.patchHash,...e.patchSource}}:{},...Tt(e.basePatchHash)&&e.basePackage!==null?{basePatch:e.basePatchHash}:{}}),Yi=e=>{let t=new Date(e);return z`<time class="dependency-review-date" datetime="${t.toISOString()}" data-tooltip="${t.toLocaleString()}">${t.toLocaleDateString(void 0,{month:`short`,day:`numeric`,...t.getFullYear()===new Date().getFullYear()?{}:{year:`numeric`}})} <span>${t.toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`})}</span></time>`},Xi=class extends jt{static properties={session:{attribute:!1},team:{attribute:!1},_reviews:{state:!0},_loading:{state:!0},_error:{state:!0},_next:{state:!0},_discarding:{state:!0},_expanded:{state:!0}};constructor(){super(),this._reviews=[],this._next=null,this._expanded=new Set,this._controller=new AbortController}createRenderRoot(){return this}disconnectedCallback(){super.disconnectedCallback(),this._controller.abort(),this._dismissLoading?.(),this._key=null}_canDiscard(e){return e.publishedAt===null&&e.user===this.session?.id&&[`triage`,`manage`,`admin`].includes(this.session?.role)}async _discard(e){if(!this._canDiscard(e)||this._discarding||this._loading)return;let t=this._key,n=this._controller.signal;this._discarding=e.id,this._error=null;try{let{confirmed:r}=await vt({reviewTitle:b(e),signal:n});if(!r||n.aborted||t!==this._key||!this._canDiscard(e)||(await _e(e.id,e.revision,this.session.csrfToken,n),t!==this._key||n.aborted))return;this._reviews=this._reviews.filter(t=>t.id!==e.id)}catch(e){t===this._key&&e.name!==`AbortError`&&(this._error=e.message)}finally{t===this._key&&(this._discarding=null)}}async _load(e=!1){let t=this._key;this._dismissLoading?.();let n=this._dismissLoading=Xe(`Loading reviews…`,{duration:0});this._loading=!0,this._error=null;try{let n=e?this._next:null,{reviews:r,next:i}=await(this.team?ge(this.team,n,this._controller.signal):he(n,this._controller.signal));if(t!==this._key)return;this._reviews=[...new Map([...e?this._reviews:[],...r].map(e=>[e.id,e])).values()],this._next=i}catch(e){t===this._key&&e.name!==`AbortError`&&(this._error=e.message)}finally{n(),t===this._key&&(this._loading=!1)}}_toggleDetails(e){let t=new Set(this._expanded);t.has(e)?t.delete(e):t.add(e),this._expanded=t}_details(e){let t=e.entries.filter(e=>e.status);return z`<section id="${`review-details-${e.id}`}" class="dependency-review-details" aria-label="${`Details for ${b(e)}`}">${e.comment?z`<div class="dependency-review-final-note" role="note" aria-label="Final note">${f(e.comment)}</div>`:B} ${t.length>0?z`<ul class="dependency-review-entries">${t.map(e=>z`<li><span class="dependency-review-entry-file">${ht(e.file)}<span>${e.file}</span></span> ${ot(e.status)}<div>${f(e.comment)}</div></li>`)}</ul>`:z`<p class="npm-review-muted">No file reviews yet.</p>`}</section>`}_row(e){let t=Ji(e),n=this._expanded.has(e.id),r=e.publishedAt!==null,i=new Set(e.entries.filter(e=>e.status).map(e=>e.file)).size,a=e.entries.filter(e=>e.status&&e.comment.trim()).length+ +!!e.comment.trim(),o=e.teams.filter(e=>e.id!==this.team).map(e=>e.name).join(`, `),s=o&&this.team?`also ${o}`:o,c=n=>{n.button!==0||n.metaKey||n.ctrlKey||n.shiftKey||n.altKey||!Re?.active||(n.preventDefault(),g(e),Re.navigate(t))};return z`<li class="${`dependency-review-row${n?` is-expanded`:``}${e.revokedAt===null?``:` is-revoked`}`}"><div class="dependency-review-row-main"><a class="dependency-review-title" href="${Dt(t)}" @click="${c}">${gt(e.ecosystem)} ${e.basePackage!==null&&e.basePackage!==e.package?z`<span>${e.basePackage} ${e.baseVersion} →</span>`:B} <strong>${e.package}</strong> <span>${e.basePackage===e.package?`${e.baseVersion} \u2192 `:``}${e.version}${e.patchHash?z`<span class="dependency-review-patched">patch:${e.patchHash}</span>`:B}</span></a> <span class="dependency-review-result">${r?ot(e.status):z`<span class="dependency-review-checked">${i} ${i===1?`file`:`files`} checked</span>`}</span> <button type="button" class="dependency-review-coverage" aria-expanded="${n}" aria-controls="${`review-details-${e.id}`}" data-tooltip="${r?`${e.checkedFiles} of ${e.totalFiles} files checked`:B}" @click="${()=>this._toggleDetails(e.id)}">${r?z`${e.coverage===`full`?`Full`:z`<span class="dependency-review-partial">Partial</span>`} · ${e.checkedFiles}/${e.totalFiles}`:a?`${a} ${a===1?`note`:`notes`}`:`No notes`}</button> ${this.team?z`<span class="dependency-review-author">${ut(e)}</span>`:B} <span class="dependency-review-meta">${r&&s?z`<span class="dependency-review-teams" data-tooltip-truncated data-tooltip="${s}">${s}</span>`:B} ${r&&a>0?z`<span class="dependency-review-note-count">${a} ${a===1?`note`:`notes`}</span>`:B} ${e.revokedAt===null?B:ct(e)}</span> ${Yi(e.publishedAt??e.time)}<div class="dependency-review-row-actions">${this.team?B:z`<dependency-review-copy .text="${e.formatted}"></dependency-review-copy>`} ${this._canDiscard(e)?z`<button type="button" class="dependency-review-discard" aria-label="Discard review" ?disabled="${this._loading||!!this._discarding}" @click="${()=>this._discard(e)}">${At(kt)}</button>`:B} <a class="dependency-review-open" href="${Dt(t)}" @click="${c}" aria-label="${`${r?`Open`:`Continue`} review for ${b(e)}`}"><span aria-hidden="true">→</span></a></div></div>${n?this._details(e):B}</li>`}render(){let e=JSON.stringify([this.session?.id,this.session?.role,this.team??null]);return e!==this._key&&(this._controller.abort(),this._controller=new AbortController,this._key=e,this._reviews=[],this._next=null,this._discarding=null,this._expanded=new Set,this._load()),this.team?z`<section class="dependency-review-list is-team">${this._error?z`<p role="alert">${this._error}</p>`:B} ${!this._loading&&!this._error&&this._reviews.length===0?z`<p class="npm-review-muted">No reviews are published to this team yet.</p>`:B}<ol>${this._reviews.map(e=>this._row(e))}</ol>${this._next?z`<button type="button" class="npm-review-button" ?disabled="${this._loading}" @click="${()=>this._load(!0)}">Load more</button>`:B}</section>`:z`<section class="dependency-review-list"><header><h1>My reviews</h1></header><p>Your private work and the reviews you’ve shared with teams.</p>${this._error?z`<p role="alert">${this._error}</p>`:B} ${!this._loading&&!this._error&&this._reviews.length===0?z`<p>No reviews yet. Open a package’s Review tab to begin.</p>`:B} ${[[`Drafts`,!1],[`Published reviews`,!0]].map(([e,t])=>{let n=this._reviews.filter(e=>e.publishedAt!==null===t);return z`<section class="dependency-review-section"><h2>${e}<span class="npm-review-count">${n.length}</span></h2><ol>${n.map(e=>this._row(e))}</ol>${n.length===0&&!this._loading?z`<p class="npm-review-muted">${t?`No published reviews yet.`:`No drafts.`}</p>`:B}</section>`})} ${this._next?z`<button type="button" class="npm-review-button" ?disabled="${this._loading||!!this._discarding}" @click="${()=>this._load(!0)}">Load more</button>`:B}</section>`}};customElements.define(`dependency-review-list`,Xi);
|
|
32
30
|
/*! Bundled license information:
|
|
33
31
|
|
|
34
32
|
lit-html/static.js:
|