@preventive/triage 1.0.0-alpha.87 → 1.0.0-alpha.89

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/compare.js CHANGED
@@ -1,26 +1,26 @@
1
- import{a as e}from"./chunk-RAM3GDAD.js";import"./chunk-R3NZFXVR.js";import{$c as t,$d as n,$f as r,Ad as i,Ae as a,Af as o,Bd as s,Be as c,Cd as l,Cg as u,Dd as d,Df as f,Dg as p,Ed as m,Ef as h,Fa as g,Fd as _,Ff as v,Ga as y,Gc as b,Gd as x,Ha as S,Hc as C,Hd as w,Ia as T,Ic as E,Id as D,Ie as ee,Ja as te,Jc as ne,Jd as re,Je as ie,Ka as ae,Kc as oe,Kd as se,Ke as ce,La as le,Lc as ue,Ld as de,Le as fe,Ma as pe,Md as me,Me as he,Nd as ge,Ne as _e,Od as ve,Pd as ye,Pe as be,Qd as xe,Rd as Se,Sd as Ce,Tc as we,Td as Te,Uc as O,Ud as Ee,Vc as De,Vd as Oe,Wd as ke,Zc as Ae,_c as je,ad as Me,ae as Ne,ag as Pe,bd as Fe,be as Ie,bg as Le,cd as Re,ce as ze,cg as Be,dc as Ve,dd as He,dg as Ue,ec as We,ed as Ge,eg as Ke,fc as qe,fd as Je,fg as Ye,gc as Xe,gd as Ze,gg as Qe,ha as k,hd as $e,hg as et,id as tt,ig as nt,jc as rt,jg as it,kc as at,kf as ot,kg as st,ld as ct,lf as lt,lg as ut,md as dt,mg as A,nd as j,ng as M,od as N,og as ft,pd as pt,pg as mt,qd as ht,qg as P,rd as gt,sd as _t,td as vt,u as F,ud as yt,uf as bt,vd as xt,wa as St,wd as Ct,xa as wt,xd as Tt,xe as Et,ya as Dt,yd as Ot,ye as kt,yf as At,za as jt,zd as Mt,ze as Nt,zf as Pt}from"./chunk-5LY6QSPD.js";import"./chunk-A4BBBHQU.js";import{a as Ft,b as It,i as Lt,j as Rt,m as zt,n as Bt}from"./chunk-3YPZ7UBC.js";import"./chunk-VYYUMYVW.js";import"./chunk-7HP2VYIC.js";import{f as Vt}from"./chunk-N57OWFKY.js";import"./chunk-7YFJUT2P.js";import"./chunk-PXK7EU4V.js";import"./chunk-XRAAYXPR.js";import{Ba as Ht,L as Ut,Na as Wt,Pa as Gt,Sa as Kt,rb as qt,sb as Jt,tb as Yt,wa as I,wb as Xt,xa as Zt,ya as Qt,za as $t}from"./chunk-ZPIUN4FW.js";import{a as en,k as tn,l as L,m as R}from"./chunk-KP2XM324.js";import{b as nn}from"./chunk-DUASGS2O.js";import"./chunk-NRPC74AM.js";import"./chunk-7BKKYVWR.js";import"./chunk-7C7DWL7I.js";import"./chunk-PNHBZGDD.js";import{Ga as rn,K as z,L as an,a as B}from"./chunk-3TJCEPHF.js";import"./chunk-TKPNRQNN.js";import{e as on}from"./chunk-74JZTGTO.js";import{e as sn}from"./chunk-IYPY47MC.js";import{d as cn}from"./chunk-G5JKKNZF.js";import{a as V,d as H}from"./chunk-PWFUOLZK.js";import"./chunk-C4Z6ZBXV.js";import{k as ln,n as un,p as dn,s as fn}from"./chunk-BZJU5EEV.js";import{a as pn}from"./chunk-QRKFPLA4.js";import{c as U,g as W,j as G}from"./chunk-2XUEZHIP.js";import"./chunk-TUII34K2.js";import"./chunk-OOJM4CTU.js";var mn=e=>e.toLocaleString(),hn=(e,t)=>`${e===0?`±`:e>0?`+`:`−`}${t(Math.abs(e))}`,gn=e=>hn(e,mn),_n=e=>hn(e,z);function vn(e){return e>0?`up`:e<0?`down`:``}function yn({onlyBase:e,onlyOther:t,changed:n}){return[[`removed`,`−`,e],[`added`,`+`,t],[`repointed`,``,n]].filter(([,,e])=>e.length>0).map(([e,t,n])=>U`<span class="${`bundle-compare-chip ${e===`repointed`?`changed`:e}`}">${t}${n.length.toLocaleString()} ${e} ${n.length===1?`resolution`:`resolutions`}</span>`)}function bn(e,t){if(!t)return``;let n=e/t*100;return`${n>0?`+`:n<0?`−`:`±`}${Math.abs(n).toFixed(1)}%`}var xn=(e,t,n,r,i=mn,a=gn(r))=>U`<div class="bundle-compare-metric"><span class="bundle-compare-metric-label">${e}</span> <span class="bundle-compare-metric-value">${i(t)} → ${i(n)}</span> <span class="${`bundle-compare-metric-delta ${vn(r)}`}">${a}</span></div>`;function Sn(e){let t=e.totals,n=e.versionUpdates?.totals??{baseDeps:0,otherDeps:0},r=bn(t.byteDelta,t.baseBytes);return U`<div class="bundle-compare-stats">${n.baseDeps>0||n.otherDeps>0?xn(`Deps`,n.baseDeps,n.otherDeps,n.otherDeps-n.baseDeps):W} ${xn(`Size`,t.baseBytes,t.otherBytes,t.byteDelta,z,U`${_n(t.byteDelta)}${r?U`${` `}<span class="bundle-compare-pct">(${r})</span>`:W}`)} ${t.baseLines>0||t.otherLines>0?xn(`LoC`,t.baseLines,t.otherLines,t.otherLines-t.baseLines):W}<div class="bundle-compare-files">${xn(`Files`,t.baseFiles,t.otherFiles,t.fileDelta)}<div class="bundle-compare-chips">${t.onlyBaseFiles>0?U`<span class="bundle-compare-chip removed">−${t.onlyBaseFiles.toLocaleString()} removed</span>`:W} ${t.onlyOtherFiles>0?U`<span class="bundle-compare-chip added">+${t.onlyOtherFiles.toLocaleString()} added</span>`:W} ${t.changedFiles>0?U`<span class="bundle-compare-chip changed">${t.changedFiles.toLocaleString()} changed${t.renamedFiles>0?` (${t.renamedFiles.toLocaleString()} renamed)`:``}</span>`:W} <span class="bundle-compare-chip unchanged">${t.unchangedFiles.toLocaleString()} unchanged</span> ${e.resolutions?yn(e.resolutions):W}</div></div></div>`}var Cn=24;function K(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 wn(e){if(!e)return W;let t=({name:e=``,detail:t=``,detailNote:n=null}={})=>e.length+Math.min(t.length,Cn)*.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 V({"--compare-select-chars":`${Math.ceil(n)}`})}function Tn({source:e,label:t=`Compare`,from:n,to:r,clear:i,swap:a,extras:o=W,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):U`<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 U`<div class="${e?`bundle-compare-picker is-versions`:`bundle-compare-picker`}" style="${wn(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?U`<button type="button" class="bundle-compare-clear" aria-label="${i.label??`Clear comparison`}" ?disabled="${c}" @click="${i.run}">×</button>`:W}</div><span class="bundle-compare-arrow" aria-hidden="true">→</span><div class="bundle-compare-select-wrap">${f(r,`${d} to compare`)} ${a?U`<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>`:W}</div>${o}${s?e?.badges?.(s.base,s.other,s.files)??W:W}</div>`}function En(e,t=W){return U`<div class="bundle-compare-summary">${Sn(e)}${t}</div>`}function Dn(e,t=W){return U`<header class="bundle-compare-head">${e}${t}</header>`}var On=4,kn=e=>e?.integrity===`(empty)`,An=new Map,jn=e=>e.state.status!==`loading`;function Mn(e){e.notify?.();for(let t of e.waiting.splice(0))t()}var Nn=null,Pn=(e,t)=>!!(e.managedId&&t.managedId)||!(!t.npm&&!t.npmPatch||!e.npm&&!kn(e));function Fn(e,t,n){if(e.managedId&&t.managedId)return Dt(e.managedId,t.managedId,{scope:n});if(Pn(e,t)){let{name:n,version:r,patch:i}=t.npm??t.npmPatch;return jt(n,r,e.npm?.version??`(empty)`,{otherName:e.npm?.name??n,...i?{patch:i}:{},...e.npmPatch?{otherPatch:e.npmPatch.patch}:{}})}return import(`./chunk-7PXMWWTQ.js`).then(r=>(Nn=r,r.prepareComparison(e,t,n)))}async function In(e,t,n,r,i){let a;try{a={status:`ready`,diff:await Fn(n,r,i)}}catch(n){if(x(n)){An.get(e)===t&&An.delete(e),Mn(t);return}if(a={status:`error`,message:n?.message??String(n)},d(n?.status)){let e=m(t.failures);Object.assign(t,{retryAt:Date.now()+e,failures:t.failures+1}),_(e,()=>{t.notify?.()})}}a.status===`ready`&&(t.failures=0),t.state=a,Mn(t),w(An,On,jn)}var Ln=new WeakMap,Rn=0,zn=e=>(Ln.has(e)||Ln.set(e,++Rn),Ln.get(e));function Bn(e,t,n,r=!1){let i=Pn(e,t)?`${e.integrity}\0${t.integrity}\0${n??``}`:`${zn(e)}\0${zn(t)}\0${n??``}\0here`;return D(An,i,On,jn,r=>{let a={state:{status:`loading`},notify:r?.notify??null,waiting:[],failures:r?.failures??0};return Nn&&!Pn(e,t)?a.state={status:`ready`,diff:Nn.prepareComparison(e,t,n??``)}:In(i,a,e,t,n??``),a},e=>!e||r&&e.state.status===`error`||e.retryAt!==void 0&&Date.now()>=e.retryAt)}function Vn(e,t,n,r){let i=Bn(e,t,n);return i.notify=se(r),i.state}function Hn(e,t,n=null){return new Promise((r,i)=>{let a=(o=!1)=>{let s=Bn(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 Un(e,t){let{head:n,from:r,to:i,tail:a}=Rt(e,t);return U`${n}{<span class="bundle-compare-rename-from">${r}</span> → <span class="bundle-compare-rename-to">${i}</span>}${a}`}var q=(e,t)=>t&&e.startsWith(t)?e.slice(t.length):e;function Wn({from:e,to:t}){return U`<span class="bundle-compare-rename-from">${e}</span> → <span class="bundle-compare-rename-to">${t}</span>`}function Gn(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 J(e,t,n,{kind:r,basePath:i=n}){let a=r===`added`?``:L(e).get(i),o=r===`removed`?``:L(t).get(n);return r===`repointed`&&(a=o??=a),{before:a,after:o}}var Kn=new WeakMap,qn=Object.freeze([]);function Jn(e){if(!e)return qn;let t=Kn.get(e);return t||Kn.set(e,t=[...e.onlyBase,...e.onlyOther,...e.changed]),t}function Yn(e){return e.baseTarget===null?`added`:e.otherTarget===null?`removed`:`repointed`}function Xn(e,t,n,r=[]){let i=Gn(n);if(!n)return i;for(let n of r){if(!i.has(n.parent)){let r=R(L(t).get(n.parent)??L(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 Zn(e,t,n){return[...Xn(e,t,n.files,Jn(n.resolutions))].map(([n,r])=>({path:n,...r,...J(e,t,n,r)}))}function Qn(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+=R(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=new Set([`module`,`commonjs`,`module-typescript`,`commonjs-typescript`,`json`,`xml`,`php`,`shell`,`gradle`,`cmake`,`solidity`,`rust`,`java`,`kotlin`,`objc`,`objcpp`,`swift`,`c`,`cpp`,`c-header`,`cpp-header`,`pbxproj`]),er=/\.(?:[cm]?js|jsx|[cm]?ts|tsx|json5?|jsonc|css|scss|less|html?|xhtml|xml|svg|php|sh|bash|zsh|c|h|cc|cpp|cxx|hh|hpp|hxx|java|kts?|go|rs|cs|swift)$/u,tr=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 nr(e,t=``,n=void 0){return typeof n==`string`?$n.has(n):er.test(e.toLowerCase())||typeof t==`string`&&tr.has(t.split(`
3
- `,1)[0])}var rr=3,ir=20,ar=4;function or(e,t,{ignoreWhitespace:n=!1,changes:r=null,marks:i=null}={}){let a=j(e),o=j(t),s=r?.blocks??N(e,t,n),c={a:e!==``&&!e.endsWith(`
1
+ import{a as e}from"./chunk-RAM3GDAD.js";import"./chunk-R3NZFXVR.js";import{$c as t,$d as n,Ad as r,Bd as i,Cd as a,Ce as o,Dd as s,De as c,Df as l,Ed as u,Ee as d,Ef as f,Fa as p,Fd as m,Fe as h,Ff as g,Ga as _,Gc as v,Gd as y,Ge as b,Ha as x,Hc as S,Hd as C,Hg as w,Ia as T,Ic as E,Id as D,If as ee,Ig as te,Ja as ne,Jc as O,Jd as re,Jf as ie,Ka as ae,Kc as oe,Kd as se,Kf as ce,La as le,Lc as ue,Ld as de,Ma as fe,Md as pe,Nd as me,Ne as he,Od as ge,Oe as _e,Pd as ve,Pe as ye,Qd as be,Qe as xe,Rd as Se,Re as Ce,Sd as we,Se as Te,Tc as Ee,Td as De,Uc as k,Ud as Oe,Ue as ke,Vc as Ae,Vd as je,Wd as Me,Xd as Ne,Yd as Pe,Zc as Fe,Zd as Ie,_c as Le,_d as Re,ad as ze,bd as Be,cd as Ve,dc as He,dd as Ue,ec as We,ed as Ge,ee as Ke,eg as qe,fc as Je,fd as Ye,fe as Xe,fg as Ze,gc as Qe,gd as $e,ge as et,gg as tt,ha as A,hd as nt,he as rt,hg as it,id as at,ig as ot,jc as st,jg as ct,kc as lt,kg as ut,ld as dt,lg as ft,md as pt,mg as mt,nd as ht,ng as gt,od as _t,og as vt,pd as yt,pf as bt,pg as xt,qd as j,qf as St,qg as Ct,rd as wt,rg as Tt,sd as Et,sg as M,td as Dt,tg as Ot,u as N,ud as kt,ug as At,vd as jt,vg as P,wa as Mt,wd as Nt,xa as Pt,xd as Ft,ya as It,yd as F,za as Lt,zd as Rt,zf as zt}from"./chunk-7KUZQB6S.js";import"./chunk-A4BBBHQU.js";import{a as Bt,b as Vt,i as Ht,j as Ut,m as Wt,n as Gt}from"./chunk-WBK5ZN4K.js";import"./chunk-VYYUMYVW.js";import"./chunk-7HP2VYIC.js";import{f as Kt}from"./chunk-N57OWFKY.js";import"./chunk-7YFJUT2P.js";import"./chunk-PXK7EU4V.js";import"./chunk-XRAAYXPR.js";import{Ba as qt,L as Jt,Na as Yt,Pa as Xt,Sa as Zt,rb as Qt,sb as $t,tb as en,wa as I,wb as tn,xa as nn,ya as rn,za as an}from"./chunk-ZPIUN4FW.js";import{a as on,k as sn,l as L,m as R}from"./chunk-KP2XM324.js";import{b as cn}from"./chunk-DUASGS2O.js";import"./chunk-NRPC74AM.js";import"./chunk-7BKKYVWR.js";import"./chunk-7C7DWL7I.js";import"./chunk-PNHBZGDD.js";import{Ga as ln,K as z,L as un,a as B}from"./chunk-3TJCEPHF.js";import"./chunk-TKPNRQNN.js";import{e as dn}from"./chunk-74JZTGTO.js";import{e as fn}from"./chunk-IYPY47MC.js";import{d as pn}from"./chunk-G5JKKNZF.js";import{a as V,d as H}from"./chunk-PWFUOLZK.js";import"./chunk-C4Z6ZBXV.js";import{k as mn,n as hn,p as gn,s as _n}from"./chunk-BZJU5EEV.js";import{a as vn}from"./chunk-QRKFPLA4.js";import{c as U,g as W,j as G}from"./chunk-2XUEZHIP.js";import"./chunk-TUII34K2.js";import"./chunk-OOJM4CTU.js";var yn=e=>e.toLocaleString(),bn=(e,t)=>`${e===0?`±`:e>0?`+`:`−`}${t(Math.abs(e))}`,xn=e=>bn(e,yn),Sn=e=>bn(e,z);function Cn(e){return e>0?`up`:e<0?`down`:``}function wn({onlyBase:e,onlyOther:t,changed:n}){return[[`removed`,`−`,e],[`added`,`+`,t],[`repointed`,``,n]].filter(([,,e])=>e.length>0).map(([e,t,n])=>U`<span class="${`bundle-compare-chip ${e===`repointed`?`changed`:e}`}">${t}${n.length.toLocaleString()} ${e} ${n.length===1?`resolution`:`resolutions`}</span>`)}function Tn(e,t){if(!t)return``;let n=e/t*100;return`${n>0?`+`:n<0?`−`:`±`}${Math.abs(n).toFixed(1)}%`}var En=(e,t,n,r,i=yn,a=xn(r))=>U`<div class="bundle-compare-metric"><span class="bundle-compare-metric-label">${e}</span> <span class="bundle-compare-metric-value">${i(t)} → ${i(n)}</span> <span class="${`bundle-compare-metric-delta ${Cn(r)}`}">${a}</span></div>`;function Dn(e){let t=e.totals,n=e.versionUpdates?.totals??{baseDeps:0,otherDeps:0},r=Tn(t.byteDelta,t.baseBytes);return U`<div class="bundle-compare-stats">${n.baseDeps>0||n.otherDeps>0?En(`Deps`,n.baseDeps,n.otherDeps,n.otherDeps-n.baseDeps):W} ${En(`Size`,t.baseBytes,t.otherBytes,t.byteDelta,z,U`${Sn(t.byteDelta)}${r?U`${` `}<span class="bundle-compare-pct">(${r})</span>`:W}`)} ${t.baseLines>0||t.otherLines>0?En(`LoC`,t.baseLines,t.otherLines,t.otherLines-t.baseLines):W}<div class="bundle-compare-files">${En(`Files`,t.baseFiles,t.otherFiles,t.fileDelta)}<div class="bundle-compare-chips">${t.onlyBaseFiles>0?U`<span class="bundle-compare-chip removed">−${t.onlyBaseFiles.toLocaleString()} removed</span>`:W} ${t.onlyOtherFiles>0?U`<span class="bundle-compare-chip added">+${t.onlyOtherFiles.toLocaleString()} added</span>`:W} ${t.changedFiles>0?U`<span class="bundle-compare-chip changed">${t.changedFiles.toLocaleString()} changed${t.renamedFiles>0?` (${t.renamedFiles.toLocaleString()} renamed)`:``}</span>`:W} <span class="bundle-compare-chip unchanged">${t.unchangedFiles.toLocaleString()} unchanged</span> ${e.resolutions?wn(e.resolutions):W}</div></div></div>`}var On=24;function K(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 kn(e){if(!e)return W;let t=({name:e=``,detail:t=``,detailNote:n=null}={})=>e.length+Math.min(t.length,On)*.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 V({"--compare-select-chars":`${Math.ceil(n)}`})}function An({source:e,label:t=`Compare`,from:n,to:r,clear:i,swap:a,extras:o=W,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):U`<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 U`<div class="${e?`bundle-compare-picker is-versions`:`bundle-compare-picker`}" style="${kn(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?U`<button type="button" class="bundle-compare-clear" aria-label="${i.label??`Clear comparison`}" ?disabled="${c}" @click="${i.run}">×</button>`:W}</div><span class="bundle-compare-arrow" aria-hidden="true">→</span><div class="bundle-compare-select-wrap">${f(r,`${d} to compare`)} ${a?U`<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>`:W}</div>${o}${s?e?.badges?.(s.base,s.other,s.files)??W:W}</div>`}function jn(e,t=W){return U`<div class="bundle-compare-summary">${Dn(e)}${t}</div>`}function Mn(e,t=W){return U`<header class="bundle-compare-head">${e}${t}</header>`}var Nn=4,Pn=e=>e?.integrity===`(empty)`,Fn=new Map,In=e=>e.state.status!==`loading`;function Ln(e){e.notify?.();for(let t of e.waiting.splice(0))t()}var Rn=null,zn=(e,t)=>!!(e.managedId&&t.managedId)||!(!t.npm&&!t.npmPatch||!e.npm&&!Pn(e));function Bn(e,t,n){if(e.managedId&&t.managedId)return It(e.managedId,t.managedId,{scope:n});if(zn(e,t)){let{name:n,version:r,patch:i}=t.npm??t.npmPatch;return Lt(n,r,e.npm?.version??`(empty)`,{otherName:e.npm?.name??n,...i?{patch:i}:{},...e.npmPatch?{otherPatch:e.npmPatch.patch}:{}})}return import(`./chunk-5PWEAEA5.js`).then(r=>(Rn=r,r.prepareComparison(e,t,n)))}async function Vn(e,t,n,r,i){let a;try{a={status:`ready`,diff:await Bn(n,r,i)}}catch(n){if(se(n)){Fn.get(e)===t&&Fn.delete(e),Ln(t);return}if(a={status:`error`,message:n?.message??String(n)},C(n?.status)){let e=D(t.failures);Object.assign(t,{retryAt:Date.now()+e,failures:t.failures+1}),re(e,()=>{t.notify?.()})}}a.status===`ready`&&(t.failures=0),t.state=a,Ln(t),de(Fn,Nn,In)}var Hn=new WeakMap,Un=0,Wn=e=>(Hn.has(e)||Hn.set(e,++Un),Hn.get(e));function Gn(e,t,n,r=!1){let i=zn(e,t)?`${e.integrity}\0${t.integrity}\0${n??``}`:`${Wn(e)}\0${Wn(t)}\0${n??``}\0here`;return pe(Fn,i,Nn,In,r=>{let a={state:{status:`loading`},notify:r?.notify??null,waiting:[],failures:r?.failures??0};return Rn&&!zn(e,t)?a.state={status:`ready`,diff:Rn.prepareComparison(e,t,n??``)}:Vn(i,a,e,t,n??``),a},e=>!e||r&&e.state.status===`error`||e.retryAt!==void 0&&Date.now()>=e.retryAt)}function Kn(e,t,n,r){let i=Gn(e,t,n);return i.notify=ge(r),i.state}function qn(e,t,n=null){return new Promise((r,i)=>{let a=(o=!1)=>{let s=Gn(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 Jn(e,t){let{head:n,from:r,to:i,tail:a}=Ut(e,t);return U`${n}{<span class="bundle-compare-rename-from">${r}</span> → <span class="bundle-compare-rename-to">${i}</span>}${a}`}var q=(e,t)=>t&&e.startsWith(t)?e.slice(t.length):e;function Yn({from:e,to:t}){return U`<span class="bundle-compare-rename-from">${e}</span> → <span class="bundle-compare-rename-to">${t}</span>`}function Xn(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 J(e,t,n,{kind:r,basePath:i=n}){let a=r===`added`?``:L(e).get(i),o=r===`removed`?``:L(t).get(n);return r===`repointed`&&(a=o??=a),{before:a,after:o}}var Zn=new WeakMap,Qn=Object.freeze([]);function $n(e){if(!e)return Qn;let t=Zn.get(e);return t||Zn.set(e,t=[...e.onlyBase,...e.onlyOther,...e.changed]),t}function er(e){return e.baseTarget===null?`added`:e.otherTarget===null?`removed`:`repointed`}function tr(e,t,n,r=[]){let i=Xn(n);if(!n)return i;for(let n of r){if(!i.has(n.parent)){let r=R(L(t).get(n.parent)??L(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 nr(e,t,n){return[...tr(e,t,n.files,$n(n.resolutions))].map(([n,r])=>({path:n,...r,...J(e,t,n,r)}))}function rr(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+=R(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 ir=new Set([`module`,`commonjs`,`module-typescript`,`commonjs-typescript`,`json`,`xml`,`php`,`shell`,`gradle`,`cmake`,`solidity`,`rust`,`java`,`kotlin`,`objc`,`objcpp`,`swift`,`c`,`cpp`,`c-header`,`cpp-header`,`pbxproj`]),ar=/\.(?:[cm]?js|jsx|[cm]?ts|tsx|json5?|jsonc|css|scss|less|html?|xhtml|xml|svg|php|sh|bash|zsh|c|h|cc|cpp|cxx|hh|hpp|hxx|java|kts?|go|rs|cs|swift)$/u,or=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 sr(e,t=``,n=void 0){return typeof n==`string`?ir.has(n):ar.test(e.toLowerCase())||typeof t==`string`&&or.has(t.split(`
3
+ `,1)[0])}var cr=3,lr=20,ur=4;function dr(e,t,{ignoreWhitespace:n=!1,changes:r=null,marks:i=null}={}){let a=j(e),o=j(t),s=r?.blocks??wt(e,t,n),c={a:e!==``&&!e.endsWith(`
4
4
  `),b:t!==``&&!t.endsWith(`
5
- `)};return{a,b:o,blocks:s,..._t(s,i),noEol:c,words:new Map}}function sr(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 cr=2e6,lr=2e4,ur=e=>{let t=+(e!==``&&!e.endsWith(`
5
+ `)};return{a,b:o,blocks:s,...Nt(s,i),noEol:c,words:new Map}}function fr(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 pr=2e6,mr=2e4,hr=e=>{let t=+(e!==``&&!e.endsWith(`
6
6
  `));for(let n=e.indexOf(`
7
7
  `);n!==-1;n=e.indexOf(`
8
- `,n+1))t++;return t};function dr(e,t){if(typeof e!=`string`||typeof t!=`string`)return null;if(e===t)return{additions:0,deletions:0};if(e===``)return{additions:ur(t),deletions:0};if(t===``)return{additions:0,deletions:ur(e)};if(e.length+t.length>cr||ur(e)+ur(t)>lr)return null;let n=0,r=0;for(let{a0:i,a1:a,b0:o,b1:s}of N(e,t))n+=s-o,r+=a-i;return{additions:n,deletions:r}}var fr=(e,t,n)=>!xt(e,t,n);function pr(e,t){let n=N(e,t,`leading`),r=fr(e,t,n);return{hides:r,mixed:r&&Lt(e,t,n)}}function mr(e,t=new Map,{context:n=e.typeFolds?1/0:rr,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<ar)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 _=br(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?sr(o,e.typeFolds):o}var hr=2e3,gr=(e,t)=>e.length>hr||t.length>hr;function _r(e,t){let n=Math.min(e.length,t.length),r=0,i=0;for(;r<n&&e[r]===t[r];)r++;for(r>0&&/[\uDC00-\uDFFF]/u.test(e[r]??t[r]??``)&&r--;i<n-r&&e[e.length-1-i]===t[t.length-1-i];)i++;i>0&&/[\uDC00-\uDFFF]/u.test(e[e.length-i])&&i--;let a=e=>r<e.length-i?[[r,e.length-i]]:[];return{a:a(e),b:a(t)}}var vr=(e,t)=>Ft(e,t)??(gr(e,t)?_r(e,t):null);function yr(e,t,n){let r=It(e.slice(n.a0,n.a1),t.slice(n.b0,n.b1)).map(([e,t])=>[n.a0+e,n.b0+t]),i=[],a=n.a0,o=n.b0;for(let[s,c]of[...r,[n.a1,n.b1]]){for(;a<s||o<c;){let n=a<s?a++:null,r=o<c?o++:null;i.push([n,r,n!==null&&r!==null&&gr(e[n],t[r])])}s<n.a1&&(i.push([s,c,!0]),a=s+1,o=c+1)}return i}function br(e,t){return e.aligned??=new Map,e.aligned.has(t)||e.aligned.set(t,yr(e.a,e.b,e.blocks[t])),e.aligned.get(t)}function xr(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 Sr(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 Cr=100,wr=20;function Tr(e,t,n=wr,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 Er=(e,t,n,r)=>yr(e,t,r);function Dr(e,t,n,r,{split:i=!1,align:a=Er}={}){return e===t?Tr(j(t),n).map(e=>({...e,side:`b`,sign:` `})):e===``?Tr(j(t),n).map(e=>({...e,side:`b`,sign:`+`})):t===``?Tr(j(e),n).map(e=>({...e,side:`a`,sign:`−`})):Or(j(e),j(t),n,r,i,a)}function Or(e,t,n,r,i,a){let o=Tr(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===wr)break;c.push(...Tr(e,n,wr-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,wr)}function kr(e,t,n,{split:r=!1,align:i=Er}={}){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=l!==u&&l!==``&&u!==``?n(c,l,u):null;if(e?.length===0)continue;let d=Dr(l,u,t,e,{split:r,align:i});if(d.length!==0){if(a.length===Cr)return{files:a,hits:o,truncated:!0};a.push({path:c,hits:d}),o+=d.length}}return{files:a,hits:o,truncated:!1}}var Ar=2,jr=new Set([`ts`,`mts`,`cts`]),Mr=e=>e!==501&&d(e),Nr=e=>e?.integrity===`(empty)`,Pr=(e,t)=>de(e,t)||Nr(e)&&!!t?.npm,Fr=(e,t)=>`${e??``}\0${t??``}`,Y=new Map,Ir=re();async function Lr(e,t,n){if(t===null)return n===null;let r=typeof t==`string`?L(e).get(t):void 0;return typeof r==`string`&&n===await(e.fileHashes?.get(t)??pn(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 zr(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 Lr(n,e,t)&&await Lr(r,i,a)&&o.set(Fr(e,i),l)};await(n.npm?wt(n.npm.name,n.npm.version,r.npm.version,e):Nr(n)?wt(r.npm.name,r.npm.version,`(empty)`,e):St(n.managedId,r.managedId,e,{scope:i}))}catch(n){if(x(n)){Y.get(e)===t&&Y.delete(e);return}a=Mr(n?.status)}Object.assign(t,{files:o,ended:!0}),Ir(e,a,()=>Y.get(e)===t&&Y.delete(e),()=>t.notify),t.notify?.(),w(Y,Ar,e=>e.ended)}function Br(e,t,n,{kind:r,basePath:i=n},{before:a,after:o},s,c=``){if(r===`repointed`||!Pr(e,t))return;let l=[r===`added`?null:i,r===`removed`?null:n];if(!l.every(e=>e===null||jr.has(dt(e)))||l[0]!==null&&a!==L(e).get(i)||l[1]!==null&&o!==L(t).get(n))return;let u=`${e.integrity}\0${t.integrity}\0${c}`,d=D(Y,u,Ar,e=>e.ended,()=>{let n={files:new Map,notify:null,ended:!1};return zr(u,n,e,t,c),n});return d.notify=se(s),d.files.get(Fr(...l))}function Vr(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]=[nn.isResourceFormat(e),nn.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 Hr(e=[],t=!1){return e.map(({field:e,from:n,to:r})=>e===`format`?U`<span class="bundle-compare-code-meta">${t?`format`:`${n??`none`} \u2192 ${r??`none`}`}</span>`:U`<span class="${`bundle-compare-code-meta${r?``:` is-dropped`}`}">${e===`executable`?r?`+x`:`−x`:r?`new entry`:`entry`}</span>`)}var Ur=(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 Wr(e=[]){return e.map(({field:e,from:t,to:n})=>e===`format`?`${Vr(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 Gr=[{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`}],Kr=Object.fromEntries(Gr.map(e=>[e.kind,e])),X=2e3,qr=24,Jr=3,Yr=300,Xr=30,Zr=[{mode:`files`,label:`Filter files`,placeholder:`Filter changed files`,icon:oe},{mode:`code`,label:`Search code`,placeholder:`Search changed code`,icon:ue}],Qr=ir/2,$r=65536,ei=new WeakSet,ti={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.`},ni={"+":{name:`add`,label:`Added`},"−":{name:`del`,label:`Removed`}," ":{name:`ctx`,label:`Unchanged`}},ri=()=>`${O.ignoreWhitespace}\0${O.ignoreRenames}`,ii=`Hide renamed names`,ai=`Hide type-only changes`,oi=`Hide whitespace changes`,si=e=>`${ct(e)?F.bundleSourcePretty:!!F.bundleSourcePretty}\0${O.ignoreWhitespace}\0${O.ignoreRenames}\0${O.ignoreTypes}`,ci=({pretty:e,spacesHidden:t,hiding:n,typesHidden:r,typesFolded:i})=>[e?.status===`ready`&&`Pretty-print`,t&&oi,n&&ii,(r||i)&&ai].filter(Boolean),li=(e,t)=>({additions:e.additions,deletions:e.deletions,renamed:e.renamed,aside:ci(t)}),ui=`Whitespace changes are shown: hiding them would hide blanks of more than one kind changing.`,di=(e,t)=>e?.kind===`stasis`?e.bundle?.formats?.get(t):void 0,fi=e=>/\.[cm]?js$/iu.test(e),pi=(e,t,n)=>Ot(e,t,n).category===`minified`;function Z(e,t,n,r,i=0){let a=e.get(t);return i&&e.delete(t),a&&a.inputs.length===n.length&&a.inputs.every((e,t)=>e===n[t])||(a={inputs:n,value:r()}),e.set(t,a),i&&e.size>i&&e.delete(e.keys().next().value),a.value}var mi=`A license file`,hi=new WeakMap;function gi(e){let t=hi.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(L(e).keys());for(let e of[`main`,`module`,`types`])typeof r[e]==`string`&&n(Ne(r[e],t),e,`package.json "${e}": ${r[e]}`);for(let[e,i]of Object.entries(r.bin??{}))typeof i==`string`&&n(Ne(i,t),`bin`,`package.json "bin" ${e}: ${i}`);let i=Map.groupBy(typeof r.license==`string`?ze(r.license,[...t]).filter(e=>e.file):[],e=>e.file);for(let e of t)Ie.test(e)&&n(e,`license`,i.has(e)?`License: ${i.get(e).map(e=>e.text).join(`, `)}`:mi)}else for(let t of L(e).keys())Ie.test(t.slice(t.lastIndexOf(`/`)+1))&&n(t,`license`,mi);return hi.set(e,t),t}var _i=/(?:^|\/)package\.json$/u,vi=new WeakMap;function yi(e,t,r){let i=vi.get(e);return i||vi.set(e,i=new Map),i.has(t)||i.set(t,n(r,L(e).has(`${t.slice(0,-12)}binding.gyp`))),i.get(t)}var bi={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`},xi={status:`error`,message:`The server's diff doesn't take this file's old side to its new one as shown.`,retry:!1},Si={module:`as the other side is a module`,minified:`as a minifier renamed them all`},Ci=({reads:e,assumed:t=[]})=>[...e.length>0?[`Renamed names are hidden, though the file reads ${e.map(e=>`.${e}`).join(`, `)}, which a rename may change.`]:[],...t.length>0?[`Renamed names are hidden, though some are names at the top level of a script, taken as its own ${t.map(e=>Si[e]??e).join(` and `)}: run as a classic script, they are globals, which a rename may change.`]:[]],wi=(e,t,n=O)=>`${e}\0${n.ignoreWhitespace}\0${n.ignoreRenames&&fi(e)}\0${!!n.markRenames}\0${t}`,Ti=6,Ei=new Map,Di=new Set,Oi=new WeakMap,ki=new WeakMap,Ai=(e,{before:t,after:n})=>Z(ki,e,[t,n],()=>gt(t,n,e)),ji=(e,t,n)=>(e.typeFolds?.lineOf[t][n]??n)+1;function Mi(e){let t=0;for(let n=e.indexOf(`
8
+ `,n+1))t++;return t};function gr(e,t){if(typeof e!=`string`||typeof t!=`string`)return null;if(e===t)return{additions:0,deletions:0};if(e===``)return{additions:hr(t),deletions:0};if(t===``)return{additions:0,deletions:hr(e)};if(e.length+t.length>pr||hr(e)+hr(t)>mr)return null;let n=0,r=0;for(let{a0:i,a1:a,b0:o,b1:s}of wt(e,t))n+=s-o,r+=a-i;return{additions:n,deletions:r}}var _r=(e,t,n)=>!Rt(e,t,n);function vr(e,t){let n=wt(e,t,`leading`),r=_r(e,t,n);return{hides:r,mixed:r&&Ht(e,t,n)}}function yr(e,t=new Map,{context:n=e.typeFolds?1/0:cr,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<ur)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 _=Tr(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?fr(o,e.typeFolds):o}var br=2e3,xr=(e,t)=>e.length>br||t.length>br;function Sr(e,t){let n=Math.min(e.length,t.length),r=0,i=0;for(;r<n&&e[r]===t[r];)r++;for(r>0&&/[\uDC00-\uDFFF]/u.test(e[r]??t[r]??``)&&r--;i<n-r&&e[e.length-1-i]===t[t.length-1-i];)i++;i>0&&/[\uDC00-\uDFFF]/u.test(e[e.length-i])&&i--;let a=e=>r<e.length-i?[[r,e.length-i]]:[];return{a:a(e),b:a(t)}}var Cr=(e,t)=>Bt(e,t)??(xr(e,t)?Sr(e,t):null);function wr(e,t,n){let r=Vt(e.slice(n.a0,n.a1),t.slice(n.b0,n.b1)).map(([e,t])=>[n.a0+e,n.b0+t]),i=[],a=n.a0,o=n.b0;for(let[s,c]of[...r,[n.a1,n.b1]]){for(;a<s||o<c;){let n=a<s?a++:null,r=o<c?o++:null;i.push([n,r,n!==null&&r!==null&&xr(e[n],t[r])])}s<n.a1&&(i.push([s,c,!0]),a=s+1,o=c+1)}return i}function Tr(e,t){return e.aligned??=new Map,e.aligned.has(t)||e.aligned.set(t,wr(e.a,e.b,e.blocks[t])),e.aligned.get(t)}function Er(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 Dr(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 Or=100,kr=20;function Ar(e,t,n=kr,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 jr=(e,t,n,r)=>wr(e,t,r);function Mr(e,t,n,r,{split:i=!1,align:a=jr}={}){return e===t?Ar(j(t),n).map(e=>({...e,side:`b`,sign:` `})):e===``?Ar(j(t),n).map(e=>({...e,side:`b`,sign:`+`})):t===``?Ar(j(e),n).map(e=>({...e,side:`a`,sign:`−`})):Nr(j(e),j(t),n,r,i,a)}function Nr(e,t,n,r,i,a){let o=Ar(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===kr)break;c.push(...Ar(e,n,kr-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,kr)}function Pr(e,t,n,{split:r=!1,align:i=jr}={}){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=l!==u&&l!==``&&u!==``?n(c,l,u):null;if(e?.length===0)continue;let d=Mr(l,u,t,e,{split:r,align:i});if(d.length!==0){if(a.length===Or)return{files:a,hits:o,truncated:!0};a.push({path:c,hits:d}),o+=d.length}}return{files:a,hits:o,truncated:!1}}var Fr=2,Ir=new Set([`ts`,`mts`,`cts`]),Lr=e=>e!==501&&C(e),Rr=e=>e?.integrity===`(empty)`,zr=(e,t)=>ve(e,t)||Rr(e)&&!!t?.npm,Br=(e,t)=>`${e??``}\0${t??``}`,Y=new Map,Vr=me();async function Hr(e,t,n){if(t===null)return n===null;let r=typeof t==`string`?L(e).get(t):void 0;return typeof r==`string`&&n===await(e.fileHashes?.get(t)??vn(r))}var Ur=(e,t)=>(t||e?.length===0)&&yt(e)!==null;async function Wr(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||Ur(s,e!==null)&&Ur(c,i!==null)&&{runs:s,otherRuns:c};l&&await Hr(n,e,t)&&await Hr(r,i,a)&&o.set(Br(e,i),l)};await(n.npm?Pt(n.npm.name,n.npm.version,r.npm.version,e):Rr(n)?Pt(r.npm.name,r.npm.version,`(empty)`,e):Mt(n.managedId,r.managedId,e,{scope:i}))}catch(n){if(se(n)){Y.get(e)===t&&Y.delete(e);return}a=Lr(n?.status)}Object.assign(t,{files:o,ended:!0}),Vr(e,a,()=>Y.get(e)===t&&Y.delete(e),()=>t.notify),t.notify?.(),de(Y,Fr,e=>e.ended)}function Gr(e,t,n,{kind:r,basePath:i=n},{before:a,after:o},s,c=``){if(r===`repointed`||!zr(e,t))return;let l=[r===`added`?null:i,r===`removed`?null:n];if(!l.every(e=>e===null||Ir.has(_t(e)))||l[0]!==null&&a!==L(e).get(i)||l[1]!==null&&o!==L(t).get(n))return;let u=`${e.integrity}\0${t.integrity}\0${c}`,d=pe(Y,u,Fr,e=>e.ended,()=>{let n={files:new Map,notify:null,ended:!1};return Wr(u,n,e,t,c),n});return d.notify=ge(s),d.files.get(Br(...l))}function Kr(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]=[cn.isResourceFormat(e),cn.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 qr(e=[],t=!1){return e.map(({field:e,from:n,to:r})=>e===`format`?U`<span class="bundle-compare-code-meta">${t?`format`:`${n??`none`} \u2192 ${r??`none`}`}</span>`:U`<span class="${`bundle-compare-code-meta${r?``:` is-dropped`}`}">${e===`executable`?r?`+x`:`−x`:r?`new entry`:`entry`}</span>`)}var Jr=(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 Yr(e=[]){return e.map(({field:e,from:t,to:n})=>e===`format`?`${Kr(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 Xr=[{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`}],Zr=Object.fromEntries(Xr.map(e=>[e.kind,e])),X=2e3,Qr=24,$r=3,ei=300,ti=30,ni=[{mode:`files`,label:`Filter files`,placeholder:`Filter changed files`,icon:oe},{mode:`code`,label:`Search code`,placeholder:`Search changed code`,icon:ue}],ri=lr/2,ii=65536,ai=new WeakSet,oi={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.`},si={"+":{name:`add`,label:`Added`},"−":{name:`del`,label:`Removed`}," ":{name:`ctx`,label:`Unchanged`}},ci=()=>`${k.ignoreWhitespace}\0${k.ignoreRenames}`,li=`Hide renamed names`,ui=`Hide type-only changes`,di=`Hide whitespace changes`,fi=e=>`${dt(e)?N.bundleSourcePretty:!!N.bundleSourcePretty}\0${k.ignoreWhitespace}\0${k.ignoreRenames}\0${k.ignoreTypes}`,pi=({pretty:e,spacesHidden:t,hiding:n,typesHidden:r,typesFolded:i})=>[e?.status===`ready`&&`Pretty-print`,t&&di,n&&li,(r||i)&&ui].filter(Boolean),mi=(e,t)=>({additions:e.additions,deletions:e.deletions,renamed:e.renamed,aside:pi(t)}),hi=`Whitespace changes are shown: hiding them would hide blanks of more than one kind changing.`,gi=(e,t)=>e?.kind===`stasis`?e.bundle?.formats?.get(t):void 0,_i=e=>/\.[cm]?js$/iu.test(e),vi=(e,t,n)=>a(e,t,n).category===`minified`;function Z(e,t,n,r,i=0){let a=e.get(t);return i&&e.delete(t),a&&a.inputs.length===n.length&&a.inputs.every((e,t)=>e===n[t])||(a={inputs:n,value:r()}),e.set(t,a),i&&e.size>i&&e.delete(e.keys().next().value),a.value}var yi=`A license file`,bi=new WeakMap;function xi(e){let t=bi.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(L(e).keys());for(let e of[`main`,`module`,`types`])typeof r[e]==`string`&&n(Xe(r[e],t),e,`package.json "${e}": ${r[e]}`);for(let[e,i]of Object.entries(r.bin??{}))typeof i==`string`&&n(Xe(i,t),`bin`,`package.json "bin" ${e}: ${i}`);let i=Map.groupBy(typeof r.license==`string`?rt(r.license,[...t]).filter(e=>e.file):[],e=>e.file);for(let e of t)et.test(e)&&n(e,`license`,i.has(e)?`License: ${i.get(e).map(e=>e.text).join(`, `)}`:yi)}else for(let t of L(e).keys())et.test(t.slice(t.lastIndexOf(`/`)+1))&&n(t,`license`,yi);return bi.set(e,t),t}var Si=/(?:^|\/)package\.json$/u,Ci=new WeakMap;function wi(e,t,n){let r=Ci.get(e);return r||Ci.set(e,r=new Map),r.has(t)||r.set(t,Ke(n,L(e).has(`${t.slice(0,-12)}binding.gyp`))),r.get(t)}var Ti={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`},Ei={status:`error`,message:`The server's diff doesn't take this file's old side to its new one as shown.`,retry:!1},Di={module:`as the other side is a module`,minified:`as a minifier renamed them all`},Oi=({reads:e,assumed:t=[]})=>[...e.length>0?[`Renamed names are hidden, though the file reads ${e.map(e=>`.${e}`).join(`, `)}, which a rename may change.`]:[],...t.length>0?[`Renamed names are hidden, though some are names at the top level of a script, taken as its own ${t.map(e=>Di[e]??e).join(` and `)}: run as a classic script, they are globals, which a rename may change.`]:[]],ki=(e,t,n=k)=>`${e}\0${n.ignoreWhitespace}\0${n.ignoreRenames&&_i(e)}\0${!!n.markRenames}\0${t}`,Ai=6,ji=new Map,Mi=new Set,Ni=new WeakMap,Pi=new WeakMap,Fi=(e,{before:t,after:n})=>Z(Pi,e,[t,n],()=>kt(t,n,e)),Ii=(e,t,n)=>(e.typeFolds?.lineOf[t][n]??n)+1;function Li(e){let t=0;for(let n=e.indexOf(`
9
9
  `);n!==-1;n=e.indexOf(`
10
- `,n+1))t++;return t}var Ni=e=>e.printing?.applies?{...e.pretty??{status:`off`},json:e.printing.json}:null,Pi=5,Fi=e=>e?e.length>Pi?`
10
+ `,n+1))t++;return t}var Ri=e=>e.printing?.applies?{...e.pretty??{status:`off`},json:e.printing.json,folds:e.printing.folds}:null,zi=5,Bi=e=>e?e.length>zi?`
11
11
  Affects files: ${e.length.toLocaleString()}`:`
12
12
  Affects files:
13
13
  ${e.join(`
14
- `)}`:``,Q=(e,t)=>U`<button type="button" class="bundle-compare-code-action" @click="${t}">${e}</button>`,Ii=(e,t,...n)=>on(e,U`<div class="bundle-compare-code-message"><p>${t}</p>${n.map((e,t)=>t?[` `,e]:e)}</div>`),Li=e=>z(e??0),Ri=(e,t,n)=>e===`added`?Li(n):e===`removed`?Li(t):`${Li(t)} \u2192 ${Li(n)}`,zi=e=>typeof e?.link==`string`?e.link:void 0,Bi=(e,t,n=zi(t))=>n===void 0?`a file`:U`a symlink to <code>${n}</code>${tn(e,n)===null?`, out of the package`:``}`,Vi=({after:e,before:t})=>[e,t].find(e=>typeof e==`string`&&e!==``)??null,Hi=(e,t)=>U`<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>`,Ui=(e,t,n)=>e.hideable??=fr(t,n,e.blocks);function Wi(e){let t=Map.groupBy(e,Yn);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 Gi=e=>e.kind===`repointed`||e.kind===`renamed`&&!e.modified&&!!e.repointed&&!e.meta,Ki=e=>Array.isArray(e)?e.some(Ki):e?.strings?e.strings.some(e=>e.trim()!==``)||e.values.some(Ki):e!=null&&e!==W&&e!==!1&&e!==``,qi=new WeakMap;function Ji(e,t){if(qi.has(e))return qi.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 qi.set(e,n),n}function Yi(e){let t=L(e);return Ji(t,t.keys())}function Xi(e,t){for(let n of e.files.values())if(n===t)return!0;for(let n of e.dirs.values())if(Xi(n,t))return!0;return!1}var Zi=class extends G{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._query=``,this._kinds=new Set(Gr.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=qr,this._counted=new Map,this._countModels=new Map,this._drawnCounts=new Map,this._drawnTotals=new Map,this._spaced=new Map,this._shared=new Map,this._shorter=new Map,this._larges=new Map,this._unrebuilt=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;for(let e of[this._models,this._spaced,this._shared,this._shorter,this._unrebuilt,this._larges,this._expansions,this._limits,this._forced])e.clear()}if([`files`,`resolutions`,`base`,`other`].some(t=>e.has(t))){this._entries=Xn(this.base,this.other,this.files,this.resolutions??[]);for(let e of[this._counted,this._countModels,this._drawnCounts,this._drawnTotals,this._blocks,this._rowless])e.clear();this._treeLimit=this.extensions?.treePageSize??1/0,this._sought=this._soughtRow=null,this._soughtSettling=!1}if(e.has(`seek`)&&this.seek&&!ei.has(this.seek)){ei.add(this.seek);let{path:e,line:t,query:n}=this.seek,r=this._entries?.get(e),i=r?J(this.base,this.other,e,r).after:null,a=typeof i==`string`?j(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,t]=[this.base,this.other].map(e=>e?.kind===`stasis`?e.bundle?.modules:null),n={root:this.files?.root,paths:this.files?.basePaths??new Map};return e||t?new Map([...[...e??[]].map(([e,t])=>[zt(n,e,Object.keys(t.files??{})),t]),...t??[]]):null}_baseDirs(){let e=this.files?.root?this.files.basePaths:null;return e?Ji(e,e.values()):Yi(this.base)}_format(e){let t=this._entries.get(e),n=Qt(this.base,t?.basePath??e),r=Qt(this.other,e);return[n,r].find(Zt)??(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 n=[...this._entries.keys()],r=this._modules(),i=Bt(this.files?.root,this.extensions?.fullPaths?``:Me(an(n).prefix,r,n)),{prefix:a}=i,o=n.filter(e=>this._shown(this._entries.get(e))),s=t(o.map(e=>q(e,a)),o,r);return this._treeKey=e,this._treeMemo={prefix:a,root:i,tree:s,shown:o.length,allOrder:Ze(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=q(e,t).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=Fe(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?Ze(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<=Yr,c=this._mode===`code`?W:i?this._renderTree(i,o,0,s,s?null:He(i)):U`<div class="bundle-code-search-empty">No changed files match.</div>`,l=new Set([...this._entries.values()].flatMap(e=>[e.kind!==`repointed`&&e.kind,e.modified&&`changed`,e.repointed&&`repointed`])),u=Zr.find(({mode:e})=>e===this._mode),d=this._mode===`files`?this.extensions:null;return U`<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">${this.extensions?.copyDiff?U`<button type="button" class="bundle-code-rail-action bundle-code-copy-diff" aria-label="Copy complete diff" data-tooltip="Copy complete diff" @click="${e=>{this._copyDiff(e.currentTarget)}}">${b}</button>`:W} <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)}">${ne}</button></span></div>${t.from?U`<div class="bundle-code-rail-prefix mono" data-tooltip="${`Root moved: ${t.from} \u2192 ${t.to}`}">${Wn(t)}</div>`:e?U`<div class="bundle-code-rail-prefix mono" data-tooltip-truncated data-tooltip="${e}">${e}</div>`:W}<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="${d?.searchPlaceholder??u.placeholder}" aria-label="${d?.searchLabel??u.placeholder}" spellcheck="false" autocomplete="off" .value="${I(this._query)}" @input="${e=>{this._query=e.target.value,this._treeLimit=this.extensions?.treePageSize??1/0}}"> <span class="bundle-code-search-modes" role="tablist">${Zr.map(({mode:e,label:t,icon:n})=>U`<button type="button" class="${B({"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??U`<div class="bundle-compare-code-kinds" role="group" aria-label="Show changes">${Gr.filter(({kind:e})=>l.has(e)).map(({kind:e,label:t})=>U`<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._wrapTree(this._mode===`code`?this._renderSearch(a,o,e):c)} ${this._mode===`files`&&this._treeTruncated?Q(`Show more files`,()=>{this._treeLimit+=this.extensions.treePageSize,this.requestUpdate()}):W}</div></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>`}_wrapTree(e){return this.extensions?.railTree?.(e)??e}async _copyDiff(e){try{await navigator.clipboard.writeText(this.extensions.copyDiff())}catch{be(`Could not copy the diff to the clipboard.`,{kind:`error`});return}e.classList.add(`copied`),setTimeout(()=>e.classList.remove(`copied`),1e3)}_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?U`${this._renderFile(t,this.extensions?.fullPaths?``:e.prefix)}${this.extensions?.fileActions?.(t,!1)??W}`:U`<div class="bundle-code-placeholder">No files differ in this comparison.</div>`;return this._layout(e,t,n)}_layout(e,t,n){return U`<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.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 U`<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);return r.length===0?U`<div class="bundle-code-search-empty">No matches.</div>`:U`<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 ${Cr}`:``}</div>${H(r,e=>e.path,({path:e,hits:r})=>U`<div class="${B({"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)}">${q(e,n)}</button> ${o.has(e)?U`<p class="bundle-compare-search-note">${ti[o.get(e)]}</p>`:W}<ul class="bundle-code-search-hits">${r.map(t=>U`<li class="bundle-code-search-hit"><button type="button" class="bundle-code-search-hit-link" aria-label="${`${ni[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 ${ni[t.sign]?.name??``}`}" aria-hidden="true">${t.sign??``}</span> <span class="bundle-code-search-hit-text mono">${lt(t.text,t.ranges)}</span></button></li>`)}</ul></div>`)}</div>`}_searchResults(e){let t=ri(),n=`${this._query}\0${this._forced.size}\0${t}\0${O.layout}\0${F.bundleSourcePretty}\0${Se()}\0${this._rowlessCount}\0${e.join(`\0`)}`;if(this._found?.key===n&&this._found.entries===this._entries)return this._found.result;let r=null,i=!0,a=new Map,o={...kr(e.flatMap(e=>{let n=this._entries.get(e);if(!this._searchable(n))return[];let r=J(this.base,this.other,e,n),{before:i,after:o}=r;if(this._prettyShown(e,n,r)){if(!/\S/u.test(this._query))return[];let n=i!==``&&o!==``&&i!==o;if(n&&this._rowless.get(e)===t)return[];a.set(e,n?`printed`:`numbered`)}return[{path:e,...r}]}),ot(this._query,!1,!1),(e,t,n)=>{if(a.get(e)===`printed`)return null;let o=`${O.ignoreWhitespace}\0${e}`;if(this._blocks.has(o))return this._blocks.get(o);if(!this._forced.has(e)&&yt(t,n))return a.set(e,`large`),null;let s=performance.now();if(r??=s+Xr,s>r)return i=!1,null;let c=O.ignoreWhitespace&&!this._unlisted(e,this._entries.get(e),{before:t,after:n})?pt(t,n):N(t,n);return this._blocks.set(o,c),c},{split:O.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}),br(i,n.indexOf(r))}}),unsigned:a};return i?this._found={key:n,entries:this._entries,result:o}:this._later(`_searchLater`),o}_later(e){this[e]??=setTimeout(()=>{this[e]=null,this.requestUpdate()})}_spent(){let e=performance.now();return this._countUntil??=e+Xr,e<=this._countUntil?!1:(this._later(`_countLater`),!0)}_searchable(e){return e.modified!==!1||Gi(e)}_prettyShown(e,t,n){if(!F.bundleSourcePretty)return!1;let r=this._printing(e,t,n);return!!r?.applies&&r.copies.status!==`error`}_noteRowless(e,t){let n=t?ri():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=j(J(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+=$r){a+=c(o.slice(e,e+$r)).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=mr(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+Qr}:r.up?{...a,bottom:(a.bottom??0)+r.count-d+Qr}:{all:!0}),this._expansions.set(e,c),l=mr(t,c,{split:i}),u=l.findIndex(s)}}return this._reach(e,u),{rows:l,index:u}}_reach(e,t){return t<(this._limits.get(e)??X)?!1:(this._limits.set(e,Math.ceil((t+1)/X)*X),!0)}_takeTreeRow(e=!1){return this._treeRemaining-->0||(this._treeTruncated=!0,e)}_renderTree(e,t,n,r,i){let a=[...e.dirs.entries()].toSorted(Je),o=[...e.files.entries()].toSorted(([e],[t])=>e.localeCompare(t)),s=a.flatMap(([e,a])=>{let o=Re(e,a,n),s=a.package,c=s?.ecosystem===`cargo`||s?.ecosystem===`composer`||s?.ecosystem===`soldeer`,l=this._pathQuery()?!0:this._open.get(a.path)??(r||!!i?.has(a.path)||Xi(a,t)),u=this._baseDirs().has(a.sourcePath)?Yi(this.other).has(a.sourcePath)?null:`removed`:`added`;if(!this._takeTreeRow(Xi(a,t)))return[];let d=U`<li class="bundle-code-tree-dir"><details .open="${I(l)}" @toggle="${e=>{let t=e.currentTarget.open;this._open.get(a.path)!==t&&(this._open.set(a.path,t),this.extensions?.treePageSize&&this.requestUpdate())}}"><summary aria-label="${this.extensions?.directoryLabel?.(o.node)??W}"><span class="bundle-code-tree-chevron" aria-hidden="true"></span> ${s||a.dependencyRoot?Ht(s?.ecosystem??a.dependencyRoot):W} <span class="${B({"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?U`<span class="bundle-code-tree-package-name">${s.name}</span>${s.version?U`<span class="bundle-code-tree-package-version">${c?`- `:`@`}${s.version}</span>`:W}`:o.names.map((e,t)=>U`${t>0?U`<span class="bundle-code-tree-separator">/</span>`:W}${e}`)} </span>${s?.variant?U`<span class="bundle-code-tree-variant">variant ${s.variant}</span>`:W} <span class="bundle-compare-code-dir-count" data-tooltip="${`${a.fileCount} changed ${a.fileCount===1?`file`:`files`}`}">${this.extensions?.directorySummary?.(o.node)??a.fileCount}</span> ${u?U`<span class="${`bundle-compare-code-letter ${u}`}" data-tooltip="${`${s?`Package`:`Directory`} ${u}`}">${Kr[u].letter}</span>`:W}</summary>${l||!this.extensions?.treePageSize?this._renderTree(o.node,t,n+1,r,i):W}</details></li>`;return[{key:a.path,content:d}]}),c=o.flatMap(([e,n])=>{if(!this._takeTreeRow(n===t))return[];let r=this._entries.get(n),{kind:i,repointed:a,renamedFrom:o,modified:s}=r,c=a?Wi(a).note:``;return[{key:n,content:U`<li class="bundle-code-tree-file"><button type="button" class="${B({"bundle-code-tree-link":!0,current:n===t})}" aria-label="${this.extensions?.fileLabel?.(n)??W}" aria-current="${n===t?`true`:W}" @click="${()=>this._select(n)}">${this.extensions?.filePrefix?.(n)??W}${$t(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)??W} ${o?U`<span class="bundle-compare-code-oldname" data-tooltip-truncated data-tooltip="${`Renamed from ${o}`}">← ${Rt(o,n,{extension:!1}).from}</span>`:W} ${this._fileTags(n,r,!0)} ${this._treeCounts(n,r)} ${a&&i!==`repointed`?U`<span class="bundle-compare-code-letter repointed" data-tooltip="${c}">R</span>`:W} <span class="${B({"bundle-compare-code-letter":!0,[i]:!0,pure:i===`renamed`&&!s})}" data-tooltip="${i===`repointed`?c:o?`Renamed${s?` and modified`:``} from ${o}`:Kr[i].label}">${Kr[i].letter}</span></button></li>`}]});return U`<ul class="${B({"bundle-code-tree":!0,root:n===0})}" aria-label="${n===0?this.extensions?.treeLabel??`Changed files`:W}" @keydown="${n===0?Ge:W}">${H(s,e=>e.key,e=>e.content)}${H(c,e=>e.key,e=>e.content)}</ul>`}_treeCounts(e,t){if(t.kind===`repointed`)return W;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 W;let{additions:i,deletions:a}=r??n,o=!n||n.additions>0||n.deletions>0,s=t.kind===`renamed`,c=r?.renamed>0?`
14
+ `)}`:``,Q=(e,t)=>U`<button type="button" class="bundle-compare-code-action" @click="${t}">${e}</button>`,Vi=(e,t,...n)=>dn(e,U`<div class="bundle-compare-code-message"><p>${t}</p>${n.map((e,t)=>t?[` `,e]:e)}</div>`),Hi=e=>z(e??0),Ui=(e,t,n)=>e===`added`?Hi(n):e===`removed`?Hi(t):`${Hi(t)} \u2192 ${Hi(n)}`,Wi=e=>typeof e?.link==`string`?e.link:void 0,Gi=(e,t,n=Wi(t))=>n===void 0?`a file`:U`a symlink to <code>${n}</code>${sn(e,n)===null?`, out of the package`:``}`,Ki=({after:e,before:t})=>[e,t].find(e=>typeof e==`string`&&e!==``)??null,qi=(e,t)=>U`<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>`,Ji=(e,t,n)=>e.hideable??=_r(t,n,e.blocks);function Yi(e){let t=Map.groupBy(e,er);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 Xi=e=>e.kind===`repointed`||e.kind===`renamed`&&!e.modified&&!!e.repointed&&!e.meta,Zi=e=>Array.isArray(e)?e.some(Zi):e?.strings?e.strings.some(e=>e.trim()!==``)||e.values.some(Zi):e!=null&&e!==W&&e!==!1&&e!==``,Qi=new WeakMap;function $i(e,t){if(Qi.has(e))return Qi.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 Qi.set(e,n),n}function ea(e){let t=L(e);return $i(t,t.keys())}function ta(e,t){for(let n of e.files.values())if(n===t)return!0;for(let n of e.dirs.values())if(ta(n,t))return!0;return!1}var na=class extends G{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._query=``,this._kinds=new Set(Xr.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=Qr,this._counted=new Map,this._countModels=new Map,this._drawnCounts=new Map,this._drawnTotals=new Map,this._spaced=new Map,this._shared=new Map,this._printedFolds=new Map,this._shorter=new Map,this._folding=new Map,this._larges=new Map,this._unrebuilt=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;for(let e of[this._models,this._spaced,this._shared,this._printedFolds,this._shorter,this._folding,this._unrebuilt,this._larges,this._expansions,this._limits,this._forced])e.clear()}if([`files`,`resolutions`,`base`,`other`].some(t=>e.has(t))){this._entries=tr(this.base,this.other,this.files,this.resolutions??[]);for(let e of[this._counted,this._countModels,this._drawnCounts,this._drawnTotals,this._blocks,this._rowless])e.clear();this._treeLimit=this.extensions?.treePageSize??1/0,this._sought=this._soughtRow=null,this._soughtSettling=!1}if(e.has(`seek`)&&this.seek&&!ai.has(this.seek)){ai.add(this.seek);let{path:e,line:t,query:n}=this.seek,r=this._entries?.get(e),i=r?J(this.base,this.other,e,r).after:null,a=typeof i==`string`?j(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,t]=[this.base,this.other].map(e=>e?.kind===`stasis`?e.bundle?.modules:null),n={root:this.files?.root,paths:this.files?.basePaths??new Map};return e||t?new Map([...[...e??[]].map(([e,t])=>[Wt(n,e,Object.keys(t.files??{})),t]),...t??[]]):null}_baseDirs(){let e=this.files?.root?this.files.basePaths:null;return e?$i(e,e.values()):ea(this.base)}_format(e){let t=this._entries.get(e),n=rn(this.base,t?.basePath??e),r=rn(this.other,e);return[n,r].find(nn)??(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 n=[...this._entries.keys()],r=this._modules(),i=Gt(this.files?.root,this.extensions?.fullPaths?``:ze(un(n).prefix,r,n)),{prefix:a}=i,o=n.filter(e=>this._shown(this._entries.get(e))),s=t(o.map(e=>q(e,a)),o,r);return this._treeKey=e,this._treeMemo={prefix:a,root:i,tree:s,shown:o.length,allOrder:$e(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=q(e,t).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=Be(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?$e(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<=ei,c=this._mode===`code`?W:i?this._renderTree(i,o,0,s,s?null:Ue(i)):U`<div class="bundle-code-search-empty">No changed files match.</div>`,l=new Set([...this._entries.values()].flatMap(e=>[e.kind!==`repointed`&&e.kind,e.modified&&`changed`,e.repointed&&`repointed`])),u=ni.find(({mode:e})=>e===this._mode),d=this._mode===`files`?this.extensions:null;return U`<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">${this.extensions?.copyDiff?U`<button type="button" class="bundle-code-rail-action bundle-code-copy-diff" aria-label="Copy complete diff" data-tooltip="Copy complete diff" @click="${e=>{this._copyDiff(e.currentTarget)}}">${v}</button>`:W} <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)}">${O}</button></span></div>${t.from?U`<div class="bundle-code-rail-prefix mono" data-tooltip="${`Root moved: ${t.from} \u2192 ${t.to}`}">${Yn(t)}</div>`:e?U`<div class="bundle-code-rail-prefix mono" data-tooltip-truncated data-tooltip="${e}">${e}</div>`:W}<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="${d?.searchPlaceholder??u.placeholder}" aria-label="${d?.searchLabel??u.placeholder}" spellcheck="false" autocomplete="off" .value="${I(this._query)}" @input="${e=>{this._query=e.target.value,this._treeLimit=this.extensions?.treePageSize??1/0}}"> <span class="bundle-code-search-modes" role="tablist">${ni.map(({mode:e,label:t,icon:n})=>U`<button type="button" class="${B({"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??U`<div class="bundle-compare-code-kinds" role="group" aria-label="Show changes">${Xr.filter(({kind:e})=>l.has(e)).map(({kind:e,label:t})=>U`<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._wrapTree(this._mode===`code`?this._renderSearch(a,o,e):c)} ${this._mode===`files`&&this._treeTruncated?Q(`Show more files`,()=>{this._treeLimit+=this.extensions.treePageSize,this.requestUpdate()}):W}</div></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>`}_wrapTree(e){return this.extensions?.railTree?.(e)??e}async _copyDiff(e){try{await navigator.clipboard.writeText(this.extensions.copyDiff())}catch{ke(`Could not copy the diff to the clipboard.`,{kind:`error`});return}e.classList.add(`copied`),setTimeout(()=>e.classList.remove(`copied`),1e3)}_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?U`${this._renderFile(t,this.extensions?.fullPaths?``:e.prefix)}${this.extensions?.fileActions?.(t,!1)??W}`:U`<div class="bundle-code-placeholder">No files differ in this comparison.</div>`;return this._layout(e,t,n)}_layout(e,t,n){return U`<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.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 U`<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);return r.length===0?U`<div class="bundle-code-search-empty">No matches.</div>`:U`<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 ${Or}`:``}</div>${H(r,e=>e.path,({path:e,hits:r})=>U`<div class="${B({"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)}">${q(e,n)}</button> ${o.has(e)?U`<p class="bundle-compare-search-note">${oi[o.get(e)]}</p>`:W}<ul class="bundle-code-search-hits">${r.map(t=>U`<li class="bundle-code-search-hit"><button type="button" class="bundle-code-search-hit-link" aria-label="${`${si[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 ${si[t.sign]?.name??``}`}" aria-hidden="true">${t.sign??``}</span> <span class="bundle-code-search-hit-text mono">${St(t.text,t.ranges)}</span></button></li>`)}</ul></div>`)}</div>`}_searchResults(e){let t=ci(),n=`${this._query}\0${this._forced.size}\0${t}\0${k.layout}\0${N.bundleSourcePretty}\0${je()}\0${this._rowlessCount}\0${e.join(`\0`)}`;if(this._found?.key===n&&this._found.entries===this._entries)return this._found.result;let r=null,i=!0,a=new Map,o={...Pr(e.flatMap(e=>{let n=this._entries.get(e);if(!this._searchable(n))return[];let r=J(this.base,this.other,e,n),{before:i,after:o}=r;if(this._prettyShown(e,n,r)){if(!/\S/u.test(this._query))return[];let n=i!==``&&o!==``&&i!==o;if(n&&this._rowless.get(e)===t)return[];a.set(e,n?`printed`:`numbered`)}return[{path:e,...r}]}),bt(this._query,!1,!1),(e,t,n)=>{if(a.get(e)===`printed`)return null;let o=`${k.ignoreWhitespace}\0${e}`;if(this._blocks.has(o))return this._blocks.get(o);if(!this._forced.has(e)&&F(t,n))return a.set(e,`large`),null;let s=performance.now();if(r??=s+ti,s>r)return i=!1,null;let c=k.ignoreWhitespace&&!this._unlisted(e,this._entries.get(e),{before:t,after:n})?Et(t,n):wt(t,n);return this._blocks.set(o,c),c},{split:k.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}),Tr(i,n.indexOf(r))}}),unsigned:a};return i?this._found={key:n,entries:this._entries,result:o}:this._later(`_searchLater`),o}_later(e){this[e]??=setTimeout(()=>{this[e]=null,this.requestUpdate()})}_spent(){let e=performance.now();return this._countUntil??=e+ti,e<=this._countUntil?!1:(this._later(`_countLater`),!0)}_searchable(e){return e.modified!==!1||Xi(e)}_prettyShown(e,t,n){if(!N.bundleSourcePretty)return!1;let r=this._printing(e,t,n),i=k.ignoreTypes&&r?Gr(this.base,this.other,e,t,n,this._repaint,this.scope):null,a=i&&i!==!0?Fi(i,n):null;return a?!!this._byPrinted(e,t,n,a,r):!!r?.applies&&r.copies.status!==`error`}_byPrinted(e,t,n,r,i){let a=r&&k.ignoreTypes&&i?.copies.status===`ready`&&i.copies.runs?i.copies:null,o=i?.json||i?.map||i?.minified;if(!a||!(o||n.before!==``&&n.after!==``))return null;let s=Z(this._printedFolds,e,[...a.made,a.runs.runs,a.runs.otherRuns],()=>kt(...a.made,a.runs));return s===!1||o||this._smaller(e,t,n,s||a,r)?{folds:s}:null}_noteRowless(e,t){let n=t?ci():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=j(J(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+=ii){a+=c(o.slice(e,e+ii)).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=r.typeFolds?j(r.typeFolds.whole[i]):r[i],m=f(l,(e,t)=>t>=u),h=(m&&f(p,e=>e===m.index)?.start)??u;for(let e=0;e<p.length;e++)if(h-=c(p[e]).length,h<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=yr(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+ri}:r.up?{...a,bottom:(a.bottom??0)+r.count-d+ri}:{all:!0}),this._expansions.set(e,c),l=yr(t,c,{split:i}),u=l.findIndex(s)}}return this._reach(e,u),{rows:l,index:u}}_reach(e,t){return t<(this._limits.get(e)??X)?!1:(this._limits.set(e,Math.ceil((t+1)/X)*X),!0)}_takeTreeRow(e=!1){return this._treeRemaining-->0||(this._treeTruncated=!0,e)}_renderTree(e,t,n,r,i){let a=[...e.dirs.entries()].toSorted(Ye),o=[...e.files.entries()].toSorted(([e],[t])=>e.localeCompare(t)),s=a.flatMap(([e,a])=>{let o=Ve(e,a,n),s=a.package,c=s?.ecosystem===`cargo`||s?.ecosystem===`composer`||s?.ecosystem===`soldeer`,l=this._pathQuery()?!0:this._open.get(a.path)??(r||!!i?.has(a.path)||ta(a,t)),u=this._baseDirs().has(a.sourcePath)?ea(this.other).has(a.sourcePath)?null:`removed`:`added`;if(!this._takeTreeRow(ta(a,t)))return[];let d=U`<li class="bundle-code-tree-dir"><details .open="${I(l)}" @toggle="${e=>{let t=e.currentTarget.open;this._open.get(a.path)!==t&&(this._open.set(a.path,t),this.extensions?.treePageSize&&this.requestUpdate())}}"><summary aria-label="${this.extensions?.directoryLabel?.(o.node)??W}"><span class="bundle-code-tree-chevron" aria-hidden="true"></span> ${s||a.dependencyRoot?qt(s?.ecosystem??a.dependencyRoot):W} <span class="${B({"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?U`<span class="bundle-code-tree-package-name">${s.name}</span>${s.version?U`<span class="bundle-code-tree-package-version">${c?`- `:`@`}${s.version}</span>`:W}`:o.names.map((e,t)=>U`${t>0?U`<span class="bundle-code-tree-separator">/</span>`:W}${e}`)} </span>${s?.variant?U`<span class="bundle-code-tree-variant">variant ${s.variant}</span>`:W} <span class="bundle-compare-code-dir-count" data-tooltip="${`${a.fileCount} changed ${a.fileCount===1?`file`:`files`}`}">${this.extensions?.directorySummary?.(o.node)??a.fileCount}</span> ${u?U`<span class="${`bundle-compare-code-letter ${u}`}" data-tooltip="${`${s?`Package`:`Directory`} ${u}`}">${Zr[u].letter}</span>`:W}</summary>${l||!this.extensions?.treePageSize?this._renderTree(o.node,t,n+1,r,i):W}</details></li>`;return[{key:a.path,content:d}]}),c=o.flatMap(([e,n])=>{if(!this._takeTreeRow(n===t))return[];let r=this._entries.get(n),{kind:i,repointed:a,renamedFrom:o,modified:s}=r,c=a?Yi(a).note:``;return[{key:n,content:U`<li class="bundle-code-tree-file"><button type="button" class="${B({"bundle-code-tree-link":!0,current:n===t})}" aria-label="${this.extensions?.fileLabel?.(n)??W}" aria-current="${n===t?`true`:W}" @click="${()=>this._select(n)}">${this.extensions?.filePrefix?.(n)??W}${an(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)??W} ${o?U`<span class="bundle-compare-code-oldname" data-tooltip-truncated data-tooltip="${`Renamed from ${o}`}">← ${Ut(o,n,{extension:!1}).from}</span>`:W} ${this._fileTags(n,r,!0)} ${this._treeCounts(n,r)} ${a&&i!==`repointed`?U`<span class="bundle-compare-code-letter repointed" data-tooltip="${c}">R</span>`:W} <span class="${B({"bundle-compare-code-letter":!0,[i]:!0,pure:i===`renamed`&&!s})}" data-tooltip="${i===`repointed`?c:o?`Renamed${s?` and modified`:``} from ${o}`:Zr[i].label}">${Zr[i].letter}</span></button></li>`}]});return U`<ul class="${B({"bundle-code-tree":!0,root:n===0})}" aria-label="${n===0?this.extensions?.treeLabel??`Changed files`:W}" @keydown="${n===0?Ge:W}">${H(s,e=>e.key,e=>e.content)}${H(c,e=>e.key,e=>e.content)}</ul>`}_treeCounts(e,t){if(t.kind===`repointed`)return W;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 W;let{additions:i,deletions:a}=r??n,o=!n||n.additions>0||n.deletions>0,s=t.kind===`renamed`,c=r?.renamed>0?`
15
15
  \u2248${r.renamed.toLocaleString()} lines differing in renamed names alone, marked`:``,l=n?`
16
- 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 U`<span class="bundle-compare-code-line-counts unchanged" aria-label="No line changes">=</span>`;if(r&&o)return U`<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 U`<span class="bundle-compare-code-line-counts" aria-label="${`${i} added, ${a} removed lines`}" data-tooltip="${d?`With ${u}`:W}"><span class="${B({add:!0,empty:s&&i===0})}">+${i.toLocaleString()}</span> <span class="${B({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(!(F.bundleSourcePretty||O.ignoreWhitespace||O.ignoreRenames||O.ignoreTypes))return null;let n=`${si(e)}\0${this._arrived}\0${this._forced.size}`,r=this._drawnCounts.get(e);if(r?.settings===n)return r.counts;if(this._spent())return;let i=this._countingState(e,t),a=i.model&&ci(i).length>0?li(i.model,i):null;return this._drawnCounts.set(e,{settings:n,counts:a}),a}_lineCounts(e,t){if(this._counted.has(e))return this._counted.get(e);if(this._spent())return null;let{before:n,after:r}=J(this.base,this.other,e,t),i=dr(n,r);return this._counted.set(e,i),i}_noteDrawn(e,t){return t.model&&this._drawnTotals.set(e,{settings:si(e),counts:li(t.model,t)}),t}_largeCounts(e,t){let n=this._drawnTotals.get(e);if(n?.settings===si(e))return n.counts.aside.length===0?{published:n.counts,shown:null}:{published:null,shown:n.counts};let r=O.ignoreTypes?J(this.base,this.other,e,t):null;return{published:null,shown:typeof r?.before==`string`&&typeof r.after==`string`&&Br(this.base,this.other,e,t,r,this._repaint,this.scope)===!0?{additions:0,deletions:0,renamed:0,aside:[ai]}:null}}_model(e,t,n,r={},i=O.ignoreWhitespace){return Z(this._models,e,[t,n,r.changes?.blocks??r.marks??null],()=>or(t,n,{...r,ignoreWhitespace:i}),this._modelCap)}_counts(e,t,n,r,i){return Z(this._countModels,e,[t,n,r.changes?.blocks??r.marks??null],()=>{let e=r.changes?.blocks??N(t,n,i);return{blocks:e,..._t(e,r.marks)}})}_fileState(e,t,n=!1){let r=J(this.base,this.other,e,t),i=typeof r.before==`string`&&typeof r.after==`string`,a=i?Br(this.base,this.other,e,t,r,this._repaint,this.scope):void 0,o=a===!0;if(o&&O.ignoreTypes){let t={a:[],b:[],blocks:[],additions:0,deletions:0,renamed:0,marked:new Set,noEol:{a:!1,b:!1},words:new Map};return n?{pretty:null,hiding:!1,model:t,spacesHidden:!1,typesHidden:!0}:this._noteDrawn(e,{...r,textual:i,large:!1,printing:null,pretty:null,key:null,generated:!1,renamed:!1,warned:[],hiding:!1,changes:null,model:t,whitespace:null,spacesHidden:!1,types:o,typesHidden:!0})}let s=a&&a!==!0?Ai(a,r):null,c=!!s&&O.ignoreTypes,l=i&&!c&&(!n||F.bundleSourcePretty)?this._printing(e,t,r):null,u=F.bundleSourcePretty&&l?.applies?l.copies:null,{before:d,after:f}=c?s:u?.status===`ready`?u:r,p=i&&[`ready`,`loading`,`error`].includes(u?.status)&&this._generated(e,t,r),m=p&&u.status===`ready`;!n&&i&&this._sought?.path===e&&!this._forced.has(e)&&this._large(e,d,f)&&this._forced.add(e);let h=i&&!this._forced.has(e)&&this._large(e,d,f),{basePath:g=e}=t,_=t=>{let a=m&&!h?me(this.base,g,r.before,this.other,e,r.after,!1,this._repaint,u.hashes,!n&&this._renamesAlone,this.scope):null,o=a?.status===`ready`&&O.ignoreRenames&&!(a.holds??=xt(a.before,f,a.blocks))?xi:a,l=o?.status===`ready`,_=l&&O.ignoreRenames,v=l&&!_,y=_&&o.reason===null?Ci(o):[],b=l&&o.reason===null?o.marks.length>0||O.ignoreRenames&&o.before!==d:O.ignoreRenames&&p,x=`${wi(e,u?.status===`ready`,{...O,ignoreWhitespace:t,ignoreRenames:_,markRenames:v})}${c?`\0types`:``}`,S=_?o.before:d,C=_?t?{}:{changes:{blocks:o.blocks}}:v?{marks:o.marks}:{},w=i&&!h&&(!o||l||!O.ignoreRenames)?n?this._counts(x,S,f,C,t):this._model(x,S,f,C,t):null;return c&&w&&(w.typeFolds=s),{key:x,changes:o,warned:y,renamed:b,hiding:_,shown:S,model:w,ignoreWhitespace:t}},v=this._unlisted(e,t,r),y=_(O.ignoreWhitespace&&!v&&`leading`),b=!!y.ignoreWhitespace&&!!y.model&&(y.model.mixed??=Lt(y.shown,f,y.model.blocks));b&&(y=_(!1));let{key:x,changes:S,warned:C,renamed:w,hiding:T,shown:E,model:D}=y;if(l?.map&&u?.status===`ready`&&D&&(Object.hasOwn(D,`listingRefusal`)||(D.listingRefusal=Ee(this.base,this.other,g,e,r,{a:D.a??j(E),b:D.b??j(f),blocks:D.blocks})),D.listingRefusal!==null))return this._unrebuilt.set(`${g}\0${e}`,{status:`error`,message:`Its listings' diff wouldn't show every change: ${D.listingRefusal}`,retry:!1}),this._fileState(e,t,n);if(n)return{pretty:u,hiding:T,model:D,spacesHidden:y.ignoreWhitespace,typesFolded:c};u?.status===`ready`&&D?this._noteRowless(e,D.blocks.length===0):D&&!c&&(this._blocks.set(`${O.ignoreWhitespace}\0${e}`,D.blocks),this._aligned.set(D.blocks,D));let ee=D&&!v&&!O.ignoreWhitespace?this._whitespaceHidden(`${e}\0${u?.status===`ready`}\0${T}`,E,f):null,te=D===null||v?null:b?`mixed`:O.ignoreWhitespace?Ui(D,E,f)?`hideable`:null:ee.hides&&!ee.mixed?`hideable`:null;return this._sought?.path===e&&(this._soughtSettling=u?.status===`loading`||O.ignoreRenames&&(S?.status===`loading`||S?.status===`error`)),this._noteDrawn(e,{...c?r:{before:E,after:f},textual:i,large:h,printing:l,pretty:u,key:x,generated:p,renamed:w,warned:C,hiding:T,changes:S,model:D,whitespace:te,spacesHidden:y.ignoreWhitespace,types:o||!!s,typesFolded:c})}_unlisted(e,{basePath:t=e},{before:n,after:r}){return!nr(e,r,di(this.other,e))||!nr(t,n,di(this.base,t))}_whitespaceHidden(e,t,n){return Z(this._spaced,e,[t,n],()=>pr(t,n),this._modelCap)}_generated(e,{kind:t,basePath:n=e},{before:r,after:i}){return t!==`repointed`&&fi(e)&&fi(n)&&de(this.base,this.other)&&pi(this.base,n,r)&&pi(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===``||Ce(this.base,this.other,e,t,n)))return null;let l=c.every(([,,e,t])=>t===``||ct(e)),u=c.every(([,,e,t])=>t===``||Ct(e)),d=!l&&!u&&c.some(([,e,t,n])=>n!==``&&pi(e,t,n)),f=c.map(([e,,t,n])=>n===``?{status:`ready`,text:n}:Te(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`,...this._drawn(e,t,n,f),hashes:f.map(e=>e.hash)},m=!l&&!u&&!d&&o!==``&&s!==``&&p.status===`ready`&&this._smaller(e,t,n,p);return{copies:p,json:l,map:u,minified:d,smaller:m,applies:l||u||d||m}}_drawn(e,t,n,[r,i]){return this._generated(e,t,n)?{before:r.text,after:i.text}:Z(this._shared,e,[r.text,i.text,r.blank,i.blank],()=>ht(r.text,i.text,r.blank??[],i.blank??[]))}_large(e,t,n){return Z(this._larges,e,[t,n],()=>yt(t,n))}_smaller(e,t,{before:n,after:r},i){let a=O.ignoreWhitespace&&!this._unlisted(e,t,{before:n,after:r})&&`leading`;return Z(this._shorter,`${e}\0${a}`,[n,r,i.before,i.after],()=>{if(yt(n,r)||yt(i.before,i.after))return!1;let e=vt(i.before,i.after,a),t=vt(n,r,a);return e.lines<t.lines||e.lines===t.lines&&e.marks<t.marks})}_fileMessage(e,{kind:t,modified:n,meta:r,basePath:i=e},{before:a,after:o,textual:s,large:c,model:l,pretty:u,hiding:d,warned:f=[],changes:p,whitespace:m,typesHidden:h=!1,typesFolded:g=!1}){let _=Wr(r),v=e=>`${e}${_?` ${_}`:``}`,y=v(t===`renamed`?_?`Renamed, its contents the same.`:`Renamed without changes.`:`The contents are the same.`);if(s&&n===!1)return Ii(`same`,y);if(!s&&[a,o].some(e=>zi(e)!==void 0)){let[n,r]=[t===`added`?`nothing`:Bi(i,a),t===`removed`?`nothing`:Bi(e,o)];return U`<div class="bundle-compare-code-message">Was ${n}; now ${r}.${_?` ${_}`:``}</div>`}if(!s){let r=[a,o].some(e=>e?.format===`digest`)&&Wt(e),i=r?`Code that isn't text`:`Binary file`;if(t===`changed`&&n===!1)return U`<div class="bundle-compare-code-message">${i}, its bytes the same · ${Li(R(o))}. ${_}</div>`;let s=r?` It is not UTF-8, or holds a NUL, so it is shown as no text, yet node runs it all the same, decoded as UTF-8.`:``;return U`<div class="bundle-compare-code-message">${i} ${t} · ${Ri(t,R(a),R(o))}. A text diff is not available.${s}${_?` ${_}`:``}</div>`}if(c)return Ii(`large`,U`This diff is large (${(Mi(a)+Mi(o)).toLocaleString()} lines across both sides) and may take a few seconds to compute.`,Q(`Show diff`,()=>{this._forced.add(e),this.requestUpdate()}));let b=Q(`Show renamed names`,()=>this._setRenames(!1)),x=Q(`Show type-only changes`,()=>this._setTypes(!1));if(h)return Ii(`types`,U`Only types changed in this file.${_?` ${_}`:``}`,x);if(p?.status===`loading`&&O.ignoreRenames)return U`<div class="bundle-compare-code-message" aria-busy="true">Hiding renamed names…</div>`;if(p?.status===`error`&&O.ignoreRenames)return Ii(`renames`,U`Couldn't hide renamed names: ${p.message}`,b);if(l.blocks.length>0)return null;let S=u?.status===`ready`&&u.before===u.after,C=!S&&O.ignoreWhitespace&&m===`hideable`,w=!S&&d,T=[g&&`types`,C&&`whitespace`,w&&`renamed names`].filter(Boolean),E=S?`No actual code changes in this file.`:T.length>0?`Only ${T.join(` and `)} changed in this file.`:null;return Ii(`told`,E?v(E):y,f.map(e=>U`<p>${e}</p>`),S?Q(`Show as published`,()=>{ke(!1),this._viewChanged()}):W,g?x:W,C?Q(`Show whitespace changes`,()=>this._setWhitespace(!1)):W,w?b:W)}_fileName(e,t,n,r=W){let i=e=>q(e,n);return U`<span class="${B({"bundle-compare-code-pill":!0,[t.kind]:!0,pure:t.kind===`renamed`&&!t.modified})}">${Kr[t.kind].label}</span> ${$t(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?Un(i(t.renamedFrom),i(e)):i(e)}</span> ${r}${this._githubLink(e,t)}${this._fileTags(e,t)}`}_side(e,{kind:t,basePath:n=e}){return t===`removed`?{details:this.base,at:n,alerts:this.baseAlerts}:{details:this.other,at:e,alerts:this.otherAlerts}}_fileTags(e,t,n=!1){if(!n)return U`${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)}${Hr(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),Hr(t.meta,!0)];return Ki(r)?r:this._flagTags(e,t)}_githubLink(e,t){let{details:n,at:r}=this._side(e,t),i=$e(n,r);return i?tt(i):W}_alertTags(e,t){let{alerts:n,at:r}=this._side(e,t),i=n?.get(r);return i?.length>0&&this.alertTags?this.alertTags(i):W}_newHostTags(e,{kind:t}){let n=t===`removed`?null:this.newHosts?.get(e);return n&&this.newHostTag?this.newHostTag(n):W}_runsTags(e,t){return[[ee,ie],[ce,fe]].map(([n,r])=>{let{was:i,now:a}=this._reads(e,t,n);return t.kind===`removed`?r(i):r(a,i)})}_entryTags(e,t){let{details:n,at:r}=this._side(e,t);return[...Map.groupBy(gi(n).get(r)??[],({label:e})=>e)].map(([e,t])=>U`<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(!_i.test(e))return W;let{kind:r,basePath:i=e}=t,{before:a,after:o}=J(this.base,this.other,e,t),s=new Map(r===`added`||a===void 0?[]:yi(this.base,i,a)),c=new Map(r===`removed`||o===void 0?[]:yi(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 U`<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(U`<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}=J(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),a=e=>U`${Mt(e)}${i(e)}`,o=!n||!r||Gt(n)===Gt(r)&&n.kind===r.kind?a(r??n):U`<span class="bundle-compare-code-readability">${a(n)}<span aria-hidden="true">→</span>${a(r)}</span>`;return U`${s(r??n)}${o}`}_flagTags(e,t,n=!0){let{details:r,at:i}=this._side(e,t);return l(r,i,t.kind===`removed`?t.baseBytes:t.otherBytes,n)}_treeTag(e,t){let{was:n,now:r}=this._reads(e,t),i=r??n;if(!i)return W;let a=i.category!==`map`&&Kt.get(Gt(i)).mark;return U`${s(i,[`warn`])}${a?Mt(i,!0):W}`}_fileFigures({kind:e,baseBytes:t,otherBytes:n},r){return U`${r?.blocks.length>(r?.marked?.size??0)?Hi(r.additions,r.deletions):W} ${r?.renamed>0?U`<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>`:W} <span class="bundle-code-main-stats">${Ri(e,t,n)}</span>`}_highlighted(e,t,n,r=``){if(!n)return null;let i=en(t,di(e,t),n);if(!i)return null;let a=`${t}${r?`\0${r}`:``}`,o=`${e.integrity}\0${a}`,s=rt(Ei,e.integrity)?.get(a);return s?.text===n?s.lines:(Di.has(o)||(Di.add(o),(async()=>{let t=await Ve(n,i),r=typeof t==`string`?We(t):null;(rt(Ei,e.integrity)??Ei.set(e.integrity,new Map).get(e.integrity)).set(a,{text:n,lines:r?.length===n.split(`
17
- `).length?r:null}),at(Ei,Ti),Di.delete(o),this.isConnected&&this.requestUpdate()})()),null)}_renderFile(e,t){let n=this._entries.get(e),r=this._fileState(e,n),{after:i,before:a,textual:o,model:s}=r,c=Gi(n),l=o&&(!c||s?.blocks.length>0),u=this._order.indexOf(e),d=n.kind===`repointed`&&a===void 0?U`<div class="bundle-compare-code-message">Neither bundle carries this importer's source.</div>`:c&&s?.blocks.length===0?this._renderSource(e,i,n.repointed,r):this._fileMessage(e,n,r)??this._renderDiff(e,n,r);return U`<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="${u<=0}" @click="${()=>this._select(this._order[u-1])}">${C}</button> <button type="button" class="focus-code-nav-btn" aria-label="Next file" data-tooltip="Next file" ?disabled="${u===-1?this._order.length===0:u>=this._order.length-1}" @click="${()=>this._select(this._order[u+1])}">${E}</button> </span>${this._fileName(e,n,t,U`<button type="button" class="bundle-code-copy-path" data-copy-path="${e}" aria-label="Copy file path">${b}</button>`)} <span class="bundle-code-main-spacer"></span> ${this._fileFigures(n,s)} ${this._toggles(l,Ni(r),r.renamed,r.whitespace===`hideable`,r.types)}</header><div class="bundle-compare-diff" tabindex="0" aria-label="${`Changes in ${q(e,t)}`}">${this._dependencyChanges(e)} ${n.repointed?this._renderRepointed(e,n.repointed,Vi(r),o&&!l):W} ${d}</div>`}_toggles(e,t=null,n=!1,r=!1,i=!1){return U`${e?this._hides(n,r,i):W} ${t?U`<button type="button" class="${B({"bundle-compare-code-toggle":!0,"is-loading":t.status===`loading`,"is-error":t.status===`error`,"is-folded":xe(t.json)})}" aria-pressed="${String(!!F.bundleSourcePretty)}" aria-busy="${t.status===`loading`?`true`:W}" aria-label="Pretty-print" data-tooltip="${`${ye(t,t.json)}${Fi(t.affects)}`}" @click="${()=>{Oe(t.json),this._viewChanged()}}">${ve}</button>`:W} ${e?U`<span class="bundles-overview-sort bundle-compare-code-layout" role="group" aria-label="Diff layout">${[[`unified`,`Unified`],[`split`,`Split`]].map(([e,t])=>U`<button type="button" aria-pressed="${String(O.layout===e)}" @click="${()=>{O.layout=e,this.requestUpdate()}}">${t}</button>`)}</span>`:W}`}_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 L(this.other).has(e)?this.other:this.base}_dependencyChanges(e){if(e!==`package.json`||!this.dependencies)return W;let t={added:[`new`,`New`],changed:[`updated`,`Updated`],removed:[`removed`,`Removed`]},n=Object.keys(t).flatMap(e=>this.dependencies[e].map(t=>[e,t]));if(n.length===0)return W;let r=Object.entries(t).filter(([e])=>this.dependencies[e].length>0).map(([e,[t]])=>`${this.dependencies[e].length} ${t}`),i=Map.groupBy(n.flatMap(([,e])=>e.flags??[]),({label:e})=>e),a=this.openDependency;return U`<section class="bundle-compare-code-deps" aria-label="Dependency changes"><h4>Dependencies <span>${r.join(` · `)}</span>${[...i].map(([e,t])=>U`<span class="bundle-compare-code-deps-flagged">${t.length} ${e}</span>`)}</h4><ul>${n.map(([e,n])=>{let r=U`<span class="bundle-compare-code-dep-range">${e===`changed`?U`${n.from} → <b>${n.to}</b>`:n.range}</span>`,i=U`<span class="bundle-compare-code-dep-name">${n.name}</span>${n.kind?U`<span class="npm-dependency-kind">${n.kind}</span>`:W}${r}${this.dependencyTags?.(n,e)??W}`,o=`${t[e][1]}: ${n.name}`;return U`<li>${a&&n.opens?U`<button type="button" class="${`bundle-compare-code-dep is-${e}`}" aria-label="${o}" @click="${()=>a(n)}">${i}</button>`:U`<span class="${`bundle-compare-code-dep is-${e}`}" aria-label="${o}">${i}</span>`}</li>`})}</ul></section>`}_renderRepointed(e,t,n,r){let i=n?n.split(`
18
- `):[],a=n?this._highlighted(this._textSide(e),e,n):null,o=this._importLines(t,i),s=e=>e===null?U`<code class="is-none">(none)</code>`:U`<code data-tooltip-truncated data-tooltip="${e||`(empty target)`}">${e||`(empty target)`}</code>`,{title:c}=Wi(t);return U`<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 U`<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,Jr).map(t=>this._importLine(t,i[t],a?.[t],e.specifier,r))} ${t.length>Jr?U`<span class="bundle-compare-code-repointed-more">and ${t.length-Jr} more ${t.length-Jr===1?`line`:`lines`}</span>`:W}</li>`})}</ul></section>`}_importLine(e,t,n,r,i){let a=t.length>240?Math.max(0,t.indexOf(r)-80):0;return U`<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`?cn(Xe(n,!0)):je(`${a>0?`…`:``}${t.slice(a,a+240)}${t.length>a+240?`…`:``}`,!0)}</code></button>`}_goToLine(e){this._reach(`${this._current}\0source`,e-1)&&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&&(this._reach(c,l.line),this._soughtRow={path:e,index:l.line});let u=this._limits.get(c)??X,d=a.b.length>u?a.b.slice(0,u):a.b;return U`<div class="bundle-compare-diff-table single" data-path="${e}" style="${V({"--diff-num-width":`${String(a.b.length).length+1}ch`})}" role="table" aria-label="Source">${H(d,(e,t)=>t,(e,t)=>U`<div class="${B({"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>${this._moreRows(c,u,d.length,a.b.length,`lines`)}`}_moreRows(e,t,n,r,i){return r>n?U`<div class="bundle-compare-code-more">${Q(`Show ${Math.min(X,r-n).toLocaleString()} more ${i}`,()=>{this._limits.set(e,t+X),this.requestUpdate()})} <span>${(r-n).toLocaleString()} not shown</span></div>`:W}_hides(e,t,n){let r=[e&&[`Renames`,ii,O.ignoreRenames,()=>this._setRenames(!O.ignoreRenames)],t&&[`Whitespace`,oi,O.ignoreWhitespace,()=>this._setWhitespace(!O.ignoreWhitespace)],n&&[`Type-only`,ai,O.ignoreTypes,()=>this._setTypes(!O.ignoreTypes)]].filter(Boolean);return r.length===0?W:U`<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])=>U`<mode-switch compact="compact" borderless .checked="${n}" accessible-label="${t}" label="${e}" @click="${r}"></mode-switch>`)}</span>`}_setWhitespace(e){O.ignoreWhitespace=e,this._viewChanged()}_setTypes(e){O.ignoreTypes=e,this._viewChanged()}_setRenames(e){O.ignoreRenames=e,e&&ge(),this._viewChanged()}_viewChanged(){this.requestUpdate(),this.dispatchEvent(new CustomEvent(`compare-view-change`,{bubbles:!0,composed:!0}))}_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=O.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??mr(a,_,{split:p}),y=this._limits.get(i)??X,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)+ir}),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 U`${O.ignoreRenames&&s?.reason?U`<p class="bundle-compare-code-note">Renamed names are shown: ${bi[s.reason]??s.reason}.</p>`:W} ${u===`mixed`?U`<p class="bundle-compare-code-note">${ui}</p>`:W} ${l.length>0?U`<p class="bundle-compare-code-note">${l.join(` `)} <button type="button" @click="${()=>this._setRenames(!1)}">Show them marked</button></p>`:W}<div class="${B({"bundle-compare-diff-table":!0,split:p,unified:!p})}" data-path="${e}" style="${V({"--diff-num-width":`${w+1}ch`})}" role="table" aria-label="Diff">${p?U`<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>`:W} ${H(b,e=>this._rowKey(e),e=>this._row(e,S,p))}</div>${this._moreRows(i,y,b.length,v.length,`rows`)}`}_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(e,t,n){if(t==null||n==null)return null;let r=`${t}:${n}`;return e.words.has(r)||e.words.set(r,vr(e.a[t],e.b[n])),e.words.get(r)}_code(e,t,n,r){let i=r&&!(e.endsWith(`\r`)&&n?.at(-1)?.[1]===e.length);if(typeof t==`string`)return cn(Xe(xr(t,n),i));if(n){let t=Sr(e,n);return t.map((e,n)=>{let r=je(e.text,i&&n===t.length-1);return e.marked?U`<mark class="diff-word">${r}</mark>`:r})}return je(e,i)}_cell(e,t,n,r,i){return n==null?U`<span class="diff-num"></span><span class="diff-sign"></span><span class="diff-code diff-empty"></span>`:U`<span class="diff-num">${ji(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 U`<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> ${Q(`Show type-only changes`,()=>this._setTypes(!1))}</div>`}_fold(e,t){let n=`Show ${ir} more lines`,r=e.count>ir,i=(n,r,i,a)=>U`<button type="button" aria-label="${r}" data-tooltip="${i}" @click="${()=>t.expand(e.run,n)}"><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="${a}"></path></svg></button>`;return U`<div class="diff-row diff-fold" role="row"><span class="diff-fold-actions">${r&&e.down?i(`top`,`${n} below`,n,`M8 3v9m-4-4 4 4 4-4`):W} ${r&&e.up?i(`bottom`,`${n} above`,n,`M8 13V4M4 8l4-4 4 4`):W} <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"></path></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>`}_row(e,t,n){let{model:r}=t;if(e.kind===`fold`)return this._fold(e,t);if(e.kind===`types`)return this._types(e);if(e.kind===`ctx`)return n?U`<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>`:U`<div class="diff-row ctx" role="row"><span class="diff-num">${ji(r,`a`,e.a)}</span>${this._cell(t,`b`,e.b,` `,null)}</div>`;let i=r.marked?.has(e.change),a;if(n){let n=e.paired?this._words(r,e.left,e.right):null;a=U`<span class="${B({"diff-half":!0,del:e.left!==null,blank:e.left===null})}">${this._cell(t,`a`,e.left,`−`,n?.a)}</span> <span class="${B({"diff-half":!0,add:e.right!==null,blank:e.right===null})}">${this._cell(t,`b`,e.right,`+`,n?.b)}</span>`}else{let n=e.kind===`del`,[i,o]=n?[`a`,e.a]:[`b`,e.b],s=ji(r,i,o),c=n?this._words(r,e.a,e.pair)?.a:this._words(r,e.pair,e.b)?.b;a=U`<span class="diff-num">${n?s:W}</span><span class="diff-num">${n?W:s}</span><span class="diff-sign">${n?`−`:`+`}</span>${this._codeCell(t,i,o,c)}`}return U`<div class="${`diff-row ${e.kind}${i?` renamed`:``}`}" role="row" data-tooltip="${i?`Renamed names alone`:W}">${a}</div>`}_codeCell(e,t,n,r){let i=e.model[t],a=e[t]?.[n],o=i[n],s=e.model.noEol[t]&&n===i.length-1,c=Oi.get(i);c||Oi.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)}),U`<span class="${B({"diff-code":!0,"diff-long":o.length>Ae})}">${l.drawn}${s?U`<span class="diff-no-eol" data-tooltip="No newline at end of file" aria-label="No newline at end of file">⊘</span>`:W}</span>`}};customElements.define(`bundle-compare-code`,Zi);var Qi=25e3,$i=40;function ea(e,t,n,{resolutions:r=[],max:i=Qi}={}){let a=new Map,o=Gn(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[...o].toSorted(([e],[t])=>e.localeCompare(t))){c++;let{before:o,after:s}=J(e,t,n,r);if(r.modified===!1)c++;else if(typeof o==`string`&&typeof s==`string`){if(yt(o,s))return{rows:1/0,models:a};let e=or(o,s);a.set(n,e),c+=Math.max(mr(e).length,1)}else c++;if(c>=i)break}return{rows:c,models:a}}var ta=class extends Zi{static properties={...Zi.properties,models:{attribute:!1}};constructor(){super(),this.models=null,this._modelCap=1/0,this._fileLimit=$i}_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}=J(this.base,this.other,e,n);this._models.set(wi(e,!1,{ignoreWhitespace:!1,ignoreRenames:!1}),{inputs:[r,i,null],value:t})}e.has(`files`)&&(this._fileLimit=$i,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+=$i,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,Vi(n),!1):W,i=t.kind===`repointed`||t.kind===`renamed`&&!t.modified&&!!t.repointed&&!t.meta&&!(n.model?.blocks.length>0);return U`${this._dependencyChanges(e)}${r}${i?W:this._fileMessage(e,t,n)??this._renderDiff(e,t,n)}`}_fileContent(e,t,n,r){return U`<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)}`}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)/$i)*$i);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})=>Ni(e)),l=c.map(({file:e})=>Ni(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,this._current,U`<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?Hi(o,s):W} <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?U`<div class="bundle-code-placeholder">${this._entries.size===0?`No files differ in this comparison.`:`No changed files match.`}</div>`:H(a.slice(0,this._fileLimit),({path:e})=>e,({path:e,entry:n,file:r})=>U`<section class="bundle-compare-all-file" aria-label="${e}" data-path="${e}">${this.extensions?.fileActions?U`<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?U`<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>`:W}</div>`)}};customElements.define(`bundle-compare-all`,ta);function na({base:e,other:t,diff:n,source:r,path:i,seek:a,baseName:o,otherName:s,select:c,extensions:l=null,mode:u,viewChanged:d=null}){let f=Jn(n.resolutions),p=u?null:n.combined??=ea(e,t,n.files,{resolutions:f});u??=p.rows<Qi?`diff`:`code`;let m=u===`diff`?le`bundle-compare-all`:le`bundle-compare-code`;return pe`<${m} .base=${e} .other=${t} .files=${n.files} .scope=${n.scope??``} .resolutions=${f}
16
+ 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 U`<span class="bundle-compare-code-line-counts unchanged" aria-label="No line changes">=</span>`;if(r&&o)return U`<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 U`<span class="bundle-compare-code-line-counts" aria-label="${`${i} added, ${a} removed lines`}" data-tooltip="${d?`With ${u}`:W}"><span class="${B({add:!0,empty:s&&i===0})}">+${i.toLocaleString()}</span> <span class="${B({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(!(N.bundleSourcePretty||k.ignoreWhitespace||k.ignoreRenames||k.ignoreTypes))return null;let n=`${fi(e)}\0${this._arrived}\0${this._forced.size}`,r=this._drawnCounts.get(e);if(r?.settings===n)return r.counts;if(this._spent())return;let i=this._countingState(e,t),a=i.model&&pi(i).length>0?mi(i.model,i):null;return this._drawnCounts.set(e,{settings:n,counts:a}),a}_lineCounts(e,t){if(this._counted.has(e))return this._counted.get(e);if(this._spent())return null;let{before:n,after:r}=J(this.base,this.other,e,t),i=gr(n,r);return this._counted.set(e,i),i}_noteDrawn(e,t){return t.model&&this._drawnTotals.set(e,{settings:fi(e),counts:mi(t.model,t)}),t}_largeCounts(e,t){let n=this._drawnTotals.get(e);if(n?.settings===fi(e))return n.counts.aside.length===0?{published:n.counts,shown:null}:{published:null,shown:n.counts};let r=k.ignoreTypes?J(this.base,this.other,e,t):null;return{published:null,shown:typeof r?.before==`string`&&typeof r.after==`string`&&Gr(this.base,this.other,e,t,r,this._repaint,this.scope)===!0?{additions:0,deletions:0,renamed:0,aside:[ui]}:null}}_model(e,t,n,r={},i=k.ignoreWhitespace){return Z(this._models,e,[t,n,r.changes?.blocks??r.marks??null],()=>dr(t,n,{...r,ignoreWhitespace:i}),this._modelCap)}_counts(e,t,n,r,i){return Z(this._countModels,e,[t,n,r.changes?.blocks??r.marks??null],()=>{let e=r.changes?.blocks??wt(t,n,i);return{blocks:e,...Nt(e,r.marks)}})}_fileState(e,t,n=!1){let r=J(this.base,this.other,e,t),i=typeof r.before==`string`&&typeof r.after==`string`,a=i?Gr(this.base,this.other,e,t,r,this._repaint,this.scope):void 0,o=a===!0,s=(t=null,a=null)=>{let o={a:[],b:[],blocks:[],additions:0,deletions:0,renamed:0,marked:new Set,noEol:{a:!1,b:!1},words:new Map};return n?{pretty:a,hiding:!1,model:o,spacesHidden:!1,typesHidden:!0}:this._noteDrawn(e,{...r,textual:i,large:!1,printing:t,pretty:a,key:null,generated:!1,renamed:!1,warned:[],hiding:!1,changes:null,model:o,whitespace:null,spacesHidden:!1,types:!0,typesHidden:!0})};if(o&&k.ignoreTypes)return s();let c=a&&a!==!0?Fi(a,r):null,l=i&&(!n||N.bundleSourcePretty)?this._printing(e,t,r,!n):null,u=this._byPrinted(e,t,r,c,l),d=c&&k.ignoreTypes&&l?{...l,applies:!!u}:l,f=N.bundleSourcePretty&&d?.applies?d.copies:null;if(f&&u?.folds===!1)return s(d,f);let p=f&&u?u.folds:c,m=!!p&&k.ignoreTypes,{before:h,after:g}=m?p:f?.status===`ready`?f:r,_=i&&[`ready`,`loading`,`error`].includes(f?.status)&&this._generated(e,t,r),v=_&&f.status===`ready`;!n&&i&&this._sought?.path===e&&!this._forced.has(e)&&this._large(e,h,g)&&this._forced.add(e);let y=i&&!this._forced.has(e)&&this._large(e,h,g),{basePath:b=e}=t,x=t=>{let a=v&&!y?be(this.base,b,r.before,this.other,e,r.after,!1,this._repaint,f.hashes,!n&&this._renamesAlone,this.scope):null,o=a?.status===`ready`&&k.ignoreRenames&&!(a.holds??=Rt(a.before,g,a.blocks))?Ei:a,s=o?.status===`ready`,c=s&&k.ignoreRenames,l=s&&!c,u=c&&o.reason===null?Oi(o):[],d=s&&o.reason===null?o.marks.length>0||k.ignoreRenames&&o.before!==h:k.ignoreRenames&&_,x=`${ki(e,f?.status===`ready`,{...k,ignoreWhitespace:t,ignoreRenames:c,markRenames:l})}${m?`\0types`:``}`,S=c?o.before:h,C=c?t?{}:{changes:{blocks:o.blocks}}:l?{marks:o.marks}:{},w=i&&!y&&(!o||s||!k.ignoreRenames)?n?this._counts(x,S,g,C,t):this._model(x,S,g,C,t):null;return m&&w&&(w.typeFolds=p),{key:x,changes:o,warned:u,renamed:d,hiding:c,shown:S,model:w,ignoreWhitespace:t}},S=this._unlisted(e,t,r),C=x(k.ignoreWhitespace&&!S&&`leading`),w=!!C.ignoreWhitespace&&!!C.model&&(C.model.mixed??=Ht(C.shown,g,C.model.blocks));w&&(C=x(!1));let{key:T,changes:E,warned:D,renamed:ee,hiding:te,shown:ne,model:O}=C;if(d?.map&&f?.status===`ready`&&O&&(Object.hasOwn(O,`listingRefusal`)||(O.listingRefusal=Ie(this.base,this.other,b,e,r,{a:O.a??j(ne),b:O.b??j(g),blocks:O.blocks})),O.listingRefusal!==null))return this._unrebuilt.set(`${b}\0${e}`,{status:`error`,message:`Its listings' diff wouldn't show every change: ${O.listingRefusal}`,retry:!1}),this._fileState(e,t,n);if(n)return{pretty:f,hiding:te,model:O,spacesHidden:C.ignoreWhitespace,typesFolded:m};f?.status===`ready`&&O?this._noteRowless(e,O.blocks.length===0):O&&!m&&(this._blocks.set(`${k.ignoreWhitespace}\0${e}`,O.blocks),this._aligned.set(O.blocks,O));let re=O&&!S&&!k.ignoreWhitespace?this._whitespaceHidden(`${e}\0${f?.status===`ready`}\0${te}${m?`\0types`:``}`,ne,g):null,ie=O===null||S?null:w?`mixed`:k.ignoreWhitespace?Ji(O,ne,g)?`hideable`:null:re.hides&&!re.mixed?`hideable`:null;return this._sought?.path===e&&(this._soughtSettling=f?.status===`loading`||k.ignoreRenames&&(E?.status===`loading`||E?.status===`error`)),this._noteDrawn(e,{...m?{before:p.whole.a,after:p.whole.b}:{before:ne,after:g},textual:i,large:y,printing:d,pretty:f,key:T,generated:_,renamed:ee,warned:D,hiding:te,changes:E,model:O,whitespace:ie,spacesHidden:C.ignoreWhitespace,types:o||!!c,typesFolded:m})}_unlisted(e,{basePath:t=e},{before:n,after:r}){return!sr(e,r,gi(this.other,e))||!sr(t,n,gi(this.base,t))}_whitespaceHidden(e,t,n){return Z(this._spaced,e,[t,n],()=>vr(t,n),this._modelCap)}_generated(e,{kind:t,basePath:n=e},{before:r,after:i}){return t!==`repointed`&&_i(e)&&_i(n)&&ve(this.base,this.other)&&vi(this.base,n,r)&&vi(this.other,e,i)}_printing(e,t,n,i=!1){let{kind:a,basePath:o=e,modified:s}=t,{before:c,after:l}=n;if(a===`repointed`||s===!1||typeof c!=`string`||typeof l!=`string`||c===l)return null;let u=[[`base`,this.base,o,c],[`other`,this.other,e,l]];if(!u.every(([e,,t,n])=>n===``||Ne(this.base,this.other,e,t,n)))return null;let d=u.every(([,,e,t])=>t===``||dt(e)),f=u.every(([,,e,t])=>t===``||r(e)),p=!d&&!f&&u.some(([,e,t,n])=>n!==``&&vi(e,t,n)),m=u.map(([e,,t,n])=>n===``?{status:`ready`,text:n}:Pe(this.base,this.other,e,t,n,this._repaint)),h=this._unrebuilt.get(`${o}\0${e}`)??m.find(e=>e.status===`error`)??m.find(e=>e.status===`loading`)??m.find(e=>e.status===`off`)??{status:`ready`,...this._drawn(e,t,n,m),hashes:m.map(e=>e.hash),made:m.map(e=>e.text),runs:jt(...m)},g=!d&&!f&&!p&&c!==``&&l!==``&&h.status===`ready`&&this._smaller(e,t,n,h);return{copies:h,json:d,folds:i&&d&&N.bundleSourcePretty===`indented`&&h.status===`ready`&&this._folds(e,t,n,u),map:f,minified:p,smaller:g,applies:d||f||p||g}}_folds(e,t,n,r){if(!r.every(([,,e])=>pt(e)))return!1;let i=r.map(([,e,t,n])=>n===``?[``,``]:Me(e,t,n));if(i.includes(null))return!1;let a=k.ignoreWhitespace&&!this._unlisted(e,t,n)&&`leading`;return Z(this._folding,`${e}\0${a}`,i.flat(),()=>ht(i,(e,t)=>F(e,t)?null:Ft(e,t,a).lines))}_drawn(e,t,n,[r,i]){return this._generated(e,t,n)?{before:r.text,after:i.text}:Z(this._shared,e,[r.text,i.text,r.blank,i.blank],()=>Dt(r.text,i.text,r.blank??[],i.blank??[]))}_large(e,t,n){return Z(this._larges,e,[t,n],()=>F(t,n))}_smaller(e,t,n,r,i=null){let a=k.ignoreWhitespace&&!this._unlisted(e,t,n)&&`leading`,{before:o,after:s}=i??n;return Z(this._shorter,`${e}\0${a}${i?`\0types`:``}`,[o,s,r.before,r.after],()=>{if(F(o,s)||F(r.before,r.after))return!1;let e=Ft(r.before,r.after,a),t=Ft(o,s,a);return e.lines<t.lines||e.lines===t.lines&&e.marks<t.marks})}_fileMessage(e,{kind:t,modified:r,meta:i,basePath:a=e},{before:o,after:s,textual:c,large:l,model:u,pretty:d,hiding:f,warned:p=[],changes:m,whitespace:h,typesHidden:g=!1,typesFolded:_=!1}){let v=Yr(i),y=e=>`${e}${v?` ${v}`:``}`,b=y(t===`renamed`?v?`Renamed, its contents the same.`:`Renamed without changes.`:`The contents are the same.`);if(c&&r===!1)return Vi(`same`,b);if(!c&&[o,s].some(e=>Wi(e)!==void 0)){let[n,r]=[t===`added`?`nothing`:Gi(a,o),t===`removed`?`nothing`:Gi(e,s)];return U`<div class="bundle-compare-code-message">Was ${n}; now ${r}.${v?` ${v}`:``}</div>`}if(!c){let n=[o,s].some(e=>e?.format===`digest`)&&Yt(e),i=n?`Code that isn't text`:`Binary file`;if(t===`changed`&&r===!1)return U`<div class="bundle-compare-code-message">${i}, its bytes the same · ${Hi(R(s))}. ${v}</div>`;let a=n?` It is not UTF-8, or holds a NUL, so it is shown as no text, yet node runs it all the same, decoded as UTF-8.`:``;return U`<div class="bundle-compare-code-message">${i} ${t} · ${Ui(t,R(o),R(s))}. A text diff is not available.${a}${v?` ${v}`:``}</div>`}if(l)return Vi(`large`,U`This diff is large (${(Li(o)+Li(s)).toLocaleString()} lines across both sides) and may take a few seconds to compute.`,Q(`Show diff`,()=>{this._forced.add(e),this.requestUpdate()}));let x=Q(`Show renamed names`,()=>this._setRenames(!1)),S=Q(`Show type-only changes`,()=>this._setTypes(!1));if(g)return Vi(`types`,U`Only types changed in this file.${v?` ${v}`:``}`,S);if(m?.status===`loading`&&k.ignoreRenames)return U`<div class="bundle-compare-code-message" aria-busy="true">Hiding renamed names…</div>`;if(m?.status===`error`&&k.ignoreRenames)return Vi(`renames`,U`Couldn't hide renamed names: ${m.message}`,x);if(u.blocks.length>0)return null;let C=d?.status===`ready`&&d.before===d.after,w=!C&&k.ignoreWhitespace&&h===`hideable`,T=!C&&f,E=[_&&`types`,w&&`whitespace`,T&&`renamed names`].filter(Boolean),D=C?`No actual code changes in this file.`:E.length>0?`Only ${E.join(` and `)} changed in this file.`:null;return Vi(`told`,D?y(D):b,p.map(e=>U`<p>${e}</p>`),C?Q(`Show as published`,()=>{n(!1),this._viewChanged()}):W,_?S:W,w?Q(`Show whitespace changes`,()=>this._setWhitespace(!1)):W,T?x:W)}_fileName(e,t,n,r=W){let i=e=>q(e,n);return U`<span class="${B({"bundle-compare-code-pill":!0,[t.kind]:!0,pure:t.kind===`renamed`&&!t.modified})}">${Zr[t.kind].label}</span> ${an(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?Jn(i(t.renamedFrom),i(e)):i(e)}</span> ${r}${this._githubLink(e,t)}${this._fileTags(e,t)}`}_side(e,{kind:t,basePath:n=e}){return t===`removed`?{details:this.base,at:n,alerts:this.baseAlerts}:{details:this.other,at:e,alerts:this.otherAlerts}}_fileTags(e,t,n=!1){if(!n)return U`${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)}${qr(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),qr(t.meta,!0)];return Zi(r)?r:this._flagTags(e,t)}_githubLink(e,t){let{details:n,at:r}=this._side(e,t),i=nt(n,r);return i?at(i):W}_alertTags(e,t){let{alerts:n,at:r}=this._side(e,t),i=n?.get(r);return i?.length>0&&this.alertTags?this.alertTags(i):W}_newHostTags(e,{kind:t}){let n=t===`removed`?null:this.newHosts?.get(e);return n&&this.newHostTag?this.newHostTag(n):W}_runsTags(e,t){return[[he,_e],[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,t){let{details:n,at:r}=this._side(e,t);return[...Map.groupBy(xi(n).get(r)??[],({label:e})=>e)].map(([e,t])=>U`<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(!Si.test(e))return W;let{kind:r,basePath:i=e}=t,{before:a,after:o}=J(this.base,this.other,e,t),s=new Map(r===`added`||a===void 0?[]:wi(this.base,i,a)),c=new Map(r===`removed`||o===void 0?[]:wi(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 U`<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(U`<span class="bundle-compare-code-install is-dropped" data-tooltip="${`No longer run on install: ${t}`}">${e}</span>`);return l}_reads(e,t,n=i){let{kind:r,basePath:a=e}=t,{before:o,after:s}=J(this.base,this.other,e,t);return{was:r===`added`?null:o===void 0?void 0:n(this.base,a,o),now:r===`removed`||s===void 0?null:n(this.other,e,s)}}_readability(e,t){let{was:n,now:r}=this._reads(e,t),i=e=>U`${s(e)}${u(e)}`,a=!n||!r||Xt(n)===Xt(r)&&n.kind===r.kind?i(r??n):U`<span class="bundle-compare-code-readability">${i(n)}<span aria-hidden="true">→</span>${i(r)}</span>`;return U`${m(r??n)}${a}`}_flagTags(e,t,n=!0){let{details:r,at:i}=this._side(e,t);return y(r,i,t.kind===`removed`?t.baseBytes:t.otherBytes,n)}_treeTag(e,t){let{was:n,now:r}=this._reads(e,t),i=r??n;if(!i)return W;let a=i.category!==`map`&&Zt.get(Xt(i)).mark;return U`${m(i,[`warn`])}${a?s(i,!0):W}`}_fileFigures({kind:e,baseBytes:t,otherBytes:n},r){return U`${r?.blocks.length>(r?.marked?.size??0)?qi(r.additions,r.deletions):W} ${r?.renamed>0?U`<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>`:W} <span class="bundle-code-main-stats">${Ui(e,t,n)}</span>`}_highlighted(e,t,n,r=``){if(!n)return null;let i=on(t,gi(e,t),n);if(!i)return null;let a=`${t}${r?`\0${r}`:``}`,o=`${e.integrity}\0${a}`,s=st(ji,e.integrity)?.get(a);return s?.text===n?s.lines:(Mi.has(o)||(Mi.add(o),(async()=>{let t=await He(n,i),r=typeof t==`string`?We(t):null;(st(ji,e.integrity)??ji.set(e.integrity,new Map).get(e.integrity)).set(a,{text:n,lines:r?.length===n.split(`
17
+ `).length?r:null}),lt(ji,Ai),Mi.delete(o),this.isConnected&&this.requestUpdate()})()),null)}_renderFile(e,t){let n=this._entries.get(e),r=this._fileState(e,n),{after:i,before:a,textual:o,model:s}=r,c=Xi(n),l=o&&(!c||s?.blocks.length>0),u=this._order.indexOf(e),d=n.kind===`repointed`&&a===void 0?U`<div class="bundle-compare-code-message">Neither bundle carries this importer's source.</div>`:c&&s?.blocks.length===0?this._renderSource(e,i,n.repointed,r):this._fileMessage(e,n,r)??this._renderDiff(e,n,r);return U`<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="${u<=0}" @click="${()=>this._select(this._order[u-1])}">${S}</button> <button type="button" class="focus-code-nav-btn" aria-label="Next file" data-tooltip="Next file" ?disabled="${u===-1?this._order.length===0:u>=this._order.length-1}" @click="${()=>this._select(this._order[u+1])}">${E}</button> </span>${this._fileName(e,n,t,U`<button type="button" class="bundle-code-copy-path" data-copy-path="${e}" aria-label="Copy file path">${v}</button>`)} <span class="bundle-code-main-spacer"></span> ${this._fileFigures(n,s)} ${this._toggles(l,Ri(r),r.renamed,r.whitespace===`hideable`,r.types)}</header><div class="bundle-compare-diff" tabindex="0" aria-label="${`Changes in ${q(e,t)}`}">${this._dependencyChanges(e)} ${n.repointed?this._renderRepointed(e,n.repointed,Ki(r),o&&!l):W} ${d}</div>`}_toggles(e,t=null,n=!1,r=!1,i=!1){return U`${e?this._hides(n,r,i):W} ${t?U`<button type="button" class="${B({"bundle-compare-code-toggle":!0,"is-loading":t.status===`loading`,"is-error":t.status===`error`,"is-folded":Oe(t.json)})}" aria-pressed="${String(!!N.bundleSourcePretty)}" aria-busy="${t.status===`loading`?`true`:W}" aria-label="Pretty-print" data-tooltip="${`${De(t,t.json,t.folds)}${Bi(t.affects)}`}" @click="${()=>{Re(t.folds),this._viewChanged()}}">${we}</button>`:W} ${e?U`<span class="bundles-overview-sort bundle-compare-code-layout" role="group" aria-label="Diff layout">${[[`unified`,`Unified`],[`split`,`Split`]].map(([e,t])=>U`<button type="button" aria-pressed="${String(k.layout===e)}" @click="${()=>{k.layout=e,this.requestUpdate()}}">${t}</button>`)}</span>`:W}`}_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 L(this.other).has(e)?this.other:this.base}_dependencyChanges(e){if(e!==`package.json`||!this.dependencies)return W;let t={added:[`new`,`New`],changed:[`updated`,`Updated`],removed:[`removed`,`Removed`]},n=Object.keys(t).flatMap(e=>this.dependencies[e].map(t=>[e,t]));if(n.length===0)return W;let r=Object.entries(t).filter(([e])=>this.dependencies[e].length>0).map(([e,[t]])=>`${this.dependencies[e].length} ${t}`),i=Map.groupBy(n.flatMap(([,e])=>e.flags??[]),({label:e})=>e),a=this.openDependency;return U`<section class="bundle-compare-code-deps" aria-label="Dependency changes"><h4>Dependencies <span>${r.join(` · `)}</span>${[...i].map(([e,t])=>U`<span class="bundle-compare-code-deps-flagged">${t.length} ${e}</span>`)}</h4><ul>${n.map(([e,n])=>{let r=U`<span class="bundle-compare-code-dep-range">${e===`changed`?U`${n.from} → <b>${n.to}</b>`:n.range}</span>`,i=U`<span class="bundle-compare-code-dep-name">${n.name}</span>${n.kind?U`<span class="npm-dependency-kind">${n.kind}</span>`:W}${r}${this.dependencyTags?.(n,e)??W}`,o=`${t[e][1]}: ${n.name}`;return U`<li>${a&&n.opens?U`<button type="button" class="${`bundle-compare-code-dep is-${e}`}" aria-label="${o}" @click="${()=>a(n)}">${i}</button>`:U`<span class="${`bundle-compare-code-dep is-${e}`}" aria-label="${o}">${i}</span>`}</li>`})}</ul></section>`}_renderRepointed(e,t,n,r){let i=n?n.split(`
18
+ `):[],a=n?this._highlighted(this._textSide(e),e,n):null,o=this._importLines(t,i),s=e=>e===null?U`<code class="is-none">(none)</code>`:U`<code data-tooltip-truncated data-tooltip="${e||`(empty target)`}">${e||`(empty target)`}</code>`,{title:c}=Yi(t);return U`<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 U`<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,$r).map(t=>this._importLine(t,i[t],a?.[t],e.specifier,r))} ${t.length>$r?U`<span class="bundle-compare-code-repointed-more">and ${t.length-$r} more ${t.length-$r===1?`line`:`lines`}</span>`:W}</li>`})}</ul></section>`}_importLine(e,t,n,r,i){let a=t.length>240?Math.max(0,t.indexOf(r)-80):0;return U`<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`?pn(Qe(n,!0)):Le(`${a>0?`…`:``}${t.slice(a,a+240)}${t.length>a+240?`…`:``}`,!0)}</code></button>`}_goToLine(e){this._reach(`${this._current}\0source`,e-1)&&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&&(this._reach(c,l.line),this._soughtRow={path:e,index:l.line});let u=this._limits.get(c)??X,d=a.b.length>u?a.b.slice(0,u):a.b;return U`<div class="bundle-compare-diff-table single" data-path="${e}" style="${V({"--diff-num-width":`${String(a.b.length).length+1}ch`})}" role="table" aria-label="Source">${H(d,(e,t)=>t,(e,t)=>U`<div class="${B({"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>${this._moreRows(c,u,d.length,a.b.length,`lines`)}`}_moreRows(e,t,n,r,i){return r>n?U`<div class="bundle-compare-code-more">${Q(`Show ${Math.min(X,r-n).toLocaleString()} more ${i}`,()=>{this._limits.set(e,t+X),this.requestUpdate()})} <span>${(r-n).toLocaleString()} not shown</span></div>`:W}_hides(e,t,n){let r=[e&&[`Renames`,li,k.ignoreRenames,()=>this._setRenames(!k.ignoreRenames)],t&&[`Whitespace`,di,k.ignoreWhitespace,()=>this._setWhitespace(!k.ignoreWhitespace)],n&&[`Type-only`,ui,k.ignoreTypes,()=>this._setTypes(!k.ignoreTypes)]].filter(Boolean);return r.length===0?W:U`<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])=>U`<mode-switch compact="compact" borderless .checked="${n}" accessible-label="${t}" label="${e}" @click="${r}"></mode-switch>`)}</span>`}_setWhitespace(e){k.ignoreWhitespace=e,this._viewChanged()}_setTypes(e){k.ignoreTypes=e,this._viewChanged()}_setRenames(e){k.ignoreRenames=e,e&&Se(),this._viewChanged()}_viewChanged(){this.requestUpdate(),this.dispatchEvent(new CustomEvent(`compare-view-change`,{bubbles:!0,composed:!0}))}_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=k.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??yr(a,_,{split:p}),y=this._limits.get(i)??X,b=v.length>y?v.slice(0,y):v,x=(e,t)=>e&&h?h.lineOf[t].map(t=>e[t]):e,S=o?.status===`ready`?`pretty${h?`\0whole`:``}`:``,C={model:a,a:d===`added`?null:x(this._highlighted(this.base,f,r,c?`renamed\0${this.other.integrity}\0${e}`:S),`a`),b:d===`removed`?null:x(this._highlighted(this.other,e,n,S),`b`),expand:(e,t)=>{let n=new Map(_);n.set(e,t===`all`?{all:!0}:{...n.get(e),[t]:(n.get(e)?.[t]??0)+lr}),this._expansions.set(i,n),this.requestUpdate()}},w=h?.lines??{a:a.a.length,b:a.b.length},T=String(Math.max(w.a,w.b,1)).length;return U`${k.ignoreRenames&&s?.reason?U`<p class="bundle-compare-code-note">Renamed names are shown: ${Ti[s.reason]??s.reason}.</p>`:W} ${u===`mixed`?U`<p class="bundle-compare-code-note">${hi}</p>`:W} ${l.length>0?U`<p class="bundle-compare-code-note">${l.join(` `)} <button type="button" @click="${()=>this._setRenames(!1)}">Show them marked</button></p>`:W}<div class="${B({"bundle-compare-diff-table":!0,split:p,unified:!p})}" data-path="${e}" style="${V({"--diff-num-width":`${T+1}ch`})}" role="table" aria-label="Diff">${p?U`<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>`:W} ${H(b,e=>this._rowKey(e),e=>this._row(e,C,p))}</div>${this._moreRows(i,y,b.length,v.length,`rows`)}`}_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(e,t,n){if(t==null||n==null)return null;let r=`${t}:${n}`;return e.words.has(r)||e.words.set(r,Cr(e.a[t],e.b[n])),e.words.get(r)}_code(e,t,n,r){let i=r&&!(e.endsWith(`\r`)&&n?.at(-1)?.[1]===e.length);if(typeof t==`string`)return pn(Qe(Er(t,n),i));if(n){let t=Dr(e,n);return t.map((e,n)=>{let r=Le(e.text,i&&n===t.length-1);return e.marked?U`<mark class="diff-word">${r}</mark>`:r})}return Le(e,i)}_cell(e,t,n,r,i){return n==null?U`<span class="diff-num"></span><span class="diff-sign"></span><span class="diff-code diff-empty"></span>`:U`<span class="diff-num">${Ii(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 U`<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> ${Q(`Show type-only changes`,()=>this._setTypes(!1))}</div>`}_fold(e,t){let n=`Show ${lr} more lines`,r=e.count>lr,i=(n,r,i,a)=>U`<button type="button" aria-label="${r}" data-tooltip="${i}" @click="${()=>t.expand(e.run,n)}"><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="${a}"></path></svg></button>`;return U`<div class="diff-row diff-fold" role="row"><span class="diff-fold-actions">${r&&e.down?i(`top`,`${n} below`,n,`M8 3v9m-4-4 4 4 4-4`):W} ${r&&e.up?i(`bottom`,`${n} above`,n,`M8 13V4M4 8l4-4 4 4`):W} <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"></path></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>`}_row(e,t,n){let{model:r}=t;if(e.kind===`fold`)return this._fold(e,t);if(e.kind===`types`)return this._types(e);if(e.kind===`ctx`)return n?U`<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>`:U`<div class="diff-row ctx" role="row"><span class="diff-num">${Ii(r,`a`,e.a)}</span>${this._cell(t,`b`,e.b,` `,null)}</div>`;let i=r.marked?.has(e.change),a;if(n){let n=e.paired?this._words(r,e.left,e.right):null;a=U`<span class="${B({"diff-half":!0,del:e.left!==null,blank:e.left===null})}">${this._cell(t,`a`,e.left,`−`,n?.a)}</span> <span class="${B({"diff-half":!0,add:e.right!==null,blank:e.right===null})}">${this._cell(t,`b`,e.right,`+`,n?.b)}</span>`}else{let n=e.kind===`del`,[i,o]=n?[`a`,e.a]:[`b`,e.b],s=Ii(r,i,o),c=n?this._words(r,e.a,e.pair)?.a:this._words(r,e.pair,e.b)?.b;a=U`<span class="diff-num">${n?s:W}</span><span class="diff-num">${n?W:s}</span><span class="diff-sign">${n?`−`:`+`}</span>${this._codeCell(t,i,o,c)}`}return U`<div class="${`diff-row ${e.kind}${i?` renamed`:``}`}" role="row" data-tooltip="${i?`Renamed names alone`:W}">${a}</div>`}_codeCell(e,t,n,r){let i=e.model[t],a=e[t]?.[n],o=i[n],s=e.model.noEol[t]&&n===i.length-1,c=Ni.get(i);c||Ni.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)}),U`<span class="${B({"diff-code":!0,"diff-long":o.length>Fe})}">${l.drawn}${s?U`<span class="diff-no-eol" data-tooltip="No newline at end of file" aria-label="No newline at end of file">⊘</span>`:W}</span>`}};customElements.define(`bundle-compare-code`,na);var ra=25e3,ia=40;function aa(e,t,n,{resolutions:r=[],max:i=ra}={}){let a=new Map,o=Xn(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[...o].toSorted(([e],[t])=>e.localeCompare(t))){c++;let{before:o,after:s}=J(e,t,n,r);if(r.modified===!1)c++;else if(typeof o==`string`&&typeof s==`string`){if(F(o,s))return{rows:1/0,models:a};let e=dr(o,s);a.set(n,e),c+=Math.max(yr(e).length,1)}else c++;if(c>=i)break}return{rows:c,models:a}}var oa=class extends na{static properties={...na.properties,models:{attribute:!1}};constructor(){super(),this.models=null,this._modelCap=1/0,this._fileLimit=ia}_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}=J(this.base,this.other,e,n);this._models.set(ki(e,!1,{ignoreWhitespace:!1,ignoreRenames:!1}),{inputs:[r,i,null],value:t})}e.has(`files`)&&(this._fileLimit=ia,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+=ia,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,Ki(n),!1):W,i=t.kind===`repointed`||t.kind===`renamed`&&!t.modified&&!!t.repointed&&!t.meta&&!(n.model?.blocks.length>0);return U`${this._dependencyChanges(e)}${r}${i?W:this._fileMessage(e,t,n)??this._renderDiff(e,t,n)}`}_fileContent(e,t,n,r){return U`<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)}`}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)/ia)*ia);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})=>Ri(e)),l=c.map(({file:e})=>Ri(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),folds:l.some(e=>e.folds),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,this._current,U`<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?qi(o,s):W} <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?U`<div class="bundle-code-placeholder">${this._entries.size===0?`No files differ in this comparison.`:`No changed files match.`}</div>`:H(a.slice(0,this._fileLimit),({path:e})=>e,({path:e,entry:n,file:r})=>U`<section class="bundle-compare-all-file" aria-label="${e}" data-path="${e}">${this.extensions?.fileActions?U`<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?U`<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>`:W}</div>`)}};customElements.define(`bundle-compare-all`,oa);function sa({base:e,other:t,diff:n,source:r,path:i,seek:a,baseName:o,otherName:s,select:c,extensions:l=null,mode:u,viewChanged:d=null}){let f=$n(n.resolutions),p=u?null:n.combined??=aa(e,t,n.files,{resolutions:f});u??=p.rows<ra?`diff`:`code`;let m=u===`diff`?le`bundle-compare-all`:le`bundle-compare-code`;return fe`<${m} .base=${e} .other=${t} .files=${n.files} .scope=${n.scope??``} .resolutions=${f}
19
19
  .baseAlerts=${r?.files?.alerts?.(e)??null} .otherAlerts=${r?.files?.alerts?.(t)??null} .alertTags=${r?.files?.alertTags??null}
20
20
  .newHosts=${r?.files?.newHosts?.(e,t)??null} .newHostTag=${r?.files?.newHostTag??null}
21
21
  .dependencies=${r?.dependencies?.(e,t)??null} .openDependency=${r?.openDependency??null} .dependencyTags=${r?.dependencyTags??null}
22
22
  .models=${p?.models??null} .path=${i} .seek=${a} .extensions=${l} baseName=${o} otherName=${s}
23
23
  @compare-code-select=${e=>{e.stopPropagation(),c(e.detail.path)}}
24
- @compare-view-change=${e=>{e.stopPropagation(),d?.()}}></${m}>`}var ra=400,ia=24,aa=[`removed`,`added`,`changed`],oa=null,sa=(e,t,n,r,i=null)=>U`<span class="bundle-compare-ver" aria-label="${e}"><span class="bundle-compare-ver-from">${t}</span> <span class="bundle-compare-ver-arrow" aria-hidden="true">→</span> <span class="${`bundle-compare-ver-to ${r}`}">${n}</span>${i?[` `,U`<span class="${`bundle-compare-ver-dir ${r}`}" aria-hidden="true">${i}</span>`]:W}</span>`,ca=class extends G{static properties={details:{attribute:!1},integrity:{attribute:!1},request:{attribute:!1},source:{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(t){t.has(`source`)&&this.source&&!t.get(`source`)&&(this._openSections=new Set([...this._openSections,`files`])),(t.has(`_otherDetails`)||t.has(`details`))&&this._status===`ready`&&!e(this._otherDetails,this.details).some(e=>e.id===this._scope)&&(this._scope=``),t.has(`integrity`)&&this._rebase(),(t.has(`request`)||t.has(`integrity`))&&this.integrity&&this.request?.bundle===this.integrity?(this.request.target!==this._targetIntegrity&&this._choose(this.request.target),this._mode=dn(this.request.mode)):t.has(`request`)&&!t.has(`integrity`)&&t.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,t=e&&oa?.base===e?oa:null;e&&(oa=null),t&&(this._mode=t.mode),this._scope=t?t.scope:``,this._codePath=t?t.codePath:null;let n=t?.target||null;this._targetIntegrity=n;let r=n&&!this.source?u(n,e=>!!(e.json||e.bundle)):null;this._otherDetails=r,this._status=r?`ready`:n?`loading`:`idle`,n&&!r&&this._loadOther(n)}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&&!we(F.bundles??[],this.integrity).some(t=>t.integrity===e))return;if(oa={base:e,target:t,scope:this._scope,mode:this._mode,codePath:this._codePath},this.source){this.source.open(e,t,this._mode);return}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):(F.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){let t=this.source?null:we(F.bundles??[],this.integrity).find(t=>t.integrity===e);if(!this.source&&!t){this._status=`idle`,this._targetIntegrity=null,this._notify();return}let n;try{n=await(this.source?this.source.load(e):p(e,t))}catch(e){if(e.name===`AbortError`)return;if(!this.source)throw e;n={error:e.message}}this._targetIntegrity===e&&(this._otherDetails=n,this._status=`ready`,this.source&&n?.compareId&&n.compareId!==e&&(this._targetIntegrity=n.compareId,this._notify()))}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)}_group(e,t,n,r,i,a=W,{fill:o=!1,lanes:s=aa,style:c={}}={}){return t.length===0?W:U`<section class="${`bundle-compare-group bundle-compare-${n}`}" style="${V({"--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`}">${H(t,r,i)}</ul></section>`}_sizeCells(e){let t=e=>e==null?`—`:z(e),n=e=>`${e.toLocaleString()} LoC`;return e.delta===void 0?U`<span class="bundle-compare-row-size" data-tooltip="${e.lines>0?n(e.lines):W}">${t(e.bytes)}</span>`:U`<span class="${`bundle-compare-row-delta ${e.delta===null?``:vn(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?`—`:_n(e.delta)}</span>`}_sortActions(e,t,n,r=!1,i=this[e][t]){return U`<span class="bundles-overview-sort" role="group" aria-label="${`${t} ${n} order`}">${[[`name`,`Name`],[`size`,`Size`],...r?[[`flags`,`Flags`]]:[]].map(([n,r])=>U`<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)):[],...Ur(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`?he(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=>U`<li><button type="button" class="bundle-compare-row bundle-compare-row-link" @click="${()=>this._openFile(e.path)}">${a?a.icon(e.path,[[this._otherDetails,e.basePath??e.path],[this.details,e.path]]):W}<span class="bundle-compare-row-path mono" data-tooltip-truncated data-tooltip="${e.renamedFrom==null?e.path:`${e.renamedFrom} \u2192 ${e.path}`}">${e.renamedFrom==null?r(e.path):Un(r(e.renamedFrom),r(e.path))}</span>${o?a?.tag?.(this.details,e.path,s(e))??W:W}${Hr(e.meta)}${this._sizeCells(e)}</button></li>`,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)||sn(e.pkg).localeCompare(sn(t.pkg))),s=n===`changed`?0:Math.min(ia,Math.max(0,...t.map(e=>e.versions.join(`, `).length)));return this._group(e,o,n,e=>e.pkg,e=>U`<li><div class="bundle-compare-row"><span class="bundle-compare-pkg-dot" style="${V({background:rn(e.pkg)})}"></span> <span class="bundle-compare-row-path" data-tooltip-truncated data-tooltip="${sn(e.pkg)}">${sn(e.pkg)}</span> ${n===`changed`?this._versionCell(e):s>0?U`<span class="bundle-compare-dep-ver" data-tooltip-truncated data-tooltip="${e.versions.join(`, `)}">${e.versions.join(`, `)}</span>`:W} ${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.join(`, `),n=e.baseVersions.join(`, `);if(e.baseVersions.join()===e.otherVersions.join())return e.baseVersions.length>0?U`<span class="bundle-compare-dep-ver">${n}</span>`:W;let r=e.direction??`changed`,[i,a]=r===`up`?[`↑`,`Upgraded`]:r===`down`?[`↓`,`Downgraded`]:[`±`,`Changed`];return sa(`${a}: ${n||`none`} to ${t||`none`}`,n||`—`,t||`—`,r,i)}_depGroup(e,t,n,r){let i=n===`changed`?0:Math.min(ia,Math.max(0,...t.map(e=>e.range.length))),a=e=>U`<span class="bundle-compare-row-path" data-tooltip-truncated data-tooltip="${e.name}">${e.name}</span> ${this.source?.dependencyTags?.(e,n)??W}${e.kind?U`<span class="npm-dependency-kind">${e.kind}</span>`:W} ${n===`changed`?sa(`Changed: ${e.from} to ${e.to}`,e.from,e.to,`changed`):U`<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=>U`<li>${o&&e.opens?U`<button type="button" class="bundle-compare-row bundle-compare-row-link" @click="${()=>o(e)}">${a(e)}</button>`:U`<div class="bundle-compare-row">${a(e)}</div>`}</li>`,W,{fill:!0,lanes:r,style:i>0?{"--compare-version-width":`${i}ch`}:{}})}_renderDependencies(e,t,n,r){return r.length===0?W:U`<section class="bundle-compare-section"><h3 class="bundle-compare-section-head">Dependencies</h3>${this._cols(r,(...e)=>this._depGroup(...e),e,t,n,`dependencies`)}</section>`}_renderPackages(e,t,n,r=aa){return e.removed.length===0&&e.added.length===0&&e.changed.length===0?W:U`<section class="bundle-compare-section"><h3 class="bundle-compare-section-head">Packages</h3>${this._cols(r,(...e)=>this._pkgGroup(...e),e,t,n,`packages`)}</section>`}_cols(e,t,n,r,i,a){let o=e.map(e=>e===`changed`?`minmax(0, 5fr)`:`minmax(0, 4fr)`).join(` `);return U`<div class="bundle-compare-cols" data-lanes="${e.length}" data-section="${a}" style="${V({"--compare-lanes":o})}">${t(`Removed \xB7 only in ${r}`,n.removed,`removed`,e)} ${t(`Added \xB7 only in ${i}`,n.added,`added`,e)} ${t(`Changed`,n.changed,`changed`,e)}</div>`}_collapsible(e,t,n,r,i=``){let a=this._openSections.has(e);return U`<details class="bundle-compare-section bundle-compare-collapsible" .open="${I(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?U`<span class="bundle-compare-section-note" data-tooltip-truncated data-tooltip="${i}">${i}</span>`:W}</summary>${a?r():W}</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 W;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,ra)})),i=(e,t=``)=>U`<td class="${t}"><code data-tooltip-truncated data-tooltip="${e}">${e}</code></td>`,a=(e,t)=>e===null?U`<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})=>U`<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?U`<th>Conditions</th>`:W}</tr></thead><tbody>${H(r,e=>e.key,e=>{let t=o(e);return U`<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?U`<td class="bundle-compare-resolution-context"><span data-tooltip-truncated data-tooltip="${t}">${t}</span></td>`:W}</tr>`})}</tbody></table>${t.length>r.length?U`<div class="bundle-compare-more">and ${(t.length-r.length).toLocaleString()} more…</div>`:W}</section>`))}_comparison(){return Vn(this._otherDetails,this.details,this._scope,this._repaint)}_renderSummary(e){return En(e,U`<div class="bundle-compare-modes" role="tablist" aria-label="Comparison view">${[[`overview`,`Overview`],[`code`,`Code`]].map(([e,t])=>U`<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 Tn({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._swap():null,extras:n,comparison:r,openLine:e=>this._openLine(e)})}_baseOptions(){if(this.source)return K(this.source.choices??[]);let e=(F.bundles??[]).find(e=>e.integrity===this.integrity),t=we(F.bundles??[],this.integrity);return this._bundleOptions(e?[e,...t]:t)}_otherOptions(){return this.source?K(this.source.options):this._bundleOptions(we(F.bundles??[],this.integrity))}_bundleOptions(e){let t=Map.groupBy(e,e=>e.name);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`?z(e.size):`—`,filename:t.get(e.name).length>1?`${e.name} \xB7 ${e.integrity.slice(7,13)}\u2026`:e.name}))}render(){let t=this._otherOptions(),n=!!this._targetIntegrity&&(!!this.source||t.some(e=>e.integrity===this._targetIntegrity)),r=this._baseReady?e(n?this._otherDetails:null,this.details):[],i=r.length>0?U`<bundle-scope-selector .reasons="${r}" .value="${this._scope}" label="Compare scope" @scope-change="${e=>{this._scope=e.detail.value}}"></bundle-scope-selector>`:W,a=n&&this._status===`ready`&&this._otherDetails&&(this._otherDetails.json||this._otherDetails.bundle)&&!this._otherDetails.error,o=this._baseReady&&a?this._comparison():null,s=o?.status===`ready`?o.diff:null,c=s?{base:this._otherDetails,other:this.details,files:s.files}:null,l=t.length>0||this.source?this._renderPicker(t,n,i,c):i,u=s?this._mode:`overview`;return U`<div class="bundle-compare">${Dn(l,s?this._renderSummary(s):W)} ${u===`code`?na({base:this._otherDetails,other:this.details,diff:s,source:this.source,path:this._codePath,seek:this._codeSeek,baseName:this._nameFor(this._targetIntegrity),otherName:this._nameFor(this.integrity),select:e=>{this._codePath=e}}):U`<div class="bundle-compare-body">${s?this._renderDiff(s):this._empty(t,n,o)}</div>`}</div>`}_empty(e,t,n){let r=U`<strong>${this._nameFor(this.integrity)}</strong>`,i=this.source?.noun??`bundle`,a=(e,t=!1)=>U`<div class="${t?`bundle-compare-empty is-error`:`bundle-compare-empty`}">${e}</div>`;return this._baseReady?this.source&&!t&&(this.source.pending||this.source.error||!this.source.select&&e.length===0)?a(this.source.pending?`Loading ${i}s\u2026`:this.source.error??U`No other ${i}s to compare ${r} with.`,!!this.source.error):e.length===0&&!this.source?a(U`No other bundles to compare with. Drop a second <code>.map</code>, <code>.stasis.code.br</code> or <code>.stasis.tgz</code> bundle to diff against this one.`):t?this._status===`loading`||!this._otherDetails?a(`Comparing…`):this._otherDetails.error?a(`Couldn't read the selected ${i}: ${this._otherDetails.error}`,!0):!this._otherDetails.json&&!this._otherDetails.bundle?a(`The selected ${i} couldn't be parsed.`,!0):n?.status===`error`?a(`Couldn't compare the ${i}s: ${n.message}`,!0):a(`Comparing…`):a(U`Pick a ${i} above to compare ${r} against.`):a(`Loading bundle…`)}_renderDiff(e){let t=this._nameFor(this._targetIntegrity),n=this._nameFor(this.integrity),r={removed:e.files.onlyBase,added:e.files.onlyOther,changed:e.files.changed},i=[...r.removed,...r.added,...r.changed].flatMap(e=>e.renamedFrom==null?[e.path]:[e.path,e.renamedFrom]),a=Bt(e.files.root,an(i).prefix),{prefix:o}=a,s=e=>q(e,o),c=r.removed.length+r.added.length+r.changed.length,l=!e.totals.identical,u=this.source?.dependencies?.(this._otherDetails,this.details)??null,d=aa.filter(t=>(u??e.packageRows)[t].length>0),f=l?aa.filter(e=>r[e].length>0):[],p=f.every(e=>d.includes(e))?d:f,m=l?this.source?.files?.warning?.(this.details,[...r.added,...r.changed].map(e=>e.path)):W;return U`${u?this._renderDependencies(u,t,n,d):this._renderPackages(e.packageRows,t,n,d)} ${m??W} ${e.totals.identical?e.resolutions.totalChanges>0?U`<div class="bundle-compare-caption">File contents are unchanged; import resolutions differ.</div>`:U`<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`})${a.from?U`, moved <span class="mono">${Wn(a)}</span>`:``}.</div>`:this._collapsible(`files`,`Files`,c,()=>this._cols(p,(e,t,n,r)=>this._fileGroup(e,t,n,s,r),r,t,n,`files`),a.from?`${a.from} \u2192 ${a.to}`:o)} ${this._renderResolutions(e.resolutions,t,n)}`}};customElements.define(`bundle-compare`,ca);var la=/\p{Cc}/u,ua=(e,t)=>t===null?`/dev/null`:`${e}/${t}${t.includes(` `)?` `:``}`;function da({path:e,kind:t,basePath:n=e,modified:r,before:i,after:a}){let o={from:null,to:e,before:``,after:a},s={from:n,to:null,before:i,after:``};return t===`added`?[o]:t===`removed`?[s]:n===e?t===`repointed`||r===!1||i===a?[]:[{from:e,to:e,before:i,after:a}]:[s,o]}var fa=e=>typeof e==`string`&&!qe(e),pa=e=>e===null||!la.test(e)&&!qe(e);function ma(e){let t=e.flatMap(da);return t.every(({from:e,to:t,before:n,after:r})=>pa(e)&&pa(t)&&fa(n)&&fa(r))?t:null}function ha(e){return e.map(({from:e,to:t,before:n,after:r})=>`--- ${ua(`a`,e)}
25
- +++ ${ua(`b`,t)}
26
- ${Vt(n,r)}`).join(``)}var $=e=>e._blocked||e._loading,ga=e=>e._shownReview?.publishedAt!=null,_a=e=>e._error?U`<p class="npm-review-error" role="alert">${e._error}</p>`:W,va=e=>e._saveBlocked?U`<div class="npm-review-saving" role="status">Saving changes…</div>`:W,ya=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)),ba=e=>`npm-review-button npm-review-primary npm-review-finalize ${e._allowedVerdicts[0]}`,xa=(e,t,n,i,a=Object.keys(r),o=!1)=>U`<div class="npm-review-verdict-options" role="group" aria-label="Verdict">${Object.entries(o?{"":`Not checked`,...r}:r).map(([r,o])=>U`<label class="${`npm-review-verdict-choice ${r||`unchecked`}`}"><input type="radio" name="${e}" aria-label="${o}" value="${r}" .checked="${I(t===r)}" ?disabled="${i||r!==``&&!a.includes(r)}" @change="${()=>n(r)}">${o}</label>`)}</div>`;function Sa(e){let t=ga(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,a=t&&n.revokedAt===null&&n.user===e.session?.id?U`<dependency-review-copy .text="${n.formatted}"></dependency-review-copy>`:W;return U`<div class="npm-review-summary-actions">${t||e._draftStarted?U`<span class="npm-review-status">${a}${Ue(n??{publishedAt:null,revokedAt:null})}</span>`:W}<div class="npm-review-progress-block"><span>${e._unsaved&&(e._saveBlocked||e._error)?U`<button type="button" class="npm-review-button npm-review-text-button" @click="${()=>e._openPanel(`unsaved`)}">Unsaved changes</button>`:U`<strong>${r.checkedFiles} of ${r.totalFiles}</strong> files checked`}</span> ${Qe(r.checkedFiles,r.totalFiles)}</div>${i?U`<button type="button" class="${e._canEdit?ba(e):`npm-review-button`}" ?disabled="${$(e)||i.disabled}" @click="${i.run}">${i.label} ${E}</button>`:W}</div>`}var Ca=(e,t)=>e.some(e=>e.id===t)?e:[...e,...K([{id:t,name:t,format:`npm`}])];function wa(e,t,n,r,i){if(!r)return null;let a=e.findIndex(e=>e.id===t),o=`patch:${r.slice(0,5)}`;return e.splice(a,1,{...e[a],detail:o,detailNote:i},{...e[a],id:`${t} unpatched`}),{name:n,detail:o,detailNote:i}}function Ta(e){let t=e.source??_e(e.entry),{name:n,version:r}=e.entry.npm,i=!!(e._target&&e._target!==`(empty)`),a=K(t.options,e=>`${n}@${e.id}`),o=i?Ca(a,e._target):a,s=Ca(K(t.choices),r),c=`${e._target} unpatched`,l=`${r} unpatched`,u=wa(s,r,`${n}@${r}`,e._patch?.hash,Da(Ea(e))),d=wa(o,e._target,e._target,i&&e._basePatch,Da(e._base?.npmPatch?.patch));return Dn(Tn({source:u||d?{...t,widest:u||d}:t,label:`Review`,disabled:$(e),from:{options:o,value:i?e._target:null,label:`Review base`,pick:t=>{e._navigate(t===c?e._target:t,t===e._target?e._basePatch:null)}},to:{options:s,value:r,label:`Version to review`,pick:t=>{e._navigateTo({view:`npm`,packageName:n,packageSpec:t===l?r:t,bundleTab:`review`,...e._location(e._target,t===r)})}},clear:i?{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?En(e._diff):W)}var Ea=e=>e._patched?.npmPatch?.patch??e._patch,Da=e=>`As pnpm\u2019s patch${e?.path?` ${e.path}`:``} changes it`,Oa=e=>`${Da(Ea(e))}${Ea(e).commit?`, read at ${Ea(e).commit.slice(0,7)}`:``}`,ka=e=>e._patch?U`<span class="npm-review-patched" data-tooltip="${Oa(e)}">patch:${e._patch.hash}</span>`:W;function Aa(e){return U`<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="${$(e)}" @click="${()=>{e._navigateTo({view:`reviews`})}}">My reviews</button> ${E}<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">${ya(e).length}</span></button> ${ka(e)}</nav>${Sa(e)}</div>`}function ja(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 U`<section class="${`npm-review-decision${n?` npm-review-inline-decision`:``}`}" aria-label="File decision">${e._canEdit?U`${xa(`file:${t}`,a?``:r.status,n=>{e._setFileStatus(t,n)},$(e)||a,void 0,!0)} ${a?U`<p class="npm-review-help">Non-text file. Verdicts are not supported yet; this file remains unchecked.</p>`:W} ${o?U`<textarea aria-label="File note" rows="2" maxlength="20000" placeholder="Add a note (optional)…" .value="${I(r.comment)}" ?disabled="${$(e)}" @input="${n=>e._editFile(t,{comment:n.target.value})}" @blur="${()=>{e._saveFile(t)}}"></textarea>`:W}`:U`${n?W:U`<header><strong>File review</strong><span class="npm-review-muted">${ga(e)?`Frozen`:`Read only`}</span></header>`} ${i?.status&&!a?U`${Be(i.status)}${A(i.comment)}`:U`<p class="npm-review-muted">This file was not reviewed.</p>`} ${e._reviewer||e._loading?W:U`<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 Ma(e,t,n,r,i,a){return U`<fieldset class="npm-review-team-options"><legend>${t}</legend>${n.map(t=>U`<mode-switch label="${t.name}" .checked="${r.has(t.id)}" .disabled="${$(e)}" @click="${()=>{if($(e))return;let n=new Set(r);n.delete(t.id)||n.add(t.id),i(n)}}"></mode-switch>`)}${a}</fieldset>`}function Na(e,t){let n=e._allowedVerdicts,r=Jt(t.entries,e._files,e._nonTextFiles),i=t.entries.filter(t=>t.status&&t.comment.trim()&&!e._nonTextFiles.includes(t.file));return U`<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>${r.coverage===`full`?`Full`:`Partial`} review</strong><span>${r.checkedFiles} of ${r.totalFiles} files checked</span></div>${Qe(r.checkedFiles,r.totalFiles)}<p>${r.totalFiles>r.checkedFiles?U`${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?U`<p class="npm-review-error">Review ${e._files.includes(`package.json`)?U`<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>`:W}</section>${i.length>0?U`<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=>U`<li>${nt(e.file)} ${A(e.comment)}</li>`)}</ul></section>`:W}<div><strong>Final verdict</strong>${xa(`final-verdict`,e._finalStatus,t=>{e._finalStatus=t},$(e),n)}</div>${e._securityLimit===`reject`?U`<p class="npm-review-help">Malware detected. Only Reject is available.</p>`:e._securityLimit===`request-changes`?U`<p class="npm-review-help">Critical vulnerabilities detected.</p>`:W} <label>Final note <span class="npm-review-muted">· optional</span><textarea aria-label="Final comment" rows="3" maxlength="20000" .value="${I(e._finalComment)}" placeholder="Summarize your findings or explain what remains…" ?disabled="${$(e)}" @input="${t=>{e._finalComment=t.target.value}}"></textarea></label> ${e._unchangedContinuation?U`<p class="npm-review-help">Change a verdict or note to publish a new review.</p>`:W} ${Ma(e,`Publish to teams`,e._teams,e._selectedTeams,t=>{e._selectedTeams=t},e._selectedTeams.size>0?W:U`<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>`)} ${_a(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="${ba(e)}" ?disabled="${$(e)||!e._canPublish}">Publish to ${e._selectedTeams.size} ${e._selectedTeams.size===1?`team`:`teams`} ${E}</button></footer></form>`}function Pa(e,t){let n=t===e._shownReview,r=t.publishedAt!==null,i=r?t:M(t,e._context)?Jt(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 U`<section class="npm-review-entry" aria-current="${String(n)}"><div class="npm-review-history-heading"><strong>${Ke(t)}</strong>${n?U`<span class="npm-review-current">Current</span>`:W}${Ue(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?Be(t.status):W}<span class="dependency-review-coverage"> ${r?U`${et(i)} · `:W}${i.checkedFiles}${i.totalFiles===null?W:`/${i.totalFiles}`} files checked</span></div><p class="npm-review-help">${t.teams.length>0?`${t.teams.map(e=>e.name).join(`, `)} \xB7 `:``}${Ye(t.publishedAt??t.time)}</p>${A(t.comment)}<div class="npm-review-entry-actions"><button type="button" class="npm-review-button" ?disabled="${$(e)}" @click="${()=>{e._openReview(t)}}">Open ${E}</button> ${r&&o&&!a&&e._reviewer?U`<button type="button" class="npm-review-button" aria-label="Revise in a new draft" ?disabled="${$(e)}" @click="${()=>{e._openReview(t,!0)}}">Revise</button>`:W} ${r&&o&&e._writable&&t.revokedAt===null?U`<button type="button" class="npm-review-button npm-review-danger" ?disabled="${$(e)}" @click="${()=>e._change({action:`revoke`,reviewId:t.id,revision:t.revision})}">Revoke</button>`:W} ${o?U`<dependency-review-copy .text="${t.formatted}"></dependency-review-copy>`:W} ${!r&&o&&e._writable?st($(e),()=>{e._discard(t)}):W}</div>${r&&o&&e._writable&&t.revokedAt===null&&s.length>0?U`<details class="npm-review-share"><summary>Publish to more teams</summary>${Ma(e,`Teams`,s,c,n=>{e._additionalTeams=new Map(e._additionalTeams).set(t.id,n)},U`<button type="button" class="npm-review-button" ?disabled="${$(e)||l.length===0}" @click="${()=>e._change({action:`publish`,reviewId:t.id,revision:t.revision,teamIds:l})}">Publish to more teams</button>`)}</details>`:W} ${t.revokedAt===null?W:U`<p class="npm-review-help">Revoked ${Ye(t.revokedAt)}. Content and team links remain frozen.</p>`}</section>`}function Fa(e){if(!e._panel)return W;let t={publish:`Publish review`,reviews:`Reviews`,unsaved:`Unsaved changes`};return U`<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)`:``}`:P(e._context)}</p></header>${e._panel===`publish`?Na(e,e._activeReview):U`<div class="${`npm-review-dialog-body${e._panel===`reviews`?` npm-review-entries`:``}`}">${e._panel===`unsaved`?U`${e._dirtyFiles.map(t=>U`<button type="button" class="npm-review-button" @click="${()=>{e._closePanel(),e._selectFile(t)}}">${t} ${E}</button>`)}`:ya(e).map(t=>Pa(e,t))} ${e._panel===`reviews`&&ya(e).length===0?U`<p class="npm-review-muted">No reviews yet.</p>`:W}${_a(e)}</div>`} ${va(e)}</dialog>`}function Ia(e){let t=e._shownReview?.entries,n=e._files,i=e._nonTextFiles;if(e._treeProgress?.entries!==t||e._treeProgress?.files!==n||e._treeProgress?.nonTextFiles!==i){let r=ut(t,i),a=new Map,o=0;for(let t of e._files){let e=t.split(`/`),n=+!!r.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:i,states:r,directories:a,checked:o}}let{states:a,directories:o,checked:s}=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=>!a.get(e)?.status:null,fileLabel:e=>`${e}, ${r[a.get(e)?.status]??`Not reviewed`}`,filePrefix:e=>Pe(a.get(e)?.status),fileSuffix:e=>a.get(e)?.notes?U`<span class="npm-review-note-dot" aria-label="Has notes">•</span>`:W,directoryLabel:e=>{let t=o.get(e.sourcePath);return`${e.sourcePath}, ${t?.checked??0} of ${t?.total??0} checked`},directorySummary:e=>{let t=o.get(e.sourcePath);return`${t?.checked??0}/${t?.total??0}`},filters:U`<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-s}</button></div>`,fileActions:(t,n)=>ja(e,t,n),copyDiff:e._unified?.length>0?()=>e._unifiedText??=ha(e._unified):null}}function La(e){if(!e._base){let t=U`<div class="npm-review-empty" role="${e._baseError?`alert`:`status`}">${e._baseError??`Loading comparison…`} ${e._baseError?U`<button type="button" class="npm-review-button" @click="${()=>{e._baseKey=null,e._loadBase(e._target,e.request?.resume)}}">Retry</button>`:W}</div>`;return e._baseError&&e._basePatch?U`${Ta(e)}${t}`:t}return U`${Ta(e)}${Aa(e)}${e._panel?W:_a(e)} ${na({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:Ia(e),mode:e._mode,viewChanged:()=>e._viewChanged()})} <span class="npm-review-announcement" role="status">${e._notice??``}</span>${e._panel?W:va(e)}${Fa(e)}`}var Ra=Object.freeze([]),za={maxLines:5e4,maxBytes:2097152},Ba={integrity:`(empty)`,kind:`sourcemap`,json:{version:3,sources:[],sourcesContent:[]},fileSizes:new Map},Va=(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}),Ha=(e,t)=>e?`${e}@${t??`latest`}`:`(empty)`,Ua=e=>class extends e{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._unified=null,this._unifiedText=null,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()}get _routed(){return F.bundleDetailsTab===`review`&&F.selectedBundle===this.entry?.integrity}_rememberBase(){!this._routed||!this._context||!this._activeReview&&this._ownPublished.length===0&&!this._unsaved||(F.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}_ownHere(e){return e.user===this.session?.id&&M(e,this._context)}get _activeReview(){return this._reviews.find(e=>e.publishedAt===null&&this._ownHere(e))??(this._continuation&&this._continuation.review.user===this.session?.id?this._continuation.review:null)}get _ownPublished(){return this._reviews.filter(e=>e.publishedAt!==null&&this._ownHere(e)).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(){let e=this._shownReview?.entries??Ra,t=this._summaryHeld;if(t?.entries===e&&t.files===this._files&&t.nonText===this._nonTextFiles)return t.summary;let n=Jt(e,this._files,this._nonTextFiles);return this._summaryHeld={entries:e,files:this._files,nonText:this._nonTextFiles,summary:n},n}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 Yt([...e.values()].filter(e=>!this._nonTextFiles.includes(e.file)),this._securityLimit)}get _needsPackageJson(){return Xt(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 _publishReady(){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)}get _canPublish(){return this._askable&&this._publishReady}_location(e,t=!0,n=e===this._target?this._basePatch:null){let r=e&&e!==`(empty)`?Et(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(kt(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 k?.navigate(e.bundleTab===`review`?{...e,...De(F)}:e)}_shownRoute(e=this._base){let t=this._location(Ha(e.npm?.name,e.npm?.version),!0,e.npmPatch?.patch.hash??null);return kt(this.entry,`review`,{...t,...De(F)})}_viewChanged(){this._routed&&this._base&&this._context&&k?.replaceRoute(this._shownRoute())}_baseKeyOf(e){return JSON.stringify([this.entry.integrity,e,this._patch,this._basePatch,this.session?.id,this.session?.role])}_restart(){this._controller.abort(),this._cancelSaves(),this._controller=new AbortController}async _loadBase(e,t=!1){let n=this._baseKeyOf(e);if(this._baseKey!==n){this._baseKey=n,this._base=null,this._baseError=null,this._key=null,this._restart();try{let r=this._controller.signal,i=this._patch?c(this.entry,this._patch,{signal:r}):Promise.resolve(this.details);i.catch(()=>{});let a=t?await ae(Va(this.entry,null,this._patch),r):null;if(this._baseKey!==n)return;a&&([e,this._basePatch]=[Ha(a.basePackage,a.baseVersion),a.basePatchHash??null]);let o=e===`(empty)`?null:Et(e),s=o?await Nt(o.name,o.spec??`latest`):null,l=s&&this._basePatch?{...await c(s.entry,{hash:this._basePatch},{signal:r}),npm:s.details.npm}:s?.details??Ba,u=await i;if(this._baseKey!==n)return;let d=await Hn(l,u);if(this._baseKey!==n)return;t&&(a&&ft(a),this._target=e,this.request={bundle:this.entry.integrity,...this._location(e)},this._baseKey=this._baseKeyOf(e)),this._patched=this._patch?u:null,this._base=l,this._ensureContext(l,d)}catch(e){this._baseKey===n&&([this._baseError,this._baseStatus]=[e.message,e.status??null])}}}_ensureContext(e,n){let r=Va(this.entry,e,this._patch),i=JSON.stringify([this.session?.id,this.session?.role,r]);if(i===this._key)return;this._restart(),this._context=r,this._diff=n;let a=Zn(e,this._other,this._diff);this._files=Ze(t(a.map(e=>e.path)));let o=new Set(a.filter(e=>!qt(e.before,e.after)).map(e=>e.path));this._nonTextFiles=this._files.filter(e=>o.has(e));let s=new Map(a.map(e=>[e.path,e]));if(this._unified=ma(this._files.map(e=>s.get(e))),this._unifiedText=null,this._mode=Qn(a,za)?`diff`:`code`,this._key=i,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),this._routed){let t=Ha(e.npm?.name,e.npm?.version),n=this._location(t,!0,e.npmPatch?.patch.hash??null);F.npmReview={bundle:this.entry.integrity,...n},this._baseKey=this._baseKeyOf(t),k?.replaceRoute(this._shownRoute(e))}}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;let n=this._loadingShown();this._loading=!0,this._error=null;try{let{reviews:n,teams:r}=await g({...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.publishedAt===null&&this._ownHere(e))&&(this._continuation=null),this._rememberBase();let i=mt(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._clearEditors(this._file)}}catch(e){t===this._key&&e.name!==`AbortError`&&(this._error=e.message)}finally{n(),t===this._key&&(this._loading=!1)}}_loadingShown(){return this._dismissLoading?.(),this._dismissLoading=be(`Loading reviews…`,{duration:0})}_resetEditor(e=null){this._publishRevision=null,this._file=e,this._editorState(e)}_clearEditors(e=this._path){this._editors.clear(),this._resetEditor(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,r=this._nonTextFiles.includes(e);t={edit:n,revision:this._activeReview?.revision??null,comment:r?``:n?.comment??``,status:r?``: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||(ft(e,t),await this._navigate(Ha(e.basePackage,e.baseVersion),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 Ut({reviewTitle:P(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 T(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._clearEditors(),this._finalStatus=null,this._finalComment=``,this._panel=null,this._ownPublished.length===0&&F.npmReview?.bundle===this.entry.integrity&&delete F.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.publishedAt!==null&&this._ownHere(n));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._clearEditors(),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 g(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}_putReview(e){this._reviews=[...this._reviews.filter(t=>t.id!==e.id),e]}_acceptSave(e,t){this._putReview(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 g(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}}}get _askable(){return!this._blocked&&this._pendingSaves.length===0&&!this._loading&&this._writable}async _ask(e,t){if(!this._askable)return null;let n=this._key;this._saving=!0,this._error=null;try{let r=await e();if(!r||n!==this._key)return null;let{review:i}=await g(r.context,r.change,this.session.csrfToken,this._controller.signal);return n===this._key?(t(i),i):null}catch(e){return n===this._key&&e.name!==`AbortError`&&(this._error=e.message),null}finally{n===this._key&&(this._saving=!1)}}_askedFor(e){return{context:this._asked(this._reviews.find(t=>t.id===e.reviewId)??this._context),change:e}}_change(e){return e.action===`continue`?Promise.resolve(this._askable?this._continue(e.reviewId,e.revision):null):this._ask(()=>this._askedFor(e),e=>{this._putReview(e),this._rememberBase()})}_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(){return this._ask(()=>this._publication(),e=>this._published({review:e}))}async _publication(){if(!this._publishReady)return null;let e={action:`publish`,reviewId:this._activeReview.id,revision:this._publishRevision,teamIds:[...this._selectedTeams],finalStatus:this._finalStatus,finalComment:this._finalComment};if(e.finalStatus&&this._continuation){let t=await this._persistContinuation();if(!t)return null;e={...e,reviewId:t.id,revision:t.revision}}return this._askedFor(e)}_published({review:e,error:t}){return t?(this._error=t,!1):(this._putReview(e),M(e,this._context)&&(this._selectedReview=e.id,this._panel=null,this._editors.clear(),this._notice=`Published. Verdicts and notes are now frozen.`),this._rememberBase(),!0)}render(){if(!this.entry?.npm||!this.details)return W;let e=this.request?.bundle===this.entry.integrity?this.request:{};return this._target=Ha(e.reviewPackage,e.reviewSpec),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),La(this)}},Wa=class extends Ua(G){};customElements.define(`npm-review`,Wa);var Ga=2,Ka=(e,t)=>`${e.toLocaleString(`en-US`)} ${t}${e===1?``:`s`}`,qa=class extends Ua(class{}){constructor(e,t,{review:n,repoId:r,head:i}){super(),this._page=e,this.pkg=t,this.key=At(t),this.target=un(t,n),this._patch=t.patch?.path?{hash:t.patch.hash,repoId:r,commit:i,path:t.patch.path}:null,this._started=!1,this._busyTries=0}get session(){return this._page.session}get source(){return this._source??=_e(this.entry)}get status(){return this._baseError?`error`:this._base?`ready`:this._started?`loading`:`waiting`}get _routed(){return!1}_loadingShown(){return()=>{}}requestUpdate(){this._page?.requestUpdate()}get title(){return this._context?P(this._context):`${this.pkg.name} ${this.pkg.version}`}get route(){return{view:`npm`,packageName:this.pkg.name,packageSpec:this.pkg.version,bundleTab:`review`,...this.target?{reviewPackage:this.target.name,reviewSpec:this.target.version}:{},...this._patch?{patch:this._patch}:{}}}dispose(){this._controller.abort(),this._cancelSaves(),this._key=this._baseKey=null}async load(){this._started=!0,this._baseError=null,this._baseStatus=null,this._baseKey=null,this.target&&a(this.target.name,this.target.version);try{({entry:this.entry,details:this.details}=await Nt(this.pkg.name,this.pkg.version)),await this._loadBase(this.target?`${this.target.name}@${this.target.version}`:`(empty)`)}catch(e){[this._baseError,this._baseStatus]=[e.message,e.status??null]}this._baseStatus===429?(this._baseError=null,_(m(this._busyTries++),()=>{this._started=!1,this._page?.isConnected&&this._page._loadNext()})):this._busyTries=0}};for(let e of Object.keys(qa.properties))Object.hasOwn(qa.prototype,e)||Object.defineProperty(qa.prototype,e,{get(){return this._drawn?.[e]},set(t){(this._drawn??={})[e]=t,this.requestUpdate()}});function Ja(e){let{pkg:t,target:n}=e,r=e._shownReview,i=e._summary;return U`${Ht(`npm`)}<span class="bundle-code-tree-dirname pull-review-package-label" data-tooltip-truncated data-tooltip="${e.title}"> <span class="pull-review-package-name">${t.name}</span><span class="pull-review-package-version">${n?`${n.name===t.name?n.version:`${n.name}@${n.version}`} \u2192 `:`new `}${t.version}</span>${e._patch?U`<span class="team-deps-patched">patched</span>`:W}</span>${v(t)} ${r?.publishedAt!=null&&r.revokedAt===null?Le({status:r.status,partial:i.coverage===`partial`}):r?Ue(r):W}<npm-delta .name="${t.name}" .version="${t.version}" .base="${n?.version??`(empty)`}" .baseName="${n?.name??t.name}" .patch="${e._patch}"></npm-delta><span class="bundle-compare-code-dir-count">${e.status===`ready`?`${i.checkedFiles}/${i.totalFiles}`:e.status===`error`?`!`:`…`}</span>`}var Ya=class extends G{static properties={team:{attribute:!1},repositories:{attribute:!1},pull:{attribute:!1},session:{attribute:!1},_selected:{state:!0},_panel:{state:!0},_includePartial:{state:!0},_selectedTeams:{state:!0},_publishing:{state:!0},_notice:{state:!0}};createRenderRoot(){return this}constructor(){super(),this._units=new Map,this._selected=null,this._panel=null,this._includePartial=!1,this._selectedTeams=null,this._publishing=!1,this._notice=``,this._notify=e=>{(!e||e.repoId===this.pull?.repoId&&e.number===this.pull?.number)&&this.requestUpdate()},this._controller=new AbortController}connectedCallback(){super.connectedCallback(),this._unsubscribe=bt(this._notify)}disconnectedCallback(){super.disconnectedCallback(),this._controller.abort(),this._controller=new AbortController,this._unsubscribe?.();for(let e of this._units.values())e.dispose()}updated(){let e=this.querySelector(`:scope > dialog`);e&&!e.open&&e.showModal?.()}get _blocked(){return this._publishing||[...this._units.values()].some(e=>e._blocked)}get _repository(){return(this.repositories??[]).find(e=>e.repoId===this.pull?.repoId)??null}willUpdate(){let e=this.pull;if(this._answer=e&&this._repository?Pt(e.repoId,e.number,!0):null,this._answer?.status===`ready`&&this._answer.review?.canReview){for(let t of f(this._answer).toSorted((e,t)=>e.name.localeCompare(t.name)))this._units.has(At(t))||this._units.set(At(t),new qa(this,t,{review:this._answer.review,repoId:e.repoId,head:this._answer.head}));this._units.has(this._selected)||(this._selected=this._units.keys().next().value??null),this._loadNext()}}_loadNext(){let e=[...this._units.values()],t=e.filter(e=>e.status===`loading`).length;for(let n of new Set([this._units.get(this._selected),...e]))if(n?.status===`waiting`){if(t++>=Ga)break;n.load().finally(()=>{this.isConnected&&this._loadNext()})}}_select(e,t=null){e._blocked||this._panel||(e.key!==this._selected&&(this._selected=e.key,this._loadNext()),t&&e._selectFile(t))}get _drafts(){return[...this._units.values()].filter(e=>e.status===`ready`&&e._canEdit&&e._activeReview&&e._summary.checkedFiles>0)}_publishable(e){return e._canPublish&&(this._includePartial||e._summary.coverage===`full`)}_pickTeams(e){this._selectedTeams=e;for(let t of this._units.values())t._selectedTeams=e}async _beginPublish(){if(this._blocked)return;for(let e of this._drafts)await e._beginPublish();let e=this._drafts[0]?._teams;e&&(this._pickTeams(this._selectedTeams??new Set(e.length===1?[e[0].id]:[])),this._notice=``,this._panel=`publish`)}_closePanel(){if(!this._publishing){for(let e of this._units.values())e._panel=null;this.querySelector(`:scope > dialog`)?.close?.(),this._panel=null}}async _publishAll(){let e=this._drafts.filter(e=>this._publishable(e));if(this._publishing||e.length===0)return;this._publishing=!0;let t=0,n=[];try{for(let t of e){let e=t._key;try{let r=await t._publication();r&&e===t._key&&n.push({unit:t,key:e,publication:r})}catch(n){e===t._key&&n.name!==`AbortError`&&(t._error=n.message)}}for(let{unit:e}of n)e._saving=!0;let r=await te(n.map(e=>e.publication),this.session.csrfToken,this._controller.signal);for(let[e,{unit:i,key:a}]of n.entries())a===i._key&&i._published(r[e])&&t++}catch(t){if(t.name===`AbortError`)return;for(let n of e)n._error=t.message}finally{for(let{unit:e,key:t}of n)t===e._key&&(e._saving=!1);this._publishing=!1}o([{repoId:this.pull.repoId,number:this.pull.number}]),this._notice=`Published ${Ka(t,`review`)}${t<e.length?`; ${e.length-t} failed`:``}.`,t===e.length&&this._closePanel()}_said(e){return e?e.status===`loading`?`Reading its dependencies…`:e.status===`error`?e.error:e.review?e.review.canReview?this._units.size===0?`None of its versions wants your review here.`:null:`You publish reviews to no team counting for its repository.`:`Its repository reviews no dependencies for you.`:`This pull request’s repository is none of this team’s.`}render(){let e=this._answer,t=this.pull?this._said(e):``;if(t!==null)return U`<p class="npm-review-empty" role="status">${t}</p>`;let n=this._units.get(this._selected);return U`${this._toolbar(e,n)}${this._view(n)}<span class="npm-review-announcement" role="status">${this._notice}</span>${this._dialog()}`}_toolbar(e,t){let n=[...this._units.values()].filter(e=>e.status===`ready`),r=n.reduce((e,t)=>e+t._summary.checkedFiles,0),i=n.reduce((e,t)=>e+t._summary.totalFiles,0);return U`<div class="npm-review-toolbar"><nav class="npm-review-toolbar-group" aria-label="Review breadcrumbs"><a class="pull-review-pull" href="${`https://github.com/${this._repository.name}/pull/${this.pull.number}`}" target="_blank" rel="noopener noreferrer">${this._repository.name}#${this.pull.number}</a> ${h(e,!0)}${E}<a class="npm-review-button npm-review-text-button npm-review-package" href="${fn(t.route)}" target="_blank" rel="noopener noreferrer"><span>${t.title}</span></a>${ka(t)}</nav><div class="npm-review-summary-actions">${e.formatted?U`<dependency-review-copy .text="${e.formatted}" .label="${`Copy your dependency reviews`}"></dependency-review-copy>`:W}<div class="npm-review-progress-block"><span><strong>${r} of ${i}</strong> files checked</span>${Qe(r,i)}</div><button type="button" class="npm-review-button npm-review-primary" ?disabled="${this._blocked||this._drafts.length===0}" @click="${()=>{this._beginPublish()}}">Finalize reviews ${E}</button></div></div>`}_tree(e,t){return U`<ul class="bundle-code-tree root" aria-label="Versions to review">${[...this._units.values()].map(n=>U`<li class="${B({"bundle-code-tree-dir":!0,"pull-review-package":!0,current:n===e})}"><details ?open="${n===e}"><summary @click="${e=>{e.preventDefault(),this._select(n)}}"><span class="bundle-code-tree-chevron" aria-hidden="true"></span>${Ja(n)}</summary>${n===e?t:W}</details></li>`)}</ul>`}_view(e){if(e.status!==`ready`){let t=e.status===`error`?U`${e._baseError} <button type="button" class="npm-review-button npm-review-text-button" @click="${()=>{e.load(),this.requestUpdate()}}">Retry</button>`:`Reading its files…`;return U`<div class="bundle-code-view"><aside class="bundle-code-rail"><div class="bundle-code-rail-body">${this._tree(e,U`<p class="pull-review-package-note" role="status">${t}</p>`)}</div></aside></div>`}return U`${e._error?U`<p class="npm-review-error" role="alert">${e._error}</p>`:W} ${na({base:e._base,other:e._other,diff:e._diff,source:e.source,path:e._path,seek:null,baseName:e._base.npm?`${e._base.npm.name}@${e._base.npm.version}`:`Empty package`,otherName:`${e.pkg.name}@${e.pkg.version}${e._patch?` (patched)`:``}`,select:t=>this._select(e,t),extensions:{...Ia(e),railTree:t=>this._tree(e,t)},mode:e._mode})} ${e._saveBlocked?U`<div class="npm-review-saving" role="status">Saving changes…</div>`:W}`}_dialog(){if(this._panel!==`publish`)return W;let e=this._publishing,t=this._drafts,n=this._selectedTeams??new Set,r=t[0]?._teams??[],i=t.filter(e=>this._publishable(e)).length;return U`<dialog class="npm-review-dialog" aria-label="Publish reviews" @cancel="${e=>{e.preventDefault(),this._closePanel()}}"><button type="button" class="detail-action npm-review-close" aria-label="Close panel" ?disabled="${e}" @click="${()=>this._closePanel()}">×</button><header class="npm-review-dialog-head"><h2>Publish reviews</h2><p>${this._repository.name}#${this.pull.number}</p></header><form class="npm-review-publish-form" @submit="${e=>{e.preventDefault(),this._publishAll()}}"><div class="npm-review-dialog-body"><mode-switch class="pull-review-partial" label="Include partial" .checked="${this._includePartial}" .disabled="${e}" @click="${()=>{e||(this._includePartial=!this._includePartial)}}"></mode-switch><ul class="pull-review-finals" aria-label="Reviews to publish">${t.map(t=>this._final(t,e))}</ul>${Ma(this,`Publish to teams`,r,n,e=>this._pickTeams(e),n.size>0?W:U`<p class="npm-review-error">Select at least one team to publish.</p>`)}</div><footer class="npm-review-dialog-footer"><p>Publishing freezes their verdicts and notes.</p><button type="submit" class="npm-review-button npm-review-primary" ?disabled="${e||i===0}">Publish ${Ka(i,`review`)} to ${Ka(n.size,`team`)} ${E}</button></footer></form></dialog>`}_final(e,t){let n=e._summary,r=n.coverage===`full`,i=!r&&!this._includePartial?`Partial: published with Include partial on.`:e._needsPackageJson?`Review package.json before publishing a partial review.`:e._unchangedContinuation?`Change a verdict or note to publish a new review.`:null;return U`<li class="${B({"pull-review-final":!0,"is-left":i!==null})}"><div class="pull-review-final-head"><strong>${e.title}</strong><span>${r?`Full`:`Partial`} · ${n.checkedFiles}/${n.totalFiles}</span></div>${i?U`<p class="npm-review-help">${i}</p>`:U`${xa(`final:${e.key}`,e._finalStatus,t=>{e._finalStatus=t},t,e._allowedVerdicts)} <textarea aria-label="${`Final comment on ${e.title}`}" rows="2" maxlength="20000" .value="${I(e._finalComment)}" placeholder="Final note (optional)…" ?disabled="${t}" @input="${t=>{e._finalComment=t.target.value}}"></textarea>`} ${e._error?U`<p class="npm-review-error" role="alert">${e._error}</p>`:W}</li>`}};customElements.define(`pull-dependency-review`,Ya);var Xa=e=>({view:`npm`,packageName:e.package,packageSpec:e.version,bundleTab:`review`,...e.basePackage===null?{}:{reviewPackage:e.basePackage,reviewSpec:e.baseVersion},...ln(e.patchHash)&&e.patchSource?{patch:{hash:e.patchHash,...e.patchSource}}:{},...ln(e.basePatchHash)&&e.basePackage!==null?{basePatch:e.basePatchHash}:{}}),Za=e=>{let t=new Date(e);return U`<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>`},Qa=class extends G{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 Ut({reviewTitle:P(e),signal:n});if(!r||n.aborted||t!==this._key||!this._canDiscard(e)||(await T(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=be(`Loading reviews…`,{duration:0});this._loading=!0,this._error=null;try{let n=e?this._next:null,{reviews:r,next:i}=await(this.team?S(this.team,n,this._controller.signal):y(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.delete(e)||t.add(e),this._expanded=t}_details(e){let t=e.entries.filter(e=>e.status);return U`<section id="${`review-details-${e.id}`}" class="dependency-review-details" aria-label="${`Details for ${P(e)}`}">${e.comment?U`<div class="dependency-review-final-note" role="note" aria-label="Final note">${A(e.comment)}</div>`:W} ${t.length>0?U`<ul class="dependency-review-entries">${t.map(e=>U`<li>${nt(e.file)} ${Be(e.status)}<div>${A(e.comment)}</div></li>`)}</ul>`:U`<p class="npm-review-muted">No file reviews yet.</p>`}</section>`}_row(e){let t=Xa(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||!k?.active||(n.preventDefault(),ft(e),k.navigate(t))};return U`<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="${fn(t)}" @click="${c}">${Ht(e.ecosystem)} ${e.basePackage!==null&&e.basePackage!==e.package?U`<span>${e.basePackage} ${e.baseVersion} →</span>`:W} <strong>${e.package}</strong> <span>${e.basePackage===e.package?`${e.baseVersion} \u2192 `:``}${e.version}${e.patchHash?U`<span class="dependency-review-patched">patch:${e.patchHash}</span>`:W}</span></a> <span class="dependency-review-result">${r?Be(e.status):U`<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`:W}" @click="${()=>this._toggleDetails(e.id)}">${r?U`${et(e)} · ${e.checkedFiles}/${e.totalFiles}`:a?it(a):`No notes`}</button> ${this.team?U`<span class="dependency-review-author">${Ke(e)}</span>`:W} <span class="dependency-review-meta">${r&&s?U`<span class="dependency-review-teams" data-tooltip-truncated data-tooltip="${s}">${s}</span>`:W} ${r&&a>0?U`<span class="dependency-review-note-count">${it(a)}</span>`:W} ${e.revokedAt===null?W:Ue(e)}</span> ${Za(e.publishedAt??e.time)}<div class="dependency-review-row-actions">${this.team?W:U`<dependency-review-copy .text="${e.formatted}"></dependency-review-copy>`} ${this._canDiscard(e)?st(this._loading||!!this._discarding,()=>this._discard(e)):W} <a class="dependency-review-open" href="${fn(t)}" @click="${c}" aria-label="${`${r?`Open`:`Continue`} review for ${P(e)}`}"><span aria-hidden="true">→</span></a></div></div>${n?this._details(e):W}</li>`}render(){let e=JSON.stringify([this.session?.id,this.session?.role,this.team??null]);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());let t=this._error?U`<p role="alert">${this._error}</p>`:W,n=!this._loading&&!this._error&&this._reviews.length===0,r=this._next?U`<button type="button" class="npm-review-button" ?disabled="${this._loading||!this.team&&!!this._discarding}" @click="${()=>this._load(!0)}">Load more</button>`:W;return this.team?U`<section class="dependency-review-list is-team">${t} ${n?U`<p class="npm-review-muted">No reviews are published to this team yet.</p>`:W}<ol>${this._reviews.map(e=>this._row(e))}</ol>${r}</section>`:U`<section class="dependency-review-list"><header><h1>My reviews</h1></header><p>Your private work and the reviews you’ve shared with teams.</p>${t} ${n?U`<p>No reviews yet. Open a package’s Review tab to begin.</p>`:W} ${[[`Drafts`,!1],[`Published reviews`,!0]].map(([e,t])=>{let n=this._reviews.filter(e=>e.publishedAt!==null===t);return U`<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?U`<p class="npm-review-muted">${t?`No published reviews yet.`:`No drafts.`}</p>`:W}</section>`})} ${r}</section>`}};customElements.define(`dependency-review-list`,Qa);
24
+ @compare-view-change=${e=>{e.stopPropagation(),d?.()}}></${m}>`}var ca=400,la=24,ua=[`removed`,`added`,`changed`],da=null,fa=(e,t,n,r,i=null)=>U`<span class="bundle-compare-ver" aria-label="${e}"><span class="bundle-compare-ver-from">${t}</span> <span class="bundle-compare-ver-arrow" aria-hidden="true">→</span> <span class="${`bundle-compare-ver-to ${r}`}">${n}</span>${i?[` `,U`<span class="${`bundle-compare-ver-dir ${r}`}" aria-hidden="true">${i}</span>`]:W}</span>`,pa=class extends G{static properties={details:{attribute:!1},integrity:{attribute:!1},request:{attribute:!1},source:{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(t){t.has(`source`)&&this.source&&!t.get(`source`)&&(this._openSections=new Set([...this._openSections,`files`])),(t.has(`_otherDetails`)||t.has(`details`))&&this._status===`ready`&&!e(this._otherDetails,this.details).some(e=>e.id===this._scope)&&(this._scope=``),t.has(`integrity`)&&this._rebase(),(t.has(`request`)||t.has(`integrity`))&&this.integrity&&this.request?.bundle===this.integrity?(this.request.target!==this._targetIntegrity&&this._choose(this.request.target),this._mode=gn(this.request.mode)):t.has(`request`)&&!t.has(`integrity`)&&t.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,t=e&&da?.base===e?da:null;e&&(da=null),t&&(this._mode=t.mode),this._scope=t?t.scope:``,this._codePath=t?t.codePath:null;let n=t?.target||null;this._targetIntegrity=n;let r=n&&!this.source?w(n,e=>!!(e.json||e.bundle)):null;this._otherDetails=r,this._status=r?`ready`:n?`loading`:`idle`,n&&!r&&this._loadOther(n)}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&&!Ee(N.bundles??[],this.integrity).some(t=>t.integrity===e))return;if(da={base:e,target:t,scope:this._scope,mode:this._mode,codePath:this._codePath},this.source){this.source.open(e,t,this._mode);return}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):(N.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){let t=this.source?null:Ee(N.bundles??[],this.integrity).find(t=>t.integrity===e);if(!this.source&&!t){this._status=`idle`,this._targetIntegrity=null,this._notify();return}let n;try{n=await(this.source?this.source.load(e):te(e,t))}catch(e){if(e.name===`AbortError`)return;if(!this.source)throw e;n={error:e.message}}this._targetIntegrity===e&&(this._otherDetails=n,this._status=`ready`,this.source&&n?.compareId&&n.compareId!==e&&(this._targetIntegrity=n.compareId,this._notify()))}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)}_group(e,t,n,r,i,a=W,{fill:o=!1,lanes:s=ua,style:c={}}={}){return t.length===0?W:U`<section class="${`bundle-compare-group bundle-compare-${n}`}" style="${V({"--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`}">${H(t,r,i)}</ul></section>`}_sizeCells(e){let t=e=>e==null?`—`:z(e),n=e=>`${e.toLocaleString()} LoC`;return e.delta===void 0?U`<span class="bundle-compare-row-size" data-tooltip="${e.lines>0?n(e.lines):W}">${t(e.bytes)}</span>`:U`<span class="${`bundle-compare-row-delta ${e.delta===null?``:Cn(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?`—`:Sn(e.delta)}</span>`}_sortActions(e,t,n,r=!1,i=this[e][t]){return U`<span class="bundles-overview-sort" role="group" aria-label="${`${t} ${n} order`}">${[[`name`,`Name`],[`size`,`Size`],...r?[[`flags`,`Flags`]]:[]].map(([n,r])=>U`<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)):[],...Jr(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`?Ce(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=>U`<li><button type="button" class="bundle-compare-row bundle-compare-row-link" @click="${()=>this._openFile(e.path)}">${a?a.icon(e.path,[[this._otherDetails,e.basePath??e.path],[this.details,e.path]]):W}<span class="bundle-compare-row-path mono" data-tooltip-truncated data-tooltip="${e.renamedFrom==null?e.path:`${e.renamedFrom} \u2192 ${e.path}`}">${e.renamedFrom==null?r(e.path):Jn(r(e.renamedFrom),r(e.path))}</span>${o?a?.tag?.(this.details,e.path,s(e))??W:W}${qr(e.meta)}${this._sizeCells(e)}</button></li>`,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)||fn(e.pkg).localeCompare(fn(t.pkg))),s=n===`changed`?0:Math.min(la,Math.max(0,...t.map(e=>e.versions.join(`, `).length)));return this._group(e,o,n,e=>e.pkg,e=>U`<li><div class="bundle-compare-row"><span class="bundle-compare-pkg-dot" style="${V({background:ln(e.pkg)})}"></span> <span class="bundle-compare-row-path" data-tooltip-truncated data-tooltip="${fn(e.pkg)}">${fn(e.pkg)}</span> ${n===`changed`?this._versionCell(e):s>0?U`<span class="bundle-compare-dep-ver" data-tooltip-truncated data-tooltip="${e.versions.join(`, `)}">${e.versions.join(`, `)}</span>`:W} ${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.join(`, `),n=e.baseVersions.join(`, `);if(e.baseVersions.join()===e.otherVersions.join())return e.baseVersions.length>0?U`<span class="bundle-compare-dep-ver">${n}</span>`:W;let r=e.direction??`changed`,[i,a]=r===`up`?[`↑`,`Upgraded`]:r===`down`?[`↓`,`Downgraded`]:[`±`,`Changed`];return fa(`${a}: ${n||`none`} to ${t||`none`}`,n||`—`,t||`—`,r,i)}_depGroup(e,t,n,r){let i=n===`changed`?0:Math.min(la,Math.max(0,...t.map(e=>e.range.length))),a=e=>U`<span class="bundle-compare-row-path" data-tooltip-truncated data-tooltip="${e.name}">${e.name}</span> ${this.source?.dependencyTags?.(e,n)??W}${e.kind?U`<span class="npm-dependency-kind">${e.kind}</span>`:W} ${n===`changed`?fa(`Changed: ${e.from} to ${e.to}`,e.from,e.to,`changed`):U`<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=>U`<li>${o&&e.opens?U`<button type="button" class="bundle-compare-row bundle-compare-row-link" @click="${()=>o(e)}">${a(e)}</button>`:U`<div class="bundle-compare-row">${a(e)}</div>`}</li>`,W,{fill:!0,lanes:r,style:i>0?{"--compare-version-width":`${i}ch`}:{}})}_renderDependencies(e,t,n,r){return r.length===0?W:U`<section class="bundle-compare-section"><h3 class="bundle-compare-section-head">Dependencies</h3>${this._cols(r,(...e)=>this._depGroup(...e),e,t,n,`dependencies`)}</section>`}_renderPackages(e,t,n,r=ua){return e.removed.length===0&&e.added.length===0&&e.changed.length===0?W:U`<section class="bundle-compare-section"><h3 class="bundle-compare-section-head">Packages</h3>${this._cols(r,(...e)=>this._pkgGroup(...e),e,t,n,`packages`)}</section>`}_cols(e,t,n,r,i,a){let o=e.map(e=>e===`changed`?`minmax(0, 5fr)`:`minmax(0, 4fr)`).join(` `);return U`<div class="bundle-compare-cols" data-lanes="${e.length}" data-section="${a}" style="${V({"--compare-lanes":o})}">${t(`Removed \xB7 only in ${r}`,n.removed,`removed`,e)} ${t(`Added \xB7 only in ${i}`,n.added,`added`,e)} ${t(`Changed`,n.changed,`changed`,e)}</div>`}_collapsible(e,t,n,r,i=``){let a=this._openSections.has(e);return U`<details class="bundle-compare-section bundle-compare-collapsible" .open="${I(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?U`<span class="bundle-compare-section-note" data-tooltip-truncated data-tooltip="${i}">${i}</span>`:W}</summary>${a?r():W}</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 W;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,ca)})),i=(e,t=``)=>U`<td class="${t}"><code data-tooltip-truncated data-tooltip="${e}">${e}</code></td>`,a=(e,t)=>e===null?U`<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})=>U`<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?U`<th>Conditions</th>`:W}</tr></thead><tbody>${H(r,e=>e.key,e=>{let t=o(e);return U`<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?U`<td class="bundle-compare-resolution-context"><span data-tooltip-truncated data-tooltip="${t}">${t}</span></td>`:W}</tr>`})}</tbody></table>${t.length>r.length?U`<div class="bundle-compare-more">and ${(t.length-r.length).toLocaleString()} more…</div>`:W}</section>`))}_comparison(){return Kn(this._otherDetails,this.details,this._scope,this._repaint)}_renderSummary(e){return jn(e,U`<div class="bundle-compare-modes" role="tablist" aria-label="Comparison view">${[[`overview`,`Overview`],[`code`,`Code`]].map(([e,t])=>U`<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 An({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._swap():null,extras:n,comparison:r,openLine:e=>this._openLine(e)})}_baseOptions(){if(this.source)return K(this.source.choices??[]);let e=(N.bundles??[]).find(e=>e.integrity===this.integrity),t=Ee(N.bundles??[],this.integrity);return this._bundleOptions(e?[e,...t]:t)}_otherOptions(){return this.source?K(this.source.options):this._bundleOptions(Ee(N.bundles??[],this.integrity))}_bundleOptions(e){let t=Map.groupBy(e,e=>e.name);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`?z(e.size):`—`,filename:t.get(e.name).length>1?`${e.name} \xB7 ${e.integrity.slice(7,13)}\u2026`:e.name}))}render(){let t=this._otherOptions(),n=!!this._targetIntegrity&&(!!this.source||t.some(e=>e.integrity===this._targetIntegrity)),r=this._baseReady?e(n?this._otherDetails:null,this.details):[],i=r.length>0?U`<bundle-scope-selector .reasons="${r}" .value="${this._scope}" label="Compare scope" @scope-change="${e=>{this._scope=e.detail.value}}"></bundle-scope-selector>`:W,a=n&&this._status===`ready`&&this._otherDetails&&(this._otherDetails.json||this._otherDetails.bundle)&&!this._otherDetails.error,o=this._baseReady&&a?this._comparison():null,s=o?.status===`ready`?o.diff:null,c=s?{base:this._otherDetails,other:this.details,files:s.files}:null,l=t.length>0||this.source?this._renderPicker(t,n,i,c):i,u=s?this._mode:`overview`;return U`<div class="bundle-compare">${Mn(l,s?this._renderSummary(s):W)} ${u===`code`?sa({base:this._otherDetails,other:this.details,diff:s,source:this.source,path:this._codePath,seek:this._codeSeek,baseName:this._nameFor(this._targetIntegrity),otherName:this._nameFor(this.integrity),select:e=>{this._codePath=e}}):U`<div class="bundle-compare-body">${s?this._renderDiff(s):this._empty(t,n,o)}</div>`}</div>`}_empty(e,t,n){let r=U`<strong>${this._nameFor(this.integrity)}</strong>`,i=this.source?.noun??`bundle`,a=(e,t=!1)=>U`<div class="${t?`bundle-compare-empty is-error`:`bundle-compare-empty`}">${e}</div>`;return this._baseReady?this.source&&!t&&(this.source.pending||this.source.error||!this.source.select&&e.length===0)?a(this.source.pending?`Loading ${i}s\u2026`:this.source.error??U`No other ${i}s to compare ${r} with.`,!!this.source.error):e.length===0&&!this.source?a(U`No other bundles to compare with. Drop a second <code>.map</code>, <code>.stasis.code.br</code> or <code>.stasis.tgz</code> bundle to diff against this one.`):t?this._status===`loading`||!this._otherDetails?a(`Comparing…`):this._otherDetails.error?a(`Couldn't read the selected ${i}: ${this._otherDetails.error}`,!0):!this._otherDetails.json&&!this._otherDetails.bundle?a(`The selected ${i} couldn't be parsed.`,!0):n?.status===`error`?a(`Couldn't compare the ${i}s: ${n.message}`,!0):a(`Comparing…`):a(U`Pick a ${i} above to compare ${r} against.`):a(`Loading bundle…`)}_renderDiff(e){let t=this._nameFor(this._targetIntegrity),n=this._nameFor(this.integrity),r={removed:e.files.onlyBase,added:e.files.onlyOther,changed:e.files.changed},i=[...r.removed,...r.added,...r.changed].flatMap(e=>e.renamedFrom==null?[e.path]:[e.path,e.renamedFrom]),a=Gt(e.files.root,un(i).prefix),{prefix:o}=a,s=e=>q(e,o),c=r.removed.length+r.added.length+r.changed.length,l=!e.totals.identical,u=this.source?.dependencies?.(this._otherDetails,this.details)??null,d=ua.filter(t=>(u??e.packageRows)[t].length>0),f=l?ua.filter(e=>r[e].length>0):[],p=f.every(e=>d.includes(e))?d:f,m=l?this.source?.files?.warning?.(this.details,[...r.added,...r.changed].map(e=>e.path)):W;return U`${u?this._renderDependencies(u,t,n,d):this._renderPackages(e.packageRows,t,n,d)} ${m??W} ${e.totals.identical?e.resolutions.totalChanges>0?U`<div class="bundle-compare-caption">File contents are unchanged; import resolutions differ.</div>`:U`<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`})${a.from?U`, moved <span class="mono">${Yn(a)}</span>`:``}.</div>`:this._collapsible(`files`,`Files`,c,()=>this._cols(p,(e,t,n,r)=>this._fileGroup(e,t,n,s,r),r,t,n,`files`),a.from?`${a.from} \u2192 ${a.to}`:o)} ${this._renderResolutions(e.resolutions,t,n)}`}};customElements.define(`bundle-compare`,pa);var ma=/\p{Cc}/u,ha=(e,t)=>t===null?`/dev/null`:`${e}/${t}${t.includes(` `)?` `:``}`;function ga({path:e,kind:t,basePath:n=e,modified:r,before:i,after:a}){let o={from:null,to:e,before:``,after:a},s={from:n,to:null,before:i,after:``};return t===`added`?[o]:t===`removed`?[s]:n===e?t===`repointed`||r===!1||i===a?[]:[{from:e,to:e,before:i,after:a}]:[s,o]}var _a=e=>typeof e==`string`&&!Je(e),va=e=>e===null||!ma.test(e)&&!Je(e);function ya(e){let t=e.flatMap(ga);return t.every(({from:e,to:t,before:n,after:r})=>va(e)&&va(t)&&_a(n)&&_a(r))?t:null}function ba(e){return e.map(({from:e,to:t,before:n,after:r})=>`--- ${ha(`a`,e)}
25
+ +++ ${ha(`b`,t)}
26
+ ${Kt(n,r)}`).join(``)}var $=e=>e._blocked||e._loading,xa=e=>e._shownReview?.publishedAt!=null,Sa=e=>e._error?U`<p class="npm-review-error" role="alert">${e._error}</p>`:W,Ca=e=>e._saveBlocked?U`<div class="npm-review-saving" role="status">Saving changes…</div>`:W,wa=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)),Ta=e=>`npm-review-button npm-review-primary npm-review-finalize ${e._allowedVerdicts[0]}`,Ea=(e,t,n,r,i=Object.keys(qe),a=!1)=>U`<div class="npm-review-verdict-options" role="group" aria-label="Verdict">${Object.entries(a?{"":`Not checked`,...qe}:qe).map(([a,o])=>U`<label class="${`npm-review-verdict-choice ${a||`unchecked`}`}"><input type="radio" name="${e}" aria-label="${o}" value="${a}" .checked="${I(t===a)}" ?disabled="${r||a!==``&&!i.includes(a)}" @change="${()=>n(a)}">${o}</label>`)}</div>`;function Da(e){let t=xa(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,a=t&&n.revokedAt===null&&n.user===e.session?.id?U`<dependency-review-copy .text="${n.formatted}"></dependency-review-copy>`:W;return U`<div class="npm-review-summary-actions">${t||e._draftStarted?U`<span class="npm-review-status">${a}${ot(n??{publishedAt:null,revokedAt:null})}</span>`:W}<div class="npm-review-progress-block"><span>${e._unsaved&&(e._saveBlocked||e._error)?U`<button type="button" class="npm-review-button npm-review-text-button" @click="${()=>e._openPanel(`unsaved`)}">Unsaved changes</button>`:U`<strong>${r.checkedFiles} of ${r.totalFiles}</strong> files checked`}</span> ${ft(r.checkedFiles,r.totalFiles)}</div>${i?U`<button type="button" class="${e._canEdit?Ta(e):`npm-review-button`}" ?disabled="${$(e)||i.disabled}" @click="${i.run}">${i.label} ${E}</button>`:W}</div>`}var Oa=(e,t)=>e.some(e=>e.id===t)?e:[...e,...K([{id:t,name:t,format:`npm`}])];function ka(e,t,n,r,i){if(!r)return null;let a=e.findIndex(e=>e.id===t),o=`patch:${r.slice(0,5)}`;return e.splice(a,1,{...e[a],detail:o,detailNote:i},{...e[a],id:`${t} unpatched`}),{name:n,detail:o,detailNote:i}}function Aa(e){let t=e.source??Te(e.entry),{name:n,version:r}=e.entry.npm,i=!!(e._target&&e._target!==`(empty)`),a=K(t.options,e=>`${n}@${e.id}`),o=i?Oa(a,e._target):a,s=Oa(K(t.choices),r),c=`${e._target} unpatched`,l=`${r} unpatched`,u=ka(s,r,`${n}@${r}`,e._patch?.hash,Ma(ja(e))),d=ka(o,e._target,e._target,i&&e._basePatch,Ma(e._base?.npmPatch?.patch));return Mn(An({source:u||d?{...t,widest:u||d}:t,label:`Review`,disabled:$(e),from:{options:o,value:i?e._target:null,label:`Review base`,pick:t=>{e._navigate(t===c?e._target:t,t===e._target?e._basePatch:null)}},to:{options:s,value:r,label:`Version to review`,pick:t=>{e._navigateTo({view:`npm`,packageName:n,packageSpec:t===l?r:t,bundleTab:`review`,...e._location(e._target,t===r)})}},clear:i?{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?jn(e._diff):W)}var ja=e=>e._patched?.npmPatch?.patch??e._patch,Ma=e=>`As pnpm\u2019s patch${e?.path?` ${e.path}`:``} changes it`,Na=e=>`${Ma(ja(e))}${ja(e).commit?`, read at ${ja(e).commit.slice(0,7)}`:``}`,Pa=e=>e._patch?U`<span class="npm-review-patched" data-tooltip="${Na(e)}">patch:${e._patch.hash}</span>`:W;function Fa(e){return U`<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="${$(e)}" @click="${()=>{e._navigateTo({view:`reviews`})}}">My reviews</button> ${E}<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">${wa(e).length}</span></button> ${Pa(e)}</nav>${Da(e)}</div>`}function Ia(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 U`<section class="${`npm-review-decision${n?` npm-review-inline-decision`:``}`}" aria-label="File decision">${e._canEdit?U`${Ea(`file:${t}`,a?``:r.status,n=>{e._setFileStatus(t,n)},$(e)||a,void 0,!0)} ${a?U`<p class="npm-review-help">Non-text file. Verdicts are not supported yet; this file remains unchecked.</p>`:W} ${o?U`<textarea aria-label="File note" rows="2" maxlength="20000" placeholder="Add a note (optional)…" .value="${I(r.comment)}" ?disabled="${$(e)}" @input="${n=>e._editFile(t,{comment:n.target.value})}" @blur="${()=>{e._saveFile(t)}}"></textarea>`:W}`:U`${n?W:U`<header><strong>File review</strong><span class="npm-review-muted">${xa(e)?`Frozen`:`Read only`}</span></header>`} ${i?.status&&!a?U`${it(i.status)}${Tt(i.comment)}`:U`<p class="npm-review-muted">This file was not reviewed.</p>`} ${e._reviewer||e._loading?W:U`<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 La(e,t,n,r,i,a){return U`<fieldset class="npm-review-team-options"><legend>${t}</legend>${n.map(t=>U`<mode-switch label="${t.name}" .checked="${r.has(t.id)}" .disabled="${$(e)}" @click="${()=>{if($(e))return;let n=new Set(r);n.delete(t.id)||n.add(t.id),i(n)}}"></mode-switch>`)}${a}</fieldset>`}function Ra(e,t){let n=e._allowedVerdicts,r=$t(t.entries,e._files,e._nonTextFiles),i=t.entries.filter(t=>t.status&&t.comment.trim()&&!e._nonTextFiles.includes(t.file));return U`<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>${r.coverage===`full`?`Full`:`Partial`} review</strong><span>${r.checkedFiles} of ${r.totalFiles} files checked</span></div>${ft(r.checkedFiles,r.totalFiles)}<p>${r.totalFiles>r.checkedFiles?U`${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?U`<p class="npm-review-error">Review ${e._files.includes(`package.json`)?U`<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>`:W}</section>${i.length>0?U`<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=>U`<li>${gt(e.file)} ${Tt(e.comment)}</li>`)}</ul></section>`:W}<div><strong>Final verdict</strong>${Ea(`final-verdict`,e._finalStatus,t=>{e._finalStatus=t},$(e),n)}</div>${e._securityLimit===`reject`?U`<p class="npm-review-help">Malware detected. Only Reject is available.</p>`:e._securityLimit===`request-changes`?U`<p class="npm-review-help">Critical vulnerabilities detected.</p>`:W} <label>Final note <span class="npm-review-muted">· optional</span><textarea aria-label="Final comment" rows="3" maxlength="20000" .value="${I(e._finalComment)}" placeholder="Summarize your findings or explain what remains…" ?disabled="${$(e)}" @input="${t=>{e._finalComment=t.target.value}}"></textarea></label> ${e._unchangedContinuation?U`<p class="npm-review-help">Change a verdict or note to publish a new review.</p>`:W} ${La(e,`Publish to teams`,e._teams,e._selectedTeams,t=>{e._selectedTeams=t},e._selectedTeams.size>0?W:U`<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>`)} ${Sa(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="${Ta(e)}" ?disabled="${$(e)||!e._canPublish}">Publish to ${e._selectedTeams.size} ${e._selectedTeams.size===1?`team`:`teams`} ${E}</button></footer></form>`}function za(e,t){let n=t===e._shownReview,r=t.publishedAt!==null,i=r?t:M(t,e._context)?$t(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 U`<section class="npm-review-entry" aria-current="${String(n)}"><div class="npm-review-history-heading"><strong>${ct(t)}</strong>${n?U`<span class="npm-review-current">Current</span>`:W}${ot(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?it(t.status):W}<span class="dependency-review-coverage"> ${r?U`${mt(i)} · `:W}${i.checkedFiles}${i.totalFiles===null?W:`/${i.totalFiles}`} files checked</span></div><p class="npm-review-help">${t.teams.length>0?`${t.teams.map(e=>e.name).join(`, `)} \xB7 `:``}${ut(t.publishedAt??t.time)}</p>${Tt(t.comment)}<div class="npm-review-entry-actions"><button type="button" class="npm-review-button" ?disabled="${$(e)}" @click="${()=>{e._openReview(t)}}">Open ${E}</button> ${r&&o&&!a&&e._reviewer?U`<button type="button" class="npm-review-button" aria-label="Revise in a new draft" ?disabled="${$(e)}" @click="${()=>{e._openReview(t,!0)}}">Revise</button>`:W} ${r&&o&&e._writable&&t.revokedAt===null?U`<button type="button" class="npm-review-button npm-review-danger" ?disabled="${$(e)}" @click="${()=>e._change({action:`revoke`,reviewId:t.id,revision:t.revision})}">Revoke</button>`:W} ${o?U`<dependency-review-copy .text="${t.formatted}"></dependency-review-copy>`:W} ${!r&&o&&e._writable?xt($(e),()=>{e._discard(t)}):W}</div>${r&&o&&e._writable&&t.revokedAt===null&&s.length>0?U`<details class="npm-review-share"><summary>Publish to more teams</summary>${La(e,`Teams`,s,c,n=>{e._additionalTeams=new Map(e._additionalTeams).set(t.id,n)},U`<button type="button" class="npm-review-button" ?disabled="${$(e)||l.length===0}" @click="${()=>e._change({action:`publish`,reviewId:t.id,revision:t.revision,teamIds:l})}">Publish to more teams</button>`)}</details>`:W} ${t.revokedAt===null?W:U`<p class="npm-review-help">Revoked ${ut(t.revokedAt)}. Content and team links remain frozen.</p>`}</section>`}function Ba(e){if(!e._panel)return W;let t={publish:`Publish review`,reviews:`Reviews`,unsaved:`Unsaved changes`};return U`<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)`:``}`:P(e._context)}</p></header>${e._panel===`publish`?Ra(e,e._activeReview):U`<div class="${`npm-review-dialog-body${e._panel===`reviews`?` npm-review-entries`:``}`}">${e._panel===`unsaved`?U`${e._dirtyFiles.map(t=>U`<button type="button" class="npm-review-button" @click="${()=>{e._closePanel(),e._selectFile(t)}}">${t} ${E}</button>`)}`:wa(e).map(t=>za(e,t))} ${e._panel===`reviews`&&wa(e).length===0?U`<p class="npm-review-muted">No reviews yet.</p>`:W}${Sa(e)}</div>`} ${Ca(e)}</dialog>`}function Va(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=Ct(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}, ${qe[i.get(e)?.status]??`Not reviewed`}`,filePrefix:e=>Ze(i.get(e)?.status),fileSuffix:e=>i.get(e)?.notes?U`<span class="npm-review-note-dot" aria-label="Has notes">•</span>`:W,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:U`<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)=>Ia(e,t,n),copyDiff:e._unified?.length>0?()=>e._unifiedText??=ba(e._unified):null}}function Ha(e){if(!e._base){let t=U`<div class="npm-review-empty" role="${e._baseError?`alert`:`status`}">${e._baseError??`Loading comparison…`} ${e._baseError?U`<button type="button" class="npm-review-button" @click="${()=>{e._baseKey=null,e._loadBase(e._target,e.request?.resume)}}">Retry</button>`:W}</div>`;return e._baseError&&e._basePatch?U`${Aa(e)}${t}`:t}return U`${Aa(e)}${Fa(e)}${e._panel?W:Sa(e)} ${sa({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:Va(e),mode:e._mode,viewChanged:()=>e._viewChanged()})} <span class="npm-review-announcement" role="status">${e._notice??``}</span>${e._panel?W:Ca(e)}${Ba(e)}`}var Ua=Object.freeze([]),Wa={maxLines:5e4,maxBytes:2097152},Ga={integrity:`(empty)`,kind:`sourcemap`,json:{version:3,sources:[],sourcesContent:[]},fileSizes:new Map},Ka=(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}),qa=(e,t)=>e?`${e}@${t??`latest`}`:`(empty)`,Ja=e=>class extends e{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._unified=null,this._unifiedText=null,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()}get _routed(){return N.bundleDetailsTab===`review`&&N.selectedBundle===this.entry?.integrity}_rememberBase(){!this._routed||!this._context||!this._activeReview&&this._ownPublished.length===0&&!this._unsaved||(N.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}_ownHere(e){return e.user===this.session?.id&&M(e,this._context)}get _activeReview(){return this._reviews.find(e=>e.publishedAt===null&&this._ownHere(e))??(this._continuation&&this._continuation.review.user===this.session?.id?this._continuation.review:null)}get _ownPublished(){return this._reviews.filter(e=>e.publishedAt!==null&&this._ownHere(e)).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(){let e=this._shownReview?.entries??Ua,t=this._summaryHeld;if(t?.entries===e&&t.files===this._files&&t.nonText===this._nonTextFiles)return t.summary;let n=$t(e,this._files,this._nonTextFiles);return this._summaryHeld={entries:e,files:this._files,nonText:this._nonTextFiles,summary:n},n}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 en([...e.values()].filter(e=>!this._nonTextFiles.includes(e.file)),this._securityLimit)}get _needsPackageJson(){return tn(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 _publishReady(){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)}get _canPublish(){return this._askable&&this._publishReady}_location(e,t=!0,n=e===this._target?this._basePatch:null){let r=e&&e!==`(empty)`?o(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(c(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 A?.navigate(e.bundleTab===`review`?{...e,...Ae(N)}:e)}_shownRoute(e=this._base){let t=this._location(qa(e.npm?.name,e.npm?.version),!0,e.npmPatch?.patch.hash??null);return c(this.entry,`review`,{...t,...Ae(N)})}_viewChanged(){this._routed&&this._base&&this._context&&A?.replaceRoute(this._shownRoute())}_baseKeyOf(e){return JSON.stringify([this.entry.integrity,e,this._patch,this._basePatch,this.session?.id,this.session?.role])}_restart(){this._controller.abort(),this._cancelSaves(),this._controller=new AbortController}async _loadBase(e,t=!1){let n=this._baseKeyOf(e);if(this._baseKey!==n){this._baseKey=n,this._base=null,this._baseError=null,this._key=null,this._restart();try{let r=this._controller.signal,i=this._patch?b(this.entry,this._patch,{signal:r}):Promise.resolve(this.details);i.catch(()=>{});let a=t?await ae(Ka(this.entry,null,this._patch),r):null;if(this._baseKey!==n)return;a&&([e,this._basePatch]=[qa(a.basePackage,a.baseVersion),a.basePatchHash??null]);let s=e===`(empty)`?null:o(e),c=s?await d(s.name,s.spec??`latest`):null,l=c&&this._basePatch?{...await b(c.entry,{hash:this._basePatch},{signal:r}),npm:c.details.npm}:c?.details??Ga,u=await i;if(this._baseKey!==n)return;let f=await qn(l,u);if(this._baseKey!==n)return;t&&(a&&Ot(a),this._target=e,this.request={bundle:this.entry.integrity,...this._location(e)},this._baseKey=this._baseKeyOf(e)),this._patched=this._patch?u:null,this._base=l,this._ensureContext(l,f)}catch(e){this._baseKey===n&&([this._baseError,this._baseStatus]=[e.message,e.status??null])}}}_ensureContext(e,n){let r=Ka(this.entry,e,this._patch),i=JSON.stringify([this.session?.id,this.session?.role,r]);if(i===this._key)return;this._restart(),this._context=r,this._diff=n;let a=nr(e,this._other,this._diff);this._files=$e(t(a.map(e=>e.path)));let o=new Set(a.filter(e=>!Qt(e.before,e.after)).map(e=>e.path));this._nonTextFiles=this._files.filter(e=>o.has(e));let s=new Map(a.map(e=>[e.path,e]));if(this._unified=ya(this._files.map(e=>s.get(e))),this._unifiedText=null,this._mode=rr(a,Wa)?`diff`:`code`,this._key=i,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),this._routed){let t=qa(e.npm?.name,e.npm?.version),n=this._location(t,!0,e.npmPatch?.patch.hash??null);N.npmReview={bundle:this.entry.integrity,...n},this._baseKey=this._baseKeyOf(t),A?.replaceRoute(this._shownRoute(e))}}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;let n=this._loadingShown();this._loading=!0,this._error=null;try{let{reviews:n,teams:r}=await p({...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.publishedAt===null&&this._ownHere(e))&&(this._continuation=null),this._rememberBase();let i=At(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._clearEditors(this._file)}}catch(e){t===this._key&&e.name!==`AbortError`&&(this._error=e.message)}finally{n(),t===this._key&&(this._loading=!1)}}_loadingShown(){return this._dismissLoading?.(),this._dismissLoading=ke(`Loading reviews…`,{duration:0})}_resetEditor(e=null){this._publishRevision=null,this._file=e,this._editorState(e)}_clearEditors(e=this._path){this._editors.clear(),this._resetEditor(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,r=this._nonTextFiles.includes(e);t={edit:n,revision:this._activeReview?.revision??null,comment:r?``:n?.comment??``,status:r?``: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||(Ot(e,t),await this._navigate(qa(e.basePackage,e.baseVersion),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 Jt({reviewTitle:P(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 T(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._clearEditors(),this._finalStatus=null,this._finalComment=``,this._panel=null,this._ownPublished.length===0&&N.npmReview?.bundle===this.entry.integrity&&delete N.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.publishedAt!==null&&this._ownHere(n));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._clearEditors(),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 p(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}_putReview(e){this._reviews=[...this._reviews.filter(t=>t.id!==e.id),e]}_acceptSave(e,t){this._putReview(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 p(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}}}get _askable(){return!this._blocked&&this._pendingSaves.length===0&&!this._loading&&this._writable}async _ask(e,t){if(!this._askable)return null;let n=this._key;this._saving=!0,this._error=null;try{let r=await e();if(!r||n!==this._key)return null;let{review:i}=await p(r.context,r.change,this.session.csrfToken,this._controller.signal);return n===this._key?(t(i),i):null}catch(e){return n===this._key&&e.name!==`AbortError`&&(this._error=e.message),null}finally{n===this._key&&(this._saving=!1)}}_askedFor(e){return{context:this._asked(this._reviews.find(t=>t.id===e.reviewId)??this._context),change:e}}_change(e){return e.action===`continue`?Promise.resolve(this._askable?this._continue(e.reviewId,e.revision):null):this._ask(()=>this._askedFor(e),e=>{this._putReview(e),this._rememberBase()})}_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(){return this._ask(()=>this._publication(),e=>this._published({review:e}))}async _publication(){if(!this._publishReady)return null;let e={action:`publish`,reviewId:this._activeReview.id,revision:this._publishRevision,teamIds:[...this._selectedTeams],finalStatus:this._finalStatus,finalComment:this._finalComment};if(e.finalStatus&&this._continuation){let t=await this._persistContinuation();if(!t)return null;e={...e,reviewId:t.id,revision:t.revision}}return this._askedFor(e)}_published({review:e,error:t}){return t?(this._error=t,!1):(this._putReview(e),M(e,this._context)&&(this._selectedReview=e.id,this._panel=null,this._editors.clear(),this._notice=`Published. Verdicts and notes are now frozen.`),this._rememberBase(),!0)}render(){if(!this.entry?.npm||!this.details)return W;let e=this.request?.bundle===this.entry.integrity?this.request:{};return this._target=qa(e.reviewPackage,e.reviewSpec),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),Ha(this)}},Ya=class extends Ja(G){};customElements.define(`npm-review`,Ya);var Xa=2,Za=(e,t)=>`${e.toLocaleString(`en-US`)} ${t}${e===1?``:`s`}`,Qa=(e,t)=>+(e.unreached===!0)-(t.unreached===!0)||e.name.localeCompare(t.name),$a=class extends Ja(class{}){constructor(e,t,{review:n,repoId:r,head:i}){super(),this._page=e,this.pkg=t,this.key=l(t),this.target=hn(t,n),this._patch=t.patch?.path?{hash:t.patch.hash,repoId:r,commit:i,path:t.patch.path}:null,this._started=!1,this._busyTries=0}get session(){return this._page.session}get source(){return this._source??=Te(this.entry)}get status(){return this._baseError?`error`:this._base?`ready`:this._started?`loading`:`waiting`}get _routed(){return!1}_loadingShown(){return()=>{}}requestUpdate(){this._page?.requestUpdate()}get title(){return this._context?P(this._context):`${this.pkg.name} ${this.pkg.version}`}get route(){return{view:`npm`,packageName:this.pkg.name,packageSpec:this.pkg.version,bundleTab:`review`,...this.target?{reviewPackage:this.target.name,reviewSpec:this.target.version}:{},...this._patch?{patch:this._patch}:{}}}dispose(){this._controller.abort(),this._cancelSaves(),this._key=this._baseKey=null}async load(){this._started=!0,this._baseError=null,this._baseStatus=null,this._baseKey=null,this.target&&h(this.target.name,this.target.version);try{({entry:this.entry,details:this.details}=await d(this.pkg.name,this.pkg.version)),await this._loadBase(this.target?`${this.target.name}@${this.target.version}`:`(empty)`)}catch(e){[this._baseError,this._baseStatus]=[e.message,e.status??null]}this._baseStatus===429?(this._baseError=null,re(D(this._busyTries++),()=>{this._started=!1,this._page?.isConnected&&this._page._loadNext()})):this._busyTries=0}};for(let e of Object.keys($a.properties))Object.hasOwn($a.prototype,e)||Object.defineProperty($a.prototype,e,{get(){return this._drawn?.[e]},set(t){(this._drawn??={})[e]=t,this.requestUpdate()}});function eo(e){let{pkg:t,target:n}=e,r=e._shownReview,i=e._summary;return U`${qt(`npm`)}<span class="bundle-code-tree-dirname pull-review-package-label" data-tooltip-truncated data-tooltip="${e.title}"> <span class="pull-review-package-name">${t.name}</span><span class="pull-review-package-version">${n?`${n.name===t.name?n.version:`${n.name}@${n.version}`} \u2192 `:`new `}${t.version}</span>${e._patch?U`<span class="team-deps-patched">patched</span>`:W}</span>${ce(t)} ${r?.publishedAt!=null&&r.revokedAt===null?tt({status:r.status,partial:i.coverage===`partial`}):r?ot(r):W}<npm-delta .name="${t.name}" .version="${t.version}" .base="${n?.version??`(empty)`}" .baseName="${n?.name??t.name}" .patch="${e._patch}"></npm-delta><span class="bundle-compare-code-dir-count">${e.status===`ready`?`${i.checkedFiles}/${i.totalFiles}`:e.status===`error`?`!`:`…`}</span>`}var to=class extends G{static properties={team:{attribute:!1},repositories:{attribute:!1},pull:{attribute:!1},session:{attribute:!1},_selected:{state:!0},_panel:{state:!0},_includePartial:{state:!0},_selectedTeams:{state:!0},_publishing:{state:!0},_notice:{state:!0}};createRenderRoot(){return this}constructor(){super(),this._units=new Map,this._selected=null,this._panel=null,this._includePartial=!1,this._selectedTeams=null,this._publishing=!1,this._notice=``,this._notify=e=>{(!e||e.repoId===this.pull?.repoId&&e.number===this.pull?.number)&&this.requestUpdate()},this._controller=new AbortController}connectedCallback(){super.connectedCallback(),this._unsubscribe=zt(this._notify)}disconnectedCallback(){super.disconnectedCallback(),this._controller.abort(),this._controller=new AbortController,this._unsubscribe?.();for(let e of this._units.values())e.dispose()}updated(){let e=this.querySelector(`:scope > dialog`);e&&!e.open&&e.showModal?.()}get _blocked(){return this._publishing||[...this._units.values()].some(e=>e._blocked)}get _repository(){return(this.repositories??[]).find(e=>e.repoId===this.pull?.repoId)??null}willUpdate(){let e=this.pull;if(this._answer=e&&this._repository?f(e.repoId,e.number,!0):null,this._answer?.status!==`ready`||!this._answer.review?.canReview)return;let t=this._units.size;for(let t of ee(this._answer))this._units.has(l(t))||this._units.set(l(t),new $a(this,t,{review:this._answer.review,repoId:e.repoId,head:this._answer.head}));this._units.size>t&&(this._units=new Map([...this._units].toSorted(([,e],[,t])=>Qa(e.pkg,t.pkg)))),this._units.has(this._selected)||(this._selected=this._units.keys().next().value??null),this._loadNext()}_loadNext(){let e=[...this._units.values()],t=e.filter(e=>e.status===`loading`).length;for(let n of new Set([this._units.get(this._selected),...e]))if(n?.status===`waiting`){if(t++>=Xa)break;n.load().finally(()=>{this.isConnected&&this._loadNext()})}}_select(e,t=null){e._blocked||this._panel||(e.key!==this._selected&&(this._selected=e.key,this._loadNext()),t&&e._selectFile(t))}get _drafts(){return[...this._units.values()].filter(e=>e.status===`ready`&&e._canEdit&&e._activeReview&&e._summary.checkedFiles>0)}_publishable(e){return e._canPublish&&(this._includePartial||e._summary.coverage===`full`)}_pickTeams(e){this._selectedTeams=e;for(let t of this._units.values())t._selectedTeams=e}async _beginPublish(){if(this._blocked)return;for(let e of this._drafts)await e._beginPublish();let e=this._drafts[0]?._teams;e&&(this._pickTeams(this._selectedTeams??new Set(e.length===1?[e[0].id]:[])),this._notice=``,this._panel=`publish`)}_closePanel(){if(!this._publishing){for(let e of this._units.values())e._panel=null;this.querySelector(`:scope > dialog`)?.close?.(),this._panel=null}}async _publishAll(){let e=this._drafts.filter(e=>this._publishable(e));if(this._publishing||e.length===0)return;this._publishing=!0;let t=0,n=[];try{for(let t of e){let e=t._key;try{let r=await t._publication();r&&e===t._key&&n.push({unit:t,key:e,publication:r})}catch(n){e===t._key&&n.name!==`AbortError`&&(t._error=n.message)}}for(let{unit:e}of n)e._saving=!0;let r=await ne(n.map(e=>e.publication),this.session.csrfToken,this._controller.signal);for(let[e,{unit:i,key:a}]of n.entries())a===i._key&&i._published(r[e])&&t++}catch(t){if(t.name===`AbortError`)return;for(let n of e)n._error=t.message}finally{for(let{unit:e,key:t}of n)t===e._key&&(e._saving=!1);this._publishing=!1}g([{repoId:this.pull.repoId,number:this.pull.number}]),this._notice=`Published ${Za(t,`review`)}${t<e.length?`; ${e.length-t} failed`:``}.`,t===e.length&&this._closePanel()}_said(e){return e?e.status===`loading`?`Reading its dependencies…`:e.status===`error`?e.error:e.review?e.review.canReview?this._units.size===0?`None of its versions wants your review here.`:null:`You publish reviews to no team counting for its repository.`:`Its repository reviews no dependencies for you.`:`This pull request’s repository is none of this team’s.`}render(){let e=this._answer,t=this.pull?this._said(e):``;if(t!==null)return U`<p class="npm-review-empty" role="status">${t}</p>`;let n=this._units.get(this._selected);return U`${this._toolbar(e,n)}${this._view(n)}<span class="npm-review-announcement" role="status">${this._notice}</span>${this._dialog()}`}_toolbar(e,t){let n=[...this._units.values()].filter(e=>e.status===`ready`),r=n.reduce((e,t)=>e+t._summary.checkedFiles,0),i=n.reduce((e,t)=>e+t._summary.totalFiles,0);return U`<div class="npm-review-toolbar"><nav class="npm-review-toolbar-group" aria-label="Review breadcrumbs"><a class="pull-review-pull" href="${`https://github.com/${this._repository.name}/pull/${this.pull.number}`}" target="_blank" rel="noopener noreferrer">${this._repository.name}#${this.pull.number}</a> ${ie(e,!0)}${E}<a class="npm-review-button npm-review-text-button npm-review-package" href="${_n(t.route)}" target="_blank" rel="noopener noreferrer"><span>${t.title}</span></a>${Pa(t)}</nav><div class="npm-review-summary-actions">${e.formatted?U`<dependency-review-copy .text="${e.formatted}" .label="${`Copy your dependency reviews`}"></dependency-review-copy>`:W}<div class="npm-review-progress-block"><span><strong>${r} of ${i}</strong> files checked</span>${ft(r,i)}</div><button type="button" class="npm-review-button npm-review-primary" ?disabled="${this._blocked||this._drafts.length===0}" @click="${()=>{this._beginPublish()}}">Finalize reviews ${E}</button></div></div>`}_tree(e,t){return U`<ul class="bundle-code-tree root" aria-label="Versions to review">${[...this._units.values()].map(n=>U`<li class="${B({"bundle-code-tree-dir":!0,"pull-review-package":!0,current:n===e})}"><details ?open="${n===e}"><summary @click="${e=>{e.preventDefault(),this._select(n)}}"><span class="bundle-code-tree-chevron" aria-hidden="true"></span>${eo(n)}</summary>${n===e?t:W}</details></li>`)}</ul>`}_view(e){if(e.status!==`ready`){let t=e.status===`error`?U`${e._baseError} <button type="button" class="npm-review-button npm-review-text-button" @click="${()=>{e.load(),this.requestUpdate()}}">Retry</button>`:`Reading its files…`;return U`<div class="bundle-code-view"><aside class="bundle-code-rail"><div class="bundle-code-rail-body">${this._tree(e,U`<p class="pull-review-package-note" role="status">${t}</p>`)}</div></aside></div>`}return U`${e._error?U`<p class="npm-review-error" role="alert">${e._error}</p>`:W} ${sa({base:e._base,other:e._other,diff:e._diff,source:e.source,path:e._path,seek:null,baseName:e._base.npm?`${e._base.npm.name}@${e._base.npm.version}`:`Empty package`,otherName:`${e.pkg.name}@${e.pkg.version}${e._patch?` (patched)`:``}`,select:t=>this._select(e,t),extensions:{...Va(e),railTree:t=>this._tree(e,t)},mode:e._mode})} ${e._saveBlocked?U`<div class="npm-review-saving" role="status">Saving changes…</div>`:W}`}_dialog(){if(this._panel!==`publish`)return W;let e=this._publishing,t=this._drafts,n=this._selectedTeams??new Set,r=t[0]?._teams??[],i=t.filter(e=>this._publishable(e)).length;return U`<dialog class="npm-review-dialog" aria-label="Publish reviews" @cancel="${e=>{e.preventDefault(),this._closePanel()}}"><button type="button" class="detail-action npm-review-close" aria-label="Close panel" ?disabled="${e}" @click="${()=>this._closePanel()}">×</button><header class="npm-review-dialog-head"><h2>Publish reviews</h2><p>${this._repository.name}#${this.pull.number}</p></header><form class="npm-review-publish-form" @submit="${e=>{e.preventDefault(),this._publishAll()}}"><div class="npm-review-dialog-body"><mode-switch class="pull-review-partial" label="Include partial" .checked="${this._includePartial}" .disabled="${e}" @click="${()=>{e||(this._includePartial=!this._includePartial)}}"></mode-switch><ul class="pull-review-finals" aria-label="Reviews to publish">${t.map(t=>this._final(t,e))}</ul>${La(this,`Publish to teams`,r,n,e=>this._pickTeams(e),n.size>0?W:U`<p class="npm-review-error">Select at least one team to publish.</p>`)}</div><footer class="npm-review-dialog-footer"><p>Publishing freezes their verdicts and notes.</p><button type="submit" class="npm-review-button npm-review-primary" ?disabled="${e||i===0}">Publish ${Za(i,`review`)} to ${Za(n.size,`team`)} ${E}</button></footer></form></dialog>`}_final(e,t){let n=e._summary,r=n.coverage===`full`,i=!r&&!this._includePartial?`Partial: published with Include partial on.`:e._needsPackageJson?`Review package.json before publishing a partial review.`:e._unchangedContinuation?`Change a verdict or note to publish a new review.`:null;return U`<li class="${B({"pull-review-final":!0,"is-left":i!==null})}"><div class="pull-review-final-head"><strong>${e.title}</strong><span>${r?`Full`:`Partial`} · ${n.checkedFiles}/${n.totalFiles}</span></div>${i?U`<p class="npm-review-help">${i}</p>`:U`${Ea(`final:${e.key}`,e._finalStatus,t=>{e._finalStatus=t},t,e._allowedVerdicts)} <textarea aria-label="${`Final comment on ${e.title}`}" rows="2" maxlength="20000" .value="${I(e._finalComment)}" placeholder="Final note (optional)…" ?disabled="${t}" @input="${t=>{e._finalComment=t.target.value}}"></textarea>`} ${e._error?U`<p class="npm-review-error" role="alert">${e._error}</p>`:W}</li>`}};customElements.define(`pull-dependency-review`,to);var no=e=>({view:`npm`,packageName:e.package,packageSpec:e.version,bundleTab:`review`,...e.basePackage===null?{}:{reviewPackage:e.basePackage,reviewSpec:e.baseVersion},...mn(e.patchHash)&&e.patchSource?{patch:{hash:e.patchHash,...e.patchSource}}:{},...mn(e.basePatchHash)&&e.basePackage!==null?{basePatch:e.basePatchHash}:{}}),ro=e=>{let t=new Date(e);return U`<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>`},io=class extends G{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 Jt({reviewTitle:P(e),signal:n});if(!r||n.aborted||t!==this._key||!this._canDiscard(e)||(await T(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=ke(`Loading reviews…`,{duration:0});this._loading=!0,this._error=null;try{let n=e?this._next:null,{reviews:r,next:i}=await(this.team?x(this.team,n,this._controller.signal):_(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.delete(e)||t.add(e),this._expanded=t}_details(e){let t=e.entries.filter(e=>e.status);return U`<section id="${`review-details-${e.id}`}" class="dependency-review-details" aria-label="${`Details for ${P(e)}`}">${e.comment?U`<div class="dependency-review-final-note" role="note" aria-label="Final note">${Tt(e.comment)}</div>`:W} ${t.length>0?U`<ul class="dependency-review-entries">${t.map(e=>U`<li>${gt(e.file)} ${it(e.status)}<div>${Tt(e.comment)}</div></li>`)}</ul>`:U`<p class="npm-review-muted">No file reviews yet.</p>`}</section>`}_row(e){let t=no(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||!A?.active||(n.preventDefault(),Ot(e),A.navigate(t))};return U`<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="${_n(t)}" @click="${c}">${qt(e.ecosystem)} ${e.basePackage!==null&&e.basePackage!==e.package?U`<span>${e.basePackage} ${e.baseVersion} →</span>`:W} <strong>${e.package}</strong> <span>${e.basePackage===e.package?`${e.baseVersion} \u2192 `:``}${e.version}${e.patchHash?U`<span class="dependency-review-patched">patch:${e.patchHash}</span>`:W}</span></a> <span class="dependency-review-result">${r?it(e.status):U`<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`:W}" @click="${()=>this._toggleDetails(e.id)}">${r?U`${mt(e)} · ${e.checkedFiles}/${e.totalFiles}`:a?vt(a):`No notes`}</button> ${this.team?U`<span class="dependency-review-author">${ct(e)}</span>`:W} <span class="dependency-review-meta">${r&&s?U`<span class="dependency-review-teams" data-tooltip-truncated data-tooltip="${s}">${s}</span>`:W} ${r&&a>0?U`<span class="dependency-review-note-count">${vt(a)}</span>`:W} ${e.revokedAt===null?W:ot(e)}</span> ${ro(e.publishedAt??e.time)}<div class="dependency-review-row-actions">${this.team?W:U`<dependency-review-copy .text="${e.formatted}"></dependency-review-copy>`} ${this._canDiscard(e)?xt(this._loading||!!this._discarding,()=>this._discard(e)):W} <a class="dependency-review-open" href="${_n(t)}" @click="${c}" aria-label="${`${r?`Open`:`Continue`} review for ${P(e)}`}"><span aria-hidden="true">→</span></a></div></div>${n?this._details(e):W}</li>`}render(){let e=JSON.stringify([this.session?.id,this.session?.role,this.team??null]);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());let t=this._error?U`<p role="alert">${this._error}</p>`:W,n=!this._loading&&!this._error&&this._reviews.length===0,r=this._next?U`<button type="button" class="npm-review-button" ?disabled="${this._loading||!this.team&&!!this._discarding}" @click="${()=>this._load(!0)}">Load more</button>`:W;return this.team?U`<section class="dependency-review-list is-team">${t} ${n?U`<p class="npm-review-muted">No reviews are published to this team yet.</p>`:W}<ol>${this._reviews.map(e=>this._row(e))}</ol>${r}</section>`:U`<section class="dependency-review-list"><header><h1>My reviews</h1></header><p>Your private work and the reviews you’ve shared with teams.</p>${t} ${n?U`<p>No reviews yet. Open a package’s Review tab to begin.</p>`:W} ${[[`Drafts`,!1],[`Published reviews`,!0]].map(([e,t])=>{let n=this._reviews.filter(e=>e.publishedAt!==null===t);return U`<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?U`<p class="npm-review-muted">${t?`No published reviews yet.`:`No drafts.`}</p>`:W}</section>`})} ${r}</section>`}};customElements.define(`dependency-review-list`,io);