@preventive/triage 1.0.0-alpha.8 → 1.0.0-alpha.9

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/view.js CHANGED
@@ -1,58 +1,59 @@
1
- var No=globalThis,Uo=No.ShadowRoot&&(No.ShadyCSS===void 0||No.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,_d=Symbol(),xd=new WeakMap,Do=class{constructor(t,r,n){if(this._$cssResult$=!0,n!==_d)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=r}get styleSheet(){let t=this.o,r=this.t;if(Uo&&t===void 0){let n=r!==void 0&&r.length===1;n&&(t=xd.get(r)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),n&&xd.set(r,t))}return t}toString(){return this.cssText}},T=e=>new Do(typeof e=="string"?e:e+"",void 0,_d);var Sd=(e,t)=>{if(Uo)e.adoptedStyleSheets=t.map(r=>r instanceof CSSStyleSheet?r:r.styleSheet);else for(let r of t){let n=document.createElement("style"),o=No.litNonce;o!==void 0&&n.setAttribute("nonce",o),n.textContent=r.cssText,e.appendChild(n)}},Ri=Uo?e=>e:e=>e instanceof CSSStyleSheet?(t=>{let r="";for(let n of t.cssRules)r+=n.cssText;return T(r)})(e):e;var{is:Kg,defineProperty:Gg,getOwnPropertyDescriptor:qg,getOwnPropertyNames:Yg,getOwnPropertySymbols:Jg,getPrototypeOf:Xg}=Object,zo=globalThis,Cd=zo.trustedTypes,Qg=Cd?Cd.emptyScript:"",Zg=zo.reactiveElementPolyfillSupport,vn=(e,t)=>e,Fi={toAttribute(e,t){switch(t){case Boolean:e=e?Qg:null;break;case Object:case Array:e=e==null?e:JSON.stringify(e)}return e},fromAttribute(e,t){let r=e;switch(t){case Boolean:r=e!==null;break;case Number:r=e===null?null:Number(e);break;case Object:case Array:try{r=JSON.parse(e)}catch{r=null}}return r}},Ad=(e,t)=>!Kg(e,t),Ed={attribute:!0,type:String,converter:Fi,reflect:!1,useDefault:!1,hasChanged:Ad};Symbol.metadata??=Symbol("metadata"),zo.litPropertyMetadata??=new WeakMap;var At=class extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,r=Ed){if(r.state&&(r.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((r=Object.create(r)).wrapped=!0),this.elementProperties.set(t,r),!r.noAccessor){let n=Symbol(),o=this.getPropertyDescriptor(t,n,r);o!==void 0&&Gg(this.prototype,t,o)}}static getPropertyDescriptor(t,r,n){let{get:o,set:s}=qg(this.prototype,t)??{get(){return this[r]},set(i){this[r]=i}};return{get:o,set(i){let l=o?.call(this);s?.call(this,i),this.requestUpdate(t,l,n)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??Ed}static _$Ei(){if(this.hasOwnProperty(vn("elementProperties")))return;let t=Xg(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(vn("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(vn("properties"))){let r=this.properties,n=[...Yg(r),...Jg(r)];for(let o of n)this.createProperty(o,r[o])}let t=this[Symbol.metadata];if(t!==null){let r=litPropertyMetadata.get(t);if(r!==void 0)for(let[n,o]of r)this.elementProperties.set(n,o)}this._$Eh=new Map;for(let[r,n]of this.elementProperties){let o=this._$Eu(r,n);o!==void 0&&this._$Eh.set(o,r)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){let r=[];if(Array.isArray(t)){let n=new Set(t.flat(1/0).reverse());for(let o of n)r.unshift(Ri(o))}else t!==void 0&&r.push(Ri(t));return r}static _$Eu(t,r){let n=r.attribute;return n===!1?void 0:typeof n=="string"?n:typeof t=="string"?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(t=>t(this))}addController(t){(this._$EO??=new Set).add(t),this.renderRoot!==void 0&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$EO?.delete(t)}_$E_(){let t=new Map,r=this.constructor.elementProperties;for(let n of r.keys())this.hasOwnProperty(n)&&(t.set(n,this[n]),delete this[n]);t.size>0&&(this._$Ep=t)}createRenderRoot(){let t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return Sd(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(t=>t.hostConnected?.())}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach(t=>t.hostDisconnected?.())}attributeChangedCallback(t,r,n){this._$AK(t,n)}_$ET(t,r){let n=this.constructor.elementProperties.get(t),o=this.constructor._$Eu(t,n);if(o!==void 0&&n.reflect===!0){let s=(n.converter?.toAttribute!==void 0?n.converter:Fi).toAttribute(r,n.type);this._$Em=t,s==null?this.removeAttribute(o):this.setAttribute(o,s),this._$Em=null}}_$AK(t,r){let n=this.constructor,o=n._$Eh.get(t);if(o!==void 0&&this._$Em!==o){let s=n.getPropertyOptions(o),i=typeof s.converter=="function"?{fromAttribute:s.converter}:s.converter?.fromAttribute!==void 0?s.converter:Fi;this._$Em=o;let l=i.fromAttribute(r,s.type);this[o]=l??this._$Ej?.get(o)??l,this._$Em=null}}requestUpdate(t,r,n,o=!1,s){if(t!==void 0){let i=this.constructor;if(o===!1&&(s=this[t]),n??=i.getPropertyOptions(t),!((n.hasChanged??Ad)(s,r)||n.useDefault&&n.reflect&&s===this._$Ej?.get(t)&&!this.hasAttribute(i._$Eu(t,n))))return;this.C(t,r,n)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(t,r,{useDefault:n,reflect:o,wrapped:s},i){n&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,i??r??this[t]),s!==!0||i!==void 0)||(this._$AL.has(t)||(this.hasUpdated||n||(r=void 0),this._$AL.set(t,r)),o===!0&&this._$Em!==t&&(this._$Eq??=new Set).add(t))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(r){Promise.reject(r)}let t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(let[o,s]of this._$Ep)this[o]=s;this._$Ep=void 0}let n=this.constructor.elementProperties;if(n.size>0)for(let[o,s]of n){let{wrapped:i}=s,l=this[o];i!==!0||this._$AL.has(o)||l===void 0||this.C(o,void 0,s,l)}}let t=!1,r=this._$AL;try{t=this.shouldUpdate(r),t?(this.willUpdate(r),this._$EO?.forEach(n=>n.hostUpdate?.()),this.update(r)):this._$EM()}catch(n){throw t=!1,this._$EM(),n}t&&this._$AE(r)}willUpdate(t){}_$AE(t){this._$EO?.forEach(r=>r.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&=this._$Eq.forEach(r=>this._$ET(r,this[r])),this._$EM()}updated(t){}firstUpdated(t){}};At.elementStyles=[],At.shadowRootOptions={mode:"open"},At[vn("elementProperties")]=new Map,At[vn("finalized")]=new Map,Zg?.({ReactiveElement:At}),(zo.reactiveElementVersions??=[]).push("2.1.2");var Mi=globalThis,Td=e=>e,Wo=Mi.trustedTypes,Id=Wo?Wo.createPolicy("lit-html",{createHTML:e=>e}):void 0,Li="$lit$",Tt=`lit$${Math.random().toFixed(9).slice(2)}$`,Pi="?"+Tt,em=`<${Pi}>`,dr=document,$n=()=>dr.createComment(""),xn=e=>e===null||typeof e!="object"&&typeof e!="function",Oi=Array.isArray,Pd=e=>Oi(e)||typeof e?.[Symbol.iterator]=="function",Bi=`[
2
- \f\r]`,kn=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Rd=/-->/g,Fd=/>/g,lr=RegExp(`>|${Bi}(?:([^\\s"'>=/]+)(${Bi}*=${Bi}*(?:[^
3
- \f\r"'\`<>=]|("|')|))|$)`,"g"),Bd=/'/g,Md=/"/g,Od=/^(?:script|style|textarea|title)$/i,Ni=e=>(t,...r)=>({_$litType$:e,strings:t,values:r}),c=Ni(1),zk=Ni(2),Wk=Ni(3),de=Symbol.for("lit-noChange"),g=Symbol.for("lit-nothing"),Ld=new WeakMap,cr=dr.createTreeWalker(dr,129);function Nd(e,t){if(!Oi(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return Id!==void 0?Id.createHTML(t):t}var Dd=(e,t)=>{let r=e.length-1,n=[],o,s=t===2?"<svg>":t===3?"<math>":"",i=kn;for(let l=0;l<r;l++){let d=e[l],u,p,f=-1,h=0;for(;h<d.length&&(i.lastIndex=h,p=i.exec(d),p!==null);)h=i.lastIndex,i===kn?p[1]==="!--"?i=Rd:p[1]!==void 0?i=Fd:p[2]!==void 0?(Od.test(p[2])&&(o=RegExp("</"+p[2],"g")),i=lr):p[3]!==void 0&&(i=lr):i===lr?p[0]===">"?(i=o??kn,f=-1):p[1]===void 0?f=-2:(f=i.lastIndex-p[2].length,u=p[1],i=p[3]===void 0?lr:p[3]==='"'?Md:Bd):i===Md||i===Bd?i=lr:i===Rd||i===Fd?i=kn:(i=lr,o=void 0);let b=i===lr&&e[l+1].startsWith("/>")?" ":"";s+=i===kn?d+em:f>=0?(n.push(u),d.slice(0,f)+Li+d.slice(f)+Tt+b):d+Tt+(f===-2?l:b)}return[Nd(e,s+(e[r]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),n]},_n=class e{constructor({strings:t,_$litType$:r},n){let o;this.parts=[];let s=0,i=0,l=t.length-1,d=this.parts,[u,p]=Dd(t,r);if(this.el=e.createElement(u,n),cr.currentNode=this.el.content,r===2||r===3){let f=this.el.content.firstChild;f.replaceWith(...f.childNodes)}for(;(o=cr.nextNode())!==null&&d.length<l;){if(o.nodeType===1){if(o.hasAttributes())for(let f of o.getAttributeNames())if(f.endsWith(Li)){let h=p[i++],b=o.getAttribute(f).split(Tt),m=/([.?@])?(.*)/.exec(h);d.push({type:1,index:s,name:m[2],strings:b,ctor:m[1]==="."?jo:m[1]==="?"?Vo:m[1]==="@"?Ko:pr}),o.removeAttribute(f)}else f.startsWith(Tt)&&(d.push({type:6,index:s}),o.removeAttribute(f));if(Od.test(o.tagName)){let f=o.textContent.split(Tt),h=f.length-1;if(h>0){o.textContent=Wo?Wo.emptyScript:"";for(let b=0;b<h;b++)o.append(f[b],$n()),cr.nextNode(),d.push({type:2,index:++s});o.append(f[h],$n())}}}else if(o.nodeType===8)if(o.data===Pi)d.push({type:2,index:s});else{let f=-1;for(;(f=o.data.indexOf(Tt,f+1))!==-1;)d.push({type:7,index:s}),f+=Tt.length-1}s++}}static createElement(t,r){let n=dr.createElement("template");return n.innerHTML=t,n}};function ur(e,t,r=e,n){if(t===de)return t;let o=n!==void 0?r._$Co?.[n]:r._$Cl,s=xn(t)?void 0:t._$litDirective$;return o?.constructor!==s&&(o?._$AO?.(!1),s===void 0?o=void 0:(o=new s(e),o._$AT(e,r,n)),n!==void 0?(r._$Co??=[])[n]=o:r._$Cl=o),o!==void 0&&(t=ur(e,o._$AS(e,t.values),o,n)),t}var Ho=class{constructor(t,r){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=r}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){let{el:{content:r},parts:n}=this._$AD,o=(t?.creationScope??dr).importNode(r,!0);cr.currentNode=o;let s=cr.nextNode(),i=0,l=0,d=n[0];for(;d!==void 0;){if(i===d.index){let u;d.type===2?u=new Br(s,s.nextSibling,this,t):d.type===1?u=new d.ctor(s,d.name,d.strings,this,t):d.type===6&&(u=new Go(s,this,t)),this._$AV.push(u),d=n[++l]}i!==d?.index&&(s=cr.nextNode(),i++)}return cr.currentNode=dr,o}p(t){let r=0;for(let n of this._$AV)n!==void 0&&(n.strings!==void 0?(n._$AI(t,n,r),r+=n.strings.length-2):n._$AI(t[r])),r++}},Br=class e{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,r,n,o){this.type=2,this._$AH=g,this._$AN=void 0,this._$AA=t,this._$AB=r,this._$AM=n,this.options=o,this._$Cv=o?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode,r=this._$AM;return r!==void 0&&t?.nodeType===11&&(t=r.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,r=this){t=ur(this,t,r),xn(t)?t===g||t==null||t===""?(this._$AH!==g&&this._$AR(),this._$AH=g):t!==this._$AH&&t!==de&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):Pd(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==g&&xn(this._$AH)?this._$AA.nextSibling.data=t:this.T(dr.createTextNode(t)),this._$AH=t}$(t){let{values:r,_$litType$:n}=t,o=typeof n=="number"?this._$AC(t):(n.el===void 0&&(n.el=_n.createElement(Nd(n.h,n.h[0]),this.options)),n);if(this._$AH?._$AD===o)this._$AH.p(r);else{let s=new Ho(o,this),i=s.u(this.options);s.p(r),this.T(i),this._$AH=s}}_$AC(t){let r=Ld.get(t.strings);return r===void 0&&Ld.set(t.strings,r=new _n(t)),r}k(t){Oi(this._$AH)||(this._$AH=[],this._$AR());let r=this._$AH,n,o=0;for(let s of t)o===r.length?r.push(n=new e(this.O($n()),this.O($n()),this,this.options)):n=r[o],n._$AI(s),o++;o<r.length&&(this._$AR(n&&n._$AB.nextSibling,o),r.length=o)}_$AR(t=this._$AA.nextSibling,r){for(this._$AP?.(!1,!0,r);t!==this._$AB;){let n=Td(t).nextSibling;Td(t).remove(),t=n}}setConnected(t){this._$AM===void 0&&(this._$Cv=t,this._$AP?.(t))}},pr=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,r,n,o,s){this.type=1,this._$AH=g,this._$AN=void 0,this.element=t,this.name=r,this._$AM=o,this.options=s,n.length>2||n[0]!==""||n[1]!==""?(this._$AH=Array(n.length-1).fill(new String),this.strings=n):this._$AH=g}_$AI(t,r=this,n,o){let s=this.strings,i=!1;if(s===void 0)t=ur(this,t,r,0),i=!xn(t)||t!==this._$AH&&t!==de,i&&(this._$AH=t);else{let l=t,d,u;for(t=s[0],d=0;d<s.length-1;d++)u=ur(this,l[n+d],r,d),u===de&&(u=this._$AH[d]),i||=!xn(u)||u!==this._$AH[d],u===g?t=g:t!==g&&(t+=(u??"")+s[d+1]),this._$AH[d]=u}i&&!o&&this.j(t)}j(t){t===g?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}},jo=class extends pr{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===g?void 0:t}},Vo=class extends pr{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==g)}},Ko=class extends pr{constructor(t,r,n,o,s){super(t,r,n,o,s),this.type=5}_$AI(t,r=this){if((t=ur(this,t,r,0)??g)===de)return;let n=this._$AH,o=t===g&&n!==g||t.capture!==n.capture||t.once!==n.once||t.passive!==n.passive,s=t!==g&&(n===g||o);o&&this.element.removeEventListener(this.name,this,n),s&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){typeof this._$AH=="function"?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}},Go=class{constructor(t,r,n){this.element=t,this.type=6,this._$AN=void 0,this._$AM=r,this.options=n}get _$AU(){return this._$AM._$AU}_$AI(t){ur(this,t)}},Ud={M:Li,P:Tt,A:Pi,C:1,L:Dd,R:Ho,D:Pd,V:ur,I:Br,H:pr,N:Vo,U:Ko,B:jo,F:Go},tm=Mi.litHtmlPolyfillSupport;tm?.(_n,Br),(Mi.litHtmlVersions??=[]).push("3.3.2");var K=(e,t,r)=>{let n=r?.renderBefore??t,o=n._$litPart$;if(o===void 0){let s=r?.renderBefore??null;n._$litPart$=o=new Br(t.insertBefore($n(),s),s,void 0,r??{})}return o._$AI(e),o};var Di=globalThis,H=class extends At{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){let t=super.createRenderRoot();return this.renderOptions.renderBefore??=t.firstChild,t}update(t){let r=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=K(r,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return de}};H._$litElement$=!0,H.finalized=!0,Di.litElementHydrateSupport?.({LitElement:H});var rm=Di.litElementPolyfillSupport;rm?.({LitElement:H});(Di.litElementVersions??=[]).push("4.2.2");var Le={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},mt=e=>(...t)=>({_$litDirective$:e,values:t}),tt=class{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,r,n){this._$Ct=t,this._$AM=r,this._$Ci=n}_$AS(t,r){return this.update(t,r)}update(t,r){return this.render(...r)}};var A=mt(class extends tt{constructor(e){if(super(e),e.type!==Le.ATTRIBUTE||e.name!=="class"||e.strings?.length>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(e){return" "+Object.keys(e).filter(t=>e[t]).join(" ")+" "}update(e,[t]){if(this.st===void 0){this.st=new Set,e.strings!==void 0&&(this.nt=new Set(e.strings.join(" ").split(/\s/).filter(n=>n!=="")));for(let n in t)t[n]&&!this.nt?.has(n)&&this.st.add(n);return this.render(t)}let r=e.element.classList;for(let n of this.st)n in t||(r.remove(n),this.st.delete(n));for(let n in t){let o=!!t[n];o===this.st.has(n)||this.nt?.has(n)||(o?(r.add(n),this.st.add(n)):(r.remove(n),this.st.delete(n)))}return de}});var{I:nm}=Ud,zd=e=>e;var Hd=e=>e.strings===void 0,Wd=()=>document.createComment(""),Mr=(e,t,r)=>{let n=e._$AA.parentNode,o=t===void 0?e._$AB:t._$AA;if(r===void 0){let s=n.insertBefore(Wd(),o),i=n.insertBefore(Wd(),o);r=new nm(s,i,e,e.options)}else{let s=r._$AB.nextSibling,i=r._$AM,l=i!==e;if(l){let d;r._$AQ?.(e),r._$AM=e,r._$AP!==void 0&&(d=e._$AU)!==i._$AU&&r._$AP(d)}if(s!==o||l){let d=r._$AA;for(;d!==s;){let u=zd(d).nextSibling;zd(n).insertBefore(d,o),d=u}}}return r},zt=(e,t,r=e)=>(e._$AI(t,r),e),om={},qo=(e,t=om)=>e._$AH=t,jd=e=>e._$AH,Yo=e=>{e._$AR(),e._$AA.remove()};var Vd=(e,t,r)=>{let n=new Map;for(let o=t;o<=r;o++)n.set(e[o],o);return n},G=mt(class extends tt{constructor(e){if(super(e),e.type!==Le.CHILD)throw Error("repeat() can only be used in text expressions")}dt(e,t,r){let n;r===void 0?r=t:t!==void 0&&(n=t);let o=[],s=[],i=0;for(let l of e)o[i]=n?n(l,i):i,s[i]=r(l,i),i++;return{values:s,keys:o}}render(e,t,r){return this.dt(e,t,r).values}update(e,[t,r,n]){let o=jd(e),{values:s,keys:i}=this.dt(t,r,n);if(!Array.isArray(o))return this.ut=i,s;let l=this.ut??=[],d=[],u,p,f=0,h=o.length-1,b=0,m=s.length-1;for(;f<=h&&b<=m;)if(o[f]===null)f++;else if(o[h]===null)h--;else if(l[f]===i[b])d[b]=zt(o[f],s[b]),f++,b++;else if(l[h]===i[m])d[m]=zt(o[h],s[m]),h--,m--;else if(l[f]===i[m])d[m]=zt(o[f],s[m]),Mr(e,d[m+1],o[f]),f++,m--;else if(l[h]===i[b])d[b]=zt(o[h],s[b]),Mr(e,o[f],o[h]),h--,b++;else if(u===void 0&&(u=Vd(i,b,m),p=Vd(l,f,h)),u.has(l[f]))if(u.has(l[h])){let y=p.get(i[b]),k=y!==void 0?o[y]:null;if(k===null){let w=Mr(e,o[f]);zt(w,s[b]),d[b]=w}else d[b]=zt(k,s[b]),Mr(e,o[f],k),o[y]=null;b++}else Yo(o[h]),h--;else Yo(o[f]),f++;for(;b<=m;){let y=Mr(e,d[m+1]);zt(y,s[b]),d[b++]=y}for(;f<=h;){let y=o[f++];y!==null&&Yo(y)}return this.ut=i,qo(e,d),de}});var Kd="important",sm=" !"+Kd,ue=mt(class extends tt{constructor(e){if(super(e),e.type!==Le.ATTRIBUTE||e.name!=="style"||e.strings?.length>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(e){return Object.keys(e).reduce((t,r)=>{let n=e[r];return n==null?t:t+`${r=r.includes("-")?r:r.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${n};`},"")}update(e,[t]){let{style:r}=e.element;if(this.ft===void 0)return this.ft=new Set(Object.keys(t)),this.render(t);for(let n of this.ft)t[n]==null&&(this.ft.delete(n),n.includes("-")?r.removeProperty(n):r[n]=null);for(let n in t){let o=t[n];if(o!=null){this.ft.add(n);let s=typeof o=="string"&&o.endsWith(sm);n.includes("-")||s?r.setProperty(n,s?o.slice(0,-11):o,s?Kd:""):r[n]=o}}return de}});var Hi=new WeakMap,Jd=Symbol("iteration key");function im(e){Hi.set(e,new Map)}function am(e,{target:t,key:r,type:n}){n==="iterate"&&(r=Jd);let o=Hi.get(t),s=o.get(r);s||(s=new Set,o.set(r,s)),s.has(e)||(s.add(e),e.cleaners.push(s))}function lm({target:e,key:t,type:r}){let n=Hi.get(e),o=new Set;if(r==="clear"?n.forEach((s,i)=>{Ui(o,n,i)}):Ui(o,n,t),r==="add"||r==="delete"||r==="clear"){let s=Array.isArray(e)?"length":Jd;Ui(o,n,s)}return o}function Ui(e,t,r){let n=t.get(r);n&&n.forEach(e.add,e)}function Xd(e){e.cleaners&&e.cleaners.forEach(cm,e),e.cleaners=[]}function cm(e){e.delete(this)}var Lr=[],zi=!1;function dm(e,t,r,n){if(e.unobserved)return Reflect.apply(t,r,n);if(Lr.indexOf(e)===-1){Xd(e);try{return Lr.push(e),Reflect.apply(t,r,n)}finally{Lr.pop()}}}function at(e){let t=Lr[Lr.length-1];t&&(Qd(t,e),am(t,e))}function Wt(e){lm(e).forEach(um,e)}function um(e){Qd(e,this),typeof e.scheduler=="function"?e.scheduler(e):typeof e.scheduler=="object"?e.scheduler.add(e):e()}function Qd(e,t){if(e.debugger&&!zi)try{zi=!0,e.debugger(t)}finally{zi=!1}}function Zd(){return Lr.length>0}var Gd=Symbol("is reaction");function eu(e,t={}){let r=e[Gd]?e:function n(){return dm(n,e,this,arguments)};return r.scheduler=t.scheduler,r.debugger=t.debugger,r[Gd]=!0,t.lazy||r(),r}function ji(e){e.unobserved||(e.unobserved=!0,Xd(e)),typeof e.scheduler=="object"&&e.scheduler.delete(e)}var Fe=new WeakMap,Qo=new WeakMap,pm=Object.prototype.hasOwnProperty;function Xo(e){let t=Qo.get(e);return Zd()&&typeof e=="object"&&e!==null?t||Zo(e):t||e}function Wi(e,t){let r=e.next;return e.next=()=>{let{done:n,value:o}=r.call(e);return n||(t?o[1]=Xo(o[1]):o=Xo(o)),{done:n,value:o}},e}var qd={has(e){let t=Fe.get(this),r=Reflect.getPrototypeOf(this);return at({target:t,key:e,type:"has"}),r.has.apply(t,arguments)},get(e){let t=Fe.get(this),r=Reflect.getPrototypeOf(this);return at({target:t,key:e,type:"get"}),Xo(r.get.apply(t,arguments))},add(e){let t=Fe.get(this),r=Reflect.getPrototypeOf(this),n=r.has.call(t,e),o=r.add.apply(t,arguments);return n||Wt({target:t,key:e,value:e,type:"add"}),o},set(e,t){let r=Fe.get(this),n=Reflect.getPrototypeOf(this),o=n.has.call(r,e),s=n.get.call(r,e),i=n.set.apply(r,arguments);return o?t!==s&&Wt({target:r,key:e,value:t,oldValue:s,type:"set"}):Wt({target:r,key:e,value:t,type:"add"}),i},delete(e){let t=Fe.get(this),r=Reflect.getPrototypeOf(this),n=r.has.call(t,e),o=r.get?r.get.call(t,e):void 0,s=r.delete.apply(t,arguments);return n&&Wt({target:t,key:e,oldValue:o,type:"delete"}),s},clear(){let e=Fe.get(this),t=Reflect.getPrototypeOf(this),r=e.size!==0,n=e instanceof Map?new Map(e):new Set(e),o=t.clear.apply(e,arguments);return r&&Wt({target:e,oldTarget:n,type:"clear"}),o},forEach(e,...t){let r=Fe.get(this),n=Reflect.getPrototypeOf(this);at({target:r,type:"iterate"});let o=(s,...i)=>e(Xo(s),...i);return n.forEach.call(r,o,...t)},keys(){let e=Fe.get(this),t=Reflect.getPrototypeOf(this);return at({target:e,type:"iterate"}),t.keys.apply(e,arguments)},values(){let e=Fe.get(this),t=Reflect.getPrototypeOf(this);at({target:e,type:"iterate"});let r=t.values.apply(e,arguments);return Wi(r,!1)},entries(){let e=Fe.get(this),t=Reflect.getPrototypeOf(this);at({target:e,type:"iterate"});let r=t.entries.apply(e,arguments);return Wi(r,!0)},[Symbol.iterator](){let e=Fe.get(this),t=Reflect.getPrototypeOf(this);at({target:e,type:"iterate"});let r=t[Symbol.iterator].apply(e,arguments);return Wi(r,e instanceof Map)},get size(){let e=Fe.get(this),t=Reflect.getPrototypeOf(this);return at({target:e,type:"iterate"}),Reflect.get(t,"size",e)}},Jo={get(e,t,r){return e=pm.call(qd,t)?qd:e,Reflect.get(e,t,r)}},Yd=typeof window=="object"?window:Function("return this")(),tu=new Map([[Map,Jo],[Set,Jo],[WeakMap,Jo],[WeakSet,Jo],[Object,!1],[Array,!1],[Int8Array,!1],[Uint8Array,!1],[Uint8ClampedArray,!1],[Int16Array,!1],[Uint16Array,!1],[Int32Array,!1],[Uint32Array,!1],[Float32Array,!1],[Float64Array,!1]]);function fm({constructor:e}){return!(typeof e=="function"&&e.name in Yd&&Yd[e.name]===e)||tu.has(e)}function hm(e){return tu.get(e.constructor)}var ru=Object.prototype.hasOwnProperty,gm=new Set(Object.getOwnPropertyNames(Symbol).map(e=>Symbol[e]).filter(e=>typeof e=="symbol"));function mm(e,t,r){let n=Reflect.get(e,t,r);if(typeof t=="symbol"&&gm.has(t))return n;at({target:e,key:t,receiver:r,type:"get"});let o=Qo.get(n);if(Zd()&&typeof n=="object"&&n!==null){if(o)return o;let s=Reflect.getOwnPropertyDescriptor(e,t);if(!s||!(s.writable===!1&&s.configurable===!1))return Zo(n)}return o||n}function bm(e,t){let r=Reflect.has(e,t);return at({target:e,key:t,type:"has"}),r}function ym(e){return at({target:e,type:"iterate"}),Reflect.ownKeys(e)}function wm(e,t,r,n){typeof r=="object"&&r!==null&&(r=Fe.get(r)||r);let o=ru.call(e,t),s=e[t],i=Reflect.set(e,t,r,n);return e!==Fe.get(n)||(o?r!==s&&Wt({target:e,key:t,value:r,oldValue:s,receiver:n,type:"set"}):Wt({target:e,key:t,value:r,receiver:n,type:"add"})),i}function vm(e,t){let r=ru.call(e,t),n=e[t],o=Reflect.deleteProperty(e,t);return r&&Wt({target:e,key:t,oldValue:n,type:"delete"}),o}var km={get:mm,has:bm,ownKeys:ym,set:wm,deleteProperty:vm};function Zo(e={}){return Fe.has(e)||!fm(e)?e:Qo.get(e)||$m(e)}function $m(e){let t=hm(e)||km,r=new Proxy(e,t);return Qo.set(e,r),Fe.set(r,e),im(e),r}var nu=Zo;function Vi(e){let t=!0,r=eu(()=>{try{e(t)}finally{t=!1}},{lazy:!0});try{r()}catch(n){throw ji(r),n}return()=>ji(r)}var P=class extends H{_disposers=[];observes=null;connectedCallback(){super.connectedCallback(),this.bindState()}bindState(){if(this.observes){this._disposers.push(Vi(t=>{this.observes(),t||this.requestUpdate()}));return}this._render||(this._render=this.render,this.render=()=>{let t,r=Vi(n=>{if(!n){r(),this._dispose===r&&(this._dispose=null),this.updateComplete.then(()=>this.requestUpdate());return}t=this._render()});return this._dispose=r,t}),this._disposers.push(()=>this._dispose&&this._dispose())}disconnectedCallback(){for(super.disconnectedCallback();this._disposers.length>0;)this._disposers.pop()()}};globalThis[Symbol.for("@rray/frontend")]={LitElement:H,html:c,nothing:g,render:K,unsafeCSS:T,StateElement:P,classMap:A,repeat:G,styleMap:ue};var Be=document.querySelector("#drop-zone"),C=document.querySelector("#report"),ou=document.querySelector("app-sidebar");function Pr(e,t){let r=URL.createObjectURL(e),n=document.createElement("span");n.style.display="none",K(c`<a href="${r}" download="${t}"></a>`,n),document.body.append(n),n.firstElementChild.click(),n.remove(),URL.revokeObjectURL(r)}function bt(e){return new Error("Another dialog is already open. Close it and try again.",{cause:e})}var xm="solidity-bundle",_m="0.0.0";function Or(e){if(e?.name!==xm)return!1;let t=e.version;return!t||t===_m}function iu(e){let t=e?.package?.npm,r=t?.version;if(typeof r=="string"&&r&&!Or(t))return r;let n=e?.file;if(!n)return null;let o=/(?:^|\/)node_modules\/\.pnpm\/([^/]+)\/node_modules\//u.exec(n);if(!o)return null;let s=o[1],i=s.indexOf("_");i>0&&(s=s.slice(0,i));let l=s.lastIndexOf("@");return l<=0?null:s.slice(l+1)||null}function es(){return{keys:new Set,findings:[],files:new Map,reports:new Set,_keyReports:new Map}}function ts(e,t,r,n){e.reports.add(r);let o=e._keyReports.get(t);o||e._keyReports.set(t,o=new Set);let s=!o.has(r);return o.add(r),e.keys.has(t)||(e.keys.add(t),e.findings.push(n),e.files.has(n.file)||e.files.set(n.file,[]),e.files.get(n.file).push(n)),s}function rs(e,t,r,n){e._keyReports.delete(t),e.keys.delete(t);let o=e.findings.findIndex(l=>n(l)===t);o>=0&&e.findings.splice(o,1);let s=e.files.get(r);if(!s)return;let i=s.findIndex(l=>n(l)===t);i>=0&&s.splice(i,1),s.length===0&&e.files.delete(r)}function ns(e){let t=new Set;for(let r of e._keyReports.values())for(let n of r)t.add(n);e.reports=t}function au(e,t,r,n,o){let s=e.byVersion.get(t);s||(s=es(),e.byVersion.set(t,s)),ts(s,n,o,r)}function lu(e,t,r,n,o,s){let i=e.byVersion.get(t);if(!i)return;let l=i._keyReports.get(r);if(l&&(l.delete(o),l.size===0&&rs(i,r,n,s)),i._keyReports.size===0){e.byVersion.delete(t);return}ns(i)}function Ki(e,t){if(e===t)return 0;if(e===null)return 1;if(t===null)return-1;let[r,n=""]=su(e,"-"),[o,s=""]=su(t,"-"),i=r.split("."),l=o.split("."),d=Math.max(i.length,l.length);for(let u=0;u<d;u++){let p=i[u]??"0",f=l[u]??"0",h=/^\d+$/u.test(p),b=/^\d+$/u.test(f);if(h&&b){let m=Number(f)-Number(p);if(m!==0)return m}else{let m=f.localeCompare(p);if(m!==0)return m}}return n===""&&s!==""?-1:n!==""&&s===""?1:s.localeCompare(n)}function su(e,t){let r=e.indexOf(t);return r<0?[e,""]:[e.slice(0,r),e.slice(r+1)]}var Sm=new TextEncoder,Cm=new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});function Y(e){if(typeof e!="string")throw new TypeError(`encodeUtf8 expects a string, got ${typeof e}`);if(!e.isWellFormed())throw new TypeError("encodeUtf8: input contains lone surrogates");return Sm.encode(e)}function he(e){if(!ArrayBuffer.isView(e)&&!(e instanceof ArrayBuffer))throw new TypeError(`decodeUtf8 expects a BufferSource, got ${e===null?"null":typeof e}`);return Cm.decode(e)}async function Sn(e){let t=new Blob([e]).stream().pipeThrough(new CompressionStream("gzip"));return new Uint8Array(await new Response(t).arrayBuffer())}async function yt(e){let t=new Blob([e]).stream().pipeThrough(new DecompressionStream("gzip"));return new Uint8Array(await new Response(t).arrayBuffer())}async function os(e){return await Sn(Y(e))}async function Cn(e){return he(await yt(e))}async function cu(e){let t=await crypto.subtle.digest("SHA-512",e);return`sha512-${new Uint8Array(t).toBase64()}`}var lt=new Uint8Array([68,86,69,49]),Nr=12,Em=32,Am="deepview-passkey.v1.content-key";function En(){return!(typeof window>"u"||typeof PublicKeyCredential>"u"||typeof navigator>"u"||!navigator.credentials)}async function du(){if(typeof PublicKeyCredential>"u")return!1;let e=PublicKeyCredential.getClientCapabilities;if(typeof e!="function")return null;try{let t=await e.call(PublicKeyCredential);if(!t||typeof t!="object")return null;let r=t["extension:prf"],n=t.prf;return r===!0||n===!0?!0:r===!1||n===!1?!1:null}catch{return null}}function ss(e){let t=new Uint8Array(e);return crypto.getRandomValues(t),t}async function Gi(e){if(e.length<32)throw new Error(`PRF output too short (${e.length} bytes; need \u2265 32)`);let t=await crypto.subtle.importKey("raw",e,"HKDF",!1,["deriveBits"]),r=await crypto.subtle.deriveBits({name:"HKDF",hash:"SHA-256",salt:new Uint8Array,info:Y(Am)},t,Em*8);return new Uint8Array(r)}function qi(e){return crypto.subtle.importKey("raw",e,{name:"AES-GCM"},!1,["encrypt","decrypt"])}async function Ht(e,t,r){let n=ss(Nr),o=new Uint8Array(await crypto.subtle.encrypt({name:"AES-GCM",iv:n,additionalData:r},e,t)),s=new Uint8Array(lt.length+Nr+o.length);return s.set(lt,0),s.set(n,lt.length),s.set(o,lt.length+Nr),s}async function fr(e,t,r){if(!Ue(t))throw new Error("passkey: missing envelope magic");if(t.length<lt.length+Nr+16)throw new Error("passkey: envelope too short");let n=t.subarray(lt.length,lt.length+Nr),o=t.subarray(lt.length+Nr);return new Uint8Array(await crypto.subtle.decrypt({name:"AES-GCM",iv:n,additionalData:r},e,o))}function Ue(e){if(e.length<lt.length)return!1;for(let t=0;t<lt.length;t++)if(e[t]!==lt[t])return!1;return!0}async function uu(e){if(!En())throw new Error("passkey: not supported in this environment");let t=ss(32),r=ss(32),n=await navigator.credentials.create({publicKey:{challenge:t,rp:{name:e.rpName,id:e.rpId},user:{id:e.userId,name:e.userName,displayName:e.userName},pubKeyCredParams:[{type:"public-key",alg:-7},{type:"public-key",alg:-257}],authenticatorSelection:{residentKey:"required",userVerification:"required"},extensions:{prf:{eval:{first:r}}},timeout:e.timeoutMs??12e4},...e.signal?{signal:e.signal}:{}});if(!(n instanceof PublicKeyCredential))throw new Error("passkey: registration returned no credential");let o=new Uint8Array(n.rawId).toBase64({alphabet:"base64url",omitPadding:!0}),s=n.getClientExtensionResults().prf,i=s?.results?.first?new Uint8Array(s.results.first):null;return{credentialId:o,prfSalt:r.toBase64({alphabet:"base64url",omitPadding:!0}),prfOutput:i}}async function Yi(e){if(!En())throw new Error("passkey: not supported in this environment");let t=ss(32),r=Uint8Array.fromBase64(e.credentialId,{alphabet:"base64url"}),n=Uint8Array.fromBase64(e.prfSalt,{alphabet:"base64url"}),o=await navigator.credentials.get({publicKey:{challenge:t,rpId:e.rpId,allowCredentials:[{type:"public-key",id:r}],userVerification:"required",extensions:{prf:{eval:{first:n}}},timeout:e.timeoutMs??12e4},...e.signal?{signal:e.signal}:{}});if(!(o instanceof PublicKeyCredential))throw new Error("passkey: assertion returned no credential");let i=o.getClientExtensionResults().prf?.results?.first;if(!i)throw new Error("passkey: authenticator did not return PRF output (extension unsupported)");return new Uint8Array(i)}var An=Object.freeze(["deepview.workspaces","deepview.sync.sessions","deepview.sync.userEnabled","deepview.sync.password","deepview.repoUrls","deepview.fileCounts","deepview.lastFile"]),Pe=new Map,as=!1,It=new Map,rt=new Map,is=new Set;function Dr(e){let t=()=>e();return is.add(t),as&&queueMicrotask(()=>{if(is.has(t))try{t()}catch(r){console.warn("secure-storage after-hydrate listener:",r)}}),()=>is.delete(t)}function Tm(){for(let e of is)try{e()}catch(t){console.warn("secure-storage after-hydrate listener:",t)}}function ls(e){let t=gu()??"";return Y(`deepview.secure.v1|${t}|${e}`)}function Ji(e){try{let t=Uint8Array.fromBase64(e);if(Ue(t))return t}catch{}return null}function we(e){return Pe.get(e)??null}async function Se(e,t){if(typeof t!="string")throw new TypeError("secure-storage: value must be a string");if(Q()&&!Ce())throw new Error(`secure-storage: vault locked, cannot save "${e}"`);if(hu())throw new Error(`secure-storage: wipe in progress, cannot save "${e}"`);let r=Pe.has(e),n=Pe.get(e);Pe.set(e,t),rt.set(e,t);let o=It.get(e)??Promise.resolve(),s=()=>{rt.get(e)===t&&rt.delete(e)},i=o.catch(()=>{}).then(()=>Im(e,t)).then(()=>s(),l=>{throw s(),Pe.get(e)===t&&(r?Pe.set(e,n):Pe.delete(e)),l});It.set(e,i.catch(()=>{})),await i}async function Ur(e){let t=Symbol("secure-storage:removed");Pe.delete(e),rt.set(e,t);let r=It.get(e)??Promise.resolve(),n=()=>{try{localStorage.removeItem(e)}catch{}rt.get(e)===t&&(rt.delete(e),Pe.delete(e))},o=r.catch(()=>{}).then(()=>n());It.set(e,o.catch(()=>{})),await o}async function Im(e,t){let r=Ce();if(r){let n=await Ht(r,Y(t),ls(e));localStorage.setItem(e,n.toBase64())}else localStorage.setItem(e,t)}async function jt(){as||ve(()=>{jt().catch(r=>console.warn("secure-storage rehydrate:",r))}),as=!0;for(let r of[...Pe.keys()])rt.has(r)||Pe.delete(r);let e=Ce(),t=[];for(let r of An){if(rt.has(r))continue;let n=localStorage.getItem(r);if(n===null)continue;let o=Ji(n);if(o){if(!e)continue;try{let s=await fr(e,o,ls(r));if(rt.has(r))continue;Pe.set(r,he(s))}catch(s){console.warn(`secure-storage: decrypt failed for "${r}":`,s)}}else Pe.set(r,n),e&&Q()&&t.push([r,n])}Tm(),t.length>0&&queueMicrotask(()=>{for(let[r,n]of t)Pe.get(r)===n&&Se(r,n).catch(o=>{console.warn(`secure-storage: self-heal failed for "${r}":`,o)})})}async function pu(e,t){let r=It.get(e)??Promise.resolve(),n=async()=>{if(rt.has(e))return;let s=localStorage.getItem(e);if(s===null)return;let i=await t(s);i!==null&&(rt.has(e)||(localStorage.setItem(e,i.storageValue),Pe.set(e,i.cacheValue)))},o=r.catch(()=>{}).then(n);It.set(e,o.catch(()=>{})),await o}async function Xi({seal:e}){for(let t of An)await pu(t,async r=>{if(Ji(r))return null;let n=Ce();return n?{storageValue:(await Ht(n,Y(r),ls(t))).toBase64(),cacheValue:r}:null})}async function Qi({open:e}){for(let t of An)await pu(t,async r=>{let n=Ji(r);if(!n)return null;let o=await e(n,ls(t)),s=he(o);return{storageValue:s,cacheValue:s}})}var Rm="deepview.secure.v1.mutate:";function Zi(e,t){return An.includes(e)?navigator.locks.request(Rm+e,async()=>{let r=It.get(e);r&&await r.catch(()=>{}),await jt();let n=we(e),o=await t(n);if(!(o==null||o===n)){if(typeof o!="string")throw new TypeError(`secure-storage: mutate updater for "${e}" must return a string`);await Se(e,o)}}):Promise.reject(new Error(`secure-storage: mutate() called with non-secure key "${e}"`))}async function fu(){await Promise.allSettled([...It.values()]),rt.clear(),It.clear()}typeof window<"u"&&window.addEventListener("storage",e=>{!as||!e.key||!An.includes(e.key)||jt().catch(()=>{})});var Rn="deepview.passkey.v1",zr="deepview.passkey.userId",ds="deepview.passkey.cleanDisable",nt="deepview.passkey.v1.write",Bm="deepview.triage.v1|",Mm="deepview.opfs.v1|",Lm="deepview.bundle.v1|",ee=null,wt=null,Vt=null,In=0;function ra(){return In>0}var ea=0;function hu(){return ea>0}function hr(){try{let e=localStorage.getItem(Rn);if(!e)return null;let t=JSON.parse(e);return t&&typeof t=="object"&&t.enabled===!0&&typeof t.credentialId=="string"&&t.credentialId.length>0&&typeof t.prfSalt=="string"&&t.prfSalt.length>0&&typeof t.userId=="string"&&t.userId.length>0?t:null}catch{return null}}function mu(e){localStorage.setItem(Rn,JSON.stringify(e))}function Pm(){localStorage.removeItem(Rn)}function Om(){try{let t=localStorage.getItem(zr);if(t){let r=Uint8Array.fromBase64(t,{alphabet:"base64url"});if(r.length===16)return r}}catch{}let e=new Uint8Array(16);crypto.getRandomValues(e);try{localStorage.setItem(zr,e.toBase64({alphabet:"base64url",omitPadding:!0}))}catch{}return e}function us(){return typeof location>"u"?"":location.hostname}function Q(){return hr()!==null}function ct(){return ee!==null}function vt(){return!(!En()||typeof navigator>"u"||!navigator.locks?.request||!us())}function gu(){return wt}function Fn(){if(hr()!==null)return!1;try{return localStorage.getItem(ds)==="1"?!1:localStorage.getItem(zr)!==null}catch{return!1}}function Ce(){return ee}function Bn(){return Y(Bm+(wt??""))}function ps(e){if(typeof e!="string")throw new TypeError("passkey vault: OPFS AAD requires a filename string");return Y(Mm+(wt??"")+"|"+e)}function fs(e){if(typeof e!="string")throw new TypeError("passkey vault: bundle AAD requires a slot string");return Y(Lm+(wt??"")+"|"+e)}var ta=new Set;function ve(e){return ta.add(e),()=>ta.delete(e)}function Wr(){for(let e of ta)try{e()}catch(t){console.warn("passkey vault listener:",t)}}async function Mn({signal:e}={}){let t=hr();if(!t)return!1;let r;try{r=await Yi({credentialId:t.credentialId,prfSalt:t.prfSalt,rpId:t.rpId??us(),...e?{signal:e}:{}})}catch(o){if(o&&o.name==="NotAllowedError"||o&&o.name==="AbortError")return!1;throw o&&o.message?.includes("PRF")?Tn(o):o}if(!r||r.length<32)throw Tn();let n=await Gi(r);return r.fill(0),navigator.locks.request(nt,async()=>{let o=hr();if(!o||o.credentialId!==t.credentialId)throw n.fill(0),new Error("passkey: vault state changed during unlock (another tab wiped or re-enabled it). Reload this page and try again.");return ee=await qi(n),n.fill(0),wt=o.userId,Vt=o.credentialId,Wr(),!0})}function Tn(e){let t=new Error("Your browser or authenticator doesn't support passkey-derived encryption keys (the WebAuthn PRF extension). Try Chrome 116+, Safari 18+, or Firefox 130+ on a device with a platform authenticator (TouchID / Windows Hello).");return e&&(t.cause=e),t}function na({migrate:e,userName:t,rpName:r,signal:n,acknowledgeOrphan:o}){if(!En())throw new Error("passkey: WebAuthn unavailable in this environment");if(Fn()&&!o)throw new Error("passkey: a previous vault exists on this device with no metadata. Any data encrypted under the old passkey will be unreadable after a new setup. Call enableEncryption({acknowledgeOrphan: true}) to proceed, or wipeAllVaultData() to start clean first.");let s=us();return navigator.locks.request(nt,async()=>{if(Q())throw new Error("passkey: encryption is already enabled");if(await du()===!1)throw Tn();let l=Om(),d=await uu({userName:t||"DeepView user",userId:l,rpName:r||"DeepView",rpId:s,...n?{signal:n}:{}}),u=d.prfOutput;if(!u)try{u=await Yi({credentialId:d.credentialId,prfSalt:d.prfSalt,rpId:s,...n?{signal:n}:{}})}catch(m){let y=l.toBase64({alphabet:"base64url",omitPadding:!0});await cs({credentialId:d.credentialId,rpId:s,userId:y}).catch(()=>{});try{localStorage.removeItem(zr)}catch{}throw m&&m.message?.includes("PRF")?Tn(m):m}if(!u||u.length<32){let m=l.toBase64({alphabet:"base64url",omitPadding:!0});await cs({credentialId:d.credentialId,rpId:s,userId:m}).catch(()=>{});try{localStorage.removeItem(zr)}catch{}throw Tn()}let p=await Gi(u);u.fill(0);let f=await qi(p);p.fill(0);let h=l.toBase64({alphabet:"base64url",omitPadding:!0}),b={enabled:!0,credentialId:d.credentialId,prfSalt:d.prfSalt,userId:h,rpId:s,createdAt:Date.now()};ee=f,wt=h,Vt=d.credentialId,mu(b),typeof e=="function"&&await e({seal:(y,k)=>Ht(f,y,k)});try{localStorage.removeItem(ds)}catch{}return Wr(),!0})}async function oa({migrate:e}){if(!Q())return{disabled:!1,signalAttempted:!1};if(!ct())throw new Error("passkey: must unlock before disabling encryption");In+=1;try{return await navigator.locks.request(nt,async()=>{let t=hr();if(!t)return{disabled:!1,signalAttempted:!1};let r=ee;if(!r)return{disabled:!1,signalAttempted:!1};if(Pm(),ee=null,Vt=null,typeof e=="function"){let o=(s,i)=>fr(r,s,i);try{await e({open:o})}catch(s){throw mu(t),ee=r,Vt=t.credentialId,Wr(),s}}wt=null;try{localStorage.setItem(ds,"1")}catch{}let n=await cs(t).catch(()=>!1);return Wr(),{disabled:!0,signalAttempted:n}})}finally{In-=1}}async function cs({credentialId:e,rpId:t,userId:r}){if(typeof PublicKeyCredential>"u"||!t)return!1;let n=PublicKeyCredential,o=!1;if(typeof n.signalUnknownCredential=="function"){o=!0;try{await n.signalUnknownCredential({rpId:t,credentialId:e})}catch{}}if(typeof n.signalAllAcceptedCredentials=="function"&&r){o=!0;try{await n.signalAllAcceptedCredentials({rpId:t,userId:r,allAcceptedCredentialIds:[]})}catch{}}return o}async function Nm(e,t){try{return await e.removeEntry(t,{recursive:!0}),null}catch(r){return r?.name==="NotFoundError"?null:`${t}: ${r?.message??String(r)}`}}async function Dm(e){let t=[];if(typeof navigator>"u"||!navigator.storage?.getDirectory)return t;let r;try{r=await navigator.storage.getDirectory()}catch(n){return t.push(`storage root: ${n?.message??String(n)}`),t}for(let n of e){let o=await Nm(r,n);o&&t.push(o)}return t}async function Ln({refuseIfEnabled:e=!1}={}){In+=1,ea+=1;try{return await navigator.locks.request(nt,async()=>{if(e&&Q())throw new Error("passkey: encryption was just enabled in another tab. Reload this page to unlock instead of wiping.");await fu();let t=hr();if(t)try{await cs({credentialId:t.credentialId,rpId:t.rpId??us(),userId:t.userId})}catch{}try{localStorage.removeItem(Rn)}catch{}try{localStorage.removeItem(zr)}catch{}try{localStorage.removeItem(ds)}catch{}for(let n of["deepview.workspaces","deepview.sync.sessions","deepview.sync.userEnabled","deepview.repoUrls","deepview.fileCounts","deepview.lastFile","deepview.triage","deepview.triage.pending","deepview.passkey.firstImportPrompted","deepview.viewMode"])try{localStorage.removeItem(n)}catch{}try{let n=[];for(let o=0;o<localStorage.length;o+=1){let s=localStorage.key(o);s&&s.startsWith("deepview.report:")&&n.push(s)}for(let o of n)try{localStorage.removeItem(o)}catch{}}catch{}ee=null,wt=null,Vt=null,Wr();let r=await Dm(["deepview-reports","deepview-bundles"]);if(r.length>0)throw new Error(`passkey: wipe partially succeeded \u2014 localStorage cleared but the following OPFS paths could not be removed: ${r.join("; ")}. Open DevTools \u2192 Application \u2192 Storage \u2192 Origin Private File System to inspect, or use the browser's site-data clear tool to finish.`)})}finally{In-=1,ea-=1}}function bu(e){return ee?Ht(ee,e,Bn()):Promise.reject(new Error("passkey: vault locked, cannot seal triage"))}function yu(e){return ee?fr(ee,e,Bn()):Promise.reject(new Error("passkey: vault locked, cannot open triage"))}function hs(e,t){return ee?Ht(ee,e,ps(t)):Promise.reject(new Error("passkey: vault locked, cannot seal OPFS file"))}function wu(e,t){return ee?fr(ee,e,ps(t)):Promise.reject(new Error("passkey: vault locked, cannot open OPFS file"))}function sa(e,t){return ee?Ht(ee,e,fs(t)):Promise.reject(new Error("passkey: vault locked, cannot seal bundle"))}function ia(e,t){return ee?fr(ee,e,fs(t)):Promise.reject(new Error("passkey: vault locked, cannot open bundle"))}typeof window<"u"&&window.addEventListener("storage",e=>{if(e.key!==Rn)return;let t=hr();(!t&&ee||t&&ee&&t.credentialId!==Vt)&&(ee=null,wt=null,Vt=null),Wr()});var da="__meta__",Um="deepview-reports",ua="deepview-bundles",Rt="deepview.report:",vu=!1;async function pa(e,{create:t,warnOnce:r=!1}={}){try{return await(await navigator.storage.getDirectory()).getDirectoryHandle(e,{create:t})}catch(n){return r&&!vu&&(vu=!0,console.warn("OPFS unavailable, falling back to gzipped localStorage (limited quota).",n)),null}}async function gs(e,t){let r=await e.createWritable();try{await r.write(t),await r.close()}catch(n){try{await r.abort(n)}catch{}throw n}}async function aa(e,t){if(!Ue(e))return e;if(!Ce())throw new Error(`storage: vault locked, cannot decrypt "${t}"`);return await wu(e,t)}async function Pn(e,t,r,n,o=()=>{}){if(Q()&&!Ce())throw o(),new Error(`storage: vault locked, cannot save ${n}`);let s=Ce(),i=s?await t(e,r):e;if(Ce()!==s)throw o(),new Error(`storage: vault state changed mid-save for ${n}; retry`);return i}function gr(){return pa(Um,{create:!0,warnOnce:!0})}var dt=new Map,Kt=new Map,la=new Map;function ie(e){la.set(e,(la.get(e)??0)+1)}function ku(e){return la.get(e)??0}var ca=new Set;function $u(e){return ca.add(e),()=>ca.delete(e)}function Hr(e,t){for(let r of ca)try{r(e,t)}catch(n){console.warn("storage file-change listener:",n)}}async function pe(){let e=await gr();if(e){let r=[];for await(let[n]of e.entries())r.push(n);return r.toSorted()}let t=[];for(let r=0;r<localStorage.length;r++){let n=localStorage.key(r);n&&n.startsWith(Rt)&&t.push(n.slice(Rt.length))}return t.toSorted()}async function ut(e,t){if(typeof e!="string"||e.includes("\0"))throw new Error("Invalid report name: contains NUL byte or is not a string");return ie(e),navigator.locks.request(nt,{mode:"shared"},async()=>{let r=await gr();if(r){let s=await Sn(Y(t));s=await Pn(s,hs,e,`"${e}"`,()=>ie(e));let l=await(await r.getFileHandle(e,{create:!0})).createWritable();try{await l.write(s),await l.close()}catch(d){dt.delete(e),ie(e);try{await l.abort(d)}catch{}throw d}dt.set(e,t),ie(e),Hr(e,"save");return}let n=Y(t);n=await Sn(n),n=await Pn(n,hs,e,`"${e}"`,()=>ie(e));let o=n.toBase64();try{localStorage.setItem(Rt+e,o),dt.set(e,t),ie(e),Hr(e,"save")}catch(s){throw ie(e),new Error(`localStorage write failed for ${e}: ${s.message}`,{cause:s})}})}async function Oe(e){if(dt.has(e))return dt.get(e);if(Kt.has(e))return Kt.get(e);let t=ku(e),r=(async()=>{let n=await gr();if(n){let d=await(await n.getFileHandle(e)).getFile(),u=new Uint8Array(await d.arrayBuffer());if(u=await aa(u,e),u.length>=2&&u[0]===31&&u[1]===139){let f=await yt(u);return he(f)}let p=he(u);return ut(e,p).catch(f=>{console.warn(`storage: legacy-uncompressed migration of "${e}" failed:`,f)}),p}let o=localStorage.getItem(Rt+e);if(o===null)throw new Error(`File not found: ${e}`);let s=Uint8Array.fromBase64(o);s=await aa(s,e);let i=await yt(s);return he(i)})();Kt.set(e,r);try{let n=await r;return ku(e)===t&&dt.set(e,n),n}finally{Kt.delete(e)}}async function mr(e){let t=await gr(),r;if(t){let o=await(await t.getFileHandle(e)).getFile();r=new Uint8Array(await o.arrayBuffer())}else{let n=localStorage.getItem(Rt+e);if(n===null)throw new Error(`File not found: ${e}`);r=Uint8Array.fromBase64(n)}return r=await aa(r,e),r}async function Nn(e,t){if(typeof e!="string"||e.includes("\0"))throw new Error("Invalid report name: contains NUL byte or is not a string");return ie(e),dt.delete(e),navigator.locks.request(nt,{mode:"shared"},async()=>{let r=await Pn(t,hs,e,`"${e}"`,()=>ie(e)),n=await gr();if(n){let s=await(await n.getFileHandle(e,{create:!0})).createWritable();try{await s.write(r),await s.close()}catch(i){ie(e);try{await s.abort(i)}catch{}throw i}ie(e),Hr(e,"save");return}try{localStorage.setItem(Rt+e,r.toBase64()),ie(e),Hr(e,"save")}catch(o){throw ie(e),new Error(`localStorage write failed for ${e}: ${o.message}`,{cause:o})}})}async function jr(e){return ie(e),dt.delete(e),Kt.delete(e),navigator.locks.request(nt,{mode:"shared"},async()=>{let t=await gr();if(t){try{await t.removeEntry(e)}catch(r){if(!(r instanceof DOMException)||r.name!=="NotFoundError")throw ie(e),r}ie(e),Hr(e,"delete");return}localStorage.removeItem(Rt+e),ie(e),Hr(e,"delete")})}var On="_meta.json";function Dn(){return pa(ua,{create:!0})}function fa(e){return e.replaceAll("/","_")}async function ha(e){let t;try{let o=await(await e.getFileHandle(On)).getFile();t=new Uint8Array(await o.arrayBuffer())}catch(n){return n instanceof DOMException&&n.name==="NotFoundError"?[]:(console.warn("readBundleMeta: failed to read _meta.json:",n),[])}let r=t;if(Ue(t)){if(!Ce())return console.warn("readBundleMeta: vault locked, returning empty bundle list"),[];try{r=await ia(t,da)}catch(o){return console.warn("readBundleMeta: decrypt failed (tampering, key mismatch, or vault identity drift):",o),[]}}try{let n=JSON.parse(he(r));return Array.isArray(n)?n:[]}catch(n){return console.warn("readBundleMeta: JSON.parse failed:",n),[]}}async function xu(e,t){let r=Y(JSON.stringify(t));r=await Pn(r,sa,da,"bundle metadata");try{await e.removeEntry(On)}catch{}let n=await e.getFileHandle(On,{create:!0});await gs(n,r)}var zm=`${ua}/${On}`;function _u(e){return navigator.locks.request(zm,e)}async function pt(){let e=await Dn();return e?[...await ha(e)].toSorted((r,n)=>r.name.localeCompare(n.name)):[]}async function ga(){if(typeof navigator>"u"||!navigator.storage?.getDirectory)return!1;let e=await pa(ua,{create:!1});if(!e)return!1;try{for await(let t of e.entries())return!0}catch{}return!1}async function br(e,t){let r=await Dn();if(!r)throw new Error(`Cannot save bundle ${e}: OPFS unavailable`);let n=t instanceof Uint8Array?t:Y(t),o=await cu(n),s=fa(o),i=e.toLowerCase().endsWith(".map")?await Sn(n):n;return navigator.locks.request(nt,{mode:"shared"},async()=>{i=await Pn(i,sa,o,`bundle "${e}"`);try{await r.removeEntry(s)}catch{}let l=await r.getFileHandle(s,{create:!0});await gs(l,i);try{await _u(async()=>{let d=await ha(r),u=d.findIndex(p=>p.integrity===o);u>=0?d[u]={integrity:o,name:e}:d.push({integrity:o,name:e}),await xu(r,d)})}catch(d){try{await r.removeEntry(s)}catch{}throw d}return{integrity:o,name:e}})}async function ma(e){let t=await Dn();if(t)return navigator.locks.request(nt,{mode:"shared"},async()=>{try{await t.removeEntry(fa(e))}catch(r){if(!(r instanceof DOMException)||r.name!=="NotFoundError")throw r}await _u(async()=>{let r=await ha(t),n=r.filter(o=>o.integrity!==e);n.length!==r.length&&await xu(t,n)})})}async function yr(e){let t=await Dn();if(!t)throw new Error("OPFS unavailable");let n=await(await t.getFileHandle(fa(e))).getFile(),o=new Uint8Array(await n.arrayBuffer());if(Ue(o)){if(!Ce())throw new Error(`storage: vault locked, cannot read bundle "${e}"`);o=await ia(o,e)}return o.length>=2&&o[0]===31&&o[1]===139?await yt(o):o}async function Wm(e,t){let r=await gr();if(r){let l=await(await r.getFileHandle(e)).getFile(),d=new Uint8Array(await l.arrayBuffer()),u=await t(d);if(u===null)return;dt.delete(e),Kt.delete(e),ie(e);let p=await r.getFileHandle(e,{create:!0});await gs(p,u),ie(e);return}let n=localStorage.getItem(Rt+e);if(n===null)return;let o=Uint8Array.fromBase64(n),s=await t(o);s!==null&&(dt.delete(e),Kt.delete(e),ie(e),localStorage.setItem(Rt+e,s.toBase64()),ie(e))}function Su(e,t){return e.seal?r=>Ue(r)?null:e.seal(r,t):r=>Ue(r)?e.open(r,t):null}async function Cu(e){let t=await pe();for(let r of t)try{await Wm(r,Su(e,ps(r)))}catch(n){if(n instanceof DOMException&&n.name==="NotFoundError")continue;throw n}}var ba=({seal:e})=>Cu({seal:e}),ya=({open:e})=>Cu({open:e});async function Hm(){let e=await Dn();if(!e)return{dir:null,keys:[]};let t=[];for await(let[r]of e.entries())t.push(r);return{dir:e,keys:t}}function jm(e){return e===On?da:e.startsWith("sha512-")?e.replaceAll("_","/"):null}async function Vm(e,t,r){let o=await(await e.getFileHandle(t)).getFile(),s=new Uint8Array(await o.arrayBuffer()),i=await r(s);if(i===null)return;let l=await e.getFileHandle(t,{create:!0});await gs(l,i)}async function Eu(e){let{dir:t,keys:r}=await Hm();if(t)for(let n of r){let o=jm(n);if(o!==null)try{await Vm(t,n,Su(e,fs(o)))}catch(s){if(s instanceof DOMException&&s.name==="NotFoundError")continue;throw s}}}var wa=({seal:e})=>Eu({seal:e}),va=({open:e})=>Eu({open:e});ve(()=>{dt.clear(),Kt.clear()});var bs="deepview.viewMode",ms="deepview.repoUrls",Km=new Set(["grouped","list","table","kanban","focus"]);function Gm(){try{let e=localStorage.getItem(bs);return e!==null&&Km.has(e)?e:null}catch{return null}}function $a(e){try{let t=JSON.parse(e||"{}");return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}catch{return{}}}function ys(){return $a(we(ms))}function Ke(e){return e?ys()[e]??"":""}var ka=new Set;function Au(e){return ka.add(e),()=>{ka.delete(e)}}function qm(e){for(let t of ka)try{t(e)}catch(r){console.warn("repo-url listener:",r)}}function Ge(e,t){if(!e)return;let r=ys();t?r[e]=t:delete r[e],Se(ms,JSON.stringify(r)).catch(n=>console.warn("saveRepoUrlFor:",n)),Zi(ms,n=>{let o=$a(n);return t?o[e]=t:delete o[e],JSON.stringify(o)}).catch(n=>console.warn("saveRepoUrlFor cross-tab merge:",n)),qm(e)}async function Tu(e,t){await Zi(ms,r=>{let n=$a(r),o=t==="replace"?{...e}:t==="prefer-imported"?{...n,...e}:{...e,...n};return JSON.stringify(o)}),Iu()}var a=nu({reports:[],workspaceMerges:[],currentFile:null,currentWorkspace:null,currentView:"findings",bundles:[],selectedBundle:null,bundleDetails:null,bundleDetailsTab:"overview",selectedPackage:null,selectedPackageVersion:null,packageDetailsTab:"overview",packageSlideTriage:null,packageSlideTransient:!1,packagesSearchQuery:"",packagesSortBy:"findings-desc",expandedPackages:new Set,selectedRepository:null,repositoryDetailsTab:"overview",repositorySlideTriage:null,repositorySlideTransient:!1,repositoriesSearchQuery:"",repositoriesSortBy:"findings-desc",bundleSourceFile:null,bundleSourceFindingIdx:null,bundleCodeSearchMode:"files",bundleCodeSearchQuery:"",bundleSearchQuery:"",bundleSearchRegex:!1,bundleSearchCase:!1,bundleSearchContext:!0,filterSeverities:new Set,filterColors:new Set,filterSources:new Set,filterAnalyzer:"",filterRepo:"",filterConfMin:0,filterConfMax:10,filterInclude:"",filterIncludeNegate:!1,filterComment:"",filterFix:"",filterFlagged:"",repoUrl:"",repoEditing:!1,sortBy:"severity",viewMode:Gm()??"table",triage:new Map,shownTriage:null,nextFindingId:0,activeTabByGroup:new Map,tableSelectedGid:null,filesViewMode:"table",filesSearch:"",filesSelectedFile:null,kanbanPopoverGid:null,focusGid:null,focusCodeTick:0});function Iu(){a.repoEditing||a.currentFile&&(a.repoUrl=Ke(a.currentFile))}Dr(()=>{Iu()});var Ym=/^## ([A-Z][A-Z_]*)\s*\(\d+\)\s*$/mu;function Jm(e){switch(e.toUpperCase()){case"CRITICAL":return"critical";case"HIGH":return"high";case"MEDIUM":return"medium";case"LOW":return"low";case"HIGH_BUG":return"high_bug";case"BUG":return"bug";case"INFO":case"INFORMATIONAL":return"informational";default:return"medium"}}function Xm(e){if(e)switch(e.toLowerCase()){case"high":return 8;case"medium":return 5;case"low":return 2;default:return}}function Qm(e){return typeof e=="string"?e.replace(/^`(.*)`$/u,"$1"):e}function Vr(e){let t=e.replaceAll(/\r\n?/gu,`
4
- `).trim();if(!Ym.test(t))return null;let r=t.split(/^## ([A-Z][A-Z_]*)\s*\(\d+\)\s*\n/mu),n=[];for(let o=1;o<r.length;o+=2){let s=Jm(r[o]),l=(r[o+1]||"").split(/^### /mu).slice(1);for(let d of l){let u=Zm(d,s);u&&n.push(u)}}return n.length===0?null:{type:"security",source:"deepsec",findings:n}}function Zm(e,t){let r=e.indexOf(`
1
+ var es=globalThis,rs=es.ShadowRoot&&(es.ShadyCSS===void 0||es.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Vd=Symbol(),Wd=new WeakMap,ts=class{constructor(t,r,n){if(this._$cssResult$=!0,n!==Vd)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=r}get styleSheet(){let t=this.o,r=this.t;if(rs&&t===void 0){let n=r!==void 0&&r.length===1;n&&(t=Wd.get(r)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),n&&Wd.set(r,t))}return t}toString(){return this.cssText}},B=e=>new ts(typeof e=="string"?e:e+"",void 0,Vd);var jd=(e,t)=>{if(rs)e.adoptedStyleSheets=t.map(r=>r instanceof CSSStyleSheet?r:r.styleSheet);else for(let r of t){let n=document.createElement("style"),o=es.litNonce;o!==void 0&&n.setAttribute("nonce",o),n.textContent=r.cssText,e.appendChild(n)}},ji=rs?e=>e:e=>e instanceof CSSStyleSheet?(t=>{let r="";for(let n of t.cssRules)r+=n.cssText;return B(r)})(e):e;var{is:Em,defineProperty:Am,getOwnPropertyDescriptor:Tm,getOwnPropertyNames:Im,getOwnPropertySymbols:Rm,getPrototypeOf:Fm}=Object,ns=globalThis,Kd=ns.trustedTypes,Bm=Kd?Kd.emptyScript:"",Mm=ns.reactiveElementPolyfillSupport,Mn=(e,t)=>e,Ki={toAttribute(e,t){switch(t){case Boolean:e=e?Bm:null;break;case Object:case Array:e=e==null?e:JSON.stringify(e)}return e},fromAttribute(e,t){let r=e;switch(t){case Boolean:r=e!==null;break;case Number:r=e===null?null:Number(e);break;case Object:case Array:try{r=JSON.parse(e)}catch{r=null}}return r}},qd=(e,t)=>!Em(e,t),Gd={attribute:!0,type:String,converter:Ki,reflect:!1,useDefault:!1,hasChanged:qd};Symbol.metadata??=Symbol("metadata"),ns.litPropertyMetadata??=new WeakMap;var Tt=class extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,r=Gd){if(r.state&&(r.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((r=Object.create(r)).wrapped=!0),this.elementProperties.set(t,r),!r.noAccessor){let n=Symbol(),o=this.getPropertyDescriptor(t,n,r);o!==void 0&&Am(this.prototype,t,o)}}static getPropertyDescriptor(t,r,n){let{get:o,set:s}=Tm(this.prototype,t)??{get(){return this[r]},set(i){this[r]=i}};return{get:o,set(i){let l=o?.call(this);s?.call(this,i),this.requestUpdate(t,l,n)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??Gd}static _$Ei(){if(this.hasOwnProperty(Mn("elementProperties")))return;let t=Fm(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(Mn("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Mn("properties"))){let r=this.properties,n=[...Im(r),...Rm(r)];for(let o of n)this.createProperty(o,r[o])}let t=this[Symbol.metadata];if(t!==null){let r=litPropertyMetadata.get(t);if(r!==void 0)for(let[n,o]of r)this.elementProperties.set(n,o)}this._$Eh=new Map;for(let[r,n]of this.elementProperties){let o=this._$Eu(r,n);o!==void 0&&this._$Eh.set(o,r)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){let r=[];if(Array.isArray(t)){let n=new Set(t.flat(1/0).reverse());for(let o of n)r.unshift(ji(o))}else t!==void 0&&r.push(ji(t));return r}static _$Eu(t,r){let n=r.attribute;return n===!1?void 0:typeof n=="string"?n:typeof t=="string"?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(t=>t(this))}addController(t){(this._$EO??=new Set).add(t),this.renderRoot!==void 0&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$EO?.delete(t)}_$E_(){let t=new Map,r=this.constructor.elementProperties;for(let n of r.keys())this.hasOwnProperty(n)&&(t.set(n,this[n]),delete this[n]);t.size>0&&(this._$Ep=t)}createRenderRoot(){let t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return jd(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(t=>t.hostConnected?.())}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach(t=>t.hostDisconnected?.())}attributeChangedCallback(t,r,n){this._$AK(t,n)}_$ET(t,r){let n=this.constructor.elementProperties.get(t),o=this.constructor._$Eu(t,n);if(o!==void 0&&n.reflect===!0){let s=(n.converter?.toAttribute!==void 0?n.converter:Ki).toAttribute(r,n.type);this._$Em=t,s==null?this.removeAttribute(o):this.setAttribute(o,s),this._$Em=null}}_$AK(t,r){let n=this.constructor,o=n._$Eh.get(t);if(o!==void 0&&this._$Em!==o){let s=n.getPropertyOptions(o),i=typeof s.converter=="function"?{fromAttribute:s.converter}:s.converter?.fromAttribute!==void 0?s.converter:Ki;this._$Em=o;let l=i.fromAttribute(r,s.type);this[o]=l??this._$Ej?.get(o)??l,this._$Em=null}}requestUpdate(t,r,n,o=!1,s){if(t!==void 0){let i=this.constructor;if(o===!1&&(s=this[t]),n??=i.getPropertyOptions(t),!((n.hasChanged??qd)(s,r)||n.useDefault&&n.reflect&&s===this._$Ej?.get(t)&&!this.hasAttribute(i._$Eu(t,n))))return;this.C(t,r,n)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(t,r,{useDefault:n,reflect:o,wrapped:s},i){n&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,i??r??this[t]),s!==!0||i!==void 0)||(this._$AL.has(t)||(this.hasUpdated||n||(r=void 0),this._$AL.set(t,r)),o===!0&&this._$Em!==t&&(this._$Eq??=new Set).add(t))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(r){Promise.reject(r)}let t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(let[o,s]of this._$Ep)this[o]=s;this._$Ep=void 0}let n=this.constructor.elementProperties;if(n.size>0)for(let[o,s]of n){let{wrapped:i}=s,l=this[o];i!==!0||this._$AL.has(o)||l===void 0||this.C(o,void 0,s,l)}}let t=!1,r=this._$AL;try{t=this.shouldUpdate(r),t?(this.willUpdate(r),this._$EO?.forEach(n=>n.hostUpdate?.()),this.update(r)):this._$EM()}catch(n){throw t=!1,this._$EM(),n}t&&this._$AE(r)}willUpdate(t){}_$AE(t){this._$EO?.forEach(r=>r.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&=this._$Eq.forEach(r=>this._$ET(r,this[r])),this._$EM()}updated(t){}firstUpdated(t){}};Tt.elementStyles=[],Tt.shadowRootOptions={mode:"open"},Tt[Mn("elementProperties")]=new Map,Tt[Mn("finalized")]=new Map,Mm?.({ReactiveElement:Tt}),(ns.reactiveElementVersions??=[]).push("2.1.2");var qi=globalThis,Yd=e=>e,os=qi.trustedTypes,Jd=os?os.createPolicy("lit-html",{createHTML:e=>e}):void 0,Yi="$lit$",It=`lit$${Math.random().toFixed(9).slice(2)}$`,Ji="?"+It,Lm=`<${Ji}>`,hr=document,Pn=()=>hr.createComment(""),On=e=>e===null||typeof e!="object"&&typeof e!="function",Xi=Array.isArray,ru=e=>Xi(e)||typeof e?.[Symbol.iterator]=="function",Gi=`[
2
+ \f\r]`,Ln=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Xd=/-->/g,Qd=/>/g,pr=RegExp(`>|${Gi}(?:([^\\s"'>=/]+)(${Gi}*=${Gi}*(?:[^
3
+ \f\r"'\`<>=]|("|')|))|$)`,"g"),Zd=/'/g,eu=/"/g,nu=/^(?:script|style|textarea|title)$/i,Qi=e=>(t,...r)=>({_$litType$:e,strings:t,values:r}),c=Qi(1),Ut=Qi(2),B$=Qi(3),ue=Symbol.for("lit-noChange"),g=Symbol.for("lit-nothing"),tu=new WeakMap,fr=hr.createTreeWalker(hr,129);function ou(e,t){if(!Xi(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return Jd!==void 0?Jd.createHTML(t):t}var su=(e,t)=>{let r=e.length-1,n=[],o,s=t===2?"<svg>":t===3?"<math>":"",i=Ln;for(let l=0;l<r;l++){let d=e[l],u,p,f=-1,h=0;for(;h<d.length&&(i.lastIndex=h,p=i.exec(d),p!==null);)h=i.lastIndex,i===Ln?p[1]==="!--"?i=Xd:p[1]!==void 0?i=Qd:p[2]!==void 0?(nu.test(p[2])&&(o=RegExp("</"+p[2],"g")),i=pr):p[3]!==void 0&&(i=pr):i===pr?p[0]===">"?(i=o??Ln,f=-1):p[1]===void 0?f=-2:(f=i.lastIndex-p[2].length,u=p[1],i=p[3]===void 0?pr:p[3]==='"'?eu:Zd):i===eu||i===Zd?i=pr:i===Xd||i===Qd?i=Ln:(i=pr,o=void 0);let b=i===pr&&e[l+1].startsWith("/>")?" ":"";s+=i===Ln?d+Lm:f>=0?(n.push(u),d.slice(0,f)+Yi+d.slice(f)+It+b):d+It+(f===-2?l:b)}return[ou(e,s+(e[r]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),n]},Nn=class e{constructor({strings:t,_$litType$:r},n){let o;this.parts=[];let s=0,i=0,l=t.length-1,d=this.parts,[u,p]=su(t,r);if(this.el=e.createElement(u,n),fr.currentNode=this.el.content,r===2||r===3){let f=this.el.content.firstChild;f.replaceWith(...f.childNodes)}for(;(o=fr.nextNode())!==null&&d.length<l;){if(o.nodeType===1){if(o.hasAttributes())for(let f of o.getAttributeNames())if(f.endsWith(Yi)){let h=p[i++],b=o.getAttribute(f).split(It),m=/([.?@])?(.*)/.exec(h);d.push({type:1,index:s,name:m[2],strings:b,ctor:m[1]==="."?is:m[1]==="?"?as:m[1]==="@"?ls:mr}),o.removeAttribute(f)}else f.startsWith(It)&&(d.push({type:6,index:s}),o.removeAttribute(f));if(nu.test(o.tagName)){let f=o.textContent.split(It),h=f.length-1;if(h>0){o.textContent=os?os.emptyScript:"";for(let b=0;b<h;b++)o.append(f[b],Pn()),fr.nextNode(),d.push({type:2,index:++s});o.append(f[h],Pn())}}}else if(o.nodeType===8)if(o.data===Ji)d.push({type:2,index:s});else{let f=-1;for(;(f=o.data.indexOf(It,f+1))!==-1;)d.push({type:7,index:s}),f+=It.length-1}s++}}static createElement(t,r){let n=hr.createElement("template");return n.innerHTML=t,n}};function gr(e,t,r=e,n){if(t===ue)return t;let o=n!==void 0?r._$Co?.[n]:r._$Cl,s=On(t)?void 0:t._$litDirective$;return o?.constructor!==s&&(o?._$AO?.(!1),s===void 0?o=void 0:(o=new s(e),o._$AT(e,r,n)),n!==void 0?(r._$Co??=[])[n]=o:r._$Cl=o),o!==void 0&&(t=gr(e,o._$AS(e,t.values),o,n)),t}var ss=class{constructor(t,r){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=r}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){let{el:{content:r},parts:n}=this._$AD,o=(t?.creationScope??hr).importNode(r,!0);fr.currentNode=o;let s=fr.nextNode(),i=0,l=0,d=n[0];for(;d!==void 0;){if(i===d.index){let u;d.type===2?u=new zr(s,s.nextSibling,this,t):d.type===1?u=new d.ctor(s,d.name,d.strings,this,t):d.type===6&&(u=new cs(s,this,t)),this._$AV.push(u),d=n[++l]}i!==d?.index&&(s=fr.nextNode(),i++)}return fr.currentNode=hr,o}p(t){let r=0;for(let n of this._$AV)n!==void 0&&(n.strings!==void 0?(n._$AI(t,n,r),r+=n.strings.length-2):n._$AI(t[r])),r++}},zr=class e{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,r,n,o){this.type=2,this._$AH=g,this._$AN=void 0,this._$AA=t,this._$AB=r,this._$AM=n,this.options=o,this._$Cv=o?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode,r=this._$AM;return r!==void 0&&t?.nodeType===11&&(t=r.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,r=this){t=gr(this,t,r),On(t)?t===g||t==null||t===""?(this._$AH!==g&&this._$AR(),this._$AH=g):t!==this._$AH&&t!==ue&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):ru(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==g&&On(this._$AH)?this._$AA.nextSibling.data=t:this.T(hr.createTextNode(t)),this._$AH=t}$(t){let{values:r,_$litType$:n}=t,o=typeof n=="number"?this._$AC(t):(n.el===void 0&&(n.el=Nn.createElement(ou(n.h,n.h[0]),this.options)),n);if(this._$AH?._$AD===o)this._$AH.p(r);else{let s=new ss(o,this),i=s.u(this.options);s.p(r),this.T(i),this._$AH=s}}_$AC(t){let r=tu.get(t.strings);return r===void 0&&tu.set(t.strings,r=new Nn(t)),r}k(t){Xi(this._$AH)||(this._$AH=[],this._$AR());let r=this._$AH,n,o=0;for(let s of t)o===r.length?r.push(n=new e(this.O(Pn()),this.O(Pn()),this,this.options)):n=r[o],n._$AI(s),o++;o<r.length&&(this._$AR(n&&n._$AB.nextSibling,o),r.length=o)}_$AR(t=this._$AA.nextSibling,r){for(this._$AP?.(!1,!0,r);t!==this._$AB;){let n=Yd(t).nextSibling;Yd(t).remove(),t=n}}setConnected(t){this._$AM===void 0&&(this._$Cv=t,this._$AP?.(t))}},mr=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,r,n,o,s){this.type=1,this._$AH=g,this._$AN=void 0,this.element=t,this.name=r,this._$AM=o,this.options=s,n.length>2||n[0]!==""||n[1]!==""?(this._$AH=Array(n.length-1).fill(new String),this.strings=n):this._$AH=g}_$AI(t,r=this,n,o){let s=this.strings,i=!1;if(s===void 0)t=gr(this,t,r,0),i=!On(t)||t!==this._$AH&&t!==ue,i&&(this._$AH=t);else{let l=t,d,u;for(t=s[0],d=0;d<s.length-1;d++)u=gr(this,l[n+d],r,d),u===ue&&(u=this._$AH[d]),i||=!On(u)||u!==this._$AH[d],u===g?t=g:t!==g&&(t+=(u??"")+s[d+1]),this._$AH[d]=u}i&&!o&&this.j(t)}j(t){t===g?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}},is=class extends mr{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===g?void 0:t}},as=class extends mr{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==g)}},ls=class extends mr{constructor(t,r,n,o,s){super(t,r,n,o,s),this.type=5}_$AI(t,r=this){if((t=gr(this,t,r,0)??g)===ue)return;let n=this._$AH,o=t===g&&n!==g||t.capture!==n.capture||t.once!==n.once||t.passive!==n.passive,s=t!==g&&(n===g||o);o&&this.element.removeEventListener(this.name,this,n),s&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){typeof this._$AH=="function"?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}},cs=class{constructor(t,r,n){this.element=t,this.type=6,this._$AN=void 0,this._$AM=r,this.options=n}get _$AU(){return this._$AM._$AU}_$AI(t){gr(this,t)}},iu={M:Yi,P:It,A:Ji,C:1,L:su,R:ss,D:ru,V:gr,I:zr,H:mr,N:as,U:ls,B:is,F:cs},Pm=qi.litHtmlPolyfillSupport;Pm?.(Nn,zr),(qi.litHtmlVersions??=[]).push("3.3.2");var q=(e,t,r)=>{let n=r?.renderBefore??t,o=n._$litPart$;if(o===void 0){let s=r?.renderBefore??null;n._$litPart$=o=new zr(t.insertBefore(Pn(),s),s,void 0,r??{})}return o._$AI(e),o};var Zi=globalThis,j=class extends Tt{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){let t=super.createRenderRoot();return this.renderOptions.renderBefore??=t.firstChild,t}update(t){let r=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=q(r,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return ue}};j._$litElement$=!0,j.finalized=!0,Zi.litElementHydrateSupport?.({LitElement:j});var Om=Zi.litElementPolyfillSupport;Om?.({LitElement:j});(Zi.litElementVersions??=[]).push("4.2.2");var Oe={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},bt=e=>(...t)=>({_$litDirective$:e,values:t}),et=class{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,r,n){this._$Ct=t,this._$AM=r,this._$Ci=n}_$AS(t,r){return this.update(t,r)}update(t,r){return this.render(...r)}};var R=bt(class extends et{constructor(e){if(super(e),e.type!==Oe.ATTRIBUTE||e.name!=="class"||e.strings?.length>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(e){return" "+Object.keys(e).filter(t=>e[t]).join(" ")+" "}update(e,[t]){if(this.st===void 0){this.st=new Set,e.strings!==void 0&&(this.nt=new Set(e.strings.join(" ").split(/\s/).filter(n=>n!=="")));for(let n in t)t[n]&&!this.nt?.has(n)&&this.st.add(n);return this.render(t)}let r=e.element.classList;for(let n of this.st)n in t||(r.remove(n),this.st.delete(n));for(let n in t){let o=!!t[n];o===this.st.has(n)||this.nt?.has(n)||(o?(r.add(n),this.st.add(n)):(r.remove(n),this.st.delete(n)))}return ue}});var{I:Nm}=iu,au=e=>e;var cu=e=>e.strings===void 0,lu=()=>document.createComment(""),Ur=(e,t,r)=>{let n=e._$AA.parentNode,o=t===void 0?e._$AB:t._$AA;if(r===void 0){let s=n.insertBefore(lu(),o),i=n.insertBefore(lu(),o);r=new Nm(s,i,e,e.options)}else{let s=r._$AB.nextSibling,i=r._$AM,l=i!==e;if(l){let d;r._$AQ?.(e),r._$AM=e,r._$AP!==void 0&&(d=e._$AU)!==i._$AU&&r._$AP(d)}if(s!==o||l){let d=r._$AA;for(;d!==s;){let u=au(d).nextSibling;au(n).insertBefore(d,o),d=u}}}return r},Ht=(e,t,r=e)=>(e._$AI(t,r),e),Dm={},ds=(e,t=Dm)=>e._$AH=t,du=e=>e._$AH,us=e=>{e._$AR(),e._$AA.remove()};var uu=(e,t,r)=>{let n=new Map;for(let o=t;o<=r;o++)n.set(e[o],o);return n},X=bt(class extends et{constructor(e){if(super(e),e.type!==Oe.CHILD)throw Error("repeat() can only be used in text expressions")}dt(e,t,r){let n;r===void 0?r=t:t!==void 0&&(n=t);let o=[],s=[],i=0;for(let l of e)o[i]=n?n(l,i):i,s[i]=r(l,i),i++;return{values:s,keys:o}}render(e,t,r){return this.dt(e,t,r).values}update(e,[t,r,n]){let o=du(e),{values:s,keys:i}=this.dt(t,r,n);if(!Array.isArray(o))return this.ut=i,s;let l=this.ut??=[],d=[],u,p,f=0,h=o.length-1,b=0,m=s.length-1;for(;f<=h&&b<=m;)if(o[f]===null)f++;else if(o[h]===null)h--;else if(l[f]===i[b])d[b]=Ht(o[f],s[b]),f++,b++;else if(l[h]===i[m])d[m]=Ht(o[h],s[m]),h--,m--;else if(l[f]===i[m])d[m]=Ht(o[f],s[m]),Ur(e,d[m+1],o[f]),f++,m--;else if(l[h]===i[b])d[b]=Ht(o[h],s[b]),Ur(e,o[f],o[h]),h--,b++;else if(u===void 0&&(u=uu(i,b,m),p=uu(l,f,h)),u.has(l[f]))if(u.has(l[h])){let y=p.get(i[b]),v=y!==void 0?o[y]:null;if(v===null){let w=Ur(e,o[f]);Ht(w,s[b]),d[b]=w}else d[b]=Ht(v,s[b]),Ur(e,o[f],v),o[y]=null;b++}else us(o[h]),h--;else us(o[f]),f++;for(;b<=m;){let y=Ur(e,d[m+1]);Ht(y,s[b]),d[b++]=y}for(;f<=h;){let y=o[f++];y!==null&&us(y)}return this.ut=i,ds(e,d),ue}});var pu="important",zm=" !"+pu,pe=bt(class extends et{constructor(e){if(super(e),e.type!==Oe.ATTRIBUTE||e.name!=="style"||e.strings?.length>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(e){return Object.keys(e).reduce((t,r)=>{let n=e[r];return n==null?t:t+`${r=r.includes("-")?r:r.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${n};`},"")}update(e,[t]){let{style:r}=e.element;if(this.ft===void 0)return this.ft=new Set(Object.keys(t)),this.render(t);for(let n of this.ft)t[n]==null&&(this.ft.delete(n),n.includes("-")?r.removeProperty(n):r[n]=null);for(let n in t){let o=t[n];if(o!=null){this.ft.add(n);let s=typeof o=="string"&&o.endsWith(zm);n.includes("-")||s?r.setProperty(n,s?o.slice(0,-11):o,s?pu:""):r[n]=o}}return ue}});var na=new WeakMap,mu=Symbol("iteration key");function Um(e){na.set(e,new Map)}function Hm(e,{target:t,key:r,type:n}){n==="iterate"&&(r=mu);let o=na.get(t),s=o.get(r);s||(s=new Set,o.set(r,s)),s.has(e)||(s.add(e),e.cleaners.push(s))}function Wm({target:e,key:t,type:r}){let n=na.get(e),o=new Set;if(r==="clear"?n.forEach((s,i)=>{ea(o,n,i)}):ea(o,n,t),r==="add"||r==="delete"||r==="clear"){let s=Array.isArray(e)?"length":mu;ea(o,n,s)}return o}function ea(e,t,r){let n=t.get(r);n&&n.forEach(e.add,e)}function bu(e){e.cleaners&&e.cleaners.forEach(Vm,e),e.cleaners=[]}function Vm(e){e.delete(this)}var Hr=[],ta=!1;function jm(e,t,r,n){if(e.unobserved)return Reflect.apply(t,r,n);if(Hr.indexOf(e)===-1){bu(e);try{return Hr.push(e),Reflect.apply(t,r,n)}finally{Hr.pop()}}}function dt(e){let t=Hr[Hr.length-1];t&&(yu(t,e),Hm(t,e))}function Wt(e){Wm(e).forEach(Km,e)}function Km(e){yu(e,this),typeof e.scheduler=="function"?e.scheduler(e):typeof e.scheduler=="object"?e.scheduler.add(e):e()}function yu(e,t){if(e.debugger&&!ta)try{ta=!0,e.debugger(t)}finally{ta=!1}}function wu(){return Hr.length>0}var fu=Symbol("is reaction");function vu(e,t={}){let r=e[fu]?e:function n(){return jm(n,e,this,arguments)};return r.scheduler=t.scheduler,r.debugger=t.debugger,r[fu]=!0,t.lazy||r(),r}function oa(e){e.unobserved||(e.unobserved=!0,bu(e)),typeof e.scheduler=="object"&&e.scheduler.delete(e)}var Fe=new WeakMap,hs=new WeakMap,Gm=Object.prototype.hasOwnProperty;function fs(e){let t=hs.get(e);return wu()&&typeof e=="object"&&e!==null?t||gs(e):t||e}function ra(e,t){let r=e.next;return e.next=()=>{let{done:n,value:o}=r.call(e);return n||(t?o[1]=fs(o[1]):o=fs(o)),{done:n,value:o}},e}var hu={has(e){let t=Fe.get(this),r=Reflect.getPrototypeOf(this);return dt({target:t,key:e,type:"has"}),r.has.apply(t,arguments)},get(e){let t=Fe.get(this),r=Reflect.getPrototypeOf(this);return dt({target:t,key:e,type:"get"}),fs(r.get.apply(t,arguments))},add(e){let t=Fe.get(this),r=Reflect.getPrototypeOf(this),n=r.has.call(t,e),o=r.add.apply(t,arguments);return n||Wt({target:t,key:e,value:e,type:"add"}),o},set(e,t){let r=Fe.get(this),n=Reflect.getPrototypeOf(this),o=n.has.call(r,e),s=n.get.call(r,e),i=n.set.apply(r,arguments);return o?t!==s&&Wt({target:r,key:e,value:t,oldValue:s,type:"set"}):Wt({target:r,key:e,value:t,type:"add"}),i},delete(e){let t=Fe.get(this),r=Reflect.getPrototypeOf(this),n=r.has.call(t,e),o=r.get?r.get.call(t,e):void 0,s=r.delete.apply(t,arguments);return n&&Wt({target:t,key:e,oldValue:o,type:"delete"}),s},clear(){let e=Fe.get(this),t=Reflect.getPrototypeOf(this),r=e.size!==0,n=e instanceof Map?new Map(e):new Set(e),o=t.clear.apply(e,arguments);return r&&Wt({target:e,oldTarget:n,type:"clear"}),o},forEach(e,...t){let r=Fe.get(this),n=Reflect.getPrototypeOf(this);dt({target:r,type:"iterate"});let o=(s,...i)=>e(fs(s),...i);return n.forEach.call(r,o,...t)},keys(){let e=Fe.get(this),t=Reflect.getPrototypeOf(this);return dt({target:e,type:"iterate"}),t.keys.apply(e,arguments)},values(){let e=Fe.get(this),t=Reflect.getPrototypeOf(this);dt({target:e,type:"iterate"});let r=t.values.apply(e,arguments);return ra(r,!1)},entries(){let e=Fe.get(this),t=Reflect.getPrototypeOf(this);dt({target:e,type:"iterate"});let r=t.entries.apply(e,arguments);return ra(r,!0)},[Symbol.iterator](){let e=Fe.get(this),t=Reflect.getPrototypeOf(this);dt({target:e,type:"iterate"});let r=t[Symbol.iterator].apply(e,arguments);return ra(r,e instanceof Map)},get size(){let e=Fe.get(this),t=Reflect.getPrototypeOf(this);return dt({target:e,type:"iterate"}),Reflect.get(t,"size",e)}},ps={get(e,t,r){return e=Gm.call(hu,t)?hu:e,Reflect.get(e,t,r)}},gu=typeof window=="object"?window:Function("return this")(),ku=new Map([[Map,ps],[Set,ps],[WeakMap,ps],[WeakSet,ps],[Object,!1],[Array,!1],[Int8Array,!1],[Uint8Array,!1],[Uint8ClampedArray,!1],[Int16Array,!1],[Uint16Array,!1],[Int32Array,!1],[Uint32Array,!1],[Float32Array,!1],[Float64Array,!1]]);function qm({constructor:e}){return!(typeof e=="function"&&e.name in gu&&gu[e.name]===e)||ku.has(e)}function Ym(e){return ku.get(e.constructor)}var $u=Object.prototype.hasOwnProperty,Jm=new Set(Object.getOwnPropertyNames(Symbol).map(e=>Symbol[e]).filter(e=>typeof e=="symbol"));function Xm(e,t,r){let n=Reflect.get(e,t,r);if(typeof t=="symbol"&&Jm.has(t))return n;dt({target:e,key:t,receiver:r,type:"get"});let o=hs.get(n);if(wu()&&typeof n=="object"&&n!==null){if(o)return o;let s=Reflect.getOwnPropertyDescriptor(e,t);if(!s||!(s.writable===!1&&s.configurable===!1))return gs(n)}return o||n}function Qm(e,t){let r=Reflect.has(e,t);return dt({target:e,key:t,type:"has"}),r}function Zm(e){return dt({target:e,type:"iterate"}),Reflect.ownKeys(e)}function eb(e,t,r,n){typeof r=="object"&&r!==null&&(r=Fe.get(r)||r);let o=$u.call(e,t),s=e[t],i=Reflect.set(e,t,r,n);return e!==Fe.get(n)||(o?r!==s&&Wt({target:e,key:t,value:r,oldValue:s,receiver:n,type:"set"}):Wt({target:e,key:t,value:r,receiver:n,type:"add"})),i}function tb(e,t){let r=$u.call(e,t),n=e[t],o=Reflect.deleteProperty(e,t);return r&&Wt({target:e,key:t,oldValue:n,type:"delete"}),o}var rb={get:Xm,has:Qm,ownKeys:Zm,set:eb,deleteProperty:tb};function gs(e={}){return Fe.has(e)||!qm(e)?e:hs.get(e)||nb(e)}function nb(e){let t=Ym(e)||rb,r=new Proxy(e,t);return hs.set(e,r),Fe.set(r,e),Um(e),r}var xu=gs;function sa(e){let t=!0,r=vu(()=>{try{e(t)}finally{t=!1}},{lazy:!0});try{r()}catch(n){throw oa(r),n}return()=>oa(r)}var O=class extends j{_disposers=[];observes=null;connectedCallback(){super.connectedCallback(),this.bindState()}bindState(){if(this.observes){this._disposers.push(sa(t=>{this.observes(),t||this.requestUpdate()}));return}this._render||(this._render=this.render,this.render=()=>{let t,r=sa(n=>{if(!n){r(),this._dispose===r&&(this._dispose=null),this.updateComplete.then(()=>this.requestUpdate());return}t=this._render()});return this._dispose=r,t}),this._disposers.push(()=>this._dispose&&this._dispose())}disconnectedCallback(){for(super.disconnectedCallback();this._disposers.length>0;)this._disposers.pop()()}};globalThis[Symbol.for("@rray/frontend")]={LitElement:j,html:c,nothing:g,render:q,unsafeCSS:B,StateElement:O,classMap:R,repeat:X,styleMap:pe};var Be=document.querySelector("#drop-zone"),I=document.querySelector("#report"),_u=document.querySelector("app-sidebar");function Wr(e,t){let r=URL.createObjectURL(e),n=document.createElement("span");n.style.display="none",q(c`<a href="${r}" download="${t}"></a>`,n),document.body.append(n),n.firstElementChild.click(),n.remove(),URL.revokeObjectURL(r)}function yt(e){return new Error("Another dialog is already open. Close it and try again.",{cause:e})}var ob="solidity-bundle",sb="0.0.0";function Vr(e){if(e?.name!==ob)return!1;let t=e.version;return!t||t===sb}function Cu(e){let t=e?.package?.npm,r=t?.version;if(typeof r=="string"&&r&&!Vr(t))return r;let n=e?.file;if(!n)return null;let o=/(?:^|\/)node_modules\/\.pnpm\/([^/]+)\/node_modules\//u.exec(n);if(!o)return null;let s=o[1],i=s.indexOf("_");i>0&&(s=s.slice(0,i));let l=s.lastIndexOf("@");return l<=0?null:s.slice(l+1)||null}function ms(){return{keys:new Set,findings:[],files:new Map,reports:new Set,_keyReports:new Map}}function bs(e,t,r,n){e.reports.add(r);let o=e._keyReports.get(t);o||e._keyReports.set(t,o=new Set);let s=!o.has(r);return o.add(r),e.keys.has(t)||(e.keys.add(t),e.findings.push(n),e.files.has(n.file)||e.files.set(n.file,[]),e.files.get(n.file).push(n)),s}function ys(e,t,r,n){e._keyReports.delete(t),e.keys.delete(t);let o=e.findings.findIndex(l=>n(l)===t);o>=0&&e.findings.splice(o,1);let s=e.files.get(r);if(!s)return;let i=s.findIndex(l=>n(l)===t);i>=0&&s.splice(i,1),s.length===0&&e.files.delete(r)}function ws(e){let t=new Set;for(let r of e._keyReports.values())for(let n of r)t.add(n);e.reports=t}function Eu(e,t,r,n,o){let s=e.byVersion.get(t);s||(s=ms(),e.byVersion.set(t,s)),bs(s,n,o,r)}function Au(e,t,r,n,o,s){let i=e.byVersion.get(t);if(!i)return;let l=i._keyReports.get(r);if(l&&(l.delete(o),l.size===0&&ys(i,r,n,s)),i._keyReports.size===0){e.byVersion.delete(t);return}ws(i)}function ia(e,t){if(e===t)return 0;if(e===null)return 1;if(t===null)return-1;let[r,n=""]=Su(e,"-"),[o,s=""]=Su(t,"-"),i=r.split("."),l=o.split("."),d=Math.max(i.length,l.length);for(let u=0;u<d;u++){let p=i[u]??"0",f=l[u]??"0",h=/^\d+$/u.test(p),b=/^\d+$/u.test(f);if(h&&b){let m=Number(f)-Number(p);if(m!==0)return m}else{let m=f.localeCompare(p);if(m!==0)return m}}return n===""&&s!==""?-1:n!==""&&s===""?1:s.localeCompare(n)}function Su(e,t){let r=e.indexOf(t);return r<0?[e,""]:[e.slice(0,r),e.slice(r+1)]}var ib=new TextEncoder,ab=new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});function te(e){if(typeof e!="string")throw new TypeError(`encodeUtf8 expects a string, got ${typeof e}`);if(!e.isWellFormed())throw new TypeError("encodeUtf8: input contains lone surrogates");return ib.encode(e)}function he(e){if(!ArrayBuffer.isView(e)&&!(e instanceof ArrayBuffer))throw new TypeError(`decodeUtf8 expects a BufferSource, got ${e===null?"null":typeof e}`);return ab.decode(e)}async function Dn(e){let t=new Blob([e]).stream().pipeThrough(new CompressionStream("gzip"));return new Uint8Array(await new Response(t).arrayBuffer())}async function wt(e,{maxBytes:t}={}){let r=new Blob([e]).stream().pipeThrough(new DecompressionStream("gzip"));if(t==null)return new Uint8Array(await new Response(r).arrayBuffer());let n=r.getReader(),o=[],s=0;for(;;){let{value:d,done:u}=await n.read();if(u)break;if(s+=d.length,s>t){try{await n.cancel()}catch{}throw new Error(`gunzipBytes: decompressed size exceeds ${t}-byte cap`)}o.push(d)}let i=new Uint8Array(s),l=0;for(let d of o)i.set(d,l),l+=d.length;return i}async function vs(e){return await Dn(te(e))}async function zn(e){return he(await wt(e))}async function Tu(e){let t=await crypto.subtle.digest("SHA-512",e);return`sha512-${new Uint8Array(t).toBase64()}`}var ut=new Uint8Array([68,86,69,49]),jr=12,lb=32,cb="deepview-passkey.v1.content-key";function Un(){return!(typeof window>"u"||typeof PublicKeyCredential>"u"||typeof navigator>"u"||!navigator.credentials)}async function Iu(){if(typeof PublicKeyCredential>"u")return!1;let e=PublicKeyCredential.getClientCapabilities;if(typeof e!="function")return null;try{let t=await e.call(PublicKeyCredential);if(!t||typeof t!="object")return null;let r=t["extension:prf"],n=t.prf;return r===!0||n===!0?!0:r===!1||n===!1?!1:null}catch{return null}}function ks(e){let t=new Uint8Array(e);return crypto.getRandomValues(t),t}async function aa(e){if(e.length<32)throw new Error(`PRF output too short (${e.length} bytes; need \u2265 32)`);let t=await crypto.subtle.importKey("raw",e,"HKDF",!1,["deriveBits"]),r=await crypto.subtle.deriveBits({name:"HKDF",hash:"SHA-256",salt:new Uint8Array,info:te(cb)},t,lb*8);return new Uint8Array(r)}function la(e){return crypto.subtle.importKey("raw",e,{name:"AES-GCM"},!1,["encrypt","decrypt"])}async function Vt(e,t,r){let n=ks(jr),o=new Uint8Array(await crypto.subtle.encrypt({name:"AES-GCM",iv:n,additionalData:r},e,t)),s=new Uint8Array(ut.length+jr+o.length);return s.set(ut,0),s.set(n,ut.length),s.set(o,ut.length+jr),s}async function br(e,t,r){if(!je(t))throw new Error("passkey: missing envelope magic");if(t.length<ut.length+jr+16)throw new Error("passkey: envelope too short");let n=t.subarray(ut.length,ut.length+jr),o=t.subarray(ut.length+jr);return new Uint8Array(await crypto.subtle.decrypt({name:"AES-GCM",iv:n,additionalData:r},e,o))}function je(e){if(e.length<ut.length)return!1;for(let t=0;t<ut.length;t++)if(e[t]!==ut[t])return!1;return!0}async function Ru(e){if(!Un())throw new Error("passkey: not supported in this environment");let t=ks(32),r=ks(32),n=await navigator.credentials.create({publicKey:{challenge:t,rp:{name:e.rpName,id:e.rpId},user:{id:e.userId,name:e.userName,displayName:e.userName},pubKeyCredParams:[{type:"public-key",alg:-7},{type:"public-key",alg:-257}],authenticatorSelection:{residentKey:"required",userVerification:"required"},extensions:{prf:{eval:{first:r}}},timeout:e.timeoutMs??12e4},...e.signal?{signal:e.signal}:{}});if(!(n instanceof PublicKeyCredential))throw new Error("passkey: registration returned no credential");let o=new Uint8Array(n.rawId).toBase64({alphabet:"base64url",omitPadding:!0}),s=n.getClientExtensionResults().prf,i=s?.results?.first?new Uint8Array(s.results.first):null;return{credentialId:o,prfSalt:r.toBase64({alphabet:"base64url",omitPadding:!0}),prfOutput:i}}async function ca(e){if(!Un())throw new Error("passkey: not supported in this environment");let t=ks(32),r=Uint8Array.fromBase64(e.credentialId,{alphabet:"base64url"}),n=Uint8Array.fromBase64(e.prfSalt,{alphabet:"base64url"}),o=await navigator.credentials.get({publicKey:{challenge:t,rpId:e.rpId,allowCredentials:[{type:"public-key",id:r}],userVerification:"required",extensions:{prf:{eval:{first:n}}},timeout:e.timeoutMs??12e4},...e.signal?{signal:e.signal}:{}});if(!(o instanceof PublicKeyCredential))throw new Error("passkey: assertion returned no credential");let i=o.getClientExtensionResults().prf?.results?.first;if(!i)throw new Error("passkey: authenticator did not return PRF output (extension unsupported)");return new Uint8Array(i)}var Hn=Object.freeze(["deepview.workspaces","deepview.sync.sessions","deepview.sync.userEnabled","deepview.sync.password","deepview.repoUrls","deepview.fileCounts","deepview.lastFile"]),Ne=new Map,xs=!1,Rt=new Map,tt=new Map,$s=new Set;function Kr(e){let t=()=>e();return $s.add(t),xs&&queueMicrotask(()=>{if($s.has(t))try{t()}catch(r){console.warn("secure-storage after-hydrate listener:",r)}}),()=>$s.delete(t)}function db(){for(let e of $s)try{e()}catch(t){console.warn("secure-storage after-hydrate listener:",t)}}function _s(e){let t=Lu()??"";return te(`deepview.secure.v1|${t}|${e}`)}function da(e){try{let t=Uint8Array.fromBase64(e);if(je(t))return t}catch{}return null}function we(e){return Ne.get(e)??null}async function Ee(e,t){if(typeof t!="string")throw new TypeError("secure-storage: value must be a string");if(ne()&&!Ae())throw new Error(`secure-storage: vault locked, cannot save "${e}"`);if(Mu())throw new Error(`secure-storage: wipe in progress, cannot save "${e}"`);let r=Ne.has(e),n=Ne.get(e);Ne.set(e,t),tt.set(e,t);let o=Rt.get(e)??Promise.resolve(),s=()=>{tt.get(e)===t&&tt.delete(e)},i=o.catch(()=>{}).then(()=>ub(e,t)).then(()=>s(),l=>{throw s(),Ne.get(e)===t&&(r?Ne.set(e,n):Ne.delete(e)),l});Rt.set(e,i.catch(()=>{})),await i}async function Gr(e){let t=Symbol("secure-storage:removed");Ne.delete(e),tt.set(e,t);let r=Rt.get(e)??Promise.resolve(),n=()=>{try{localStorage.removeItem(e)}catch{}tt.get(e)===t&&(tt.delete(e),Ne.delete(e))},o=r.catch(()=>{}).then(()=>n());Rt.set(e,o.catch(()=>{})),await o}async function ub(e,t){let r=Ae();if(r){let n=await Vt(r,te(t),_s(e));localStorage.setItem(e,n.toBase64())}else localStorage.setItem(e,t)}async function jt(){xs||ve(()=>{jt().catch(r=>console.warn("secure-storage rehydrate:",r))}),xs=!0;for(let r of[...Ne.keys()])tt.has(r)||Ne.delete(r);let e=Ae(),t=[];for(let r of Hn){if(tt.has(r))continue;let n=localStorage.getItem(r);if(n===null)continue;let o=da(n);if(o){if(!e)continue;try{let s=await br(e,o,_s(r));if(tt.has(r))continue;Ne.set(r,he(s))}catch(s){console.warn(`secure-storage: decrypt failed for "${r}":`,s)}}else Ne.set(r,n),e&&ne()&&t.push([r,n])}db(),t.length>0&&queueMicrotask(()=>{for(let[r,n]of t)Ne.get(r)===n&&Ee(r,n).catch(o=>{console.warn(`secure-storage: self-heal failed for "${r}":`,o)})})}async function Fu(e,t){let r=Rt.get(e)??Promise.resolve(),n=async()=>{if(tt.has(e))return;let s=localStorage.getItem(e);if(s===null)return;let i=await t(s);i!==null&&(tt.has(e)||(localStorage.setItem(e,i.storageValue),Ne.set(e,i.cacheValue)))},o=r.catch(()=>{}).then(n);Rt.set(e,o.catch(()=>{})),await o}async function ua({seal:e}){for(let t of Hn)await Fu(t,async r=>{if(da(r))return null;let n=Ae();return n?{storageValue:(await Vt(n,te(r),_s(t))).toBase64(),cacheValue:r}:null})}async function pa({open:e}){for(let t of Hn)await Fu(t,async r=>{let n=da(r);if(!n)return null;let o=await e(n,_s(t)),s=he(o);return{storageValue:s,cacheValue:s}})}var pb="deepview.secure.v1.mutate:";function fa(e,t){return Hn.includes(e)?navigator.locks.request(pb+e,async()=>{let r=Rt.get(e);r&&await r.catch(()=>{}),await jt();let n=we(e),o=await t(n);if(!(o==null||o===n)){if(typeof o!="string")throw new TypeError(`secure-storage: mutate updater for "${e}" must return a string`);await Ee(e,o)}}):Promise.reject(new Error(`secure-storage: mutate() called with non-secure key "${e}"`))}async function Bu(){await Promise.allSettled([...Rt.values()]),tt.clear(),Rt.clear()}typeof window<"u"&&window.addEventListener("storage",e=>{!xs||!e.key||!Hn.includes(e.key)||jt().catch(()=>{})});var jn="deepview.passkey.v1",qr="deepview.passkey.userId",Cs="deepview.passkey.cleanDisable",rt="deepview.passkey.v1.write",hb="deepview.triage.v1|",gb="deepview.opfs.v1|",mb="deepview.bundle.v1|",oe=null,vt=null,Kt=null,Vn=0;function ma(){return Vn>0}var ha=0;function Mu(){return ha>0}function yr(){try{let e=localStorage.getItem(jn);if(!e)return null;let t=JSON.parse(e);return t&&typeof t=="object"&&t.enabled===!0&&typeof t.credentialId=="string"&&t.credentialId.length>0&&typeof t.prfSalt=="string"&&t.prfSalt.length>0&&typeof t.userId=="string"&&t.userId.length>0?t:null}catch{return null}}function Pu(e){localStorage.setItem(jn,JSON.stringify(e))}function bb(){localStorage.removeItem(jn)}function yb(){try{let t=localStorage.getItem(qr);if(t){let r=Uint8Array.fromBase64(t,{alphabet:"base64url"});if(r.length===16)return r}}catch{}let e=new Uint8Array(16);crypto.getRandomValues(e);try{localStorage.setItem(qr,e.toBase64({alphabet:"base64url",omitPadding:!0}))}catch{}return e}function Es(){return typeof location>"u"?"":location.hostname}function ne(){return yr()!==null}function pt(){return oe!==null}function kt(){return!(!Un()||typeof navigator>"u"||!navigator.locks?.request||!Es())}function Lu(){return vt}function Kn(){if(yr()!==null)return!1;try{return localStorage.getItem(Cs)==="1"?!1:localStorage.getItem(qr)!==null}catch{return!1}}function Ae(){return oe}function Gn(){return te(hb+(vt??""))}function As(e){if(typeof e!="string")throw new TypeError("passkey vault: OPFS AAD requires a filename string");return te(gb+(vt??"")+"|"+e)}function Ts(e){if(typeof e!="string")throw new TypeError("passkey vault: bundle AAD requires a slot string");return te(mb+(vt??"")+"|"+e)}var ga=new Set;function ve(e){return ga.add(e),()=>ga.delete(e)}function Yr(){for(let e of ga)try{e()}catch(t){console.warn("passkey vault listener:",t)}}async function qn({signal:e}={}){let t=yr();if(!t)return!1;let r;try{r=await ca({credentialId:t.credentialId,prfSalt:t.prfSalt,rpId:t.rpId??Es(),...e?{signal:e}:{}})}catch(o){if(o&&o.name==="NotAllowedError"||o&&o.name==="AbortError")return!1;throw o&&o.message?.includes("PRF")?Wn(o):o}if(!r||r.length<32)throw Wn();let n=await aa(r);return r.fill(0),navigator.locks.request(rt,async()=>{let o=yr();if(!o||o.credentialId!==t.credentialId)throw n.fill(0),new Error("passkey: vault state changed during unlock (another tab wiped or re-enabled it). Reload this page and try again.");return oe=await la(n),n.fill(0),vt=o.userId,Kt=o.credentialId,Yr(),!0})}function Wn(e){let t=new Error("Your browser or authenticator doesn't support passkey-derived encryption keys (the WebAuthn PRF extension). Try Chrome 116+, Safari 18+, or Firefox 130+ on a device with a platform authenticator (TouchID / Windows Hello).");return e&&(t.cause=e),t}function ba({migrate:e,userName:t,rpName:r,signal:n,acknowledgeOrphan:o}){if(!Un())throw new Error("passkey: WebAuthn unavailable in this environment");if(Kn()&&!o)throw new Error("passkey: a previous vault exists on this device with no metadata. Any data encrypted under the old passkey will be unreadable after a new setup. Call enableEncryption({acknowledgeOrphan: true}) to proceed, or wipeAllVaultData() to start clean first.");let s=Es();return navigator.locks.request(rt,async()=>{if(ne())throw new Error("passkey: encryption is already enabled");if(await Iu()===!1)throw Wn();let l=yb(),d=await Ru({userName:t||"DeepView user",userId:l,rpName:r||"DeepView",rpId:s,...n?{signal:n}:{}}),u=d.prfOutput;if(!u)try{u=await ca({credentialId:d.credentialId,prfSalt:d.prfSalt,rpId:s,...n?{signal:n}:{}})}catch(m){let y=l.toBase64({alphabet:"base64url",omitPadding:!0});await Ss({credentialId:d.credentialId,rpId:s,userId:y}).catch(()=>{});try{localStorage.removeItem(qr)}catch{}throw m&&m.message?.includes("PRF")?Wn(m):m}if(!u||u.length<32){let m=l.toBase64({alphabet:"base64url",omitPadding:!0});await Ss({credentialId:d.credentialId,rpId:s,userId:m}).catch(()=>{});try{localStorage.removeItem(qr)}catch{}throw Wn()}let p=await aa(u);u.fill(0);let f=await la(p);p.fill(0);let h=l.toBase64({alphabet:"base64url",omitPadding:!0}),b={enabled:!0,credentialId:d.credentialId,prfSalt:d.prfSalt,userId:h,rpId:s,createdAt:Date.now()};oe=f,vt=h,Kt=d.credentialId,Pu(b),typeof e=="function"&&await e({seal:(y,v)=>Vt(f,y,v)});try{localStorage.removeItem(Cs)}catch{}return Yr(),!0})}async function ya({migrate:e}){if(!ne())return{disabled:!1,signalAttempted:!1};if(!pt())throw new Error("passkey: must unlock before disabling encryption");Vn+=1;try{return await navigator.locks.request(rt,async()=>{let t=yr();if(!t)return{disabled:!1,signalAttempted:!1};let r=oe;if(!r)return{disabled:!1,signalAttempted:!1};if(bb(),oe=null,Kt=null,typeof e=="function"){let o=(s,i)=>br(r,s,i);try{await e({open:o})}catch(s){throw Pu(t),oe=r,Kt=t.credentialId,Yr(),s}}vt=null;try{localStorage.setItem(Cs,"1")}catch{}let n=await Ss(t).catch(()=>!1);return Yr(),{disabled:!0,signalAttempted:n}})}finally{Vn-=1}}async function Ss({credentialId:e,rpId:t,userId:r}){if(typeof PublicKeyCredential>"u"||!t)return!1;let n=PublicKeyCredential,o=!1;if(typeof n.signalUnknownCredential=="function"){o=!0;try{await n.signalUnknownCredential({rpId:t,credentialId:e})}catch{}}if(typeof n.signalAllAcceptedCredentials=="function"&&r){o=!0;try{await n.signalAllAcceptedCredentials({rpId:t,userId:r,allAcceptedCredentialIds:[]})}catch{}}return o}async function wb(e,t){try{return await e.removeEntry(t,{recursive:!0}),null}catch(r){return r?.name==="NotFoundError"?null:`${t}: ${r?.message??String(r)}`}}async function vb(e){let t=[];if(typeof navigator>"u"||!navigator.storage?.getDirectory)return t;let r;try{r=await navigator.storage.getDirectory()}catch(n){return t.push(`storage root: ${n?.message??String(n)}`),t}for(let n of e){let o=await wb(r,n);o&&t.push(o)}return t}async function Yn({refuseIfEnabled:e=!1}={}){Vn+=1,ha+=1;try{return await navigator.locks.request(rt,async()=>{if(e&&ne())throw new Error("passkey: encryption was just enabled in another tab. Reload this page to unlock instead of wiping.");await Bu();let t=yr();if(t)try{await Ss({credentialId:t.credentialId,rpId:t.rpId??Es(),userId:t.userId})}catch{}try{localStorage.removeItem(jn)}catch{}try{localStorage.removeItem(qr)}catch{}try{localStorage.removeItem(Cs)}catch{}for(let n of["deepview.workspaces","deepview.sync.sessions","deepview.sync.userEnabled","deepview.repoUrls","deepview.fileCounts","deepview.lastFile","deepview.triage","deepview.triage.pending","deepview.passkey.firstImportPrompted","deepview.viewMode"])try{localStorage.removeItem(n)}catch{}try{let n=[];for(let o=0;o<localStorage.length;o+=1){let s=localStorage.key(o);s&&s.startsWith("deepview.report:")&&n.push(s)}for(let o of n)try{localStorage.removeItem(o)}catch{}}catch{}oe=null,vt=null,Kt=null,Yr();let r=await vb(["deepview-reports","deepview-bundles"]);if(r.length>0)throw new Error(`passkey: wipe partially succeeded \u2014 localStorage cleared but the following OPFS paths could not be removed: ${r.join("; ")}. Open DevTools \u2192 Application \u2192 Storage \u2192 Origin Private File System to inspect, or use the browser's site-data clear tool to finish.`)})}finally{Vn-=1,ha-=1}}function Ou(e){return oe?Vt(oe,e,Gn()):Promise.reject(new Error("passkey: vault locked, cannot seal triage"))}function Nu(e){return oe?br(oe,e,Gn()):Promise.reject(new Error("passkey: vault locked, cannot open triage"))}function Is(e,t){return oe?Vt(oe,e,As(t)):Promise.reject(new Error("passkey: vault locked, cannot seal OPFS file"))}function Du(e,t){return oe?br(oe,e,As(t)):Promise.reject(new Error("passkey: vault locked, cannot open OPFS file"))}function wa(e,t){return oe?Vt(oe,e,Ts(t)):Promise.reject(new Error("passkey: vault locked, cannot seal bundle"))}function va(e,t){return oe?br(oe,e,Ts(t)):Promise.reject(new Error("passkey: vault locked, cannot open bundle"))}typeof window<"u"&&window.addEventListener("storage",e=>{if(e.key!==jn)return;let t=yr();(!t&&oe||t&&oe&&t.credentialId!==Kt)&&(oe=null,vt=null,Kt=null),Yr()});var _a="__meta__",kb="deepview-reports",Sa="deepview-bundles",Ft="deepview.report:",zu=!1;async function Ca(e,{create:t,warnOnce:r=!1}={}){try{return await(await navigator.storage.getDirectory()).getDirectoryHandle(e,{create:t})}catch(n){return r&&!zu&&(zu=!0,console.warn("OPFS unavailable, falling back to gzipped localStorage (limited quota).",n)),null}}async function Rs(e,t){let r=await e.createWritable();try{await r.write(t),await r.close()}catch(n){try{await r.abort(n)}catch{}throw n}}async function ka(e,t){if(!je(e))return e;if(!Ae())throw new Error(`storage: vault locked, cannot decrypt "${t}"`);return await Du(e,t)}async function Jn(e,t,r,n,o=()=>{}){if(ne()&&!Ae())throw o(),new Error(`storage: vault locked, cannot save ${n}`);let s=Ae(),i=s?await t(e,r):e;if(Ae()!==s)throw o(),new Error(`storage: vault state changed mid-save for ${n}; retry`);return i}function wr(){return Ca(kb,{create:!0,warnOnce:!0})}var ft=new Map,Gt=new Map,$a=new Map;function le(e){$a.set(e,($a.get(e)??0)+1)}function Uu(e){return $a.get(e)??0}var xa=new Set;function Hu(e){return xa.add(e),()=>xa.delete(e)}function Jr(e,t){for(let r of xa)try{r(e,t)}catch(n){console.warn("storage file-change listener:",n)}}async function fe(){let e=await wr();if(e){let r=[];for await(let[n]of e.entries())r.push(n);return r.toSorted()}let t=[];for(let r=0;r<localStorage.length;r++){let n=localStorage.key(r);n&&n.startsWith(Ft)&&t.push(n.slice(Ft.length))}return t.toSorted()}async function ht(e,t){if(typeof e!="string"||e.includes("\0"))throw new Error("Invalid report name: contains NUL byte or is not a string");return le(e),navigator.locks.request(rt,{mode:"shared"},async()=>{let r=await wr();if(r){let s=await Dn(te(t));s=await Jn(s,Is,e,`"${e}"`,()=>le(e));let l=await(await r.getFileHandle(e,{create:!0})).createWritable();try{await l.write(s),await l.close()}catch(d){ft.delete(e),le(e);try{await l.abort(d)}catch{}throw d}ft.set(e,t),le(e),Jr(e,"save");return}let n=te(t);n=await Dn(n),n=await Jn(n,Is,e,`"${e}"`,()=>le(e));let o=n.toBase64();try{localStorage.setItem(Ft+e,o),ft.set(e,t),le(e),Jr(e,"save")}catch(s){throw le(e),new Error(`localStorage write failed for ${e}: ${s.message}`,{cause:s})}})}async function De(e){if(ft.has(e))return ft.get(e);if(Gt.has(e))return Gt.get(e);let t=Uu(e),r=(async()=>{let n=await wr();if(n){let d=await(await n.getFileHandle(e)).getFile(),u=new Uint8Array(await d.arrayBuffer());if(u=await ka(u,e),u.length>=2&&u[0]===31&&u[1]===139){let f=await wt(u);return he(f)}let p=he(u);return ht(e,p).catch(f=>{console.warn(`storage: legacy-uncompressed migration of "${e}" failed:`,f)}),p}let o=localStorage.getItem(Ft+e);if(o===null)throw new Error(`File not found: ${e}`);let s=Uint8Array.fromBase64(o);s=await ka(s,e);let i=await wt(s);return he(i)})();Gt.set(e,r);try{let n=await r;return Uu(e)===t&&ft.set(e,n),n}finally{Gt.delete(e)}}async function vr(e){let t=await wr(),r;if(t){let o=await(await t.getFileHandle(e)).getFile();r=new Uint8Array(await o.arrayBuffer())}else{let n=localStorage.getItem(Ft+e);if(n===null)throw new Error(`File not found: ${e}`);r=Uint8Array.fromBase64(n)}return r=await ka(r,e),r}async function Qn(e,t){if(typeof e!="string"||e.includes("\0"))throw new Error("Invalid report name: contains NUL byte or is not a string");return le(e),ft.delete(e),navigator.locks.request(rt,{mode:"shared"},async()=>{let r=await Jn(t,Is,e,`"${e}"`,()=>le(e)),n=await wr();if(n){let s=await(await n.getFileHandle(e,{create:!0})).createWritable();try{await s.write(r),await s.close()}catch(i){le(e);try{await s.abort(i)}catch{}throw i}le(e),Jr(e,"save");return}try{localStorage.setItem(Ft+e,r.toBase64()),le(e),Jr(e,"save")}catch(o){throw le(e),new Error(`localStorage write failed for ${e}: ${o.message}`,{cause:o})}})}async function Xr(e){return le(e),ft.delete(e),Gt.delete(e),navigator.locks.request(rt,{mode:"shared"},async()=>{let t=await wr();if(t){try{await t.removeEntry(e)}catch(r){if(!(r instanceof DOMException)||r.name!=="NotFoundError")throw le(e),r}le(e),Jr(e,"delete");return}localStorage.removeItem(Ft+e),le(e),Jr(e,"delete")})}var Xn="_meta.json";function Zn(){return Ca(Sa,{create:!0})}function Ea(e){return e.replaceAll("/","_")}async function Aa(e){let t;try{let o=await(await e.getFileHandle(Xn)).getFile();t=new Uint8Array(await o.arrayBuffer())}catch(n){return n instanceof DOMException&&n.name==="NotFoundError"?[]:(console.warn("readBundleMeta: failed to read _meta.json:",n),[])}let r=t;if(je(t)){if(!Ae())return console.warn("readBundleMeta: vault locked, returning empty bundle list"),[];try{r=await va(t,_a)}catch(o){return console.warn("readBundleMeta: decrypt failed (tampering, key mismatch, or vault identity drift):",o),[]}}try{let n=JSON.parse(he(r));return Array.isArray(n)?n:[]}catch(n){return console.warn("readBundleMeta: JSON.parse failed:",n),[]}}async function Wu(e,t){let r=te(JSON.stringify(t));r=await Jn(r,wa,_a,"bundle metadata");try{await e.removeEntry(Xn)}catch{}let n=await e.getFileHandle(Xn,{create:!0});await Rs(n,r)}var $b=`${Sa}/${Xn}`;function Vu(e){return navigator.locks.request($b,e)}async function gt(){let e=await Zn();return e?[...await Aa(e)].toSorted((r,n)=>r.name.localeCompare(n.name)):[]}async function Ta(){if(typeof navigator>"u"||!navigator.storage?.getDirectory)return!1;let e=await Ca(Sa,{create:!1});if(!e)return!1;try{for await(let t of e.entries())return!0}catch{}return!1}async function kr(e,t){let r=await Zn();if(!r)throw new Error(`Cannot save bundle ${e}: OPFS unavailable`);let n=t instanceof Uint8Array?t:te(t),o=await Tu(n),s=Ea(o),i=e.toLowerCase().endsWith(".map")?await Dn(n):n;return navigator.locks.request(rt,{mode:"shared"},async()=>{i=await Jn(i,wa,o,`bundle "${e}"`);try{await r.removeEntry(s)}catch{}let l=await r.getFileHandle(s,{create:!0});await Rs(l,i);try{await Vu(async()=>{let d=await Aa(r),u=d.findIndex(p=>p.integrity===o);u>=0?d[u]={integrity:o,name:e}:d.push({integrity:o,name:e}),await Wu(r,d)})}catch(d){try{await r.removeEntry(s)}catch{}throw d}return{integrity:o,name:e}})}async function Ia(e){let t=await Zn();if(t)return navigator.locks.request(rt,{mode:"shared"},async()=>{try{await t.removeEntry(Ea(e))}catch(r){if(!(r instanceof DOMException)||r.name!=="NotFoundError")throw r}await Vu(async()=>{let r=await Aa(t),n=r.filter(o=>o.integrity!==e);n.length!==r.length&&await Wu(t,n)})})}async function $r(e){let t=await Zn();if(!t)throw new Error("OPFS unavailable");let n=await(await t.getFileHandle(Ea(e))).getFile(),o=new Uint8Array(await n.arrayBuffer());if(je(o)){if(!Ae())throw new Error(`storage: vault locked, cannot read bundle "${e}"`);o=await va(o,e)}return o.length>=2&&o[0]===31&&o[1]===139?await wt(o):o}async function xb(e,t){let r=await wr();if(r){let l=await(await r.getFileHandle(e)).getFile(),d=new Uint8Array(await l.arrayBuffer()),u=await t(d);if(u===null)return;ft.delete(e),Gt.delete(e),le(e);let p=await r.getFileHandle(e,{create:!0});await Rs(p,u),le(e);return}let n=localStorage.getItem(Ft+e);if(n===null)return;let o=Uint8Array.fromBase64(n),s=await t(o);s!==null&&(ft.delete(e),Gt.delete(e),le(e),localStorage.setItem(Ft+e,s.toBase64()),le(e))}function ju(e,t){return e.seal?r=>je(r)?null:e.seal(r,t):r=>je(r)?e.open(r,t):null}async function Ku(e){let t=await fe();for(let r of t)try{await xb(r,ju(e,As(r)))}catch(n){if(n instanceof DOMException&&n.name==="NotFoundError")continue;throw n}}var Ra=({seal:e})=>Ku({seal:e}),Fa=({open:e})=>Ku({open:e});async function _b(){let e=await Zn();if(!e)return{dir:null,keys:[]};let t=[];for await(let[r]of e.entries())t.push(r);return{dir:e,keys:t}}function Sb(e){return e===Xn?_a:e.startsWith("sha512-")?e.replaceAll("_","/"):null}async function Cb(e,t,r){let o=await(await e.getFileHandle(t)).getFile(),s=new Uint8Array(await o.arrayBuffer()),i=await r(s);if(i===null)return;let l=await e.getFileHandle(t,{create:!0});await Rs(l,i)}async function Gu(e){let{dir:t,keys:r}=await _b();if(t)for(let n of r){let o=Sb(n);if(o!==null)try{await Cb(t,n,ju(e,Ts(o)))}catch(s){if(s instanceof DOMException&&s.name==="NotFoundError")continue;throw s}}}var Ba=({seal:e})=>Gu({seal:e}),Ma=({open:e})=>Gu({open:e});ve(()=>{ft.clear(),Gt.clear()});var Bs="deepview.viewMode",Fs="deepview.repoUrls",Eb=new Set(["grouped","list","table","kanban","focus"]);function Ab(){try{let e=localStorage.getItem(Bs);return e!==null&&Eb.has(e)?e:null}catch{return null}}function Pa(e){try{let t=JSON.parse(e||"{}");return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}catch{return{}}}function Ms(){return Pa(we(Fs))}function qe(e){return e?Ms()[e]??"":""}var La=new Set;function qu(e){return La.add(e),()=>{La.delete(e)}}function Tb(e){for(let t of La)try{t(e)}catch(r){console.warn("repo-url listener:",r)}}function Ye(e,t){if(!e)return;let r=Ms();t?r[e]=t:delete r[e],Ee(Fs,JSON.stringify(r)).catch(n=>console.warn("saveRepoUrlFor:",n)),fa(Fs,n=>{let o=Pa(n);return t?o[e]=t:delete o[e],JSON.stringify(o)}).catch(n=>console.warn("saveRepoUrlFor cross-tab merge:",n)),Tb(e)}async function Yu(e,t){await fa(Fs,r=>{let n=Pa(r),o=t==="replace"?{...e}:t==="prefer-imported"?{...n,...e}:{...e,...n};return JSON.stringify(o)}),Ju()}var a=xu({reports:[],workspaceMerges:[],currentFile:null,currentWorkspace:null,currentView:"findings",bundles:[],selectedBundle:null,bundleDetails:null,bundleDetailsTab:"overview",selectedPackage:null,selectedPackageVersion:null,packageDetailsTab:"overview",packageSlideTriage:null,packageSlideTransient:!1,packagesSearchQuery:"",packagesSortBy:"findings-desc",expandedPackages:new Set,selectedRepository:null,repositoryDetailsTab:"overview",repositorySlideTriage:null,repositorySlideTransient:!1,repositoriesSearchQuery:"",repositoriesSortBy:"findings-desc",bundleSourceFile:null,bundleSourceFindingIdx:null,bundleCodeSearchMode:"files",bundleCodeSearchQuery:"",bundleSearchQuery:"",bundleSearchRegex:!1,bundleSearchCase:!1,bundleSearchContext:!0,filterSeverities:new Set,filterColors:new Set,filterSources:new Set,filterAnalyzer:"",filterModel:"",filterRepo:"",filterConfMin:0,filterConfMax:10,filterInclude:"",filterIncludeNegate:!1,filterComment:"",filterFix:"",filterFlagged:"",repoUrl:"",repoEditing:!1,sortBy:"severity",viewMode:Ab()??"table",triage:new Map,shownTriage:null,nextFindingId:0,activeTabByGroup:new Map,tableSelectedGid:null,filesViewMode:"table",filesSearch:"",filesSelectedFile:null,kanbanPopoverGid:null,focusGid:null,focusCodeTick:0});function Ju(){a.repoEditing||a.currentFile&&(a.repoUrl=qe(a.currentFile))}Kr(()=>{Ju()});var Ib=/^## ([A-Z][A-Z_]*)\s*\(\d+\)\s*$/mu;function Rb(e){switch(e.toUpperCase()){case"CRITICAL":return"critical";case"HIGH":return"high";case"MEDIUM":return"medium";case"LOW":return"low";case"HIGH_BUG":return"high_bug";case"BUG":return"bug";case"INFO":case"INFORMATIONAL":return"informational";default:return"medium"}}function Fb(e){if(e)switch(e.toLowerCase()){case"high":return 8;case"medium":return 5;case"low":return 2;default:return}}function Bb(e){return typeof e=="string"?e.replace(/^`(.*)`$/u,"$1"):e}function Qr(e){let t=e.replaceAll(/\r\n?/gu,`
4
+ `).trim();if(!Ib.test(t))return null;let r=t.split(/^## ([A-Z][A-Z_]*)\s*\(\d+\)\s*\n/mu),n=[];for(let o=1;o<r.length;o+=2){let s=Rb(r[o]),l=(r[o+1]||"").split(/^### /mu).slice(1);for(let d of l){let u=Mb(d,s);u&&n.push(u)}}return n.length===0?null:{type:"security",source:"deepsec",findings:n}}function Mb(e,t){let r=e.indexOf(`
5
5
  `),n=(r===-1?e:e.slice(0,r)).trim();if(!n)return null;let o=r===-1?"":e.slice(r+1);o=o.replace(/\n---\s*$/u,"").trim();let s={};for(let y of o.matchAll(/^- \*\*([^:*]+):\*\*\s*(.+)$/gmu))s[y[1].trim().toLowerCase()]=y[2].trim();let i=/^\*\*Recommendation:\*\*\s*/mu.exec(o),l=o,d="";i&&(l=o.slice(0,i.index),d=o.slice(i.index+i[0].length).trim());let u=l.split(`
6
6
  `).filter(y=>!/^\s*- \*\*/u.test(y)).join(`
7
7
  `).replaceAll("**","").trim(),p=n+(u?`
8
8
 
9
- `+u:""),f=Qm(s.file||"unknown"),h=(s.lines||"").split(",").map(y=>y.trim()).find(Boolean)||"?",b={file:f,line:h,severity:t,description:p};d&&(b.recommendation=d.replaceAll("**",""));let m=Xm(s.confidence);return m!==void 0&&(b.confidence=m),s.slug&&(b.slug=s.slug),b}var eb=new Set(["critical","high","medium","low","high_bug","bug","informational"]);function Kr(e){let t=e.replaceAll(/\r\n?/gu,`
10
- `).trim();if(!t.startsWith("# "))return null;let r=t.split(/^# /mu).filter(s=>s.trim().length>0),n=[];for(let s of r){let i=tb(s);i&&n.push(i)}return n.length===0?null:{type:n.find(s=>s.type)?.type||"analysis",source:"claude-security",findings:n}}function tb(e){let t=e.indexOf(`
11
- `),r=(t===-1?e:e.slice(0,t)).trim();if(!r)return null;let n=t===-1?"":e.slice(t+1),{sectionsText:o,metaText:s}=rb(n),i=nb(o),l=ob(s),{file:d,line:u,locationLink:p}=sb(i.location||""),f=(l.severity||"").toLowerCase(),h=eb.has(f)?f:"medium",b=ib(r,i),m=i["recommended fix"]?Ru(i["recommended fix"]):void 0,y={file:d||"unknown",line:u,severity:h,description:b};return p&&(y.location=p),m&&(y.recommendation=m),l.repository&&(y.repo={github:l.repository}),l.branch&&(y.branch=l.branch),l["date created"]&&(y.dateCreated=l["date created"]),l.status&&(y.status=l.status),l.category&&(y.type=l.category.toLowerCase()),y}function rb(e){let t=/^---\s*$/mu,r=t.exec(e);if(!r)return{sectionsText:e,metaText:""};let n=e.slice(0,r.index).trim(),o=e.slice(r.index+r[0].length).replace(/^\n/u,""),s=t.exec(o),i=s?o.slice(0,s.index):o;return{sectionsText:n,metaText:i}}function nb(e){let t={},r=e.split(/^## /mu);for(let n=1;n<r.length;n++){let o=r[n],s=o.indexOf(`
12
- `),i=(s===-1?o:o.slice(0,s)).trim().toLowerCase(),l=(s===-1?"":o.slice(s+1)).trim();i&&(t[i]=l)}return t}function ob(e){let t={};for(let r of e.matchAll(/\*\*([^:]+):\*\*\s*(.+)/gu))t[r[1].trim().toLowerCase()]=r[2].trim();return t}function sb(e){let t="",r="?",n="",o=e.match(/\[([^\]]+)\]\(([^)]+)\)/u);if(o){t=o[1].trim(),n=o[2];let i=o[2].match(/#L(\d+)/u);i&&(r=i[1])}else t=e.trim(),n=e.trim();let s=t.match(/^(.+):(\d+)$/u);return s&&(t=s[1],r==="?"&&(r=s[2])),{file:t,line:r,locationLink:n}}function ib(e,t){let r=[e];return t.details&&r.push(t.details),t.impact&&r.push(`Impact: ${t.impact}`),t["reproduction steps"]&&r.push(`Reproduction: ${t["reproduction steps"]}`),Ru(r.join(`
9
+ `+u:""),f=Bb(s.file||"unknown"),h=(s.lines||"").split(",").map(y=>y.trim()).find(Boolean)||"?",b={file:f,line:h,severity:t,description:p};d&&(b.recommendation=d.replaceAll("**",""));let m=Fb(s.confidence);return m!==void 0&&(b.confidence=m),s.slug&&(b.slug=s.slug),b}var Lb=new Set(["critical","high","medium","low","high_bug","bug","informational"]);function Zr(e){let t=e.replaceAll(/\r\n?/gu,`
10
+ `).trim();if(!t.startsWith("# "))return null;let r=t.split(/^# /mu).filter(s=>s.trim().length>0),n=[];for(let s of r){let i=Pb(s);i&&n.push(i)}return n.length===0?null:{type:n.find(s=>s.type)?.type||"analysis",source:"claude-security",findings:n}}function Pb(e){let t=e.indexOf(`
11
+ `),r=(t===-1?e:e.slice(0,t)).trim();if(!r)return null;let n=t===-1?"":e.slice(t+1),{sectionsText:o,metaText:s}=Ob(n),i=Nb(o),l=Db(s),{file:d,line:u,locationLink:p}=zb(i.location||""),f=(l.severity||"").toLowerCase(),h=Lb.has(f)?f:"medium",b=Ub(r,i),m=i["recommended fix"]?Xu(i["recommended fix"]):void 0,y={file:d||"unknown",line:u,severity:h,description:b};return p&&(y.location=p),m&&(y.recommendation=m),l.repository&&(y.repo={github:l.repository}),l.branch&&(y.branch=l.branch),l["date created"]&&(y.dateCreated=l["date created"]),l.status&&(y.status=l.status),l.category&&(y.type=l.category.toLowerCase()),y}function Ob(e){let t=/^---\s*$/mu,r=t.exec(e);if(!r)return{sectionsText:e,metaText:""};let n=e.slice(0,r.index).trim(),o=e.slice(r.index+r[0].length).replace(/^\n/u,""),s=t.exec(o),i=s?o.slice(0,s.index):o;return{sectionsText:n,metaText:i}}function Nb(e){let t={},r=e.split(/^## /mu);for(let n=1;n<r.length;n++){let o=r[n],s=o.indexOf(`
12
+ `),i=(s===-1?o:o.slice(0,s)).trim().toLowerCase(),l=(s===-1?"":o.slice(s+1)).trim();i&&(t[i]=l)}return t}function Db(e){let t={};for(let r of e.matchAll(/\*\*([^:]+):\*\*\s*(.+)/gu))t[r[1].trim().toLowerCase()]=r[2].trim();return t}function zb(e){let t="",r="?",n="",o=e.match(/\[([^\]]+)\]\(([^)]+)\)/u);if(o){t=o[1].trim(),n=o[2];let i=o[2].match(/#L(\d+)/u);i&&(r=i[1])}else t=e.trim(),n=e.trim();let s=t.match(/^(.+):(\d+)$/u);return s&&(t=s[1],r==="?"&&(r=s[2])),{file:t,line:r,locationLink:n}}function Ub(e,t){let r=[e];return t.details&&r.push(t.details),t.impact&&r.push(`Impact: ${t.impact}`),t["reproduction steps"]&&r.push(`Reproduction: ${t["reproduction steps"]}`),Xu(r.join(`
13
13
 
14
- `))}function Ru(e){return e.replaceAll("**","")}function ab(e){return Array.from(e,t=>t.toString(16).padStart(2,"0")).join("")}function lb(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCodePoint(e[r]);return btoa(t)}async function Fu(e){let t=typeof e=="string"?Y(e):e,r=await crypto.subtle.digest("SHA-512",t);return`sha512-${lb(new Uint8Array(r))}`}async function cb(e){let t=Y(JSON.stringify(e)),r=await crypto.subtle.digest("SHA-256",t),n=new Uint8Array(r,0,16);n[6]=n[6]&15|64,n[8]=n[8]&63|128;let o=ab(n);return`${o.slice(0,8)}-${o.slice(8,12)}-${o.slice(12,16)}-${o.slice(16,20)}-${o.slice(20,32)}`}async function ws(e){if(typeof crypto?.subtle?.digest!="function")return null;let t;e.fileHash?t={severity:e.severity,description:e.description,fileHash:e.fileHash}:e.location?t={severity:e.severity,description:e.description,location:e.location}:t={severity:e.severity,description:e.description,file:e.file,line:e.line};try{return await cb(t)}catch{return null}}function Gt(e){try{return JSON.parse(e)}catch{return Vr(e)??Kr(e)}}function qt(e){let t=[];for(let r of e){let n=Array.isArray(r)?r:[r];for(let o of n)o&&t.push(o)}return t}async function Gr(e){let t=e.filter(n=>n&&!n.id);if(t.length===0)return;let r=await Promise.all(t.map(ws));t.forEach((n,o)=>{r[o]&&(n.id=r[o])})}var qr=new Map,Yr=new Map,Jr=new Map,vs=new Map;function db(e){let t=e?.package?.npm;if(typeof t?.name=="string"&&t.name&&!Or(t))return t.name;if(!e?.file)return null;let r=/(?:^|\/)(?:node_modules|dependencies)\/(@[^/]+\/[^/]+|[^/]+)/gu,n;for(;(n=r.exec(e.file))!==null;)if(n[1]!==".pnpm")return n[1];return null}function ub(e){return typeof e?.file!="string"?!1:/(?:^|\/)(?:node_modules|dependencies)\//u.test(e.file)}function pb(e,t){return typeof e.repo?.github=="string"&&e.repo.github?e.repo.github:typeof e._repoFallback=="string"&&e._repoFallback?e._repoFallback:typeof t=="string"&&t?t:null}var zn=new Set,xa=new Set,Un=null,_a=!1;function Sa(e){return xa.add(e),()=>xa.delete(e)}function Ca(){for(let e of xa)try{e()}catch{}}function ks(e){return qr.get(e)?.list??[]}function kt(){return Yr}function wr(){return Jr}function Wn(e,t){let r=qr.get(e);if(!r)return[];let n=r.reports.get(Yt(t));return n?[...n]:[]}function Ea(e,t){let r=Yr.get(e);if(!r)return[];let n=r._keyReports.get(Yt(t));return n?[...n]:[]}function Aa(e,t){let r=Jr.get(e);if(!r)return[];let n=r._keyReports.get(Yt(t));return n?[...n]:[]}var Bu=["type","model","think","effort","exportsMode"];function fb(e,t){if(!Bu.some(r=>e[r]!==void 0))for(let r of Bu)t[r]!==void 0&&(e[r]=t[r])}function hb(e){let t=Array.isArray(e?.findings)?e.findings:Array.isArray(e?.groups)?e.groups:null;if(!t)return[];let r=!e?.source,n=[];for(let o of qt(t))r&&fb(o,e),n.push(o);return n}function Yt(e){return e.id?`id:${e.id}`:`c:${e.severity??""}|${e.description??""}|${e.file??""}|${e.line??""}`}function Ta(e,t,r){let n=vs.get(e);n||(n={hash:[],pkg:[],repo:[]},vs.set(e,n)),n[t].push(r)}function gb(e,t,r){let n=qr.get(e.fileHash);n||(n={keys:new Set,list:[],reports:new Map},qr.set(e.fileHash,n));let o=n.reports.get(t);o||(o=new Set,n.reports.set(t,o));let s=!o.has(r);return o.add(r),s&&Ta(r,"hash",{hash:e.fileHash,key:t}),n.keys.has(t)?s:(n.keys.add(t),n.list.push(e),!0)}function mb(e,t,r){let n=db(e);if(!n)return!1;let o=iu(e),s=Yr.get(n);if(s||(s={...es(),repos:new Set,byVersion:new Map,_repoReports:new Map},Yr.set(n,s)),typeof e.repo?.github=="string"&&e.repo.github){s.repos.add(e.repo.github);let l=s._repoReports.get(e.repo.github);l||s._repoReports.set(e.repo.github,l=new Set),l.add(r)}au(s,o,e,t,r);let i=ts(s,t,r,e);return Ta(r,"pkg",{pkg:n,key:t,file:e.file,version:o}),i}function bb(e,t,r,n){if(ub(e))return!1;let o=pb(e,n);if(!o)return!1;let s=Jr.get(o);s||(s=es(),Jr.set(o,s));let i=ts(s,t,r,e);return i&&Ta(r,"repo",{repo:o,key:t,file:e.file}),i}function Ia(e){let t=vs.get(e);if(vs.delete(e),zn.delete(e),!t)return!1;let r=!1;for(let{hash:o,key:s}of t.hash){let i=qr.get(o);if(!i)continue;let l=i.reports.get(s);if(l){if(l.delete(e)&&(r=!0),l.size===0){i.reports.delete(s),i.keys.delete(s);let d=i.list.findIndex(u=>Yt(u)===s);d>=0&&i.list.splice(d,1)}i.keys.size===0&&qr.delete(o)}}let n=new Set;for(let{pkg:o,key:s,file:i,version:l}of t.pkg){let d=Yr.get(o);if(!d)continue;let u=d._keyReports.get(s);if(u){if(u.delete(e)&&(r=!0),u.size===0&&rs(d,s,i,Yt),lu(d,l,s,i,e,Yt),!n.has(o)){n.add(o);for(let p of[...d._repoReports.keys()]){let f=d._repoReports.get(p);f?.delete(e)&&f.size===0&&(d._repoReports.delete(p),d.repos.delete(p),r=!0)}}d._keyReports.size===0?Yr.delete(o):ns(d)}}for(let{repo:o,key:s,file:i}of t.repo){let l=Jr.get(o);if(!l)continue;let d=l._keyReports.get(s);d&&(d.delete(e)&&(r=!0),d.size===0&&rs(l,s,i,Yt),l._keyReports.size===0?Jr.delete(o):ns(l))}return r}async function yb(e){if(zn.has(e))return!1;zn.add(e);try{let t=await Oe(e),r=Gt(t);if(!r)return!1;let n=hb(r);if(n.length===0)return!1;let o="";try{o=Ke(e)}catch{}let s=!1;for(let i of n){let l=Yt(i);i.fileHash&&gb(i,l,e)&&(s=!0),i.file&&mb(i,l,e)&&(s=!0),i.file&&bb(i,l,e,o)&&(s=!0)}return zn.has(e)?s:(Ia(e),_a=!0,!1)}catch{return zn.delete(e),!1}}function $t(){return Un||(Un=(async()=>{try{do{_a=!1;let e=await pe();for(let t of e)await yb(t)&&Ca()}while(_a)}finally{Un=null}})(),Un)}$u(e=>{Ia(e)&&Ca()});Au(e=>{Ia(e)&&Ca(),$t().catch(()=>{})});var Hn=new Map,jn=new Map;function $s(e,t){if(!e||!t)return!1;let r=!jn.has(e);jn.set(e,t);for(let[n,o]of t){if(!o)continue;let s=Hn.get(o);s||(s=new Map,Hn.set(o,s)),s.set(e,n)}return r}function Ra(e){let t=jn.get(e);if(jn.delete(e),!!t)for(let r of t.values()){let n=Hn.get(r);n&&(n.delete(e),n.size===0&&Hn.delete(r))}}function vr(e){if(!e)return[];let t=Hn.get(e);if(!t)return[];let r=[];for(let[n,o]of t)r.push({integrity:n,file:o});return r}function Fa(e){return jn.has(e)}var Mu="deepview.fileCounts",Qr=null;function _s(){if(Qr)return Qr;try{Qr=JSON.parse(we(Mu)||"{}")}catch{Qr={}}return Qr}function Ba(){Se(Mu,JSON.stringify(Qr)).catch(e=>console.warn("counts persist:",e))}function Lu(e){let t=_s()[e];if(t!==void 0)return typeof t=="number"?{count:t}:t}function Kn(e){return Lu(e)?.count}function Gn(e){return Lu(e)?.source}function qe(e,t,r){let n=_s();n[e]=r?{count:t,source:r}:{count:t},Ba()}function Zr(e){let t=_s();delete t[e],Ba()}function ze(e){try{let n=JSON.parse(e);if(n&&Array.isArray(n.findings))return{count:n.findings.length,source:n.source,recognized:!0}}catch{}let t=Vr(e);if(t)return{count:t.findings.length,source:t.source,recognized:!0};let r=Kr(e);return r?{count:r.findings.length,source:r.source,recognized:!0}:{count:0,recognized:!1}}var Vn=null,Xr=null,xs=null;function wb(e,t){for(let{names:r,onUpdate:n}of xs)if(r.has(e))try{n(e,t)}catch(o){console.warn("ensureCounts onUpdate:",o)}}function Ma(e,t){if(Vn){t&&xs.push({names:new Set(e),onUpdate:t});for(let r of e)Xr.add(r);return Vn}return Xr=new Set(e),xs=t?[{names:new Set(e),onUpdate:t}]:[],Vn=(async()=>{await Promise.resolve();try{let r=_s();for(;Xr.size>0;){let n=Xr.values().next().value;if(Xr.delete(n),r[n]===void 0)try{let o=await Oe(n);if(r[n]!==void 0)continue;let{count:s,source:i}=ze(o);r[n]=i?{count:s,source:i}:{count:s},Ba(),wb(n,s)}catch{}}}finally{Vn=null,Xr=null,xs=null}})(),Vn}function La(e){if(!e)return"";for(let t of e.split(`
15
- `))if(t.trim())return t.trim();return""}function Pa(e){let t=new Set(e.map(n=>n.id)),r=new Map;for(let n of a.reports)for(let o of n.groups)for(let s of o){let i=s.id??String(s._id);if(!(!t.has(i)||r.has(i))&&(r.set(i,{severity:s.severity,file:s.file,line:s.line,description:La(s.description)}),r.size===t.size))return r}return r}var vb=`deepview/workspace-id/v1
16
- `;async function qn(e){let t=Uint8Array.fromBase64(e),r=Y(vb),n=new Uint8Array(r.length+t.length);n.set(r,0),n.set(t,r.length);let o=new Uint8Array(await crypto.subtle.digest("SHA-256",n)),i=Array.from(o.subarray(0,16),u=>u.toString(16).padStart(2,"0")).join("").split("");i[12]="8";let l=parseInt(i[16],16)&3|8;i[16]=l.toString(16);let d=i.join("");return`${d.slice(0,8)}-${d.slice(8,12)}-${d.slice(12,16)}-${d.slice(16,20)}-${d.slice(20,32)}`}function Yn(e){let t=new Set;function r(o){return t.add(o),()=>t.delete(o)}function n(o){for(let s of t)try{s(o)}catch(i){console.warn(`workspace ${e} listener failed:`,i)}}return{on:r,fire:n}}var Pu=Yn("create"),Ou=Yn("delete"),Nu=Yn("privateKey"),Du=Yn("report-membership"),Uu=Yn("bundle-membership"),kb=Pu.on,Oa=Ou.on,Na=Nu.on,Da=Du.on,Ua=Uu.on,Ss=Pu.fire,za=Ou.fire,Wa=Nu.fire,Cs=Du.fire,Es=Uu.fire;var ja="deepview.workspaces",$b=1;function Jn(){try{let e=we(ja);if(!e)return[];let t=JSON.parse(e);return t&&typeof t=="object"&&Array.isArray(t.workspaces)?t.workspaces:Array.isArray(t)?t:[]}catch{return[]}}async function xb(e){await Se(ja,JSON.stringify({version:$b,workspaces:e}))}var _b=ja;function en(e){return navigator.locks.request(_b,async()=>{await jt();let t=Jn(),r=await e(t);if(r!==!1)return await xb(t),r})}function Xn(e){return{id:e.id,privateKey:e.privateKey,reports:Array.isArray(e.reports)?[...e.reports]:[],bundles:Array.isArray(e.bundles)?[...e.bundles]:[]}}var ft=Jn().map(Xn);function Va(){ft=Jn().map(Xn)}function Ka(e){ft=ft.filter(t=>t.id!==e.id),ft.push(Xn(e))}function Sb(e,t){let r=Array.isArray(e[t])?[...e[t]]:[],n=ft.find(o=>o.id===e.id);if(n){n[t]=r;return}ft.push(Xn(e))}function Cb(e){ft=ft.filter(t=>t.id!==e)}function W(){let e=Jn();for(let t of e)Array.isArray(t.reports)||(t.reports=[]),Array.isArray(t.bundles)||(t.bundles=[]);return e}var Eb=200;function xt(e){let t=(e??"").trim();return t&&t.replaceAll(/[\u0000-\u001F\u007F]/gu,"").slice(0,Eb)||null}async function Ga(e){let t=xt(e);if(!t)return null;let r=new Uint8Array(32);crypto.getRandomValues(r);let n=r.toBase64(),o={id:await qn(n),name:t,privateKey:n,reports:[],bundles:[],createdAt:Date.now()};return await en(i=>i.some(l=>l.id===o.id)?!1:(i.push(o),o))?(Ka(o),o):null}async function qa(e){await en(r=>{let n=r.findIndex(o=>o.id===e);return n<0?!1:(r.splice(n,1),!0)})&&(za(e),Cb(e))}async function Ya(e,t){let r=xt(t);return!(!r||!await en(o=>{let s=o.find(i=>i.id===e);return!s||s.name===r?!1:(s.name=r,s)}))}async function zu(e){let t=await en(o=>{let s=o.findIndex(p=>p.id===e.id),i=s>=0?o[s]:null,l=xt(e.name)??i?.name??"Workspace",d=e.preserveBundles?Array.isArray(i?.bundles)?i.bundles:[]:Array.isArray(e.bundles)?e.bundles:[],u={id:e.id,name:l,privateKey:e.privateKey,reports:Array.isArray(e.reports)?[...new Set(e.reports)]:[],bundles:[...new Set(d)],createdAt:e.createdAt??Date.now()};return s>=0?o[s]=u:o.push(u),{previous:i,next:u}}),{next:r}=t,n=ft.find(o=>o.id===r.id)??null;return n==null?Ss(r.id):(n.privateKey!==r.privateKey&&Wa(r.id),As(n.reports,r.reports)||Cs(r.id),As(n.bundles,r.bundles)||Es(r.id)),Ka(r),r}async function Ja({id:e,name:t,privateKey:r,createdAt:n}){let o=null;return await en(s=>{let i=xt(t);if(!i)return o={status:"name-collision",existing:null},!1;let l=s.find(p=>p.id===e)??null;if(l)return o={status:"already-attached",workspace:l},!1;let d=s.find(p=>xt(p.name)===i)??null;if(d)return o={status:"name-collision",existing:d},!1;let u={id:e,name:i,privateKey:r,reports:[],bundles:[],createdAt:n??Date.now()};s.push(u),o={status:"attached",workspace:u}}),o?.status==="attached"&&(Ss(o.workspace.id),Ka(o.workspace)),o}function As(e,t){let r=new Set(e),n=new Set(t);if(r.size!==n.size)return!1;for(let o of r)if(!n.has(o))return!1;return!0}async function Ha({identifier:e,workspaceId:t,field:r,fire:n,additive:o=!1,from:s=void 0}){let i=await en(u=>{if((u.find(m=>Array.isArray(m[r])&&m[r].includes(e))?.id??null)===(t??null))return!1;let f=null;if(t!=null&&(f=u.find(m=>m.id===t)??null,!f))return!1;let h=new Set;if(!o)for(let m of u)s!==void 0&&m.id!==s||(Array.isArray(m[r])||(m[r]=[]),m[r].includes(e)&&(m[r]=m[r].filter(y=>y!==e),h.add(m.id)));if(f&&(Array.isArray(f[r])||(f[r]=[]),f[r].includes(e)||(f[r].push(e),h.add(f.id))),h.size===0)return!1;let b=new Map;for(let m of h){let y=u.find(k=>k.id===m);y&&b.set(m,y)}return{affected:h,snapshot:b}});if(!i)return;let{affected:l,snapshot:d}=i;for(let u of l){n(u);let p=d.get(u);p&&Sb(p,r)}}function Wu(e,t){return{move:(r,n)=>Ha({identifier:r,workspaceId:n,field:e,fire:t}),add:(r,n)=>Ha({identifier:r,workspaceId:n,field:e,fire:t,additive:!0}),remove:(r,n)=>Ha({identifier:r,field:e,fire:t,from:n})}}var Xa=Wu("reports",Cs),Qa=Wu("bundles",Es),Qn=Xa.move,Ft=Xa.add,Zn=Xa.remove,Za=Qa.move,kr=Qa.add,el=Qa.remove;function Ab(){let e=Jn().map(Xn),t=ft,r=new Map(t.map(o=>[o.id,o])),n=new Map(e.map(o=>[o.id,o]));for(let o of r.keys())n.has(o)||za(o);for(let[o,s]of n){let i=r.get(o);if(!i){Ss(o);continue}i.privateKey!==s.privateKey&&Wa(o),As(i.reports,s.reports)||Cs(o),As(i.bundles,s.bundles)||Es(o)}ft=e}Dr(()=>{Ab()});function Hu(e){return e==="inprogress"||e==="fixed"||e==="invalid"||e==="deleted"?e:void 0}function ge(e){if(e)return Hu(e.triage)??(e.deleted?"deleted":void 0)}function Tb(e){return e?!e.color&&!ge(e)&&!e.comment&&!e.fix&&!(e.ignoredReports&&e.ignoredReports.length>0)&&e.flagged===void 0:!0}function Bt(e,t,r){let n=e.get(t)?.ignoredReports;return Array.isArray(n)&&n.includes(r)}function eo(e){if(!e||typeof e!="object")return;let t=e,r={};typeof t.color=="string"&&t.color&&(r.color=t.color);let n=Hu(t.triage)??(t.deleted?"deleted":void 0);if(n&&(r.triage=n),typeof t.comment=="string"&&t.comment&&(r.comment=t.comment),typeof t.fix=="string"&&t.fix&&(r.fix=t.fix),typeof t.flagged=="boolean"&&(r.flagged=t.flagged),Array.isArray(t.ignoredReports)){let o=t.ignoredReports.filter(s=>typeof s=="string"&&s.length>0);o.length>0&&(r.ignoredReports=o)}return Tb(r)?void 0:r}function Ib(e,t){let r=e??[],n=t??[];if(r.length!==n.length)return!1;if(r.length===0)return!0;let o=new Set(r);for(let s of n)if(!o.has(s))return!1;return!0}function Rb(e,t){let r=e??{},n=t??{};return(r.color??"")===(n.color??"")&&(ge(r)??"")===(ge(n)??"")&&(r.comment??"")===(n.comment??"")&&(r.fix??"")===(n.fix??"")&&r.flagged===n.flagged&&Ib(r.ignoredReports,n.ignoredReports)}function L(e,t,r){let n=e.get(t),o=eo({...n,...r});return o===void 0?e.delete(t):Rb(n,o)?!1:(e.set(t,o),!0)}function ae(e,t,r,n){let o=new Set(e.get(t)?.ignoredReports??[]);return n?o.add(r):o.delete(r),L(e,t,{ignoredReports:o.size>0?[...o]:void 0})}var tl=()=>{};function Vu(e){tl=typeof e=="function"?e:()=>{}}var Ku=()=>{};function rl(e){Ku=typeof e=="function"?e:()=>{}}var Jt="deepview.triage",Mt="deepview.triage.pending",_t=/^\d+$/u;async function Fb(e){let t=new Blob([e]).stream().pipeThrough(new CompressionStream("deflate"));return new Uint8Array(await new Response(t).arrayBuffer())}async function Bb(e){let t=new Blob([e]).stream().pipeThrough(new DecompressionStream("deflate"));return new Uint8Array(await new Response(t).arrayBuffer())}var Mb="deepview.triage.save",ju=0;function nl(){let e={};for(let[t,r]of a.triage){if(_t.test(t))continue;let n=eo(r);n&&(e[t]=n)}return e}function oe(){let e=++ju,t=nl(),r=Object.keys(t).length===0,n=r?null:JSON.stringify(t);if(n!=null)try{localStorage.setItem(Mt,n)}catch{}return navigator.locks.request(nt,{mode:"shared"},async()=>{let o=null,s=null;if(n!=null)try{let i=Y(n),l=await Fb(i);s=Ce(),o=(s?await bu(l):l).toBase64()}catch(i){console.warn("Failed to save triage:",i),tl();return}await navigator.locks.request(Mb,()=>{try{if(e!==ju)return;if(n!=null&&Ce()!==s){queueMicrotask(()=>{oe()});return}if(r)localStorage.removeItem(Jt),localStorage.removeItem(Mt);else{localStorage.setItem(Jt,o);try{localStorage.removeItem(Mt)}catch{}}}catch(i){console.warn("Failed to save triage:",i)}}),tl()})}async function Gu(){let e=localStorage.getItem(Mt);if(e)try{return JSON.parse(e)}catch{}let t=localStorage.getItem(Jt);if(!t)return null;let r=Uint8Array.fromBase64(t);if(Ue(r)){if(!Ce())throw new Error("triage: vault locked, cannot decrypt envelope");r=await yu(r)}let n=await Bb(r);return JSON.parse(he(n))}function qu(e,{replace:t=!1}={}){let r=a.triage;if(t){let n=null,o=localStorage.getItem(Mt);if(o)try{n=JSON.parse(o)}catch{}let s=i=>n!=null&&i in n;for(let i of[...r.keys()]){if(_t.test(i))continue;let l=e?.[i],d=!e||!(i in e);!(s(i)&&n[i]?.color)&&(d||!l?.color)&&L(r,i,{color:void 0}),!(s(i)&&(n[i]?.triage||n[i]?.deleted))&&!ge(l)&&L(r,i,{triage:void 0}),!(s(i)&&n[i]?.comment)&&(d||typeof l?.comment!="string"||!l.comment)&&L(r,i,{comment:void 0}),!(s(i)&&n[i]?.fix)&&(d||typeof l?.fix!="string"||!l.fix)&&L(r,i,{fix:void 0}),!(s(i)&&n[i]?.flagged!==void 0)&&(d||l?.flagged===void 0)&&L(r,i,{flagged:void 0})}for(let i of[...r.keys()]){if(_t.test(i))continue;let l=r.get(i)?.ignoredReports;if(!l||l.length===0)continue;let d=e?.[i],u=!!ge(d);for(let p of[...l]){if(s(i)&&Array.isArray(n[i]?.ignoredReports)&&n[i].ignoredReports.includes(p))continue;if(u){ae(r,i,p,!1);continue}let f=d?.ignoredReports;(!Array.isArray(f)||!f.includes(p))&&ae(r,i,p,!1)}}}if(e)for(let[n,o]of Object.entries(e)){let s=ge(o),i={};if(o&&o.color&&(i.color=o.color),s&&(i.triage=s),o&&typeof o.comment=="string"&&o.comment&&(i.comment=o.comment),o&&typeof o.fix=="string"&&o.fix&&(i.fix=o.fix),o&&typeof o.flagged=="boolean"&&(i.flagged=o.flagged),Object.keys(i).length>0&&L(r,n,i),!s&&o&&Array.isArray(o.ignoredReports)){let l=new Set(r.get(n)?.ignoredReports??[]),d=!1;for(let u of o.ignoredReports)typeof u=="string"&&!l.has(u)&&(l.add(u),d=!0);d&&L(r,n,{ignoredReports:[...l]})}}}async function Lb(){try{let e=await Gu();qu(e)}catch(e){console.warn("Failed to load triage:",e)}}async function Yu(){try{let e=await Gu();qu(e,{replace:!0}),Ku()}catch(e){console.warn("Failed to reload triage:",e)}}typeof window<"u"&&window.addEventListener("storage",e=>{e.key!==Jt&&e.key!==Mt||Yu()});var to=Lb();ve(()=>{Yu()});ve(()=>{Ce()&&localStorage.getItem(Mt)&&oe()});async function ol({seal:e}){try{localStorage.removeItem(Mt)}catch{}let t=localStorage.getItem(Jt);if(!t)return;let r=Uint8Array.fromBase64(t);if(Ue(r))return;let n=await e(r,Bn());localStorage.setItem(Jt,n.toBase64())}async function sl({open:e}){try{localStorage.removeItem(Mt)}catch{}let t=localStorage.getItem(Jt);if(!t)return;let r=Uint8Array.fromBase64(t);if(!Ue(r))return;let n=await e(r,Bn());localStorage.setItem(Jt,n.toBase64())}var Ju="deepview.lastFile",ro=null;function il(){return ro||(ro=Pb(),ro.catch(()=>{ro=null})),ro}async function Pb(){try{await to}catch{}let e=await pe(),t=new Set(e),r=new Set(e),n=new Set;for(let o of e){if(!o.toLowerCase().endsWith(".deepseek"))continue;let s=o.slice(0,-9)+".md";if(t.has(s))continue;let i;try{i=await Oe(o),await ut(s,i),await jr(o)}catch(p){console.warn(`migrate: failed to rename ${o} -> ${s}`,p);continue}t.delete(o),t.add(s),n.add(o);let l=Kn(o);if(Zr(o),l===void 0){let{count:p,source:f}=ze(i);qe(s,p,f)}else{let{source:p}=ze(i);qe(s,l,p)}let d=Ke(o);d&&(Ge(o,""),Ge(s,d));let u=!1;for(let[p,f]of[...a.triage])f.ignoredReports?.includes(o)&&(ae(a.triage,p,o,!1),ae(a.triage,p,s,!0),u=!0);if(u&&await oe(),we(Ju)===o)try{await Se(Ju,s)}catch{}}for(let o of W())for(let s of o.reports){if(!s.toLowerCase().endsWith(".deepseek")||!n.has(s)&&r.has(s))continue;let i=s.slice(0,-9)+".md";await Zn(s,o.id),await Ft(i,o.id)}}var al=1;function Ob(){let e=nl(),t=ys();return{version:al,exportedAt:new Date().toISOString(),triage:e,repoUrls:t}}function Nb(){return`deepview-triage-${new Date().toISOString().replaceAll(/[:.]/gu,"-").slice(0,19)}.json.gz`}async function ll(){let e=Ob();return{blob:new Blob([await os(JSON.stringify(e))]),filename:Nb()}}async function cl(e){let t;try{t=await Cn(new Uint8Array(await e.arrayBuffer()))}catch(n){throw new Error(`Failed to gunzip: ${n.message}`,{cause:n})}let r;try{r=JSON.parse(t)}catch(n){throw new Error(`Failed to parse JSON: ${n.message}`,{cause:n})}if(!r||typeof r!="object")throw new Error("Invalid backup file (not an object)");if(r.version!==al)throw new Error(`Unsupported backup version: ${r.version} (expected ${al})`);if(!r.triage||typeof r.triage!="object")throw new Error("Backup is missing the `triage` map");if(!r.repoUrls||typeof r.repoUrls!="object")throw new Error("Backup is missing the `repoUrls` map");return r}async function dl(e,t){if(!["replace","prefer-imported","prefer-current"].includes(t))throw new Error(`Unknown merge mode: ${t}`);if(!e||typeof e!="object")throw new Error("Invalid payload: not an object");if(!e.triage||typeof e.triage!="object"||Array.isArray(e.triage))throw new Error("Invalid payload: missing or non-object `triage`");if(!e.repoUrls||typeof e.repoUrls!="object"||Array.isArray(e.repoUrls))throw new Error("Invalid payload: missing or non-object `repoUrls`");let r=e.triage,n=a.triage;if(t==="replace")for(let l of[...n.keys()])_t.test(l)||n.delete(l);let o=t==="prefer-current";for(let[l,d]of Object.entries(r)){if(_t.test(l)||!d||typeof d!="object")continue;typeof d.color=="string"&&d.color&&(!o||!n.get(l)?.color)&&L(n,l,{color:d.color});let u=ge(d);if(u&&(!o||!ge(n.get(l)))&&L(n,l,{triage:u}),typeof d.comment=="string"&&d.comment&&(!o||!n.get(l)?.comment)&&L(n,l,{comment:d.comment}),typeof d.fix=="string"&&d.fix&&(!o||!n.get(l)?.fix)&&L(n,l,{fix:d.fix}),typeof d.flagged=="boolean"&&(!o||n.get(l)?.flagged===void 0)&&L(n,l,{flagged:d.flagged}),Array.isArray(d.ignoredReports)&&!ge(n.get(l)))for(let p of d.ignoredReports)typeof p=="string"&&(o&&Bt(n,l,p)||ae(n,l,p,!0))}await oe();let s=0,i=null;try{await Tu(e.repoUrls,t),s=Object.keys(e.repoUrls).length}catch(l){console.warn("applyTriageImport: repo-URL import failed:",l),i=l}return{triageEntries:Object.keys(r).length,repoUrls:s,repoUrlError:i}}function Db(e){return e?.name==="NotFoundError"||typeof e?.message=="string"&&e.message.startsWith("File not found:")}async function ul(e){let t=new Set;for(let r of e){let n;try{n=await Oe(r)}catch(i){if(Db(i))continue;throw new Error(`Failed to read ${r}: ${i.message}`,{cause:i})}if(n==null)continue;let o=Gt(n);if(!Array.isArray(o?.findings))continue;let s=qt(o.findings);await Gr(s);for(let i of s)i.id&&t.add(i.id)}return t}function Ub(){let e=new Set;for(let t of a.triage.keys())_t.test(t)||e.add(t);return e}async function Ts(e){let t=Ub();if(t.size===0)return{orphanedCount:0,sharedCount:0};let r=await ul(e),n=new Set;for(let p of t)r.has(p)&&n.add(p);if(n.size===0)return{orphanedCount:0,sharedCount:0};let o=await pe(),s=new Set(e),i=o.filter(p=>!s.has(p)),l=await ul(i),d=0,u=0;for(let p of n)l.has(p)?u++:d++;return{orphanedCount:d,sharedCount:u}}async function Is(){let e=new Set(a.triage.keys()),t=[];for(let[i,l]of a.triage)if(l.ignoredReports)for(let d of l.ignoredReports)t.push({id:i,report:d});let r=await pe(),n=new Set(r),o=await ul(r),s=!1;for(let i of e){if(_t.test(i)||o.has(i))continue;let l=a.triage.get(i);!l||!(l.color||ge(l)||l.comment||l.fix||l.flagged!==void 0)||L(a.triage,i,{color:void 0,triage:void 0,comment:void 0,fix:void 0,flagged:void 0,deleted:void 0})&&(s=!0)}for(let{id:i,report:l}of t)_t.test(i)||o.has(i)&&n.has(l)||Bt(a.triage,i,l)&&ae(a.triage,i,l,!1)&&(s=!0);s&&await oe()}var pl=1,Qt=16,Xu=12,Qu=1+Qt+Xu+16,Xt=1+Qt+Xu;async function Zu(e,t){let r=await crypto.subtle.importKey("raw",Y(e),"PBKDF2",!1,["deriveKey"]);return crypto.subtle.deriveKey({name:"PBKDF2",hash:"SHA-256",salt:t,iterations:3e6},r,{name:"AES-GCM",length:256},!1,["encrypt","decrypt"])}function ep(e){return!(e instanceof Uint8Array)||e.length<Qu?!1:e[0]===pl}async function Rs(e,t){if(!(e instanceof Uint8Array))throw new TypeError("encryptWithPassword: plaintext Uint8Array required");if(typeof t!="string"||!t)throw new TypeError("encryptWithPassword: password required");let r=new Uint8Array(Xt+e.length+16);r[0]=pl,crypto.getRandomValues(r.subarray(1,1+Qt)),crypto.getRandomValues(r.subarray(1+Qt,Xt));let n=r.subarray(1,1+Qt),o=r.subarray(1+Qt,Xt),s=await Zu(t,n),i=new Uint8Array(await crypto.subtle.encrypt({name:"AES-GCM",iv:o,additionalData:r.subarray(0,Xt)},s,e));return r.set(i,Xt),r}async function Wb(e,t){if(typeof t!="string"||!t)throw new TypeError("tryDecryptWithPassword: password required");if(!(e instanceof Uint8Array)||e.length<Qu)return{ok:!1,reason:"malformed"};if(e[0]!==pl)return{ok:!1,reason:"malformed"};let r=e.subarray(1,1+Qt),n=e.subarray(1+Qt,Xt),o=e.subarray(Xt),s=await Zu(t,r),i;try{i=new Uint8Array(await crypto.subtle.decrypt({name:"AES-GCM",iv:n,additionalData:e.subarray(0,Xt)},s,o))}catch{return{ok:!1,reason:"wrong-password"}}return{ok:!0,plaintext:i}}async function Fs(e,t,r){if(!r||typeof r.malformedMsg!="string"||typeof r.wrongPasswordMsg!="string")throw new TypeError("decryptWithPasswordOrThrow: { malformedMsg, wrongPasswordMsg } strings required");let n=await Wb(e,t);if(n.ok)return n.plaintext;throw n.reason==="wrong-password"?new Error(r.wrongPasswordMsg):new Error(r.malformedMsg)}var no=ep,tp=Rs;function rp(e,t){return Fs(e,t,{malformedMsg:"malformed encrypted bundle",wrongPasswordMsg:"wrong password or corrupt bundle"})}var Hb=1;async function jb(e){let t=new Set,r=Gt(e);if(!Array.isArray(r?.findings))return t;let n=qt(r.findings);await Gr(n);for(let o of n)o.id&&t.add(o.id);return t}function np(e){return(e??"").replaceAll(/[^a-zA-Z0-9._-]+/gu,"_").replaceAll(/^_+|_+$/gu,"")||"workspace"}async function Vb(e){if(!Array.isArray(e)||e.length===0)return[];let t=await pt(),r=new Map(t.map(o=>[o.integrity,o.name])),n=[];for(let o of e){let s=r.get(o);if(!s)continue;let i;try{i=await yr(o)}catch(l){console.warn(`Workspace export: failed to read bundle ${o}: ${l?.message??l}`);continue}n.push({integrity:o,name:s,data:i.toBase64()})}return n}async function Kb(e,{includeBundleBytes:t=!1}={}){let r=[],n=new Set;for(let u of e.reports??[]){let p;try{p=await Oe(u)}catch(f){console.warn(`Workspace export: skipping ${u}: ${f?.message??f}`),(f instanceof DOMException&&f.name==="NotFoundError"||typeof f?.message=="string"&&f.message.startsWith("File not found:"))&&await Qn(u,null);continue}r.push({name:u,content:p});for(let f of await jb(p))n.add(f)}let o=new Set(e.reports??[]),s={};for(let[u,p]of a.triage){if(!n.has(u))continue;let f=(p.ignoredReports??[]).filter(b=>o.has(b)),h=eo({...p,ignoredReports:f});h&&(s[u]=h)}let i={};for(let u of r){let p=Ke(u.name);p&&(i[u.name]=p)}let l=(e.bundles??[]).filter(u=>typeof u=="string"&&u.length>0),d={version:Hb,exportedAt:new Date().toISOString(),workspace:{id:e.id,name:e.name,privateKey:e.privateKey,createdAt:e.createdAt},reports:r,bundles:l,repoUrls:i,triage:s};if(t){let u=await Vb(l);u.length>0&&(d.bundleBlobs=u)}return d}async function op(e,{includeBundleBytes:t=!1}={}){let r=await Kb(e,{includeBundleBytes:t});return{blob:new Blob([await os(JSON.stringify(r))]),filename:`${np(e.name)}.deepview-workspace.json.gz`}}async function Gb(e,t,{includeBundleBytes:r=!1}={}){if(typeof t!="string"||!t)throw new TypeError("buildWorkspaceExportEncrypted: password required");let{blob:n}=await op(e,{includeBundleBytes:r}),o=new Uint8Array(await n.arrayBuffer()),s=await tp(o,t);return{blob:new Blob([s],{type:"application/octet-stream"}),filename:`${np(e.name)}.deepview-workspace.enc`}}async function fl(e,{password:t,includeBundleBytes:r=!1}={}){return typeof t=="string"&&t?await Gb(e,t,{includeBundleBytes:r}):await op(e,{includeBundleBytes:r})}var qb=1,sp=1024,ip=1024,Bs=200,dp=100*1024*1024,Yb=Math.ceil(dp*4/3)+16,ap=512,lp=64;function Jb(e){if(!e||typeof e!="object")return"payload is not an object";if(e.version!==qb)return`unsupported export version: ${e.version}`;if(!e.workspace||typeof e.workspace!="object")return"workspace metadata missing";if(typeof e.workspace.id!="string")return"workspace.id must be a string";if(typeof e.workspace.name!="string")return"workspace.name must be a string";if(typeof e.workspace.privateKey!="string")return"workspace.privateKey must be a string";if(e.workspace.createdAt!==void 0&&!Number.isFinite(e.workspace.createdAt))return"workspace.createdAt must be a finite number or omitted";if(!Array.isArray(e.reports))return"reports field must be an array";if(e.reports.length>ip)return`reports count (${e.reports.length}) exceeds cap (${ip})`;if(e.bundles!==void 0){if(!Array.isArray(e.bundles))return"bundles field must be an array when present";if(e.bundles.length>sp)return`bundles count (${e.bundles.length}) exceeds cap (${sp})`;for(let t of e.bundles){if(typeof t!="string")return"bundles entries must be strings";if(t.length>Bs)return`bundle integrity exceeds per-entry length cap (${Bs})`}}if(e.bundleBlobs!==void 0){if(!Array.isArray(e.bundleBlobs))return"bundleBlobs field must be an array when present";if(e.bundleBlobs.length>lp)return`bundleBlobs count (${e.bundleBlobs.length}) exceeds cap (${lp})`;for(let t of e.bundleBlobs){if(!t||typeof t!="object"||Array.isArray(t))return"bundleBlobs entries must be objects";if(typeof t.integrity!="string"||t.integrity.length===0)return"bundleBlobs.integrity must be a non-empty string";if(t.integrity.length>Bs)return`bundleBlobs.integrity exceeds per-entry length cap (${Bs})`;if(typeof t.name!="string"||t.name.length===0)return"bundleBlobs.name must be a non-empty string";if(t.name.length>ap)return`bundleBlobs.name exceeds per-entry length cap (${ap})`;if(t.name.includes("\0"))return"bundleBlobs.name cannot contain NUL";if(typeof t.data!="string")return"bundleBlobs.data must be a base64 string";if(t.data.length>Yb)return`bundleBlobs.data exceeds per-blob size cap (${dp} bytes raw)`}}return null}async function hl(e){return new Uint8Array(await e.arrayBuffer())}async function Ms(e,t){if(no(e)){if(typeof t!="string"||!t)throw new TypeError("parseWorkspaceBundleBytes: password required for encrypted bundle");let n=await rp(e,t);try{return cp(await Cn(n))}catch(o){throw new Error("wrong password or corrupt bundle",{cause:o})}}let r;try{r=await Cn(e)}catch(n){throw new Error(`gzip decompression failed: ${n.message}`,{cause:n})}return cp(r)}function cp(e){let t;try{t=JSON.parse(e)}catch(o){throw new Error(`payload is not JSON: ${o.message}`,{cause:o})}let r=Jb(t);if(r===null)return t;let n=r.includes("exceeds cap");throw new Error(n?r:`not a deepview workspace export: ${r}`)}function Xb(e){return ge(e)??null}async function Qb(e){let t=new Map;for(let r of e??[]){if(typeof r?.content!="string")continue;let n=Gt(r.content);if(!n?.findings)continue;let o=qt(n.findings);await Gr(o);for(let s of o)!s.id||t.has(s.id)||t.set(s.id,{severity:s.severity,file:s.file,line:s.line,description:La(s.description)})}return t}async function Zb(e,t,r){if(!e||typeof e!="object"||Array.isArray(e))return;let n=a.triage,o=[];for(let[s,i]of Object.entries(e)){if(!i||typeof i!="object")continue;let l=n.get(s)?.color,d=typeof i.color=="string"?i.color:void 0;d&&l&&l!==d?o.push({id:s,property:"color",local:l,imported:d}):d&&d!==l&&L(n,s,{color:d});let u=n.get(s)?.comment??"",p=typeof i.comment=="string"?i.comment:"";p&&u&&u!==p?o.push({id:s,property:"comment",local:u,imported:p}):p&&p!==u&&L(n,s,{comment:p});let f=n.get(s)?.fix??"",h=typeof i.fix=="string"?i.fix:"";h&&f&&f!==h?o.push({id:s,property:"fix",local:f,imported:h}):h&&h!==f&&L(n,s,{fix:h});let b=Xb(i),m=ge(n.get(s))??null;b&&m&&m!==b?o.push({id:s,property:"triage",local:m,imported:b}):b&&!m&&L(n,s,{triage:b,ignoredReports:void 0});let y=n.get(s)?.flagged,k=typeof i.flagged=="boolean"?i.flagged:void 0;k!==void 0&&y!==void 0&&y!==k?o.push({id:s,property:"flagged",local:y?"flagged":"not flagged",imported:k?"flagged":"not flagged"}):k!==void 0&&k!==y&&L(n,s,{flagged:k});let w=Array.isArray(i.ignoredReports)?i.ignoredReports:[];if(!ge(n.get(s)))for(let v of w)typeof v=="string"&&ae(n,s,v,!0)}if(o.length>0&&t){let s=await t(o,r??new Map);s&&ey(o,s)}await oe()}function ey(e,t){for(let r of e){let n=`${r.id}:${r.property}`;t[n]==="imported"&&ty(r.id,r.property)===r.local&&(r.property==="color"?L(a.triage,r.id,{color:r.imported}):r.property==="comment"?L(a.triage,r.id,{comment:r.imported}):r.property==="fix"?L(a.triage,r.id,{fix:r.imported}):r.property==="triage"?L(a.triage,r.id,{triage:r.imported,ignoredReports:void 0}):r.property==="flagged"&&L(a.triage,r.id,{flagged:r.imported==="flagged"?!0:r.imported==="not flagged"?!1:void 0}))}}function ty(e,t){if(t==="color")return a.triage.get(e)?.color;if(t==="triage")return ge(a.triage.get(e))??null;if(t==="comment")return a.triage.get(e)?.comment??"";if(t==="fix")return a.triage.get(e)?.fix??"";if(t==="flagged"){let r=a.triage.get(e)?.flagged;return r===!0?"flagged":r===!1?"not flagged":""}}async function ry(e){if(Array.isArray(e))for(let t of e){let r;try{r=Uint8Array.fromBase64(t.data)}catch(n){console.warn(`Workspace import: failed to decode bundle ${t.integrity}: ${n?.message??n}`);continue}try{let n=await br(t.name,r);n?.integrity!==t.integrity&&console.warn(`Workspace import: bundle ${t.name} integrity mismatch (claimed ${t.integrity}, computed ${n?.integrity})`)}catch(n){console.warn(`Workspace import: failed to save bundle ${t.name}: ${n?.message??n}`)}}}async function gl(e,{conflictResolver:t}={}){let r=[];for(let u of e.reports)if(!(typeof u?.name!="string"||typeof u?.content!="string"))try{await ut(u.name,u.content);let{count:p,source:f}=ze(u.content);qe(u.name,p,f??Gn(u.name)),r.push(u.name)}catch(p){console.warn(`Workspace import: failed to save ${u.name}: ${p.message}`)}Array.isArray(e.bundleBlobs)&&e.bundleBlobs.length>0&&await ry(e.bundleBlobs);let o=e.triage&&Object.keys(e.triage).length>0?await Qb(e.reports):new Map;await Zb(e.triage,t,o);let s=Array.isArray(e.bundles),i=s?e.bundles.filter(u=>typeof u=="string"&&u.length>0):[],l=await zu({id:e.workspace.id,name:e.workspace.name,privateKey:e.workspace.privateKey,reports:r,bundles:s?i:void 0,preserveBundles:!s,createdAt:e.workspace.createdAt}),d=new Set(r);if(e.repoUrls&&typeof e.repoUrls=="object")for(let[u,p]of Object.entries(e.repoUrls))!d.has(u)||typeof p!="string"||!p||Ke(u)||(Ge(u,p),a.currentFile===u&&(a.repoUrl=p));return l}async function ml({id:e,name:t,privateKeyBase64:r,password:n}){if(typeof e!="string"||!e)throw new TypeError("encodeShareLink: id required");if(typeof t!="string"||!t)throw new TypeError("encodeShareLink: name required");if(typeof r!="string"||!r)throw new TypeError("encodeShareLink: privateKey required");if(typeof n!="string"||!n)throw new TypeError("encodeShareLink: password required");let s=await qn(r)===e?{v:1,n:t,k:r}:{v:1,i:e,n:t,k:r};return(await Rs(Y(JSON.stringify(s)),n)).toBase64({alphabet:"base64url",omitPadding:!0})}async function bl({encoded:e,password:t}){if(typeof e!="string"||!e)throw new Error("malformed share link");if(typeof t!="string"||!t)throw new TypeError("decodeShareLink: password required");let r;try{r=Uint8Array.fromBase64(e,{alphabet:"base64url"})}catch{throw new Error("malformed share link")}let n=await Fs(r,t,{malformedMsg:"malformed share link",wrongPasswordMsg:"wrong password or corrupt link"});try{return await ny(n)}catch(o){throw new Error("wrong password or corrupt link",{cause:o})}}async function ny(e){let t=JSON.parse(he(e));if(!t||typeof t!="object"||typeof t.n!="string"||typeof t.k!="string"||!t.n||!t.k)throw new Error("shape");if(t.i!==void 0&&(typeof t.i!="string"||!t.i))throw new Error("shape");if(typeof t.i=="string"&&t.i.length>256)throw new Error("shape");if(t.n.length>1024)throw new Error("shape");if(Uint8Array.fromBase64(t.k).length!==32)throw new Error("shape");return{id:typeof t.i=="string"?t.i:await qn(t.k),name:t.n,privateKeyBase64:t.k}}function yl(e){return typeof location>"u"?`#share=${e}`:`${location.origin}${location.pathname}#share=${e}`}function wl(e){let t=typeof e=="string"?e:typeof location>"u"?"":location.hash;if(!t)return null;let r=t.replace(/^#/u,"");if(!r)return null;for(let n of r.split("&")){let o=n.indexOf("=");if(o<0||n.slice(0,o)!=="share")continue;return n.slice(o+1)||null}return null}var oy={get state(){return a},listWorkspaces:W,addReportToWorkspace:Ft,addBundleToWorkspace:kr,onReportMembershipChanged:Da,onBundleMembershipChanged:Ua,onWorkspaceDeleted:Oa,onWorkspacePrivateKeyChanged:Na,analyzeContent:ze,setCount:qe,gunzipBytes:yt,listBundles:pt,listFiles:pe,readBundle:yr,readFileBytes:mr,saveBundle:br,saveFileBytes:Nn,saveTriage:oe,getSecureItem:we,setSecureItem:Se,removeSecureItem:Ur,onSecureStorageHydrated:Dr};function up(e){e.installSyncHost(oy),Vu(()=>e.triageSync.notify())}var U=null,oo=null;function gp(){try{return we("deepview.sync.userEnabled")!=="0"}catch{return!0}}function vl(){return oo||(oo=(async()=>{let e="./client-sync.js";try{let t=await import(e);return up(t),U=t,sy(),t}catch(t){throw oo=null,t}})(),oo)}function mp(){return vl()}var bp=[];function io(e){U?e(U):bp.push(e)}function sy(){let e=bp.splice(0);for(let t of e)try{t(U)}catch(r){console.warn("client-sync: deferred apply failed:",r)}}function so(e,t){let r={cancelled:!1,unsub:null};return io(n=>{r.cancelled||(r.unsub=t(n,e))}),()=>{r.cancelled=!0,r.unsub&&r.unsub()}}function kl(e,t){return U?U.isInRemote(e,t):!1}function yp(e,t){return U?U.isBundleInRemote(e,t):!1}var iy="deepview.objstore-presence.";function wp(e){try{let t=localStorage.getItem(iy+e);if(!t)return null;let r=JSON.parse(t);return r&&typeof r=="object"?r:null}catch{return null}}function ao(e,t){if(U&&U.isInRemote(e,t))return!0;let r=wp(e);if(!r||typeof r.names!="object")return!1;for(let n of Object.values(r.names))if(n===t)return!0;return!1}function $l(e,t){if(U&&U.isBundleInRemote(e,t))return!0;let r=wp(e);if(!r||typeof r.bundles!="object")return!1;for(let n of Object.values(r.bundles))if(n===t)return!0;return!1}function vp(e){return U?U.remoteCount(e):0}function kp(e){return so(e,(t,r)=>t.onAutoDownloaded(r))}function $p(e){return so(e,(t,r)=>t.onBundleAutoDownloaded(r))}function xp(e){return so(e,(t,r)=>t.onChange(r))}var pp=null,fp=null,hp=null,Ls=[];function _p(e){if(U){U.setRedraw(e);return}pp=e,io(t=>{pp===e&&t.setRedraw(e)})}function Sp(e){if(U){U.setAuthenticationResolver(e);return}fp=e,io(t=>{fp===e&&t.setAuthenticationResolver(e)})}function Cp(e){if(U){U.setHydrationConflictResolver(e);return}hp=e,io(t=>{hp===e&&t.setHydrationConflictResolver(e)})}async function Lt(e,t){if(!(!gp()&&!U))return(await vl())[e](...t)}function Ep(...e){return Lt("fetchFile",e)}function Ap(...e){return Lt("fetchBundleFromRemote",e)}function Ps(...e){return Lt("putFile",e)}function Tp(...e){return Lt("putBundleToRemote",e)}function Os(...e){return Lt("deleteFromRemote",e)}function Ns(...e){return Lt("deleteBundleFromRemote",e)}function Ds(...e){return Lt("openWorkspace",e)}function lo(...e){return Lt("closeWorkspace",e)}function Ip(...e){return Lt("recheckRemoteStorage",e)}function Zt(e,t){if(U)return U.triageSync[e](...t);io(r=>{r.triageSync[e](...t)})}var N={get status(){return U?U.triageSync.status:"off"},get openSessions(){return U?U.triageSync.openSessions:[]},get persistenceDegraded(){return U?U.triageSync.persistenceDegraded:!1},setEnabled(e){if(e===!0)return vl().then(t=>{t.triageSync.setEnabled(!0);let r=Ls;Ls=[];for(let n of r)try{t.openWorkspace(n)}catch(o){console.warn(`client-sync: openWorkspace(${n}) failed during re-enable:`,o)}return null}).catch(t=>(console.warn("client-sync: setEnabled load failed:",t),null));if(U){Ls=U.openWorkspaceIds();for(let t of Ls)try{U.closeWorkspace(t)}catch(r){console.warn(`client-sync: closeWorkspace(${t}) failed during disable:`,r)}U.triageSync.setEnabled(!1);return}Zt("setEnabled",[e])},isEnabled(){return U?U.triageSync.isEnabled():gp()},openSession(e){Zt("openSession",[e])},closeSession(e){Zt("closeSession",[e])},refreshSession(e){Zt("refreshSession",[e])},dismissError(e){Zt("dismissError",[e])},setForcedOff(e){Zt("setForcedOff",[e])},setServerUrl(e){Zt("setServerUrl",[e])},getServerUrl(){return U?U.triageSync.getServerUrl():null},notify(){Zt("notify",[])},onStatusChange(e){return so(e,(t,r)=>t.triageSync.onStatusChange(r))},onPersistenceDegraded(e){return so(e,(t,r)=>t.triageSync.onPersistenceDegraded(r))}};var co=class extends tt{constructor(t){if(super(t),this.it=g,t.type!==Le.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===g||t==null)return this._t=void 0,this.it=t;if(t===de)return t;if(typeof t!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(t===this.it)return this._t;this.it=t;let r=[t];return r.raw=r,this._t={_$litType$:this.constructor.resultType,strings:r,values:[]}}};co.directiveName="unsafeHTML",co.resultType=1;var me=mt(co);var Rp=`*,*:before,*:after{box-sizing:border-box;margin:0;padding:0}:host{width:260px;flex-shrink:0;height:100%;background:var(--surface);backdrop-filter:var(--glass-blur);border-right:1px solid var(--border);display:flex;flex-direction:column;transition:width .15s ease-out;overflow:hidden}:host(.collapsed){width:32px}:host(.empty){display:none}:host(.collapsed) .brand,:host(.collapsed) .sidebar-search,:host(.collapsed) #encryption-toggle,:host(.collapsed) #file-list{display:none}:host(.collapsed) .sidebar-header{padding:.5rem 0;justify-content:center}:host(.collapsed) .sidebar-actions{padding:.35rem 0;justify-content:center}:host(.collapsed) sidebar-delete-current,:host(.collapsed) #sync-status .sync-label{display:none}:host(.collapsed) #sync-status{padding:.25rem;border:0}.sidebar-header{display:flex;align-items:center;gap:.5rem;padding:.5rem .75rem .4rem;.brand{flex:1;min-width:0;display:flex;align-items:baseline;gap:.4rem;font-size:.95rem;font-weight:700;letter-spacing:-.01em;white-space:nowrap;overflow:hidden;user-select:none}.brand-button{background:transparent;border:0;padding:0;margin:0;font:inherit;color:inherit;border-radius:4px;&:focus-visible{outline:2px solid var(--accent);outline-offset:2px}}.brand-tag{font-size:.65rem;font-weight:500;color:var(--muted);text-transform:lowercase;letter-spacing:.02em}}@media(display-mode:window-controls-overlay){.sidebar-header{min-height:env(titlebar-area-height,0px);padding-left:max(.75rem,env(titlebar-area-x,0px));-webkit-app-region:drag;app-region:drag;.brand-button,#encryption-toggle{-webkit-app-region:no-drag;app-region:no-drag}#sidebar-toggle{display:none}}}#sidebar-toggle{flex-shrink:0;width:22px;height:22px;display:grid;place-items:center;background:transparent;color:var(--muted);border:0;border-radius:4px;padding:0;&:hover{color:var(--text);background:rgb(from var(--text) r g b / .06)}}#encryption-toggle{flex-shrink:0;width:22px;height:22px;display:grid;place-items:center;background:transparent;color:var(--muted);border:0;border-radius:4px;padding:0;&:hover{color:var(--text);background:rgb(from var(--text) r g b / .06)}&.encrypted{color:var(--accent)}&.locked-pending{color:light-dark(#b25b00,#f0a060);outline:1px dashed currentcolor;outline-offset:-2px}}.sidebar-search{display:flex;align-items:center;margin:0 .55rem .25rem;padding:0 .25rem 0 .55rem;background:rgb(from var(--text) r g b / .04);border:1px solid var(--border);border-radius:5px;transition:background .12s,border-color .12s;-webkit-app-region:no-drag;app-region:no-drag;&:has(input:focus){border-color:var(--accent);background:rgb(from var(--text) r g b / .06)}.sidebar-search-icon{flex-shrink:0;color:var(--muted);pointer-events:none;margin-right:.4rem}& input{flex:1;min-width:0;padding:.3rem 0;background:transparent;color:var(--text);border:0;outline:none;font:inherit;font-size:.78rem;&::placeholder{color:var(--muted)}&:focus::placeholder{color:transparent}&::-webkit-search-cancel-button{display:none}}}sidebar-view-button{display:contents}.sidebar-view-btn{position:relative;flex-shrink:0;width:20px;height:20px;display:grid;place-items:center;background:transparent;color:var(--muted);border:0;border-radius:3px;padding:0;margin-left:2px;transition:background .12s,color .12s;sidebar-view-button+sidebar-view-button>&{margin-left:.4rem}sidebar-view-button:last-of-type>&{margin-right:.1rem}& svg{width:14px;height:14px}&:hover{color:var(--text);background:rgb(from var(--text) r g b / .08)}&.active{color:var(--accent);background:rgb(from var(--text) r g b / .1)}.view-btn-count{position:absolute;top:-4px;right:-4px;background:var(--bg);color:var(--muted);font-size:8.5px;font-weight:600;border-radius:999px;padding:0 3px;min-width:11px;text-align:center;line-height:11px;font-variant-numeric:tabular-nums;pointer-events:none}&.active .view-btn-count{color:var(--accent)}}#file-list{list-style:none;flex:1;overflow-y:auto;overscroll-behavior:none;scrollbar-gutter:stable;-webkit-app-region:no-drag;app-region:no-drag;padding:0 .35rem .25rem 0;margin:0;scrollbar-width:thin;scrollbar-color:var(--border) transparent;&::-webkit-scrollbar{width:5px}&::-webkit-scrollbar-thumb{background:var(--border);border-radius:3px}}.file-group-header{display:flex;align-items:center;justify-content:space-between;padding:.45rem .35rem .2rem .55rem;font-size:.62rem;font-weight:700;text-transform:uppercase;letter-spacing:.12em;color:var(--muted);user-select:none;&:first-child{padding-top:.25rem}.group-count{font-weight:500;letter-spacing:.04em;color:var(--muted);font-size:.7rem}}.file-group-header.workspace-header .workspace-header-actions{display:flex;align-items:center;gap:.35rem}.workspace-add{width:18px;height:18px;display:grid;place-items:center;background:transparent;color:var(--muted);border:1px solid transparent;border-radius:4px;padding:0;&:hover{color:var(--text);border-color:var(--accent)}}.file-item.workspace-item{display:flex;align-items:stretch;gap:.15rem}.file-item.workspace-item button.file-name{flex:1;min-width:0}.file-item.workspace-item .workspace-count{align-self:center;margin-right:.35rem}.workspace-share,.workspace-export,.workspace-leave{flex-shrink:0;width:22px;align-self:center;height:22px;display:none;place-items:center;background:transparent;color:var(--muted);border:1px solid transparent;border-radius:4px;padding:0;&:hover:not(:disabled){color:var(--text);background:rgb(from var(--text) r g b / .06);border-color:var(--accent)}}.workspace-leave:hover:not(:disabled){color:var(--critical, #f87171);border-color:var(--critical, #f87171)}@media(hover:hover){.file-item.workspace-item:hover .workspace-share,.file-item.workspace-item:hover .workspace-export,.file-item.workspace-item:hover .workspace-leave{display:grid}}.workspace-rename-input{width:100%;box-sizing:border-box;background:var(--surface);color:var(--text);border:1px solid var(--accent);border-radius:3px;padding:0 .25rem;margin:-1px 0;font:inherit;font-size:.76rem;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;outline:none}.file-item{list-style:none;position:relative;&.hidden{display:none}}.file-item.current:after{content:"";position:absolute;left:0;top:50%;transform:translateY(-50%);width:3px;height:18px;background:var(--accent);border-radius:0 2px 2px 0;pointer-events:none}.file-item button.file-name{display:flex;align-items:center;gap:.5rem;width:100%;box-sizing:border-box;padding:.2rem .3rem .2rem .55rem;background:transparent;color:var(--text);border:1px solid transparent;border-radius:0 5px 5px 0;font-family:inherit;font-size:.78rem;text-align:left;&:hover{background:rgb(from var(--text) r g b / .04)}.file-icon{flex-shrink:0;color:var(--muted)}.file-label{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:.76rem;line-height:14.5px}}.file-item .file-count{flex-shrink:0;display:inline-flex;align-items:center;justify-content:center;color:var(--muted);opacity:.65;font-size:.68rem;font-weight:500;font-variant-numeric:tabular-nums}.workspace-count-missing{margin-left:2px;opacity:.55;font-style:italic}.file-item.current button.file-name{background:rgb(from var(--text) r g b / .05);border-color:var(--border);.file-icon,.file-count{color:var(--text)}}.file-item.indented button.file-name{padding-left:1.3rem}.file-item.indented:before{content:"";position:absolute;left:.85rem;top:0;bottom:0;width:1px;background:var(--border)}.file-item.bundle-missing>.file-name,.file-item.report-missing>.file-name{display:flex;align-items:center;gap:.5rem;padding:.2rem .3rem .2rem 1.4rem;color:var(--muted);font-size:.78rem;font-style:italic;cursor:help;.file-icon{flex-shrink:0;color:var(--muted);font-style:normal}.file-label{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:.76rem;line-height:14.5px}}:host-context(body.theme-pink) .workspace-rename-input,:host-context(body.theme-pink) .file-item button.file-name .file-label,:host-context(body.theme-pink) .file-item.bundle-missing .file-label,:host-context(body.theme-pink) .file-item.report-missing .file-label{font-family:inherit}.file-item.dragging button.file-name{opacity:.4}.file-item.workspace-item.drag-over button.file-name,.file-item.indented.drag-over button.file-name{background:rgb(from var(--accent) r g b / .12);border-color:var(--accent)}.file-group-header.drag-over{background:rgb(from var(--accent) r g b / .12);border-radius:4px}.sidebar-actions{padding:.35rem .55rem .45rem;border-top:1px solid var(--border);display:flex;gap:.35rem;align-items:center;justify-content:space-between;& button{background:transparent;border:1px solid var(--border);color:var(--muted);border-radius:4px;padding:.2rem .5rem;font-size:.72rem;font-family:inherit;-webkit-app-region:no-drag;app-region:no-drag;&:hover{color:var(--text);border-color:var(--accent)}&.danger:hover{color:var(--critical);border-color:var(--critical)}&[disabled]{opacity:.4;border-color:var(--border)!important;color:var(--muted)!important}}}sidebar-delete-current{display:contents}sidebar-delete-current button{display:inline-flex;align-items:center;gap:.35rem;.trash-icon{flex-shrink:0}}#sync-status{display:inline-flex;align-items:center;gap:.35rem;border-color:transparent;&:hover{border-color:var(--accent)}.sync-dot{width:8px;height:8px;border-radius:50%;background:var(--muted);flex-shrink:0;box-shadow:0 0 0 1px rgb(from var(--text) r g b / .15)}&[data-status=online] .sync-dot{background:var(--green)}&[data-status=connecting] .sync-dot{background:var(--medium)}&[data-status=offline] .sync-dot{background:var(--critical)}}#sync-status[data-degraded] .sync-dot{box-shadow:0 0 0 2px var(--medium)}#sync-status[hidden]{display:none}
17
- `;var Fp=`.file-icon.brand-deepview{.bg{fill:#2563eb}.fg{fill:#fff}}.file-icon.brand-claude{.bg{fill:#d97757}.fg{fill:#fff}}.file-icon.brand-codex{.bg{fill:#fff;stroke:#000;stroke-width:.5}.fg{fill:#000}}.file-icon.brand-vercel{.bg{fill:#000;stroke:#fff;stroke-width:.5}.fg{fill:#fff}}
18
- `;var Bp=`*,*:before,*:after{box-sizing:border-box;margin:0;padding:0}dialog{margin-top:5rem;margin-inline:auto;border:1px solid var(--border);border-radius:10px;background:var(--surface);color:var(--text);padding:1.1rem 1.25rem 1rem;max-width:480px;width:min(94vw,480px);box-shadow:0 20px 60px #00000059;&::backdrop{background:rgb(from var(--theme-bar) r g b / .55);backdrop-filter:blur(2px)}}header h3{margin:0 0 .6rem;font-size:1rem;font-weight:600}.nwd-input{display:block;width:100%;box-sizing:border-box;padding:.5rem .65rem;border:1px solid var(--border);border-radius:6px;background:var(--bg, var(--surface));color:var(--text);font:inherit;font-size:.88rem;&:focus{outline:none;border-color:var(--accent);box-shadow:0 0 0 3px rgb(from var(--accent) r g b / .18)}&::placeholder{color:var(--muted)}}.nwd-note{margin:.55rem 0 0;color:var(--muted);font-size:.74rem;line-height:1.45}.nwd-intro{margin:0 0 .8rem;color:var(--muted);font-size:.82rem;line-height:1.5}.nwd-actions{display:flex;align-items:center;gap:.4rem;margin-top:.8rem;padding-top:.7rem;border-top:1px solid var(--border)}.nwd-spacer{flex:1}.nwd-actions button{background:transparent;border:1px solid var(--border);color:var(--text);border-radius:5px;padding:.35rem .9rem;font:inherit;font-size:.8rem;&:hover:not(:disabled){border-color:var(--accent);color:var(--accent)}&.primary{background:var(--accent);color:var(--surface);border-color:var(--accent);&:hover:not(:disabled){color:var(--surface);filter:brightness(1.08)}}&.danger{color:var(--critical, #f87171);border-color:var(--border);&:hover:not(:disabled){border-color:var(--critical, #f87171);color:var(--critical, #f87171)}}&:disabled{opacity:.5}}@media(display-mode:window-controls-overlay){dialog{-webkit-app-region:no-drag;app-region:no-drag}}
19
- `;var I=class extends H{static styles=[T(Bp)];firstUpdated(){this.beforeOpen();let t=this.renderRoot.querySelector("dialog");if(t){try{t.showModal()}catch(r){this._settled=!0,this.dispatchEvent(new CustomEvent("modal-conflict",{detail:{cause:r}}));return}this.focusInitial()}}beforeOpen(){}focusInitial(){(this.renderRoot.querySelector("input, textarea")??this.renderRoot.querySelector("button.primary")??this.renderRoot.querySelector("button"))?.focus()}_finish(t){this._settled||(this._settled=!0,this.renderRoot.querySelector("dialog")?.close(),this.dispatchEvent(new CustomEvent("resolve",{detail:t})))}_onClose=()=>this._finish(null)};function q(e,t={}){return new Promise(r=>{let n=document.createElement(e);Object.assign(n,t),n.addEventListener("resolve",o=>{n.remove(),r(o.detail)}),document.body.append(n)})}var ot=`dialog{max-width:520px;width:min(94vw,520px)}.wsl-field{display:block;margin-top:.6rem;color:var(--text);font-size:.78rem;>span{display:block;margin-bottom:.25rem;color:var(--muted);font-size:.72rem;text-transform:uppercase;letter-spacing:.04em}}.wsl-ack{display:flex;align-items:flex-start;gap:.5rem;margin-top:.6rem;color:var(--text);font-size:.8rem;line-height:1.4;>input[type=checkbox]{flex:0 0 auto;margin-top:.15rem}>span{flex:1 1 auto}}.wsl-link{display:block;width:100%;box-sizing:border-box;padding:.5rem .65rem;border:1px solid var(--border);border-radius:6px;background:var(--bg, var(--surface));color:var(--text);font:inherit;font-size:.78rem;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;resize:vertical;word-break:break-all}.wsl-error{margin:.55rem 0 0;color:var(--critical, #f87171);font-size:.74rem;line-height:1.4}.wsl-warning{padding:.55rem .65rem;border:1px solid var(--critical, #f87171);border-radius:6px;background:rgb(from var(--critical, #f87171) r g b / .08)}.wsl-optout{display:flex;align-items:center;gap:.5rem;margin-top:.7rem;color:var(--text);font-size:.78rem}.nwd-input:disabled{opacity:.5}
20
- `;var xl=class extends I{static styles=[...I.styles,T(ot)];static properties={_userName:{state:!0},_busy:{state:!0},_error:{state:!0},_phase:{state:!0},_success:{state:!0},_orphan:{state:!0},_orphanAck:{state:!0},_canCancel:{state:!0}};constructor(){super(),this._userName="",this._busy=!1,this._error="",this._phase="",this._success=!1,this._orphan=!1,this._orphanAck=!1,this._canCancel=!0,this._abortController=null}updated(t){if(t.has("_success")&&this._success){let r=this.renderRoot.querySelector("footer button.primary");r&&r.focus()}}beforeOpen(){typeof location<"u"&&(this._userName=location.hostname||"DeepView"),this._orphan=Fn(),this._vaultStateUnsub=ve(()=>{if(this._settled)return;let t=Fn();this._orphan&&!t&&Q()?(this._error="Encryption was just enabled in another tab. Close this dialog and reload to unlock.",this._busy=!1,this._canCancel=!0):this._orphan!==t&&(this._orphan=t)})}async focusInitial(){await this.updateComplete;let t=this._orphan?'input[data-role="orphan-ack"]':'input[data-role="name"]';this.renderRoot.querySelector(t)?.focus()}disconnectedCallback(){if(super.disconnectedCallback(),this._vaultStateUnsub){try{this._vaultStateUnsub()}catch{}this._vaultStateUnsub=null}}_finish(t){if(!this._settled){if(this._abortController)try{this._abortController.abort()}catch{}super._finish(!!t)}}_onClose=()=>this._finish(this._success);_onCancel=()=>{this._busy&&!this._canCancel||this._finish(!1)};_onDialogCancel=t=>{if(this._busy&&!this._canCancel){t.preventDefault();return}this._finish(!1)};_onNameInput=t=>{this._userName=t.target.value};_onOrphanAckInput=t=>{this._orphanAck=t.target.checked};_onWipeOrphan=async()=>{if(!this._busy&&this._orphanAck){if(Q()){this._error="Encryption was just enabled in another tab. Reload this page to unlock.";return}this._busy=!0,this._canCancel=!1,this._error="",this._phase="Clearing previous vault state\u2026";try{await Ln({refuseIfEnabled:!0}),location.reload()}catch(t){this._error=`Could not clear previous vault state: ${t?.message??t}`,this._phase=""}finally{this._busy=!1,this._canCancel=!0}}};_onEnable=async()=>{if(!this._busy){if(!vt()){this._error="Passkeys are not supported in this browser.";return}this._busy=!0,this._canCancel=!0,this._error="",this._phase="Registering passkey\u2026",this._abortController=new AbortController;try{await na({userName:this._userName.trim()||"DeepView user",rpName:"DeepView",signal:this._abortController.signal,migrate:async({seal:r})=>{this._canCancel=!1,this._phase="Encrypting workspaces and metadata\u2026",await Xi({seal:r}),this._phase="Encrypting triage data\u2026",await ol({seal:r}),this._phase="Encrypting report files\u2026",await ba({seal:r}),this._phase="Encrypting bundles\u2026",await wa({seal:r})}})&&(this._success=!0,this._phase="")}catch(t){t?.name==="AbortError"?this._error="":this._error=t?.message??String(t),this._phase=""}finally{this._busy=!1,this._canCancel=!0,this._abortController=null}}};_body(){if(this._orphan)return c`<p class="wsl-error">DeepView found an abandoned passkey setup on this device. The original passkey can no longer be accessed, so any local data still encrypted under it is <strong>unreadable</strong> and cannot be recovered.</p><p class="nwd-note">To enable encryption, DeepView will <strong>permanently delete ALL local DeepView data on this device</strong> — including any plaintext workspaces or reports you may have added after the previous passkey was lost — and then register a fresh passkey. This is irreversible. There is no backup.</p><label class="wsl-ack"><input type="checkbox" data-role="orphan-ack" .checked="${this._orphanAck}" ?disabled="${this._busy}" @change="${this._onOrphanAckInput}"> <span>I understand all local DeepView data on this device will be deleted.</span></label> ${this._phase?c`<p class="nwd-note">${this._phase}</p>`:g} ${this._error?c`<p class="wsl-error">${this._error}</p>`:g}<footer class="nwd-actions"><span class="nwd-spacer"></span> <button type="button" ?disabled="${this._busy&&!this._canCancel}" @click="${this._onCancel}">Cancel</button> <button type="button" class="primary" ?disabled="${this._busy||!this._orphanAck}" @click="${this._onWipeOrphan}">${this._busy?"Working\u2026":"Wipe and continue"}</button></footer>`;if(this._success)return c`<p class="nwd-note"><strong>Encryption is on.</strong> Your triage data and report files are now sealed under your passkey. You'll be asked to unlock with the passkey on every fresh load.</p><footer class="nwd-actions"><span class="nwd-spacer"></span> <button type="button" class="primary" @click="${()=>this._finish(!0)}">Close</button></footer>`;let t=vt();return c`<p class="nwd-note">Passkey encryption protects your local triage and report data with a hardware-backed key (TouchID, Windows Hello, security key). Without the passkey, the data on disk is unreadable — even to scripts running on this origin.</p><p class="wsl-error"><strong>If you lose access to this passkey, your data CANNOT be recovered.</strong> DeepView has no backup key, no recovery code, and no escrow. Make sure your passkey is backed up (iCloud Keychain / Google Password Manager sync, or a second registered device) before relying on encryption for important data.</p><p class="nwd-note"><strong>Opt-in.</strong> You can disable encryption later from the lock icon in the sidebar header — the data is rewritten as plaintext and DeepView signals your authenticator to remove the passkey (where supported).</p>${t?g:c`<p class="wsl-error">Your browser doesn't expose the WebAuthn passkey API. Try Chrome, Safari, Edge, or Firefox in a recent version on a device with a platform authenticator.</p>`} <label class="wsl-field"><span>Passkey label</span> <input type="text" class="nwd-input" data-role="name" placeholder="DeepView" maxlength="200" .value="${this._userName}" @input="${this._onNameInput}"></label> ${this._phase?c`<p class="nwd-note">${this._phase}</p>`:g} ${this._error?c`<p class="wsl-error">${this._error}</p>`:g}<footer class="nwd-actions"><span class="nwd-spacer"></span> <button type="button" ?disabled="${this._busy&&!this._canCancel}" @click="${this._onCancel}">Cancel</button> <button type="button" class="primary" ?disabled="${!t||this._busy}" @click="${this._onEnable}">${this._busy?"Working\u2026":"Enable encryption"}</button></footer>`}render(){return c`<dialog @close="${this._onClose}" @cancel="${this._onDialogCancel}"><header><h3>${this._success?"Encryption enabled":this._orphan?"Previous passkey setup detected":"Enable passkey encryption"}</h3></header>${this._body()}</dialog>`}};customElements.define("passkey-setup-dialog",xl);function Us(){return q("passkey-setup-dialog")}var _l=class extends I{static styles=[...I.styles,T(ot)];static properties={_busy:{state:!0},_error:{state:!0}};constructor(){super(),this._busy=!1,this._error="",this._abortController=null}_finish(t){if(!this._settled){if(this._abortController)try{this._abortController.abort()}catch{}super._finish(!!t)}}_onCancel=()=>this._finish(!1);_onUnlock=async()=>{if(!this._busy){this._busy=!0,this._error="",this._abortController=new AbortController;try{if(await Mn({signal:this._abortController.signal})){this._finish(!0);return}this._error=""}catch(t){this._error=t?.message??String(t)}finally{this._busy=!1,this._abortController=null}}};render(){return c`<dialog @close="${this._onClose}"><header><h3>Unlock your data</h3></header><p class="nwd-note">Your triage data and report files are encrypted with a passkey on this device. Unlock to load them.</p>${this._error?c`<p class="wsl-error">${this._error}</p>`:g}<footer class="nwd-actions"><span class="nwd-spacer"></span> <button type="button" @click="${this._onCancel}">${this._busy?"Cancel":"Later"}</button> <button type="button" class="primary" ?disabled="${this._busy}" @click="${this._onUnlock}">${this._busy?"Waiting\u2026":"Unlock with passkey"}</button></footer></dialog>`}};customElements.define("passkey-unlock-dialog",_l);function zs(){return q("passkey-unlock-dialog")}var Mp=c`<svg viewBox="0 0 16 16" width="13" height="13" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3" y="8" width="10" height="6" rx="1"/><path d="M5 8V5.5a3 3 0 0 1 6 0V8"/></svg>`,uy=c`<svg viewBox="0 0 16 16" width="13" height="13" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3" y="8" width="10" height="6" rx="1"/><path d="M5 8V5a3 3 0 0 1 6 -0.5"/></svg>`,Ee=null;function Lp(){if(!Ee)return;if(!vt()){Ee.hidden=!0;return}Ee.hidden=!1;let e=Q(),t=ct();Ee.classList.toggle("encrypted",e&&t),Ee.classList.toggle("locked-pending",e&&!t),e&&t?(Ee.title="Encryption on \u2014 click to disable",Ee.setAttribute("aria-label","Disable encryption"),K(Mp,Ee)):e?(Ee.title="Encryption on, locked \u2014 click to unlock",Ee.setAttribute("aria-label","Unlock encrypted data"),K(Mp,Ee)):(Ee.title="Encryption off \u2014 click to enable",Ee.setAttribute("aria-label","Enable encryption"),K(uy,Ee))}async function py(){if(confirm(`Disable encryption?
14
+ `))}function Xu(e){return e.replaceAll("**","")}function Hb(e){return Array.from(e,t=>t.toString(16).padStart(2,"0")).join("")}function Wb(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCodePoint(e[r]);return btoa(t)}async function Qu(e){let t=typeof e=="string"?te(e):e,r=await crypto.subtle.digest("SHA-512",t);return`sha512-${Wb(new Uint8Array(r))}`}async function Vb(e){let t=te(JSON.stringify(e)),r=await crypto.subtle.digest("SHA-256",t),n=new Uint8Array(r,0,16);n[6]=n[6]&15|64,n[8]=n[8]&63|128;let o=Hb(n);return`${o.slice(0,8)}-${o.slice(8,12)}-${o.slice(12,16)}-${o.slice(16,20)}-${o.slice(20,32)}`}async function Ls(e){if(typeof crypto?.subtle?.digest!="function")return null;let t;e.fileHash?t={severity:e.severity,description:e.description,fileHash:e.fileHash}:e.location?t={severity:e.severity,description:e.description,location:e.location}:t={severity:e.severity,description:e.description,file:e.file,line:e.line};try{return await Vb(t)}catch{return null}}function qt(e){try{return JSON.parse(e)}catch{return Qr(e)??Zr(e)}}function Yt(e){let t=[];for(let r of e){let n=Array.isArray(r)?r:[r];for(let o of n)o&&t.push(o)}return t}async function en(e){let t=e.filter(n=>n&&!n.id);if(t.length===0)return;let r=await Promise.all(t.map(Ls));t.forEach((n,o)=>{r[o]&&(n.id=r[o])})}var xr=new Map,tn=new Map,rn=new Map,Ps=new Map;function jb(e){let t=e?.package?.npm;if(typeof t?.name=="string"&&t.name&&!Vr(t))return t.name;if(!e?.file)return null;let r=/(?:^|\/)(?:node_modules|dependencies)\/(@[^/]+\/[^/]+|[^/]+)/gu,n;for(;(n=r.exec(e.file))!==null;)if(n[1]!==".pnpm")return n[1];return null}function Kb(e){return typeof e?.file!="string"?!1:/(?:^|\/)(?:node_modules|dependencies)\//u.test(e.file)}function Gb(e,t){return typeof e.repo?.github=="string"&&e.repo.github?e.repo.github:typeof e._repoFallback=="string"&&e._repoFallback?e._repoFallback:typeof t=="string"&&t?t:null}var to=new Set,Oa=new Set,eo=null,Na=!1;function Da(e){return Oa.add(e),()=>Oa.delete(e)}function za(){for(let e of Oa)try{e()}catch{}}function ro(e){return xr.get(e)?.list??[]}function Ua(){let e=0;for(let t of xr.values())e+=t.list.length;return e}function $t(){return tn}function _r(){return rn}function no(e,t){let r=xr.get(e);if(!r)return[];let n=r.reports.get(Jt(t));return n?[...n]:[]}function Ha(e,t){let r=tn.get(e);if(!r)return[];let n=r._keyReports.get(Jt(t));return n?[...n]:[]}function Wa(e,t){let r=rn.get(e);if(!r)return[];let n=r._keyReports.get(Jt(t));return n?[...n]:[]}var Zu=["type","model","think","effort","exportsMode"];function qb(e,t){if(!Zu.some(r=>e[r]!==void 0))for(let r of Zu)t[r]!==void 0&&(e[r]=t[r])}function Yb(e){let t=Array.isArray(e?.findings)?e.findings:Array.isArray(e?.groups)?e.groups:null;if(!t)return[];let r=!e?.source,n=[];for(let o of Yt(t))r&&qb(o,e),n.push(o);return n}function Jt(e){return e.id?`id:${e.id}`:`c:${e.severity??""}|${e.description??""}|${e.file??""}|${e.line??""}`}function Va(e,t,r){let n=Ps.get(e);n||(n={hash:[],pkg:[],repo:[]},Ps.set(e,n)),n[t].push(r)}function Jb(e,t,r){let n=xr.get(e.fileHash);n||(n={keys:new Set,list:[],reports:new Map},xr.set(e.fileHash,n));let o=n.reports.get(t);o||(o=new Set,n.reports.set(t,o));let s=!o.has(r);return o.add(r),s&&Va(r,"hash",{hash:e.fileHash,key:t}),n.keys.has(t)?s:(n.keys.add(t),n.list.push(e),!0)}function Xb(e,t,r){let n=jb(e);if(!n)return!1;let o=Cu(e),s=tn.get(n);if(s||(s={...ms(),repos:new Set,byVersion:new Map,_repoReports:new Map},tn.set(n,s)),typeof e.repo?.github=="string"&&e.repo.github){s.repos.add(e.repo.github);let l=s._repoReports.get(e.repo.github);l||s._repoReports.set(e.repo.github,l=new Set),l.add(r)}Eu(s,o,e,t,r);let i=bs(s,t,r,e);return Va(r,"pkg",{pkg:n,key:t,file:e.file,version:o}),i}function Qb(e,t,r,n){if(Kb(e))return!1;let o=Gb(e,n);if(!o)return!1;let s=rn.get(o);s||(s=ms(),rn.set(o,s));let i=bs(s,t,r,e);return i&&Va(r,"repo",{repo:o,key:t,file:e.file}),i}function ja(e){let t=Ps.get(e);if(Ps.delete(e),to.delete(e),!t)return!1;let r=!1;for(let{hash:o,key:s}of t.hash){let i=xr.get(o);if(!i)continue;let l=i.reports.get(s);if(l){if(l.delete(e)&&(r=!0),l.size===0){i.reports.delete(s),i.keys.delete(s);let d=i.list.findIndex(u=>Jt(u)===s);d>=0&&i.list.splice(d,1)}i.keys.size===0&&xr.delete(o)}}let n=new Set;for(let{pkg:o,key:s,file:i,version:l}of t.pkg){let d=tn.get(o);if(!d)continue;let u=d._keyReports.get(s);if(u){if(u.delete(e)&&(r=!0),u.size===0&&ys(d,s,i,Jt),Au(d,l,s,i,e,Jt),!n.has(o)){n.add(o);for(let p of[...d._repoReports.keys()]){let f=d._repoReports.get(p);f?.delete(e)&&f.size===0&&(d._repoReports.delete(p),d.repos.delete(p),r=!0)}}d._keyReports.size===0?tn.delete(o):ws(d)}}for(let{repo:o,key:s,file:i}of t.repo){let l=rn.get(o);if(!l)continue;let d=l._keyReports.get(s);d&&(d.delete(e)&&(r=!0),d.size===0&&ys(l,s,i,Jt),l._keyReports.size===0?rn.delete(o):ws(l))}return r}async function Zb(e){if(to.has(e))return!1;to.add(e);try{let t=await De(e),r=qt(t);if(!r)return!1;let n=Yb(r);if(n.length===0)return!1;let o="";try{o=qe(e)}catch{}let s=!1;for(let i of n){let l=Jt(i);i.fileHash&&Jb(i,l,e)&&(s=!0),i.file&&Xb(i,l,e)&&(s=!0),i.file&&Qb(i,l,e,o)&&(s=!0)}return to.has(e)?s:(ja(e),Na=!0,!1)}catch{return to.delete(e),!1}}function xt(){return eo||(eo=(async()=>{try{do{Na=!1;let e=await fe();for(let t of e)await Zb(t)&&za()}while(Na)}finally{eo=null}})(),eo)}Hu(e=>{ja(e)&&za()});qu(e=>{ja(e)&&za(),xt().catch(()=>{})});var oo=new Map,so=new Map;function Os(e,t){if(!e||!t)return!1;let r=!so.has(e);so.set(e,t);for(let[n,o]of t){if(!o)continue;let s=oo.get(o);s||(s=new Map,oo.set(o,s)),s.set(e,n)}return r}function Ka(e){let t=so.get(e);if(so.delete(e),!!t)for(let r of t.values()){let n=oo.get(r);n&&(n.delete(e),n.size===0&&oo.delete(r))}}function Sr(e){if(!e)return[];let t=oo.get(e);if(!t)return[];let r=[];for(let[n,o]of t)r.push({integrity:n,file:o});return r}function Ga(e){return so.has(e)}var ep="deepview.fileCounts",on=null;function Ds(){if(on)return on;try{on=JSON.parse(we(ep)||"{}")}catch{on={}}return on}function qa(){Ee(ep,JSON.stringify(on)).catch(e=>console.warn("counts persist:",e))}function tp(e){let t=Ds()[e];if(t!==void 0)return typeof t=="number"?{count:t}:t}function ao(e){return tp(e)?.count}function lo(e){return tp(e)?.source}function Je(e,t,r){let n=Ds();n[e]=r?{count:t,source:r}:{count:t},qa()}function sn(e){let t=Ds();delete t[e],qa()}function Ke(e){try{let n=JSON.parse(e);if(n&&Array.isArray(n.findings))return{count:n.findings.length,source:n.source,recognized:!0}}catch{}let t=Qr(e);if(t)return{count:t.findings.length,source:t.source,recognized:!0};let r=Zr(e);return r?{count:r.findings.length,source:r.source,recognized:!0}:{count:0,recognized:!1}}var io=null,nn=null,Ns=null;function ey(e,t){for(let{names:r,onUpdate:n}of Ns)if(r.has(e))try{n(e,t)}catch(o){console.warn("ensureCounts onUpdate:",o)}}function Ya(e,t){if(io){t&&Ns.push({names:new Set(e),onUpdate:t});for(let r of e)nn.add(r);return io}return nn=new Set(e),Ns=t?[{names:new Set(e),onUpdate:t}]:[],io=(async()=>{await Promise.resolve();try{let r=Ds();for(;nn.size>0;){let n=nn.values().next().value;if(nn.delete(n),r[n]===void 0)try{let o=await De(n);if(r[n]!==void 0)continue;let{count:s,source:i}=Ke(o);r[n]=i?{count:s,source:i}:{count:s},qa(),ey(n,s)}catch{}}}finally{io=null,nn=null,Ns=null}})(),io}function Ja(e){if(!e)return"";for(let t of e.split(`
15
+ `))if(t.trim())return t.trim();return""}function Xa(e){let t=new Set(e.map(n=>n.id)),r=new Map;for(let n of a.reports)for(let o of n.groups)for(let s of o){let i=s.id??String(s._id);if(!(!t.has(i)||r.has(i))&&(r.set(i,{severity:s.severity,file:s.file,line:s.line,description:Ja(s.description)}),r.size===t.size))return r}return r}var ty=`deepview/workspace-id/v1
16
+ `;async function co(e){let t=Uint8Array.fromBase64(e),r=te(ty),n=new Uint8Array(r.length+t.length);n.set(r,0),n.set(t,r.length);let o=new Uint8Array(await crypto.subtle.digest("SHA-256",n)),i=Array.from(o.subarray(0,16),u=>u.toString(16).padStart(2,"0")).join("").split("");i[12]="8";let l=parseInt(i[16],16)&3|8;i[16]=l.toString(16);let d=i.join("");return`${d.slice(0,8)}-${d.slice(8,12)}-${d.slice(12,16)}-${d.slice(16,20)}-${d.slice(20,32)}`}function uo(e){let t=new Set;function r(o){return t.add(o),()=>t.delete(o)}function n(o){for(let s of t)try{s(o)}catch(i){console.warn(`workspace ${e} listener failed:`,i)}}return{on:r,fire:n}}var rp=uo("create"),np=uo("delete"),op=uo("privateKey"),sp=uo("report-membership"),ip=uo("bundle-membership"),ry=rp.on,Qa=np.on,Za=op.on,el=sp.on,tl=ip.on,zs=rp.fire,rl=np.fire,nl=op.fire,Us=sp.fire,Hs=ip.fire;var sl="deepview.workspaces",ny=1;function po(){try{let e=we(sl);if(!e)return[];let t=JSON.parse(e);return t&&typeof t=="object"&&Array.isArray(t.workspaces)?t.workspaces:Array.isArray(t)?t:[]}catch{return[]}}async function oy(e){await Ee(sl,JSON.stringify({version:ny,workspaces:e}))}var sy=sl;function an(e){return navigator.locks.request(sy,async()=>{await jt();let t=po(),r=await e(t);if(r!==!1)return await oy(t),r})}function fo(e){return{id:e.id,privateKey:e.privateKey,reports:Array.isArray(e.reports)?[...e.reports]:[],bundles:Array.isArray(e.bundles)?[...e.bundles]:[]}}var mt=po().map(fo);function il(){mt=po().map(fo)}function al(e){mt=mt.filter(t=>t.id!==e.id),mt.push(fo(e))}function iy(e,t){let r=Array.isArray(e[t])?[...e[t]]:[],n=mt.find(o=>o.id===e.id);if(n){n[t]=r;return}mt.push(fo(e))}function ay(e){mt=mt.filter(t=>t.id!==e)}function V(){let e=po();for(let t of e)Array.isArray(t.reports)||(t.reports=[]),Array.isArray(t.bundles)||(t.bundles=[]);return e}var ly=200;function _t(e){let t=(e??"").trim();return t&&t.replaceAll(/[\u0000-\u001F\u007F]/gu,"").slice(0,ly)||null}async function ll(e){let t=_t(e);if(!t)return null;let r=new Uint8Array(32);crypto.getRandomValues(r);let n=r.toBase64(),o={id:await co(n),name:t,privateKey:n,reports:[],bundles:[],createdAt:Date.now()};return await an(i=>i.some(l=>l.id===o.id)?!1:(i.push(o),o))?(al(o),o):null}async function cl(e){await an(r=>{let n=r.findIndex(o=>o.id===e);return n<0?!1:(r.splice(n,1),!0)})&&(rl(e),ay(e))}async function dl(e,t){let r=_t(t);return!(!r||!await an(o=>{let s=o.find(i=>i.id===e);return!s||s.name===r?!1:(s.name=r,s)}))}async function ap(e){let t=await an(o=>{let s=o.findIndex(p=>p.id===e.id),i=s>=0?o[s]:null,l=_t(e.name)??i?.name??"Workspace",d=e.preserveBundles?Array.isArray(i?.bundles)?i.bundles:[]:Array.isArray(e.bundles)?e.bundles:[],u={id:e.id,name:l,privateKey:e.privateKey,reports:Array.isArray(e.reports)?[...new Set(e.reports)]:[],bundles:[...new Set(d)],createdAt:e.createdAt??Date.now()};return s>=0?o[s]=u:o.push(u),{previous:i,next:u}}),{next:r}=t,n=mt.find(o=>o.id===r.id)??null;return n==null?zs(r.id):(n.privateKey!==r.privateKey&&nl(r.id),Ws(n.reports,r.reports)||Us(r.id),Ws(n.bundles,r.bundles)||Hs(r.id)),al(r),r}async function ul({id:e,name:t,privateKey:r,createdAt:n}){let o=null;return await an(s=>{let i=_t(t);if(!i)return o={status:"name-collision",existing:null},!1;let l=s.find(p=>p.id===e)??null;if(l)return o={status:"already-attached",workspace:l},!1;let d=s.find(p=>_t(p.name)===i)??null;if(d)return o={status:"name-collision",existing:d},!1;let u={id:e,name:i,privateKey:r,reports:[],bundles:[],createdAt:n??Date.now()};s.push(u),o={status:"attached",workspace:u}}),o?.status==="attached"&&(zs(o.workspace.id),al(o.workspace)),o}function Ws(e,t){let r=new Set(e),n=new Set(t);if(r.size!==n.size)return!1;for(let o of r)if(!n.has(o))return!1;return!0}async function ol({identifier:e,workspaceId:t,field:r,fire:n,additive:o=!1,from:s=void 0}){let i=await an(u=>{if((u.find(m=>Array.isArray(m[r])&&m[r].includes(e))?.id??null)===(t??null))return!1;let f=null;if(t!=null&&(f=u.find(m=>m.id===t)??null,!f))return!1;let h=new Set;if(!o)for(let m of u)s!==void 0&&m.id!==s||(Array.isArray(m[r])||(m[r]=[]),m[r].includes(e)&&(m[r]=m[r].filter(y=>y!==e),h.add(m.id)));if(f&&(Array.isArray(f[r])||(f[r]=[]),f[r].includes(e)||(f[r].push(e),h.add(f.id))),h.size===0)return!1;let b=new Map;for(let m of h){let y=u.find(v=>v.id===m);y&&b.set(m,y)}return{affected:h,snapshot:b}});if(!i)return;let{affected:l,snapshot:d}=i;for(let u of l){n(u);let p=d.get(u);p&&iy(p,r)}}function lp(e,t){return{move:(r,n)=>ol({identifier:r,workspaceId:n,field:e,fire:t}),add:(r,n)=>ol({identifier:r,workspaceId:n,field:e,fire:t,additive:!0}),remove:(r,n)=>ol({identifier:r,field:e,fire:t,from:n})}}var pl=lp("reports",Us),fl=lp("bundles",Hs),ho=pl.move,Bt=pl.add,go=pl.remove,hl=fl.move,Cr=fl.add,gl=fl.remove;function cy(){let e=po().map(fo),t=mt,r=new Map(t.map(o=>[o.id,o])),n=new Map(e.map(o=>[o.id,o]));for(let o of r.keys())n.has(o)||rl(o);for(let[o,s]of n){let i=r.get(o);if(!i){zs(o);continue}i.privateKey!==s.privateKey&&nl(o),Ws(i.reports,s.reports)||Us(o),Ws(i.bundles,s.bundles)||Hs(o)}mt=e}Kr(()=>{cy()});function cp(e){return e==="inprogress"||e==="fixed"||e==="invalid"||e==="deleted"?e:void 0}function ge(e){if(e)return cp(e.triage)??(e.deleted?"deleted":void 0)}function dy(e){return e?!e.color&&!ge(e)&&!e.comment&&!e.fix&&!(e.ignoredReports&&e.ignoredReports.length>0)&&e.flagged===void 0:!0}function Mt(e,t,r){let n=e.get(t)?.ignoredReports;return Array.isArray(n)&&n.includes(r)}function mo(e){if(!e||typeof e!="object")return;let t=e,r={};typeof t.color=="string"&&t.color&&(r.color=t.color);let n=cp(t.triage)??(t.deleted?"deleted":void 0);if(n&&(r.triage=n),typeof t.comment=="string"&&t.comment&&(r.comment=t.comment),typeof t.fix=="string"&&t.fix&&(r.fix=t.fix),typeof t.flagged=="boolean"&&(r.flagged=t.flagged),Array.isArray(t.ignoredReports)){let o=t.ignoredReports.filter(s=>typeof s=="string"&&s.length>0);o.length>0&&(r.ignoredReports=o)}return dy(r)?void 0:r}function uy(e,t){let r=e??[],n=t??[];if(r.length!==n.length)return!1;if(r.length===0)return!0;let o=new Set(r);for(let s of n)if(!o.has(s))return!1;return!0}function py(e,t){let r=e??{},n=t??{};return(r.color??"")===(n.color??"")&&(ge(r)??"")===(ge(n)??"")&&(r.comment??"")===(n.comment??"")&&(r.fix??"")===(n.fix??"")&&r.flagged===n.flagged&&uy(r.ignoredReports,n.ignoredReports)}function L(e,t,r){let n=e.get(t),o=mo({...n,...r});return o===void 0?e.delete(t):py(n,o)?!1:(e.set(t,o),!0)}function ce(e,t,r,n){let o=new Set(e.get(t)?.ignoredReports??[]);return n?o.add(r):o.delete(r),L(e,t,{ignoredReports:o.size>0?[...o]:void 0})}var ml=()=>{};function up(e){ml=typeof e=="function"?e:()=>{}}var pp=()=>{};function bl(e){pp=typeof e=="function"?e:()=>{}}var Xt="deepview.triage",Lt="deepview.triage.pending",St=/^\d+$/u;async function fy(e){let t=new Blob([e]).stream().pipeThrough(new CompressionStream("deflate"));return new Uint8Array(await new Response(t).arrayBuffer())}async function hy(e){let t=new Blob([e]).stream().pipeThrough(new DecompressionStream("deflate"));return new Uint8Array(await new Response(t).arrayBuffer())}var gy="deepview.triage.save",dp=0;function yl(){let e={};for(let[t,r]of a.triage){if(St.test(t))continue;let n=mo(r);n&&(e[t]=n)}return e}function ae(){let e=++dp,t=yl(),r=Object.keys(t).length===0,n=r?null:JSON.stringify(t);if(n!=null)try{localStorage.setItem(Lt,n)}catch{}return navigator.locks.request(rt,{mode:"shared"},async()=>{let o=null,s=null;if(n!=null)try{let i=te(n),l=await fy(i);s=Ae(),o=(s?await Ou(l):l).toBase64()}catch(i){console.warn("Failed to save triage:",i),ml();return}await navigator.locks.request(gy,()=>{try{if(e!==dp)return;if(n!=null&&Ae()!==s){queueMicrotask(()=>{ae()});return}if(r)localStorage.removeItem(Xt),localStorage.removeItem(Lt);else{localStorage.setItem(Xt,o);try{localStorage.removeItem(Lt)}catch{}}}catch(i){console.warn("Failed to save triage:",i)}}),ml()})}async function fp(){let e=localStorage.getItem(Lt);if(e)try{return JSON.parse(e)}catch{}let t=localStorage.getItem(Xt);if(!t)return null;let r=Uint8Array.fromBase64(t);if(je(r)){if(!Ae())throw new Error("triage: vault locked, cannot decrypt envelope");r=await Nu(r)}let n=await hy(r);return JSON.parse(he(n))}function hp(e,{replace:t=!1}={}){let r=a.triage;if(t){let n=null,o=localStorage.getItem(Lt);if(o)try{n=JSON.parse(o)}catch{}let s=i=>n!=null&&i in n;for(let i of[...r.keys()]){if(St.test(i))continue;let l=e?.[i],d=!e||!(i in e);!(s(i)&&n[i]?.color)&&(d||!l?.color)&&L(r,i,{color:void 0}),!(s(i)&&(n[i]?.triage||n[i]?.deleted))&&!ge(l)&&L(r,i,{triage:void 0}),!(s(i)&&n[i]?.comment)&&(d||typeof l?.comment!="string"||!l.comment)&&L(r,i,{comment:void 0}),!(s(i)&&n[i]?.fix)&&(d||typeof l?.fix!="string"||!l.fix)&&L(r,i,{fix:void 0}),!(s(i)&&n[i]?.flagged!==void 0)&&(d||l?.flagged===void 0)&&L(r,i,{flagged:void 0})}for(let i of[...r.keys()]){if(St.test(i))continue;let l=r.get(i)?.ignoredReports;if(!l||l.length===0)continue;let d=e?.[i],u=!!ge(d);for(let p of[...l]){if(s(i)&&Array.isArray(n[i]?.ignoredReports)&&n[i].ignoredReports.includes(p))continue;if(u){ce(r,i,p,!1);continue}let f=d?.ignoredReports;(!Array.isArray(f)||!f.includes(p))&&ce(r,i,p,!1)}}}if(e)for(let[n,o]of Object.entries(e)){let s=ge(o),i={};if(o&&o.color&&(i.color=o.color),s&&(i.triage=s),o&&typeof o.comment=="string"&&o.comment&&(i.comment=o.comment),o&&typeof o.fix=="string"&&o.fix&&(i.fix=o.fix),o&&typeof o.flagged=="boolean"&&(i.flagged=o.flagged),Object.keys(i).length>0&&L(r,n,i),!s&&o&&Array.isArray(o.ignoredReports)){let l=new Set(r.get(n)?.ignoredReports??[]),d=!1;for(let u of o.ignoredReports)typeof u=="string"&&!l.has(u)&&(l.add(u),d=!0);d&&L(r,n,{ignoredReports:[...l]})}}}async function my(){try{let e=await fp();hp(e)}catch(e){console.warn("Failed to load triage:",e)}}async function gp(){try{let e=await fp();hp(e,{replace:!0}),pp()}catch(e){console.warn("Failed to reload triage:",e)}}typeof window<"u"&&window.addEventListener("storage",e=>{e.key!==Xt&&e.key!==Lt||gp()});var bo=my();ve(()=>{gp()});ve(()=>{Ae()&&localStorage.getItem(Lt)&&ae()});async function wl({seal:e}){try{localStorage.removeItem(Lt)}catch{}let t=localStorage.getItem(Xt);if(!t)return;let r=Uint8Array.fromBase64(t);if(je(r))return;let n=await e(r,Gn());localStorage.setItem(Xt,n.toBase64())}async function vl({open:e}){try{localStorage.removeItem(Lt)}catch{}let t=localStorage.getItem(Xt);if(!t)return;let r=Uint8Array.fromBase64(t);if(!je(r))return;let n=await e(r,Gn());localStorage.setItem(Xt,n.toBase64())}var mp="deepview.lastFile",yo=null;function kl(){return yo||(yo=by(),yo.catch(()=>{yo=null})),yo}async function by(){try{await bo}catch{}let e=await fe(),t=new Set(e),r=new Set(e),n=new Set;for(let o of e){if(!o.toLowerCase().endsWith(".deepseek"))continue;let s=o.slice(0,-9)+".md";if(t.has(s))continue;let i;try{i=await De(o),await ht(s,i),await Xr(o)}catch(p){console.warn(`migrate: failed to rename ${o} -> ${s}`,p);continue}t.delete(o),t.add(s),n.add(o);let l=ao(o);if(sn(o),l===void 0){let{count:p,source:f}=Ke(i);Je(s,p,f)}else{let{source:p}=Ke(i);Je(s,l,p)}let d=qe(o);d&&(Ye(o,""),Ye(s,d));let u=!1;for(let[p,f]of[...a.triage])f.ignoredReports?.includes(o)&&(ce(a.triage,p,o,!1),ce(a.triage,p,s,!0),u=!0);if(u&&await ae(),we(mp)===o)try{await Ee(mp,s)}catch{}}for(let o of V())for(let s of o.reports){if(!s.toLowerCase().endsWith(".deepseek")||!n.has(s)&&r.has(s))continue;let i=s.slice(0,-9)+".md";await go(s,o.id),await Bt(i,o.id)}}var $l=1;function yy(){let e=yl(),t=Ms();return{version:$l,exportedAt:new Date().toISOString(),triage:e,repoUrls:t}}function wy(){return`deepview-triage-${new Date().toISOString().replaceAll(/[:.]/gu,"-").slice(0,19)}.json.gz`}async function xl(){let e=yy();return{blob:new Blob([await vs(JSON.stringify(e))]),filename:wy()}}async function _l(e){let t;try{t=await zn(new Uint8Array(await e.arrayBuffer()))}catch(n){throw new Error(`Failed to gunzip: ${n.message}`,{cause:n})}let r;try{r=JSON.parse(t)}catch(n){throw new Error(`Failed to parse JSON: ${n.message}`,{cause:n})}if(!r||typeof r!="object")throw new Error("Invalid backup file (not an object)");if(r.version!==$l)throw new Error(`Unsupported backup version: ${r.version} (expected ${$l})`);if(!r.triage||typeof r.triage!="object")throw new Error("Backup is missing the `triage` map");if(!r.repoUrls||typeof r.repoUrls!="object")throw new Error("Backup is missing the `repoUrls` map");return r}async function Sl(e,t){if(!["replace","prefer-imported","prefer-current"].includes(t))throw new Error(`Unknown merge mode: ${t}`);if(!e||typeof e!="object")throw new Error("Invalid payload: not an object");if(!e.triage||typeof e.triage!="object"||Array.isArray(e.triage))throw new Error("Invalid payload: missing or non-object `triage`");if(!e.repoUrls||typeof e.repoUrls!="object"||Array.isArray(e.repoUrls))throw new Error("Invalid payload: missing or non-object `repoUrls`");let r=e.triage,n=a.triage;if(t==="replace")for(let l of[...n.keys()])St.test(l)||n.delete(l);let o=t==="prefer-current";for(let[l,d]of Object.entries(r)){if(St.test(l)||!d||typeof d!="object")continue;typeof d.color=="string"&&d.color&&(!o||!n.get(l)?.color)&&L(n,l,{color:d.color});let u=ge(d);if(u&&(!o||!ge(n.get(l)))&&L(n,l,{triage:u}),typeof d.comment=="string"&&d.comment&&(!o||!n.get(l)?.comment)&&L(n,l,{comment:d.comment}),typeof d.fix=="string"&&d.fix&&(!o||!n.get(l)?.fix)&&L(n,l,{fix:d.fix}),typeof d.flagged=="boolean"&&(!o||n.get(l)?.flagged===void 0)&&L(n,l,{flagged:d.flagged}),Array.isArray(d.ignoredReports)&&!ge(n.get(l)))for(let p of d.ignoredReports)typeof p=="string"&&(o&&Mt(n,l,p)||ce(n,l,p,!0))}await ae();let s=0,i=null;try{await Yu(e.repoUrls,t),s=Object.keys(e.repoUrls).length}catch(l){console.warn("applyTriageImport: repo-URL import failed:",l),i=l}return{triageEntries:Object.keys(r).length,repoUrls:s,repoUrlError:i}}function vy(e){return e?.name==="NotFoundError"||typeof e?.message=="string"&&e.message.startsWith("File not found:")}async function Cl(e){let t=new Set;for(let r of e){let n;try{n=await De(r)}catch(i){if(vy(i))continue;throw new Error(`Failed to read ${r}: ${i.message}`,{cause:i})}if(n==null)continue;let o=qt(n);if(!Array.isArray(o?.findings))continue;let s=Yt(o.findings);await en(s);for(let i of s)i.id&&t.add(i.id)}return t}function ky(){let e=new Set;for(let t of a.triage.keys())St.test(t)||e.add(t);return e}async function Vs(e){let t=ky();if(t.size===0)return{orphanedCount:0,sharedCount:0};let r=await Cl(e),n=new Set;for(let p of t)r.has(p)&&n.add(p);if(n.size===0)return{orphanedCount:0,sharedCount:0};let o=await fe(),s=new Set(e),i=o.filter(p=>!s.has(p)),l=await Cl(i),d=0,u=0;for(let p of n)l.has(p)?u++:d++;return{orphanedCount:d,sharedCount:u}}async function js(){let e=new Set(a.triage.keys()),t=[];for(let[i,l]of a.triage)if(l.ignoredReports)for(let d of l.ignoredReports)t.push({id:i,report:d});let r=await fe(),n=new Set(r),o=await Cl(r),s=!1;for(let i of e){if(St.test(i)||o.has(i))continue;let l=a.triage.get(i);!l||!(l.color||ge(l)||l.comment||l.fix||l.flagged!==void 0)||L(a.triage,i,{color:void 0,triage:void 0,comment:void 0,fix:void 0,flagged:void 0,deleted:void 0})&&(s=!0)}for(let{id:i,report:l}of t)St.test(i)||o.has(i)&&n.has(l)||Mt(a.triage,i,l)&&ce(a.triage,i,l,!1)&&(s=!0);s&&await ae()}var El=1,Zt=16,bp=12,yp=1+Zt+bp+16,Qt=1+Zt+bp;async function wp(e,t){let r=await crypto.subtle.importKey("raw",te(e),"PBKDF2",!1,["deriveKey"]);return crypto.subtle.deriveKey({name:"PBKDF2",hash:"SHA-256",salt:t,iterations:3e6},r,{name:"AES-GCM",length:256},!1,["encrypt","decrypt"])}function vp(e){return!(e instanceof Uint8Array)||e.length<yp?!1:e[0]===El}async function Ks(e,t){if(!(e instanceof Uint8Array))throw new TypeError("encryptWithPassword: plaintext Uint8Array required");if(typeof t!="string"||!t)throw new TypeError("encryptWithPassword: password required");let r=new Uint8Array(Qt+e.length+16);r[0]=El,crypto.getRandomValues(r.subarray(1,1+Zt)),crypto.getRandomValues(r.subarray(1+Zt,Qt));let n=r.subarray(1,1+Zt),o=r.subarray(1+Zt,Qt),s=await wp(t,n),i=new Uint8Array(await crypto.subtle.encrypt({name:"AES-GCM",iv:o,additionalData:r.subarray(0,Qt)},s,e));return r.set(i,Qt),r}async function xy(e,t){if(typeof t!="string"||!t)throw new TypeError("tryDecryptWithPassword: password required");if(!(e instanceof Uint8Array)||e.length<yp)return{ok:!1,reason:"malformed"};if(e[0]!==El)return{ok:!1,reason:"malformed"};let r=e.subarray(1,1+Zt),n=e.subarray(1+Zt,Qt),o=e.subarray(Qt),s=await wp(t,r),i;try{i=new Uint8Array(await crypto.subtle.decrypt({name:"AES-GCM",iv:n,additionalData:e.subarray(0,Qt)},s,o))}catch{return{ok:!1,reason:"wrong-password"}}return{ok:!0,plaintext:i}}async function Gs(e,t,r){if(!r||typeof r.malformedMsg!="string"||typeof r.wrongPasswordMsg!="string")throw new TypeError("decryptWithPasswordOrThrow: { malformedMsg, wrongPasswordMsg } strings required");let n=await xy(e,t);if(n.ok)return n.plaintext;throw n.reason==="wrong-password"?new Error(r.wrongPasswordMsg):new Error(r.malformedMsg)}var wo=vp,kp=Ks;function $p(e,t){return Gs(e,t,{malformedMsg:"malformed encrypted bundle",wrongPasswordMsg:"wrong password or corrupt bundle"})}var _y=1;async function Sy(e){let t=new Set,r=qt(e);if(!Array.isArray(r?.findings))return t;let n=Yt(r.findings);await en(n);for(let o of n)o.id&&t.add(o.id);return t}function xp(e){return(e??"").replaceAll(/[^a-zA-Z0-9._-]+/gu,"_").replaceAll(/^_+|_+$/gu,"")||"workspace"}async function Cy(e){if(!Array.isArray(e)||e.length===0)return[];let t=await gt(),r=new Map(t.map(o=>[o.integrity,o.name])),n=[];for(let o of e){let s=r.get(o);if(!s)continue;let i;try{i=await $r(o)}catch(l){console.warn(`Workspace export: failed to read bundle ${o}: ${l?.message??l}`);continue}n.push({integrity:o,name:s,data:i.toBase64()})}return n}async function Ey(e,{includeBundleBytes:t=!1}={}){let r=[],n=new Set;for(let u of e.reports??[]){let p;try{p=await De(u)}catch(f){console.warn(`Workspace export: skipping ${u}: ${f?.message??f}`),(f instanceof DOMException&&f.name==="NotFoundError"||typeof f?.message=="string"&&f.message.startsWith("File not found:"))&&await ho(u,null);continue}r.push({name:u,content:p});for(let f of await Sy(p))n.add(f)}let o=new Set(e.reports??[]),s={};for(let[u,p]of a.triage){if(!n.has(u))continue;let f=(p.ignoredReports??[]).filter(b=>o.has(b)),h=mo({...p,ignoredReports:f});h&&(s[u]=h)}let i={};for(let u of r){let p=qe(u.name);p&&(i[u.name]=p)}let l=(e.bundles??[]).filter(u=>typeof u=="string"&&u.length>0),d={version:_y,exportedAt:new Date().toISOString(),workspace:{id:e.id,name:e.name,privateKey:e.privateKey,createdAt:e.createdAt},reports:r,bundles:l,repoUrls:i,triage:s};if(t){let u=await Cy(l);u.length>0&&(d.bundleBlobs=u)}return d}async function _p(e,{includeBundleBytes:t=!1}={}){let r=await Ey(e,{includeBundleBytes:t});return{blob:new Blob([await vs(JSON.stringify(r))]),filename:`${xp(e.name)}.deepview-workspace.json.gz`}}async function Ay(e,t,{includeBundleBytes:r=!1}={}){if(typeof t!="string"||!t)throw new TypeError("buildWorkspaceExportEncrypted: password required");let{blob:n}=await _p(e,{includeBundleBytes:r}),o=new Uint8Array(await n.arrayBuffer()),s=await kp(o,t);return{blob:new Blob([s],{type:"application/octet-stream"}),filename:`${xp(e.name)}.deepview-workspace.enc`}}async function Al(e,{password:t,includeBundleBytes:r=!1}={}){return typeof t=="string"&&t?await Ay(e,t,{includeBundleBytes:r}):await _p(e,{includeBundleBytes:r})}var Ty=1,Sp=1024,Cp=1024,qs=200,Ip=100*1024*1024,Iy=Math.ceil(Ip*4/3)+16,Ep=512,Ap=64;function Ry(e){if(!e||typeof e!="object")return"payload is not an object";if(e.version!==Ty)return`unsupported export version: ${e.version}`;if(!e.workspace||typeof e.workspace!="object")return"workspace metadata missing";if(typeof e.workspace.id!="string")return"workspace.id must be a string";if(typeof e.workspace.name!="string")return"workspace.name must be a string";if(typeof e.workspace.privateKey!="string")return"workspace.privateKey must be a string";if(e.workspace.createdAt!==void 0&&!Number.isFinite(e.workspace.createdAt))return"workspace.createdAt must be a finite number or omitted";if(!Array.isArray(e.reports))return"reports field must be an array";if(e.reports.length>Cp)return`reports count (${e.reports.length}) exceeds cap (${Cp})`;if(e.bundles!==void 0){if(!Array.isArray(e.bundles))return"bundles field must be an array when present";if(e.bundles.length>Sp)return`bundles count (${e.bundles.length}) exceeds cap (${Sp})`;for(let t of e.bundles){if(typeof t!="string")return"bundles entries must be strings";if(t.length>qs)return`bundle integrity exceeds per-entry length cap (${qs})`}}if(e.bundleBlobs!==void 0){if(!Array.isArray(e.bundleBlobs))return"bundleBlobs field must be an array when present";if(e.bundleBlobs.length>Ap)return`bundleBlobs count (${e.bundleBlobs.length}) exceeds cap (${Ap})`;for(let t of e.bundleBlobs){if(!t||typeof t!="object"||Array.isArray(t))return"bundleBlobs entries must be objects";if(typeof t.integrity!="string"||t.integrity.length===0)return"bundleBlobs.integrity must be a non-empty string";if(t.integrity.length>qs)return`bundleBlobs.integrity exceeds per-entry length cap (${qs})`;if(typeof t.name!="string"||t.name.length===0)return"bundleBlobs.name must be a non-empty string";if(t.name.length>Ep)return`bundleBlobs.name exceeds per-entry length cap (${Ep})`;if(t.name.includes("\0"))return"bundleBlobs.name cannot contain NUL";if(typeof t.data!="string")return"bundleBlobs.data must be a base64 string";if(t.data.length>Iy)return`bundleBlobs.data exceeds per-blob size cap (${Ip} bytes raw)`}}return null}async function Tl(e){return new Uint8Array(await e.arrayBuffer())}async function Ys(e,t){if(wo(e)){if(typeof t!="string"||!t)throw new TypeError("parseWorkspaceBundleBytes: password required for encrypted bundle");let n=await $p(e,t);try{return Tp(await zn(n))}catch(o){throw new Error("wrong password or corrupt bundle",{cause:o})}}let r;try{r=await zn(e)}catch(n){throw new Error(`gzip decompression failed: ${n.message}`,{cause:n})}return Tp(r)}function Tp(e){let t;try{t=JSON.parse(e)}catch(o){throw new Error(`payload is not JSON: ${o.message}`,{cause:o})}let r=Ry(t);if(r===null)return t;let n=r.includes("exceeds cap");throw new Error(n?r:`not a deepview workspace export: ${r}`)}function Fy(e){return ge(e)??null}async function By(e){let t=new Map;for(let r of e??[]){if(typeof r?.content!="string")continue;let n=qt(r.content);if(!n?.findings)continue;let o=Yt(n.findings);await en(o);for(let s of o)!s.id||t.has(s.id)||t.set(s.id,{severity:s.severity,file:s.file,line:s.line,description:Ja(s.description)})}return t}async function My(e,t,r){if(!e||typeof e!="object"||Array.isArray(e))return;let n=a.triage,o=[];for(let[s,i]of Object.entries(e)){if(!i||typeof i!="object")continue;let l=n.get(s)?.color,d=typeof i.color=="string"?i.color:void 0;d&&l&&l!==d?o.push({id:s,property:"color",local:l,imported:d}):d&&d!==l&&L(n,s,{color:d});let u=n.get(s)?.comment??"",p=typeof i.comment=="string"?i.comment:"";p&&u&&u!==p?o.push({id:s,property:"comment",local:u,imported:p}):p&&p!==u&&L(n,s,{comment:p});let f=n.get(s)?.fix??"",h=typeof i.fix=="string"?i.fix:"";h&&f&&f!==h?o.push({id:s,property:"fix",local:f,imported:h}):h&&h!==f&&L(n,s,{fix:h});let b=Fy(i),m=ge(n.get(s))??null;b&&m&&m!==b?o.push({id:s,property:"triage",local:m,imported:b}):b&&!m&&L(n,s,{triage:b,ignoredReports:void 0});let y=n.get(s)?.flagged,v=typeof i.flagged=="boolean"?i.flagged:void 0;v!==void 0&&y!==void 0&&y!==v?o.push({id:s,property:"flagged",local:y?"flagged":"not flagged",imported:v?"flagged":"not flagged"}):v!==void 0&&v!==y&&L(n,s,{flagged:v});let w=Array.isArray(i.ignoredReports)?i.ignoredReports:[];if(!ge(n.get(s)))for(let k of w)typeof k=="string"&&ce(n,s,k,!0)}if(o.length>0&&t){let s=await t(o,r??new Map);s&&Ly(o,s)}await ae()}function Ly(e,t){for(let r of e){let n=`${r.id}:${r.property}`;t[n]==="imported"&&Py(r.id,r.property)===r.local&&(r.property==="color"?L(a.triage,r.id,{color:r.imported}):r.property==="comment"?L(a.triage,r.id,{comment:r.imported}):r.property==="fix"?L(a.triage,r.id,{fix:r.imported}):r.property==="triage"?L(a.triage,r.id,{triage:r.imported,ignoredReports:void 0}):r.property==="flagged"&&L(a.triage,r.id,{flagged:r.imported==="flagged"?!0:r.imported==="not flagged"?!1:void 0}))}}function Py(e,t){if(t==="color")return a.triage.get(e)?.color;if(t==="triage")return ge(a.triage.get(e))??null;if(t==="comment")return a.triage.get(e)?.comment??"";if(t==="fix")return a.triage.get(e)?.fix??"";if(t==="flagged"){let r=a.triage.get(e)?.flagged;return r===!0?"flagged":r===!1?"not flagged":""}}async function Oy(e){if(Array.isArray(e))for(let t of e){let r;try{r=Uint8Array.fromBase64(t.data)}catch(n){console.warn(`Workspace import: failed to decode bundle ${t.integrity}: ${n?.message??n}`);continue}try{let n=await kr(t.name,r);n?.integrity!==t.integrity&&console.warn(`Workspace import: bundle ${t.name} integrity mismatch (claimed ${t.integrity}, computed ${n?.integrity})`)}catch(n){console.warn(`Workspace import: failed to save bundle ${t.name}: ${n?.message??n}`)}}}async function Il(e,{conflictResolver:t}={}){let r=[];for(let u of e.reports)if(!(typeof u?.name!="string"||typeof u?.content!="string"))try{await ht(u.name,u.content);let{count:p,source:f}=Ke(u.content);Je(u.name,p,f??lo(u.name)),r.push(u.name)}catch(p){console.warn(`Workspace import: failed to save ${u.name}: ${p.message}`)}Array.isArray(e.bundleBlobs)&&e.bundleBlobs.length>0&&await Oy(e.bundleBlobs);let o=e.triage&&Object.keys(e.triage).length>0?await By(e.reports):new Map;await My(e.triage,t,o);let s=Array.isArray(e.bundles),i=s?e.bundles.filter(u=>typeof u=="string"&&u.length>0):[],l=await ap({id:e.workspace.id,name:e.workspace.name,privateKey:e.workspace.privateKey,reports:r,bundles:s?i:void 0,preserveBundles:!s,createdAt:e.workspace.createdAt}),d=new Set(r);if(e.repoUrls&&typeof e.repoUrls=="object")for(let[u,p]of Object.entries(e.repoUrls))!d.has(u)||typeof p!="string"||!p||qe(u)||(Ye(u,p),a.currentFile===u&&(a.repoUrl=p));return l}async function Rl({id:e,name:t,privateKeyBase64:r,password:n}){if(typeof e!="string"||!e)throw new TypeError("encodeShareLink: id required");if(typeof t!="string"||!t)throw new TypeError("encodeShareLink: name required");if(typeof r!="string"||!r)throw new TypeError("encodeShareLink: privateKey required");if(typeof n!="string"||!n)throw new TypeError("encodeShareLink: password required");let s=await co(r)===e?{v:1,n:t,k:r}:{v:1,i:e,n:t,k:r};return(await Ks(te(JSON.stringify(s)),n)).toBase64({alphabet:"base64url",omitPadding:!0})}async function Fl({encoded:e,password:t}){if(typeof e!="string"||!e)throw new Error("malformed share link");if(typeof t!="string"||!t)throw new TypeError("decodeShareLink: password required");let r;try{r=Uint8Array.fromBase64(e,{alphabet:"base64url"})}catch{throw new Error("malformed share link")}let n=await Gs(r,t,{malformedMsg:"malformed share link",wrongPasswordMsg:"wrong password or corrupt link"});try{return await Ny(n)}catch(o){throw new Error("wrong password or corrupt link",{cause:o})}}async function Ny(e){let t=JSON.parse(he(e));if(!t||typeof t!="object"||typeof t.n!="string"||typeof t.k!="string"||!t.n||!t.k)throw new Error("shape");if(t.i!==void 0&&(typeof t.i!="string"||!t.i))throw new Error("shape");if(typeof t.i=="string"&&t.i.length>256)throw new Error("shape");if(t.n.length>1024)throw new Error("shape");if(Uint8Array.fromBase64(t.k).length!==32)throw new Error("shape");return{id:typeof t.i=="string"?t.i:await co(t.k),name:t.n,privateKeyBase64:t.k}}function Bl(e){return typeof location>"u"?`#share=${e}`:`${location.origin}${location.pathname}#share=${e}`}function Ml(e){let t=typeof e=="string"?e:typeof location>"u"?"":location.hash;if(!t)return null;let r=t.replace(/^#/u,"");if(!r)return null;for(let n of r.split("&")){let o=n.indexOf("=");if(o<0||n.slice(0,o)!=="share")continue;return n.slice(o+1)||null}return null}var Dy={get state(){return a},listWorkspaces:V,addReportToWorkspace:Bt,addBundleToWorkspace:Cr,onReportMembershipChanged:el,onBundleMembershipChanged:tl,onWorkspaceDeleted:Qa,onWorkspacePrivateKeyChanged:Za,analyzeContent:Ke,setCount:Je,gunzipBytes:wt,listBundles:gt,listFiles:fe,readBundle:$r,readFileBytes:vr,saveBundle:kr,saveFileBytes:Qn,saveTriage:ae,getSecureItem:we,setSecureItem:Ee,removeSecureItem:Gr,onSecureStorageHydrated:Kr};function Rp(e){e.installSyncHost(Dy),up(()=>e.triageSync.notify())}var U=null,vo=null;function Lp(){try{return we("deepview.sync.userEnabled")!=="0"}catch{return!0}}function Ll(){return vo||(vo=(async()=>{let e="./client-sync.js";try{let t=await import(e);return Rp(t),U=t,zy(),t}catch(t){throw vo=null,t}})(),vo)}function Pp(){return Ll()}var Op=[];function ko(e){U?e(U):Op.push(e)}function zy(){let e=Op.splice(0);for(let t of e)try{t(U)}catch(r){console.warn("client-sync: deferred apply failed:",r)}}function ln(e,t){let r={cancelled:!1,unsub:null};return ko(n=>{r.cancelled||(r.unsub=t(n,e))}),()=>{r.cancelled=!0,r.unsub&&r.unsub()}}function Pl(e,t){return U?U.isInRemote(e,t):!1}function Np(e,t){return U?U.isBundleInRemote(e,t):!1}var Uy="deepview.objstore-presence.";function Dp(e){try{let t=localStorage.getItem(Uy+e);if(!t)return null;let r=JSON.parse(t);return r&&typeof r=="object"?r:null}catch{return null}}function $o(e,t){if(U&&U.isInRemote(e,t))return!0;let r=Dp(e);if(!r||typeof r.names!="object")return!1;for(let n of Object.values(r.names))if(n===t)return!0;return!1}function Ol(e,t){if(U&&U.isBundleInRemote(e,t))return!0;let r=Dp(e);if(!r||typeof r.bundles!="object")return!1;for(let n of Object.values(r.bundles))if(n===t)return!0;return!1}function zp(e){return U?U.remoteCount(e):0}function Up(e){return ln(e,(t,r)=>t.onAutoDownloaded(r))}function Hp(e){return ln(e,(t,r)=>t.onBundleAutoDownloaded(r))}function Wp(e){return ln(e,(t,r)=>t.onChange(r))}var Fp=null,Bp=null,Mp=null,Js=[];function Vp(e){if(U){U.setRedraw(e);return}Fp=e,ko(t=>{Fp===e&&t.setRedraw(e)})}function jp(e){if(U){U.setAuthenticationResolver(e);return}Bp=e,ko(t=>{Bp===e&&t.setAuthenticationResolver(e)})}function Kp(e){if(U){U.setHydrationConflictResolver(e);return}Mp=e,ko(t=>{Mp===e&&t.setHydrationConflictResolver(e)})}async function Pt(e,t){if(!(!Lp()&&!U))return(await Ll())[e](...t)}function Gp(...e){return Pt("fetchFile",e)}function qp(...e){return Pt("fetchBundleFromRemote",e)}function Xs(...e){return Pt("putFile",e)}function Yp(...e){return Pt("putBundleToRemote",e)}function Qs(...e){return Pt("deleteFromRemote",e)}function Zs(...e){return Pt("deleteBundleFromRemote",e)}function ei(...e){return Pt("openWorkspace",e)}function xo(...e){return Pt("closeWorkspace",e)}function Jp(...e){return Pt("recheckRemoteStorage",e)}function er(e,t){if(U)return U.triageSync[e](...t);ko(r=>{r.triageSync[e](...t)})}var D={get status(){return U?U.triageSync.status:"off"},get openSessions(){return U?U.triageSync.openSessions:[]},get persistenceDegraded(){return U?U.triageSync.persistenceDegraded:!1},get proxyAuthRequired(){return U?U.triageSync.proxyAuthRequired:!1},setEnabled(e){if(e===!0)return Ll().then(t=>{t.triageSync.setEnabled(!0);let r=Js;Js=[];for(let n of r)try{t.openWorkspace(n)}catch(o){console.warn(`client-sync: openWorkspace(${n}) failed during re-enable:`,o)}return null}).catch(t=>(console.warn("client-sync: setEnabled load failed:",t),null));if(U){Js=U.openWorkspaceIds();for(let t of Js)try{U.closeWorkspace(t)}catch(r){console.warn(`client-sync: closeWorkspace(${t}) failed during disable:`,r)}U.triageSync.setEnabled(!1);return}er("setEnabled",[e])},isEnabled(){return U?U.triageSync.isEnabled():Lp()},openSession(e){er("openSession",[e])},closeSession(e){er("closeSession",[e])},refreshSession(e){er("refreshSession",[e])},dismissError(e){er("dismissError",[e])},setForcedOff(e){er("setForcedOff",[e])},setServerUrl(e){er("setServerUrl",[e])},getServerUrl(){return U?U.triageSync.getServerUrl():null},notify(){er("notify",[])},onStatusChange(e){return ln(e,(t,r)=>t.triageSync.onStatusChange(r))},onPersistenceDegraded(e){return ln(e,(t,r)=>t.triageSync.onPersistenceDegraded(r))},onProxyAuthRequired(e){return ln(e,(t,r)=>t.triageSync.onProxyAuthRequired(r))}};var _o=class extends et{constructor(t){if(super(t),this.it=g,t.type!==Oe.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===g||t==null)return this._t=void 0,this.it=t;if(t===ue)return t;if(typeof t!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(t===this.it)return this._t;this.it=t;let r=[t];return r.raw=r,this._t={_$litType$:this.constructor.resultType,strings:r,values:[]}}};_o.directiveName="unsafeHTML",_o.resultType=1;var me=bt(_o);var Xp=`*,*:before,*:after{box-sizing:border-box;margin:0;padding:0}:host{width:260px;flex-shrink:0;height:100%;background:var(--surface);backdrop-filter:var(--glass-blur);border-right:1px solid var(--border);display:flex;flex-direction:column;transition:width .15s ease-out;overflow:hidden}:host(.collapsed){width:32px}:host(.empty){display:none}:host(.collapsed) .brand,:host(.collapsed) .sidebar-search,:host(.collapsed) #encryption-toggle,:host(.collapsed) #file-list{display:none}:host(.collapsed) .sidebar-header{padding:.5rem 0;justify-content:center}:host(.collapsed) .sidebar-actions{padding:.35rem 0;justify-content:center}:host(.collapsed) sidebar-delete-current,:host(.collapsed) #sync-status .sync-label{display:none}:host(.collapsed) #sync-status{padding:.25rem;border:0}.sidebar-header{display:flex;align-items:center;gap:.5rem;padding:.5rem .75rem .4rem;.brand{flex:1;min-width:0;display:flex;align-items:baseline;gap:.4rem;font-size:.95rem;font-weight:700;letter-spacing:-.01em;white-space:nowrap;overflow:hidden;user-select:none}.brand-button{background:transparent;border:0;padding:0;margin:0;font:inherit;color:inherit;border-radius:4px;&:focus-visible{outline:2px solid var(--accent);outline-offset:2px}}.brand-tag{font-size:.65rem;font-weight:500;color:var(--muted);text-transform:lowercase;letter-spacing:.02em}}@media(display-mode:window-controls-overlay){.sidebar-header{min-height:env(titlebar-area-height,0px);padding-left:max(.75rem,env(titlebar-area-x,0px));-webkit-app-region:drag;app-region:drag;.brand-button,#encryption-toggle{-webkit-app-region:no-drag;app-region:no-drag}#sidebar-toggle{display:none}}}#sidebar-toggle{flex-shrink:0;width:22px;height:22px;display:grid;place-items:center;background:transparent;color:var(--muted);border:0;border-radius:4px;padding:0;&:hover{color:var(--text);background:rgb(from var(--text) r g b / .06)}}#encryption-toggle{flex-shrink:0;width:22px;height:22px;display:grid;place-items:center;background:transparent;color:var(--muted);border:0;border-radius:4px;padding:0;&:hover{color:var(--text);background:rgb(from var(--text) r g b / .06)}&.encrypted{color:var(--accent)}&.locked-pending{color:light-dark(#b25b00,#f0a060);outline:1px dashed currentcolor;outline-offset:-2px}}.sidebar-search{display:flex;align-items:center;margin:0 .55rem .25rem;padding:0 .25rem 0 .55rem;background:rgb(from var(--text) r g b / .04);border:1px solid var(--border);border-radius:5px;transition:background .12s,border-color .12s;-webkit-app-region:no-drag;app-region:no-drag;&:has(input:focus){border-color:var(--accent);background:rgb(from var(--text) r g b / .06)}.sidebar-search-icon{flex-shrink:0;color:var(--muted);pointer-events:none;margin-right:.4rem}& input{flex:1;min-width:0;padding:.3rem 0;background:transparent;color:var(--text);border:0;outline:none;font:inherit;font-size:.78rem;&::placeholder{color:var(--muted)}&:focus::placeholder{color:transparent}&::-webkit-search-cancel-button{display:none}}}sidebar-view-button{display:contents}.sidebar-view-btn{position:relative;flex-shrink:0;width:20px;height:20px;display:grid;place-items:center;background:transparent;color:var(--muted);border:0;border-radius:3px;padding:0;margin-left:2px;transition:background .12s,color .12s;sidebar-view-button+sidebar-view-button>&{margin-left:.4rem}sidebar-view-button:last-of-type>&{margin-right:.1rem}& svg{width:14px;height:14px}&:hover{color:var(--text);background:rgb(from var(--text) r g b / .08)}&.active{color:var(--accent);background:rgb(from var(--text) r g b / .1)}.view-btn-count{position:absolute;top:-4px;right:-4px;background:var(--bg);color:var(--muted);font-size:8.5px;font-weight:600;border-radius:999px;padding:0 3px;min-width:11px;text-align:center;line-height:11px;font-variant-numeric:tabular-nums;pointer-events:none}&.active .view-btn-count{color:var(--accent)}}#file-list{list-style:none;flex:1;overflow-y:auto;overscroll-behavior:none;scrollbar-gutter:stable;-webkit-app-region:no-drag;app-region:no-drag;padding:0 .35rem .25rem 0;margin:0;scrollbar-width:thin;scrollbar-color:var(--border) transparent;&::-webkit-scrollbar{width:5px}&::-webkit-scrollbar-thumb{background:var(--border);border-radius:3px}}.file-group-header{display:flex;align-items:center;justify-content:space-between;padding:.45rem .35rem .2rem .55rem;font-size:.62rem;font-weight:700;text-transform:uppercase;letter-spacing:.12em;color:var(--muted);user-select:none;&:first-child{padding-top:.25rem}.group-count{font-weight:500;letter-spacing:.04em;color:var(--muted);font-size:.7rem}}.file-group-header.workspace-header .workspace-header-actions{display:flex;align-items:center;gap:.35rem}.workspace-add{width:18px;height:18px;display:grid;place-items:center;background:transparent;color:var(--muted);border:1px solid transparent;border-radius:4px;padding:0;&:hover{color:var(--text);border-color:var(--accent)}}.file-item.workspace-item{display:flex;align-items:stretch;gap:.15rem}.file-item.workspace-item button.file-name{flex:1;min-width:0}.file-item.workspace-item .workspace-count{align-self:center;margin-right:.35rem}.workspace-share,.workspace-export,.workspace-leave{flex-shrink:0;width:22px;align-self:center;height:22px;display:none;place-items:center;background:transparent;color:var(--muted);border:1px solid transparent;border-radius:4px;padding:0;&:hover:not(:disabled){color:var(--text);background:rgb(from var(--text) r g b / .06);border-color:var(--accent)}}.workspace-leave:hover:not(:disabled){color:var(--critical, #f87171);border-color:var(--critical, #f87171)}@media(hover:hover){.file-item.workspace-item:hover .workspace-share,.file-item.workspace-item:hover .workspace-export,.file-item.workspace-item:hover .workspace-leave{display:grid}}.workspace-rename-input{width:100%;box-sizing:border-box;background:var(--surface);color:var(--text);border:1px solid var(--accent);border-radius:3px;padding:0 .25rem;margin:-1px 0;font:inherit;font-size:.76rem;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;outline:none}.file-item{list-style:none;position:relative;&.hidden{display:none}}.file-item.current:after{content:"";position:absolute;left:0;top:50%;transform:translateY(-50%);width:3px;height:18px;background:var(--accent);border-radius:0 2px 2px 0;pointer-events:none}.file-item button.file-name{display:flex;align-items:center;gap:.5rem;width:100%;box-sizing:border-box;padding:.2rem .3rem .2rem .55rem;background:transparent;color:var(--text);border:1px solid transparent;border-radius:0 5px 5px 0;font-family:inherit;font-size:.78rem;text-align:left;&:hover{background:rgb(from var(--text) r g b / .04)}.file-icon{flex-shrink:0;color:var(--muted)}.file-label{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:.76rem;line-height:14.5px}}.file-item .file-count{flex-shrink:0;display:inline-flex;align-items:center;justify-content:center;color:var(--muted);opacity:.65;font-size:.68rem;font-weight:500;font-variant-numeric:tabular-nums}.workspace-count-missing{margin-left:2px;opacity:.55;font-style:italic}.file-item.current button.file-name{background:rgb(from var(--text) r g b / .05);border-color:var(--border);.file-icon,.file-count{color:var(--text)}}.file-item.indented button.file-name{padding-left:1.3rem}.file-item.indented:before{content:"";position:absolute;left:.85rem;top:0;bottom:0;width:1px;background:var(--border)}.file-item.bundle-missing>.file-name,.file-item.report-missing>.file-name{display:flex;align-items:center;gap:.5rem;padding:.2rem .3rem .2rem 1.4rem;color:var(--muted);font-size:.78rem;font-style:italic;cursor:help;.file-icon{flex-shrink:0;color:var(--muted);font-style:normal}.file-label{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:.76rem;line-height:14.5px}}:host-context(body.theme-pink) .workspace-rename-input,:host-context(body.theme-pink) .file-item button.file-name .file-label,:host-context(body.theme-pink) .file-item.bundle-missing .file-label,:host-context(body.theme-pink) .file-item.report-missing .file-label{font-family:inherit}.file-item.dragging button.file-name{opacity:.4}.file-item.workspace-item.drag-over button.file-name,.file-item.indented.drag-over button.file-name{background:rgb(from var(--accent) r g b / .12);border-color:var(--accent)}.file-group-header.drag-over{background:rgb(from var(--accent) r g b / .12);border-radius:4px}.sidebar-actions{padding:.35rem .55rem .45rem;border-top:1px solid var(--border);display:flex;gap:.35rem;align-items:center;justify-content:space-between;& button{background:transparent;border:1px solid var(--border);color:var(--muted);border-radius:4px;padding:.2rem .5rem;font-size:.72rem;font-family:inherit;-webkit-app-region:no-drag;app-region:no-drag;&:hover{color:var(--text);border-color:var(--accent)}&.danger:hover{color:var(--critical);border-color:var(--critical)}&[disabled]{opacity:.4;border-color:var(--border)!important;color:var(--muted)!important}}}sidebar-delete-current{display:contents}sidebar-delete-current button{display:inline-flex;align-items:center;gap:.35rem;.trash-icon{flex-shrink:0}}#sync-status{display:inline-flex;align-items:center;gap:.35rem;border-color:transparent;&:hover{border-color:var(--accent)}.sync-dot{width:8px;height:8px;border-radius:50%;background:var(--muted);flex-shrink:0;box-shadow:0 0 0 1px rgb(from var(--text) r g b / .15)}&[data-status=online] .sync-dot{background:var(--green)}&[data-status=connecting] .sync-dot{background:var(--medium)}&[data-status=offline] .sync-dot{background:var(--critical)}}#sync-status[data-proxy-auth] .sync-dot{box-shadow:0 0 0 2px var(--accent)}#sync-status[data-degraded] .sync-dot{box-shadow:0 0 0 2px var(--medium)}#sync-status[hidden]{display:none}
17
+ `;var Qp=`.file-icon.brand-deepview{.bg{fill:#2563eb}.fg{fill:#fff}}.file-icon.brand-claude{.bg{fill:#d97757}.fg{fill:#fff}}.file-icon.brand-codex{.bg{fill:#fff;stroke:#000;stroke-width:.5}.fg{fill:#000}}.file-icon.brand-vercel{.bg{fill:#000;stroke:#fff;stroke-width:.5}.fg{fill:#fff}}
18
+ `;var Zp=`*,*:before,*:after{box-sizing:border-box;margin:0;padding:0}dialog{margin-top:5rem;margin-inline:auto;border:1px solid var(--border);border-radius:10px;background:var(--surface);color:var(--text);padding:1.1rem 1.25rem 1rem;max-width:480px;width:min(94vw,480px);box-shadow:0 20px 60px #00000059;&::backdrop{background:rgb(from var(--theme-bar) r g b / .55);backdrop-filter:blur(2px)}}header h3{margin:0 0 .6rem;font-size:1rem;font-weight:600}.nwd-input{display:block;width:100%;box-sizing:border-box;padding:.5rem .65rem;border:1px solid var(--border);border-radius:6px;background:var(--bg, var(--surface));color:var(--text);font:inherit;font-size:.88rem;&:focus{outline:none;border-color:var(--accent);box-shadow:0 0 0 3px rgb(from var(--accent) r g b / .18)}&::placeholder{color:var(--muted)}}.nwd-note{margin:.55rem 0 0;color:var(--muted);font-size:.74rem;line-height:1.45}.nwd-intro{margin:0 0 .8rem;color:var(--muted);font-size:.82rem;line-height:1.5}.nwd-actions{display:flex;align-items:center;gap:.4rem;margin-top:.8rem;padding-top:.7rem;border-top:1px solid var(--border)}.nwd-spacer{flex:1}.nwd-actions button{background:transparent;border:1px solid var(--border);color:var(--text);border-radius:5px;padding:.35rem .9rem;font:inherit;font-size:.8rem;&:hover:not(:disabled){border-color:var(--accent);color:var(--accent)}&.primary{background:var(--accent);color:var(--surface);border-color:var(--accent);&:hover:not(:disabled){color:var(--surface);filter:brightness(1.08)}}&.danger{color:var(--critical, #f87171);border-color:var(--border);&:hover:not(:disabled){border-color:var(--critical, #f87171);color:var(--critical, #f87171)}}&:disabled{opacity:.5}}@media(display-mode:window-controls-overlay){dialog{-webkit-app-region:no-drag;app-region:no-drag}}
19
+ `;var F=class extends j{static styles=[B(Zp)];firstUpdated(){this.beforeOpen();let t=this.renderRoot.querySelector("dialog");if(t){try{t.showModal()}catch(r){this._settled=!0,this.dispatchEvent(new CustomEvent("modal-conflict",{detail:{cause:r}}));return}this.focusInitial()}}beforeOpen(){}focusInitial(){(this.renderRoot.querySelector("input, textarea")??this.renderRoot.querySelector("button.primary")??this.renderRoot.querySelector("button"))?.focus()}_finish(t){this._settled||(this._settled=!0,this.renderRoot.querySelector("dialog")?.close(),this.dispatchEvent(new CustomEvent("resolve",{detail:t})))}_onClose=()=>this._finish(null)};function Q(e,t={}){return new Promise(r=>{let n=document.createElement(e);Object.assign(n,t),n.addEventListener("resolve",o=>{n.remove(),r(o.detail)}),document.body.append(n)})}var nt=`dialog{max-width:520px;width:min(94vw,520px)}.wsl-field{display:block;margin-top:.6rem;color:var(--text);font-size:.78rem;>span{display:block;margin-bottom:.25rem;color:var(--muted);font-size:.72rem;text-transform:uppercase;letter-spacing:.04em}}.wsl-ack{display:flex;align-items:flex-start;gap:.5rem;margin-top:.6rem;color:var(--text);font-size:.8rem;line-height:1.4;>input[type=checkbox]{flex:0 0 auto;margin-top:.15rem}>span{flex:1 1 auto}}.wsl-link{display:block;width:100%;box-sizing:border-box;padding:.5rem .65rem;border:1px solid var(--border);border-radius:6px;background:var(--bg, var(--surface));color:var(--text);font:inherit;font-size:.78rem;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;resize:vertical;word-break:break-all}.wsl-error{margin:.55rem 0 0;color:var(--critical, #f87171);font-size:.74rem;line-height:1.4}.wsl-warning{padding:.55rem .65rem;border:1px solid var(--critical, #f87171);border-radius:6px;background:rgb(from var(--critical, #f87171) r g b / .08)}.wsl-optout{display:flex;align-items:center;gap:.5rem;margin-top:.7rem;color:var(--text);font-size:.78rem}.nwd-input:disabled{opacity:.5}
20
+ `;var Nl=class extends F{static styles=[...F.styles,B(nt)];static properties={_userName:{state:!0},_busy:{state:!0},_error:{state:!0},_phase:{state:!0},_success:{state:!0},_orphan:{state:!0},_orphanAck:{state:!0},_canCancel:{state:!0}};constructor(){super(),this._userName="",this._busy=!1,this._error="",this._phase="",this._success=!1,this._orphan=!1,this._orphanAck=!1,this._canCancel=!0,this._abortController=null}updated(t){if(t.has("_success")&&this._success){let r=this.renderRoot.querySelector("footer button.primary");r&&r.focus()}}beforeOpen(){typeof location<"u"&&(this._userName=location.hostname||"DeepView"),this._orphan=Kn(),this._vaultStateUnsub=ve(()=>{if(this._settled)return;let t=Kn();this._orphan&&!t&&ne()?(this._error="Encryption was just enabled in another tab. Close this dialog and reload to unlock.",this._busy=!1,this._canCancel=!0):this._orphan!==t&&(this._orphan=t)})}async focusInitial(){await this.updateComplete;let t=this._orphan?'input[data-role="orphan-ack"]':'input[data-role="name"]';this.renderRoot.querySelector(t)?.focus()}disconnectedCallback(){if(super.disconnectedCallback(),this._vaultStateUnsub){try{this._vaultStateUnsub()}catch{}this._vaultStateUnsub=null}}_finish(t){if(!this._settled){if(this._abortController)try{this._abortController.abort()}catch{}super._finish(!!t)}}_onClose=()=>this._finish(this._success);_onCancel=()=>{this._busy&&!this._canCancel||this._finish(!1)};_onDialogCancel=t=>{if(this._busy&&!this._canCancel){t.preventDefault();return}this._finish(!1)};_onNameInput=t=>{this._userName=t.target.value};_onOrphanAckInput=t=>{this._orphanAck=t.target.checked};_onWipeOrphan=async()=>{if(!this._busy&&this._orphanAck){if(ne()){this._error="Encryption was just enabled in another tab. Reload this page to unlock.";return}this._busy=!0,this._canCancel=!1,this._error="",this._phase="Clearing previous vault state\u2026";try{await Yn({refuseIfEnabled:!0}),location.reload()}catch(t){this._error=`Could not clear previous vault state: ${t?.message??t}`,this._phase=""}finally{this._busy=!1,this._canCancel=!0}}};_onEnable=async()=>{if(!this._busy){if(!kt()){this._error="Passkeys are not supported in this browser.";return}this._busy=!0,this._canCancel=!0,this._error="",this._phase="Registering passkey\u2026",this._abortController=new AbortController;try{await ba({userName:this._userName.trim()||"DeepView user",rpName:"DeepView",signal:this._abortController.signal,migrate:async({seal:r})=>{this._canCancel=!1,this._phase="Encrypting workspaces and metadata\u2026",await ua({seal:r}),this._phase="Encrypting triage data\u2026",await wl({seal:r}),this._phase="Encrypting report files\u2026",await Ra({seal:r}),this._phase="Encrypting bundles\u2026",await Ba({seal:r})}})&&(this._success=!0,this._phase="")}catch(t){t?.name==="AbortError"?this._error="":this._error=t?.message??String(t),this._phase=""}finally{this._busy=!1,this._canCancel=!0,this._abortController=null}}};_body(){if(this._orphan)return c`<p class="wsl-error">DeepView found an abandoned passkey setup on this device. The original passkey can no longer be accessed, so any local data still encrypted under it is <strong>unreadable</strong> and cannot be recovered.</p><p class="nwd-note">To enable encryption, DeepView will <strong>permanently delete ALL local DeepView data on this device</strong> — including any plaintext workspaces or reports you may have added after the previous passkey was lost — and then register a fresh passkey. This is irreversible. There is no backup.</p><label class="wsl-ack"><input type="checkbox" data-role="orphan-ack" .checked="${this._orphanAck}" ?disabled="${this._busy}" @change="${this._onOrphanAckInput}"> <span>I understand all local DeepView data on this device will be deleted.</span></label> ${this._phase?c`<p class="nwd-note">${this._phase}</p>`:g} ${this._error?c`<p class="wsl-error">${this._error}</p>`:g}<footer class="nwd-actions"><span class="nwd-spacer"></span> <button type="button" ?disabled="${this._busy&&!this._canCancel}" @click="${this._onCancel}">Cancel</button> <button type="button" class="primary" ?disabled="${this._busy||!this._orphanAck}" @click="${this._onWipeOrphan}">${this._busy?"Working\u2026":"Wipe and continue"}</button></footer>`;if(this._success)return c`<p class="nwd-note"><strong>Encryption is on.</strong> Your triage data and report files are now sealed under your passkey. You'll be asked to unlock with the passkey on every fresh load.</p><footer class="nwd-actions"><span class="nwd-spacer"></span> <button type="button" class="primary" @click="${()=>this._finish(!0)}">Close</button></footer>`;let t=kt();return c`<p class="nwd-note">Passkey encryption protects your local triage and report data with a hardware-backed key (TouchID, Windows Hello, security key). Without the passkey, the data on disk is unreadable — even to scripts running on this origin.</p><p class="wsl-error"><strong>If you lose access to this passkey, your data CANNOT be recovered.</strong> DeepView has no backup key, no recovery code, and no escrow. Make sure your passkey is backed up (iCloud Keychain / Google Password Manager sync, or a second registered device) before relying on encryption for important data.</p><p class="nwd-note"><strong>Opt-in.</strong> You can disable encryption later from the lock icon in the sidebar header — the data is rewritten as plaintext and DeepView signals your authenticator to remove the passkey (where supported).</p>${t?g:c`<p class="wsl-error">Your browser doesn't expose the WebAuthn passkey API. Try Chrome, Safari, Edge, or Firefox in a recent version on a device with a platform authenticator.</p>`} <label class="wsl-field"><span>Passkey label</span> <input type="text" class="nwd-input" data-role="name" placeholder="DeepView" maxlength="200" .value="${this._userName}" @input="${this._onNameInput}"></label> ${this._phase?c`<p class="nwd-note">${this._phase}</p>`:g} ${this._error?c`<p class="wsl-error">${this._error}</p>`:g}<footer class="nwd-actions"><span class="nwd-spacer"></span> <button type="button" ?disabled="${this._busy&&!this._canCancel}" @click="${this._onCancel}">Cancel</button> <button type="button" class="primary" ?disabled="${!t||this._busy}" @click="${this._onEnable}">${this._busy?"Working\u2026":"Enable encryption"}</button></footer>`}render(){return c`<dialog @close="${this._onClose}" @cancel="${this._onDialogCancel}"><header><h3>${this._success?"Encryption enabled":this._orphan?"Previous passkey setup detected":"Enable passkey encryption"}</h3></header>${this._body()}</dialog>`}};customElements.define("passkey-setup-dialog",Nl);function ti(){return Q("passkey-setup-dialog")}var Dl=class extends F{static styles=[...F.styles,B(nt)];static properties={_busy:{state:!0},_error:{state:!0}};constructor(){super(),this._busy=!1,this._error="",this._abortController=null}_finish(t){if(!this._settled){if(this._abortController)try{this._abortController.abort()}catch{}super._finish(!!t)}}_onCancel=()=>this._finish(!1);_onUnlock=async()=>{if(!this._busy){this._busy=!0,this._error="",this._abortController=new AbortController;try{if(await qn({signal:this._abortController.signal})){this._finish(!0);return}this._error=""}catch(t){this._error=t?.message??String(t)}finally{this._busy=!1,this._abortController=null}}};render(){return c`<dialog @close="${this._onClose}"><header><h3>Unlock your data</h3></header><p class="nwd-note">Your triage data and report files are encrypted with a passkey on this device. Unlock to load them.</p>${this._error?c`<p class="wsl-error">${this._error}</p>`:g}<footer class="nwd-actions"><span class="nwd-spacer"></span> <button type="button" @click="${this._onCancel}">${this._busy?"Cancel":"Later"}</button> <button type="button" class="primary" ?disabled="${this._busy}" @click="${this._onUnlock}">${this._busy?"Waiting\u2026":"Unlock with passkey"}</button></footer></dialog>`}};customElements.define("passkey-unlock-dialog",Dl);function ri(){return Q("passkey-unlock-dialog")}var ef=c`<svg viewBox="0 0 16 16" width="13" height="13" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3" y="8" width="10" height="6" rx="1"/><path d="M5 8V5.5a3 3 0 0 1 6 0V8"/></svg>`,Ky=c`<svg viewBox="0 0 16 16" width="13" height="13" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3" y="8" width="10" height="6" rx="1"/><path d="M5 8V5a3 3 0 0 1 6 -0.5"/></svg>`,Te=null;function tf(){if(!Te)return;if(!kt()){Te.hidden=!0;return}Te.hidden=!1;let e=ne(),t=pt();Te.classList.toggle("encrypted",e&&t),Te.classList.toggle("locked-pending",e&&!t),e&&t?(Te.title="Encryption on \u2014 click to disable",Te.setAttribute("aria-label","Disable encryption"),q(ef,Te)):e?(Te.title="Encryption on, locked \u2014 click to unlock",Te.setAttribute("aria-label","Unlock encrypted data"),q(ef,Te)):(Te.title="Encryption off \u2014 click to enable",Te.setAttribute("aria-label","Enable encryption"),q(Ky,Te))}async function Gy(){if(confirm(`Disable encryption?
21
21
 
22
22
  Your local triage and report data will be rewritten as plaintext.
23
23
 
24
- IMPORTANT: DeepView cannot directly delete your passkey. Most browsers / password managers require you to remove the entry manually after disabling. You can re-enable encryption later.`))try{(await oa({migrate:async({open:t})=>{await Qi({open:t}),await sl({open:t}),await ya({open:t}),await va({open:t})}}))?.disabled&&alert(`Encryption disabled. Your data is now plaintext.
24
+ IMPORTANT: DeepView cannot directly delete your passkey. Most browsers / password managers require you to remove the entry manually after disabling. You can re-enable encryption later.`))try{(await ya({migrate:async({open:t})=>{await pa({open:t}),await vl({open:t}),await Fa({open:t}),await Ma({open:t})}}))?.disabled&&alert(`Encryption disabled. Your data is now plaintext.
25
25
 
26
26
  To complete cleanup, remove the DeepView passkey from your password manager / OS settings:
27
27
  \u2022 macOS / iOS: Settings \u2192 Passwords
28
28
  \u2022 Windows: Settings \u2192 Accounts \u2192 Sign-in options \u2192 Passkeys
29
29
  \u2022 Chrome: chrome://settings/passkeys
30
- \u2022 Hardware security key: use the vendor's management tool`)}catch(e){alert(`Could not disable encryption: ${e?.message??e}`)}}async function fy(){await Us()}function Pp(e){if(!e||e===Ee)return;Ee=e;let t=!1;Ee.addEventListener("click",async()=>{if(!t){t=!0;try{if(!Q()){await fy();return}if(!ct()){await zs();return}await py()}finally{t=!1}}}),ve(Lp),Lp()}var Ws='<path class="bg" d="M3 2h6l4 4v8H3z"/><path fill="rgba(0,0,0,.18)" d="M9 2v4h4Z"/>',X={default:`<svg class="file-icon brand-deepview" viewBox="0 0 16 16" width="14" height="14" aria-hidden="true">${Ws}<path class="fg" d="M7.843 6.719c-1.605 0-2.926 1.292-3.477 1.947.466.58 1.872 2.024 3.496 2.024s2.907-1.292 3.486-2.005c-.627-.703-1.88-1.966-3.505-1.966m.019 3.857c-1.51 0-2.802-1.263-3.353-1.9.55-.617 1.814-1.852 3.334-1.852 1.51 0 2.698 1.12 3.335 1.852-.533.618-1.787 1.9-3.316 1.9m-.019-3.42c-.826 0-1.577.694-1.577 1.596 0 .789.599 1.577 1.577 1.577.893 0 1.587-.684 1.587-1.577-.01-.779-.627-1.596-1.587-1.596m0 3.069a1.476 1.476 0 0 1-1.482-1.473c0-.722.599-1.491 1.482-1.491.846 0 1.482.693 1.492 1.491 0 .808-.618 1.473-1.492 1.473m.01-2.727c-.637 0-1.264.532-1.264 1.244 0 .627.475 1.235 1.245 1.245.684 0 1.254-.522 1.254-1.244 0-.58-.475-1.236-1.235-1.245m-.02 2.403a1.167 1.167 0 0 1-1.149-1.159c0-.532.456-1.14 1.169-1.149.56 0 1.149.427 1.159 1.15 0 .636-.485 1.158-1.179 1.158m-.769-1.833c-.19.238-.275.494-.237.864l.74.057zm1.026-.294c-.295-.057-.665 0-.912.228l.323.607zm.133.047-.38.56.988.114c-.057-.275-.323-.579-.608-.674m-.124.741.456.912c.21-.209.352-.484.314-.836zm-1.225.504a.97.97 0 0 0 .57.617l.399-.551zm.713.664c.313.076.636.01.845-.161l-.295-.618zm-.637 1.55c0 .028-.028.066-.066.066h-.59c-.028 0-.066-.028-.066-.066s.029-.066.067-.066h.579c.048 0 .076.028.076.066m.712 0c0 .028-.028.066-.066.066h-.437c-.028 0-.066-.028-.066-.066s.028-.066.066-.066h.437c.038 0 .066.028.066.066m.666 0c0 .028-.029.066-.067.066h-.37c-.029 0-.067-.028-.067-.066s.029-.066.067-.066h.37c.038 0 .067.028.067.066m-1.672.351c0 .029-.029.067-.067.067h-.295c-.028 0-.066-.028-.066-.066 0-.029.029-.067.067-.067h.294c.038 0 .066.028.066.066m.694 0c0 .029-.028.067-.066.067h-.409c-.028 0-.066-.028-.066-.066 0-.029.028-.067.066-.067h.399c.038 0 .076.028.076.066m.732 0c0 .029-.029.067-.067.067h-.465c-.029 0-.067-.028-.067-.066 0-.029.029-.067.067-.067h.465c.038 0 .067.028.067.066m-1.093.371a.065.065 0 0 1-.067.066h-.627c-.028 0-.075-.028-.066-.066 0-.028.029-.066.067-.066h.627c.038 0 .066.028.066.066m.684 0a.065.065 0 0 1-.066.066h-.39c-.028 0-.076-.028-.066-.066 0-.028.028-.066.066-.066h.39c.038 0 .066.028.066.066M5.088 6.263c-.019-.105-.114-.19-.237-.19s-.257.104-.257.237.105.238.247.238c.105 0 .218-.076.238-.18h.864v.826l.095-.048V6.31c0-.028-.019-.057-.048-.057h-.902zm-.237.19c-.076 0-.143-.066-.143-.143s.066-.142.143-.142.142.066.142.143c.01.076-.066.142-.143.142m2.89-.323H6.38l.418-.475v-.332a.255.255 0 0 0 .218-.248c0-.123-.114-.256-.256-.256s-.266.114-.266.257c0 .123.095.228.209.247v.284l-.456.523v.893l.095-.047v-.742h1.396c.029 0 .067-.009.067-.057 0-.028-.019-.047-.067-.047m-1.13-1.054c0-.076.066-.152.152-.152s.152.066.152.151c0 .076-.066.152-.152.152s-.152-.066-.152-.152m-.836 5.264h-.874c-.019-.105-.114-.219-.247-.219s-.256.105-.256.257c0 .132.114.275.266.275.104 0 .218-.076.237-.19h.827v.608l-.257.285a.3.3 0 0 0-.095-.019c-.133 0-.256.105-.256.228 0 .133.104.238.237.238.124 0 .247-.105.247-.238a.23.23 0 0 0-.057-.152l.285-.304v-.712c0-.029-.019-.058-.057-.058m-1.121.219a.16.16 0 0 1-.152-.161c0-.077.066-.162.152-.162s.152.066.152.152-.066.171-.152.171m.713 1.14c-.076 0-.143-.066-.143-.143s.066-.133.143-.133.142.067.142.143c0 .066-.066.133-.143.133m5.472-1.377a.24.24 0 0 0-.237.208h-1.13c-.029 0-.038.02-.038.048v.712l-.323.39h-.029a.245.245 0 0 0-.247.247c0 .133.114.256.247.256s.247-.113.247-.256a.26.26 0 0 0-.123-.219l.313-.38v-.674h1.083c.019.105.114.2.238.2.133 0 .266-.105.266-.257 0-.133-.105-.276-.266-.276m-1.758 1.767a.15.15 0 0 1-.143-.152c0-.075.067-.142.143-.142s.152.066.152.143a.15.15 0 0 1-.152.151m1.758-1.33a.15.15 0 0 1-.143-.152.147.147 0 0 1 .294.001.15.15 0 0 1-.152.151M8.917 5.55h-.399a.075.075 0 0 1-.076-.076c0-.028.029-.066.067-.066h.418c.028 0 .066.028.066.066s-.038.076-.076.076m.742 0H9.22c-.038 0-.067-.028-.067-.076 0-.028.029-.066.067-.066h.437c.038 0 .066.028.066.066s-.028.076-.066.076m.883 0h-.598c-.029 0-.067-.028-.067-.076 0-.028.029-.066.067-.066h.598c.028 0 .066.028.066.066s-.028.076-.066.076m-1.282.4h-.741c-.038 0-.076-.029-.076-.067s.028-.076.066-.076h.75c.039 0 .067.038.067.076 0 .029-.028.067-.066.067m.797 0h-.503c-.038 0-.076-.029-.076-.067s.028-.066.066-.066h.513c.038 0 .067.028.067.066 0 .029-.029.067-.067.067m.476 0h-.19c-.039 0-.067-.029-.067-.067s.028-.066.066-.066h.2c.028 0 .066.028.066.066 0 .029-.028.067-.075.067m-1.682.398h-.332c-.039 0-.077-.028-.077-.066s.029-.066.067-.066h.342c.038 0 .076.028.076.066s-.028.066-.076.066m.789 0h-.494c-.038 0-.067-.028-.067-.066s.029-.066.067-.066h.494c.038 0 .066.028.066.066s-.028.066-.066.066m.893 0h-.599c-.038 0-.076-.028-.076-.066s.028-.066.066-.066h.618c.028 0 .066.028.066.066s-.028.066-.076.066m.418.305a.69.69 0 0 0-.674.712c0 .086.019.18.048.257l.085.066c-.028-.085-.057-.171-.057-.304 0-.285.228-.646.598-.646.295 0 .599.228.599.636a.58.58 0 0 1-.599.59.8.8 0 0 1-.237-.048l.123.114a.4.4 0 0 0 .114.01c.39 0 .684-.276.684-.666 0-.313-.266-.712-.684-.722m.353.552-.019-.01-.161.19-.143-.01-.057-.047-.019-.133.19-.2a.28.28 0 0 0-.361.077c-.076.095-.076.209-.038.351l-.247.304.171.152.266-.266c.142.038.285.019.38-.095a.31.31 0 0 0 .038-.313"/></svg>`,"claude-security":`<svg class="file-icon brand-claude" viewBox="0 0 16 16" width="14" height="14" aria-hidden="true">${Ws}<path class="fg" d="m5.875 10.154 1.376-.772.023-.067-.023-.037h-.067l-.23-.015-.787-.02-.681-.03-.661-.035-.166-.035-.156-.205.016-.103.14-.094.2.018.442.03.665.046.481.028.714.075h.113l.016-.047-.039-.028-.03-.028-.687-.466-.744-.492-.39-.284-.21-.143-.106-.135-.046-.294.19-.21.258.017.065.018.26.2.557.43.726.535.106.089.042-.03.006-.022-.048-.08-.395-.713-.422-.726-.187-.301-.05-.18a1 1 0 0 1-.03-.213l.218-.296.12-.039.29.039.123.106.18.413.293.65.453.884.133.262.07.242.027.075h.046v-.043l.038-.497.069-.611.067-.787.023-.221.11-.266.218-.143.17.081.14.2-.02.13-.083.54-.163.846-.106.567h.062l.07-.07.287-.382.482-.602.213-.239.248-.264.159-.125h.301l.221.329-.099.34-.31.393-.256.333-.369.496-.23.397.021.032.055-.006.832-.177.45-.081.537-.092.243.113.026.115-.096.236-.573.141-.673.135-1.003.237-.012.01.014.017.452.042.193.01h.473l.88.066.23.153.138.186-.023.141-.354.181-.478-.113-1.116-.266-.383-.096h-.053v.032l.32.312.584.528.731.68.037.168-.094.133-.099-.014-.643-.484-.248-.218-.561-.472H9.08v.05l.129.189.684 1.027.035.315-.05.103-.177.062-.194-.036-.4-.561-.413-.632-.333-.567-.041.023-.197 2.116-.092.108-.212.082-.177-.135-.094-.218.094-.43.113-.561.092-.447.083-.554.05-.184-.004-.013-.04.006-.418.574-.636.858-.503.539-.12.048-.21-.108.02-.193.117-.172.696-.886.42-.549.27-.317-.001-.046h-.016l-1.85 1.201-.328.042-.142-.132.018-.218.067-.071.556-.383Z"/></svg>`,"codex-security":`<svg class="file-icon brand-codex" viewBox="0 0 16 16" width="14" height="14" aria-hidden="true">${Ws}<path class="fg" d="M11.04 8.364a1.72 1.72 0 0 0-.152-1.432 1.8 1.8 0 0 0-1.925-.846 1.8 1.8 0 0 0-.778-.498 1.8 1.8 0 0 0-.927-.05 1.8 1.8 0 0 0-.827.414 1.77 1.77 0 0 0-.507.767 1.8 1.8 0 0 0-.683.297 1.75 1.75 0 0 0-.499.549 1.75 1.75 0 0 0 .22 2.07 1.72 1.72 0 0 0 .151 1.432 1.8 1.8 0 0 0 1.926.846 1.77 1.77 0 0 0 1.333.587c.78 0 1.47-.496 1.707-1.227a1.8 1.8 0 0 0 .684-.298 1.75 1.75 0 0 0 .499-.548 1.75 1.75 0 0 0-.222-2.063m-2.667 3.678a1.33 1.33 0 0 1-.851-.304l.042-.024 1.413-.804a.23.23 0 0 0 .116-.199V8.747l.597.34q.01.005.011.015v1.629a1.323 1.323 0 0 1-1.328 1.31m-2.857-1.203a1.3 1.3 0 0 1-.158-.879l.042.025 1.414.805a.23.23 0 0 0 .23 0l1.729-.982v.68a.02.02 0 0 1-.01.018l-1.431.814a1.34 1.34 0 0 1-1.816-.48m-.372-3.037a1.32 1.32 0 0 1 .7-.574v1.656a.22.22 0 0 0 .114.197l1.72.979-.598.34a.02.02 0 0 1-.021 0L5.63 9.587a1.304 1.304 0 0 1-.487-1.791zm4.907 1.125L8.327 7.94l.596-.34a.02.02 0 0 1 .02 0l1.43.814a1.3 1.3 0 0 1 .512.528 1.3 1.3 0 0 1-.118 1.4 1.33 1.33 0 0 1-.595.436V9.122a.23.23 0 0 0-.12-.195m.594-.881-.042-.025-1.411-.812a.23.23 0 0 0-.232 0l-1.727.983v-.68a.02.02 0 0 1 .008-.018l1.429-.813a1.34 1.34 0 0 1 1.425.061 1.3 1.3 0 0 1 .55 1.298zM6.908 9.252l-.597-.34a.02.02 0 0 1-.012-.016V7.271c0-.249.073-.493.209-.703s.329-.378.557-.483a1.35 1.35 0 0 1 1.415.18l-.042.023-1.413.804a.23.23 0 0 0-.116.2zm.324-.69.77-.438.77.438v.875l-.768.437-.77-.437z"/></svg>`,deepsec:`<svg class="file-icon brand-vercel" viewBox="0 0 16 16" width="14" height="14" aria-hidden="true">${Ws}<path class="fg" d="m8 5.97 3.5 6.062h-7Z"/></svg>`};function Ye(e){let t=Gn(e);if(t==="deepsec")return"deepsec";if(t==="claude-security")return"claude-security";let r=e.toLowerCase();return r.endsWith(".codex")?"codex-security":r.endsWith(".md")?"claude-security":"default"}function Me(e){return e.toLowerCase().endsWith(".codex")?e.slice(0,-6).replaceAll("__","/"):e}var Op=globalThis[Symbol.for("@rray/frontend")];if(!Op)throw new Error("@rray/frontend global not installed; view.js must run before lazy bundles import this wrapper");var{LitElement:H_,html:Sl,nothing:Np,unsafeCSS:j_,render:V_,StateElement:K_,classMap:G_,repeat:q_,styleMap:Y_}=Op;var Je={critical:6,high:5,medium:4,low:3,high_bug:2,bug:1,informational:0},ke=["critical","high","medium","low","high_bug","bug","informational"],Hs="node_modules";function Dp(e){let t=n=>/(^|\/)node_modules\//u.test(n),r=!1;e:for(let n of e){for(let o of n.groups??[])for(let s of o)if(t(s.file)){r=!0;break e}if(n.tree){for(let o of Object.keys(n.tree))if(t(o)){r=!0;break e}}}Hs=r?"node_modules":"dependencies"}function Up(){return Hs}function er(e){return Hs==="node_modules"?/(^|\/)node_modules\//u.test(e):/(^|\/)dependencies\//u.test(e)}function ne(e){return typeof e!="number"||!Number.isFinite(e)?null:`${e.toLocaleString()} B`}function Xe(e){if(e.length<=1)return{prefix:"",stripped:[...e]};let t=e.map(i=>i.split("/")),r=Math.min(...t.map(i=>i.length)),n=0;for(let i=0;i<r-1&&t.every(l=>l[i]===t[0][i]);i++)n=i+1;if(n>0&&t[0][n-1].startsWith("@")&&n--,n>0&&t[0][n-1]==="node_modules"&&n--,n===0)return{prefix:"",stripped:[...e]};let o=`${t[0].slice(0,n).join("/")}/`,s=t.map(i=>i.slice(n).join("/"));return{prefix:o,stripped:s}}function hy(e){let t=Hs==="node_modules"?/^(?:.*\/)?node_modules\/(?:@[^/]+\/[^/]+|[^/]+)\/(.*)$/u:/^(?:.*\/)?dependencies\/(?:@[^/]+\/[^/]+|[^/]+)\/(.*)$/u;return e.match(t)?.[1]??e}function st(e,t){if(!e)return e;let r=e;t?.exportsMode==="isolate"&&(r=r.replace(/^\((?:[^()]|\([^()]*\))*\): \[export:\s*\w+\] /u,""),r=r.replace(/^\[export:\s*\w+\] /u,""));let n=[t?.exportName,t?.methodName].filter(Boolean);for(let o of n){let s=o.replaceAll(/[.*+?^${}()|[\]\\]/gu,"\\$&");r=r.replaceAll(new RegExp(`\\[export:\\s*${s}\\]\\s*`,"gu"),"")}for(let o of n){let s=o.replaceAll(/[.*+?^${}()|[\]\\]/gu,"\\$&");r=r.replace(new RegExp(`^\\(\`?${s}\`?\\): `,"u"),"")}return r}function $r(e){let t=e?.exportName,r=e?.methodName;return t&&r&&t!==r?`${t}.${r}`:t||r||""}function zp(e){return[e.file,e.description,e.recommendation,e.confidenceReason,e.discoveredIn,e.repo?.github].filter(Boolean).join(`
31
- `).toLowerCase()}function Cl(e){return e&&e.replace(/^[^/]+\//u,"").replace(/^claude-/u,"").replaceAll("-"," ")}function xr(e){return[e.type,Cl(e.model),e.effort,e.exportsMode].filter(Boolean).join(" \xB7 ")}function js(e){if(e.length===0)return"";let t=e[0];for(let r=1;r<e.length;r++){for(;t&&!e[r].startsWith(t);)t=t.slice(0,-1);if(!t)return""}return t}function Wp(e){if(!e)return null;let t=e.trim().replace(/\/$/u,"");return t?/^https?:\/\//iu.test(t)?t:/^github\.com\//iu.test(t)?`https://${t}`:`https://github.com/${t}`:null}function tn(e,t,r){if(t)return`https://github.com/${t}/blob/HEAD/${hy(e)}`;if(er(e))return null;let n=Wp(r);return n?`${n}/blob/HEAD/${e}`:null}function El(e,t,r){let n=tn(e,t,r);return n?Sl`<a href="${n}" target="_blank" rel="noopener">${e}</a>`:e}function rn(e){if(typeof e!="string"||e.length===0)return!1;try{let t=new URL(e);return t.protocol==="http:"||t.protocol==="https:"}catch{return!1}}function Hp(e,t,r,n){let o=parseInt(t,10);if(!Number.isFinite(o))return Np;let s=tn(e,r,n),i=`line ${o}`;return s?Sl`<a href="${`${s}#L${o}`}" target="_blank" rel="noopener">${i}</a>`:i}function jp(e,t){return!e||!t?null:`${/^https?:/iu.test(e)?e.replace(/\/$/u,""):`https://github.com/${e}`}/commit/${t}`}function Vp(e,t){let r=[];return t&&r.push(`Repo: ${t}`),e.file&&r.push(`File: ${e.file}`),e.line!==void 0&&e.line!==null&&e.line!==""&&r.push(`Line: ${e.line}`),e.description&&r.push(`Description: ${e.description}`),e.confidence!==void 0&&e.confidence!==null&&r.push(`Confidence: ${e.confidence}/10`),r.join(`
32
- `)}function Kp(e,{title:t,body:r}={}){let n=Wp(e);if(!n)return null;let o;try{o=new URL(n).host.toLowerCase()}catch{return null}if(o!=="github.com")return null;let s=new URLSearchParams;t&&s.set("title",t),r&&s.set("body",r);let i=s.toString();return i?`${n}/issues/new?${i}`:`${n}/issues/new`}function O(e){return e.id??String(e._id)}function Ae(e){return O(e[0])}function Al(e){return Array.isArray(e)?e:[e]}function Vs(e){return e?._reportName??""}function nn(e){return Bt(a.triage,O(e),Vs(e))}function uo(e){return[...e].toSorted((t,r)=>{let n=a.triage.get(O(t))?.color?1:0,o=a.triage.get(O(r))?.color?1:0;if(n!==o)return o-n;let s=Je[t.severity]||0,i=Je[r.severity]||0;if(s!==i)return i-s;let l=t.confidence??-1;return(r.confidence??-1)-l})}function We(e){return uo(e)[0]}function Te(e){let t=a.activeTabByGroup.get(Ae(e));if(t){let r=e.find(n=>O(n)===t);if(r)return r}return We(e)}function Ks(e){for(let t of kt().values())if(t.files.has(e.file))return t.repos&&t.repos.size===1?[...t.repos][0]:null;return e.repo?.github??e._repoFallback??a.repoUrl??null}function $e(e){let t=e.map(f=>{let h=O(f),b=a.triage.get(h),m=b?.triage??(nn(f)?"ignored":void 0);return{color:b?.color,bucket:m}}).filter(f=>f.color!==void 0||f.bucket!==void 0),r=new Set(t.map(f=>f.color).filter(f=>f!==void 0)),n=Symbol("none"),o=new Set(t.map(f=>f.bucket??n)),s=r.size>1||o.size>1,i=!s&&r.size===1?[...r][0]:null,l=t.map(f=>f.bucket).filter(Boolean),d=l.some(f=>f!=="ignored"),u=t.length>0&&t.every(f=>!!f.bucket&&f.bucket!=="ignored"),p=!s&&l.length>0?l[0]:null;return{hasConflict:s,commonColor:i,anyTriage:d,allTriaged:u,commonTriage:p,isInProgress:p==="inprogress",isFixed:p==="fixed",isInvalid:p==="invalid",isDeleted:p==="deleted",isIgnored:p==="ignored"}}function Pt(){let e=a.reports.flatMap(d=>d.groups),t=a.workspaceMerges;if(!t||t.length===0)return e;let r=e.map((d,u)=>u),n=d=>{let u=d;for(;r[u]!==u;)u=r[u];for(;r[d]!==u;){let p=r[d];r[d]=u,d=p}return u},o=(d,u)=>{let p=n(d),f=n(u);p!==f&&(r[p]=f)},s=new Map;for(let d=0;d<e.length;d++)for(let u of e[d])u.id&&s.set(u.id,d);for(let d of t){let u=-1;for(let p of d){let f=s.get(p);f!==void 0&&(u===-1?u=f:o(u,f))}}let i=new Set,l=[];for(let d=0;d<e.length;d++){let u=n(d);if(i.has(u))continue;i.add(u);let p=[];for(let w=d;w<e.length;w++)n(w)===u&&p.push(...e[w]);let f=new Set(p.map(w=>w.id).filter(Boolean)),h=[],b=new Set;for(let w of t)for(let v of w)b.has(v)||f.has(v)&&(h.push(v),b.add(v));if(h.length===0){l.push(p);continue}let m=new Map;for(let w of p)w.id&&!m.has(w.id)&&m.set(w.id,w);let y=new Set,k=[];for(let w of h){let v=m.get(w);v&&(k.push(v),y.add(v))}for(let w of p)y.has(w)||k.push(w);l.push(k)}return l}function _r(e){for(let t of Pt())if(Ae(t)===e)return t;return null}var po="\0",fo="";function Tl(e){return typeof e.repo?.github=="string"&&e.repo.github?e.repo.github:typeof e._repoFallback=="string"&&e._repoFallback?e._repoFallback:null}function Gs(){a.filterSeverities=new Set,a.filterColors=new Set,a.filterSources=new Set,a.filterAnalyzer="",a.filterRepo="",a.filterConfMin=0,a.filterConfMax=10,a.filterInclude="",a.filterIncludeNegate=!1,a.filterComment="",a.filterFix="",a.filterFlagged="";let e=a.reports.some(t=>t.groups.some(r=>r.some(n=>n.priority!==void 0)));a.sortBy=e?"priority-desc":"severity"}function gy(e){let t=a.filterInclude.toLowerCase();if(a.filterSeverities.size>0&&!a.filterSeverities.has(e.severity))return!1;if(a.filterColors.size>0){let r=a.triage.get(O(e))?.color??"none";if(!a.filterColors.has(r))return!1}if(a.filterSources.size===1){let r=a.filterSources.has("own");if(r&&er(e.file)||!r&&!er(e.file))return!1}if(a.filterAnalyzer){let r=e._analyzer??null,n=a.filterAnalyzer===po?null:a.filterAnalyzer;if(r!==n)return!1}if(a.filterRepo){let r=Tl(e),n=a.filterRepo===fo?null:a.filterRepo;if(r!==n)return!1}if(e.confidence===void 0){if(e.critical===!0){if(a.filterConfMax<10)return!1}else if(a.filterConfMin>0)return!1}else if(e.confidence<a.filterConfMin||a.filterConfMax<10&&e.confidence>a.filterConfMax)return!1;if(t){let r=a.triage.get(O(e)),n=zp(e).includes(t)||(r?.comment??"").toLowerCase().includes(t)||(r?.fix??"").toLowerCase().includes(t);return a.filterIncludeNegate?!n:n}return!0}function my(e){if(!a.filterComment&&!a.filterFix&&!a.filterFlagged)return!0;let t=r=>e.some(n=>r(a.triage.get(O(n))));if(a.filterComment){let r=t(n=>!!n?.comment);if(a.filterComment==="with"?!r:r)return!1}if(a.filterFix){let r=t(n=>!!n?.fix);if(a.filterFix==="with"?!r:r)return!1}if(a.filterFlagged){let r=t(n=>n?.flagged===!0);if(a.filterFlagged==="with"?!r:r)return!1}return!0}function Yp(e){return e.filter(t=>t.some(gy)&&my(t))}function Gp(e,t,r){return(n,o)=>{let s=n[e]??r,i=o[e]??r;return(t==="desc"?i-s:s-i)||n.file.localeCompare(o.file)}}function Jp(e){let t=e==="desc"?-1:11;return(r,n)=>{let o=r.confidence===void 0&&r.critical===!0,s=n.confidence===void 0&&n.critical===!0,i=r.confidence??(o?10:t),l=n.confidence??(s?10:t);return(e==="desc"?l-i:i-l)||(o===s?0:o?-1:1)||r.file.localeCompare(n.file)}}var qp=Jp("desc"),by={severity:(e,t)=>(Je[t.severity]||0)-(Je[e.severity]||0)||qp(e,t)||parseInt(e.line,10)-parseInt(t.line,10),"confidence-desc":qp,"confidence-asc":Jp("asc"),"priority-desc":Gp("priority","desc",-1),"priority-asc":Gp("priority","asc",11)};function Xp(e){let t=by[a.sortBy];return t?[...e].toSorted((r,n)=>t(We(r),We(n))):[...e]}var fe=mt(class extends tt{constructor(e){if(super(e),e.type!==Le.PROPERTY&&e.type!==Le.ATTRIBUTE&&e.type!==Le.BOOLEAN_ATTRIBUTE)throw Error("The `live` directive is not allowed on child or event bindings");if(!Hd(e))throw Error("`live` bindings can only contain a single expression")}render(e){return e}update(e,[t]){if(t===de||t===g)return t;let r=e.element,n=e.name;if(e.type===Le.PROPERTY){if(t===r[n])return de}else if(e.type===Le.BOOLEAN_ATTRIBUTE){if(!!t===r.hasAttribute(n))return de}else if(e.type===Le.ATTRIBUTE&&r.getAttribute(n)===t+"")return de;return qo(e),t}});var Rl={"claude-security":"Claude Security","codex-security":"Codex Security",deepsec:"DeepSec"};function yy(e){return e==null?"(none)":Rl[e]??e}var Il=class extends P{static properties={options:{attribute:!1}};createRenderRoot(){return this}constructor(){super(),this.options=[]}render(){return c`<select class="sort-select" aria-label="Filter by analyzer" .value="${fe(a.filterAnalyzer)}" @change="${this._onChange}"><option value="">All analyzers</option>${this.options.map(t=>c`<option value="${t??po}">${yy(t)}</option>`)}</select>`}_onChange=t=>{this.dispatchEvent(new CustomEvent("analyzer-change",{detail:{value:t.target.value},bubbles:!0,composed:!0}))}};customElements.define("analyzer-select",Il);function on(e){return e==="informational"?"info":e.replaceAll("_"," ")}function qs(e){if(!e)return"";for(let t of e.split(`
33
- `))if(t.trim())return t.trim();return""}function wy(e){if(!e)return{title:"",body:""};let t=e.indexOf(`
34
- `);if(t<0)return{title:"",body:e};let r=e.slice(t+1).replace(/^\s+/u,"");return r?{title:e.slice(0,t).trim(),body:r}:{title:"",body:e}}var Qp=/"[^"\n]+"|`[^`\n]+`/gu;function Fl(e){if(!e)return e;Qp.lastIndex=0;let t=[],r=0,n;for(;(n=Qp.exec(e))!==null;){n.index>r&&t.push(e.slice(r,n.index));let o=n[0].codePointAt(0)===96?"inline-code":"inline-quote";t.push(c`<span class="${o}">${n[0]}</span>`),r=n.index+n[0].length}return r===0?e:(r<e.length&&t.push(e.slice(r)),t)}function vy(e){let t=tn(e.file,e.repo?.github,e._repoFallback??a.repoUrl),r=parseInt(e.line,10),n=Number.isFinite(r)?`${e.file}:${e.line}`:e.file;if(!t)return n;let o=Number.isFinite(r)?`${t}#L${r}`:t;return c`<a href="${o}" target="_blank" rel="noopener">${n}</a>`}function ky(e,t){if(!t)return g;let r=t.slice(0,7),n=jp(e,t);return n?c`<a href="${n}" target="_blank" rel="noopener" title="${t}">${r}</a>`:c`<span title="${t}">${r}</span>`}var $y=c`<svg viewBox="0 0 16 16" width="11" height="11" aria-hidden="true"><path class="bubble" d="M2.5 3h11a.5.5 0 0 1 .5.5v6.5a.5.5 0 0 1-.5.5H8.4l-3 2.6V10.5H2.5a.5.5 0 0 1-.5-.5V3.5a.5.5 0 0 1 .5-.5z" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linejoin="round"/></svg>`,xy=c`<svg viewBox="0 0 16 16" width="11" height="11" aria-hidden="true"><path class="wrench" d="M10.4 2.6a3 3 0 0 0-3.6 4.5L2 12l2 2 4.9-4.8a3 3 0 0 0 4.5-3.6l-1.8 1.8-1.5-.4-.4-1.5z" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linejoin="round"/></svg>`,_y=c`<svg viewBox="0 0 16 16" width="11" height="11" aria-hidden="true"><rect x="3" y="2.5" width="8" height="10" rx="1" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linejoin="round"/><rect x="5.5" y="5" width="8" height="9" rx="1" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linejoin="round"/></svg>`,Sy=c`<svg viewBox="0 0 16 16" width="11" height="11" aria-hidden="true"><g stroke="currentColor" stroke-width="1.2" stroke-linecap="round" fill="none"><line x1="8" y1="1.8" x2="8" y2="14.2"/><line x1="1.8" y1="8" x2="14.2" y2="8"/><line x1="3.6" y1="3.6" x2="12.4" y2="12.4"/><line x1="12.4" y1="3.6" x2="3.6" y2="12.4"/></g></svg>`,Cy=c`<svg viewBox="0 0 16 16" width="11" height="11" aria-hidden="true"><circle cx="8" cy="8" r="6" fill="none" stroke="currentColor" stroke-width="1.2"/><circle cx="8" cy="8" r="1.7" fill="currentColor"/></svg>`,Bl=c`<svg viewBox="0 0 16 16" width="11" height="11" aria-hidden="true"><path class="flag-cloth" d="M5 1.5h6v13l-3-2.7-3 2.7z" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linejoin="round"/></svg>`;function Ey(e,t=!1){let r=a.triage.get(e)?.flagged===!0,n=r?"Remove flag":"Flag this finding";return c`<button type="button" class="${A({"mark-flag":!0,flagged:r})}" data-flag-toggle="${e}" title="${n}" aria-label="${n}" aria-pressed="${String(r)}">${Bl}${t?c`<span class="mark-btn-label">${r?"Flagged":"Flag"}</span>`:g}</button>`}function Ay(e){let t=qs(e.description)||e.file||"Security finding";return t.length>120?`${t.slice(0,119)}\u2026`:t}function Ty(e){let t=tn(e.file,e.repo?.github,e._repoFallback??a.repoUrl),r=parseInt(e.line,10),n=Number.isFinite(r),o=n?`${e.file}:${r}`:e.file,s=t&&n?`${t}#L${r}`:t,i=[];return e.file&&i.push(`File: ${s?`[${o}](${s})`:o}`),e.description&&i.push(e.description),e.confidence!==void 0&&e.confidence!==null&&i.push(`Confidence: ${e.confidence}/10`),i.join(`
35
-
36
- `)}function Iy(e){if(!a.currentWorkspace)return g;let t=e[0]?._reportName;if(!t)return g;let r=X[Ye(t)]??X.default;return c`<span class="report-chip" title="${t}">${me(r)}<span class="report-chip-label">${Me(t)}</span></span>`}function Zp(e,t,r,n,o=null){let s=Iy(e),i=a.triage.get(n),l=i?.color??null,d=i?.comment??"",u=i?.fix??"",p=d?`Edit comment: ${d}`:"Add comment",f=u?`Edit fix link: ${u}`:"Add fix link (PR URL, etc.)",h=o==="focus",b=d?"Edit comment":"Comment",m=u?"Edit fix link":"Fix link",y=c`<button type="button" class="${A({"mark-comment":!0,"has-comment":d})}" title="${p}" aria-label="${p}">${$y}${h?c`<span class="mark-btn-label">${b}</span>`:g}</button>`,k=c`<button type="button" class="${A({"mark-fix":!0,"has-fix":u})}" title="${f}" aria-label="${f}">${xy}${h?c`<span class="mark-btn-label">${m}</span>`:g}</button>`,w=Ey(n,h),v=c`<button type="button" class="mark-copy" title="Copy file, line, description, confidence to clipboard" aria-label="Copy finding details to clipboard">${_y}${h?c`<span class="mark-btn-label">Copy</span>`:g}</button>`,$=Te(e),R=Ks($),F=Kp(R,{title:Ay($),body:Ty($)}),B=F?c`<a class="mark-issue" href="${F}" target="_blank" rel="noopener" title="Create a pre-filled GitHub issue for this finding" aria-label="Create a GitHub issue for this finding">${Cy}${h?c`<span class="mark-btn-label">Issue</span>`:g}</a>`:g,te=c`<button type="button" class="mark-claude" title="Open in Claude Code (claude://) with a confirm-and-fix prompt" aria-label="Open finding in Claude Code">${Sy}${h?c`<span class="mark-btn-label">Claude</span>`:g}</button>`,z=c`<color-marker .selected="${l}"></color-marker>`,be=r.hasConflict?"change triage state (colors mismatch \u2014 acts per-tab)":t.length>1?"change triage state for the whole group":"change triage state";return c`${s}<span class="mark-action-group">${y}${k}${w}</span><span class="mark-action-group">${v}${B}${te}</span>${z}${Fy(e,be,o)}`}function Ry(e){if(e.newState!=="open")return;let t=e.currentTarget,n=t.getRootNode().querySelector?.(`[popovertarget="${t.id}"]`);if(!n)return;let o=n.getBoundingClientRect(),s=t.offsetWidth||110,i=t.offsetHeight||100,l=4,d=o.right-s;d<4&&(d=4),d+s>window.innerWidth-4&&(d=window.innerWidth-s-4);let u=o.bottom+l;u+i>window.innerHeight-4&&o.top>i+l&&(u=o.top-i-l),t.style.top=`${u}px`,t.style.left=`${d}px`}function Fy(e,t,r=null){let n=O(e[0]),o=$e(e),s=Te(e),i=O(s),l=o.hasConflict?a.triage.get(i)?.triage??(nn(s)?"ignored":null):o.commonTriage,d={inprogress:"In progress",fixed:"Fixed",invalid:"Invalid",deleted:"Deleted",ignored:"Ignored"},u={inprogress:"In progress",fixed:"Fixed",invalid:"Invalid",deleted:"Delete",ignored:"Ignore"},p=!!a.shownTriage,f=p?d[a.shownTriage]:null,h=["inprogress","fixed","invalid","deleted","ignored"],b=r==="focus",m;b?m=h.map(w=>({key:w,label:u[w]})):p?m=[{key:"restore",label:"Restore"},...h.filter(w=>w!==a.shownTriage).map(w=>({key:w,label:u[w]}))]:m=h.map(w=>({key:w,label:u[w]}));let y=["mark-triage-menu"];p&&y.push("with-label",`triage-state-${a.shownTriage}`);let k=`triage-menu-${n.replaceAll(/[^A-Za-z0-9_-]/gu,"_")}`;return c`<div class="triage-menu-wrap"><button type="button" class="${y.join(" ")}" popovertarget="${k}" popovertargetaction="toggle" title="${t}" aria-label="${t}">${f?c`<span class="mark-triage-label">${f}</span>`:g} <svg viewBox="0 0 12 12" width="11" height="11" aria-hidden="true"><path d="M2 4l4 4 4-4" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg></button><div popover="auto" id="${k}" class="triage-menu" data-gid="${n}" role="menu" @beforetoggle="${Ry}">${m.map(w=>c`<button type="button" class="${A({"triage-menu-item":!0,[`triage-menu-${w.key}`]:!0,active:l===w.key})}" data-triage-action="${w.key}" role="menuitem">${w.label}</button>`)}</div></div>`}function ef(e,t){let r=O(e),n=a.triage.get(r),o=n?.color,s=n?.triage,i=nn(e),l=["tab"];return t&&l.push("active"),o&&l.push(`tab-mark-${o}`),s?l.push(`tab-${s}`):i&&l.push("tab-ignored"),c`<button type="button" class="${l.join(" ")}" data-tid="${r}"><span class="tab-label"><span class="${`badge ${e.severity}`}">${on(e.severity)}</span> ${e.confidence===void 0?g:c`<span class="tab-conf">${e.confidence}/10</span>`}</span></button>`}function By(e){if(a.viewMode==="table"||a.viewMode==="focus"){let t=e.confidence*10;return c`<div class="${`conf-ring ${e.severity}`}"><svg viewBox="0 0 36 36" aria-hidden="true"><circle class="conf-ring-track" cx="18" cy="18" r="15.9155"/><circle class="conf-ring-arc" cx="18" cy="18" r="15.9155" style="${`stroke-dasharray: ${t} 100`}"></circle></svg> <span>${e.confidence}<small>/10</small></span></div><div class="value-label">Confidence</div>`}return c`<div class="conf-score"><strong>${e.confidence}</strong>/10</div><div class="value-label">Confidence</div>`}var My=/^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/iu;function Ly(e){if(Or(e))return g;let t=e?.name;if(typeof t!="string"||!My.test(t))return g;let r=e?.version,n=typeof r=="string"&&r.length>0,o=n?`https://www.npmjs.com/package/${t}/v/${encodeURIComponent(r)}`:`https://www.npmjs.com/package/${t}`,s=n?`${t}@${r}`:t;return c`<span class="line-num"><a class="npm-link" href="${o}" target="_blank" rel="noopener noreferrer" title="${`Open ${s} on npmjs.com`}">npm: ${s}</a></span>`}function Py(e,t,r=0,n=1,o=null){let s=O(e),i=a.triage.get(s),l=i?.comment??"",d=i?.fix??"",u=tn(e.file,e.repo?.github,e._repoFallback??a.repoUrl),p=parseInt(e.line,10),f=Number.isFinite(p),h=f?`${e.file}:${e.line}`:e.file,b=u?c`<a href="${f?`${u}#L${p}`:u}" target="_blank" rel="noopener">${h}</a>`:h,m=$r(e),y=m?c`<span class="line-num">${b}, ${m}</span>`:c`<span class="line-num">${b}</span>`,k=xr(e),w=o==="focus"?Ly(e.package?.npm):g,v=g;if(o!=="focus"&&e.fileHash&&Array.isArray(e._bundleHashes)&&e._bundleHashes.length>0){let F=new Set(e._bundleHashes),B=vr(e.fileHash).find(({integrity:te})=>F.has(te));B&&(v=c`<button type="button" class="finding-code-btn" data-finding-code-bundle="${B.integrity}" data-finding-code-file="${B.file}" data-finding-code-line="${e.line??""}" title="${`Open ${B.file} in bundle source viewer`}">Code</button>`)}let{title:$,body:R}=wy(st(e.description,e));return c`<div class="${A({"tab-body":!0,active:t})}" data-tid="${s}">${n>1?c`<div class="print-case-label">${r+1} of ${n}</div>`:g}<div class="finding-left"><span class="${`badge ${e.severity}`}">${on(e.severity)}</span><div class="value-label">Severity</div>${e.confidence===void 0?g:By(e)} ${v}</div><div><div class="line-row">${y} ${w} ${e.discoveredIn?c`<span class="line-num discovered-in">(found analyzing ${e.discoveredIn})</span>`:g} ${k?c`<span class="run-meta">${k}</span>`:g}</div>${$?c`<div class="desc-title">${$}</div>`:g} ${R?c`<div class="desc">${Fl(R)}</div>`:g} ${e.recommendation?c`<div class="recommendation">Recommendation: ${Fl(st(e.recommendation,e))}</div>`:g} ${e.confidenceReason?c`<div class="conf-reason">${Fl(st(e.confidenceReason,e))}</div>`:g} ${l?c`<div class="comment-block"><span class="comment-label">Comment:</span> ${l}</div>`:g} ${d?c`<div class="fix-block"><span class="fix-label">Fix:</span> ${rn(d)?c`<a href="${d}" target="_blank" rel="noopener noreferrer">${d}</a>`:d}</div>`:g}</div></div>`}function sn(e){return Ae(e)}function tf(e){let t=$e(e),r=uo(e),n=e.some(s=>s.critical||s.severity==="critical"),o=["finding"];return n&&o.push("is-critical"),t.hasConflict?o.push("has-conflict"):t.commonColor&&o.push(`mark-${t.commonColor}`),a.shownTriage&&o.push(`triage-${a.shownTriage}`),r.length>1&&o.push("multi-case"),o}function rf(e,t={}){let{context:r=null}=t,n=$e(e),o=uo(e),s=Te(e),i=O(s),l=s.commitHash?c`<div class="commit-ref">introduced in ${ky(s.repo?.github,s.commitHash)}</div>`:g,d=a.currentWorkspace&&l!==g;return c`${o.map((u,p)=>Py(u,O(u)===i,p,o.length,r))} ${d?c`<div class="marks-commit-row">${l}</div>`:g}<div class="marks"><div class="marks-left">${d?g:l} ${o.length>1?c`<div class="tabs">${o.map(u=>ef(u,O(u)===i))}</div>`:g}</div>${Zp(e,o,n,i,r)}</div>`}function ho(e){return Ae(e)}function nf(e){let t=$e(e),r=e.some(o=>o.critical||o.severity==="critical"),n=[];return r&&n.push("is-critical"),t.hasConflict?n.push("has-conflict"):t.commonColor&&n.push(`mark-${t.commonColor}`),a.shownTriage&&n.push(`triage-${a.shownTriage}`),n}function of(e){let t=$e(e),r=uo(e),n=Te(e),o=O(n),s=n,i=qs(st(s.description,s)),l=xr(s),d=$r(s),u=d?`, ${d}`:"";return c`<div class="row-score"><span class="${`badge ${s.severity}`}">${on(s.severity)}</span> ${s.confidence===void 0?g:c`<span class="row-conf"><strong>${s.confidence}</strong>/10</span>`}</div><div class="row-body"><div class="title-row"><span class="title">${i}</span> ${l?c`<span class="row-type">${l}</span>`:g}</div><div class="meta-row"><span class="row-loc">${vy(s)}${u}</span><div class="marks">${Zp(e,r,t,o)}</div></div>${r.length>1?c`<div class="tabs-row"><div class="tabs">${r.map(p=>ef(p,O(p)===o))}</div></div>`:g}</div>`}function go(e){return"tree-"+e.replaceAll(/[^\w-]+/gu,"_")}var af=()=>Object.fromEntries(ke.map(e=>[e,0]));function Ml(e){let t=new Map;for(let r of e)for(let n of r){t.has(n.file)||t.set(n.file,af());let o=t.get(n.file);o[n.severity]!==void 0&&o[n.severity]++}return t}function Ll(e){let t=null;for(let r of e)if(r?.tree){t||(t={});for(let n of Object.keys(r.tree)){let o=r.tree[n];if(!t[n]){t[n]={...o,imports:[...o.imports??[]]};continue}let s=new Set(t[n].imports);for(let i of o.imports??[])s.has(i)||(s.add(i),t[n].imports.push(i));t[n].size==null&&o.size!=null&&(t[n].size=o.size)}}return t}function Ys(e,t){let r=new Map;for(let n of Object.keys(e)){let o=new Set,s=[...(e[n].imports??[]).filter(l=>e[l])];for(;s.length>0;){let l=s.pop();if(!o.has(l)){o.add(l);for(let d of e[l]?.imports??[])e[d]&&s.push(d)}}let i=af();for(let l of o){let d=t.get(l);if(d)for(let u of ke)i[u]+=d[u]??0}r.set(n,i)}return r}function Pl(e,t,r){let n=t.get(e),o=r.get(e);return sf(n)>0||sf(o)>0}function sf(e){if(!e)return 0;let t=0;for(let r of ke)t+=e[r]??0;return t}function lf(e){if(!e)return g;let t=vr(e)[0];return t?c`<button type="button" class="tree-code-btn" data-finding-code-bundle="${t.integrity}" data-finding-code-file="${t.file}" title="${`Open ${t.file} in bundle source viewer`}">Code</button>`:g}function cf(e,t){let r=Object.keys(e).toSorted(),n=new Map;for(let p of r)for(let f of e[p].imports??[]){let h=n.get(f)??[];h.push(p),n.set(f,h)}let o=a.filesSearch.trim().toLowerCase(),s=o?r.filter(p=>p.toLowerCase().includes(o)):r,i=p=>e[p]?c`<a href="${`#${go(p)}`}"><span class="name">${p}</span></a>`:c`<span class="name">${p}</span>`,l=p=>{let f=t.get(p);if(!f)return null;let h=ke.filter(b=>(f[b]??0)>0);return h.length===0?null:c`<span class="tree-count-chips">${h.map(b=>c`<span class="${`tree-count-chip ${b}`}">${f[b]} ${b.replaceAll("_"," ")}</span>`)}</span>`},d=p=>{let f=t.get(p);return f?ke.reduce((h,b)=>h+(f[b]??0),0):0},u=c`<div class="tree-toolbar"><view-mode-buttons modes="table,list" kind="files"></view-mode-buttons><div class="search-row"><toolbar-search kind="files"></toolbar-search><span class="result-count">${s.length} of ${r.length}</span></div></div>`;if(a.filesViewMode==="table"){let p=a.filesSelectedFile&&e[a.filesSelectedFile]&&s.includes(a.filesSelectedFile)?a.filesSelectedFile:null;return c`<div class="${p?"tree-view tree-view-table with-details":"tree-view tree-view-table"}">${u}<div class="${p?"tree-table-layout open":"tree-table-layout"}"><div class="tree-table-list">${s.length===0?c`<div class="tree-table-empty">No files match the search.</div>`:g} ${s.map(b=>{let m=d(b),y=b===p,k=ne(e[b]?.size);return c`<div class="${`tree-table-row${y?" selected":""}${m===0?" clean":""}`}" data-tree-select="${b}"><span class="tree-table-name">${b}</span> ${l(b)??c`<span class="tree-table-clean-marker">—</span>`} ${k?c`<span class="tree-table-size">${k}</span>`:g}</div>`})}</div>${p?c`<aside class="tree-table-details" id="tree-table-details"><header class="tree-table-details-bar"><span class="tree-table-details-label">Details</span> <button type="button" class="tree-table-details-close" data-tree-deselect title="Close details" aria-label="Close details">×</button></header><div class="tree-table-details-body">${Oy(e[p],p,n.get(p)??[],i)}</div></aside>`:g}</div></div>`}return c`<div class="tree-view">${u} ${s.length===0?c`<div class="tree-table-empty">No files match the search.</div>`:g} ${s.map(p=>{let f=e[p],h=n.get(p)??[],b=ne(f?.size);return c`<section class="tree-file" id="${go(p)}"><div class="tree-file-header"><span class="name">${p}</span> ${l(p)} ${b?c`<span class="tree-file-size">${b}</span>`:g} ${lf(f.fileHash)}</div>${f.fileHash||f.treeHash?c`<div class="tree-hashes hashes">${f.fileHash?c`<div class="tree-hash">file: ${f.fileHash}</div>`:g} ${f.treeHash?c`<div class="tree-hash">tree: ${f.treeHash}</div>`:g}</div>`:g} ${f.imports?.length>0?c`<div class="tree-section"><span class="tree-section-label">imports</span><ul>${f.imports.map(m=>c`<li>${i(m)}</li>`)}</ul></div>`:g} ${h.length>0?c`<div class="tree-section"><span class="tree-section-label">imported by</span><ul>${h.map(m=>c`<li>${i(m)}</li>`)}</ul></div>`:g} ${f.exports?.length>0?c`<div class="tree-section"><span class="tree-section-label">exports</span><ul>${f.exports.map(m=>c`<li><span class="name">${m}</span></li>`)}</ul></div>`:g}</section>`})}</div>`}function Oy(e,t,r,n){let o=ne(e?.size);return c`<div class="tree-detail-name"><span class="name">${t}</span> ${o?c`<span class="tree-detail-size">${o}</span>`:g} ${lf(e.fileHash)}</div>${e.fileHash||e.treeHash?c`<div class="tree-hashes hashes">${e.fileHash?c`<div class="tree-hash">file: ${e.fileHash}</div>`:g} ${e.treeHash?c`<div class="tree-hash">tree: ${e.treeHash}</div>`:g}</div>`:g} ${e.imports?.length>0?c`<div class="tree-section"><span class="tree-section-label">imports</span><ul>${e.imports.map(s=>c`<li>${n(s)}</li>`)}</ul></div>`:g} ${r.length>0?c`<div class="tree-section"><span class="tree-section-label">imported by</span><ul>${r.map(s=>c`<li>${n(s)}</li>`)}</ul></div>`:g} ${e.exports?.length>0?c`<div class="tree-section"><span class="tree-section-label">exports</span><ul>${e.exports.map(s=>c`<li><span class="name">${s}</span></li>`)}</ul></div>`:g}`}function Ny(){return{showAll:!1,selected:null,focusedPkg:null,topPkgsTab:"issues",edgeOpacity:.22,nodeSize:1,showLabels:!1,selectedSeverities:new Set,selectedColors:new Set,pathFilter:"",hidden:new Set,solo:null,graphState:null,layoutCache:null}}var tr=Ny(),E=new Proxy(tr,{get(e,t){return tr[t]},set(e,t,r){return tr[t]=r,!0},has(e,t){return t in tr},deleteProperty(e,t){return delete tr[t]},ownKeys(){return Reflect.ownKeys(tr)},getOwnPropertyDescriptor(e,t){return Object.getOwnPropertyDescriptor(tr,t)}});function He(){E.graphState?._cleanup&&E.graphState._cleanup(),E.graphState=null}function df(){return tr}var mo=null,uf=null;function an(){return uf}function Dy(){return mo||(mo=(async()=>{let e="./graph.js";try{let t=await import(e);return t._swapGraph2Impl(df()),uf=t,t}catch(t){throw mo=null,t}})(),mo)}async function Ol(e,t,r,n,o){try{let s=await Dy(),i=s.buildGraphFromPrep(t);K(c`<graph-layout .graph="${i}" .options="${r}"></graph-layout>`,e);let l=e.querySelector("graph-layout");return await l.updateComplete,n(),o(),s.attachGraph2Interaction(e,i,n),l}catch(s){let i=s instanceof Error?s.message:String(s);return e.textContent=`Graph failed to load: ${i}`,null}}function Ne(e){let t=new Map;if(!e)return t;if(e.kind==="stasis"){if(!e.bundle)return t;for(let[r,n]of e.bundle.sources)typeof n=="string"&&t.set(r,n)}else if(e.kind==="sourcemap"){if(!e.json)return t;let r=e.json.sources??[],n=e.json.sourcesContent??[];for(let o=0;o<r.length;o++)typeof n[o]=="string"&&t.set(r[o],n[o])}return t}var bo=null,yo=null;function Uy(){return bo||(bo=(async()=>{let e="./terminal.js";try{return await import(e)}catch(t){throw bo=null,t}})(),bo)}function zy(e){let t=Ne(e);if(t.size===0)return t;let r=[...t.keys()],{stripped:n}=Xe(r),o=new Map;for(let s=0;s<r.length;s++)o.set(n[s],t.get(r[s]));return o}async function pf(e,t){let r=t?.integrity??"";(!yo||yo.integrity!==r)&&(yo={integrity:r,promise:Wy(t,r)});try{let n=await yo.promise;return!e.isConnected||e.contains(n)||e.replaceChildren(n),n}catch(n){yo=null;let o=n instanceof Error?n.message:String(n);return e.textContent=`Terminal failed to load: ${o}`,null}}async function Wy(e,t){return(await Uy()).createTerminalElement(zy(e),t)}function hf(e){if(!e)return null;let t=Up()==="node_modules"?/^(?:.*\/)?node_modules\/(@[^/]+\/[^/]+|[^/]+)/u:/^(?:.*\/)?dependencies\/(@[^/]+\/[^/]+|[^/]+)/u,r=e.match(t);if(r)return r[1];let n=e.indexOf("/");return n>0?e.slice(0,n):"/"}var Hy=["#4e9af1","#f28e2b","#59a14f","#e15759","#76b7b2","#edc948","#b07aa1","#ff9da7","#9c755f","#5cd1e5","#f1ce63","#d37295","#a0cbe8","#86bcb6","#8cd17d","#b6992d","#499894","#e15759","#e879c7","#d4a6c8"],ff=["#2f8aef","#d2691e","#2ea043","#e63946","#2e9a92","#b88817","#9560e8","#d24a9c","#8a5d40","#0891b2","#a07a14","#c14e8e","#1f7ad0","#549b94","#3fb95f","#a07a14","#2a8278","#cb2c40","#c026d3","#965f93"];function jy(){if(typeof document>"u")return!1;let e=document.body?.classList;return!!e&&(e.contains("theme-light")||e.contains("theme-pink"))}var Nl=new Map;function ht(e){let t=jy()?ff:Hy,n=`${t===ff?"l":"d"}:${e??"__own__"}`;if(Nl.has(n))return Nl.get(n);let o=e??"__own__",s=0;for(let u of o)s=s*37+u.codePointAt(0)|0;let l=((s%t.length+t.length)%t.length*7+3)%t.length,d=t[l];return Nl.set(n,d),d}var Dl=(e,t,r)=>{for(let n of t)if(n[0]===e)return(0,n[1])();return r?.()};var ln='<svg class="file-icon" viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M8 2 2 5v6l6 3 6-3V5L8 2Z"/><path d="M2 5l6 3 6-3"/><path d="M8 8v6"/></svg>',Js='<svg class="file-icon" viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="2.5" y="4" width="11" height="9" rx="1.2"/><path d="M6 4V3h4v1"/></svg>';var Xs=null;function Vy(){return Xs||(Xs=(async()=>await import("./prism.js"))(),Xs)}var Ky={js:"javascript",mjs:"javascript",cjs:"javascript",jsx:"jsx",ts:"typescript",mts:"typescript",cts:"typescript",tsx:"tsx",json:"json",css:"css",html:"markup",htm:"markup",xml:"markup",svg:"markup",yml:"yaml",yaml:"yaml",sh:"bash",bash:"bash",md:"markdown",markdown:"markdown",sol:"solidity"};function Qs(e){if(typeof e!="string")return null;let t=e.lastIndexOf(".");return t<0?null:Ky[e.slice(t+1).toLowerCase()]??null}async function Zs(e,t){if(!t)return null;try{return(await Vy()).highlight(e,t)}catch{return null}}var xe=`.lwd-body{margin:.2rem 0 .55rem;color:var(--text);font-size:.86rem;line-height:1.5}.lwd-empty{margin:.2rem 0 .55rem;color:var(--muted);font-size:.78rem}.lwd-note{margin:.2rem 0 .65rem;padding:.55rem .7rem;border:1px solid var(--border);border-radius:6px;background:rgb(from var(--text) r g b / .03);color:var(--muted);font-size:.78rem;line-height:1.45}.lwd-choice{margin:.2rem 0 .65rem;padding:.55rem .7rem .6rem;border:1px solid var(--border);border-radius:6px;background:rgb(from var(--text) r g b / .03);& legend{padding:0 .35rem;color:var(--text);font-size:.78rem;font-weight:500;& strong{font-weight:600}}}.lwd-option{display:flex;align-items:flex-start;gap:.5rem;padding:.3rem .15rem;& input[type=radio]{margin:.15rem 0 0;accent-color:var(--accent)}.lwd-option-text{display:flex;flex-direction:column;gap:.1rem;min-width:0}.lwd-option-title{color:var(--text);font-size:.82rem;line-height:1.35}.lwd-option-hint{color:var(--muted);font-size:.72rem;line-height:1.4}}.lwd-list{margin:0;padding-left:1.1rem;color:var(--muted);font-size:.76rem;line-height:1.5;& li+li{margin-top:.2rem}& strong{color:var(--text);font-weight:600}}.lwd-kind-tag{display:inline-block;vertical-align:middle;margin-left:.3rem;padding:0 .35rem;border:1px solid var(--border);border-radius:3px;background:rgb(from var(--text) r g b / .04);color:var(--muted);font-size:.62rem;font-weight:600;text-transform:uppercase;letter-spacing:.06em}.lwd-rename-input{margin-top:.2rem}.lwd-rename-error{margin:.25rem 0 0;color:var(--critical, #f87171);font-size:.72rem;line-height:1.35}
37
- `;var Ul=class extends I{static styles=[...I.styles,T(xe)];static properties={reportName:{type:String},workspaceNames:{type:Array},existingNames:{type:Object},_choice:{state:!0},_newName:{state:!0}};constructor(){super(),this.reportName="",this.workspaceNames=[],this.existingNames=new Set,this._choice="replace",this._newName=""}focusInitial(){this.renderRoot.querySelector('button[data-role="cancel"]')?.focus()}_onClose=()=>this._finish({action:"cancel"});_onCancel=()=>this._finish({action:"cancel"});_onChoiceChange=t=>{this._choice=t.target.value};_onNewNameInput=t=>{this._newName=t.target.value};_onNewNameKeydown=t=>{t.key==="Enter"&&(t.preventDefault(),this._onConfirm())};_onConfirm=()=>{if(this._choice==="rename"){let t=(this._newName??"").trim();if(!this._isRenameValid(t))return;this._finish({action:"rename",newName:t});return}this._finish({action:"replace"})};_replaceHint(){let t=this.workspaceNames.length;if(t===0)return c`<span class="lwd-option-hint">The local file will be overwritten.</span>`;let r=t===1?c`workspace <strong>"${this.workspaceNames[0]}"</strong>`:c`<strong>${t}</strong> workspaces (${this.workspaceNames.join(", ")})`;return c`<span class="lwd-option-hint">The local file will be overwritten. When sync is online, the new bytes are also uploaded to ${r} so the cloud copy matches.</span>`}_renameValidationTpl(t){return t?t===this.reportName?c`<p class="lwd-rename-error">Pick a name different from the original.</p>`:t.includes("\0")?c`<p class="lwd-rename-error">The new name cannot contain a NUL byte.</p>`:t.includes("/")||t.includes("\\")?c`<p class="lwd-rename-error">The new name cannot contain "/" or "\\".</p>`:this.existingNames.has(t)?c`<p class="lwd-rename-error">A file named "${t}" already exists — pick something else.</p>`:g:c`<p class="lwd-rename-error">Enter a new name.</p>`}_isRenameValid(t){return t.length>0&&t!==this.reportName&&!t.includes("\0")&&!t.includes("/")&&!t.includes("\\")&&!this.existingNames.has(t)}render(){let t=this._choice==="rename",r=(this._newName??"").trim(),n=t&&!this._isRenameValid(r),o=t?"Rename":"Replace",s=t?"primary":"danger",i=this.workspaceNames.length>0?c`<span class="lwd-option-hint">Saved as an unfiled report — the renamed copy isn't added to any workspace.</span>`:g;return c`<dialog @close="${this._onClose}"><header><h3>Import conflict</h3></header><p class="lwd-body"><strong>"${this.reportName}"</strong> already exists with different content.</p><fieldset class="lwd-choice"><legend>What should happen?</legend><label class="lwd-option"><input type="radio" name="icd-choice" value="replace" ?checked="${this._choice==="replace"}" @change="${this._onChoiceChange}"> <span class="lwd-option-text"><span class="lwd-option-title">Replace</span> ${this._replaceHint()}</span></label> <label class="lwd-option"><input type="radio" name="icd-choice" value="rename" ?checked="${this._choice==="rename"}" @change="${this._onChoiceChange}"> <span class="lwd-option-text"><span class="lwd-option-title">Rename to</span> <input type="text" class="nwd-input lwd-rename-input" maxlength="200" .value="${this._newName}" ?disabled="${!t}" @input="${this._onNewNameInput}" @keydown="${this._onNewNameKeydown}" @focus="${()=>{this._choice="rename"}}"> ${i} ${t?this._renameValidationTpl(r):g}</span></label></fieldset><footer class="nwd-actions"><span class="nwd-spacer"></span> <button type="button" data-role="cancel" @click="${this._onCancel}">Cancel</button> <button type="button" class="${s}" ?disabled="${n}" @click="${this._onConfirm}">${o}</button></footer></dialog>`}};customElements.define("import-conflict-dialog",Ul);function gf({name:e,workspaceNames:t,existingNames:r}={}){let n=r instanceof Set?r:new Set(r??[]);return new Promise(o=>{let s=document.createElement("import-conflict-dialog");Object.assign(s,{reportName:e??"",workspaceNames:Array.isArray(t)?t:[],existingNames:n,_newName:qy(e??"",n)}),s.addEventListener("resolve",i=>{s.remove(),o(i.detail)}),s.addEventListener("modal-conflict",()=>{s.remove(),o({action:"cancel"})}),document.body.append(s)})}function qy(e,t){if(typeof e!="string"||e.length===0)return"";let r=e.lastIndexOf("."),n=r>0?e.slice(0,r):e,o=r>0?e.slice(r):"",s=n.replace(/-\d+$/u,"");for(let i=2;i<1e3;i++){let l=`${s}-${i}${o}`;if(!t.has(l))return l}return""}function D(e,t){if(!e)throw new Error(t)}function cn(e,t){let[r,n]=[e.split("/"),t.split("/")];for(;r.length>0&&r[0]===n[0];)r.shift(),n.shift();if(r.length===0&&n.length===0)return 0;if(r.length<2)return n.length<2&&r>n?1:-1;if(n.length<2)return 1;if(r[0]==="*")return-1;if(n[0]==="*"||r[0]==="node_modules")return 1;if(n[0]==="node_modules")return-1;let[o,s]=[r,n].map(i=>i.join(String.fromCodePoint(0)));if(o<s)return-1;if(o>s)return 1;throw new Error("Unreachable")}var Yy=e=>e&&[null,Object.prototype].includes(Object.getPrototypeOf(e)),dn=e=>Object.setPrototypeOf(Object.fromEntries(e),null),mf=e=>[...e].toSorted((t,r)=>cn(t,r)),ei=e=>dn([...e].toSorted((t,r)=>cn(t[0],r[0])).map(([t,r])=>[t,r instanceof Map?ei(r):r])),zl=e=>new Map(Object.entries(e).map(([t,r])=>[t,Yy(r)?zl(r):r]));function bf(e){let t="node_modules/",r=e.lastIndexOf(t);if(r===-1)return null;let n=r+t.length,o=e.slice(n).split("/"),s=o[0].startsWith("@")?2:1;if(o.length<=s||o.slice(0,s).some(l=>!l))return null;let i=o.slice(0,s).join("/");return{dir:e.slice(0,n)+i,rel:o.slice(s).join("/"),name:i}}var St=1,Wl=0,ti=({name:e,version:t,files:r})=>({name:e,version:t,files:dn(Object.entries(r))}),yf=e=>bf(e)??{dir:".",rel:e,name:null},ri=class e{static VERSION=St;version=St;config;entries;modules;formats;imports;constructor({config:t={scope:"full"},entries:r,modules:n,formats:o,imports:s,version:i=St}={}){D([Wl,St].includes(i)),D(["node_modules","full"].includes(t.scope)),this.version=i,this.config=t,this.entries=r??new Set,this.modules=n??new Map,this.formats=o??new Map,this.imports=s??new Map}get sources(){let t=new Map;for(let[r,{files:n}]of this.modules)for(let[o,s]of Object.entries(n))t.set(r==="."?o:`${r}/${o}`,s);return t}static parseCode(t){let r=JSON.parse(t);D(r.version===St||r.version===Wl),D(["node_modules","full"].includes(r.config?.scope)),D(r.formats),D(r.imports);let n=new Map,o=new Set;if(r.version===St){let s=r.config.scope==="full";if(r.modules!==void 0){D(typeof r.modules=="object"&&r.modules!==null);for(let[i,l]of Object.entries(r.modules))D(i.includes("node_modules")),D(!i.startsWith("..")),D(l?.name&&l.version&&l.files),n.set(i,ti(l))}if(s){D(Array.isArray(r.entries)),D(r.entries.length>0,"v1 bundle with scope=full must have at least one entry"),D(r.sources&&typeof r.sources=="object"),o=new Set(r.entries);for(let[i,l]of Object.entries(r.sources))D(!i.includes("node_modules")),D(!i.startsWith("..")),D(l?.name&&l.version&&l.files),n.set(i,ti(l))}else D(r.entries===void 0),D(r.sources===void 0);for(let[,{files:i}]of n)for(let l of Object.keys(i))D(!l.startsWith(".."))}else{D(r.sources);for(let[s,i]of Object.entries(r.sources)){D(!s.startsWith(".."));let{dir:l,rel:d,name:u}=yf(s);D(!l.startsWith("..")&&!d.startsWith("..")),n.has(l)||n.set(l,{name:u,version:null,files:Object.create(null)}),n.get(l).files[d]=i}}return new e({version:r.version,config:r.config,entries:o,modules:n,formats:new Map(Object.entries(r.formats)),imports:zl(r.imports)})}static parseResources(t){let r=JSON.parse(t);D(r.version===St||r.version===Wl);let n=new Map,o={scope:"full"};if(r.version===St){D(["node_modules","full"].includes(r.config?.scope)),o=r.config;let s=o.scope==="full";if(r.modules!==void 0){D(typeof r.modules=="object"&&r.modules!==null);for(let[i,l]of Object.entries(r.modules))D(i.includes("node_modules")),D(!i.startsWith("..")),D(l?.name&&l.version&&l.files),n.set(i,ti(l))}if(s&&r.sources!==void 0){D(typeof r.sources=="object"&&r.sources!==null);for(let[i,l]of Object.entries(r.sources))D(!i.includes("node_modules")),D(!i.startsWith("..")),D(l?.name&&l.version&&l.files),n.set(i,ti(l))}else s||D(r.sources===void 0);for(let[,{files:i}]of n)for(let l of Object.keys(i))D(!l.startsWith(".."))}else{D(r.resources);for(let[s,i]of Object.entries(r.resources)){D(!s.startsWith(".."));let{dir:l,rel:d,name:u}=yf(s);D(!l.startsWith("..")&&!d.startsWith("..")),n.has(l)||n.set(l,{name:u,version:null,files:Object.create(null)}),n.get(l).files[d]=i}}return new e({version:r.version,config:o,modules:n})}#e(){let t=[],r=[];for(let[n,{name:o,version:s,files:i}]of this.modules){if(Object.keys(i).length===0)continue;let l=n.includes("node_modules");l&&D(o&&s&&i);let d=dn(Object.entries(i).toSorted((p,f)=>cn(p[0],f[0])));(l?t:r).push([n,{name:o,version:s,files:d}])}return t.sort((n,o)=>cn(n[0],o[0])),r.sort((n,o)=>cn(n[0],o[0])),{modules:dn(t),sources:dn(r)}}serializeCode(){let t=mf(this.entries),{modules:r,sources:n}=this.#e(),o=ei(this.formats),s=ei(this.imports),i={version:St,config:this.config};return this.config.scope==="full"&&Object.assign(i,{entries:t,sources:n}),Object.assign(i,{modules:r,formats:o,imports:s}),JSON.stringify(i,void 0,2)}serializeResources(){let{modules:t,sources:r}=this.#e(),n={version:St,config:this.config};return this.config.scope==="full"&&Object.assign(n,{sources:r}),Object.assign(n,{modules:t}),JSON.stringify(n,void 0,2)}};var ni=null,oi=null,si=null;function Jy(){for(let e of["br","brotli"])try{return new DecompressionStream(e),e}catch{}return null}async function Xy(e,t){let r=new Blob([t]).stream().pipeThrough(new DecompressionStream(e));return new Uint8Array(await new Response(r).arrayBuffer())}async function Qy(){if("serviceWorker"in navigator)try{let e=await navigator.serviceWorker.getRegistrations();for(let t of e){let r=t.active?.scriptURL??t.installing?.scriptURL??t.waiting?.scriptURL;r&&r.endsWith("/brotli-sw.js")&&await t.unregister()}}catch{}}function Zy(){return si||(si=(async()=>await import("./brotli-fallback.js"))(),si)}async function ew(){await Qy();let e=Jy();return e?(ni={kind:"native",format:e},ni):(ni={kind:"fallback"},ni)}function wf(){return oi||(oi=ew(),oi)}async function vf(e){let t=await wf();return t.kind==="native"?Xy(t.format,e):(await Zy()).brotliDecompress(e)}wf().catch(()=>{});async function un(e,t){try{let r=await yr(e),n=t.name.toLowerCase().endsWith(".map"),o=n?"sourcemap":"stasis";try{if(n){let l=JSON.parse(he(r));return{integrity:e,kind:o,size:r.byteLength,json:l}}let s=he(await vf(r)),i=ri.parseCode(s);return{integrity:e,kind:o,size:r.byteLength,bundle:i}}catch(s){return{integrity:e,kind:o,size:r.byteLength,error:s.message}}}catch(r){return{integrity:e,error:r.message,size:0}}}function tw(e){!e?.json&&!e?.bundle||(async()=>{try{let t=await jl(e);if($s(e.integrity,t),a.selectedBundle!==e.integrity)return;e.fileHashes=t,x()}catch{}})()}async function Hl(e){if(Fa(e))return;let t=(a.bundles??[]).find(n=>n.integrity===e);if(!t)return;let r=await un(e,t);if(!(!r?.json&&!r?.bundle))try{let n=await jl(r);$s(e,n)}catch{}}async function Ot(e){let t=(a.bundles??[]).find(n=>n.integrity===e);if(!t)return;let r=await un(e,t);a.selectedBundle===e&&(a.bundleDetails=r,x(),tw(r),$t().catch(()=>{}))}var rw=["finding_url","repository","title","description","severity","configured_scan_id","relevant_paths"];function nw(e){let t=[],r=[],n="",o=!1,s=e.length;for(let i=0;i<s;i++){let l=e[i];o?l==='"'?e[i+1]==='"'?(n+='"',i++):o=!1:n+=l:l==='"'?o=!0:l===","?(r.push(n),n=""):l===`
30
+ \u2022 Hardware security key: use the vendor's management tool`)}catch(e){alert(`Could not disable encryption: ${e?.message??e}`)}}async function qy(){await ti()}function rf(e){if(!e||e===Te)return;Te=e;let t=!1;Te.addEventListener("click",async()=>{if(!t){t=!0;try{if(!ne()){await qy();return}if(!pt()){await ri();return}await Gy()}finally{t=!1}}}),ve(tf),tf()}var ni='<path class="bg" d="M3 2h6l4 4v8H3z"/><path fill="rgba(0,0,0,.18)" d="M9 2v4h4Z"/>',re={default:`<svg class="file-icon brand-deepview" viewBox="0 0 16 16" width="14" height="14" aria-hidden="true">${ni}<path class="fg" d="M7.843 6.719c-1.605 0-2.926 1.292-3.477 1.947.466.58 1.872 2.024 3.496 2.024s2.907-1.292 3.486-2.005c-.627-.703-1.88-1.966-3.505-1.966m.019 3.857c-1.51 0-2.802-1.263-3.353-1.9.55-.617 1.814-1.852 3.334-1.852 1.51 0 2.698 1.12 3.335 1.852-.533.618-1.787 1.9-3.316 1.9m-.019-3.42c-.826 0-1.577.694-1.577 1.596 0 .789.599 1.577 1.577 1.577.893 0 1.587-.684 1.587-1.577-.01-.779-.627-1.596-1.587-1.596m0 3.069a1.476 1.476 0 0 1-1.482-1.473c0-.722.599-1.491 1.482-1.491.846 0 1.482.693 1.492 1.491 0 .808-.618 1.473-1.492 1.473m.01-2.727c-.637 0-1.264.532-1.264 1.244 0 .627.475 1.235 1.245 1.245.684 0 1.254-.522 1.254-1.244 0-.58-.475-1.236-1.235-1.245m-.02 2.403a1.167 1.167 0 0 1-1.149-1.159c0-.532.456-1.14 1.169-1.149.56 0 1.149.427 1.159 1.15 0 .636-.485 1.158-1.179 1.158m-.769-1.833c-.19.238-.275.494-.237.864l.74.057zm1.026-.294c-.295-.057-.665 0-.912.228l.323.607zm.133.047-.38.56.988.114c-.057-.275-.323-.579-.608-.674m-.124.741.456.912c.21-.209.352-.484.314-.836zm-1.225.504a.97.97 0 0 0 .57.617l.399-.551zm.713.664c.313.076.636.01.845-.161l-.295-.618zm-.637 1.55c0 .028-.028.066-.066.066h-.59c-.028 0-.066-.028-.066-.066s.029-.066.067-.066h.579c.048 0 .076.028.076.066m.712 0c0 .028-.028.066-.066.066h-.437c-.028 0-.066-.028-.066-.066s.028-.066.066-.066h.437c.038 0 .066.028.066.066m.666 0c0 .028-.029.066-.067.066h-.37c-.029 0-.067-.028-.067-.066s.029-.066.067-.066h.37c.038 0 .067.028.067.066m-1.672.351c0 .029-.029.067-.067.067h-.295c-.028 0-.066-.028-.066-.066 0-.029.029-.067.067-.067h.294c.038 0 .066.028.066.066m.694 0c0 .029-.028.067-.066.067h-.409c-.028 0-.066-.028-.066-.066 0-.029.028-.067.066-.067h.399c.038 0 .076.028.076.066m.732 0c0 .029-.029.067-.067.067h-.465c-.029 0-.067-.028-.067-.066 0-.029.029-.067.067-.067h.465c.038 0 .067.028.067.066m-1.093.371a.065.065 0 0 1-.067.066h-.627c-.028 0-.075-.028-.066-.066 0-.028.029-.066.067-.066h.627c.038 0 .066.028.066.066m.684 0a.065.065 0 0 1-.066.066h-.39c-.028 0-.076-.028-.066-.066 0-.028.028-.066.066-.066h.39c.038 0 .066.028.066.066M5.088 6.263c-.019-.105-.114-.19-.237-.19s-.257.104-.257.237.105.238.247.238c.105 0 .218-.076.238-.18h.864v.826l.095-.048V6.31c0-.028-.019-.057-.048-.057h-.902zm-.237.19c-.076 0-.143-.066-.143-.143s.066-.142.143-.142.142.066.142.143c.01.076-.066.142-.143.142m2.89-.323H6.38l.418-.475v-.332a.255.255 0 0 0 .218-.248c0-.123-.114-.256-.256-.256s-.266.114-.266.257c0 .123.095.228.209.247v.284l-.456.523v.893l.095-.047v-.742h1.396c.029 0 .067-.009.067-.057 0-.028-.019-.047-.067-.047m-1.13-1.054c0-.076.066-.152.152-.152s.152.066.152.151c0 .076-.066.152-.152.152s-.152-.066-.152-.152m-.836 5.264h-.874c-.019-.105-.114-.219-.247-.219s-.256.105-.256.257c0 .132.114.275.266.275.104 0 .218-.076.237-.19h.827v.608l-.257.285a.3.3 0 0 0-.095-.019c-.133 0-.256.105-.256.228 0 .133.104.238.237.238.124 0 .247-.105.247-.238a.23.23 0 0 0-.057-.152l.285-.304v-.712c0-.029-.019-.058-.057-.058m-1.121.219a.16.16 0 0 1-.152-.161c0-.077.066-.162.152-.162s.152.066.152.152-.066.171-.152.171m.713 1.14c-.076 0-.143-.066-.143-.143s.066-.133.143-.133.142.067.142.143c0 .066-.066.133-.143.133m5.472-1.377a.24.24 0 0 0-.237.208h-1.13c-.029 0-.038.02-.038.048v.712l-.323.39h-.029a.245.245 0 0 0-.247.247c0 .133.114.256.247.256s.247-.113.247-.256a.26.26 0 0 0-.123-.219l.313-.38v-.674h1.083c.019.105.114.2.238.2.133 0 .266-.105.266-.257 0-.133-.105-.276-.266-.276m-1.758 1.767a.15.15 0 0 1-.143-.152c0-.075.067-.142.143-.142s.152.066.152.143a.15.15 0 0 1-.152.151m1.758-1.33a.15.15 0 0 1-.143-.152.147.147 0 0 1 .294.001.15.15 0 0 1-.152.151M8.917 5.55h-.399a.075.075 0 0 1-.076-.076c0-.028.029-.066.067-.066h.418c.028 0 .066.028.066.066s-.038.076-.076.076m.742 0H9.22c-.038 0-.067-.028-.067-.076 0-.028.029-.066.067-.066h.437c.038 0 .066.028.066.066s-.028.076-.066.076m.883 0h-.598c-.029 0-.067-.028-.067-.076 0-.028.029-.066.067-.066h.598c.028 0 .066.028.066.066s-.028.076-.066.076m-1.282.4h-.741c-.038 0-.076-.029-.076-.067s.028-.076.066-.076h.75c.039 0 .067.038.067.076 0 .029-.028.067-.066.067m.797 0h-.503c-.038 0-.076-.029-.076-.067s.028-.066.066-.066h.513c.038 0 .067.028.067.066 0 .029-.029.067-.067.067m.476 0h-.19c-.039 0-.067-.029-.067-.067s.028-.066.066-.066h.2c.028 0 .066.028.066.066 0 .029-.028.067-.075.067m-1.682.398h-.332c-.039 0-.077-.028-.077-.066s.029-.066.067-.066h.342c.038 0 .076.028.076.066s-.028.066-.076.066m.789 0h-.494c-.038 0-.067-.028-.067-.066s.029-.066.067-.066h.494c.038 0 .066.028.066.066s-.028.066-.066.066m.893 0h-.599c-.038 0-.076-.028-.076-.066s.028-.066.066-.066h.618c.028 0 .066.028.066.066s-.028.066-.076.066m.418.305a.69.69 0 0 0-.674.712c0 .086.019.18.048.257l.085.066c-.028-.085-.057-.171-.057-.304 0-.285.228-.646.598-.646.295 0 .599.228.599.636a.58.58 0 0 1-.599.59.8.8 0 0 1-.237-.048l.123.114a.4.4 0 0 0 .114.01c.39 0 .684-.276.684-.666 0-.313-.266-.712-.684-.722m.353.552-.019-.01-.161.19-.143-.01-.057-.047-.019-.133.19-.2a.28.28 0 0 0-.361.077c-.076.095-.076.209-.038.351l-.247.304.171.152.266-.266c.142.038.285.019.38-.095a.31.31 0 0 0 .038-.313"/></svg>`,"claude-security":`<svg class="file-icon brand-claude" viewBox="0 0 16 16" width="14" height="14" aria-hidden="true">${ni}<path class="fg" d="m5.875 10.154 1.376-.772.023-.067-.023-.037h-.067l-.23-.015-.787-.02-.681-.03-.661-.035-.166-.035-.156-.205.016-.103.14-.094.2.018.442.03.665.046.481.028.714.075h.113l.016-.047-.039-.028-.03-.028-.687-.466-.744-.492-.39-.284-.21-.143-.106-.135-.046-.294.19-.21.258.017.065.018.26.2.557.43.726.535.106.089.042-.03.006-.022-.048-.08-.395-.713-.422-.726-.187-.301-.05-.18a1 1 0 0 1-.03-.213l.218-.296.12-.039.29.039.123.106.18.413.293.65.453.884.133.262.07.242.027.075h.046v-.043l.038-.497.069-.611.067-.787.023-.221.11-.266.218-.143.17.081.14.2-.02.13-.083.54-.163.846-.106.567h.062l.07-.07.287-.382.482-.602.213-.239.248-.264.159-.125h.301l.221.329-.099.34-.31.393-.256.333-.369.496-.23.397.021.032.055-.006.832-.177.45-.081.537-.092.243.113.026.115-.096.236-.573.141-.673.135-1.003.237-.012.01.014.017.452.042.193.01h.473l.88.066.23.153.138.186-.023.141-.354.181-.478-.113-1.116-.266-.383-.096h-.053v.032l.32.312.584.528.731.68.037.168-.094.133-.099-.014-.643-.484-.248-.218-.561-.472H9.08v.05l.129.189.684 1.027.035.315-.05.103-.177.062-.194-.036-.4-.561-.413-.632-.333-.567-.041.023-.197 2.116-.092.108-.212.082-.177-.135-.094-.218.094-.43.113-.561.092-.447.083-.554.05-.184-.004-.013-.04.006-.418.574-.636.858-.503.539-.12.048-.21-.108.02-.193.117-.172.696-.886.42-.549.27-.317-.001-.046h-.016l-1.85 1.201-.328.042-.142-.132.018-.218.067-.071.556-.383Z"/></svg>`,"codex-security":`<svg class="file-icon brand-codex" viewBox="0 0 16 16" width="14" height="14" aria-hidden="true">${ni}<path class="fg" d="M11.04 8.364a1.72 1.72 0 0 0-.152-1.432 1.8 1.8 0 0 0-1.925-.846 1.8 1.8 0 0 0-.778-.498 1.8 1.8 0 0 0-.927-.05 1.8 1.8 0 0 0-.827.414 1.77 1.77 0 0 0-.507.767 1.8 1.8 0 0 0-.683.297 1.75 1.75 0 0 0-.499.549 1.75 1.75 0 0 0 .22 2.07 1.72 1.72 0 0 0 .151 1.432 1.8 1.8 0 0 0 1.926.846 1.77 1.77 0 0 0 1.333.587c.78 0 1.47-.496 1.707-1.227a1.8 1.8 0 0 0 .684-.298 1.75 1.75 0 0 0 .499-.548 1.75 1.75 0 0 0-.222-2.063m-2.667 3.678a1.33 1.33 0 0 1-.851-.304l.042-.024 1.413-.804a.23.23 0 0 0 .116-.199V8.747l.597.34q.01.005.011.015v1.629a1.323 1.323 0 0 1-1.328 1.31m-2.857-1.203a1.3 1.3 0 0 1-.158-.879l.042.025 1.414.805a.23.23 0 0 0 .23 0l1.729-.982v.68a.02.02 0 0 1-.01.018l-1.431.814a1.34 1.34 0 0 1-1.816-.48m-.372-3.037a1.32 1.32 0 0 1 .7-.574v1.656a.22.22 0 0 0 .114.197l1.72.979-.598.34a.02.02 0 0 1-.021 0L5.63 9.587a1.304 1.304 0 0 1-.487-1.791zm4.907 1.125L8.327 7.94l.596-.34a.02.02 0 0 1 .02 0l1.43.814a1.3 1.3 0 0 1 .512.528 1.3 1.3 0 0 1-.118 1.4 1.33 1.33 0 0 1-.595.436V9.122a.23.23 0 0 0-.12-.195m.594-.881-.042-.025-1.411-.812a.23.23 0 0 0-.232 0l-1.727.983v-.68a.02.02 0 0 1 .008-.018l1.429-.813a1.34 1.34 0 0 1 1.425.061 1.3 1.3 0 0 1 .55 1.298zM6.908 9.252l-.597-.34a.02.02 0 0 1-.012-.016V7.271c0-.249.073-.493.209-.703s.329-.378.557-.483a1.35 1.35 0 0 1 1.415.18l-.042.023-1.413.804a.23.23 0 0 0-.116.2zm.324-.69.77-.438.77.438v.875l-.768.437-.77-.437z"/></svg>`,deepsec:`<svg class="file-icon brand-vercel" viewBox="0 0 16 16" width="14" height="14" aria-hidden="true">${ni}<path class="fg" d="m8 5.97 3.5 6.062h-7Z"/></svg>`};function Xe(e){let t=lo(e);if(t==="deepsec")return"deepsec";if(t==="claude-security")return"claude-security";let r=e.toLowerCase();return r.endsWith(".codex")?"codex-security":r.endsWith(".md")?"claude-security":"default"}function Me(e){return e.toLowerCase().endsWith(".codex")?e.slice(0,-6).replaceAll("__","/"):e}var nf=globalThis[Symbol.for("@rray/frontend")];if(!nf)throw new Error("@rray/frontend global not installed; view.js must run before lazy bundles import this wrapper");var{LitElement:MS,html:zl,nothing:of,unsafeCSS:LS,render:PS,StateElement:OS,classMap:NS,repeat:DS,styleMap:zS}=nf;var Le={critical:6,high:5,medium:4,low:3,high_bug:2,bug:1,informational:0},ke=["critical","high","medium","low","high_bug","bug","informational"],oi="node_modules";function cf(e){let t=n=>/(^|\/)node_modules\//u.test(n),r=!1;e:for(let n of e){for(let o of n.groups??[])for(let s of o)if(t(s.file)){r=!0;break e}if(n.tree){for(let o of Object.keys(n.tree))if(t(o)){r=!0;break e}}}oi=r?"node_modules":"dependencies"}function df(){return oi}function tr(e){return oi==="node_modules"?/(^|\/)node_modules\//u.test(e):/(^|\/)dependencies\//u.test(e)}function ee(e){return typeof e!="number"||!Number.isFinite(e)?null:`${e.toLocaleString()} B`}function Qe(e){if(e.length<=1)return{prefix:"",stripped:[...e]};let t=e.map(i=>i.split("/")),r=Math.min(...t.map(i=>i.length)),n=0;for(let i=0;i<r-1&&t.every(l=>l[i]===t[0][i]);i++)n=i+1;if(n>0&&t[0][n-1].startsWith("@")&&n--,n>0&&t[0][n-1]==="node_modules"&&n--,n===0)return{prefix:"",stripped:[...e]};let o=`${t[0].slice(0,n).join("/")}/`,s=t.map(i=>i.slice(n).join("/"));return{prefix:o,stripped:s}}function Yy(e){let t=oi==="node_modules"?/^(?:.*\/)?node_modules\/(?:@[^/]+\/[^/]+|[^/]+)\/(.*)$/u:/^(?:.*\/)?dependencies\/(?:@[^/]+\/[^/]+|[^/]+)\/(.*)$/u;return e.match(t)?.[1]??e}function ot(e,t){if(!e)return e;let r=e;t?.exportsMode==="isolate"&&(r=r.replace(/^\((?:[^()]|\([^()]*\))*\): \[export:\s*\w+\] /u,""),r=r.replace(/^\[export:\s*\w+\] /u,""));let n=[t?.exportName,t?.methodName].filter(Boolean);for(let o of n){let s=o.replaceAll(/[.*+?^${}()|[\]\\]/gu,"\\$&");r=r.replaceAll(new RegExp(`\\[export:\\s*${s}\\]\\s*`,"gu"),"")}for(let o of n){let s=o.replaceAll(/[.*+?^${}()|[\]\\]/gu,"\\$&");r=r.replace(new RegExp(`^\\(\`?${s}\`?\\): `,"u"),"")}return r}function Er(e){let t=e?.exportName,r=e?.methodName;return t&&r&&t!==r?`${t}.${r}`:t||r||""}function uf(e){return[e.file,e.description,e.recommendation,e.confidenceReason,e.discoveredIn,e.repo?.github].filter(Boolean).join(`
31
+ `).toLowerCase()}function So(e){return e&&e.replace(/^[^/]+\//u,"").replace(/^claude-/u,"").replaceAll("-"," ")}function Ar(e){return[e.type,So(e.model),e.effort,e.exportsMode].filter(Boolean).join(" \xB7 ")}function si(e){if(e.length===0)return"";let t=e[0];for(let r=1;r<e.length;r++){for(;t&&!e[r].startsWith(t);)t=t.slice(0,-1);if(!t)return""}return t}function pf(e){if(!e)return null;let t=e.trim().replace(/\/$/u,"");return t?/^https?:\/\//iu.test(t)?t:/^github\.com\//iu.test(t)?`https://${t}`:`https://github.com/${t}`:null}function cn(e,t,r){if(t)return`https://github.com/${t}/blob/HEAD/${Yy(e)}`;if(tr(e))return null;let n=pf(r);return n?`${n}/blob/HEAD/${e}`:null}function Hl(e,t,r){let n=cn(e,t,r);return n?zl`<a href="${n}" target="_blank" rel="noopener">${e}</a>`:e}function dn(e){if(typeof e!="string"||e.length===0)return!1;try{let t=new URL(e);return t.protocol==="http:"||t.protocol==="https:"}catch{return!1}}function ff(e,t,r,n){let o=parseInt(t,10);if(!Number.isFinite(o))return of;let s=cn(e,r,n),i=`line ${o}`;return s?zl`<a href="${`${s}#L${o}`}" target="_blank" rel="noopener">${i}</a>`:i}function hf(e,t){return!e||!t?null:`${/^https?:/iu.test(e)?e.replace(/\/$/u,""):`https://github.com/${e}`}/commit/${t}`}function gf(e,t){let r=[];return t&&r.push(`Repo: ${t}`),e.file&&r.push(`File: ${e.file}`),e.line!==void 0&&e.line!==null&&e.line!==""&&r.push(`Line: ${e.line}`),e.description&&r.push(`Description: ${e.description}`),e.confidence!==void 0&&e.confidence!==null&&r.push(`Confidence: ${e.confidence}/10`),r.join(`
32
+ `)}function mf(e,{title:t,body:r}={}){let n=pf(e);if(!n)return null;let o;try{o=new URL(n).host.toLowerCase()}catch{return null}if(o!=="github.com")return null;let s=new URLSearchParams;t&&s.set("title",t),r&&s.set("body",r);let i=s.toString();return i?`${n}/issues/new?${i}`:`${n}/issues/new`}var Jy=/^[a-zA-Z\d](?:-?[a-zA-Z\d])*$/u,Xy=/^[a-zA-Z\d._-]+$/u,Qy=/^[1-9]\d{0,9}$/u,Zy=/^[a-fA-F\d]{7,40}$/u,ew=/^#[\w-]+$/u,sf=/^GHSA(?:-[0-9a-z]{4}){3}$/u;function af(e){return e.length<=39&&Jy.test(e)}function lf(e){return e.length<=100&&e!=="."&&e!==".."&&Xy.test(e)}function tw(e){let t;try{t=new URL(e)}catch{return null}if(t.href!==e||t.protocol!=="https:"||t.hostname.toLowerCase()!=="github.com"||t.port||t.username||t.password)return null;let r=t.pathname.split("/");if(r.at(-1)===""&&r.pop(),r.length===3&&r[1]==="advisories"){let p=r[2];return sf.test(p)?{url:`https://github.com/advisories/${p}`,label:p}:null}if(r.length===6&&r[3]==="security"&&r[4]==="advisories"){let[,p,f,,,h]=r;return!af(p)||!lf(f)||!sf.test(h)?null:{url:`https://github.com/${p}/${f}/security/advisories/${h}`,label:h}}if(r.length!==5)return null;let[,n,o,s,i]=r;if(!af(n)||!lf(o))return null;let l;if(s==="issues"||s==="pull"){if(!Qy.test(i))return null;l=`${n}/${o}#${i}`}else if(s==="commit"){if(!Zy.test(i))return null;l=`${n}/${o}@${i.slice(0,7)}`}else return null;let d=ew.test(t.hash)?t.hash:"";return{url:`https://github.com/${n}/${o}/${s}/${i}${d}`,label:l}}var Ul=/https?:\/\/[^\s<>"'`(){}[\]|\\^]+/giu,rw=new Set([")",".",",","!","?",";",":","'",'"',"*","]","}",">"]);function nw(e){let t=e.length;for(;t>0&&rw.has(e[t-1]);)t--;return t===e.length?e:e.slice(0,t)}function bf(e){if(typeof e!="string"||e.length===0)return[];let t=[],r=0;Ul.lastIndex=0;let n;for(;(n=Ul.exec(e))!==null;){let o=nw(n[0]),s=o?tw(o):null;s&&(n.index>r&&t.push(e.slice(r,n.index)),t.push(s),r=n.index+o.length,Ul.lastIndex=r)}return r<e.length&&t.push(e.slice(r)),t}var un="\0",Co="",pn="";function Eo(e){return So(e.model)||null}function Wl(e){if(a.filterAnalyzer){let t=e._analyzer??null,r=a.filterAnalyzer===un?null:a.filterAnalyzer;if(t!==r)return!1}if(a.filterModel){let t=Eo(e),r=a.filterModel===pn?null:a.filterModel;if(t!==r)return!1}return!0}function Vl(e){return typeof e.repo?.github=="string"&&e.repo.github?e.repo.github:typeof e._repoFallback=="string"&&e._repoFallback?e._repoFallback:null}function ii(){a.filterSeverities=new Set,a.filterColors=new Set,a.filterSources=new Set,a.filterAnalyzer="",a.filterModel="",a.filterRepo="",a.filterConfMin=0,a.filterConfMax=10,a.filterInclude="",a.filterIncludeNegate=!1,a.filterComment="",a.filterFix="",a.filterFlagged="";let e=a.reports.some(t=>t.groups.some(r=>r.some(n=>n.priority!==void 0)));a.sortBy=e?"priority-desc":"severity"}function ow(e){let t=a.filterInclude.toLowerCase();if(a.filterSeverities.size>0&&!a.filterSeverities.has(e.severity))return!1;if(a.filterColors.size>0){let r=a.triage.get(P(e))?.color??"none";if(!a.filterColors.has(r))return!1}if(a.filterSources.size===1){let r=a.filterSources.has("own");if(r&&tr(e.file)||!r&&!tr(e.file))return!1}if(!Wl(e))return!1;if(a.filterRepo){let r=Vl(e),n=a.filterRepo===Co?null:a.filterRepo;if(r!==n)return!1}if(e.confidence===void 0){if(e.critical===!0){if(a.filterConfMax<10)return!1}else if(a.filterConfMin>0)return!1}else if(e.confidence<a.filterConfMin||a.filterConfMax<10&&e.confidence>a.filterConfMax)return!1;if(t){let r=a.triage.get(P(e)),n=uf(e).includes(t)||(r?.comment??"").toLowerCase().includes(t)||(r?.fix??"").toLowerCase().includes(t);return a.filterIncludeNegate?!n:n}return!0}function sw(e){if(!a.filterComment&&!a.filterFix&&!a.filterFlagged)return!0;let t=r=>e.some(n=>r(a.triage.get(P(n))));if(a.filterComment){let r=t(n=>!!n?.comment);if(a.filterComment==="with"?!r:r)return!1}if(a.filterFix){let r=t(n=>!!n?.fix);if(a.filterFix==="with"?!r:r)return!1}if(a.filterFlagged){let r=t(n=>n?.flagged===!0);if(a.filterFlagged==="with"?!r:r)return!1}return!0}function vf(e){return e.filter(t=>t.some(ow)&&sw(t))}function yf(e,t,r){return(n,o)=>{let s=n[e]??r,i=o[e]??r;return(t==="desc"?i-s:s-i)||n.file.localeCompare(o.file)}}function kf(e){let t=e==="desc"?-1:11;return(r,n)=>{let o=r.confidence===void 0&&r.critical===!0,s=n.confidence===void 0&&n.critical===!0,i=r.confidence??(o?10:t),l=n.confidence??(s?10:t);return(e==="desc"?l-i:i-l)||(o===s?0:o?-1:1)||r.file.localeCompare(n.file)}}var wf=kf("desc"),iw={severity:(e,t)=>(Le[t.severity]||0)-(Le[e.severity]||0)||wf(e,t)||parseInt(e.line,10)-parseInt(t.line,10),"confidence-desc":wf,"confidence-asc":kf("asc"),"priority-desc":yf("priority","desc",-1),"priority-asc":yf("priority","asc",11)};function $f(e){let t=iw[a.sortBy];return t?e.map(r=>({p:Tr(r),g:r})).toSorted((r,n)=>t(r.p,n.p)).map(r=>r.g):[...e]}function P(e){return e.id??String(e._id)}function Ie(e){return P(e[0])}function jl(e){return Array.isArray(e)?e:[e]}function ai(e){return e?._reportName??""}function fn(e){return Mt(a.triage,P(e),ai(e))}function hn(e){return e.length<=1?e:[...e].toSorted((t,r)=>{let n=a.triage.get(P(t))?.color?1:0,o=a.triage.get(P(r))?.color?1:0;if(n!==o)return o-n;let s=Le[t.severity]||0,i=Le[r.severity]||0;if(s!==i)return i-s;let l=t.confidence??-1;return(r.confidence??-1)-l})}function Tr(e){return e.length===1?e[0]:hn(e)[0]}function aw(e){let t=a.triage.get(P(e));return!!t?.comment||!!t?.fix||t?.flagged===!0}function ze(e){if(e.length===1)return e[0];let t=a.activeTabByGroup.get(Ie(e));if(t){let o=e.find(s=>P(s)===t);if(o)return o}let r=hn(e),n=r;if(a.filterAnalyzer||a.filterModel){let o=r.filter(Wl);o.length>0&&(n=o)}return n.find(aw)??n[0]}function li(e){for(let t of $t().values())if(t.files.has(e.file))return t.repos&&t.repos.size===1?[...t.repos][0]:null;return e.repo?.github??e._repoFallback??a.repoUrl??null}function Ue(e){let t=0,r=!1,n,o=!1,s=!1,i,l=!1,d=null,u=!1,p=!0;for(let y of e){let v=a.triage.get(P(y)),w=v?.triage??(fn(y)?"ignored":void 0),k=v?.color;k===void 0&&w===void 0||(t++,k!==void 0&&(o?k!==n&&(r=!0):(o=!0,n=k)),l?w!==i&&(s=!0):(l=!0,i=w),w?(d===null&&(d=w),w==="ignored"?p=!1:u=!0):p=!1)}let f=r||s,h=!f&&o?n:null,b=t>0&&p,m=!f&&d!==null?d:null;return{hasConflict:f,commonColor:h,anyTriage:u,allTriaged:b,commonTriage:m,isInProgress:m==="inprogress",isFixed:m==="fixed",isInvalid:m==="invalid",isDeleted:m==="deleted",isIgnored:m==="ignored"}}function Ir(){let e=a.reports.flatMap(d=>d.groups),t=a.workspaceMerges;if(!t||t.length===0)return e;let r=e.map((d,u)=>u),n=d=>{let u=d;for(;r[u]!==u;)u=r[u];for(;r[d]!==u;){let p=r[d];r[d]=u,d=p}return u},o=(d,u)=>{let p=n(d),f=n(u);p!==f&&(r[p]=f)},s=new Map;for(let d=0;d<e.length;d++)for(let u of e[d])u.id&&s.set(u.id,d);for(let d of t){let u=-1;for(let p of d){let f=s.get(p);f!==void 0&&(u===-1?u=f:o(u,f))}}let i=new Set,l=[];for(let d=0;d<e.length;d++){let u=n(d);if(i.has(u))continue;i.add(u);let p=[];for(let w=d;w<e.length;w++)n(w)===u&&p.push(...e[w]);let f=new Set(p.map(w=>w.id).filter(Boolean)),h=[],b=new Set;for(let w of t)for(let k of w)b.has(k)||f.has(k)&&(h.push(k),b.add(k));if(h.length===0){l.push(p);continue}let m=new Map;for(let w of p)w.id&&!m.has(w.id)&&m.set(w.id,w);let y=new Set,v=[];for(let w of h){let k=m.get(w);k&&(v.push(k),y.add(k))}for(let w of p)y.has(w)||v.push(w);l.push(v)}return l}function Rr(e){for(let t of Ir())if(Ie(t)===e)return t;return null}var Gl={"claude-security":"Claude Security","codex-security":"Codex Security",deepsec:"DeepSec"};function xf(e){return e==null?"(none)":Gl[e]??e}function _f(e){return e??"(no model)"}var Kl=class extends O{static properties={analyzers:{attribute:!1},models:{attribute:!1},groups:{attribute:!1},_open:{state:!0}};createRenderRoot(){return this}constructor(){super(),this.analyzers=[],this.models=[],this.groups=[],this._open=!1}render(){let t=this.analyzers.length>1,r=this.models.length>1;if(!t&&!r)return g;let n=a.filterAnalyzer===""?void 0:a.filterAnalyzer===un?null:a.filterAnalyzer,o=a.filterModel===""?void 0:a.filterModel===pn?null:a.filterModel,s=new Map,i=new Map;for(let f of this.groups){let h=new Set,b=new Set;for(let m of f){let y=m._analyzer??null,v=Eo(m);(o===void 0||v===o)&&h.add(y),(n===void 0||y===n)&&b.add(v)}for(let m of h)s.set(m,(s.get(m)??0)+1);for(let m of b)i.set(m,(i.get(m)??0)+1)}let l=n===void 0?null:xf(n),d=o===void 0?null:_f(o),u=l!=null&&d!=null?`${l} \xB7 ${d}`:l??d??(t?"All analyzers":"All models"),p=l!=null||d!=null;return c`<button type="button" class="${R({"analyzer-btn":!0,active:p})}" popovertarget="analyzer-select-menu" popovertargetaction="toggle" title="Filter by analyzer / model" aria-label="${`Filter by analyzer / model: ${u}`}"><span class="analyzer-btn-label">${u}</span> <svg viewBox="0 0 12 12" width="11" height="11" aria-hidden="true"><path d="M2 4l4 4 4-4" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg></button><div popover="auto" id="analyzer-select-menu" class="analyzer-menu" @beforetoggle="${this._onToggle}">${t?this._column({dim:"analyzer",heading:"Analyzer",allLabel:"All analyzers",values:this.analyzers,sentinel:un,labelOf:xf,counts:s,current:a.filterAnalyzer}):g} ${t&&r?c`<div class="analyzer-menu-sep"></div>`:g} ${r?this._column({dim:"model",heading:"Model",allLabel:"All models",values:this.models,sentinel:pn,labelOf:_f,counts:i,current:a.filterModel}):g}</div>`}_column({dim:t,heading:r,allLabel:n,values:o,sentinel:s,labelOf:i,counts:l,current:d}){return c`<div class="analyzer-menu-col" role="group" aria-label="${`Filter by ${t}`}"><div class="analyzer-menu-head">${r}</div><button type="button" aria-pressed="${String(d==="")}" class="${R({"analyzer-menu-item":!0,active:d===""})}" @click="${()=>this._pick(t,"")}"><span class="analyzer-menu-label">${n}</span></button> ${o.map(u=>{let p=u??s,f=l.get(u)??0,h=d===p;return c`<button type="button" aria-pressed="${String(h)}" class="${R({"analyzer-menu-item":!0,active:h,zero:f===0})}" @click="${()=>this._pick(t,p)}"><span class="analyzer-menu-label">${i(u)}</span><span class="analyzer-menu-count">${f}</span></button>`})}</div>`}_pick(t,r){let n=t==="analyzer"?a.filterAnalyzer:a.filterModel,o=r!==""&&n===r?"":r;this.dispatchEvent(new CustomEvent("analyzer-change",{detail:{analyzer:t==="analyzer"?o:a.filterAnalyzer,model:t==="model"?o:a.filterModel},bubbles:!0,composed:!0}))}_onToggle=t=>{this._open=t.newState==="open",this._open&&this._position()};_position(){let t=this.querySelector(".analyzer-menu"),r=this.querySelector(".analyzer-btn");if(!t||!r)return;let n=r.getBoundingClientRect(),o=t.offsetWidth||240,s=t.offsetHeight||200,i=4,l=n.left;l+o>window.innerWidth-4&&(l=window.innerWidth-o-4),l<4&&(l=4);let d=n.bottom+i;d+s>window.innerHeight-4&&n.top>s+i&&(d=n.top-s-i),t.style.top=`${d}px`,t.style.left=`${l}px`}updated(){this._open&&this.querySelector(".analyzer-menu")?.matches(":popover-open")&&this._position()}};customElements.define("analyzer-select",Kl);function gn(e){return e==="informational"?"info":e.replaceAll("_"," ")}function ci(e){if(!e)return"";for(let t of e.split(`
33
+ `))if(t.trim())return t.trim();return""}function lw(e){if(!e)return{title:"",body:""};let t=e.indexOf(`
34
+ `);if(t<0)return{title:"",body:e};let r=e.slice(t+1).replace(/^\s+/u,"");return r?{title:e.slice(0,t).trim(),body:r}:{title:"",body:e}}var Sf=/"[^"\n]+"|`[^`\n]+`/gu;function Fr(e){if(!e)return e;Sf.lastIndex=0;let t=[],r=0,n;for(;(n=Sf.exec(e))!==null;){n.index>r&&t.push(e.slice(r,n.index));let o=n[0].codePointAt(0)===96?"inline-code":"inline-quote";t.push(c`<span class="${o}">${n[0]}</span>`),r=n.index+n[0].length}return r===0?e:(r<e.length&&t.push(e.slice(r)),t)}function cw(e){return bf(e).map(t=>typeof t=="string"?t:c`<a href="${t.url}" target="_blank" rel="noopener noreferrer" title="${t.url}">${t.label}</a>`)}function dw(e){let t=cn(e.file,e.repo?.github,e._repoFallback??a.repoUrl),r=parseInt(e.line,10),n=Number.isFinite(r)?`${e.file}:${e.line}`:e.file;if(!t)return n;let o=Number.isFinite(r)?`${t}#L${r}`:t;return c`<a href="${o}" target="_blank" rel="noopener">${n}</a>`}function uw(e,t){if(!t)return g;let r=t.slice(0,7),n=hf(e,t);return n?c`<a href="${n}" target="_blank" rel="noopener" title="${t}">${r}</a>`:c`<span title="${t}">${r}</span>`}var Cf=c`<svg viewBox="0 0 16 16" width="11" height="11" aria-hidden="true"><path class="bubble" d="M2.5 3h11a.5.5 0 0 1 .5.5v6.5a.5.5 0 0 1-.5.5H8.4l-3 2.6V10.5H2.5a.5.5 0 0 1-.5-.5V3.5a.5.5 0 0 1 .5-.5z" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linejoin="round"/></svg>`,Ef=c`<svg viewBox="0 0 16 16" width="11" height="11" aria-hidden="true"><path class="wrench" d="M10.4 2.6a3 3 0 0 0-3.6 4.5L2 12l2 2 4.9-4.8a3 3 0 0 0 4.5-3.6l-1.8 1.8-1.5-.4-.4-1.5z" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linejoin="round"/></svg>`,pw=c`<svg viewBox="0 0 16 16" width="11" height="11" aria-hidden="true"><rect x="3" y="2.5" width="8" height="10" rx="1" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linejoin="round"/><rect x="5.5" y="5" width="8" height="9" rx="1" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linejoin="round"/></svg>`,fw=c`<svg viewBox="0 0 16 16" width="11" height="11" aria-hidden="true"><g stroke="currentColor" stroke-width="1.2" stroke-linecap="round" fill="none"><line x1="8" y1="1.8" x2="8" y2="14.2"/><line x1="1.8" y1="8" x2="14.2" y2="8"/><line x1="3.6" y1="3.6" x2="12.4" y2="12.4"/><line x1="12.4" y1="3.6" x2="3.6" y2="12.4"/></g></svg>`,hw=c`<svg viewBox="0 0 16 16" width="11" height="11" aria-hidden="true"><circle cx="8" cy="8" r="6" fill="none" stroke="currentColor" stroke-width="1.2"/><circle cx="8" cy="8" r="1.7" fill="currentColor"/></svg>`,di=c`<svg viewBox="0 0 16 16" width="11" height="11" aria-hidden="true"><path class="flag-cloth" d="M5 1.5h6v13l-3-2.7-3 2.7z" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linejoin="round"/></svg>`;function gw(e,t=!1){let r=a.triage.get(e)?.flagged===!0,n=r?"Remove flag":"Flag this finding";return c`<button type="button" class="${R({"mark-flag":!0,flagged:r})}" data-flag-toggle="${e}" title="${n}" aria-label="${n}" aria-pressed="${String(r)}">${di}${t?c`<span class="mark-btn-label">${r?"Flagged":"Flag"}</span>`:g}</button>`}function mw(e){let t=ci(e.description)||e.file||"Security finding";return t.length>120?`${t.slice(0,119)}\u2026`:t}function bw(e){let t=cn(e.file,e.repo?.github,e._repoFallback??a.repoUrl),r=parseInt(e.line,10),n=Number.isFinite(r),o=n?`${e.file}:${r}`:e.file,s=t&&n?`${t}#L${r}`:t,i=[];return e.file&&i.push(`File: ${s?`[${o}](${s})`:o}`),e.description&&i.push(e.description),e.confidence!==void 0&&e.confidence!==null&&i.push(`Confidence: ${e.confidence}/10`),i.join(`
35
+
36
+ `)}function yw(e){if(!a.currentWorkspace)return g;let t=e[0]?._reportName;if(!t)return g;let r=re[Xe(t)]??re.default;return c`<span class="report-chip" title="${t}">${me(r)}<span class="report-chip-label">${Me(t)}</span></span>`}function Af(e,t,r,n,o=null){let s=yw(e),i=P(n),l=a.triage.get(i),d=l?.color??null,u=l?.comment??"",p=l?.fix??"",f=u?`Edit comment: ${u}`:"Add comment",h=p?`Edit fix link: ${p}`:"Add fix link (PR URL, etc.)",b=o==="focus",m=u?"Edit comment":"Comment",y=p?"Edit fix link":"Fix link",v=c`<button type="button" class="${R({"mark-comment":!0,"has-comment":u})}" title="${f}" aria-label="${f}">${Cf}${b?c`<span class="mark-btn-label">${m}</span>`:g}</button>`,w=c`<button type="button" class="${R({"mark-fix":!0,"has-fix":p})}" title="${h}" aria-label="${h}">${Ef}${b?c`<span class="mark-btn-label">${y}</span>`:g}</button>`,k=gw(i,b),E=c`<button type="button" class="mark-copy" title="Copy file, line, description, confidence to clipboard" aria-label="Copy finding details to clipboard">${pw}${b?c`<span class="mark-btn-label">Copy</span>`:g}</button>`,S=li(n),x=mf(S,{title:mw(n),body:bw(n)}),T=x?c`<a class="mark-issue" href="${x}" target="_blank" rel="noopener" title="Create a pre-filled GitHub issue for this finding" aria-label="Create a GitHub issue for this finding">${hw}${b?c`<span class="mark-btn-label">Issue</span>`:g}</a>`:g,N=c`<button type="button" class="mark-claude" title="Open in Claude Code (claude://) with a confirm-and-fix prompt" aria-label="Open finding in Claude Code">${fw}${b?c`<span class="mark-btn-label">Claude</span>`:g}</button>`,Z=c`<color-marker .selected="${d}"></color-marker>`,W=r.hasConflict?"change triage state (colors mismatch \u2014 acts per-tab)":t.length>1?"change triage state for the whole group":"change triage state";return c`${s}<span class="mark-action-group">${v}${w}${k}</span><span class="mark-action-group">${E}${T}${N}</span>${Z}${vw(e,W,o,r,n)}`}function ww(e){if(e.newState!=="open")return;let t=e.currentTarget,n=t.getRootNode().querySelector?.(`[popovertarget="${t.id}"]`);if(!n)return;let o=n.getBoundingClientRect(),s=t.offsetWidth||110,i=t.offsetHeight||100,l=4,d=o.right-s;d<4&&(d=4),d+s>window.innerWidth-4&&(d=window.innerWidth-s-4);let u=o.bottom+l;u+i>window.innerHeight-4&&o.top>i+l&&(u=o.top-i-l),t.style.top=`${u}px`,t.style.left=`${d}px`}function vw(e,t,r,n,o){let s=P(e[0]),i=P(o),l=n.hasConflict?a.triage.get(i)?.triage??(fn(o)?"ignored":null):n.commonTriage,d={inprogress:"In progress",fixed:"Fixed",invalid:"Invalid",deleted:"Deleted",ignored:"Ignored"},u={inprogress:"In progress",fixed:"Fixed",invalid:"Invalid",deleted:"Delete",ignored:"Ignore"},p=!!a.shownTriage,f=p?d[a.shownTriage]:null,h=["inprogress","fixed","invalid","deleted","ignored"],b=r==="focus",m;b?m=h.map(w=>({key:w,label:u[w]})):p?m=[{key:"restore",label:"Restore"},...h.filter(w=>w!==a.shownTriage).map(w=>({key:w,label:u[w]}))]:m=h.map(w=>({key:w,label:u[w]}));let y=["mark-triage-menu"];p&&y.push("with-label",`triage-state-${a.shownTriage}`);let v=`triage-menu-${s.replaceAll(/[^A-Za-z0-9_-]/gu,"_")}`;return c`<div class="triage-menu-wrap"><button type="button" class="${y.join(" ")}" popovertarget="${v}" popovertargetaction="toggle" title="${t}" aria-label="${t}">${f?c`<span class="mark-triage-label">${f}</span>`:g} <svg viewBox="0 0 12 12" width="11" height="11" aria-hidden="true"><path d="M2 4l4 4 4-4" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg></button><div popover="auto" id="${v}" class="triage-menu" data-gid="${s}" role="menu" @beforetoggle="${ww}">${m.map(w=>c`<button type="button" class="${R({"triage-menu-item":!0,[`triage-menu-${w.key}`]:!0,active:l===w.key})}" data-triage-action="${w.key}" role="menuitem">${w.label}</button>`)}</div></div>`}function kw(e){let t=!!e?.comment,r=!!e?.fix,n=e?.flagged===!0;return!t&&!r&&!n?g:c`<span class="tab-marks">${t?c`<span class="has-comment" title="Has a comment">${Cf}</span>`:g}${r?c`<span class="has-fix" title="Has a fix link">${Ef}</span>`:g}${n?c`<span class="flagged" title="Flagged">${di}</span>`:g}</span>`}function Tf(e,t){let r=P(e),n=a.triage.get(r),o=n?.color,s=n?.triage,i=fn(e),l=["tab"];return t&&l.push("active"),o&&l.push(`tab-mark-${o}`),s?l.push(`tab-${s}`):i&&l.push("tab-ignored"),c`<button type="button" class="${l.join(" ")}" data-tid="${r}"><span class="tab-label"><span class="${`badge ${e.severity}`}">${gn(e.severity)}</span> ${e.confidence===void 0?g:c`<span class="tab-conf">${e.confidence}/10</span>`}${kw(n)}</span></button>`}function $w(e){if(a.viewMode==="table"||a.viewMode==="focus"){let t=e.confidence*10;return c`<div class="${`conf-ring ${e.severity}`}"><svg viewBox="0 0 36 36" aria-hidden="true"><circle class="conf-ring-track" cx="18" cy="18" r="15.9155"/><circle class="conf-ring-arc" cx="18" cy="18" r="15.9155" style="${`stroke-dasharray: ${t} 100`}"></circle></svg> <span>${e.confidence}<small>/10</small></span></div><div class="value-label">Confidence</div>`}return c`<div class="conf-score"><strong>${e.confidence}</strong>/10</div><div class="value-label">Confidence</div>`}var xw=/^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/iu;function _w(e){if(Vr(e))return g;let t=e?.name;if(typeof t!="string"||!xw.test(t))return g;let r=e?.version,n=typeof r=="string"&&r.length>0,o=n?`https://www.npmjs.com/package/${t}/v/${encodeURIComponent(r)}`:`https://www.npmjs.com/package/${t}`,s=n?`${t}@${r}`:t;return c`<span class="line-num"><a class="npm-link" href="${o}" target="_blank" rel="noopener noreferrer" title="${`Open ${s} on npmjs.com`}">npm: ${s}</a></span>`}function Sw(e,t,r=0,n=1,o=null){let s=P(e),i=a.triage.get(s),l=i?.comment??"",d=i?.fix??"",u=cn(e.file,e.repo?.github,e._repoFallback??a.repoUrl),p=parseInt(e.line,10),f=Number.isFinite(p),h=f?`${e.file}:${e.line}`:e.file,b=u?c`<a href="${f?`${u}#L${p}`:u}" target="_blank" rel="noopener">${h}</a>`:h,m=Er(e),y=m?c`<span class="line-num">${b}, ${m}</span>`:c`<span class="line-num">${b}</span>`,v=Ar(e),w=o==="focus"?_w(e.package?.npm):g,k=g;if(o!=="focus"&&e.fileHash&&Array.isArray(e._bundleHashes)&&e._bundleHashes.length>0){let x=new Set(e._bundleHashes),T=Sr(e.fileHash).find(({integrity:N})=>x.has(N));T&&(k=c`<button type="button" class="finding-code-btn" data-finding-code-bundle="${T.integrity}" data-finding-code-file="${T.file}" data-finding-code-line="${e.line??""}" title="${`Open ${T.file} in bundle source viewer`}">Code</button>`)}let{title:E,body:S}=lw(ot(e.description,e));return c`<div class="${R({"tab-body":!0,active:t})}" data-tid="${s}">${n>1?c`<div class="print-case-label">${r+1} of ${n}</div>`:g}<div class="finding-left"><span class="${`badge ${e.severity}`}">${gn(e.severity)}</span><div class="value-label">Severity</div>${e.confidence===void 0?g:$w(e)} ${k}</div><div><div class="line-row">${y} ${w} ${e.discoveredIn?c`<span class="line-num discovered-in">(found analyzing ${e.discoveredIn})</span>`:g} ${v?c`<span class="run-meta">${v}</span>`:g}</div>${E?c`<div class="desc-title">${E}</div>`:g} ${S?c`<div class="desc">${Fr(S)}</div>`:g} ${e.recommendation?c`<div class="recommendation">Recommendation: ${Fr(ot(e.recommendation,e))}</div>`:g} ${e.confidenceReason?c`<div class="conf-reason">${Fr(ot(e.confidenceReason,e))}</div>`:g} ${l?c`<div class="comment-block"><span class="comment-label">Comment:</span> ${cw(l)}</div>`:g} ${d?c`<div class="fix-block"><span class="fix-label">Fix:</span> ${dn(d)?c`<a href="${d}" target="_blank" rel="noopener noreferrer">${d}</a>`:d}</div>`:g}</div></div>`}function mn(e){return Ie(e)}function If(e){let t=Ue(e),r=hn(e),n=e.some(s=>s.critical||s.severity==="critical"),o=["finding"];return n&&o.push("is-critical"),t.hasConflict?o.push("has-conflict"):t.commonColor&&o.push(`mark-${t.commonColor}`),a.shownTriage&&o.push(`triage-${a.shownTriage}`),r.length>1&&o.push("multi-case"),o}function Rf(e,t={}){let{context:r=null}=t,n=Ue(e),o=hn(e),s=ze(e),i=P(s),l=s.commitHash?c`<div class="commit-ref">introduced in ${uw(s.repo?.github,s.commitHash)}</div>`:g,d=a.currentWorkspace&&l!==g;return c`${o.map((u,p)=>Sw(u,P(u)===i,p,o.length,r))} ${d?c`<div class="marks-commit-row">${l}</div>`:g}<div class="marks"><div class="marks-left">${d?g:l} ${o.length>1?c`<div class="tabs">${o.map(u=>Tf(u,P(u)===i))}</div>`:g}</div>${Af(e,o,n,s,r)}</div>`}function Ao(e){return Ie(e)}function Ff(e){let t=Ue(e),r=e.some(o=>o.critical||o.severity==="critical"),n=[];return r&&n.push("is-critical"),t.hasConflict?n.push("has-conflict"):t.commonColor&&n.push(`mark-${t.commonColor}`),a.shownTriage&&n.push(`triage-${a.shownTriage}`),n}function Bf(e){let t=Ue(e),r=hn(e),n=ze(e),o=P(n),s=n,i=ci(ot(s.description,s)),l=Ar(s),d=Er(s),u=d?`, ${d}`:"";return c`<div class="row-score"><span class="${`badge ${s.severity}`}">${gn(s.severity)}</span> ${s.confidence===void 0?g:c`<span class="row-conf"><strong>${s.confidence}</strong>/10</span>`}</div><div class="row-body"><div class="title-row"><span class="title">${i}</span> ${l?c`<span class="row-type">${l}</span>`:g}</div><div class="meta-row"><span class="row-loc">${dw(s)}${u}</span><div class="marks">${Af(e,r,t,n)}</div></div>${r.length>1?c`<div class="tabs-row"><div class="tabs">${r.map(p=>Tf(p,P(p)===o))}</div></div>`:g}</div>`}function To(e){return"tree-"+e.replaceAll(/[^\w-]+/gu,"_")}var Lf=()=>Object.fromEntries(ke.map(e=>[e,0]));function ql(e){let t=new Map;for(let r of e)for(let n of r){t.has(n.file)||t.set(n.file,Lf());let o=t.get(n.file);o[n.severity]!==void 0&&o[n.severity]++}return t}function Yl(e){let t=null;for(let r of e)if(r?.tree){t||(t={});for(let n of Object.keys(r.tree)){let o=r.tree[n];if(!t[n]){t[n]={...o,imports:[...o.imports??[]]};continue}let s=new Set(t[n].imports);for(let i of o.imports??[])s.has(i)||(s.add(i),t[n].imports.push(i));t[n].size==null&&o.size!=null&&(t[n].size=o.size)}}return t}function ui(e,t){let r=new Map;for(let n of Object.keys(e)){let o=new Set,s=[...(e[n].imports??[]).filter(l=>e[l])];for(;s.length>0;){let l=s.pop();if(!o.has(l)){o.add(l);for(let d of e[l]?.imports??[])e[d]&&s.push(d)}}let i=Lf();for(let l of o){let d=t.get(l);if(d)for(let u of ke)i[u]+=d[u]??0}r.set(n,i)}return r}function Jl(e,t,r){let n=t.get(e),o=r.get(e);return Mf(n)>0||Mf(o)>0}function Mf(e){if(!e)return 0;let t=0;for(let r of ke)t+=e[r]??0;return t}function Pf(e){if(!e)return g;let t=Sr(e)[0];return t?c`<button type="button" class="tree-code-btn" data-finding-code-bundle="${t.integrity}" data-finding-code-file="${t.file}" title="${`Open ${t.file} in bundle source viewer`}">Code</button>`:g}function Of(e,t){let r=Object.keys(e).toSorted(),n=new Map;for(let p of r)for(let f of e[p].imports??[]){let h=n.get(f)??[];h.push(p),n.set(f,h)}let o=a.filesSearch.trim().toLowerCase(),s=o?r.filter(p=>p.toLowerCase().includes(o)):r,i=p=>e[p]?c`<a href="${`#${To(p)}`}"><span class="name">${p}</span></a>`:c`<span class="name">${p}</span>`,l=p=>{let f=t.get(p);if(!f)return null;let h=ke.filter(b=>(f[b]??0)>0);return h.length===0?null:c`<span class="tree-count-chips">${h.map(b=>c`<span class="${`tree-count-chip ${b}`}">${f[b]} ${b.replaceAll("_"," ")}</span>`)}</span>`},d=p=>{let f=t.get(p);return f?ke.reduce((h,b)=>h+(f[b]??0),0):0},u=c`<div class="tree-toolbar"><view-mode-buttons modes="table,list" kind="files"></view-mode-buttons><div class="search-row"><toolbar-search kind="files"></toolbar-search><span class="result-count">${s.length} of ${r.length}</span></div></div>`;if(a.filesViewMode==="table"){let p=a.filesSelectedFile&&e[a.filesSelectedFile]&&s.includes(a.filesSelectedFile)?a.filesSelectedFile:null;return c`<div class="${p?"tree-view tree-view-table with-details":"tree-view tree-view-table"}">${u}<div class="${p?"tree-table-layout open":"tree-table-layout"}"><div class="tree-table-list">${s.length===0?c`<div class="tree-table-empty">No files match the search.</div>`:g} ${s.map(b=>{let m=d(b),y=b===p,v=ee(e[b]?.size);return c`<div class="${`tree-table-row${y?" selected":""}${m===0?" clean":""}`}" data-tree-select="${b}"><span class="tree-table-name">${b}</span> ${l(b)??c`<span class="tree-table-clean-marker">—</span>`} ${v?c`<span class="tree-table-size">${v}</span>`:g}</div>`})}</div>${p?c`<aside class="tree-table-details" id="tree-table-details"><header class="tree-table-details-bar"><span class="tree-table-details-label">Details</span> <button type="button" class="tree-table-details-close" data-tree-deselect title="Close details" aria-label="Close details">×</button></header><div class="tree-table-details-body">${Cw(e[p],p,n.get(p)??[],i)}</div></aside>`:g}</div></div>`}return c`<div class="tree-view">${u} ${s.length===0?c`<div class="tree-table-empty">No files match the search.</div>`:g} ${s.map(p=>{let f=e[p],h=n.get(p)??[],b=ee(f?.size);return c`<section class="tree-file" id="${To(p)}"><div class="tree-file-header"><span class="name">${p}</span> ${l(p)} ${b?c`<span class="tree-file-size">${b}</span>`:g} ${Pf(f.fileHash)}</div>${f.fileHash||f.treeHash?c`<div class="tree-hashes hashes">${f.fileHash?c`<div class="tree-hash">file: ${f.fileHash}</div>`:g} ${f.treeHash?c`<div class="tree-hash">tree: ${f.treeHash}</div>`:g}</div>`:g} ${f.imports?.length>0?c`<div class="tree-section"><span class="tree-section-label">imports</span><ul>${f.imports.map(m=>c`<li>${i(m)}</li>`)}</ul></div>`:g} ${h.length>0?c`<div class="tree-section"><span class="tree-section-label">imported by</span><ul>${h.map(m=>c`<li>${i(m)}</li>`)}</ul></div>`:g} ${f.exports?.length>0?c`<div class="tree-section"><span class="tree-section-label">exports</span><ul>${f.exports.map(m=>c`<li><span class="name">${m}</span></li>`)}</ul></div>`:g}</section>`})}</div>`}function Cw(e,t,r,n){let o=ee(e?.size);return c`<div class="tree-detail-name"><span class="name">${t}</span> ${o?c`<span class="tree-detail-size">${o}</span>`:g} ${Pf(e.fileHash)}</div>${e.fileHash||e.treeHash?c`<div class="tree-hashes hashes">${e.fileHash?c`<div class="tree-hash">file: ${e.fileHash}</div>`:g} ${e.treeHash?c`<div class="tree-hash">tree: ${e.treeHash}</div>`:g}</div>`:g} ${e.imports?.length>0?c`<div class="tree-section"><span class="tree-section-label">imports</span><ul>${e.imports.map(s=>c`<li>${n(s)}</li>`)}</ul></div>`:g} ${r.length>0?c`<div class="tree-section"><span class="tree-section-label">imported by</span><ul>${r.map(s=>c`<li>${n(s)}</li>`)}</ul></div>`:g} ${e.exports?.length>0?c`<div class="tree-section"><span class="tree-section-label">exports</span><ul>${e.exports.map(s=>c`<li><span class="name">${s}</span></li>`)}</ul></div>`:g}`}function Ew(){return{showAll:!1,splitOwnDirs:!1,packagesView:!1,selected:null,focusedPkg:null,topPkgsTab:"issues",edgeOpacity:.22,nodeSize:1,showLabels:!1,selectedSeverities:new Set,selectedColors:new Set,pathFilter:"",hidden:new Set,solo:null,graphState:null,layoutCache:null}}var rr=Ew(),C=new Proxy(rr,{get(e,t){return rr[t]},set(e,t,r){return rr[t]=r,!0},has(e,t){return t in rr},deleteProperty(e,t){return delete rr[t]},ownKeys(){return Reflect.ownKeys(rr)},getOwnPropertyDescriptor(e,t){return Object.getOwnPropertyDescriptor(rr,t)}});function Pe(){C.graphState?._cleanup&&C.graphState._cleanup(),C.graphState=null}function Nf(){return rr}var Io=null,Df=null;function bn(){return Df}function Aw(){return Io||(Io=(async()=>{let e="./graph.js";try{let t=await import(e);return t._swapGraph2Impl(Nf()),Df=t,t}catch(t){throw Io=null,t}})(),Io)}async function Xl(e,t,r,n,o){try{let s=await Aw(),i=s.buildGraphFromPrep(t);q(c`<graph-layout .graph="${i}" .options="${r}"></graph-layout>`,e);let l=e.querySelector("graph-layout");return await l.updateComplete,n(),o(),s.attachGraph2Interaction(e,i,n,o),l}catch(s){let i=s instanceof Error?s.message:String(s);return e.textContent=`Graph failed to load: ${i}`,null}}function He(e){let t=new Map;if(!e)return t;if(e.kind==="stasis"){if(!e.bundle)return t;for(let[r,n]of e.bundle.sources)typeof n=="string"&&t.set(r,n)}else if(e.kind==="sourcemap"){if(!e.json)return t;let r=e.json.sources??[],n=e.json.sourcesContent??[];for(let o=0;o<r.length;o++)typeof n[o]=="string"&&t.set(r[o],n[o])}return t}function nr(e){if(e?.kind!=="stasis"||!e.bundle?.modules)return null;let t=new Map;for(let[r,n]of e.bundle.modules)for(let o of Object.keys(n.files))t.set(r==="."?o:`${r}/${o}`,r);return t}var Ro=null,Fo=null;function Tw(){return Ro||(Ro=(async()=>{let e="./terminal.js";try{return await import(e)}catch(t){throw Ro=null,t}})(),Ro)}function Iw(e){let t=He(e);if(t.size===0)return t;let r=[...t.keys()],{stripped:n}=Qe(r),o=new Map;for(let s=0;s<r.length;s++)o.set(n[s],t.get(r[s]));return o}async function zf(e,t){let r=t?.integrity??"";(!Fo||Fo.integrity!==r)&&(Fo={integrity:r,promise:Rw(t,r)});try{let n=await Fo.promise;return!e.isConnected||e.contains(n)||e.replaceChildren(n),n}catch(n){Fo=null;let o=n instanceof Error?n.message:String(n);return e.textContent=`Terminal failed to load: ${o}`,null}}async function Rw(e,t){return(await Tw()).createTerminalElement(Iw(e),t)}function Hf(e){if(!e)return null;let t=df()==="node_modules"?/^(?:.*\/)?node_modules\/(@[^/]+\/[^/]+|[^/]+)/u:/^(?:.*\/)?dependencies\/(@[^/]+\/[^/]+|[^/]+)/u,r=e.match(t);if(r)return r[1];let n=e.indexOf("/");return n>0?e.slice(0,n):"/"}var Fw=["#4e9af1","#f28e2b","#59a14f","#e15759","#76b7b2","#edc948","#b07aa1","#ff9da7","#9c755f","#5cd1e5","#f1ce63","#d37295","#a0cbe8","#86bcb6","#8cd17d","#b6992d","#499894","#e15759","#e879c7","#d4a6c8"],Uf=["#2f8aef","#d2691e","#2ea043","#e63946","#2e9a92","#b88817","#9560e8","#d24a9c","#8a5d40","#0891b2","#a07a14","#c14e8e","#1f7ad0","#549b94","#3fb95f","#a07a14","#2a8278","#cb2c40","#c026d3","#965f93"];function Bw(){if(typeof document>"u")return!1;let e=document.body?.classList;return!!e&&(e.contains("theme-light")||e.contains("theme-pink"))}var Ql=new Map;function st(e){let t=Bw()?Uf:Fw,n=`${t===Uf?"l":"d"}:${e??"__own__"}`;if(Ql.has(n))return Ql.get(n);let o=e??"__own__",s=0;for(let u of o)s=s*37+u.codePointAt(0)|0;let l=((s%t.length+t.length)%t.length*7+3)%t.length,d=t[l];return Ql.set(n,d),d}var Zl=(e,t,r)=>{for(let n of t)if(n[0]===e)return(0,n[1])();return r?.()};var yn='<svg class="file-icon" viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M8 2 2 5v6l6 3 6-3V5L8 2Z"/><path d="M2 5l6 3 6-3"/><path d="M8 8v6"/></svg>',pi='<svg class="file-icon" viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="2.5" y="4" width="11" height="9" rx="1.2"/><path d="M6 4V3h4v1"/></svg>';function it(e,{splitOwnDirs:t=!0,packageDir:r=null}={}){let n=/(?:^|\/)(?:node_modules|dependencies)\/(@[^/]+\/[^/]+|[^/]+)/gu,o;for(;(o=n.exec(e))!==null;)if(o[1]!==".pnpm")return o[1];if(r&&r!=="."&&!r.includes("node_modules"))return r;if(t){let s=e.indexOf("/");if(s>0)return e.slice(0,s)}return"__own__"}function Wf(e,t=null){let r=new Set;for(let n of e){let o=t?.(n)??null;if(it(n,{splitOwnDirs:!1,packageDir:o})==="__own__"&&(r.add(it(n,{splitOwnDirs:!0,packageDir:o})),r.size>1))return!0}return!1}var fi=null;function Mw(){return fi||(fi=(async()=>await import("./prism.js"))(),fi)}var Lw={js:"javascript",mjs:"javascript",cjs:"javascript",jsx:"jsx",ts:"typescript",mts:"typescript",cts:"typescript",tsx:"tsx",json:"json",css:"css",html:"markup",htm:"markup",xml:"markup",svg:"markup",yml:"yaml",yaml:"yaml",sh:"bash",bash:"bash",md:"markdown",markdown:"markdown",sol:"solidity",php:"php",phtml:"php",rs:"rust"};function hi(e){if(typeof e!="string")return null;let t=e.lastIndexOf(".");return t<0?null:Lw[e.slice(t+1).toLowerCase()]??null}async function gi(e,t){if(!t)return null;try{return(await Mw()).highlight(e,t)}catch{return null}}var $e=`.lwd-body{margin:.2rem 0 .55rem;color:var(--text);font-size:.86rem;line-height:1.5}.lwd-empty{margin:.2rem 0 .55rem;color:var(--muted);font-size:.78rem}.lwd-note{margin:.2rem 0 .65rem;padding:.55rem .7rem;border:1px solid var(--border);border-radius:6px;background:rgb(from var(--text) r g b / .03);color:var(--muted);font-size:.78rem;line-height:1.45}.lwd-choice{margin:.2rem 0 .65rem;padding:.55rem .7rem .6rem;border:1px solid var(--border);border-radius:6px;background:rgb(from var(--text) r g b / .03);& legend{padding:0 .35rem;color:var(--text);font-size:.78rem;font-weight:500;& strong{font-weight:600}}}.lwd-option{display:flex;align-items:flex-start;gap:.5rem;padding:.3rem .15rem;& input[type=radio]{margin:.15rem 0 0;accent-color:var(--accent)}.lwd-option-text{display:flex;flex-direction:column;gap:.1rem;min-width:0}.lwd-option-title{color:var(--text);font-size:.82rem;line-height:1.35}.lwd-option-hint{color:var(--muted);font-size:.72rem;line-height:1.4}}.lwd-list{margin:0;padding-left:1.1rem;color:var(--muted);font-size:.76rem;line-height:1.5;& li+li{margin-top:.2rem}& strong{color:var(--text);font-weight:600}}.lwd-kind-tag{display:inline-block;vertical-align:middle;margin-left:.3rem;padding:0 .35rem;border:1px solid var(--border);border-radius:3px;background:rgb(from var(--text) r g b / .04);color:var(--muted);font-size:.62rem;font-weight:600;text-transform:uppercase;letter-spacing:.06em}.lwd-rename-input{margin-top:.2rem}.lwd-rename-error{margin:.25rem 0 0;color:var(--critical, #f87171);font-size:.72rem;line-height:1.35}
37
+ `;var ec=class extends F{static styles=[...F.styles,B($e)];static properties={reportName:{type:String},workspaceNames:{type:Array},existingNames:{type:Object},_choice:{state:!0},_newName:{state:!0}};constructor(){super(),this.reportName="",this.workspaceNames=[],this.existingNames=new Set,this._choice="replace",this._newName=""}focusInitial(){this.renderRoot.querySelector('button[data-role="cancel"]')?.focus()}_onClose=()=>this._finish({action:"cancel"});_onCancel=()=>this._finish({action:"cancel"});_onChoiceChange=t=>{this._choice=t.target.value};_onNewNameInput=t=>{this._newName=t.target.value};_onNewNameKeydown=t=>{t.key==="Enter"&&(t.preventDefault(),this._onConfirm())};_onConfirm=()=>{if(this._choice==="rename"){let t=(this._newName??"").trim();if(!this._isRenameValid(t))return;this._finish({action:"rename",newName:t});return}this._finish({action:"replace"})};_replaceHint(){let t=this.workspaceNames.length;if(t===0)return c`<span class="lwd-option-hint">The local file will be overwritten.</span>`;let r=t===1?c`workspace <strong>"${this.workspaceNames[0]}"</strong>`:c`<strong>${t}</strong> workspaces (${this.workspaceNames.join(", ")})`;return c`<span class="lwd-option-hint">The local file will be overwritten. When sync is online, the new bytes are also uploaded to ${r} so the cloud copy matches.</span>`}_renameValidationTpl(t){return t?t===this.reportName?c`<p class="lwd-rename-error">Pick a name different from the original.</p>`:t.includes("\0")?c`<p class="lwd-rename-error">The new name cannot contain a NUL byte.</p>`:t.includes("/")||t.includes("\\")?c`<p class="lwd-rename-error">The new name cannot contain "/" or "\\".</p>`:this.existingNames.has(t)?c`<p class="lwd-rename-error">A file named "${t}" already exists — pick something else.</p>`:g:c`<p class="lwd-rename-error">Enter a new name.</p>`}_isRenameValid(t){return t.length>0&&t!==this.reportName&&!t.includes("\0")&&!t.includes("/")&&!t.includes("\\")&&!this.existingNames.has(t)}render(){let t=this._choice==="rename",r=(this._newName??"").trim(),n=t&&!this._isRenameValid(r),o=t?"Rename":"Replace",s=t?"primary":"danger",i=this.workspaceNames.length>0?c`<span class="lwd-option-hint">Saved as an unfiled report — the renamed copy isn't added to any workspace.</span>`:g;return c`<dialog @close="${this._onClose}"><header><h3>Import conflict</h3></header><p class="lwd-body"><strong>"${this.reportName}"</strong> already exists with different content.</p><fieldset class="lwd-choice"><legend>What should happen?</legend><label class="lwd-option"><input type="radio" name="icd-choice" value="replace" ?checked="${this._choice==="replace"}" @change="${this._onChoiceChange}"> <span class="lwd-option-text"><span class="lwd-option-title">Replace</span> ${this._replaceHint()}</span></label> <label class="lwd-option"><input type="radio" name="icd-choice" value="rename" ?checked="${this._choice==="rename"}" @change="${this._onChoiceChange}"> <span class="lwd-option-text"><span class="lwd-option-title">Rename to</span> <input type="text" class="nwd-input lwd-rename-input" maxlength="200" .value="${this._newName}" ?disabled="${!t}" @input="${this._onNewNameInput}" @keydown="${this._onNewNameKeydown}" @focus="${()=>{this._choice="rename"}}"> ${i} ${t?this._renameValidationTpl(r):g}</span></label></fieldset><footer class="nwd-actions"><span class="nwd-spacer"></span> <button type="button" data-role="cancel" @click="${this._onCancel}">Cancel</button> <button type="button" class="${s}" ?disabled="${n}" @click="${this._onConfirm}">${o}</button></footer></dialog>`}};customElements.define("import-conflict-dialog",ec);function Vf({name:e,workspaceNames:t,existingNames:r}={}){let n=r instanceof Set?r:new Set(r??[]);return new Promise(o=>{let s=document.createElement("import-conflict-dialog");Object.assign(s,{reportName:e??"",workspaceNames:Array.isArray(t)?t:[],existingNames:n,_newName:Ow(e??"",n)}),s.addEventListener("resolve",i=>{s.remove(),o(i.detail)}),s.addEventListener("modal-conflict",()=>{s.remove(),o({action:"cancel"})}),document.body.append(s)})}function Ow(e,t){if(typeof e!="string"||e.length===0)return"";let r=e.lastIndexOf("."),n=r>0?e.slice(0,r):e,o=r>0?e.slice(r):"",s=n.replace(/-\d+$/u,"");for(let i=2;i<1e3;i++){let l=`${s}-${i}${o}`;if(!t.has(l))return l}return""}function H(e,t){if(!e)throw new Error(t)}function wn(e,t){let[r,n]=[e.split("/"),t.split("/")];for(;r.length>0&&r[0]===n[0];)r.shift(),n.shift();if(r.length===0&&n.length===0)return 0;if(r.length<2)return n.length<2&&r>n?1:-1;if(n.length<2)return 1;if(r[0]==="*")return-1;if(n[0]==="*"||r[0]==="node_modules")return 1;if(n[0]==="node_modules")return-1;let[o,s]=[r,n].map(i=>i.join(String.fromCodePoint(0)));if(o<s)return-1;if(o>s)return 1;throw new Error("Unreachable")}var Nw=e=>e&&[null,Object.prototype].includes(Object.getPrototypeOf(e)),vn=e=>Object.setPrototypeOf(Object.fromEntries(e),null),jf=e=>[...e].toSorted((t,r)=>wn(t,r)),mi=e=>vn([...e].toSorted((t,r)=>wn(t[0],r[0])).map(([t,r])=>[t,r instanceof Map?mi(r):r])),tc=e=>new Map(Object.entries(e).map(([t,r])=>[t,Nw(r)?tc(r):r]));function Kf(e){let t="node_modules/",r=e.lastIndexOf(t);if(r===-1)return null;let n=r+t.length,o=e.slice(n).split("/"),s=o[0].startsWith("@")?2:1;if(o.length<=s||o.slice(0,s).some(l=>!l))return null;let i=o.slice(0,s).join("/");return{dir:e.slice(0,n)+i,rel:o.slice(s).join("/"),name:i}}var Ct=1,rc=0,bi=({name:e,version:t,files:r})=>({name:e,version:t,files:vn(Object.entries(r))}),Gf=e=>Kf(e)??{dir:".",rel:e,name:null},yi=class e{static VERSION=Ct;version=Ct;config;entries;modules;formats;imports;constructor({config:t={scope:"full"},entries:r,modules:n,formats:o,imports:s,version:i=Ct}={}){H([rc,Ct].includes(i)),H(["node_modules","full"].includes(t.scope)),this.version=i,this.config=t,this.entries=r??new Set,this.modules=n??new Map,this.formats=o??new Map,this.imports=s??new Map}get sources(){let t=new Map;for(let[r,{files:n}]of this.modules)for(let[o,s]of Object.entries(n))t.set(r==="."?o:`${r}/${o}`,s);return t}static parseCode(t){let r=JSON.parse(t);H(r.version===Ct||r.version===rc),H(["node_modules","full"].includes(r.config?.scope)),H(r.formats),H(r.imports);let n=new Map,o=new Set;if(r.version===Ct){let s=r.config.scope==="full";if(r.modules!==void 0){H(typeof r.modules=="object"&&r.modules!==null);for(let[i,l]of Object.entries(r.modules))H(i.includes("node_modules")),H(!i.startsWith("..")),H(l?.name&&l.version&&l.files),n.set(i,bi(l))}if(s){H(Array.isArray(r.entries)),H(r.entries.length>0,"v1 bundle with scope=full must have at least one entry"),H(r.sources&&typeof r.sources=="object"),o=new Set(r.entries);for(let[i,l]of Object.entries(r.sources))H(!i.includes("node_modules")),H(!i.startsWith("..")),H(l?.name&&l.version&&l.files),n.set(i,bi(l))}else H(r.entries===void 0),H(r.sources===void 0);for(let[,{files:i}]of n)for(let l of Object.keys(i))H(!l.startsWith(".."))}else{H(r.sources);for(let[s,i]of Object.entries(r.sources)){H(!s.startsWith(".."));let{dir:l,rel:d,name:u}=Gf(s);H(!l.startsWith("..")&&!d.startsWith("..")),n.has(l)||n.set(l,{name:u,version:null,files:Object.create(null)}),n.get(l).files[d]=i}}return new e({version:r.version,config:r.config,entries:o,modules:n,formats:new Map(Object.entries(r.formats)),imports:tc(r.imports)})}static parseResources(t){let r=JSON.parse(t);H(r.version===Ct||r.version===rc);let n=new Map,o={scope:"full"};if(r.version===Ct){H(["node_modules","full"].includes(r.config?.scope)),o=r.config;let s=o.scope==="full";if(r.modules!==void 0){H(typeof r.modules=="object"&&r.modules!==null);for(let[i,l]of Object.entries(r.modules))H(i.includes("node_modules")),H(!i.startsWith("..")),H(l?.name&&l.version&&l.files),n.set(i,bi(l))}if(s&&r.sources!==void 0){H(typeof r.sources=="object"&&r.sources!==null);for(let[i,l]of Object.entries(r.sources))H(!i.includes("node_modules")),H(!i.startsWith("..")),H(l?.name&&l.version&&l.files),n.set(i,bi(l))}else s||H(r.sources===void 0);for(let[,{files:i}]of n)for(let l of Object.keys(i))H(!l.startsWith(".."))}else{H(r.resources);for(let[s,i]of Object.entries(r.resources)){H(!s.startsWith(".."));let{dir:l,rel:d,name:u}=Gf(s);H(!l.startsWith("..")&&!d.startsWith("..")),n.has(l)||n.set(l,{name:u,version:null,files:Object.create(null)}),n.get(l).files[d]=i}}return new e({version:r.version,config:o,modules:n})}#e(){let t=[],r=[];for(let[n,{name:o,version:s,files:i}]of this.modules){if(Object.keys(i).length===0)continue;let l=n.includes("node_modules");l&&H(o&&s&&i);let d=vn(Object.entries(i).toSorted((p,f)=>wn(p[0],f[0])));(l?t:r).push([n,{name:o,version:s,files:d}])}return t.sort((n,o)=>wn(n[0],o[0])),r.sort((n,o)=>wn(n[0],o[0])),{modules:vn(t),sources:vn(r)}}serializeCode(){let t=jf(this.entries),{modules:r,sources:n}=this.#e(),o=mi(this.formats),s=mi(this.imports),i={version:Ct,config:this.config};return this.config.scope==="full"&&Object.assign(i,{entries:t,sources:n}),Object.assign(i,{modules:r,formats:o,imports:s}),JSON.stringify(i,void 0,2)}serializeResources(){let{modules:t,sources:r}=this.#e(),n={version:Ct,config:this.config};return this.config.scope==="full"&&Object.assign(n,{sources:r}),Object.assign(n,{modules:t}),JSON.stringify(n,void 0,2)}};var wi=null,vi=null,ki=null;function Dw(){for(let e of["br","brotli"])try{return new DecompressionStream(e),e}catch{}return null}async function zw(e,t){let r=new Blob([t]).stream().pipeThrough(new DecompressionStream(e));return new Uint8Array(await new Response(r).arrayBuffer())}async function Uw(){if("serviceWorker"in navigator)try{let e=await navigator.serviceWorker.getRegistrations();for(let t of e){let r=t.active?.scriptURL??t.installing?.scriptURL??t.waiting?.scriptURL;r&&r.endsWith("/brotli-sw.js")&&await t.unregister()}}catch{}}function Hw(){return ki||(ki=(async()=>await import("./brotli-fallback.js"))(),ki)}async function Ww(){await Uw();let e=Dw();return e?(wi={kind:"native",format:e},wi):(wi={kind:"fallback"},wi)}function qf(){return vi||(vi=Ww(),vi)}async function Yf(e){let t=await qf();return t.kind==="native"?zw(t.format,e):(await Hw()).brotliDecompress(e)}qf().catch(()=>{});async function kn(e,t){try{let r=await $r(e),n=t.name.toLowerCase().endsWith(".map"),o=n?"sourcemap":"stasis";try{if(n){let l=JSON.parse(he(r));return{integrity:e,kind:o,size:r.byteLength,json:l}}let s=he(await Yf(r)),i=yi.parseCode(s);return{integrity:e,kind:o,size:r.byteLength,bundle:i}}catch(s){return{integrity:e,kind:o,size:r.byteLength,error:s.message}}}catch(r){return{integrity:e,error:r.message,size:0}}}function Vw(e){!e?.json&&!e?.bundle||(async()=>{try{let t=await oc(e);if(Os(e.integrity,t),a.selectedBundle!==e.integrity)return;e.fileHashes=t,$()}catch{}})()}async function nc(e){if(Ga(e))return;let t=(a.bundles??[]).find(n=>n.integrity===e);if(!t)return;let r=await kn(e,t);if(!(!r?.json&&!r?.bundle))try{let n=await oc(r);Os(e,n)}catch{}}async function Ot(e){let t=(a.bundles??[]).find(n=>n.integrity===e);if(!t)return;let r=await kn(e,t);a.selectedBundle===e&&(a.bundleDetails=r,$(),Vw(r),xt().catch(()=>{}))}var jw=["finding_url","repository","title","description","severity","configured_scan_id","relevant_paths"];function Kw(e){let t=[],r=[],n="",o=!1,s=e.length;for(let i=0;i<s;i++){let l=e[i];o?l==='"'?e[i+1]==='"'?(n+='"',i++):o=!1:n+=l:l==='"'?o=!0:l===","?(r.push(n),n=""):l===`
38
38
  `||l==="\r"?(r.push(n),t.push(r),r=[],n="",l==="\r"&&e[i+1]===`
39
- `&&i++):n+=l}for((n!==""||r.length>0)&&(r.push(n),t.push(r));t.length>0&&t.at(-1).length===1&&t.at(-1)[0]==="";)t.pop();return t}function kf(e){let t=nw(e);if(t.length<2)throw new Error("Codex CSV: empty or missing header row");let r=t[0],n=l=>r.indexOf(l);for(let l of rw)if(n(l)===-1)throw new Error(`Codex CSV: missing required column "${l}"`);let o={finding_url:n("finding_url"),repository:n("repository"),title:n("title"),description:n("description"),severity:n("severity"),detected_at:n("detected_at"),committed_at:n("committed_at"),configured_scan_id:n("configured_scan_id"),commit_hash:n("commit_hash"),relevant_paths:n("relevant_paths")},s=new Map;for(let l=1;l<t.length;l++){let d=t[l];if(d.length===1&&d[0]==="")continue;let u=d[o.configured_scan_id];u&&(s.has(u)||s.set(u,[]),s.get(u).push(d))}if(s.size===0)throw new Error("Codex CSV: no rows with a configured_scan_id");let i=[];for(let[l,d]of s){let u=new Set(d.map(m=>m[o.repository]).filter(Boolean));if(u.size>1)throw new Error(`Codex CSV: scan ${l} contains multiple repositories: ${[...u].join(", ")}`);let p=[...u][0]||"unknown-repo",f=l.replace(/^[^:]+:/u,""),h=`${p}:${f}`,b=d.map(m=>ow(m,o));i.push({displayName:h,data:{type:"security",source:"codex-security",findings:b}})}return i}function ow(e,t){let r=(e[t.relevant_paths]||"").split(" | ").map(d=>d.trim()).find(Boolean)||"unknown",n="?",o=e[t.title]||"",s=e[t.description]||"",i=o&&s?`${o}
39
+ `&&i++):n+=l}for((n!==""||r.length>0)&&(r.push(n),t.push(r));t.length>0&&t.at(-1).length===1&&t.at(-1)[0]==="";)t.pop();return t}function Jf(e){let t=Kw(e);if(t.length<2)throw new Error("Codex CSV: empty or missing header row");let r=t[0],n=l=>r.indexOf(l);for(let l of jw)if(n(l)===-1)throw new Error(`Codex CSV: missing required column "${l}"`);let o={finding_url:n("finding_url"),repository:n("repository"),title:n("title"),description:n("description"),severity:n("severity"),detected_at:n("detected_at"),committed_at:n("committed_at"),configured_scan_id:n("configured_scan_id"),commit_hash:n("commit_hash"),relevant_paths:n("relevant_paths")},s=new Map;for(let l=1;l<t.length;l++){let d=t[l];if(d.length===1&&d[0]==="")continue;let u=d[o.configured_scan_id];u&&(s.has(u)||s.set(u,[]),s.get(u).push(d))}if(s.size===0)throw new Error("Codex CSV: no rows with a configured_scan_id");let i=[];for(let[l,d]of s){let u=new Set(d.map(m=>m[o.repository]).filter(Boolean));if(u.size>1)throw new Error(`Codex CSV: scan ${l} contains multiple repositories: ${[...u].join(", ")}`);let p=[...u][0]||"unknown-repo",f=l.replace(/^[^:]+:/u,""),h=`${p}:${f}`,b=d.map(m=>Gw(m,o));i.push({displayName:h,data:{type:"security",source:"codex-security",findings:b}})}return i}function Gw(e,t){let r=(e[t.relevant_paths]||"").split(" | ").map(d=>d.trim()).find(Boolean)||"unknown",n="?",o=e[t.title]||"",s=e[t.description]||"",i=o&&s?`${o}
40
40
 
41
- ${s}`:o||s,l={id:e[t.finding_url],file:r,line:n,severity:(e[t.severity]||"medium").toLowerCase(),description:i,repo:{github:e[t.repository]}};return t.commit_hash!==-1&&e[t.commit_hash]&&(l.commitHash=e[t.commit_hash]),t.detected_at!==-1&&e[t.detected_at]&&(l.detectedAt=e[t.detected_at]),t.committed_at!==-1&&e[t.committed_at]&&(l.committedAt=e[t.committed_at]),l}var pn=`.conflict-sev{display:inline-block;padding:1px .4rem;border-radius:3px;font-size:.62rem;font-weight:700;text-transform:uppercase;letter-spacing:.08em;color:#fff;flex-shrink:0;&.sev-critical{background:var(--critical)}&.sev-high{background:var(--high)}&.sev-medium{background:var(--medium)}&.sev-low{background:var(--low)}&.sev-high_bug{background:var(--high-bug)}&.sev-bug{background:var(--bug)}&.sev-informational{background:var(--info)}}
42
- `;var $f=`dialog{max-width:720px;width:min(94vw,720px)}header h3{margin:0 0 .25rem}header p{margin:0 0 .75rem;color:var(--muted);font-size:.82rem}.bulk{display:flex;gap:.4rem;margin-bottom:.7rem;padding-bottom:.7rem;border-bottom:1px solid var(--border)}.bulk button,.actions button{background:transparent;border:1px solid var(--border);color:var(--text);border-radius:5px;padding:.3rem .8rem;font:inherit;font-size:.78rem;&:hover{border-color:var(--accent);color:var(--accent)}&.primary{background:var(--accent);color:var(--surface);border-color:var(--accent)}&.primary:hover{filter:brightness(1.08)}}.list{list-style:none;margin:0;padding:0;max-height:60vh;overflow-y:auto;overscroll-behavior:none;-webkit-app-region:no-drag;app-region:no-drag;display:flex;flex-direction:column;gap:.5rem}.card{border:1px solid var(--border);border-radius:6px;padding:.55rem .7rem .6rem;background:rgb(from var(--text) r g b / .02)}.card-head{display:flex;align-items:center;gap:.5rem;flex-wrap:wrap;margin-bottom:.35rem}.loc{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:.76rem;color:var(--text);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0;flex:1}.id{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:.68rem;color:var(--muted);padding:1px .3rem;background:rgb(from var(--text) r g b / .05);border-radius:3px}.desc{font-size:.78rem;color:var(--muted);margin-bottom:.55rem;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.rows{display:flex;flex-direction:column;gap:.35rem}.row{display:grid;grid-template-columns:5rem 1fr 1fr;align-items:stretch;gap:.4rem}.row-label{color:var(--muted);font-size:.72rem;text-transform:uppercase;letter-spacing:.08em;align-self:center}.choice{position:relative;display:flex;flex-direction:column;gap:.15rem;padding:.35rem .5rem;border:1px solid var(--border);border-radius:5px;min-width:0;&:has(input:checked){border-color:var(--accent);background:rgb(from var(--accent) r g b / .07)}&:has(input:focus-visible){outline:2px solid var(--accent);outline-offset:1px}}.choice input[type=radio]{position:absolute;opacity:0;pointer-events:none}.choice-label{font-size:.68rem;color:var(--muted);text-transform:uppercase;letter-spacing:.08em}.choice:has(input:checked) .choice-label{color:var(--accent)}.choice-value{font-size:.82rem;min-width:0}.flag-badge{font-size:.82rem;color:var(--muted)}.flag-badge.on{color:var(--accent);font-weight:600}.color{display:inline-flex;align-items:center;gap:.35rem}.color-dot{width:12px;height:12px;border-radius:50%;box-shadow:0 0 0 1px rgb(from var(--text) r g b / .2);flex-shrink:0;&.marker-red{background:var(--marker-red)}&.marker-blue{background:var(--marker-blue)}&.marker-green{background:var(--marker-green)}&.marker-gray{background:var(--marker-gray)}}.color-name{text-transform:capitalize}.comment-text{display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden;color:var(--text);white-space:pre-wrap;overflow-wrap:anywhere;& em{color:var(--muted);font-style:italic}}.fix-text{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;word-break:break-all;& a{color:var(--accent);text-decoration:none}& a:hover{text-decoration:underline}}.actions{display:flex;justify-content:flex-end;gap:.4rem;margin-top:.8rem;padding-top:.7rem;border-top:1px solid var(--border)}
43
- `;function fn(e){if(!e)return g;let t=e.replaceAll("_"," ");return c`<span class="${`conflict-sev sev-${e}`}">${t}</span>`}function aw(e){return`bundle-${e.slice(7,19)}\u2026`}function Qe(e){return e.kind==="bundle"?e.label??aw(e.identifier):e.identifier}function lw(e){return e?c`<span class="color"><span class="${`color-dot marker-${e}`}"></span> <span class="color-name">${e}</span></span>`:c`<em>none</em>`}function cw(e){return c`<span class="comment-text">${e||c`<em>empty</em>`}</span>`}function dw(e){return e?rn(e)?c`<span class="fix-text"><a href="${e}" target="_blank" rel="noopener noreferrer">${e}</a></span>`:c`<span class="fix-text">${e}</span>`:c`<span class="comment-text"><em>empty</em></span>`}function uw(e){return e?c`<span class="${`triage triage-${e}`}">${e}</span>`:c`<em>none</em>`}function pw(e){return e?c`<span class="${`flag-badge${e==="flagged"?" on":""}`}">${e}</span>`:c`<em>none</em>`}function xf(e,t){return e==="color"?lw(t):e==="comment"?cw(t):e==="fix"?dw(t):e==="triage"?uw(t):e==="flagged"?pw(t):c`${String(t)}`}function fw(e,t){let r=e?.file?e.line?`${e.file}:${e.line}`:e.file:"";return c`<div class="card-head">${fn(e?.severity)} ${r?c`<span class="loc" title="${r}">${r}</span>`:g} <code class="id" title="${t}">${t.slice(0,8)}…</code></div>${e?.description?c`<div class="desc" title="${e.description}">${e.description}</div>`:g}`}var Sf={title:"Triage conflicts",intro:"disagree with your local triage on",trailingNote:"",applyButton:"Apply",importedSideLabel:"Apply imported"},_f={color:0,comment:1,fix:2,triage:3,flagged:4},hw={color:"Color",comment:"Comment",fix:"Fix",triage:"Triage state",flagged:"Flag"},Vl=class extends I{static styles=[...I.styles,T(pn),T($f)];static properties={conflicts:{attribute:!1},findingLookup:{attribute:!1},labels:{attribute:!1},_settled:{state:!0}};constructor(){super(),this.conflicts=[],this.findingLookup=new Map,this.labels={...Sf},this._settled=!1}focusInitial(){}_blockEscClose=t=>t.preventDefault();_onClick=t=>{let r=t.target.closest("[data-bulk]");if(!r)return;let n=r.dataset.bulk;for(let o of this.renderRoot.querySelectorAll(`input[type="radio"][value="${n}"]`))o.checked=!0};_onSubmit=t=>{t.preventDefault();let r={};for(let n of this.conflicts){let o=`${n.id}:${n.property}`,s=this.renderRoot.querySelector(`input[name="conflict-${CSS.escape(o)}"]:checked`);s&&(r[o]=s.value)}this._finish(r)};render(){let t=this.labels,r=new Map;for(let p of this.conflicts)r.has(p.id)||r.set(p.id,[]),r.get(p.id).push(p);for(let p of r.values())p.sort((f,h)=>(_f[f.property]??99)-(_f[h.property]??99));let n=this.conflicts.filter(p=>p.property==="color").length,o=this.conflicts.filter(p=>p.property==="comment").length,s=this.conflicts.filter(p=>p.property==="fix").length,i=this.conflicts.filter(p=>p.property==="triage").length,l=this.conflicts.filter(p=>p.property==="flagged").length,d=[n?`${n} color${n===1?"":"s"}`:"",o?`${o} comment${o===1?"":"s"}`:"",s?`${s} fix${s===1?"":"es"}`:"",i?`${i} triage state${i===1?"":"s"}`:"",l?`${l} flag${l===1?"":"s"}`:""].filter(Boolean).join(", "),u=`${r.size} finding${r.size===1?"":"s"}`;return c`<dialog @click="${this._onClick}" @cancel="${this._blockEscClose}" @close="${this._onClose}"><header><h3>${t.title}</h3><p>${u} ${t.intro} ${d}.${t.trailingNote?` ${t.trailingNote}`:""}</p><div class="bulk"><button type="button" data-bulk="local">Keep all current</button> <button type="button" data-bulk="imported">${t.importedSideLabel} (all)</button></div></header><form @submit="${this._onSubmit}"><ul class="list">${[...r.entries()].map(([p,f])=>c`<li class="card" data-id="${p}">${fw(this.findingLookup.get(p),p)}<div class="rows">${f.map(h=>{let b=`${h.id}:${h.property}`,m=`conflict-${b}`;return c`<div class="row" data-key="${b}"><span class="row-label">${hw[h.property]??h.property}</span> <label class="choice"><input type="radio" name="${m}" value="local" required> <span class="choice-label">Keep current</span> <span class="choice-value">${xf(h.property,h.local)}</span></label> <label class="choice"><input type="radio" name="${m}" value="imported" required> <span class="choice-label">${t.importedSideLabel}</span> <span class="choice-value">${xf(h.property,h.imported)}</span></label></div>`})}</div></li>`)}</ul><footer class="actions"><button type="submit" class="primary">${t.applyButton}</button></footer></form></dialog>`}};customElements.define("triage-conflict-dialog",Vl);function ii(e,t,r={}){return new Promise((n,o)=>{let s=document.createElement("triage-conflict-dialog");s.conflicts=e,s.findingLookup=t,s.labels={...Sf,...r},s.addEventListener("resolve",i=>{s.remove(),n(i.detail)}),s.addEventListener("modal-conflict",i=>{s.remove(),o(bt(i.detail?.cause))}),document.body.append(s)})}var Kl=class extends I{static styles=[...I.styles,T(ot)];static properties={_password:{state:!0},_busy:{state:!0},_error:{state:!0},_settled:{state:!0}};constructor(){super(),this._password="",this._busy=!1,this._error="",this._settled=!1,this._tryPassword=null}_finish(t){this._settled||(this._password="",this._tryPassword=null,super._finish(t))}_onClose=()=>this._finish(null);_onCancel=()=>this._finish(null);_onPasswordInput=t=>{this._password=t.target.value,this._error=""};_onUnlock=async()=>{if(!(!this._password||this._busy)){this._busy=!0,this._error="";try{let t=await this._tryPassword(this._password);if(this._settled)return;this._finish(t)}catch(t){if(this._settled)return;this._error=t?.message??String(t)}finally{this._busy=!1}}};_onKeydown=t=>{t.key==="Enter"&&(t.preventDefault(),this._onUnlock())};render(){return c`<dialog @close="${this._onClose}"><header><h3>Unlock encrypted workspace</h3></header><p class="nwd-note">This workspace bundle is password-protected. Enter the password the sender shared with you separately to decrypt and import it.</p><label class="wsl-field"><span>Password</span> <input type="password" class="nwd-input" autocomplete="off" data-1p-ignore="true" data-lpignore="true" data-bwignore="true" data-form-type="other" name="dv-bundle-unlock" maxlength="1024" .value="${this._password}" @input="${this._onPasswordInput}" @keydown="${this._onKeydown}"></label> ${this._error?c`<p class="wsl-error" role="alert">${this._error}</p>`:g}<footer class="nwd-actions"><span class="nwd-spacer"></span> <button type="button" @click="${this._onCancel}">Cancel</button> <button type="button" class="primary" ?disabled="${!this._password||this._busy}" @click="${this._onUnlock}">${this._busy?"Unlocking\u2026":"Unlock"}</button></footer></dialog>`}};customElements.define("workspace-unlock-bundle-dialog",Kl);function Cf({tryPassword:e}={}){if(typeof e!="function")throw new TypeError("openWorkspaceUnlockBundleDialog: tryPassword required");return new Promise((t,r)=>{let n=document.createElement("workspace-unlock-bundle-dialog");n._tryPassword=e,n.addEventListener("resolve",o=>{n.remove(),t(o.detail)}),n.addEventListener("modal-conflict",o=>{n._tryPassword=null,n.remove(),r(bt(o.detail?.cause))}),document.body.append(n)})}async function Ef(e){let t=await hl(e),r;if(no(t)){if(r=await Cf({tryPassword:o=>Ms(t,o)}),!r)return null}else r=await Ms(t);let n=await gl(r,{conflictResolver:async(o,s)=>{try{return await ii(o,s,{title:"Triage conflicts on import",intro:"disagree with your local triage on",trailingNote:"Reports and non-conflicting triage were already merged; pick which side to keep for these disagreements.",importedSideLabel:"Apply imported"})}catch{let i=o.length;return alert(`Imported ${e.name}. Kept your local triage on ${i} conflicting entr${i===1?"y":"ies"} because another dialog is open \u2014 re-drop the file to pick again.`),null}}});return(a.currentFile||a.currentWorkspace)&&x(),n}var Tf="deepview.passkey.firstImportPrompted";function gw(){try{return localStorage.getItem(Tf)==="1"}catch{return!1}}function Af(){try{localStorage.setItem(Tf,"1")}catch{}}async function Gl(){if(Q()||!vt()||gw())return;if(!confirm(`Encrypt your DeepView data with a passkey?
41
+ ${s}`:o||s,l={id:e[t.finding_url],file:r,line:n,severity:(e[t.severity]||"medium").toLowerCase(),description:i,repo:{github:e[t.repository]}};return t.commit_hash!==-1&&e[t.commit_hash]&&(l.commitHash=e[t.commit_hash]),t.detected_at!==-1&&e[t.detected_at]&&(l.detectedAt=e[t.detected_at]),t.committed_at!==-1&&e[t.committed_at]&&(l.committedAt=e[t.committed_at]),l}var $n=`.conflict-sev{display:inline-block;padding:1px .4rem;border-radius:3px;font-size:.62rem;font-weight:700;text-transform:uppercase;letter-spacing:.08em;color:#fff;flex-shrink:0;&.sev-critical{background:var(--critical)}&.sev-high{background:var(--high)}&.sev-medium{background:var(--medium)}&.sev-low{background:var(--low)}&.sev-high_bug{background:var(--high-bug)}&.sev-bug{background:var(--bug)}&.sev-informational{background:var(--info)}}
42
+ `;var Xf=`dialog{max-width:720px;width:min(94vw,720px)}header h3{margin:0 0 .25rem}header p{margin:0 0 .75rem;color:var(--muted);font-size:.82rem}.bulk{display:flex;gap:.4rem;margin-bottom:.7rem;padding-bottom:.7rem;border-bottom:1px solid var(--border)}.bulk button,.actions button{background:transparent;border:1px solid var(--border);color:var(--text);border-radius:5px;padding:.3rem .8rem;font:inherit;font-size:.78rem;&:hover{border-color:var(--accent);color:var(--accent)}&.primary{background:var(--accent);color:var(--surface);border-color:var(--accent)}&.primary:hover{filter:brightness(1.08)}}.list{list-style:none;margin:0;padding:0;max-height:60vh;overflow-y:auto;overscroll-behavior:none;-webkit-app-region:no-drag;app-region:no-drag;display:flex;flex-direction:column;gap:.5rem}.card{border:1px solid var(--border);border-radius:6px;padding:.55rem .7rem .6rem;background:rgb(from var(--text) r g b / .02)}.card-head{display:flex;align-items:center;gap:.5rem;flex-wrap:wrap;margin-bottom:.35rem}.loc{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:.76rem;color:var(--text);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0;flex:1}.id{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:.68rem;color:var(--muted);padding:1px .3rem;background:rgb(from var(--text) r g b / .05);border-radius:3px}.desc{font-size:.78rem;color:var(--muted);margin-bottom:.55rem;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.rows{display:flex;flex-direction:column;gap:.35rem}.row{display:grid;grid-template-columns:5rem 1fr 1fr;align-items:stretch;gap:.4rem}.row-label{color:var(--muted);font-size:.72rem;text-transform:uppercase;letter-spacing:.08em;align-self:center}.choice{position:relative;display:flex;flex-direction:column;gap:.15rem;padding:.35rem .5rem;border:1px solid var(--border);border-radius:5px;min-width:0;&:has(input:checked){border-color:var(--accent);background:rgb(from var(--accent) r g b / .07)}&:has(input:focus-visible){outline:2px solid var(--accent);outline-offset:1px}}.choice input[type=radio]{position:absolute;opacity:0;pointer-events:none}.choice-label{font-size:.68rem;color:var(--muted);text-transform:uppercase;letter-spacing:.08em}.choice:has(input:checked) .choice-label{color:var(--accent)}.choice-value{font-size:.82rem;min-width:0}.flag-badge{font-size:.82rem;color:var(--muted)}.flag-badge.on{color:var(--accent);font-weight:600}.color{display:inline-flex;align-items:center;gap:.35rem}.color-dot{width:12px;height:12px;border-radius:50%;box-shadow:0 0 0 1px rgb(from var(--text) r g b / .2);flex-shrink:0;&.marker-red{background:var(--marker-red)}&.marker-blue{background:var(--marker-blue)}&.marker-green{background:var(--marker-green)}&.marker-gray{background:var(--marker-gray)}}.color-name{text-transform:capitalize}.comment-text{display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden;color:var(--text);white-space:pre-wrap;overflow-wrap:anywhere;& em{color:var(--muted);font-style:italic}}.fix-text{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;word-break:break-all;& a{color:var(--accent);text-decoration:none}& a:hover{text-decoration:underline}}.actions{display:flex;justify-content:flex-end;gap:.4rem;margin-top:.8rem;padding-top:.7rem;border-top:1px solid var(--border)}
43
+ `;function xn(e){if(!e)return g;let t=e.replaceAll("_"," ");return c`<span class="${`conflict-sev sev-${e}`}">${t}</span>`}function Jw(e){return`bundle-${e.slice(7,19)}\u2026`}function Ze(e){return e.kind==="bundle"?e.label??Jw(e.identifier):e.identifier}function Xw(e){return e?c`<span class="color"><span class="${`color-dot marker-${e}`}"></span> <span class="color-name">${e}</span></span>`:c`<em>none</em>`}function Qw(e){return c`<span class="comment-text">${e||c`<em>empty</em>`}</span>`}function Zw(e){return e?dn(e)?c`<span class="fix-text"><a href="${e}" target="_blank" rel="noopener noreferrer">${e}</a></span>`:c`<span class="fix-text">${e}</span>`:c`<span class="comment-text"><em>empty</em></span>`}function ev(e){return e?c`<span class="${`triage triage-${e}`}">${e}</span>`:c`<em>none</em>`}function tv(e){return e?c`<span class="${`flag-badge${e==="flagged"?" on":""}`}">${e}</span>`:c`<em>none</em>`}function Qf(e,t){return e==="color"?Xw(t):e==="comment"?Qw(t):e==="fix"?Zw(t):e==="triage"?ev(t):e==="flagged"?tv(t):c`${String(t)}`}function rv(e,t){let r=e?.file?e.line?`${e.file}:${e.line}`:e.file:"";return c`<div class="card-head">${xn(e?.severity)} ${r?c`<span class="loc" title="${r}">${r}</span>`:g} <code class="id" title="${t}">${t.slice(0,8)}…</code></div>${e?.description?c`<div class="desc" title="${e.description}">${e.description}</div>`:g}`}var eh={title:"Triage conflicts",intro:"disagree with your local triage on",trailingNote:"",applyButton:"Apply",importedSideLabel:"Apply imported"},Zf={color:0,comment:1,fix:2,triage:3,flagged:4},nv={color:"Color",comment:"Comment",fix:"Fix",triage:"Triage state",flagged:"Flag"},sc=class extends F{static styles=[...F.styles,B($n),B(Xf)];static properties={conflicts:{attribute:!1},findingLookup:{attribute:!1},labels:{attribute:!1},_settled:{state:!0}};constructor(){super(),this.conflicts=[],this.findingLookup=new Map,this.labels={...eh},this._settled=!1}focusInitial(){}_blockEscClose=t=>t.preventDefault();_onClick=t=>{let r=t.target.closest("[data-bulk]");if(!r)return;let n=r.dataset.bulk;for(let o of this.renderRoot.querySelectorAll(`input[type="radio"][value="${n}"]`))o.checked=!0};_onSubmit=t=>{t.preventDefault();let r={};for(let n of this.conflicts){let o=`${n.id}:${n.property}`,s=this.renderRoot.querySelector(`input[name="conflict-${CSS.escape(o)}"]:checked`);s&&(r[o]=s.value)}this._finish(r)};render(){let t=this.labels,r=new Map;for(let p of this.conflicts)r.has(p.id)||r.set(p.id,[]),r.get(p.id).push(p);for(let p of r.values())p.sort((f,h)=>(Zf[f.property]??99)-(Zf[h.property]??99));let n=this.conflicts.filter(p=>p.property==="color").length,o=this.conflicts.filter(p=>p.property==="comment").length,s=this.conflicts.filter(p=>p.property==="fix").length,i=this.conflicts.filter(p=>p.property==="triage").length,l=this.conflicts.filter(p=>p.property==="flagged").length,d=[n?`${n} color${n===1?"":"s"}`:"",o?`${o} comment${o===1?"":"s"}`:"",s?`${s} fix${s===1?"":"es"}`:"",i?`${i} triage state${i===1?"":"s"}`:"",l?`${l} flag${l===1?"":"s"}`:""].filter(Boolean).join(", "),u=`${r.size} finding${r.size===1?"":"s"}`;return c`<dialog @click="${this._onClick}" @cancel="${this._blockEscClose}" @close="${this._onClose}"><header><h3>${t.title}</h3><p>${u} ${t.intro} ${d}.${t.trailingNote?` ${t.trailingNote}`:""}</p><div class="bulk"><button type="button" data-bulk="local">Keep all current</button> <button type="button" data-bulk="imported">${t.importedSideLabel} (all)</button></div></header><form @submit="${this._onSubmit}"><ul class="list">${[...r.entries()].map(([p,f])=>c`<li class="card" data-id="${p}">${rv(this.findingLookup.get(p),p)}<div class="rows">${f.map(h=>{let b=`${h.id}:${h.property}`,m=`conflict-${b}`;return c`<div class="row" data-key="${b}"><span class="row-label">${nv[h.property]??h.property}</span> <label class="choice"><input type="radio" name="${m}" value="local" required> <span class="choice-label">Keep current</span> <span class="choice-value">${Qf(h.property,h.local)}</span></label> <label class="choice"><input type="radio" name="${m}" value="imported" required> <span class="choice-label">${t.importedSideLabel}</span> <span class="choice-value">${Qf(h.property,h.imported)}</span></label></div>`})}</div></li>`)}</ul><footer class="actions"><button type="submit" class="primary">${t.applyButton}</button></footer></form></dialog>`}};customElements.define("triage-conflict-dialog",sc);function $i(e,t,r={}){return new Promise((n,o)=>{let s=document.createElement("triage-conflict-dialog");s.conflicts=e,s.findingLookup=t,s.labels={...eh,...r},s.addEventListener("resolve",i=>{s.remove(),n(i.detail)}),s.addEventListener("modal-conflict",i=>{s.remove(),o(yt(i.detail?.cause))}),document.body.append(s)})}var ic=class extends F{static styles=[...F.styles,B(nt)];static properties={_password:{state:!0},_busy:{state:!0},_error:{state:!0},_settled:{state:!0}};constructor(){super(),this._password="",this._busy=!1,this._error="",this._settled=!1,this._tryPassword=null}_finish(t){this._settled||(this._password="",this._tryPassword=null,super._finish(t))}_onClose=()=>this._finish(null);_onCancel=()=>this._finish(null);_onPasswordInput=t=>{this._password=t.target.value,this._error=""};_onUnlock=async()=>{if(!(!this._password||this._busy)){this._busy=!0,this._error="";try{let t=await this._tryPassword(this._password);if(this._settled)return;this._finish(t)}catch(t){if(this._settled)return;this._error=t?.message??String(t)}finally{this._busy=!1}}};_onKeydown=t=>{t.key==="Enter"&&(t.preventDefault(),this._onUnlock())};render(){return c`<dialog @close="${this._onClose}"><header><h3>Unlock encrypted workspace</h3></header><p class="nwd-note">This workspace bundle is password-protected. Enter the password the sender shared with you separately to decrypt and import it.</p><label class="wsl-field"><span>Password</span> <input type="password" class="nwd-input" autocomplete="off" data-1p-ignore="true" data-lpignore="true" data-bwignore="true" data-form-type="other" name="dv-bundle-unlock" maxlength="1024" .value="${this._password}" @input="${this._onPasswordInput}" @keydown="${this._onKeydown}"></label> ${this._error?c`<p class="wsl-error" role="alert">${this._error}</p>`:g}<footer class="nwd-actions"><span class="nwd-spacer"></span> <button type="button" @click="${this._onCancel}">Cancel</button> <button type="button" class="primary" ?disabled="${!this._password||this._busy}" @click="${this._onUnlock}">${this._busy?"Unlocking\u2026":"Unlock"}</button></footer></dialog>`}};customElements.define("workspace-unlock-bundle-dialog",ic);function th({tryPassword:e}={}){if(typeof e!="function")throw new TypeError("openWorkspaceUnlockBundleDialog: tryPassword required");return new Promise((t,r)=>{let n=document.createElement("workspace-unlock-bundle-dialog");n._tryPassword=e,n.addEventListener("resolve",o=>{n.remove(),t(o.detail)}),n.addEventListener("modal-conflict",o=>{n._tryPassword=null,n.remove(),r(yt(o.detail?.cause))}),document.body.append(n)})}async function rh(e){let t=await Tl(e),r;if(wo(t)){if(r=await th({tryPassword:o=>Ys(t,o)}),!r)return null}else r=await Ys(t);let n=await Il(r,{conflictResolver:async(o,s)=>{try{return await $i(o,s,{title:"Triage conflicts on import",intro:"disagree with your local triage on",trailingNote:"Reports and non-conflicting triage were already merged; pick which side to keep for these disagreements.",importedSideLabel:"Apply imported"})}catch{let i=o.length;return alert(`Imported ${e.name}. Kept your local triage on ${i} conflicting entr${i===1?"y":"ies"} because another dialog is open \u2014 re-drop the file to pick again.`),null}}});return(a.currentFile||a.currentWorkspace)&&$(),n}var oh="deepview.passkey.firstImportPrompted";function ov(){try{return localStorage.getItem(oh)==="1"}catch{return!1}}function nh(){try{localStorage.setItem(oh,"1")}catch{}}async function ac(){if(ne()||!kt()||ov())return;if(!confirm(`Encrypt your DeepView data with a passkey?
44
44
 
45
45
  Your triage notes, workspaces, and report files are stored on this device. Encryption locks them under a passkey (TouchID, Windows Hello, security key) so scripts running here can't read them without the passkey.
46
46
 
47
- You can change this anytime from the lock icon in the sidebar header.`)){Af();return}await Us(),Q()&&Af()}var If=Gl;var Rf=["type","model","think","effort","exportsMode"],rr="deepview.lastFile",wo=new Set(["overview","graph","treemap","compare","advisories","issues","code","search","terminal"]);function Sr(e,t="overview"){let r=t&&t!=="overview"&&wo.has(t)?` ${t}`:"";Se(rr,`b:${e}${r}`).catch(()=>{})}var Cr=0,Ie=e=>e!==Cr;function ql(e){let t=Bf(e.toLowerCase());return t.endsWith(".map")?"sourcemap":t==="stasis.code.br"||t.endsWith(".stasis.code.br")?"stasis":null}function Bf(e){return e.replace(/ \(\d+\)(?=\.[^.]*$)/u,"")}async function Ff({name:e,content:t,existingNames:r}){if(!r.has(e))return await ut(e,t),r.add(e),{name:e,content:t};let n;try{n=await Oe(e)}catch(l){if(!(l instanceof DOMException&&l.name==="NotFoundError"||typeof l?.message=="string"&&l.message.startsWith("File not found:")))throw l;return await ut(e,t),r.add(e),{name:e,content:t}}if(n===t)return{name:e,content:t};let s=W().filter(l=>Array.isArray(l.reports)&&l.reports.includes(e)).filter(l=>ao(l.id,e)),i=await gf({name:e,workspaceNames:s.map(l=>l.name),existingNames:r});if(i.action==="cancel")return null;if(i.action==="rename"){let l=i.newName;return await ut(l,t),r.add(l),{name:l,content:t}}return await ut(e,t),s.length>0&&await mw(e,s),{name:e,content:t}}async function mw(e,t){let r;try{r=await mr(e)}catch(n){console.warn(`Import: failed to read freshly-saved "${e}" for cloud sync:`,n);return}for(let n of t)try{await Ds(n.id);let o=await Ps(n.id,e,r);o&&o.ok===!1&&console.warn(`Import: failed to upload "${e}" to workspace "${n.name}" (${n.id}): ${o.reason??"unknown"}`)}catch(o){console.warn(`Import: failed to upload "${e}" to workspace "${n.name}" (${n.id}):`,o)}}async function Yl(e){await If();let t=null,r=null,n=new Set,o=new Set(await pe());for(let s of e)try{let i=Bf(s.name.toLowerCase());if(i.endsWith(".gz")||i.endsWith(".deepview-workspace.enc")){await Ef(s);try{let u=await pe();o.clear();for(let p of u)o.add(p)}catch(u){console.warn("Import: failed to refresh existingNames after workspace import:",u)}continue}if(ql(s.name)){let u=new Uint8Array(await s.arrayBuffer()),{integrity:p}=await br(s.name,u);r=p,n.add(p);continue}let d=await s.text();if(i.endsWith(".csv")){let u=kf(d);for(let{displayName:p,data:f}of u){let h=p.replaceAll("/","__")+".codex",b=JSON.stringify(f),{count:m,source:y}=ze(b),k=await Ff({name:h,content:b,existingNames:o});k&&(qe(k.name,m,y),t={name:k.name,content:k.content})}}else{let u=ze(d);if(!u.recognized)throw new Error("not a recognized DeepView, DeepSec, Claude Security, or Codex report");let p=await Ff({name:s.name,content:d,existingNames:o});if(!p)continue;qe(p.name,u.count,u.source),t={name:p.name,content:p.content}}}catch(i){alert(`Failed to load ${s.name}: ${i.message}`)}await j();for(let s of n)Hl(s).catch(()=>{});t?await Et(t.name,t.content):r&&(a.currentView="bundles",a.selectedBundle=r,a.bundleDetails=null,a.bundleDetailsTab="overview",a.bundleSourceFile=null,a.bundleSourceFindingIdx=null,a.bundleCodeSearchQuery="",a.bundleCodeSearchMode="files",a.bundleSearchQuery="",a.bundleSearchRegex=!1,a.bundleSearchCase=!1,a.bundleSearchContext=!0,a.shownTriage=null,E.showAll=!0,Sr(r),x(),await j(),Ot(r))}async function Et(e,t){let r=++Cr,n=new Set(W().filter(o=>Array.isArray(o.reports)&&o.reports.includes(e)).map(o=>o.id));for(let o of N.openSessions)o&&!n.has(o.workspaceId)&&(N.closeSession(o.workspaceId),lo(o.workspaceId));if(a.reports=[],a.workspaceMerges=[],a.currentFile=e,a.currentWorkspace=null,(a.currentView==="bundles"||a.currentView==="packages"||a.currentView==="repositories")&&(a.currentView="findings"),a.repoUrl=Ke(e),a.repoEditing=!1,E.selected=null,E.focusedPkg=null,E.layoutCache=null,E.solo=null,E.hidden.clear(),E.pathFilter="",He(),Se(rr,e).catch(()=>{}),t===void 0){try{t=await Oe(e)}catch(o){if(Ie(r))return;if(o&&o.message?.includes("vault locked")){if(await zs()&&!Ie(r)){await Et(e);return}Ie(r)||(a.currentFile=null,await j());return}alert(`Failed to read ${e}: ${o.message}`),a.currentFile=null,await j();return}if(Ie(r))return}if(await Xl(e,t,r),!Ie(r)){for(let o of n)N.openSession(o),N.refreshSession(o),Ds(o);await j()}}async function nr(e){let t=W().find(o=>o.id===e);if(!t)return;let r=++Cr;for(let o of N.openSessions)o&&o.workspaceId!==e&&(N.closeSession(o.workspaceId),lo(o.workspaceId));(a.currentView==="bundles"||a.currentView==="packages"||a.currentView==="repositories")&&(a.currentView="findings"),a.reports=[],a.workspaceMerges=[],a.currentFile=null,a.currentWorkspace=e,a.repoUrl="",a.repoEditing=!1,E.selected=null,E.focusedPkg=null,E.layoutCache=null,E.solo=null,E.hidden.clear(),E.pathFilter="",He(),Se(rr,`ws:${e}`).catch(()=>{}),t.reports.length===0&&(C.classList.remove("active"),K(g,C),Be.classList.remove("hidden"));let n=t.reports.map(o=>Oe(o).catch(()=>null));for(let o=0;o<t.reports.length;o++){let s=await n[o];if(Ie(r))return;if(s!==null&&(await Xl(t.reports[o],s,r),Ie(r)))return}N.openSession(e),N.refreshSession(e),Ds(e),await j()}async function Mf({triage:e="keep",deleteFromRemoteWorkspaceIds:t=[]}={}){if(!a.currentFile)return;let r=++Cr,n=a.currentFile;Zr(n),Ge(n,"");for(let o of t)try{let s=await Os(o,n);if(Ie(r))return;s&&s.ok===!1&&s.reason!=="not-found"&&console.warn(`Failed to delete '${n}' from workspace ${o} remote: ${s.reason}`)}catch(s){console.warn(`Failed to delete '${n}' from workspace ${o} remote:`,s)}if(await jr(n),!Ie(r)&&(await Qn(n,null),!Ie(r))){if(e==="wipe"){try{await Is()}catch(o){console.warn("Skipped orphan-triage GC:",o)}if(Ie(r))return}Ie(r)||(Jl(),await j())}}function Jl(){a.currentFile=null,a.currentWorkspace=null,a.selectedBundle=null,a.bundleDetails=null,a.bundleSourceFile=null,a.bundleSourceFindingIdx=null,a.reports=[],a.workspaceMerges=[],a.repoUrl="",a.repoEditing=!1,a.shownTriage=null,a.currentView="findings",E.selected=null,E.focusedPkg=null,E.layoutCache=null,E.solo=null,E.hidden.clear(),E.pathFilter="",He(),Ur(rr),C.classList.remove("active"),K(g,C),Be.classList.remove("hidden"),document.title="DeepView"}async function Lf(){++Cr;for(let e of N.openSessions)e&&(N.closeSession(e.workspaceId),lo(e.workspaceId));Jl(),await j()}async function Pf({deleteFromRemoteWorkspaceIds:e=[]}={}){if(!a.selectedBundle)return;let t=++Cr,r=a.selectedBundle;for(let o of e)try{let s=await Ns(o,r);if(Ie(t))return;s&&s.ok===!1&&s.reason!=="not-found"&&console.warn(`Failed to delete bundle from workspace ${o} remote: ${s.reason}`)}catch(s){console.warn(`Failed to delete bundle from workspace ${o} remote:`,s)}if(await ma(r),Ie(t)||(await Za(r,null),Ie(t)))return;a.selectedBundle=null,a.bundleDetails=null,a.bundleSourceFile=null,a.bundleSourceFindingIdx=null;let n=we(rr);typeof n=="string"&&(n===`b:${r}`||n.startsWith(`b:${r} `))&&Ur(rr),Ra(r),a.bundles=await pt(),!Ie(t)&&(x(),await j())}async function Of(e,t="detach",{triage:r="keep"}={}){let n=W().find(l=>l.id===e);if(!n)return;++Cr;let o=Array.isArray(n.reports)?[...n.reports]:[];if(N.closeSession(e),lo(e),t==="delete"){for(let l of o){try{await jr(l)}catch{}Zr(l),Ge(l,"")}if(r==="wipe")try{await Is()}catch(l){console.warn("Skipped orphan-triage GC:",l)}}let s=a.currentWorkspace===e,i=t==="delete"&&a.currentFile!=null&&o.includes(a.currentFile);(s||i)&&Jl(),await qa(e),await j()}async function Xl(e,t,r=null){let n=()=>r!==null&&Ie(r);try{if(await to,n())return;let o;try{o=JSON.parse(t)}catch(b){if(o=Vr(t)??Kr(t),!o)throw new Error(`Not JSON, and not a recognized markdown format. (JSON error: ${b.message})`,{cause:b})}let s=a.reports.length===0,i=new Set,l=new Map;for(let b=0;b<a.reports.length;b++){let m=a.reports[b];for(let y=0;y<m.groups.length;y++){let k=m.groups[y],w=`${b}:${y}`;for(let v of k)v.id&&(i.add(v.id),l.set(v.id,w))}}let d=o.findings||[],u=d.flatMap(Al).filter(b=>!b.id);if(u.length>0){let b=await Promise.all(u.map(ws));if(n())return;u.forEach((m,y)=>{b[y]&&(m.id=b[y])})}let p=Ke(e),f=[],h=0;for(let b of d){let m=Al(b);if(m.length===0)continue;let y=m.filter(F=>F.id&&i.has(F.id)),k=m.filter(F=>!F.id||!i.has(F.id)),w=new Set;for(let F of y){let B=l.get(F.id);B!==void 0&&w.add(B)}let v=m.filter(F=>F.id).map(F=>F.id);if(k.length===0){w.size>1&&a.workspaceMerges.push(new Set(v)),h+=y.length;continue}let $=[];for(let F of k){F.id&&i.add(F.id);let B={...F,_id:a.nextFindingId++,_repoFallback:p,_reportName:e,_bundleHashes:o.bundleHashes??[]};if(!o.source&&!Rf.some(z=>B[z]!==void 0))for(let z of Rf)o[z]!==void 0&&(B[z]=o[z]);B._analyzer=o.source??B.type??null,$.push(B)}y.length>0&&(h+=y.length,a.workspaceMerges.push(new Set(v)));let R=`${a.reports.length}:${f.length}`;for(let F of k)F.id&&l.set(F.id,R);f.push($)}if(h>0&&console.log(`${e}: skipped ${h} duplicate finding${h===1?"":"s"}`),a.reports.push({type:o.type||"analysis",source:o.source??null,fileName:e,groups:f,tree:o.tree??null,bundleHashes:o.bundleHashes??[]}),Array.isArray(o.bundleHashes)&&o.bundleHashes.length>0){let b=new Set((a.bundles??[]).map(m=>m.integrity));for(let m of o.bundleHashes)b.has(m)&&Hl(m).catch(()=>{})}if(s)if(Gs(),f.some(m=>m.some(y=>y.confidence!==void 0))){let m=k=>f.reduce((w,v)=>w+(v.some($=>$.confidence!==void 0&&$.confidence>=k)?1:0),0),y;for(m(6)<=25?y=6:m(7)<=25?y=7:y=8;y>0&&m(y-1)===m(y);)y--;a.filterConfMin=y}else a.filterConfMin=0;x()}catch(o){alert(`Failed to parse ${e}: ${o.message}`)}}window.__loadFile=(e,t)=>Xl(e,t);window.__setFilters=({severities:e,confMin:t}={})=>{e!=null&&(a.filterSeverities=new Set(e)),t!==void 0&&(a.filterConfMin=t),x()};document.addEventListener("keydown",e=>{e.key==="Escape"&&document.body.classList.contains("report-fullscreen")&&document.body.classList.remove("report-fullscreen")});document.addEventListener("dragover",e=>e.preventDefault());document.addEventListener("drop",e=>{e.preventDefault(),!e.target.closest("#drop-zone")&&Yl(e.dataTransfer.files)});Be.addEventListener("dragover",e=>{e.preventDefault(),Be.classList.add("hover")});Be.addEventListener("dragleave",()=>Be.classList.remove("hover"));Be.addEventListener("drop",e=>{e.preventDefault(),Be.classList.remove("hover"),Yl(e.dataTransfer.files)});var Ct=null;function bw(){Ct||(Ct=document.createElement("input"),Ct.type="file",Ct.multiple=!0,Ct.hidden=!0,Ct.addEventListener("change",()=>{let e=Ct.files;e&&e.length>0&&Yl(e),Ct.value=""}),document.body.append(Ct)),Ct.click()}Be.addEventListener("click",e=>{e.target.closest(".drop-prompt-action")&&bw()});var Er=new Map,Nf="deepview.advisories.proxyConsent";function Df(){try{return localStorage.getItem(Nf)==="1"}catch{return!1}}function Uf(){try{localStorage.setItem(Nf,"1")}catch{}}function yw(e){let t=new Map;if(!e||e.kind!=="stasis"||!e.bundle)return t;for(let[r,n]of e.bundle.modules){if(!r.includes("node_modules")||!n?.name||typeof n.version!="string"||!n.version)continue;let o=t.get(n.name);o||(o=new Set,t.set(n.name,o)),o.add(n.version)}return t}function ww(e){if(!e||e.kind!=="stasis"||!e.bundle)return!1;for(let[t,r]of e.bundle.modules)if(t.includes("node_modules")&&r?.name&&typeof r.version=="string"&&r.version)return!0;return!1}function zf(e,t){return!e||ql(e.name)!=="stasis"?!1:!t||t.integrity!==e.integrity?!0:ww(t)}function vw(e){let t=Object.create(null);for(let[r,n]of e)t[r]=[...n].toSorted();return t}async function Wf(e,t){if(!e?.integrity||Er.has(e.integrity)||!Df())return;let r=yw(e);if(r.size===0){Er.set(e.integrity,{state:"ok",byPackage:new Map,query:r});return}Er.set(e.integrity,{state:"loading",query:r});let n=e.integrity;try{let o=await fetch("/api/npm-advisories",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(vw(r))});if(!o.ok){let l=`HTTP ${o.status}`;try{let d=await o.json();d&&typeof d.error=="string"&&d.error&&(l=`${d.error} (HTTP ${o.status})`)}catch{}Er.set(n,{state:"error",reason:l,query:r}),t();return}let s=await o.json(),i=new Map;if(s&&typeof s=="object")for(let[l,d]of Object.entries(s)){if(!Array.isArray(d))continue;let u=d.filter(p=>p&&typeof p=="object"&&typeof p.title=="string"&&typeof p.severity=="string");u.length>0&&i.set(l,u)}Er.set(n,{state:"ok",byPackage:i,query:r})}catch(o){Er.set(n,{state:"error",reason:o?.message??"fetch-failed",query:r})}t()}var kw={critical:0,high:1,moderate:2,low:3,info:4};function ai(e){return kw[e]??999}function $w(e){return e.charAt(0).toUpperCase()+e.slice(1)}function xw(){let e=typeof window>"u"?"":window.location.host;return c`<div class="bundle-advisories-consent"><div class="bundle-advisories-consent-card"><p class="bundle-advisories-consent-text">This bundle's dependency names and versions will be sent to the npm registry through a same-origin proxy (<span class="mono">${e}</span> → <span class="mono">registry.npmjs.org</span>) to look up published security advisories.</p><button type="button" class="bundle-advisories-consent-btn" data-advisories-consent>Confirm</button><p class="bundle-advisories-consent-note">This preference will be saved and reused for other bundles.</p></div></div>`}function Hf(e){if(!e)return c`<div class="bundle-advisories-empty">Bundle not loaded yet.</div>`;if(e.kind!=="stasis"||!e.bundle)return c`<div class="bundle-advisories-empty">Advisories are only available for stasis bundles.</div>`;if(!Df())return xw();let t=Er.get(e.integrity);if(!t||t.state==="loading")return c`<div class="bundle-advisories-empty">Loading advisories from npm registry…</div>`;if(t.state==="error")return c`<div class="bundle-advisories-empty is-error">Failed to fetch advisories: ${t.reason}</div>`;let r=t.query.size,n=t.byPackage.size;if(n===0)return c`<div class="bundle-advisories"><div class="bundle-advisories-summary">No advisories for the ${r} ${r===1?"package":"packages"} in this bundle.</div></div>`;let o=[...t.byPackage.entries()].toSorted(([i,l],[d,u])=>{let p=Math.min(...l.map(h=>ai(h.severity))),f=Math.min(...u.map(h=>ai(h.severity)));return p!==f?p-f:i.localeCompare(d)}),s=[...t.byPackage.values()].reduce((i,l)=>i+l.length,0);return c`<div class="bundle-advisories"><div class="bundle-advisories-summary">${s} ${s===1?"advisory":"advisories"} across ${n} of ${r} ${r===1?"package":"packages"}</div><ul class="bundle-advisories-list">${o.map(([i,l])=>_w(i,l,t.query.get(i)))}</ul></div>`}function _w(e,t,r){let n=[...t].toSorted((s,i)=>{let l=ai(s.severity)-ai(i.severity);return l!==0?l:(s.title??"").localeCompare(i.title??"")}),o=r?[...r].toSorted():[];return c`<li class="bundle-advisories-section"><div class="bundle-advisories-section-header"><span class="bundle-advisories-section-name">${e}</span> ${o.length>0?c`<span class="bundle-advisories-section-versions">${o.map(s=>c`<span class="bundle-advisories-version-chip">${s}</span>`)}</span>`:g} <span class="bundle-advisories-section-count">${n.length} ${n.length===1?"advisory":"advisories"}</span></div><ul class="bundle-advisories-rows">${n.map(s=>Aw(s))}</ul></li>`}function Sw(e){if(typeof e!="string")return null;let t=/\/(GHSA-[a-z0-9-]+)(?:[/?#]|$)/iu.exec(e);return t?t[1]:null}var Cw=c`<svg class="bundle-advisory-ghsa-icon" viewBox="0 0 16 16" width="11" height="11" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 13L13 3"/><path d="M5 3h8v8"/></svg>`;function Ew(e){let t=/^CWE-(\d+)$/u.exec(e);if(!t)return c`<span>${e}</span>`;let r=`https://cwe.mitre.org/data/definitions/${t[1]}.html`;return c`<a class="bundle-advisory-cwe" href="${r}" target="_blank" rel="noopener noreferrer">${e}</a>`}function Aw(e){let t=e.severity,r=e.title,n=typeof e?.cvss?.score=="number"?e.cvss.score.toFixed(1):"",o=typeof e?.cvss?.vectorString=="string"&&e.cvss.vectorString?e.cvss.vectorString:"",s=typeof e.vulnerable_versions=="string"?e.vulnerable_versions:null,i=typeof e.url=="string"&&/^https?:\/\//iu.test(e.url)?e.url:null,l=Sw(i),d=Array.isArray(e.cwe)?e.cwe.filter(p=>typeof p=="string"):[],u=l&&i?c`<a class="bundle-advisory-ghsa" href="${i}" target="_blank" rel="noopener noreferrer">${l}${Cw}</a>`:l?c`<span class="bundle-advisory-ghsa">${l}</span>`:g;return c`<li class="bundle-advisory-row"><div class="bundle-advisory-rail"><span class="${`bundle-advisory-severity sev-${t}`}">${$w(t)}</span> ${n?c`<span class="bundle-advisory-cvss-score">CVSS <span class="mono">${n}</span></span>`:g}</div><div class="bundle-advisory-body"><div class="bundle-advisory-header"><span class="bundle-advisory-title">${r}</span> ${u}</div><div class="bundle-advisory-subrow"><div class="bundle-advisory-meta">${s?c`<span>Affected <span class="mono">${s}</span></span>`:g} ${d.length>0?c`<span class="bundle-advisory-cwes">${d.map((p,f)=>c`${f===0?"":", "}${Ew(p)}`)}</span>`:g}</div>${o?c`<div class="bundle-advisory-cvss-vector mono">${o}</div>`:g}</div></div></li>`}var vo=null;function Tw(e){let t=new Map;if(!e||e.kind!=="stasis"||!e.bundle)return t;for(let r of e.bundle.imports.values())for(let[n,o]of r){t.has(n)||t.set(n,new Set);for(let s of o.values())typeof s=="string"&&t.get(n).add(s)}return t}function Iw(e){let t=Ne(e),r=Tw(e),n=[...t.keys()],{stripped:o}=Xe(n),s=new Map(n.map((l,d)=>[l,o[d]])),i={};for(let[l,d]of t){let u=s.get(l),p=r.get(l);i[u]={imports:p?[...p].map(f=>s.get(f)).filter(Boolean):[],size:new TextEncoder().encode(d).byteLength}}return{tree:i,origToStripped:s}}async function jl(e){let t=Ne(e),r=new Map;for(let[n,o]of t)r.set(n,await Fu(o));return r}function Gf(e){let t={inprogress:0,fixed:0,invalid:0,deleted:0};if(!e?.fileHashes)return t;let r=new Set;for(let n of e.fileHashes.values())if(!r.has(n)){r.add(n);for(let o of ks(n)){let s=a.triage.get(O(o))?.triage;s&&t[s]!==void 0&&t[s]++}}return t}function hn(e,t="graph"){if(!e||e.size===0)return new Map;let r=new Map;for(let[n,o]of e){let s=ks(o);if(s.length===0)continue;let i=s.filter(d=>{let u=a.triage.get(O(d))?.triage??null;return t==="issues"?u!=="invalid"&&u!=="deleted":u===a.shownTriage});if(i.length===0)continue;r.has(n)||r.set(n,[]);let l=r.get(n);for(let d of i)l.push(d)}return r}function Rw(e,t){let r=new Set;for(let[o,s]of t)if(s){for(let i of Object.values(s))if(i>0){r.add(o);break}}let n=[...r];for(;n.length>0;){let o=n.shift(),s=e[o]?.imports??[];for(let i of s)!r.has(i)&&e[i]&&(r.add(i),n.push(i))}return r}function qf(e){let{tree:t,origToStripped:r}=Iw(e),n=Object.keys(t);if(n.length===0)return null;let o=null;if(e.fileHashes&&e.fileHashes.size>0){o=new Map;for(let[m,y]of e.fileHashes){let k=r.get(m);k!==void 0&&o.set(k,y)}}let s=hn(o),i=new Map,l=new Map,d=new Map,u=new Map;for(let[m,y]of s){let k={critical:0,high:0,medium:0,low:0,high_bug:0,bug:0,informational:0},w=new Set,v=new Set,$=[];for(let R of y){k[R.severity]=(k[R.severity]||0)+1,w.add(R.severity);let F=a.triage.get(O(R))?.color??"none";v.add(F),$.push({severity:R.severity,color:F})}i.set(m,k),l.set(m,w),d.set(m,v),u.set(m,$)}let p=Ys(t,i),f=E.showAll?n:[...Rw(t,i)],h=new Map;for(let[m,y]of r)h.set(y,m);let b=!1;for(let m of Object.values(t))if(m?.imports&&m.imports.length>0){b=!0;break}return{treeData:t,files:f,ownCounts:i,transitiveCounts:p,severitySets:l,colorSets:d,fileFindings:u,options:{pkgOf:or},strippedToOrig:h,hasEdges:b}}function di(){if(!vo)return;let e=an();e&&e.refreshSidebar(vo,{isBundleContext:!0})}function ui(){if(!vo)return;let e=an();e&&e.refreshTopPkgs(vo)}function Yf(e){vo=e}function or(e){let t=/(?:^|\/)(?:node_modules|dependencies)\/(@[^/]+\/[^/]+|[^/]+)/gu,r;for(;(r=t.exec(e))!==null;)if(r[1]!==".pnpm")return r[1];let n=e.indexOf("/");return n>0?e.slice(0,n):"__own__"}function Fw(e){let t=new Map,r=0;for(let{path:o,size:s}of e){if(typeof s!="number"||s<=0)continue;let i=or(o);t.set(i,(t.get(i)??0)+s),r+=s}if(r===0)return g;let n=[...t.entries()].toSorted((o,s)=>s[1]-o[1]);return c`<div class="bundles-dist"><div class="bundles-dist-bar" aria-hidden="true">${G(n,([o])=>o,([o,s])=>c`<span class="bundles-dist-seg" style="${ue({flexGrow:s,background:ht(o)})}" data-tooltip="${o==="__own__"?g:`${o}: ${ne(s)}`}"></span>`)}</div><ul class="bundles-dist-list">${G(n,([o])=>o,([o,s])=>{let i=(s/r*100).toFixed(1),l=o==="__own__"?"own source":o,d=ht(o);return c`<li><span class="bundles-dist-dot" style="${ue({background:d})}"></span> <span class="bundles-dist-pkg" data-tooltip="${o==="__own__"?g:o}">${l}</span> <span class="bundles-dist-bar-row" aria-hidden="true"><span class="bundles-dist-bar-fill" style="${ue({width:`${i}%`,background:d})}"></span> </span><span class="bundles-dist-size">${ne(s)}</span> <span class="bundles-dist-percent">${i}%</span></li>`})}</ul></div>`}function jf(e,t,r,n){let{prefix:o,stripped:s}=Xe(r),i=new Set;for(let v of s)i.add(or(v));let l=s.map((v,$)=>$).toSorted((v,$)=>s[v].localeCompare(s[$])),d=s.map((v,$)=>({path:v,size:n[$]})),u=Fw(d),p=u===g?c`<p class="bundles-overview-col-empty">No size information for this bundle's sources.</p>`:u,f={critical:0,high:0,medium:0,low:0,high_bug:0,bug:0,informational:0},h=0,b=new Map;if(a.bundleDetails?.fileHashes){let v=hn(a.bundleDetails.fileHashes,"issues");for(let $ of v.values())for(let R of $){f[R.severity]!==void 0&&f[R.severity]++,h++;for(let F of Wn(R.fileHash,R))b.set(F,(b.get(F)??0)+1)}}let m=[...b.keys()].toSorted(),y=ke.filter(v=>f[v]>0).map(v=>c`<span class="${`tree-count-chip ${v}`}">${f[v]} ${v.replaceAll("_"," ")}</span>`),k=r.length>0?c`<ul class="bundles-sources-list">${l.map(v=>{let $=r[v],R=s[v],F=n[v];return c`<li><button type="button" class="bundles-source-row" data-bundle-view-source="${$}" data-tooltip="${$}"><span class="bundles-source-path">${R}</span> ${F==null?g:c`<span class="bundles-source-size">${ne(F)}</span>`}</button></li>`})}</ul>`:c`<p class="bundles-overview-col-empty">No source files in this bundle.</p>`,w=m.length>0?c`<ul class="bundles-reports-list">${m.map(v=>{let $=X[Ye(v)]??X.default,R=b.get(v)??0;return c`<li><button type="button" class="report-chip bundles-report-chip" data-tooltip="${v}" data-bundle-issue-report="${v}">${me($)}<span class="report-chip-label">${Me(v)}</span> <span class="bundles-report-count">${R} ${R===1?"issue":"issues"}</span></button></li>`})}</ul>`:c`<p class="bundles-overview-col-empty">No matching reports indexed yet.</p>`;return c`<div class="bundles-overview"><div class="bundles-overview-summary"><div class="bundles-detail-meta-row">${e}<dl class="bundles-detail-meta">${t}<dt>Sources</dt><dd>${r.length}</dd>${o?c`<dt>Prefix</dt><dd class="mono">${o}</dd>`:g}</dl></div>${h>0?c`<div class="bundles-issue-summary tree-count-chips">${y}</div>`:g}</div><div class="bundles-overview-columns"><section class="bundles-overview-col"><header class="bundles-overview-col-head">Packages <span class="bundles-overview-col-count">${i.size}</span></header><div class="bundles-overview-col-body">${p}</div></section><section class="bundles-overview-col"><header class="bundles-overview-col-head">Files <span class="bundles-overview-col-count">${r.length}</span></header><div class="bundles-overview-col-body bundles-overview-col-body--list">${k}</div></section>${m.length>0?c`<section class="bundles-overview-col"><header class="bundles-overview-col-head">Reports <span class="bundles-overview-col-count">${m.length}</span></header><div class="bundles-overview-col-body bundles-overview-col-body--list">${w}</div></section>`:g}</div></div>`}var Ql=new Map,Zl=new Set;function ci(e){for(let t of ke)for(let r of e)if(r.severity===t)return t;return e[0]?.severity??null}function tc(e,t,r,n,o=null){let s=e.split(`
48
- `).length,i=String(s).length,l=Qs(t),d=`${r??""}\0${t}`;l&&!Ql.has(d)&&!Zl.has(d)&&(Zl.add(d),(async()=>{let p=await Zs(e,l);Ql.set(d,p??null),Zl.delete(d),a.bundleSourceFile===t&&x()})());let u=Ql.get(d);return c`<div class="bundle-source-lines" style="${ue({"--lineno-width":`${i}ch`})}"><aside class="bundle-source-lineno-col" aria-hidden="true">${Array.from({length:s},(p,f)=>{let h=f+1,b=n.get(h),m=b?ci(b.map(k=>k.f)):null,y=b&&a.bundleSourceFindingIdx!=null&&b.some(k=>k.idx===a.bundleSourceFindingIdx);return c`<div class="${A({"bundle-source-lineno-row":!0,"is-match":o?.has(h)??!1})}" data-line="${h}">${b?c`<button type="button" class="${A({"bundle-source-dot":!0,[`sev-${m}`]:!0,active:y})}" data-bundle-source-finding="${b[0].idx}" title="${`${b.length} ${b.length===1?"issue":"issues"} on line ${h}`}" aria-label="${`${b.length} issues on line ${h}`}"></button>`:c`<span class="bundle-source-dot-placeholder"></span>`} <span class="bundle-source-lineno-num">${h}</span></div>`})}</aside><pre class="bundle-source-code"><code class="${l?`language-${l}`:""}">${typeof u=="string"?me(u):e}</code></pre></div>`}function rc(e){let t=a.bundleSourceFindingIdx;if(t==null)return g;let r=e[t];if(!r)return g;let n=r.fileHash?Wn(r.fileHash,r):[],o=a.triage.get(O(r))?.triage,s=o==="fixed"?"Fixed":o==="inprogress"?"In progress":null,i=xr(r),l=Zf(r.line);return c`<aside class="bundle-source-panel"><header class="bundle-source-panel-bar"><span class="${`bundle-source-panel-sev sev-${r.severity}`}">${r.severity.replaceAll("_"," ")}</span> ${s?c`<span class="${`bundle-source-panel-triage triage-${o}`}">${s}</span>`:g} <button type="button" class="bundle-source-panel-close" data-action="bundle-source-panel-close" title="Close (Esc)" aria-label="Close finding details">×</button></header><div class="bundle-source-panel-body">${l||i?c`<div class="bundle-source-panel-line-row">${l?c`<span class="bundle-source-panel-line">${l}</span>`:g} ${i?c`<span class="bundle-source-panel-meta" title="${i}">${i}</span>`:g}</div>`:g}<div class="bundle-source-panel-desc">${r.description??""}</div>${n.length>0?c`<div class="bundle-source-panel-reports"><div class="bundle-source-panel-reports-label">Reported by</div>${n.map(d=>{let u=X[Ye(d)]??X.default;return c`<button type="button" class="report-chip bundle-source-panel-report" title="${d}" data-bundle-issue-report="${d}">${me(u)}<span class="report-chip-label">${Me(d)}</span></button>`})}</div>`:g}</div></aside>`}function nc(e,t,r){let n=[],o=new Map;if(typeof r=="string"&&e?.fileHashes){let i=hn(e.fileHashes,"issues").get(t)??[];for(let l=0;l<i.length;l++){let d=i[l];n.push(d);let u=parseInt(d.line,10);Number.isFinite(u)&&u>0&&(o.has(u)||o.set(u,[]),o.get(u).push({f:d,idx:l}))}}return{fileFindings:n,lineFindings:o}}function Jf(){let e=a.bundleSourceFile;if(!e)return g;if(a.bundleDetailsTab==="code"||a.bundleDetailsTab==="search")return g;let r=Ne(a.bundleDetails).get(e),{fileFindings:n,lineFindings:o}=nc(a.bundleDetails,e,r);return c`<div class="bundle-source-overlay"><div class="${A({"bundle-source-modal":!0,"with-panel":a.bundleSourceFindingIdx!=null})}"><header class="bundle-source-bar"><div class="bundle-source-title" title="${e}">${e}</div><button type="button" class="bundle-source-close" data-action="bundle-source-close" title="Close source viewer (Esc)" aria-label="Close source viewer">×</button></header><div class="bundle-source-body"><div class="bundle-source-code-wrap">${typeof r=="string"?tc(r,e,a.bundleDetails?.integrity,o):c`<div class="bundle-source-empty">Source content not bundled.</div>`}</div>${rc(n)}</div></div></div>`}function Xf(e){let t={name:"",files:new Map,dirs:new Map};for(let r of e){let n=r.split("/"),o=t;for(let s=0;s<n.length-1;s++){let i=n[s],l=o.dirs.get(i);l||(l={name:i,files:new Map,dirs:new Map},o.dirs.set(i,l)),o=l}o.files.set(n.at(-1),r)}return t}var li=new Map,Vf=null;function ec(e,t,r=0,n=null,o="",s=!1){let i=[...e.dirs.entries()].toSorted(([f],[h])=>f.localeCompare(h)),l=[...e.files.entries()].toSorted(([f],[h])=>f.localeCompare(h)),d=f=>{if(!t)return!1;for(let h of f.files.values())if(h===t)return!0;for(let h of f.dirs.values())if(d(h))return!0;return!1},u=(f,h)=>s?!0:li.has(f)?li.get(f):r===0||d(h),p=f=>h=>{li.set(f,!h.currentTarget.parentElement.open)};return c`<ul class="${A({"bundle-code-tree":!0,root:r===0})}">${G(i,([f])=>`${o}/${f}`,([f,h])=>{let b=o?`${o}/${f}`:f;return c`<li class="bundle-code-tree-dir"><details ?open="${u(b,h)}"><summary @click="${p(b)}">${f}</summary>${ec(h,t,r+1,n,b,s)}</details></li>`})} ${G(l,([,f])=>f,([f,h])=>{let b=n?.get(h),m=b&&b.length>0?ci(b):null,y=b?.length??0;return c`<li class="bundle-code-tree-file"><button type="button" class="${A({"bundle-code-tree-link":!0,current:h===t})}" data-bundle-view-source="${h}" title="${h}"><span class="bundle-code-tree-name">${f}</span> ${y>0?c`<span class="${`bundle-code-tree-count sev-${m}`}" title="${`${y} ${y===1?"issue":"issues"}`}">${y}</span>`:g}</button></li>`})}</ul>`}function Bw(e,t,r,n,o=""){if(!r)return ec(e,t,0,n);let s=r.toLowerCase(),i=[],l=h=>{for(let[,b]of h.dirs)l(b);for(let[,b]of h.files)(o&&b.startsWith(o)?b.slice(o.length):b).toLowerCase().includes(s)&&i.push(b)};if(l(e),i.length===0)return c`<div class="bundle-code-search-empty">No files match.</div>`;let d=o?i.map(h=>h.startsWith(o)?h.slice(o.length):h):i,u=new Map;for(let h=0;h<i.length;h++)u.set(d[h],i[h]);let p=Xf(d),f=h=>{let b=new Map;for(let[m,y]of h.files)b.set(m,u.get(y)??y);h.files=b;for(let m of h.dirs.values())f(m)};return f(p),ec(p,t,0,n,"",!0)}function Mw(e,t,r,n=""){if(!t)return c`<div class="bundle-code-search-hint">Type to search across every source in this bundle.</div>`;let o=t.toLowerCase(),s=20,i=100,l=[],d=0;for(let[u,p]of e){if(typeof p!="string")continue;let f=[],h=p.split(`
49
- `);for(let b=0;b<h.length;b++){let m=h[b];if(m.toLowerCase().includes(o)&&(f.push({ln:b+1,text:m}),d++,f.length>=s))break}if(f.length>0&&l.push({path:u,hits:f}),l.length>=i)break}return l.length===0?c`<div class="bundle-code-search-empty">No matches.</div>`:c`<div class="bundle-code-search-results"><div class="bundle-code-search-summary">${d} ${d===1?"hit":"hits"} in ${l.length} ${l.length===1?"file":"files"}</div>${l.map(({path:u,hits:p})=>{let f=n&&u.startsWith(n)?u.slice(n.length):u;return c`<div class="${A({"bundle-code-search-file":!0,current:u===r})}"><button type="button" class="bundle-code-search-file-name" data-bundle-view-source="${u}" title="${u}">${f}</button><ul class="bundle-code-search-hits">${p.map(h=>c`<li class="bundle-code-search-hit"><button type="button" class="bundle-code-search-hit-link" data-bundle-view-source="${u}" data-bundle-view-line="${h.ln}" data-bundle-view-scroll-block="start" title="${`${u}:${h.ln}`}"><span class="bundle-code-search-hit-ln">${h.ln}</span> <span class="bundle-code-search-hit-text mono">${h.text.slice(0,200)}</span></button></li>`)}</ul></div>`})}</div>`}function Lw(e,t,r,n=""){if(!e.fileHashes)return c`<div class="bundle-code-search-empty">Computing file hashes…</div>`;let o=hn(e.fileHashes,"issues");if(o.size===0)return c`<div class="bundle-code-search-empty">No issues match this bundle's files.</div>`;let s=t.toLowerCase(),i=[];for(let[l,d]of o)for(let u=0;u<d.length;u++){let p=d[u],f=p.description??"";s&&!l.toLowerCase().includes(s)&&!p.severity.includes(s)&&!f.toLowerCase().includes(s)||i.push({file:l,finding:p,fileIdx:u})}return i.sort((l,d)=>{let u=Je[l.finding.severity]??0,p=Je[d.finding.severity]??0;return p!==u?p-u:l.file.localeCompare(d.file)}),i.length===0?c`<div class="bundle-code-search-empty">No matches.</div>`:c`<div class="bundle-code-search-results"><div class="bundle-code-search-summary">${i.length} ${i.length===1?"issue":"issues"}</div><ul class="bundle-code-search-issues">${i.map(({file:l,finding:d,fileIdx:u})=>{let p=d.severity,f=n&&l.startsWith(n)?l.slice(n.length):l,h=l===r&&a.bundleSourceFindingIdx===u;return c`<li class="${A({"bundle-code-search-issue":!0,current:h})}"><button type="button" class="bundle-code-search-issue-link" data-bundle-view-source="${l}" data-bundle-view-finding-idx="${u}" data-bundle-view-line="${d.line??""}" title="${l}"><div class="bundle-code-search-issue-row"><span class="${`bundle-code-search-issue-sev sev-${p}`}">${p.replaceAll("_"," ")}</span> <span class="bundle-code-search-issue-path mono">${f}${d.line?`:${d.line}`:""}</span></div><div class="bundle-code-search-issue-desc">${d.description??""}</div></button></li>`})}</ul></div>`}function Pw(e){if(!e||!e.json&&!e.bundle)return g;let t=Ne(e);if(t.size===0)return c`<div class="bundle-code-empty">This bundle doesn't carry any source content.</div>`;Vf!==a.selectedBundle&&(li.clear(),Vf=a.selectedBundle);let r=[...t.keys()].toSorted(),{prefix:n,stripped:o}=Xe(r),s=new Map;for(let w=0;w<r.length;w++)s.set(o[w],r[w]);let i=Xf(o),l=w=>{let v=new Map;for(let[$,R]of w.files)v.set($,s.get(R)??R);w.files=v;for(let $ of w.dirs.values())l($)};l(i);let d=a.bundleSourceFile,u=d?t.get(d):null,{fileFindings:p,lineFindings:f}=nc(e,d,u),h=e.fileHashes?hn(e.fileHashes,"issues"):new Map,m=h.size>0?["files","code","issues"]:["files","code"],y=m.includes(a.bundleCodeSearchMode)?a.bundleCodeSearchMode:"files",k=a.bundleCodeSearchQuery;return c`<div class="bundle-code-view"><aside class="bundle-code-rail"><div class="bundle-code-rail-head"><span class="bundle-code-rail-label">Files</span> <span class="bundle-code-rail-count">${r.length}</span></div>${n?c`<div class="bundle-code-rail-prefix mono" title="${n}">${n}</div>`:g}<bundle-code-search .modes="${m}"></bundle-code-search><div class="bundle-code-rail-body">${Dl(y,[["files",()=>Bw(i,d,k,h,n)],["code",()=>Mw(t,k,d,n)],["issues",()=>Lw(e,k,d,n)]])}</div></aside><div class="${A({"bundle-code-main":!0,"with-panel":a.bundleSourceFindingIdx!=null})}">${d?c`<header class="bundle-code-main-bar"><span class="bundle-code-main-path mono" title="${d}">${d}</span></header><div class="bundle-code-main-body"><div class="bundle-source-code-wrap">${typeof u=="string"?tc(u,d,e.integrity,f):c`<div class="bundle-source-empty">Source content not bundled.</div>`}</div>${rc(p)}</div>`:c`<div class="bundle-code-placeholder">Pick a file from the tree to view its source.</div>`}</div></div>`}var Ow=5e3,Nw=500,Dw=400,Kf=50;function Uw(e){return e<=5?8:e<=15?6:e<=40?4:e<=120?3:2}function zw(e,t){let r=t?"gu":"giu",n=t?"g":"gi";try{return{re:new RegExp(e,r)}}catch{try{return{re:new RegExp(e,n)}}catch(o){return{error:o.message}}}}function Qf(e,t,r){if(t){let s=zw(e,r);if(s.error)return{error:s.error};let{re:i}=s;return{ranges(l){i.lastIndex=0;let d=[],u;for(;(u=i.exec(l))!==null;){if(u[0].length===0){i.lastIndex++;continue}if(d.push([u.index,u.index+u[0].length]),d.length>=Kf)break}return d}}}let n=r?e:e.toLowerCase(),o=n.length;return{ranges(s){let i=r?s:s.toLowerCase(),l=[],d=0,u;for(;(u=i.indexOf(n,d))!==-1&&(l.push([u,u+o]),d=u+o,!(l.length>=Kf)););return l}}}function Ww(e,t,r){let n=[];for(let o of e){let s=Math.max(1,o.ln-r),i=Math.min(t,o.ln+r),l=n.at(-1);l&&s<=l.end+1?l.end=Math.max(l.end,i):n.push({start:s,end:i})}return n}function Hw(e,t,r){if(e.length<=r)return{text:e,ranges:t,clipped:!1};let n=t.length>0?t[0][0]:0,o=n>r-60?Math.max(0,n-60):0,s=e.slice(o,o+r);if(o===0)return{text:s,ranges:t,clipped:!1};let i=[];for(let[l,d]of t){let u=l-o,p=d-o;p<=0||u>=s.length||i.push([Math.max(0,u),Math.min(s.length,p)])}return{text:s,ranges:i,clipped:!0}}function jw(e,t){if(t.length===0)return e;let r=[],n=0;for(let[o,s]of t){let i=Math.max(n,Math.min(o,e.length)),l=Math.max(i,Math.min(s,e.length));l<=i||(i>n&&r.push(e.slice(n,i)),r.push(c`<mark class="bundle-search-mark">${e.slice(i,l)}</mark>`),n=l)}return n<e.length&&r.push(e.slice(n)),r}function Vw(e,t,r){let n=Hw(e,r??[],Dw);return c`<div class="${A({"bundle-search-line":!0,"is-match":r!=null})}"><span class="bundle-search-lineno">${t}</span> <span class="bundle-search-code">${n.clipped?c`<span class="bundle-search-clip">…</span>`:g}${jw(n.text,n.ranges)}</span></div>`}function Kw(e,t,r,n,o){let{start:s,end:i}=r,l=s;for(let p=s;p<=i;p++)if(n.has(p)){l=p;break}let d=String(i).length,u=[];for(let p=s;p<=i;p++)u.push(Vw(t[p-1]??"",p,n.get(p)??null));return c`${o?c`<div class="bundle-search-gap" aria-hidden="true"></div>`:g} <button type="button" class="bundle-search-snippet" style="${ue({"--bundle-search-lineno-w":`${d}ch`})}" data-bundle-view-source="${e}" data-bundle-view-line="${l}" data-bundle-view-scroll-block="center" title="${`${e}:${l}`}">${u}</button>`}function Gw(e,t,r){let{path:n,lines:o,hits:s}=e,i=t&&n.startsWith(t)?n.slice(t.length):n,l=Ww(s,o.length,r),d=new Map(s.map(f=>[f.ln,f.ranges])),u=s[0].ln,p=n===a.bundleSourceFile;return c`<section class="${A({"bundle-search-file":!0,current:p})}"><header class="bundle-search-file-head"><button type="button" class="bundle-search-file-name mono" data-bundle-view-source="${n}" data-bundle-view-line="${u}" data-bundle-view-scroll-block="center" title="${n}">${i}</button> <span class="bundle-search-file-count">${s.length} ${s.length===1?"match":"matches"}</span></header><div class="bundle-search-snippets">${l.map((f,h)=>Kw(n,o,f,d,h>0))}</div></section>`}function qw(e,t,r,n,o){if(!t)return c`<div class="bundle-search-results"><div class="bundle-search-hint">Search across every source in this bundle. Each match shows the surrounding lines for context — fewer matches get more context. Toggle <span class="bundle-search-hint-kbd">Aa</span> for case-sensitive and <span class="bundle-search-hint-kbd">.*</span> for regular-expression matching.</div></div>`;let s=Qf(t,r,n);if(s.error)return c`<div class="bundle-search-results"><div class="bundle-search-error"><span class="bundle-search-error-label">Invalid regular expression</span> <span class="bundle-search-error-msg mono">${s.error}</span></div></div>`;let i=[...e.keys()].toSorted(),{prefix:l}=Xe(i),d=[],u=0,p=!1;for(let b of i){let m=e.get(b);if(typeof m!="string")continue;let y=m.split(`
50
- `),k=[];for(let w=0;w<y.length;w++){let v=s.ranges(y[w]);if(v.length!==0&&(k.push({ln:w+1,ranges:v}),u++,u>=Ow)){p=!0;break}}if(k.length>0&&d.push({path:b,lines:y,hits:k}),p)break;if(d.length>=Nw){p=!0;break}}if(d.length===0)return c`<div class="bundle-search-results"><div class="bundle-search-empty">No matches.</div></div>`;let f=o?Uw(u):0,h=d.length;return c`<div class="bundle-search-results"><div class="bundle-search-summary"><span>${u}${p?"+":""} ${u===1?"match":"matches"} in ${h}${p?"+":""} ${h===1?"file":"files"}</span> ${l?c`<span class="bundle-search-summary-prefix mono" title="${l}">${l}</span>`:g} ${p?c`<span class="bundle-search-summary-more">results capped — refine to narrow</span>`:g}</div>${G(d,b=>b.path,b=>Gw(b,l,f))}</div>`}function Yw(e,t,r,n){let o=new Set;if(!t||typeof e!="string")return o;let s=Qf(t,r,n);if(s.error)return o;let i=e.split(`
51
- `);for(let l=0;l<i.length;l++)s.ranges(i[l]).length>0&&o.add(l+1);return o}function Jw(e,t,r){let n=a.bundleSourceFile;if(!n)return g;let o=t.get(n),{fileFindings:s,lineFindings:i}=nc(e,n,o);return c`<aside class="bundle-search-side"><header class="bundle-source-bar"><div class="bundle-source-title" title="${n}">${n}</div><button type="button" class="bundle-source-close" data-action="bundle-source-close" title="Close source viewer (Esc)" aria-label="Close source viewer">×</button></header><div class="bundle-source-body"><div class="bundle-source-code-wrap">${typeof o=="string"?tc(o,n,e.integrity,i,r):c`<div class="bundle-source-empty">Source content not bundled.</div>`}</div>${rc(s)}</div></aside>`}function Xw(e){if(!e||!e.json&&!e.bundle)return g;let t=Ne(e);if(t.size===0)return c`<div class="bundle-search-view"><div class="bundle-code-empty">This bundle doesn't carry any source content.</div></div>`;let r=a.bundleSearchQuery,n=a.bundleSearchRegex,o=a.bundleSearchCase,s=null;if(a.bundleSourceFile){let l=Yw(t.get(a.bundleSourceFile),r,n,o);l.size===0?(a.bundleSourceFile=null,a.bundleSourceFindingIdx=null):s=l}let i=a.bundleSearchContext;return c`<div class="bundle-search-view"><div class="bundle-search-bar-row"><bundle-search></bundle-search><button type="button" class="${A({"bundle-search-context-toggle":!0,on:i})}" data-bundle-search-context aria-pressed="${String(i)}" aria-label="Toggle context lines"><span>Context</span><span class="bundle-search-switch" aria-hidden="true"></span></button></div><div class="bundle-search-main">${qw(t,r,n,o,i)} ${Jw(e,t,s)}</div></div>`}function Qw(e){let t=zf(e,a.bundleDetails);a.bundleDetailsTab==="advisories"&&!t&&(a.bundleDetailsTab="overview");let r=(a.bundles?.length??0)>=2;a.bundleDetailsTab==="compare"&&!r&&(a.bundleDetailsTab="overview");let n=a.bundleDetailsTab,o=n==="overview";return n==="advisories"&&t&&Wf(a.bundleDetails,x).catch(()=>{}),c`<div class="bundles-view bundles-slide-view"><header class="bundles-slide-bar"><span class="bundles-slide-icon" aria-hidden="true">${me(ln)}</span><div class="bundles-slide-title"><div class="bundles-slide-name">${e.name}</div></div><div class="bundles-slide-tabs" role="tablist">${t?c`<button type="button" class="${A({"bundles-tab":!0,active:n==="advisories"})}" data-bundle-tab="advisories" aria-selected="${String(n==="advisories")}" role="tab">Advisories</button>`:g} <button type="button" class="${A({"bundles-tab":!0,active:n==="issues"})}" data-bundle-tab="issues" aria-selected="${String(n==="issues")}" role="tab">Issues</button> <button type="button" class="${A({"bundles-tab":!0,active:n==="terminal"})}" data-bundle-tab="terminal" aria-selected="${String(n==="terminal")}" role="tab">Terminal</button> <button type="button" class="${A({"bundles-tab":!0,active:n==="treemap"})}" data-bundle-tab="treemap" aria-selected="${String(n==="treemap")}" role="tab">Treemap</button> <button type="button" class="${A({"bundles-tab":!0,active:n==="graph"})}" data-bundle-tab="graph" aria-selected="${String(n==="graph")}" role="tab">Graph</button> <button type="button" class="${A({"bundles-tab":!0,active:n==="code"})}" data-bundle-tab="code" aria-selected="${String(n==="code")}" role="tab">Code</button> <button type="button" class="${A({"bundles-tab":!0,active:n==="search"})}" data-bundle-tab="search" aria-selected="${String(n==="search")}" role="tab">Search</button> ${r?c`<button type="button" class="${A({"bundles-tab":!0,active:n==="compare"})}" data-bundle-tab="compare" aria-selected="${String(n==="compare")}" role="tab">Compare</button>`:g} <button type="button" class="${A({"bundles-tab":!0,active:o})}" data-bundle-tab="overview" aria-selected="${String(o)}" role="tab">Overview</button></div></header><div class="${A({"bundles-slide-body":!0,"bundles-slide-body-overview":o})}">${o?tv(e,a.bundleDetails):Dl(n,[["terminal",()=>c`<div id="bundle-terminal-slot" class="bundle-terminal-slot"></div>`],["graph",()=>c`<div id="bundle-graph-slot" class="bundle-graph-slot"></div>`],["treemap",()=>c`<bundle-treemap .details="${a.bundleDetails}"></bundle-treemap>`],["code",()=>Pw(a.bundleDetails)],["search",()=>Xw(a.bundleDetails)],["compare",()=>c`<bundle-compare .details="${a.bundleDetails}" .integrity="${e.integrity}"></bundle-compare>`],["issues",()=>ev(a.bundleDetails)],["advisories",()=>Hf(a.bundleDetails)]])}</div></div>`}function Zw(e,t={}){if(!e)return g;let r=[];if(e.fileHash&&(r=Wn(e.fileHash,e)),r.length===0&&t.bucketKey&&(t.kind==="package"?r=Ea(t.bucketKey,e):t.kind==="repository"&&(r=Aa(t.bucketKey,e))),r.length===0)return g;let n=r.slice(0,2),o=r.length-n.length;return c`<div class="bundle-issue-reports">${n.map(s=>{let i=X[Ye(s)]??X.default;return c`<button type="button" class="report-chip" title="${s}" data-bundle-issue-report="${s}">${me(i)}<span class="report-chip-label">${Me(s)}</span></button>`})} ${o>0?c`<span class="bundle-issue-reports-more">, and ${o} more…</span>`:g}</div>`}function Zf(e){if(e==null||e==="")return"";let t=String(e),r=t.indexOf("-");if(r>0){let o=parseInt(t.slice(0,r),10),s=parseInt(t.slice(r+1),10);return Number.isFinite(o)&&Number.isFinite(s)&&s>o?`Lines ${o}-${s}`:Number.isFinite(o)?`Line ${o}`:""}let n=parseInt(t,10);return Number.isFinite(n)?`Line ${n}`:""}function ev(e){if(!e||!e.json&&!e.bundle)return g;if(!e.fileHashes)return c`<div class="bundle-issues-empty">Computing file hashes…</div>`;let t=hn(e.fileHashes,"issues");return t.size===0?c`<div class="bundle-issues-empty">No issues match this bundle's files.</div>`:ko(t,{kind:"bundle"})}function ko(e,{kind:t,bucketKey:r}={}){let n=[...e.keys()],{prefix:o,stripped:s}=Xe(n),i=new Map(n.map((u,p)=>[u,s[p]])),l=[...e.entries()].toSorted(([u,p],[f,h])=>{let b=Je[ci(p)]??0,m=Je[ci(h)]??0;return m!==b?m-b:(i.get(u)??u).localeCompare(i.get(f)??f)}),d=[...e.values()].reduce((u,p)=>u+p.length,0);return c`<div class="bundle-issues"><div class="bundle-issues-summary">${d} ${d===1?"issue":"issues"} across ${e.size} ${e.size===1?"file":"files"} ${o?c`<span class="mono">${o}</span>`:g}</div><ul class="bundle-issues-list">${G(l,([u])=>u,([u,p])=>{let f=i.get(u)??u,h=[...p].toSorted((m,y)=>{let k=Je[m.severity]??0,w=Je[y.severity]??0;if(w!==k)return w-k;let v=parseInt(m.line,10)||0,$=parseInt(y.line,10)||0;return v-$}),b=t==="repository"&&r?`${/^https?:/iu.test(r)?r.replace(/\/$/u,""):`https://github.com/${r}`}/blob/HEAD/${u}`:null;return c`<li class="bundle-issues-file-group"><header class="bundle-issues-file-header">${t==="bundle"?c`<button type="button" class="bundle-issues-file-name mono" data-bundle-view-source="${u}" title="${u}">${f}</button>`:b?c`<a class="bundle-issues-file-name bundle-issues-file-name-link mono" href="${b}" target="_blank" rel="noopener" title="${u}">${f}</a>`:c`<span class="bundle-issues-file-name bundle-issues-file-name-static mono" title="${u}">${f}</span>`} <span class="bundle-issues-file-count">${p.length} ${p.length===1?"issue":"issues"}</span></header><ul class="bundle-issues-findings">${G(h,m=>m.id??`${u}\0${m.line??""}\0${m.severity??""}\0${m.description??""}`,m=>{let y=p.indexOf(m),k=m.severity,w=a.triage.get(O(m))?.triage,v=w==="fixed"||w==="invalid"||w==="deleted"?w.toUpperCase():w==="inprogress"?"In progress":null,$=c`<div class="bundle-issues-finding-head"><span class="${`bundle-issue-sev sev-${k}`}">${k.replaceAll("_"," ")}</span> ${(()=>{let R=Zf(m.line);return R?c`<span class="bundle-issues-finding-line">${R}</span>`:g})()} ${v?c`<span class="${`bundle-issues-finding-triage triage-${w}`}">${v}</span>`:g} <span class="bundle-issues-finding-spacer"></span> ${Zw(m,{kind:t,bucketKey:r})}</div><div class="bundle-issues-finding-desc">${m.description??""}</div>`;return c`<li class="bundle-issues-finding">${t==="bundle"?c`<button type="button" class="bundle-issues-finding-link" data-bundle-view-source="${u}" data-bundle-view-finding-idx="${y}" data-bundle-view-line="${m.line??""}" title="${u}">${$}</button>`:c`<div class="bundle-issues-finding-link bundle-issues-finding-static" title="${u}">${$}</div>`}</li>`})}</ul></li>`})}</ul></div>`}function eh(e){let t=a.selectedBundle,r=t?e.find(n=>n.integrity===t):null;return r?Qw(r):c`<div class="bundles-view bundles-view-empty"><p class="bundles-empty-hint">${e.length===0?"No bundles yet. Drop a `.map` sourcemap or a `.stasis.code.br` bundle to start.":"Pick a bundle from the sidebar to open it."}</p></div>`}function tv(e,t){let r=c`<dl class="bundles-detail-meta"><dt>Name</dt><dd>${e.name}</dd><dt>Integrity</dt><dd class="mono">${e.integrity}</dd>${t&&t.integrity===e.integrity?c`<dt>Size</dt><dd>${ne(t.size)}</dd>`:g}</dl>`;if(!t||t.integrity!==e.integrity)return c`<div class="bundles-overview"><div class="bundles-overview-summary">${r}</div></div>`;if(t.error)return c`<div class="bundles-overview"><div class="bundles-overview-summary">${r}</div><div class="bundles-overview-placeholder is-error">Failed to parse: ${t.error}</div></div>`;if(t.kind==="sourcemap"&&t.json){let n=t.json,o=n.sources??[],s=n.sourcesContent??[],i=o.map((d,u)=>typeof s[u]=="string"?new TextEncoder().encode(s[u]).byteLength:null),l=c`<dt>Version</dt><dd>${String(n.version??"?")}</dd>${n.file?c`<dt>Output</dt><dd class="mono">${n.file}</dd>`:g} ${n.sourceRoot?c`<dt>Source root</dt><dd class="mono">${n.sourceRoot}</dd>`:g} ${n.names?c`<dt>Names</dt><dd>${n.names.length}</dd>`:g}`;return jf(r,l,o,i)}if(t.kind==="stasis"&&t.bundle){let n=t.bundle,o=n.sources,s=[...o.keys()],i=new Set;for(let p of n.imports.keys()){let f=p.replace(/\s*\(with: .*\)\s*$/u,"");for(let h of f.split(", "))i.add(h)}let l=[...i].toSorted(),d=s.map(p=>{let f=o.get(p);return typeof f=="string"?new TextEncoder().encode(f).byteLength:null}),u=c`<dt>Version</dt><dd>${String(n.version)}</dd>${l.length>0?c`<dt>Resolution kinds</dt><dd>${l.join(", ")}</dd>`:g}`;return jf(r,u,s,d)}return c`<div class="bundles-overview"><div class="bundles-overview-summary">${r}</div><div class="bundles-overview-placeholder">Bundle contents not parsed.</div></div>`}function th(){$t().catch(()=>{});let e=kt(),t={inprogress:0,fixed:0,invalid:0,deleted:0},r=[];for(let[h,b]of e){let m=[],y=[],k=new Map,w=new Set;for(let[v,$]of b.byVersion){let R=[],F=new Map;for(let B of $.findings){let te=a.triage.get(O(B))?.triage??null;te==="inprogress"?t.inprogress++:te==="fixed"?t.fixed++:te==="invalid"?t.invalid++:te==="deleted"&&t.deleted++,te===a.shownTriage&&(R.push(B),F.has(B.file)||F.set(B.file,[]),F.get(B.file).push(B))}if(R.length!==0){m.push([v,{findings:R,files:F,reports:$.reports}]);for(let B of R)y.push(B),k.has(B.file)||k.set(B.file,[]),k.get(B.file).push(B);for(let B of $.reports)w.add(B)}}m.length!==0&&(m.sort(([v],[$])=>Ki(v,$)),r.push([h,{findings:y,files:k,reports:w,versions:m}]))}let n=a.selectedPackage,o=n?r.find(([h])=>h===n)??null:null,s=null;if(o){let h=o[1].versions,b=a.selectedPackageVersion;s=h.find(([m])=>m===b)??null,!s&&h.length===1&&(s=h[0])}let i=s?s[1]:o?o[1]:null;if(o&&a.packageDetailsTab==="issues")return lv(o[0],i,s?s[0]:void 0);let l=a.packagesSearchQuery.trim().toLowerCase(),d=l?r.filter(([h])=>h.toLowerCase().includes(l)):r.slice();iv(d,a.packagesSortBy);let u=r.reduce((h,[,b])=>h+b.findings.length,0),p=new Set;for(let[,h]of r)for(let b of h.reports)p.add(b);let f=o?"packages-layout open":"packages-layout";return c`<div class="${A({"packages-view":!0,"with-details":!!o})}"><header class="page-head"><div class="page-title"><h1>Packages</h1><div class="meta-row"><span>${d.length===r.length?c`${r.length} ${r.length===1?"package":"packages"}`:c`${d.length} of ${r.length} ${r.length===1?"package":"packages"}`}</span> ${u>0?c`<span>${u} ${u===1?"finding":"findings"} across ${p.size} ${p.size===1?"report":"reports"}</span>`:g}</div></div>${ov(t)}</header>${r.length===0?c`<p style="color:var(--muted)">${e.size===0?"Indexing reports\u2026 this view populates as the OPFS scan finishes.":a.shownTriage?`No ${a.shownTriage} findings in any package.`:"No untriaged findings in any package."}</p>`:d.length===0?c`<p style="color:var(--muted)">No packages match "${a.packagesSearchQuery}".</p>`:c`<div class="${f}"><ul class="packages-list">${G(rv(d),nv,h=>cv(h,n,a.selectedPackageVersion))}</ul>${o?c`<aside class="packages-details" id="packages-details"><header class="packages-details-bar"><span class="packages-details-label">Details</span> <button type="button" class="packages-details-close" data-deselect-package title="Close details" aria-label="Close details">×</button></header><div class="packages-details-body">${pv(o[0],i,s?s[0]:void 0)}</div></aside>`:g}</div>`}</div>`}function rv(e){let t=[];for(let[r,n]of e){let o=n.versions;if(o.length<=1){let[d,u]=o[0];t.push({kind:"single",pkg:r,version:d,bucket:u,totalVersions:1});continue}let[s,i]=o[0],l=a.expandedPackages.has(r);if(t.push({kind:"latest",pkg:r,version:s,bucket:i,totalVersions:o.length,expanded:l}),l)for(let d=1;d<o.length;d++){let[u,p]=o[d];t.push({kind:"other",pkg:r,version:u,bucket:p,totalVersions:o.length})}}return t}function nv(e){return e.version===null?`${e.kind}:${e.pkg}`:`${e.kind}:${e.pkg}@${e.version}`}function ov(e){return c`<div class="packages-toolbar"><entity-search kind="packages"></entity-search><entity-sort kind="packages"></entity-sort><triage-selector variant="packages" .counts="${e}" .states="${sv}"></triage-selector></div>`}var sv=["inprogress","fixed","invalid","deleted"];function iv(e,t){let r=t==="name-asc"?(n,o)=>n[0].localeCompare(o[0]):t==="files-desc"?(n,o)=>o[1].files.size-n[1].files.size||n[0].localeCompare(o[0]):t==="reports-desc"?(n,o)=>o[1].reports.size-n[1].reports.size||n[0].localeCompare(o[0]):(n,o)=>o[1].findings.length-n[1].findings.length||n[0].localeCompare(o[0]);e.sort(r)}function av(e,t){let r={live:0,invalid:0,deleted:0};if(!e)return r;let n=t===void 0?e.files.values():e.byVersion.get(t)?.files.values()??[].values();for(let o of n)for(let s of o){let i=a.triage.get(O(s))?.triage??null;i==="invalid"?r.invalid++:i==="deleted"?r.deleted++:r.live++}return r}function lv(e,t,r){let n=kt().get(e),o=av(n,r),s=a.packageSlideTriage??"live",i=n?rh(n,e,s,r):new Map,l=[...i.values()].reduce((f,h)=>f+h.length,0),d=s==="live"?l===1?"issue":"issues":l===1?`${s} issue`:`${s} issues`,u=s==="live"?"No live issues for this package.":`No ${s} issues for this package.`,p=typeof r=="string"?` @ ${r}`:"";return c`<div class="packages-view packages-slide-view"><header class="bundles-slide-bar"><button type="button" class="bundles-slide-back" data-action="package-slide-back" title="Back to packages" aria-label="Back to packages">← Back</button><div class="bundles-slide-title"><div class="bundles-slide-name">${e}${p}</div><div class="bundles-slide-integrity">${l} ${d} · ${t.files.size} ${t.files.size===1?"file":"files"} · ${t.reports.size} ${t.reports.size===1?"report":"reports"}</div></div><slide-triage-tabs kind="package" .counts="${o}"></slide-triage-tabs></header><div class="bundles-slide-body">${i.size===0?c`<div class="bundle-issues-empty">${u}</div>`:ko(i,{kind:"package",bucketKey:e})}</div></div>`}function cv(e,t,r){let{kind:n,pkg:o,version:s,bucket:i}=e,l={critical:0,high:0,medium:0,low:0,high_bug:0,bug:0,informational:0};for(let m of i.findings)l[m.severity]!==void 0&&l[m.severity]++;let d=ke.filter(m=>l[m]>0),u=ht(o),f={selected:o===t&&dv(e,r),"packages-row-latest":n==="latest","packages-row-other":n==="other"},h=s===null?"":s,b=s===null?`Open issues for ${o}`:`Open issues for ${o}@${s}`;return c`<li class="${A(f)}" data-select-package="${o}" data-select-package-version="${h}"><span class="packages-dot" style="${ue({background:u})}"></span><div class="packages-row-text"><div class="packages-name-line"><span class="packages-name">${o}${s===null?g:c`<span class="packages-version">@${s}</span>`} </span>${n==="latest"?uv(o,e.expanded,e.totalVersions-1):g}</div><span class="packages-row-meta">${i.findings.length} ${i.findings.length===1?"finding":"findings"} · ${i.files.size} ${i.files.size===1?"file":"files"} · ${i.reports.size} ${i.reports.size===1?"report":"reports"}</span></div>${d.length>0?c`<div class="packages-row-chips">${d.map(m=>c`<span class="${`tree-count-chip ${m}`}" title="${m.replaceAll("_"," ")}">${l[m]}</span>`)}</div>`:g} <button type="button" class="packages-row-issues" data-package-row-issues="${o}" data-package-row-issues-version="${h}" aria-label="${b}">Issues →</button></li>`}function dv(e,t){return e.kind==="single"?!0:e.version===t}function uv(e,t,r){let n=t?"Hide":`+${r} ${r===1?"version":"versions"}`;return c`<button type="button" class="${A({"packages-row-expand":!0,expanded:t})}" data-package-expand="${e}" aria-expanded="${String(t)}" aria-label="${t?`Hide older versions of ${e}`:`Show older versions of ${e}`}" title="${t?"Hide older versions":`Show older versions (${r})`}"><span class="packages-row-expand-chevron" aria-hidden="true"></span> <span class="packages-row-expand-label">${n}</span></button>`}function pv(e,t,r){let n=kt().get(e),s=[...(n?rh(n,e,"live",r):new Map).values()].reduce((i,l)=>i+l.length,0);return c`<div class="bundles-tabs" role="tablist"><button type="button" class="bundles-tab active" data-package-tab="overview" aria-selected="true" role="tab">Overview</button> <span class="bundles-tabs-spacer"></span> ${s>0?c`<button type="button" class="bundles-tab bundles-tab-action" data-package-tab="issues">Issues (${s}) →</button>`:g}</div>${fv(e,t,r)}`}function rh(e,t,r="live",n){let o=new Map,s=n===void 0?e.files:e.byVersion.get(n)?.files??new Map;for(let[i,l]of s){let d=l.filter(f=>{let h=a.triage.get(O(f))?.triage??null;return r==="invalid"?h==="invalid":r==="deleted"?h==="deleted":h!=="invalid"&&h!=="deleted"});if(d.length===0)continue;let u=nh(t,i);o.has(u)||o.set(u,[]);let p=o.get(u);for(let f of d)p.push(f)}return o}function fv(e,t,r){let n={critical:0,high:0,medium:0,low:0,high_bug:0,bug:0,informational:0};for(let f of t.findings)n[f.severity]!==void 0&&n[f.severity]++;let o=ke.filter(f=>n[f]>0),s=[...t.files.entries()].toSorted(([f,h],[b,m])=>m.length!==h.length?m.length-h.length:f.localeCompare(b)),i=[...t.reports].toSorted((f,h)=>f.localeCompare(h)),d=kt().get(e)?.repos,u=d&&d.size===1?[...d][0]:null,p=u?/^https?:/iu.test(u)?u:`https://github.com/${u}`:null;return c`<dl class="packages-detail-meta"><dt>Package</dt><dd class="mono">${e}</dd>${r?c`<dt>Version</dt><dd class="mono">${r}</dd>`:g} ${p?c`<dt>Repository</dt><dd class="mono"><a href="${p}" target="_blank" rel="noopener">${u}</a></dd>`:g}<dt>Findings</dt><dd>${t.findings.length}</dd><dt>Files</dt><dd>${t.files.size}</dd><dt>Reports</dt><dd>${t.reports.size}</dd></dl>${o.length>0?c`<div class="packages-detail-chips">${o.map(f=>c`<span class="${`tree-count-chip ${f}`}">${n[f]} ${f.replaceAll("_"," ")}</span>`)}</div>`:g}<h3 class="packages-detail-section">Reports</h3><ul class="packages-detail-reports">${i.map(f=>{let h=X[Ye(f)]??X.default;return c`<li><button type="button" class="packages-detail-report" title="${f}" data-package-report="${f}">${me(h)}<span class="packages-detail-report-label">${Me(f)}</span></button></li>`})}</ul><h3 class="packages-detail-section">Files</h3><ul class="packages-detail-files">${s.map(([f,h])=>{let b=nh(e,f);return c`<li class="packages-detail-file"><span class="packages-detail-file-path mono" title="${f}">${b}</span> <span class="packages-detail-file-count">${h.length}</span></li>`})}</ul>`}function nh(e,t){for(let r of["node_modules","dependencies"]){let n=`${r}/${e}/`,o=t.indexOf(n);if(o>=0)return t.slice(o+n.length)}return t.startsWith(`${e}/`)?t.slice(e.length+1):t}function it(e){if(!e)return"";let t=e.match(/github\.com\/([^/?#]+\/[^/?#]+?)(?:\.git)?(?:[/?#]|$)/iu);return t?t[1]:e}function oh(){$t().catch(()=>{});let e=wr(),t={inprogress:0,fixed:0,invalid:0,deleted:0},r=[];for(let[p,f]of e){let h=[],b=new Map;for(let m of f.findings){let y=a.triage.get(O(m))?.triage??null;y==="inprogress"?t.inprogress++:y==="fixed"?t.fixed++:y==="invalid"?t.invalid++:y==="deleted"&&t.deleted++,y===a.shownTriage&&(h.push(m),b.has(m.file)||b.set(m.file,[]),b.get(m.file).push(m))}h.length>0&&r.push([p,{findings:h,files:b,reports:f.reports}])}let n=a.selectedRepository,o=n?r.find(([p])=>p===n)??null:null;if(o&&a.repositoryDetailsTab==="issues")return yv(o[0],o[1]);let s=a.repositoriesSearchQuery.trim().toLowerCase(),i=s?r.filter(([p])=>p.toLowerCase().includes(s)||it(p).toLowerCase().includes(s)):r.slice();mv(i,a.repositoriesSortBy);let l=r.reduce((p,[,f])=>p+f.findings.length,0),d=new Set;for(let[,p]of r)for(let f of p.reports)d.add(f);let u=o?"packages-layout open":"packages-layout";return c`<div class="${A({"packages-view":!0,"with-details":!!o})}"><header class="page-head"><div class="page-title"><h1>Repositories</h1><div class="meta-row"><span>${i.length===r.length?c`${r.length} ${r.length===1?"repository":"repositories"}`:c`${i.length} of ${r.length} ${r.length===1?"repository":"repositories"}`}</span> ${l>0?c`<span>${l} ${l===1?"finding":"findings"} across ${d.size} ${d.size===1?"report":"reports"}</span>`:g}</div></div>${hv(t)}</header>${r.length===0?c`<p style="color:var(--muted)">${e.size===0?"Indexing reports\u2026 this view populates as the OPFS scan finishes.":a.shownTriage?`No ${a.shownTriage} findings in any repository.`:"No untriaged findings in any repository."}</p>`:i.length===0?c`<p style="color:var(--muted)">No repositories match "${a.repositoriesSearchQuery}".</p>`:c`<div class="${u}"><ul class="packages-list">${G(i,([p])=>p,([p,f])=>wv(p,f,p===n))}</ul>${o?c`<aside class="packages-details" id="repositories-details"><header class="packages-details-bar"><span class="packages-details-label">Details</span> <button type="button" class="packages-details-close" data-deselect-repository title="Close details" aria-label="Close details">×</button></header><div class="packages-details-body">${vv(o[0],o[1])}</div></aside>`:g}</div>`}</div>`}function hv(e){return c`<div class="packages-toolbar"><entity-search kind="repositories"></entity-search><entity-sort kind="repositories"></entity-sort><triage-selector variant="packages" .counts="${e}" .states="${gv}"></triage-selector></div>`}var gv=["inprogress","fixed","invalid","deleted"];function mv(e,t){let r=t==="name-asc"?(n,o)=>it(n[0]).localeCompare(it(o[0])):t==="files-desc"?(n,o)=>o[1].files.size-n[1].files.size||it(n[0]).localeCompare(it(o[0])):t==="reports-desc"?(n,o)=>o[1].reports.size-n[1].reports.size||it(n[0]).localeCompare(it(o[0])):(n,o)=>o[1].findings.length-n[1].findings.length||it(n[0]).localeCompare(it(o[0]));e.sort(r)}function bv(e){let t={live:0,invalid:0,deleted:0};if(!e)return t;for(let r of e.files.values())for(let n of r){let o=a.triage.get(O(n))?.triage??null;o==="invalid"?t.invalid++:o==="deleted"?t.deleted++:t.live++}return t}function yv(e,t){let r=wr().get(e),n=bv(r),o=a.repositorySlideTriage??"live",s=r?sh(r,o):new Map,i=[...s.values()].reduce((u,p)=>u+p.length,0),l=o==="live"?i===1?"issue":"issues":i===1?`${o} issue`:`${o} issues`,d=o==="live"?"No live issues for this repository.":`No ${o} issues for this repository.`;return c`<div class="packages-view packages-slide-view"><header class="bundles-slide-bar"><button type="button" class="bundles-slide-back" data-action="repository-slide-back" title="Back to repositories" aria-label="Back to repositories">← Back</button><div class="bundles-slide-title"><div class="bundles-slide-name">${it(e)}</div><div class="bundles-slide-integrity">${i} ${l} · ${t.files.size} ${t.files.size===1?"file":"files"} · ${t.reports.size} ${t.reports.size===1?"report":"reports"}</div></div><slide-triage-tabs kind="repository" .counts="${n}"></slide-triage-tabs></header><div class="bundles-slide-body">${s.size===0?c`<div class="bundle-issues-empty">${d}</div>`:ko(s,{kind:"repository",bucketKey:e})}</div></div>`}function wv(e,t,r){let n={critical:0,high:0,medium:0,low:0,high_bug:0,bug:0,informational:0};for(let l of t.findings)n[l.severity]!==void 0&&n[l.severity]++;let o=ke.filter(l=>n[l]>0),s=ht(e),i=it(e);return c`<li class="${r?"selected":""}" data-select-repository="${e}"><span class="packages-dot" style="${ue({background:s})}"></span><div class="packages-row-text"><span class="packages-name">${i}</span> <span class="packages-row-meta">${t.findings.length} ${t.findings.length===1?"finding":"findings"} · ${t.files.size} ${t.files.size===1?"file":"files"} · ${t.reports.size} ${t.reports.size===1?"report":"reports"}</span></div>${o.length>0?c`<div class="packages-row-chips">${o.map(l=>c`<span class="${`tree-count-chip ${l}`}" title="${l.replaceAll("_"," ")}">${n[l]}</span>`)}</div>`:g} <button type="button" class="packages-row-issues" data-repository-row-issues="${e}" aria-label="${`Open issues for ${i}`}">Issues →</button></li>`}function vv(e,t){let r=wr().get(e),o=[...(r?sh(r):new Map).values()].reduce((s,i)=>s+i.length,0);return c`<div class="bundles-tabs" role="tablist"><button type="button" class="bundles-tab active" data-repository-tab="overview" aria-selected="true" role="tab">Overview</button> <span class="bundles-tabs-spacer"></span> ${o>0?c`<button type="button" class="bundles-tab bundles-tab-action" data-repository-tab="issues">Issues (${o}) →</button>`:g}</div>${kv(e,t)}`}function sh(e,t="live"){let r=new Map;for(let[n,o]of e.files){let s=o.filter(i=>{let l=a.triage.get(O(i))?.triage??null;return t==="invalid"?l==="invalid":t==="deleted"?l==="deleted":l!=="invalid"&&l!=="deleted"});s.length>0&&r.set(n,s)}return r}function kv(e,t){let r={critical:0,high:0,medium:0,low:0,high_bug:0,bug:0,informational:0};for(let l of t.findings)r[l.severity]!==void 0&&r[l.severity]++;let n=ke.filter(l=>r[l]>0),o=[...t.files.entries()].toSorted(([l,d],[u,p])=>p.length!==d.length?p.length-d.length:l.localeCompare(u)),s=[...t.reports].toSorted((l,d)=>l.localeCompare(d)),i=/^https?:/iu.test(e)?e:`https://github.com/${e}`;return c`<dl class="packages-detail-meta"><dt>Repository</dt><dd class="mono"><a href="${i}" target="_blank" rel="noopener">${it(e)}</a></dd><dt>Findings</dt><dd>${t.findings.length}</dd><dt>Files</dt><dd>${t.files.size}</dd><dt>Reports</dt><dd>${t.reports.size}</dd></dl>${n.length>0?c`<div class="packages-detail-chips">${n.map(l=>c`<span class="${`tree-count-chip ${l}`}">${r[l]} ${l.replaceAll("_"," ")}</span>`)}</div>`:g}<h3 class="packages-detail-section">Reports</h3><ul class="packages-detail-reports">${s.map(l=>{let d=X[Ye(l)]??X.default;return c`<li><button type="button" class="packages-detail-report" title="${l}" data-package-report="${l}">${me(d)}<span class="packages-detail-report-label">${Me(l)}</span></button></li>`})}</ul><h3 class="packages-detail-section">Files</h3><ul class="packages-detail-files">${o.map(([l,d])=>c`<li class="packages-detail-file"><span class="packages-detail-file-path mono" title="${l}">${l}</span> <span class="packages-detail-file-count">${d.length}</span></li>`)}</ul>`}var $o=new Map,xo=new Map,oc=new Set;function $v(e,t,r){let n=`${e}\0${t}`;if(xo.has(n)||oc.has(n))return;let o=Qs(t);if(!o){xo.set(n,null);return}oc.add(n),(async()=>{let s=await Zs(r,o);xo.set(n,s??null),oc.delete(n),a.focusCodeTick++,queueMicrotask(x)})()}async function xv(e){let t=$o.get(e);if(t&&(t.loading||t.sources))return;let r=(a.bundles??[]).find(n=>n.integrity===e);if(r){$o.set(e,{sources:null,loading:!0,error:null});try{let n=await un(e,r),o=Ne(n);$o.set(e,{sources:o,loading:!1,error:n.error??null})}catch(n){$o.set(e,{sources:null,loading:!1,error:n.message})}a.focusCodeTick++,queueMicrotask(x),queueMicrotask(()=>{let n=C.querySelector(".focus-code-line-active");n&&n.scrollIntoView({block:"center",behavior:"instant"})})}}function ih(e){if(!e)return null;let t=Te(e);if(!t.fileHash||!Array.isArray(t._bundleHashes)||t._bundleHashes.length===0)return null;let r=new Set(t._bundleHashes),n=vr(t.fileHash).find(({integrity:u})=>r.has(u));if(!n)return null;let o=$o.get(n.integrity);if(!o)return xv(n.integrity),{loading:!0};if(o.loading)return{loading:!0};if(!o.sources)return null;let s=o.sources.get(n.file);if(typeof s!="string")return null;$v(n.integrity,n.file,s);let i=`${n.integrity}\0${n.file}`,l=xo.has(i)?xo.get(i):void 0,d=parseInt(t.line,10);return{content:s,file:n.file,integrity:n.integrity,line:Number.isFinite(d)?d:null,highlighted:l,loading:!1}}var sc=class extends I{static styles=[...I.styles,T(xe)];static properties={workspaceId:{type:String},items:{type:Array},_uploading:{state:!0},_errors:{state:!0},_done:{state:!0},_settled:{state:!0}};constructor(){super(),this.workspaceId="",this.items=[],this._uploading=!1,this._errors=[],this._done=!1,this._settled=!1}focusInitial(){this.renderRoot.querySelector('button[data-role="upload"]')?.focus()}_onClose=()=>this._finish({uploaded:[],failed:[]});_onCancel=()=>this._finish({uploaded:[],failed:[]});_onUpload=async()=>{if(this._uploading)return;this._uploading=!0,this._errors=[];let t=[],r=[];for(let n of this.items)try{let o;if(n.kind==="bundle")o=await Tp(this.workspaceId,n.identifier);else{let s=await mr(n.identifier);o=await Ps(this.workspaceId,n.identifier,s)}if(o.ok)t.push({kind:n.kind,identifier:n.identifier});else{let s=o.reason??"unknown";r.push({kind:n.kind,identifier:n.identifier,reason:s}),this._errors=[...this._errors,{label:Qe(n),reason:s}]}}catch(o){let s=o?.message??String(o);r.push({kind:n.kind,identifier:n.identifier,reason:s}),this._errors=[...this._errors,{label:Qe(n),reason:s}]}this._uploading=!1,this._done=!0,r.length===0&&this._finish({uploaded:t,failed:r})};_errorsSection(){return this._errors.length===0?g:c`<ul class="lwd-list" role="alert">${this._errors.map(t=>c`<li><strong>${t.label}</strong> — ${t.reason}</li>`)}</ul>`}render(){let t=this.items.length,r=t===1,n=this.items.filter(u=>u.kind==="report").length,o=t-n,s="items";o===0?s=r?"report":"reports":n===0&&(s=r?"bundle":"bundles");let i=r?c`Upload <strong>"${Qe(this.items[0])}"</strong> to the workspace's remote inventory?`:c`Upload <strong>${t}</strong> local ${s} to the workspace's remote inventory?`,l=r?g:c`<ul class="lwd-list">${this.items.map(u=>c`<li>${Qe(u)}${u.kind==="bundle"?c`<span class="lwd-kind-tag">bundle</span>`:g}</li>`)}</ul>`,d=this._uploading?r?"Uploading\u2026":`Uploading ${t} ${s}\u2026`:r?"Upload":`Upload ${t}`;return c`<dialog @close="${this._onClose}"><header><h3>Upload to remote</h3></header><p class="lwd-body">${i}</p>${l}<p class="nwd-note">End-to-end encrypted with the workspace key — only workspace members can decrypt the uploaded content.</p>${this._errorsSection()}<footer class="nwd-actions"><span class="nwd-spacer"></span> <button type="button" data-role="cancel" @click="${this._onCancel}" ?disabled="${this._uploading}">${this._done&&this._errors.length>0?"Close":"Cancel"}</button> ${this._done&&this._errors.length>0?g:c`<button type="button" data-role="upload" @click="${this._onUpload}" ?disabled="${this._uploading||t===0}">${d}</button>`}</footer></dialog>`}};customElements.define("sync-upload-dialog",sc);function ah({workspaceId:e,items:t}={}){return q("sync-upload-dialog",{workspaceId:e??"",items:Array.isArray(t)?[...t]:[]})}var ic=class extends I{static styles=[...I.styles,T(xe)];static properties={workspaceId:{type:String},items:{type:Array},_running:{state:!0},_errors:{state:!0},_done:{state:!0},_settled:{state:!0}};constructor(){super(),this.workspaceId="",this.items=[],this._running=!1,this._errors=[],this._done=!1,this._settled=!1}focusInitial(){this.renderRoot.querySelector('button[data-role="download"]')?.focus()}_onClose=()=>this._finish({downloaded:[],failed:[]});_onCancel=()=>this._finish({downloaded:[],failed:[]});_onDownload=async()=>{if(this._running)return;this._running=!0,this._errors=[];let t=[],r=[];for(let n of this.items)try{if(n.kind==="bundle"){let l=await Ap(this.workspaceId,n.identifier);if(!l.ok){let d=l.reason??"unknown";r.push({kind:"bundle",identifier:n.identifier,reason:d}),this._errors=[...this._errors,{label:Qe(n),reason:d}];continue}await kr(n.identifier,this.workspaceId),t.push({kind:"bundle",identifier:n.identifier});continue}let o=await Ep(this.workspaceId,n.identifier);if(!o){r.push({kind:"report",identifier:n.identifier,reason:"not found in remote"}),this._errors=[...this._errors,{label:Qe(n),reason:"not found in remote"}];continue}let s;try{s=he(await yt(o.content))}catch{let l="remote payload is not gzipped UTF-8";r.push({kind:"report",identifier:n.identifier,reason:l}),this._errors=[...this._errors,{label:Qe(n),reason:l}];continue}let i=ze(s);if(!i.recognized){let l="remote payload is not a recognized report format";r.push({kind:"report",identifier:n.identifier,reason:l}),this._errors=[...this._errors,{label:Qe(n),reason:l}];continue}await Nn(n.identifier,o.content),qe(n.identifier,i.count,i.source),await Ft(n.identifier,this.workspaceId),t.push({kind:"report",identifier:n.identifier})}catch(o){let s=o?.message??String(o);r.push({kind:n.kind,identifier:n.identifier,reason:s}),this._errors=[...this._errors,{label:Qe(n),reason:s}]}if(this._running=!1,this._done=!0,t.some(n=>n.kind==="report"))try{a.currentWorkspace===this.workspaceId&&await nr(this.workspaceId)}catch{}r.length===0&&this._finish({downloaded:t,failed:r})};_errorsSection(){return this._errors.length===0?g:c`<ul class="lwd-list" role="alert">${this._errors.map(t=>c`<li><strong>${t.label}</strong> — ${t.reason}</li>`)}</ul>`}render(){let t=this.items.length,r=t===1,n=this.items.filter(u=>u.kind==="report").length,o=t-n,s="items";o===0?s=r?"report":"reports":n===0&&(s=r?"bundle":"bundles");let i=r?c`Download <strong>"${Qe(this.items[0])}"</strong> from the workspace's remote inventory?`:c`Download <strong>${t}</strong> remote ${s} into this workspace?`,l=r?g:c`<ul class="lwd-list">${this.items.map(u=>c`<li>${Qe(u)}${u.kind==="bundle"?c`<span class="lwd-kind-tag">bundle</span>`:g}</li>`)}</ul>`,d=this._running?r?"Downloading\u2026":`Downloading ${t} ${s}\u2026`:r?"Download":`Download ${t}`;return c`<dialog @close="${this._onClose}"><header><h3>Download from remote</h3></header><p class="lwd-body">${i}</p>${l} ${this._errorsSection()}<footer class="nwd-actions"><span class="nwd-spacer"></span> <button type="button" data-role="cancel" @click="${this._onCancel}" ?disabled="${this._running}">${this._done&&this._errors.length>0?"Close":"Cancel"}</button> ${this._done&&this._errors.length>0?g:c`<button type="button" data-role="download" @click="${this._onDownload}" ?disabled="${this._running||t===0}">${d}</button>`}</footer></dialog>`}};customElements.define("sync-download-dialog",ic);function lh({workspaceId:e,items:t}={}){return q("sync-download-dialog",{workspaceId:e??"",items:Array.isArray(t)?[...t]:[]})}var ch=`.rec-list{margin:.2rem 0 .55rem;padding:0;list-style:none;max-height:320px;overflow-y:auto}.rec-row{display:flex;align-items:center;gap:.5rem;padding:.28rem .15rem;font-size:.8rem;line-height:1.4;border-bottom:1px solid rgb(from var(--text) r g b / .06)}.rec-row:last-child{border-bottom:none}.rec-label{flex:1 1 auto;min-width:0;color:var(--text);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.rec-status{flex:0 0 auto;padding:0 .4rem;border-radius:4px;font-size:.68rem;font-weight:600;text-transform:uppercase;letter-spacing:.04em}.rec-status-checking{color:var(--muted)}.rec-status-good{color:var(--ok, #16a34a)}.rec-status-reuploaded{color:var(--accent, #2563eb)}.rec-status-failed,.rec-status-check-failed{color:var(--warning, #d97706)}.rec-status-missing{color:var(--critical, #dc2626)}.rec-summary{margin:.1rem 0 .2rem;color:var(--muted);font-size:.76rem;line-height:1.45}.rec-error{margin:.3rem 0 .2rem;color:var(--critical, #f87171);font-size:.76rem;line-height:1.4}
52
- `;var Sv={checking:"checking\u2026",good:"available",reuploaded:"re-uploaded",failed:"re-upload failed","check-failed":"check failed",missing:"missing"},ac=class extends I{static styles=[...I.styles,T(xe),T(ch)];static properties={workspaceId:{type:String},cloudCount:{type:Number},localFileNames:{type:Array},localBundles:{type:Array},_rows:{state:!0},_running:{state:!0},_ran:{state:!0},_error:{state:!0},_settled:{state:!0}};constructor(){super(),this.workspaceId="",this.cloudCount=0,this.localFileNames=[],this.localBundles=[],this._rows=[],this._running=!1,this._ran=!1,this._error=null,this._settled=!1}focusInitial(){this.renderRoot.querySelector('button[data-role="recheck"]')?.focus()}_result(){return{items:this._rows,counts:this._counts()}}_onClose=()=>this._finish(this._ran?this._result():null);_onCancel=()=>this._finish(this._ran?this._result():null);_counts(){let t={good:0,reuploaded:0,failed:0,"check-failed":0,missing:0};for(let r of this._rows)r.status in t&&(t[r.status]+=1);return t}_onRecheck=async()=>{if(!this._running){this._running=!0,this._error=null,this._rows=[];try{let{items:t}=await Ip(this.workspaceId,{onList:r=>{this._rows=r},onItem:r=>{this._rows=this._rows.map(n=>n.resourceTag===r.resourceTag?r:n)}});this._rows=t}catch(t){this._error=t?.message??String(t)}finally{this._running=!1,this._ran=!0}}};_downloadableItems(){let t=new Set(this.localFileNames),r=new Set(this.localBundles),n=[];for(let o of this._rows)o.status!=="good"||!o.identifier||(o.kind==="report"&&!t.has(o.identifier)?n.push({kind:"report",identifier:o.identifier}):o.kind==="bundle"&&!r.has(o.identifier)&&n.push({kind:"bundle",identifier:o.identifier,label:o.label}));return n}_onDownload=async()=>{let t=this._downloadableItems();t.length!==0&&await lh({workspaceId:this.workspaceId,items:t})};_rowsSection(){return this._rows.length===0?this._running?c`<p class="lwd-body">Fetching remote listing…</p>`:g:c`<ul class="rec-list">${this._rows.map(t=>c`<li class="rec-row"><span class="rec-label">${t.label}${t.kind==="bundle"?c`<span class="lwd-kind-tag">bundle</span>`:g}</span> <span class="${`rec-status rec-status-${t.status}`}" title="${t.detail??g}">${Sv[t.status]??t.status}</span></li>`)}</ul>`}_summarySection(){if(!this._ran||this._rows.length===0)return g;let t=this._counts(),r=[];return t.good&&r.push(`${t.good} available`),t.reuploaded&&r.push(`${t.reuploaded} re-uploaded`),t.failed&&r.push(`${t.failed} failed`),t["check-failed"]&&r.push(`${t["check-failed"]} check failed`),t.missing&&r.push(`${t.missing} missing`),r.length>0?c`<p class="rec-summary" role="status" aria-live="polite">${r.join(" \xB7 ")}</p>`:g}render(){let t=this.cloudCount===1?"":"s",r=this._ran?g:c`<p class="lwd-body">Re-check ${this.cloudCount>0?c`the <strong>${this.cloudCount}</strong>`:g}remote object${t} for this workspace. Each is re-fetched from the relay; any whose bytes are missing are re-uploaded from a matching local copy.</p>`,n=this._ran&&this._rows.length===0&&!this._error?c`<p class="lwd-empty">No remote objects to check.</p>`:g,o=this._ran?this._downloadableItems().length:0;return c`<dialog @close="${this._onClose}"><header><h3>Re-check cloud storage</h3></header>${r} ${this._rowsSection()} ${n} ${this._summarySection()} ${this._error?c`<p class="rec-error" role="alert">${this._error}</p>`:g}<footer class="nwd-actions"><span class="nwd-spacer"></span> ${o>0?c`<button type="button" data-role="download" @click="${this._onDownload}" ?disabled="${this._running}">Download ${o} not stored locally</button>`:g} <button type="button" data-role="cancel" @click="${this._onCancel}" ?disabled="${this._running}">${this._ran?"Close":"Cancel"}</button> <button type="button" data-role="recheck" @click="${this._onRecheck}" ?disabled="${this._running}">${this._running?"Re-checking\u2026":this._ran?"Re-check again":"Re-check"}</button></footer></dialog>`}};customElements.define("objstore-recovery-dialog",ac);function dh({workspaceId:e,cloudCount:t,localFileNames:r,localBundles:n}={}){return q("objstore-recovery-dialog",{workspaceId:e??"",cloudCount:typeof t=="number"?t:0,localFileNames:Array.isArray(r)?[...r]:[],localBundles:Array.isArray(n)?[...n]:[]})}function cc(){let e=Ll(a.reports);if(!e)return null;let t=Object.keys(e),n=Pt().filter(p=>$e(p).commonTriage===a.shownTriage),o=Ml(n),s=Ys(e,o),i=new Map,l=new Map,d=new Map;for(let p of n)for(let f of p){i.has(f.file)||i.set(f.file,new Set),i.get(f.file).add(f.severity);let h=a.triage.get(O(f))?.color??"none";l.has(f.file)||l.set(f.file,new Set),l.get(f.file).add(h),d.has(f.file)||d.set(f.file,[]),d.get(f.file).push({severity:f.severity,color:h})}let u;return E.focusedPkg?(u=t.filter(p=>(hf(p)??"__own__")===E.focusedPkg),E.showAll||(u=u.filter(p=>Pl(p,o,s)))):u=E.showAll?t:t.filter(p=>Pl(p,o,s)),{prep:{treeData:e,files:u,ownCounts:o,transitiveCounts:s,severitySets:i,colorSets:l,fileFindings:d},findingCounts:o}}function dc(){let e=an();if(!e)return;let t=cc();t&&e.refreshSidebar(t.prep,{isBundleContext:a.currentView==="bundles"})}function uc(){let e=an();if(!e)return;let t=cc();t&&e.refreshTopPkgs(t.prep)}var Cv={"claude-security":"Claude Security findings","codex-security":"Codex Security findings",deepsec:"DeepSec findings"};function Ev(e,t){return a.currentWorkspace?t?c`<repo-chip url="${t}"></repo-chip>`:g:e?c`<repo-chip url="${a.repoUrl}" editable ?editing="${a.repoEditing}" ?empty="${!a.repoUrl}"></repo-chip>`:t?c`<repo-chip url="${t}"></repo-chip>`:g}var lc=["type","model","effort","exportsMode"];function uh(e,t,{typePrefix:r=!0}={}){return e==="type"?r?`analyzer: ${t??"null"}`:`${t??"null"}`:t??null}function Av(e,t=lc){let r=new Map;for(let f of e){let h={};for(let m of t)h[m]=m==="model"?Cl(f.model)??null:f[m]??null;let b=t.map(m=>h[m]??"").join("|");r.has(b)||r.set(b,h)}let n=[...r.values()];if(n.length===0)return[];let o={};for(let f of t)o[f]=new Set(n.map(h=>h[f])).size===1;let s=t.filter(f=>!o[f]),i=n.length>2&&s.includes("type")&&s.length>1,l=["model","effort"].filter(f=>t.includes(f)&&o[f]),d=[...l,...t.filter(f=>!l.includes(f))],u=[],p=!1;for(let f of d)if(o[f]){let h=uh(f,n[0][f]);h!=null&&u.push(h)}else if(!p){for(let h of n){let b=s.map(m=>uh(m,h[m],{typePrefix:!i})).filter(m=>m!=null);b.length>0&&u.push(b.join(" \xB7 "))}p=!0}return u}function Tv(e,t,r,n,o){let s=new Set(a.reports.map(z=>z.source)),i=s.size===1?[...s][0]:null,l=a.currentWorkspace?W().find(z=>z.id===a.currentWorkspace):null,d=l?`Workspace: ${l.name}`:i?Cv[i]:"Findings",u=i&&X[i]?i:"default",p=me(X[u]),f=c`<svg class="file-icon" viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M14 3H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"/><path d="M14 3v6h6"/></svg>`,h=g;t.length===1?h=c`<span class="file-chip" data-copy-report="${t[0]}" title="Copy report name">${p}<span>${t[0]}</span></span>`:t.length>1&&(h=c`<span class="file-chip" data-copy-report="${t.join(`
53
- `)}" title="Copy report names">${f}<span>${t.length} reports</span></span>`);let b=a.reports.flatMap(z=>z.groups.flat()),y=`${e} ${`finding${e===1?"":"s"}`}`,w=i||a.currentWorkspace?lc.filter(z=>z!=="type"):lc,v=Av(b,w),$=g;if(e>0){let z={};for(let _e of Pt()){let Ze=We(_e).severity;Ze&&(z[Ze]=(z[Ze]||0)+1)}let be=ke.filter(_e=>z[_e]>0);be.length>0&&($=c`<span class="status-bar" aria-hidden="true">${be.map(_e=>{let Ze=`${z[_e]} ${_e.replaceAll("_"," ")}`;return c`<span class="${`status-seg sev-${_e}`}" style="${ue({flexGrow:z[_e]})}" title="${Ze}"></span>`})}</span>`)}let R=Ev(r,n),F=c`<span class="sep" aria-hidden="true"></span>`,B=a.currentView==="files",te=(o??0)>1?c`<button type="button" class="${A({"files-toggle-btn":!0,active:B})}" data-action="toggle-files" title="${B?"exit files view":"show files"}" aria-pressed="${String(B)}">${`Files: ${o}`}</button>`:g;return c`<header class="page-head"><div class="page-title"><h1>${d}${h}${R}${te}${Iv()}</h1><div class="meta-row"><span>${y}</span> ${$} ${v.length>0?c`${F}${v.map(z=>c`<span class="tag">${z}</span>`)}`:g}</div></div></header>`}function Iv(){if(N.status!=="online")return g;if(a.currentView!=="findings"&&a.currentView!=="files")return g;let e=Fv();if(!e)return g;let{workspaceId:t,fileNames:r,mode:n}=e;if(n==="single"){let k=r[0],w=kl(t,k)?"cloud":"local";return Rv({status:w,label:w,title:w==="cloud"?"Synced to remote":"Local only \u2014 click to upload",onClick:w==="local"?()=>ph({workspaceId:t,items:[{kind:"report",identifier:k}]}):null})}let o=W().find(k=>k.id===t),s=o&&Array.isArray(o.bundles)?o.bundles:[],i=vp(t),l=r.filter(k=>!kl(t,k)),d=s.filter(k=>!yp(t,k)),u=[...l.map(k=>({kind:"report",identifier:k})),...d.map(k=>({kind:"bundle",identifier:k}))];if(i===0&&u.length===0)return g;let p=i>0,f=u.length>0,h=[i>0?`${i} in cloud`:null,u.length>0?`${u.length} local-only`:null,i>0?'click "cloud" to re-check storage':null,u.length>0?`click "local" to upload ${u.length}`:null].filter(Boolean).join(" \u2014 "),b=i===0?g:c`<button type="button" class="sync-badge-chunk cloud" aria-label="${`re-check ${i} cloud object${i===1?"":"s"}`}" @click="${k=>{k.stopPropagation(),dh({workspaceId:t,cloudCount:i,localFileNames:r,localBundles:s})}}">${yh()}<span>${i} cloud</span></button>`,m=u.length===0?g:c`<button type="button" class="sync-badge-chunk local" aria-label="${`${u.length} items not yet uploaded \u2014 open upload dialog`}" @click="${k=>{k.stopPropagation(),ph({workspaceId:t,items:u})}}">${bh()}<span>${u.length} local</span></button>`,y=i>0&&u.length>0?c`<span class="sync-badge-divider" aria-hidden="true"></span>`:g;return c`<div class="${`report-sync-badge${p||f?" report-sync-badge-clickable":""}`}" data-status="mixed" title="${h}">${b}${y}${m}</div>`}function Rv({status:e,label:t,title:r,onClick:n}){let o=e==="cloud"?yh():bh(),s=c`<span class="sync-badge-label">${t}</span>`;return typeof n!="function"?c`<span class="report-sync-badge" data-status="${e}" title="${r}" aria-label="${`report sync status: ${t}`}">${o}${s}</span>`:c`<button type="button" class="report-sync-badge report-sync-badge-clickable" data-status="${e}" title="${r}" aria-label="${`report sync status: ${t}`}" @click="${n}">${o}${s}</button>`}function bh(){return c`<svg class="sync-badge-icon" viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="2" y="14" width="20" height="8" rx="2" ry="2"/><line x1="6" y1="18" x2="6.01" y2="18"/><line x1="10" y1="18" x2="10.01" y2="18"/><path d="M6 14V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v10"/></svg>`}function yh(){return c`<svg class="sync-badge-icon" viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M17.5 19a4.5 4.5 0 1 0-1-8.9A6 6 0 0 0 5.07 13.5 4 4 0 0 0 6 21h11.5z"/></svg>`}async function ph({workspaceId:e,items:t}){let r=t.filter(n=>n.kind==="bundle");if(r.length>0){let n=await pt(),o=new Map(n.map(s=>[s.integrity,s.name]));for(let s of r){let i=o.get(s.identifier);i&&(s.label=i)}}await ah({workspaceId:e,items:t})}function Fv(){if(a.currentWorkspace)return{mode:"workspace",workspaceId:a.currentWorkspace,fileNames:a.reports.map(e=>e.fileName).filter(e=>typeof e=="string")};if(a.currentFile){let e=W().find(t=>Array.isArray(t.reports)&&t.reports.includes(a.currentFile));return e?{mode:"single",workspaceId:e.id,fileNames:[a.currentFile]}:null}return null}function Bv(e){return Object.values(e).some(r=>r>0)||a.filterSeverities.size>0?c`<severity-chips .counts="${e}"></severity-chips>`:g}function Mv(e){return Object.values(e).some(r=>r>0)||a.filterColors.size>0?c`<triage-filter .counts="${e}"></triage-filter>`:g}function Lv(e,t,r,n,o,s,i,l){let{showSource:d,showConfidence:u,showPriority:p,showGraphMode:f,showFileSort:h,kanbanMode:b,showRepo:m,hasComment:y,hasFix:k,hasFlagged:w}=s;return c`<div class="toolbar"><div class="toolbar-row"><view-mode-buttons modes="${f?"table,list,grouped,focus,kanban,graph":"table,list,grouped,focus,kanban"}"></view-mode-buttons><findings-sort ?show-file="${h}" ?show-confidence="${u}" ?show-priority="${p}"></findings-sort>${d?c`<div class="sep"></div><source-filter></source-filter>`:g} ${y||k||w||a.filterComment||a.filterFix||a.filterFlagged?c`<div class="sep"></div><annotation-filter .hasComment="${y}" .hasFix="${k}" .hasFlagged="${w}"></annotation-filter>`:g} ${u?c`<div class="sep"></div><conf-filter></conf-filter>`:g} ${b?g:c`<triage-selector .counts="${r}"></triage-selector>`}</div><div class="toolbar-row sev-row">${Bv(n)} ${i.length>1?c`<analyzer-select .options="${i}"></analyzer-select>`:g} ${m&&l.length>1?c`<repo-filter .options="${l}"></repo-filter>`:g} ${Mv(o)}<div class="search-row"><toolbar-search kind="findings"></toolbar-search><span class="result-count">${e} of ${t}</span></div></div></div>`}var _o=null,fh=0,sr=null,pi=new Map;function So(e,t=!1,r=null){let n=sn(e);return pi.set(n,{group:e,inGroup:t}),t?r?c`<finding-card data-gid="${n}" in-group context="${r}"></finding-card>`:c`<finding-card data-gid="${n}" in-group></finding-card>`:r?c`<finding-card data-gid="${n}" context="${r}"></finding-card>`:c`<finding-card data-gid="${n}"></finding-card>`}var Pv={critical:"C",high:"H",medium:"M",low:"L",high_bug:"H",bug:"B",informational:"i"};function hh(e,t={}){let{variant:r="kanban",active:n=!1}=t,o=$e(e),s=Te(e),i=qs(st(s.description,s))||"(untitled finding)",l=r==="kanban",d={"kanban-card":!0,"has-conflict":o.hasConflict,"focus-side-card":!l,active:n};!o.hasConflict&&o.commonColor&&(d[`mark-${o.commonColor}`]=!0);let u=parseInt(s.line,10),p=Number.isFinite(u)?`:${u}`:"",f=Pv[s.severity]??"?",h=a.triage.get(O(s))?.flagged===!0,b=c`<div class="kanban-badge-col"><span class="${`kanban-badge sev-${s.severity}`}" title="${on(s.severity)}" aria-label="${on(s.severity)}">${f}</span> ${h?c`<span class="kanban-flag" title="Flagged" aria-label="Flagged">${Bl}</span>`:g}</div><span class="kanban-title">${i}</span><div class="kanban-meta"><span class="kanban-loc">${s.file}${p}</span> ${s.confidence===void 0||s.confidence===null?g:c`<span class="kanban-conf" title="${`Confidence ${s.confidence}/10`}">${s.confidence}</span>`}</div>`;return l?c`<div class="${A(d)}" data-gid="${Ae(e)}" data-kanban-source draggable="true" role="button" tabindex="0" aria-current="${n?"true":"false"}" aria-label="${`Open details for ${i}`}">${b}</div>`:c`<div class="${A(d)}" data-gid="${Ae(e)}" data-focus-select role="button" tabindex="0" aria-current="${n?"true":"false"}" aria-label="${`Focus on ${i}`}">${b}</div>`}function Ov(e){let{content:t,line:r,highlighted:n}=e,o=t.split(`
54
- `).length,s=String(o).length;return c`<div class="focus-code-lines" style="${ue({"--lineno-width":`${s}ch`})}"><aside class="focus-code-gutter" aria-hidden="true">${Array.from({length:o},(i,l)=>{let d=l+1;return c`<div class="${A({"focus-code-lineno":!0,"focus-code-line-active":d===r})}" data-focus-code-line="${d}">${d}</div>`})}</aside><pre class="focus-code-source"><code>${typeof n=="string"?me(n):t}</code></pre></div>`}function Nv(e){if(!e)return g;let t=$e(e),r={"kanban-detail-modal":!0,"has-conflict":t.hasConflict};return!t.hasConflict&&t.commonColor&&(r[`mark-${t.commonColor}`]=!0),c`<div class="kanban-detail-backdrop"><div class="kanban-detail-dim"></div><div class="${A(r)}" role="dialog" aria-modal="true"><button type="button" class="kanban-detail-close" title="Close details" aria-label="Close details">×</button><div class="kanban-detail-body">${So(e,!1,"kanban-detail")}</div></div></div>`}function Dv(e){if(a.viewMode==="table"){let r=a.sortBy==="file"?[...e].toSorted((s,i)=>{let l=We(s),d=We(i);return l.file.localeCompare(d.file)||parseInt(l.line,10)-parseInt(d.line,10)}):e;if(r.length===0)return g;let n=a.tableSelectedGid?r.find(s=>Ae(s)===a.tableSelectedGid):null;return _o=r,c`<div class="${n?"findings-table-layout open":"findings-table-layout"}"><div class="findings-table-list"><div class="finding-table-slot"></div></div>${n?c`<aside class="findings-table-details" id="findings-table-details"><header class="findings-table-details-bar"><span class="findings-table-details-label">Details</span> <button type="button" class="findings-table-details-close" data-table-deselect title="Close details" aria-label="Close details">×</button></header><div class="findings-table-details-body">${So(n)}</div></aside>`:g}</div>`}if(a.viewMode==="focus"){if(e.length===0)return g;let r=a.focusGid?e.findIndex(d=>Ae(d)===a.focusGid):-1;r<0&&(r=Math.min(fh,e.length-1),r<0&&(r=0)),fh=r;let n=e[r];a.focusCodeTick;let o=ih(n),s=o?"focus-main with-code":"focus-main",i=r===0,l=r===e.length-1;return c`<div class="focus-view"><div class="${s}"><div class="focus-pane focus-pane-card"><div class="focus-card-wrapper">${So(n,!1,"focus")}</div></div>${o?c`<div class="focus-pane focus-pane-code">${o.loading?c`<div class="focus-code-empty">Loading source…</div>`:c`<header class="focus-code-bar" title="${o.file}"><span class="focus-code-file">${o.file}</span> ${o.line?c`<span class="focus-code-line">:${o.line}</span>`:g}</header><div class="focus-code-body">${Ov(o)}</div>`}</div>`:g}</div><aside class="focus-sidebar" aria-label="Up next"><div class="focus-sidebar-header"><span class="label">Up next</span><div class="focus-nav"><button type="button" class="focus-nav-btn" data-focus-nav="prev" ?disabled="${i}" title="Previous finding (←)" aria-label="Previous finding"><svg viewBox="0 0 16 16" width="12" height="12" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M10 3 5 8l5 5"/></svg></button> <span class="count">${r+1} / ${e.length}</span> <button type="button" class="focus-nav-btn" data-focus-nav="next" ?disabled="${l}" title="Next finding (→)" aria-label="Next finding"><svg viewBox="0 0 16 16" width="12" height="12" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M6 3 11 8l-5 5"/></svg></button></div></div><div class="focus-sidebar-body">${G(e,d=>Ae(d),d=>hh(d,{variant:"focus",active:Ae(d)===Ae(n)}))}</div></aside></div>`}if(a.viewMode==="kanban"){let r=[{key:"untriaged",label:"Untriaged",target:"untriaged"},{key:"inprogress",label:"In progress",target:"inprogress"},{key:"fixed",label:"Fixed",target:"fixed"},{key:"invalid",label:"Invalid",target:"invalid"},{key:"deleted",label:"Deleted",target:"deleted"},{key:"ignored",label:"Ignored",target:"ignored"}],n=new Map(r.map(s=>[s.key,[]]));for(let s of e){let l=$e(s).commonTriage??"untriaged",d=n.get(l);d&&d.push(s)}let o=a.kanbanPopoverGid?e.find(s=>Ae(s)===a.kanbanPopoverGid):null;return c`<div class="kanban-board">${G(r,s=>s.key,s=>{let i=n.get(s.key);return c`<div class="${`kanban-column kanban-column-${s.key}`}" data-kanban-target="${s.target}"><div class="kanban-column-header"><span class="label">${s.label}</span> <span class="count">${i.length}</span></div><div class="kanban-column-body">${i.length===0?c`<div class="kanban-empty">No ${s.label.toLowerCase()} findings.</div>`:G(i,l=>Ae(l),l=>hh(l,{active:Ae(l)===a.kanbanPopoverGid}))}</div></div>`})}</div>${Nv(o)}`}if(a.viewMode==="grouped"){let r=new Map;for(let o of e){let s=We(o).file;r.has(s)||r.set(s,[]),r.get(s).push(o)}let n=a.sortBy==="file"?[...r.keys()].toSorted():[...r.keys()];return c`${G(n,o=>o,o=>{let s=a.sortBy==="file"?r.get(o).toSorted((l,d)=>parseInt(We(l).line,10)-parseInt(We(d).line,10)):r.get(o),i=We(s[0]);return c`<div class="file-group"><div class="file-header"><span>${El(o,i?.repo?.github,i?._repoFallback??a.repoUrl)}</span> <span class="count">${s.length}</span></div><div class="file-body">${G(s,l=>sn(l),l=>So(l))}</div></div>`})}`}let t=a.sortBy==="file"?[...e].toSorted((r,n)=>{let o=We(r),s=We(n);return o.file.localeCompare(s.file)||parseInt(o.line,10)-parseInt(s.line,10)}):e;return c`${G(t,r=>sn(r),r=>{let n=Te(r),o=Hp(n.file,n.line,n.repo?.github,n._repoFallback??a.repoUrl),s=xr(n),i=$r(n),l=r.length>1;return c`<div class="${A({"flat-group":!0,"multi-case":l})}"><div class="flat-group-loc"><span class="file">${El(n.file,n.repo?.github,n._repoFallback??a.repoUrl)}</span> ${o===g?g:c`<span class="line-num">${o}</span>`} ${i?c`<span class="meta">${i}</span>`:g} ${s?c`<span class="run-meta">${s}</span>`:g}</div>${So(r,!0)}</div>`})}`}function Uv(){let e=document.querySelector("#bundle-source-overlay-slot");e&&K(Jf(),e)}var gh=null;function x(){let e=gh;if(gh=a.currentView,e!==null&&e!==a.currentView&&typeof document.startViewTransition=="function"&&!matchMedia("(prefers-reduced-motion: reduce)").matches){document.startViewTransition(()=>mh());return}mh()}function mh(){if(Uv(),Dp(a.reports),a.currentView==="bundles")if((a.bundles??[]).length===0)a.currentView="findings";else{let S=document.querySelector("#bundles-slot");if((!S||!C.contains(S)||C.firstElementChild!==S)&&(C.innerHTML='<div id="bundles-slot"></div>',S=document.querySelector("#bundles-slot")),S&&K(eh(a.bundles),S),a.selectedBundle&&a.bundleDetailsTab==="graph"&&a.bundleDetails&&(a.bundleDetails.json||a.bundleDetails.bundle)){let M=document.querySelector("#bundle-graph-slot");if(M){let re=qf(a.bundleDetails);if(re){Yf(re);let Re=!re.hasEdges,Ti=Gf(a.bundleDetails);Ol(M,re,{hideAllFiles:Re,triageCounts:Ti,triageStates:["inprogress","fixed","invalid","deleted"]},di,ui)}}}if(a.selectedBundle&&a.bundleDetailsTab==="terminal"&&a.bundleDetails&&(a.bundleDetails.json||a.bundleDetails.bundle)){let M=document.querySelector("#bundle-terminal-slot");M&&pf(M,a.bundleDetails)}C.classList.add("active"),Be.classList.add("hidden"),document.title="DeepView \u2014 bundles";return}if(a.currentView==="packages"){let S=document.querySelector("#packages-slot");(!S||!C.contains(S)||C.firstElementChild!==S)&&(C.innerHTML='<div id="packages-slot"></div>',S=document.querySelector("#packages-slot")),S&&K(th(),S),C.classList.add("active"),Be.classList.add("hidden"),document.title="DeepView \u2014 packages";return}if(a.currentView==="repositories"){let S=document.querySelector("#repositories-slot");(!S||!C.contains(S)||C.firstElementChild!==S)&&(C.innerHTML='<div id="repositories-slot"></div>',S=document.querySelector("#repositories-slot")),S&&K(oh(),S),C.classList.add("active"),Be.classList.add("hidden"),document.title="DeepView \u2014 repositories";return}if(a.reports.length===0)return;let e=Pt(),t={inprogress:0,fixed:0,invalid:0,deleted:0,ignored:0};for(let S of e){let M=$e(S).commonTriage;M&&t[M]++}let r=!1,n=!1,o=!1;for(let S of e)for(let M of S){let re=a.triage.get(O(M));re&&(re.comment&&(r=!0),re.fix&&(n=!0),re.flagged===!0&&(o=!0))}let s=a.viewMode==="kanban",i=s?e:e.filter(S=>$e(S).commonTriage===a.shownTriage),d=[...new Set(a.reports.map(S=>S.type))].join(", "),u=a.reports.map(S=>S.fileName),p={critical:0,high:0,medium:0,low:0,high_bug:0,bug:0,informational:0},f={red:0,blue:0,green:0,gray:0,none:0};for(let S of i){let M=new Set(S.map(Re=>Re.severity));for(let Re of M)p[Re]=(p[Re]||0)+1;let re=new Set(S.map(Re=>a.triage.get(O(Re))?.color??"none"));for(let Re of re)f[Re]=(f[Re]||0)+1}let h=i.length>0&&i.every(S=>S.every(M=>M.confidence!==void 0||M.critical===!0)),b=e.some(S=>S.some(M=>M.priority!==void 0)),m=e.some(S=>S.some(M=>er(M.file))),y=new Set;for(let S of e)for(let M of S)y.add(M.file);let k=y.size>1,w=e.some(S=>S.some(M=>!M.repo?.github&&!er(M.file))),v=new Set;for(let S of e)for(let M of S)!er(M.file)&&M.repo?.github&&v.add(M.repo.github);let $=v.size===1?[...v][0]:null,R=new Set;for(let S of e)for(let M of S)R.add(M._analyzer??null);let F=Object.keys(Rl),B=[...R].toSorted((S,M)=>{let re=S==null?1/0:F.indexOf(S)===-1?F.length:F.indexOf(S),Re=M==null?1/0:F.indexOf(M)===-1?F.length:F.indexOf(M);return re!==Re?re-Re:String(S??"").localeCompare(String(M??""))});if(a.filterAnalyzer){let S=a.filterAnalyzer===po?null:a.filterAnalyzer;R.has(S)||(a.filterAnalyzer="")}let te=new Set;for(let S of e)for(let M of S)te.add(Tl(M));let z=[...te].toSorted((S,M)=>S==null&&M==null?0:S==null?1:M==null?-1:S.localeCompare(M));if(a.filterRepo){let S=a.filterRepo===fo?null:a.filterRepo;te.has(S)||(a.filterRepo="")}!m&&a.filterSources.size>0&&a.filterSources.clear(),h||(a.filterConfMin=0,a.filterConfMax=10,(a.sortBy==="confidence-desc"||a.sortBy==="confidence-asc")&&(a.sortBy="severity")),!b&&(a.sortBy==="priority-desc"||a.sortBy==="priority-asc")&&(a.sortBy="severity"),!k&&a.sortBy==="file"&&(a.sortBy="severity");let be=Xp(Yp(i)),_e=Ll(a.reports),Ze=_e?Object.keys(_e).length:0,Nt=Ze>1;!Nt&&a.currentView==="files"&&(a.currentView="findings"),!Nt&&a.viewMode==="graph"&&(a.viewMode="table");let Rr=Tv(e.length,u,w,$,Ze);if(a.currentView==="files"){let S=Ml(e),M=document.querySelector("#header-slot"),re=document.querySelector("#tree-view-slot");(!M||!re||!C.contains(M)||!C.contains(re))&&(C.innerHTML='<div id="header-slot"></div><div id="tree-view-slot"></div>',M=document.querySelector("#header-slot"),re=document.querySelector("#tree-view-slot")),M&&K(Rr,M),re&&K(cf(_e,S),re),C.classList.add("active"),Be.classList.add("hidden"),document.title=`DeepView \u2014 ${d||"no analyzer"}`;return}let vd=a.viewMode==="table"&&a.tableSelectedGid&&be.some(S=>Ae(S)===a.tableSelectedGid),Dt=null;a.viewMode==="graph"&&_e&&(Dt=cc(),Dt||(a.viewMode="table"));let Ut=!!Dt,gt="findings-content";vd&&(gt+=" with-details"),Ut&&(gt+=" with-graph"),s&&(gt+=" with-kanban"),a.viewMode==="focus"&&(gt+=" with-focus");let _=g,V=g,Z=g;Ut||(_=Lv(be.length,i.length,t,p,f,{showSource:m,showConfidence:h,showPriority:b,showGraphMode:Nt,showFileSort:k,kanbanMode:s,showRepo:!!a.currentWorkspace,hasComment:r,hasFix:n,hasFlagged:o},B,z),a.shownTriage&&i.length===0?V=c`<p style="color:var(--muted);margin:1rem 0">No ${a.shownTriage} findings.</p>`:be.length===0&&i.length>0?V=c`<p style="color:var(--muted);margin:1rem 0">No findings match the current filters.</p>`:i.length===0&&(V=e.length>0?c`<p style="color:var(--green)">All ${d} issues triaged.</p>`:c`<p style="color:var(--green)">No ${d} issues found.</p>`),_o=null,pi.clear(),Z=Dv(be));let ce=!!(sr&&sr.isConnected);ce&&sr.remove();let ye=document.querySelector("#header-slot"),se=C.querySelector(":scope > .findings-content"),Ve=se&&se.querySelector(":scope > #findings-graph-slot"),et=se&&se.querySelector(":scope > #findings-body-slot"),jg=se&&(Ve?"graph":et?"body":null)===(Ut?"graph":"body");if(!ye||!se||!C.contains(ye)||!C.contains(se)||!jg){let S=Ut?'<div id="findings-graph-slot"></div>':'<div id="toolbar-slot"></div><div id="empty-state-slot"></div><div id="findings-body-slot"></div>';C.innerHTML=`<div id="header-slot"></div><div class="${gt}">${S}</div>`,ye=document.querySelector("#header-slot"),se=C.querySelector(":scope > .findings-content")}else se.className!==gt&&(se.className=gt);ye&&K(Rr,ye);let kd=document.querySelector("#toolbar-slot");kd&&K(_,kd);let $d=document.querySelector("#empty-state-slot");$d&&K(V,$d);let wn=document.querySelector("#findings-body-slot");if(wn&&(_o||ce)){let S=document.createElement("div");S.id="findings-body-slot",wn.replaceWith(S),wn=S}if(wn&&K(Z,wn),Dt){let S=document.querySelector("#findings-graph-slot");if(S){let M=c`<view-mode-buttons modes="table,list,grouped,focus,kanban,graph"></view-mode-buttons>`,re={inprogress:0,fixed:0,invalid:0,deleted:0,ignored:0};for(let Ti of Pt()){let Ii=$e(Ti).commonTriage;Ii&&re[Ii]++}let Re={extraTopRow:M,triageCounts:re,triageStates:["inprogress","fixed","invalid","deleted","ignored"]};Ol(S,Dt.prep,Re,dc,uc)}}if(_o){let S=C.querySelector(".finding-table-slot");S&&(sr||(sr=document.createElement("finding-table")),sr.items=_o,sr.selectedGid=a.tableSelectedGid,S.replaceWith(sr))}if(pi.size>0)for(let S of C.querySelectorAll("finding-card")){let M=pi.get(S.dataset.gid);M&&(S.group=M.group)}C.classList.add("active"),Be.classList.add("hidden"),document.title=`DeepView \u2014 ${d||"no analyzer"}`}var pc=class extends I{static styles=[...I.styles,T(ot)];static properties={workspace:{attribute:!1},_password:{state:!0},_confirm:{state:!0},_noPassword:{state:!0},_includeBundleBytes:{state:!0},_busy:{state:!0},_error:{state:!0},_settled:{state:!0}};constructor(){super(),this.workspace=null,this._password="",this._confirm="",this._noPassword=!1,this._includeBundleBytes=!1,this._busy=!1,this._error="",this._settled=!1}_finish(t){this._settled||(this._password="",this._confirm="",this.workspace=null,super._finish(t))}_onClose=()=>this._finish(null);_onCancel=()=>this._finish(null);_onPasswordInput=t=>{this._password=t.target.value,this._error=""};_onConfirmInput=t=>{this._confirm=t.target.value,this._error=""};_onNoPasswordToggle=t=>{this._noPassword=t.target.checked,this._error="",this._noPassword&&(this._password="",this._confirm="")};_onIncludeBundleBytesToggle=t=>{this._includeBundleBytes=t.target.checked,this._error=""};_canExport(){return this._busy?!1:this._noPassword?!0:(this._password??"").length>0&&this._password===this._confirm}_onExport=async()=>{if(this._canExport()){if(!this.workspace){this._error="No workspace selected.";return}this._busy=!0,this._error="";try{let{blob:t,filename:r}=await fl(this.workspace,{password:this._noPassword?void 0:this._password,includeBundleBytes:this._includeBundleBytes});if(this._settled)return;Pr(t,r),this._finish({ok:!0})}catch(t){if(this._settled)return;this._error=t?.message??String(t)}finally{this._busy=!1}}};_onKeydown=t=>{t.key==="Enter"&&(t.preventDefault(),this._onExport())};_body(){let t=!this._password||!this._confirm||this._password===this._confirm,r=Array.isArray(this.workspace?.bundles)?this.workspace.bundles.length:0;return c`<p class="nwd-note">The export file carries this workspace's reports, triage state, comments, fixes, references to attached bundles (integrities only by default), and its private key. Encrypting the file with a password ensures only those with the password can attach the workspace after download.</p><label class="wsl-field"><span>Password</span> <input type="password" class="nwd-input" autocomplete="off" data-1p-ignore="true" data-lpignore="true" data-bwignore="true" data-form-type="other" name="dv-export-pw" maxlength="1024" ?disabled="${this._noPassword}" .value="${this._password}" @input="${this._onPasswordInput}" @keydown="${this._onKeydown}"></label> <label class="wsl-field"><span>Confirm password</span> <input type="password" class="nwd-input" autocomplete="off" data-1p-ignore="true" data-lpignore="true" data-bwignore="true" data-form-type="other" name="dv-export-pw-confirm" maxlength="1024" ?disabled="${this._noPassword}" .value="${this._confirm}" @input="${this._onConfirmInput}" @keydown="${this._onKeydown}"></label> <label class="wsl-optout"><input type="checkbox" .checked="${this._noPassword}" @change="${this._onNoPasswordToggle}"> <span>Export without password (not recommended)</span></label> ${r>0?c`<label class="wsl-optout"><input type="checkbox" .checked="${this._includeBundleBytes}" @change="${this._onIncludeBundleBytesToggle}"> <span>Include bundle bytes (${r} bundle${r===1?"":"s"}; significantly larger file)</span></label>`:g} ${this._noPassword?c`<p class="wsl-error wsl-warning">Anyone who obtains this file can attach the workspace and read every report, triage decision, comment, and fix. Only opt out when you control where the file goes.</p>`:g} ${this._error?c`<p class="wsl-error" role="alert">${this._error}</p>`:g} ${!this._noPassword&&!t?c`<p class="wsl-error" role="alert">Passwords don't match.</p>`:g}<footer class="nwd-actions"><span class="nwd-spacer"></span> <button type="button" @click="${this._onCancel}">Cancel</button> <button type="button" class="primary" ?disabled="${!this._canExport()}" @click="${this._onExport}">${this._busy?"Exporting\u2026":this._noPassword?"Export without password":"Export"}</button></footer>`}render(){return c`<dialog @close="${this._onClose}"><header><h3>Export workspace</h3></header>${this._body()}</dialog>`}};customElements.define("workspace-export-dialog",pc);function wh({workspace:e}={}){return new Promise((t,r)=>{let n=document.createElement("workspace-export-dialog");n.workspace=e??null,n.addEventListener("resolve",o=>{n.remove(),t(o.detail)}),n.addEventListener("modal-conflict",o=>{n.workspace=null,n.remove(),r(bt(o.detail?.cause))}),document.body.append(n)})}async function vh(e){await wh({workspace:e})}var fc=class extends I{static properties={_value:{state:!0}};constructor(){super(),this._value=""}_onInput=t=>{this._value=t.target.value};_onCreate=()=>{let t=(this._value??"").trim();t&&this._finish(t)};_onCancel=()=>this._finish(null);_onKeydown=t=>{t.key==="Enter"&&(t.preventDefault(),this._onCreate())};render(){let t=(this._value??"").trim().length>0;return c`<dialog @close="${this._onClose}"><header><h3>New workspace</h3></header><input type="text" class="nwd-input" placeholder="Workspace name" maxlength="200" .value="${this._value}" @input="${this._onInput}" @keydown="${this._onKeydown}"><p class="nwd-note">Workspace triage is synchronized by default over an end-to-end encrypted channel. Triage on unattached reports stays local to this browser.</p><footer class="nwd-actions"><span class="nwd-spacer"></span> <button type="button" @click="${this._onCancel}">Cancel</button> <button type="button" class="primary" ?disabled="${!t}" @click="${this._onCreate}">Create</button></footer></dialog>`}};customElements.define("new-workspace-dialog",fc);function kh(){return q("new-workspace-dialog")}var hc=class extends I{static styles=[...I.styles,T(xe)];static properties={workspaceName:{type:String},reportCount:{type:Number},bundleCount:{type:Number},orphanedTriage:{type:Number},sharedTriage:{type:Number},_mode:{state:!0},_triage:{state:!0},_settled:{state:!0}};constructor(){super(),this.workspaceName="",this.reportCount=0,this.bundleCount=0,this.orphanedTriage=0,this.sharedTriage=0,this._mode="detach",this._triage="keep",this._settled=!1}focusInitial(){this.renderRoot.querySelector('button[data-role="cancel"]')?.focus()}_finish(t){if(this._settled)return;let r=this.reportCount>0?this._mode:"detach",n=r==="delete"&&this.orphanedTriage>0?this._triage:"keep";super._finish({confirmed:!!t,mode:r,triage:n})}_onClose=()=>this._finish(!1);_onCancel=()=>this._finish(!1);_onConfirm=()=>this._finish(!0);_onModeChange=t=>{this._mode=t.target.value};_onTriageChange=t=>{this._triage=t.target.value};_triageSection(){if(this._mode!=="delete"||this.reportCount===0)return"";let t=this.orphanedTriage,r=this.sharedTriage;return t===0&&r===0?c`<p class="lwd-note">No local triage is attached to ${this.reportCount===1?"this report":"these reports"}.</p>`:t===0?c`<p class="lwd-note">Local triage on ${this.reportCount===1?"this report":"these reports"} is also attached to ${r===1?"a report":"reports"} you're keeping. Nothing will be orphaned.</p>`:c`<fieldset class="lwd-choice"><legend><strong>${t}</strong> ${t===1?"triage entry won't":"triage entries won't"} be reachable from any remaining report. What should happen ${t===1?"to it":"to them"}?</legend><label class="lwd-option"><input type="radio" name="lwd-triage" value="keep" ?checked="${this._triage==="keep"}" @change="${this._onTriageChange}"> <span class="lwd-option-text"><span class="lwd-option-title">Keep</span> <span class="lwd-option-hint">Reapplied automatically if a matching report is imported later.</span></span></label> <label class="lwd-option"><input type="radio" name="lwd-triage" value="wipe" ?checked="${this._triage==="wipe"}" @change="${this._onTriageChange}"> <span class="lwd-option-text"><span class="lwd-option-title">Wipe</span> <span class="lwd-option-hint">Drop the orphaned triage from this browser.</span></span></label></fieldset>`}render(){let t=this.reportCount,r=this.bundleCount,n=t>0,o=t===1?"report":"reports",s=t===1?"it":"them",i=t===1?"stays":"stay",l=t===1?"is removed":"are removed",d=r>0?c`<p class="lwd-note">${r===1?"One bundle is":`${r} bundles are`} also attached. ${r===1?"It":"They"} will become unfiled — the bundle bytes stay on this device either way (delete bundles manually from the Bundles list if you want them gone).</p>`:"",u=n?c`<fieldset class="lwd-choice"><legend>What should happen to the <strong>${t}</strong> attached ${o}?</legend><label class="lwd-option"><input type="radio" name="lwd-mode" value="detach" ?checked="${this._mode==="detach"}" @change="${this._onModeChange}"> <span class="lwd-option-text"><span class="lwd-option-title">Move ${s} out of the workspace</span> <span class="lwd-option-hint">The ${o} ${i} in this browser as unattached ${o}.</span></span></label> <label class="lwd-option"><input type="radio" name="lwd-mode" value="delete" ?checked="${this._mode==="delete"}" @change="${this._onModeChange}"> <span class="lwd-option-text"><span class="lwd-option-title">Delete ${s} along with the workspace</span> <span class="lwd-option-hint">The ${o} ${l} from this browser.</span></span></label></fieldset>`:r>0?c`<p class="lwd-empty">No reports are attached to this workspace (only bundles, see below).</p>`:c`<p class="lwd-empty">No reports are attached to this workspace.</p>`;return c`<dialog @close="${this._onClose}"><header><h3>Leave workspace</h3></header><p class="lwd-body">Leave workspace <strong>"${this.workspaceName}"</strong> on this device?</p>${u} ${d} ${this._triageSection()}<ul class="lwd-list"><li>Workspace synchronization data stays on the sync server — peers (and your other devices) keep their copy.</li></ul><footer class="nwd-actions"><span class="nwd-spacer"></span> <button type="button" data-role="cancel" @click="${this._onCancel}">Cancel</button> <button type="button" class="danger" @click="${this._onConfirm}">Leave</button></footer></dialog>`}};customElements.define("leave-workspace-dialog",hc);function $h({name:e,reportCount:t,bundleCount:r,triageImpact:n}={}){return q("leave-workspace-dialog",{workspaceName:e??"",reportCount:t??0,bundleCount:r??0,orphanedTriage:n?.orphanedCount??0,sharedTriage:n?.sharedCount??0})}var gc=class extends I{static styles=[...I.styles,T(ot)];static properties={workspaceId:{type:String},initialName:{type:String},privateKeyBase64:{type:String},_name:{state:!0},_password:{state:!0},_confirm:{state:!0},_url:{state:!0},_busy:{state:!0},_error:{state:!0},_copied:{state:!0},_settled:{state:!0}};constructor(){super(),this.workspaceId="",this.initialName="",this.privateKeyBase64="",this._name="",this._password="",this._confirm="",this._url="",this._busy=!1,this._error="",this._copied=!1,this._settled=!1}beforeOpen(){this._name=this.initialName}focusInitial(){this.renderRoot.querySelector('input[data-role="name"]')?.focus()}_finish(){this._settled||(this._copiedTimer&&(clearTimeout(this._copiedTimer),this._copiedTimer=null),this._password="",this._confirm="",this._url="",this.privateKeyBase64="",super._finish(null))}_onClose=()=>this._finish();_onCancel=()=>this._finish();_onNameInput=t=>{this._name=t.target.value};_onPasswordInput=t=>{this._password=t.target.value,this._error=""};_onConfirmInput=t=>{this._confirm=t.target.value,this._error=""};_canGenerate(){return(this._name??"").trim().length>0&&(this._password??"").length>0&&this._password===this._confirm&&!this._busy}_onGenerate=async()=>{if(this._canGenerate()){this._busy=!0,this._error="";try{let t=await ml({id:this.workspaceId,name:this._name.trim(),privateKeyBase64:this.privateKeyBase64,password:this._password});if(this._settled)return;this._url=yl(t),this._password="",this._confirm=""}catch(t){if(this._settled)return;this._error=t?.message??String(t)}finally{this._busy=!1}}};_onCopy=async()=>{if(this._url){this._error="";try{if(await navigator.clipboard.writeText(this._url),this._settled)return;this._copied=!0,this._copiedTimer&&clearTimeout(this._copiedTimer),this._copiedTimer=setTimeout(()=>{this._copied=!1,this._copiedTimer=null},1500)}catch{if(this._settled)return;this._error="Copy failed \u2014 select the link and copy it manually."}}};_onKeydown=t=>{t.key==="Enter"&&!this._url&&(t.preventDefault(),this._onGenerate())};_body(){return this._url?c`<p class="nwd-note">Anyone with the link <strong>and</strong> the password can attach this workspace. Share them through separate channels.</p><label class="wsl-field"><span>Share link</span> <textarea class="wsl-link" readonly="readonly" rows="3" @focus="${t=>t.target.select()}">${this._url}</textarea></label> ${this._error?c`<p class="wsl-error" role="alert">${this._error}</p>`:g}<footer class="nwd-actions"><span class="nwd-spacer"></span> <button type="button" @click="${this._onCancel}">Close</button> <button type="button" class="primary" @click="${this._onCopy}">${this._copied?"Copied":"Copy link"}</button></footer>`:c`<label class="wsl-field"><span>Workspace name</span> <input type="text" class="nwd-input" data-role="name" placeholder="Workspace name" maxlength="200" .value="${this._name}" @input="${this._onNameInput}" @keydown="${this._onKeydown}"></label> <label class="wsl-field"><span>Password</span> <input type="password" class="nwd-input" autocomplete="off" data-1p-ignore="true" data-lpignore="true" data-bwignore="true" data-form-type="other" name="dv-share-link-pw" maxlength="1024" .value="${this._password}" @input="${this._onPasswordInput}" @keydown="${this._onKeydown}"></label> <label class="wsl-field"><span>Confirm password</span> <input type="password" class="nwd-input" autocomplete="off" data-1p-ignore="true" data-lpignore="true" data-bwignore="true" data-form-type="other" name="dv-share-link-pw-confirm" maxlength="1024" .value="${this._confirm}" @input="${this._onConfirmInput}" @keydown="${this._onKeydown}"></label><p class="nwd-note">The link carries the workspace's identity (id, name, and private key) so the recipient joins the same sync chain. Triage, reports, and comments aren't in the link itself — they sync over once the recipient joins. The link decrypts with the password above; without it the link is useless.</p>${this._error?c`<p class="wsl-error" role="alert">${this._error}</p>`:g} ${this._password&&this._confirm&&this._password!==this._confirm?c`<p class="wsl-error" role="alert">Passwords don't match.</p>`:g}<footer class="nwd-actions"><span class="nwd-spacer"></span> <button type="button" @click="${this._onCancel}">Cancel</button> <button type="button" class="primary" ?disabled="${!this._canGenerate()}" @click="${this._onGenerate}">${this._busy?"Generating\u2026":"Generate link"}</button></footer>`}render(){return c`<dialog @close="${this._onClose}"><header><h3>${this._url?"Workspace share link":"Share workspace by link"}</h3></header>${this._body()}</dialog>`}};customElements.define("workspace-share-link-dialog",gc);function xh({id:e,name:t,privateKeyBase64:r}={}){return new Promise((n,o)=>{let s=document.createElement("workspace-share-link-dialog");s.workspaceId=e??"",s.initialName=t??"",s.privateKeyBase64=r??"",s.addEventListener("resolve",()=>{s.remove(),n()}),s.addEventListener("modal-conflict",i=>{s.privateKeyBase64="",s.remove(),o(bt(i.detail?.cause))}),document.body.append(s)})}var mc=class extends I{static styles=[...I.styles,T(xe)];static properties={reportName:{type:String},orphanedTriage:{type:Number},sharedTriage:{type:Number},inRemote:{type:Boolean},_triage:{state:!0}};constructor(){super(),this.reportName="",this.orphanedTriage=0,this.sharedTriage=0,this.inRemote=!1,this._triage="keep"}focusInitial(){this.renderRoot.querySelector('button[data-role="cancel"]')?.focus()}_finish(t){if(this._settled)return;let r=this.orphanedTriage>0?this._triage:"keep";super._finish({confirmed:!!t,triage:r})}_onClose=()=>this._finish(!1);_onCancel=()=>this._finish(!1);_onConfirm=()=>this._finish(!0);_onTriageChange=t=>{this._triage=t.target.value};_remoteNotice(){return this.inRemote?c`<p class="lwd-note">This report is also stored in the workspace's <strong>remote</strong> inventory and will be removed from there too. Newly synced workspace members won't see it; members who already downloaded it keep their local copy (and could re-upload).</p>`:g}_triageSection(){let t=this.orphanedTriage,r=this.sharedTriage;return t===0&&r===0?c`<p class="lwd-note">No local triage is attached to this report.</p>`:t===0?c`<p class="lwd-note">Local triage on this report is also attached to ${r===1?"a report":"reports"} you're keeping. Nothing will be orphaned.</p>`:c`<fieldset class="lwd-choice"><legend><strong>${t}</strong> ${t===1?"triage entry won't":"triage entries won't"} be reachable from any remaining report. What should happen ${t===1?"to it":"to them"}?</legend><label class="lwd-option"><input type="radio" name="drd-triage" value="keep" ?checked="${this._triage==="keep"}" @change="${this._onTriageChange}"> <span class="lwd-option-text"><span class="lwd-option-title">Keep</span> <span class="lwd-option-hint">Reapplied automatically if a matching report is imported later.</span></span></label> <label class="lwd-option"><input type="radio" name="drd-triage" value="wipe" ?checked="${this._triage==="wipe"}" @change="${this._onTriageChange}"> <span class="lwd-option-text"><span class="lwd-option-title">Wipe</span> <span class="lwd-option-hint">Drop the orphaned triage from this browser.</span></span></label></fieldset>`}render(){return c`<dialog @close="${this._onClose}"><header><h3>Delete report</h3></header><p class="lwd-body">Delete <strong>"${this.reportName}"</strong>?</p>${this._remoteNotice()} ${this._triageSection()}<footer class="nwd-actions"><span class="nwd-spacer"></span> <button type="button" data-role="cancel" @click="${this._onCancel}">Cancel</button> <button type="button" class="danger" @click="${this._onConfirm}">Delete</button></footer></dialog>`}};customElements.define("delete-report-dialog",mc);function _h({name:e,triageImpact:t,inRemote:r}={}){return q("delete-report-dialog",{reportName:e??"",orphanedTriage:t?.orphanedCount??0,sharedTriage:t?.sharedCount??0,inRemote:!!r})}var bc=class extends I{static styles=[...I.styles,T(xe)];static properties={bundleName:{type:String},inRemote:{type:Boolean}};constructor(){super(),this.bundleName="",this.inRemote=!1}focusInitial(){this.renderRoot.querySelector('button[data-role="cancel"]')?.focus()}_finish(t){this._settled||super._finish({confirmed:!!t})}_onClose=()=>this._finish(!1);_onCancel=()=>this._finish(!1);_onConfirm=()=>this._finish(!0);_remoteNotice(){return this.inRemote?c`<p class="lwd-note">This bundle is also stored in the workspace's <strong>remote</strong> inventory and will be removed from there too. Newly synced workspace members won't see it; members who already downloaded it keep their local copy (and could re-upload).</p>`:g}render(){return c`<dialog @close="${this._onClose}"><header><h3>Delete bundle</h3></header><p class="lwd-body">Delete <strong>"${this.bundleName}"</strong>?</p>${this._remoteNotice()}<footer class="nwd-actions"><span class="nwd-spacer"></span> <button type="button" data-role="cancel" @click="${this._onCancel}">Cancel</button> <button type="button" class="danger" @click="${this._onConfirm}">Delete</button></footer></dialog>`}};customElements.define("delete-bundle-dialog",bc);function Sh({name:e,inRemote:t}={}){return q("delete-bundle-dialog",{bundleName:e??"",inRemote:!!t})}var yc=class extends I{static styles=[...I.styles,T(xe)];static properties={bundleName:{type:String},workspaceName:{type:String}};constructor(){super(),this.bundleName="",this.workspaceName=""}focusInitial(){this.renderRoot.querySelector('button[data-role="cancel"]')?.focus()}_finish(t){this._settled||super._finish({confirmed:!!t})}_onClose=()=>this._finish(!1);_onCancel=()=>this._finish(!1);_onConfirm=()=>this._finish(!0);render(){return c`<dialog @close="${this._onClose}"><header><h3>Detach bundle</h3></header><p class="lwd-body">Detach <strong>"${this.bundleName}"</strong> from workspace <strong>"${this.workspaceName}"</strong>?</p><p class="lwd-note">This bundle is also stored in the workspace's <strong>remote</strong> inventory and will be removed from there too. Newly synced workspace members won't see it; members who already downloaded it keep their local copy (and could re-upload). The bundle bytes stay on this device — drop it onto another workspace to attach it there.</p><footer class="nwd-actions"><span class="nwd-spacer"></span> <button type="button" data-role="cancel" @click="${this._onCancel}">Cancel</button> <button type="button" class="danger" @click="${this._onConfirm}">Detach</button></footer></dialog>`}};customElements.define("detach-bundle-dialog",yc);function Ch({name:e,workspaceName:t}={}){return q("detach-bundle-dialog",{bundleName:e??"",workspaceName:t??""})}var wc=class extends I{static styles=[...I.styles,T(xe)];static properties={reportName:{type:String},workspaceName:{type:String}};constructor(){super(),this.reportName="",this.workspaceName=""}focusInitial(){this.renderRoot.querySelector('button[data-role="cancel"]')?.focus()}_finish(t){this._settled||super._finish({confirmed:!!t})}_onClose=()=>this._finish(!1);_onCancel=()=>this._finish(!1);_onConfirm=()=>this._finish(!0);render(){return c`<dialog @close="${this._onClose}"><header><h3>Detach report</h3></header><p class="lwd-body">Detach <strong>"${this.reportName}"</strong> from workspace <strong>"${this.workspaceName}"</strong>?</p><p class="lwd-note">This report is also stored in the workspace's <strong>remote</strong> inventory and will be removed from there too. Newly synced workspace members won't see it; members who already downloaded it keep their local copy (and could re-upload). The report bytes stay on this device — drop it onto another workspace to attach it there.</p><footer class="nwd-actions"><span class="nwd-spacer"></span> <button type="button" data-role="cancel" @click="${this._onCancel}">Cancel</button> <button type="button" class="danger" @click="${this._onConfirm}">Detach</button></footer></dialog>`}};customElements.define("detach-report-dialog",wc);function Eh({name:e,workspaceName:t}={}){return q("detach-report-dialog",{reportName:e??"",workspaceName:t??""})}var vc=class extends I{focusInitial(){this.renderRoot.querySelector("button.primary")?.focus()}_onConfirm=()=>this._finish(!0);render(){return c`<dialog @close="${this._onClose}"><header><h3>Changes might not be saved</h3></header><p class="nwd-intro">Triage works in this tab, but this browser <strong>can't save its sync state right now</strong> — so changes that haven't reached the server could be lost if you reload the page.</p><p class="nwd-intro">This usually means the browser's storage is full, or another tab is running a newer version of the app (to avoid overwriting that newer version's data, this tab has paused saving).</p><p class="nwd-note">Free up space if storage is full, and close or reload other tabs of this app to the same version. This notice clears on its own once saving works again.</p><footer class="nwd-actions"><span class="nwd-spacer"></span> <button type="button" class="primary" @click="${this._onConfirm}">Got it</button></footer></dialog>`}};customElements.define("persistence-degraded-dialog",vc);function Ah(){return new Promise(e=>{let t=document.createElement("persistence-degraded-dialog"),r=n=>{t.remove(),e({shown:n})};t.addEventListener("resolve",()=>r(!0)),t.addEventListener("modal-conflict",()=>r(!1)),document.body.append(t)})}var ir;function zv(){return ir||(ir=document.createElement("div"),ir.id="styled-tooltip",document.body.append(ir),ir)}var Ar=null,Co=null,Fh=0,Bh=0,Th=!1;function Wv(){Th||(Th=!0,document.addEventListener("mousemove",e=>{Fh=e.clientX,Bh=e.clientY},{passive:!0}))}Wv();var Hv=100,jv=14,Vv=8,Ih=8;function Kv(e,{placement:t="cursor"}={}){let r=zv();if(Ar===e)return;let n=e.dataset.tooltip??"";if(n){if(r.textContent=n,t==="right"){let o=e.getBoundingClientRect();r.style.top=`${Math.round(o.top+o.height/2)}px`,r.style.left=`${Math.round(o.right+Vv)}px`,r.style.transform="translateY(-50%)"}else{r.style.transform="none",r.style.top=`${Bh+jv}px`,r.style.left="0px",r.classList.add("visible");let o=r.offsetWidth,s=window.innerWidth-o-Ih,i=Math.max(Ih,Math.min(Fh,s));r.style.left=`${Math.round(i)}px`}r.classList.add("visible"),Ar=e}}function Eo(){clearTimeout(Co),Co=null,ir&&ir.classList.remove("visible"),Ar=null}function kc(e,{gate:t,placement:r}={}){t&&!t(e)||(clearTimeout(Co),Co=setTimeout(()=>{Kv(e,{placement:r})},Hv))}var Rh=!1;function Mh(){Rh||(Rh=!0,document.body.addEventListener("mouseover",e=>{let t=e.target.closest("[data-tooltip]");!t||t===Ar||(Eo(),kc(t))}),document.body.addEventListener("mouseout",e=>{!Ar&&!Co||Ar&&Ar.contains(e.relatedTarget)||Eo()}))}var hi=null,le=null,fi=null;Mh();function Gv(){return kt().size}function qv(){return wr().size}var Ao=typeof location>"u"||location.hostname.endsWith(".github.io")?"":`${location.protocol==="https:"?"wss:":"ws:"}//${location.host}/api/sync`,Ec="application/x-deepview-report",_c="application/x-deepview-source-ws",To="application/x-deepview-bundle",gi=!1,mi=!1,Yv={default:"Reports","claude-security":"Claude Security","codex-security":"Codex Security",deepsec:"DeepSec"},Lh=["default","claude-security","codex-security","deepsec"],Tr="";function Ph(e,t={}){let n=`file-item${e===a.currentFile&&(a.currentView==="findings"||a.currentView==="files")?" current":""}${t.indented?" indented":""}`,o=Me(e),s=Kn(e),i=X[Ye(e)]??X.default;return c`<li class="${n}" data-file="${e}" data-workspace-id="${t.workspaceId??g}" draggable="true"><button type="button" class="file-name" data-tooltip="${o}">${me(i)}<span class="file-label">${o}</span>${s===void 0?g:c`<span class="file-count">${s}</span>`}</button></li>`}function Jv(e,t={}){let r=`file-group-header${t.dropTarget?" default-reports":""}`;return c`<li class="${r}" data-default-reports="${t.dropTarget?"true":g}"><span class="group-label">${e}</span></li>`}var Xv=c`<svg viewBox="0 0 16 16" width="11" height="11" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" aria-hidden="true"><path d="M8 3.5v9M3.5 8h9"/></svg>`;function Qv(){return c`<li class="file-group-header workspace-header"><span class="group-label">Workspaces</span><span class="workspace-header-actions"><button type="button" class="workspace-add" data-action="new-workspace" title="Create a new workspace" aria-label="Create a new workspace">${Xv}</button></span></li>`}function Zv(){return c`<li class="file-group-header bundles-header" data-default-bundles="true"><span class="group-label">Bundles</span></li>`}var e0=c`${me(ln)}`;function Oh(e,t={}){let{integrity:r,name:n}=e,o=a.selectedBundle===r&&a.currentView==="bundles",i=`file-item bundle-item${t.workspaceId!=null?" indented":""}${o?" current":""}`;return c`<li class="${i}" data-bundle-integrity="${r}" data-workspace-id="${t.workspaceId??g}" draggable="true"><button type="button" class="file-name" data-tooltip="${`${n}
55
- ${r}`}">${e0}<span class="file-label">${n}</span></button></li>`}function t0(e,t){let r=e.slice(0,15);return c`<li class="file-item indented bundle-item bundle-missing" data-bundle-integrity="${e}" data-workspace-id="${t}" data-tooltip="Bundle bytes not on this device — drop the matching bundle to attach."><span class="file-name"><span class="file-icon" aria-hidden="true">?</span><span class="file-label"><em>missing · ${r}…</em></span></span></li>`}function r0(e,t){return c`<li class="file-item indented report-missing" data-workspace-id="${t}" data-tooltip="Report not on this device — it re-downloads automatically if a workspace member has uploaded it."><span class="file-name"><span class="file-icon" aria-hidden="true">?</span><span class="file-label"><em>missing · ${Me(e)}</em></span></span></li>`}var n0=c`${me(Js)}`,o0=c`<svg viewBox="0 0 16 16" width="11" height="11" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M8 2v8M5 7l3 3 3-3M3 13h10"/></svg>`,s0=c`<svg viewBox="0 0 16 16" width="11" height="11" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M9 3H4v10h5"/><path d="M7 8h7M11 5l3 3-3 3"/></svg>`,i0=c`<svg viewBox="0 0 16 16" width="11" height="11" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M7 9.5L9 7.5"/><path d="M9.5 5.5L10.5 4.5a2.1 2.1 0 1 1 3 3l-1 1"/><path d="M6.5 11.5L5.5 12.5a2.1 2.1 0 1 1-3-3l1-1"/></svg>`;function a0(e){let r=`file-item workspace-item${a.currentWorkspace===e.id&&(a.currentView==="findings"||a.currentView==="files")?" current":""}`;return c`<li class="${r}" data-workspace-id="${e.id}"><button type="button" class="file-name">${n0}<span class="file-label" .textContent="${e.name}"></span></button><button type="button" class="workspace-share" data-action="share-workspace" title="Share by link" aria-label="Share workspace by link">${i0}</button><button type="button" class="workspace-export" data-action="export-workspace" title="Export workspace" aria-label="Export workspace">${o0}</button><button type="button" class="workspace-leave" data-action="leave-workspace" title="Leave workspace" aria-label="Leave workspace">${s0}</button></li>`}function gn(e){return Tr?Me(e).toLowerCase().includes(Tr):!0}var $c=(e,t)=>Me(e).localeCompare(Me(t));async function j(){await il(),$t().catch(()=>{});let e=await pe(),t=W(),r=await pt();if(a.bundles=r,!le)return;hi.classList.remove("empty");let n=new Set(e),o=new Set;for(let h of t)for(let b of h.reports)n.has(b)&&o.add(b);let s=new Map(r.map(h=>[h.integrity,h])),i=new Set;for(let h of t)for(let b of h.bundles)s.has(b)&&i.add(b);let l=new Map;for(let h of Lh)l.set(h,[]);for(let h of e){if(o.has(h)||!gn(h))continue;let b=Ye(h);l.has(b)||l.set(b,[]),l.get(b).push(h)}let d=t.filter(h=>!Tr||h.name.toLowerCase().includes(Tr)||h.reports.some(b=>gn(b))?!0:h.bundles.some(b=>{let m=s.get(b);return m&&gn(m.name)})),u=r.filter(h=>!i.has(h.integrity)&&gn(h.name));K(c`${Qv()} ${G(d,h=>h.id,h=>{let b=[],m=[];for(let w of h.reports)gn(w)&&(n.has(w)?b.push(w):m.push(w));b.sort($c),m.sort($c);let y=[],k=[];for(let w of h.bundles){let v=s.get(w);v?(!Tr||gn(v.name))&&y.push(v):Tr||k.push(w)}return c`${a0(h)} ${b.map(w=>Ph(w,{indented:!0,workspaceId:h.id}))} ${m.map(w=>r0(w,h.id))} ${y.map(w=>Oh(w,{workspaceId:h.id}))} ${k.map(w=>t0(w,h.id))}`})} ${Lh.map(h=>{let b=(l.get(h)??[]).toSorted($c),m=h==="default";return b.length===0&&!(m&&gi)?null:c`${Jv(Yv[h]??h,{dropTarget:m})} ${b.map(y=>Ph(y))}`})} ${u.length>0||mi?Zv():null} ${G(u,h=>h.integrity,h=>Oh(h))}`,fi);let p=le.querySelector('sidebar-view-button[kind="packages"]');p&&(p.count=Gv());let f=le.querySelector('sidebar-view-button[kind="repositories"]');f&&(f.count=qv()),bi(),Ma(e,()=>{j()})}ve(()=>{j()});async function l0(e){if(e.target.closest('[data-action="go-home"]')){await Lf();return}let t=e.target.closest(".file-item[data-bundle-integrity]");if(t){if(t.classList.contains("bundle-missing"))return;let d=t.dataset.bundleIntegrity;if(a.selectedBundle===d&&a.currentView==="bundles")return;a.currentView="bundles",a.selectedBundle=d,a.bundleDetails=null,a.bundleSourceFile=null,a.bundleSourceFindingIdx=null,a.bundleCodeSearchQuery="",a.bundleCodeSearchMode="files",a.bundleSearchQuery="",a.bundleSearchRegex=!1,a.bundleSearchCase=!1,a.bundleSearchContext=!0,a.bundleDetailsTab="overview",E.showAll=!0,a.shownTriage=null,Sr(d),x(),j(),Ot(d);return}let r=e.target.closest("sidebar-view-button");if(r){let d=r.getAttribute("kind");(d==="packages"||d==="repositories")&&(a.currentView=d,x(),j());return}if(e.target.closest('[data-action="new-workspace"]')){let d=await kh();d&&(await Gl(),await Ga(d),j());return}let n=e.target.closest('[data-action="share-workspace"]');if(n){let d=n.closest("[data-workspace-id]"),u=d?W().find(p=>p.id===d.dataset.workspaceId):null;u&&xh({id:u.id,name:u.name,privateKeyBase64:u.privateKey}).catch(p=>alert(`Failed to open share dialog: ${p.message}`));return}let o=e.target.closest('[data-action="export-workspace"]');if(o){let d=o.closest("[data-workspace-id]"),u=d?W().find(p=>p.id===d.dataset.workspaceId):null;u&&vh(u).catch(p=>alert(`Failed to open export dialog: ${p.message}`));return}let s=e.target.closest('[data-action="leave-workspace"]');if(s){let d=s.closest("[data-workspace-id]"),u=d?W().find(y=>y.id===d.dataset.workspaceId):null;if(!u)return;let p=Array.isArray(u.reports)?u.reports:[],f;try{f=await Ts(p)}catch(y){alert(`Couldn't read reports to analyze triage impact: ${y.message}`);return}let{confirmed:h,mode:b,triage:m}=await $h({name:u.name,reportCount:p.length,bundleCount:u.bundles.length,triageImpact:f});if(!h)return;if(!W().some(y=>y.id===u.id)){alert(`Workspace "${u.name}" was removed elsewhere; nothing to leave.`);return}try{await Of(u.id,b,{triage:m})}catch(y){alert(`Failed to leave workspace: ${y.message}`)}return}let i=e.target.closest(".file-item.workspace-item[data-workspace-id]");if(i){let d=i.dataset.workspaceId,u=a.currentView==="findings"||a.currentView==="files";d&&(d!==a.currentWorkspace||!u)&&nr(d);return}let l=e.target.closest(".file-item[data-file]");if(l){let d=l.dataset.file;d&&(d!==a.currentFile||a.currentView!=="findings")&&Et(d);return}if(e.target.closest("sidebar-delete-current")){if(a.currentView==="bundles"&&a.selectedBundle){let m=a.selectedBundle,y=(a.bundles??[]).find(v=>v.integrity===m)?.name??m,k=W().filter(v=>Array.isArray(v.bundles)&&v.bundles.includes(m)).filter(v=>$l(v.id,m)).map(v=>v.id),{confirmed:w}=await Sh({name:y,inRemote:k.length>0});if(!w)return;if(a.selectedBundle!==m){alert(`Active bundle changed during confirmation; aborting delete of "${y}".`);return}try{await Pf({deleteFromRemoteWorkspaceIds:k})}catch(v){alert(`Failed to delete bundle: ${v.message}`)}return}if(!a.currentFile)return;let d=a.currentFile,u;try{u=await Ts([d])}catch(m){alert(`Couldn't read reports to analyze triage impact: ${m.message}`);return}let p=W().filter(m=>Array.isArray(m.reports)&&m.reports.includes(d)).filter(m=>ao(m.id,d)).map(m=>m.id),f=p.length>0,{confirmed:h,triage:b}=await _h({name:d,triageImpact:u,inRemote:f});if(!h)return;if(a.currentFile!==d){alert(`Active report changed during confirmation; aborting delete of "${d}".`);return}try{await Mf({triage:b,deleteFromRemoteWorkspaceIds:p})}catch(m){alert(`Failed to delete report: ${m.message}`)}return}if(e.target.closest("#sync-status")){N.status==="error"?N.dismissError():N.status==="off"?(!N.getServerUrl()&&Ao&&N.setServerUrl(Ao),N.setEnabled(!0)):N.setEnabled(!1);return}if(e.target.closest("#sidebar-toggle")){hi.classList.toggle("collapsed");try{localStorage.setItem("deepview.sidebarCollapsed",hi.classList.contains("collapsed")?"1":"0")}catch{}}}function c0(e){let t=e.target.closest("[data-tooltip]");if(!t){Eo();return}kc(t,{placement:"right",gate:r=>{let n=r.querySelector(".file-label");return!n||(r.dataset.tooltip??"")!==n.textContent?!0:n.scrollWidth>n.clientWidth}})}function d0(e){let t=e.target.closest("[data-tooltip]"),r=e.relatedTarget?.closest?.("[data-tooltip]")??null;t&&t===r||Eo()}function u0(e){Tr=e.target.value.trim().toLowerCase(),j()}var p0={off:"Sync off",online:"Online",offline:"Offline",connecting:"Connecting\u2026",error:"Sync error"};function f0(){return N.getServerUrl()||Ao?W().length>0:!1}function bi(e){let t=le?.querySelector("#sync-status");if(!t)return;let r=f0();if(r&&N.isEnabled()&&mp().catch(i=>{console.warn("sync: load failed",i)}),r&&!N.getServerUrl()&&Ao&&N.isEnabled()&&N.setServerUrl(Ao),N.setForcedOff(!r),!r){t.hidden=!0;return}t.hidden=!1;let n=e??N.status;t.dataset.status=n;let o=N.persistenceDegraded;t.toggleAttribute("data-degraded",o),t.title=o?"Not saving to this browser right now (storage may be full, or another tab is on a newer version). Changes that haven\u2019t synced could be lost on reload.":"";let s=t.querySelector(".sync-label");s&&(s.textContent=p0[n]??"")}N.onStatusChange(bi);var xc=!1,Sc=!1;async function Nh(){if(!N.persistenceDegraded||Sc||xc)return;xc=!0;let{shown:e}=await Ah();if(xc=!1,e){Sc=!0;return}N.persistenceDegraded&&setTimeout(Nh,1500)}N.onPersistenceDegraded(e=>{bi(),e?Nh():Sc=!1});function h0(e){let t=e.target.closest(".file-item.workspace-item");if(!t)return;let r=t.querySelector(".file-label");if(!r||r.querySelector("input"))return;let n=t.dataset.workspaceId,o=W().find(d=>d.id===n);if(!o)return;e.preventDefault();let s=document.createElement("input");s.type="text",s.value=o.name,s.className="workspace-rename-input",r.textContent="",r.append(s),s.focus(),s.select();let i=!1,l=async d=>{i||(i=!0,d&&await Ya(n,s.value),j())};s.addEventListener("keydown",d=>{d.key==="Enter"?(d.preventDefault(),l(!0)):d.key==="Escape"&&(d.preventDefault(),l(!1))}),s.addEventListener("blur",()=>l(!0)),s.addEventListener("click",d=>d.stopPropagation()),s.addEventListener("dblclick",d=>d.stopPropagation())}function yi(){for(let e of le.querySelectorAll(".drag-over"))e.classList.remove("drag-over")}function Dh(e){return e.dataTransfer.types.includes(Ec)||e.dataTransfer.types.includes(To)}function g0(e){let t=e.target.closest(".file-item[data-bundle-integrity]");if(t){if(t.classList.contains("bundle-missing")){e.preventDefault();return}let n=t.dataset.bundleIntegrity;e.dataTransfer.effectAllowed="move",e.dataTransfer.setData(To,n),e.dataTransfer.setData(_c,t.dataset.workspaceId??""),e.dataTransfer.setData("text/plain",n),t.classList.add("dragging"),mi=!0,j();return}let r=e.target.closest(".file-item[data-file]");r&&(e.dataTransfer.effectAllowed="move",e.dataTransfer.setData(Ec,r.dataset.file),e.dataTransfer.setData(_c,r.dataset.workspaceId??""),e.dataTransfer.setData("text/plain",r.dataset.file),r.classList.add("dragging"),gi=!0,j())}function m0(){for(let e of le.querySelectorAll(".dragging"))e.classList.remove("dragging");yi(),(gi||mi)&&(gi=!1,mi=!1,j())}function b0(e){if(!Dh(e))return;e.preventDefault();let t=e.target.closest("[data-workspace-id]"),r=le.querySelector(".dragging")?.closest("[data-workspace-id]")?.dataset.workspaceId??null,s=t&&r&&t.dataset.workspaceId===r||!t&&!r;if(e.dataTransfer.dropEffect=s?"none":"move",yi(),!s)if(t){let i=t.dataset.workspaceId;for(let l of le.querySelectorAll(`[data-workspace-id="${CSS.escape(i)}"]`))l.classList.contains("dragging")||l.classList.add("drag-over")}else{let l=e.dataTransfer.types.includes(To)?"[data-default-bundles]":"[data-default-reports]",d=le.querySelector(l);d&&d.classList.add("drag-over")}}function y0(e){le.contains(e.relatedTarget)||yi()}async function w0(e){if(!Dh(e))return;e.preventDefault(),e.stopPropagation(),yi();let t=e.target.closest("[data-workspace-id]"),r=t?t.dataset.workspaceId:null,n=e.dataTransfer.getData(_c)||null;if(e.dataTransfer.types.includes(To)){let s=e.dataTransfer.getData(To);if(!s)return;if(n&&n!==r&&$l(n,s)){let i=(a.bundles??[]).find(u=>u.integrity===s)?.name??s,l=W().find(u=>u.id===n),{confirmed:d}=await Ch({name:i,workspaceName:l?.name??""});if(!d)return;try{await Ns(n,s)}catch(u){console.warn(`Failed to remove '${i}' from source workspace ${n} remote:`,u)}}r&&await kr(s,r),n&&n!==r&&await el(s,n),j();return}let o=e.dataTransfer.getData(Ec);if(o){if(n&&n!==r&&ao(n,o)){let s=W().find(l=>l.id===n),{confirmed:i}=await Eh({name:o,workspaceName:s?.name??""});if(!i)return;try{await Os(n,o)}catch(l){console.warn(`Failed to remove '${o}' from source workspace ${n} remote:`,l)}}r&&await Ft(o,r),n&&n!==r&&await Zn(o,n),j()}}function v0(e){hi=e,le=e.renderRoot,fi=le.querySelector("#file-list"),Pp(le.querySelector("#encryption-toggle")),le.addEventListener("click",l0),le.addEventListener("dblclick",h0),le.addEventListener("dragstart",g0),le.addEventListener("dragend",m0),le.addEventListener("dragover",b0),le.addEventListener("dragleave",y0),le.addEventListener("drop",w0),fi.addEventListener("mouseover",c0),fi.addEventListener("mouseout",d0),le.querySelector("#sidebar-search-input")?.addEventListener("input",u0),bi(N.status),j()}var Cc=class extends H{static styles=[T(Fp),T(Rp)];render(){return c`<div class="sidebar-header"><h2 class="brand"><button class="brand-button" type="button" data-action="go-home"><span class="brand-name">DeepView</span></button> <span class="brand-tag">dev</span></h2><button id="encryption-toggle" type="button" hidden></button> <button id="sidebar-toggle" type="button" title="toggle sidebar" aria-label="toggle sidebar"><svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor" aria-hidden="true"><path d="M2 4h12v1.5H2zM2 7.25h12v1.5H2zM2 10.5h12V12H2z"/></svg></button></div><div class="sidebar-search"><svg class="sidebar-search-icon" viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.5" aria-hidden="true"><circle cx="6.5" cy="6.5" r="4.5"/><path d="M9.7 9.7L13 13" stroke-linecap="round"/></svg> <input id="sidebar-search-input" type="search" placeholder="Search reports..." autocomplete="off"><sidebar-view-button kind="packages"></sidebar-view-button><sidebar-view-button kind="repositories"></sidebar-view-button></div><ul id="file-list"></ul><div class="sidebar-actions"><sidebar-delete-current></sidebar-delete-current><button id="sync-status" type="button" data-status="off"><span class="sync-dot" aria-hidden="true"></span> <span class="sync-label">Sync off</span></button></div>`}firstUpdated(){v0(this)}};customElements.define("app-sidebar",Cc);var Uh={attach:{title:"Synced triage on report attach",intro:"have triage from your workspace that disagrees with your local view on",trailingNote:"Other findings in this report whose chain value didn't conflict were applied automatically; this list only covers disagreements. Pick which side to keep.",importedSideLabel:"Apply from chain",applyButton:"Apply"},chain:{title:"Triage conflict from peer update",intro:"were changed by a peer (or by another tab) in a way that disagrees with your local triage on",trailingNote:`Other findings whose remote value didn't conflict were applied automatically; this list only covers disagreements. Pick which side to keep for each \u2014 a "keep current" pick re-publishes your local value to the chain on your next save.`,importedSideLabel:"Apply from chain",applyButton:"Apply"}};function zh(){Cp(async(e,t,r)=>{let n=Pa(e);try{return await ii(e,n,Uh[r]??Uh.attach)}catch{let o=e.length;return alert(`${r==="attach"?"A report attach":"A workspace sync"} had ${o} triage disagreement${o===1?"":"s"} with your local view. Kept your local values because another dialog is open. ${r==="attach"?"Detach and re-attach the report to pick again.":"Your local values will re-publish to the chain on the next change."}`),null}})}var Ac=class extends I{static properties={retry:{type:Boolean},_value:{state:!0}};constructor(){super(),this.retry=!1,this._value=""}_finish(t){this._value="",super._finish(t)}_onCancel=()=>this._finish(null);_onInput=t=>{this._value=t.target.value};_onSubmit=()=>{let t=this._value??"";t&&this._finish(t)};_onKeydown=t=>{t.key==="Enter"&&(t.preventDefault(),this._onSubmit())};render(){let t=(this._value??"").length>0,r=this.retry?"That password didn't match. Try again, or cancel to leave the workspace unsynced for now.":"This sync server requires a password before it accepts a new workspace. Enter it to create the workspace on the server.";return c`<dialog @close="${this._onClose}"><header><h3>Sync server password</h3></header><p class="nwd-intro">${r}</p><input type="password" class="nwd-input" placeholder="Password" autocomplete="off" data-1p-ignore="true" data-lpignore="true" data-bwignore="true" data-form-type="other" name="dv-sync-auth" maxlength="4096" .value="${this._value}" @input="${this._onInput}" @keydown="${this._onKeydown}"><footer class="nwd-actions"><span class="nwd-spacer"></span> <button type="button" @click="${this._onCancel}">Cancel</button> <button type="button" class="primary" ?disabled="${!t}" @click="${this._onSubmit}">${this.retry?"Retry":"Authenticate"}</button></footer></dialog>`}};customElements.define("sync-auth-dialog",Ac);function Wh({retry:e=!1}={}){return q("sync-auth-dialog",{retry:!!e})}function Hh(){Sp(async({retry:e})=>{try{return await Wh({retry:e})}catch(t){return console.warn("Sync auth dialog failed to open:",t),null}})}var wi="https://triage.space/",k0=[{hostname:"deepaudit.dev",pathPrefix:"/",supportsSync:!0},{hostname:"chalker.github.io",pathPrefix:"/deepview/",supportsSync:!1}];function $0(){for(let e of k0)if(location.hostname===e.hostname&&location.pathname.startsWith(e.pathPrefix))return e;return null}var x0=["deepview.triage","deepview.triage.pending"],_0="deepview.repoUrls";function S0(){try{for(let e of x0)if(localStorage.getItem(e))return!0}catch{return!0}try{let e=localStorage.getItem(_0);if(e){let t=JSON.parse(e);if(t&&typeof t=="object"&&Object.keys(t).length>0)return!0}}catch{return!0}return!1}async function C0(){if(S0())return!0;let e=[];try{e=await pe()}catch{return!0}if(e.length>0)return!0;try{if(W().length>0)return!0}catch{return!0}try{return await ga()}catch{return!0}}var Tc=class extends H{static properties={supportsSync:{attribute:!1}};createRenderRoot(){return this}constructor(){super(),this.supportsSync=!1}firstUpdated(){let t=this.querySelector("dialog");t&&t.showModal();let r=this.querySelector("button.om-stay");r&&r.focus()}_finish(t){if(this._settled)return;this._settled=!0;let r=this.querySelector("dialog");r&&r.close(),this.dispatchEvent(new CustomEvent("resolve",{detail:t}))}_onClose=()=>this._finish(!1);_onStay=()=>this._finish(!1);_onMigrate=()=>this._finish(!0);render(){let t=()=>c`<a class="om-link" href="${wi}" target="_blank" rel="noopener noreferrer">${wi}</a>`;return c`<dialog class="origin-migration-dialog" @close="${this._onClose}"><header class="om-head"><h3>This deepview build has moved</h3><p><code>${location.host}${location.pathname}</code> has moved to ${t()}.</p></header><section class="om-body"><p>Workspaces and reports don't migrate automatically — they live in this origin's browser storage (OPFS where available, localStorage as a fallback) and have to be re-imported on ${t()}.</p>${this.supportsSync?c`<p>For each workspace, use the <strong>Export workspace</strong> button in the sidebar to download a <code>.gz</code> bundle (workspace + its reports + its triage), then drop that file on ${t()}. Workspaces that had sync configured will pick their triage state back up from the sync server once you re-import them with the same key.</p><p>For triage attached to loose reports (or as a top-up after re-importing workspaces), call <code>DeepView.export()</code> in the browser console — that downloads just the triage entries plus saved repo URLs, no reports or workspaces.</p>`:c`<p>This build has no sync layer. For each workspace, use the <strong>Export workspace</strong> button in the sidebar to download a <code>.gz</code> bundle (workspace + its reports + its triage), then drop that file on ${t()}.</p><p>For triage attached to loose reports, call <code>DeepView.export()</code> in the browser console — that downloads just the triage entries plus saved repo URLs, no reports or workspaces. Reports themselves need to be re-dropped from their original JSON on the new origin.</p>`}</section><footer class="om-actions"><button type="button" class="om-stay" @click="${this._onStay}">Keep editing on ${location.host}</button> <button type="button" class="primary om-go" @click="${this._onMigrate}">Switch to triage.space</button></footer></dialog>`}};customElements.define("origin-migration-dialog",Tc);function E0(e){return new Promise(t=>{let r=document.createElement("origin-migration-dialog");r.supportsSync=e.supportsSync,r.addEventListener("resolve",n=>{r.remove(),t(!!n.detail)}),document.body.append(r)})}async function jh(){let e=$0();return e?await C0()?await E0(e)?(location.assign(wi),!0):!1:(location.replace(wi),!0):!1}var Ic=class extends I{static styles=[...I.styles,T(ot)];static properties={encoded:{type:String},_stage:{state:!0},_password:{state:!0},_name:{state:!0},_decoded:{state:!0},_existingById:{state:!0},_busy:{state:!0},_error:{state:!0},_settled:{state:!0}};constructor(){super(),this.encoded="",this._stage="password",this._password="",this._name="",this._decoded=null,this._existingById=null,this._busy=!1,this._error="",this._settled=!1}focusInitial(){this._focusActiveInput()}updated(t){t.has("_stage")&&this._focusActiveInput()}_focusActiveInput(){if(this._stage==="password")this.renderRoot.querySelector('input[type="password"]')?.focus();else if(this._stage==="name"){let t=this.renderRoot.querySelector('input[data-role="name"]');t&&(t.focus(),t.select())}}_finish(t){this._settled||(this._decoded=null,this._password="",this.encoded="",super._finish(t))}_onClose=()=>this._finish(null);_onCancel=()=>this._finish(null);_onPasswordInput=t=>{this._password=t.target.value,this._error=""};_onNameInput=t=>{this._name=t.target.value};_onUnlock=async()=>{if(!(!this._password||this._busy)){this._busy=!0,this._error="";try{let t=await bl({encoded:this.encoded,password:this._password});if(this._settled)return;let r=W().find(n=>n.id===t.id)??null;this._decoded=t,this._existingById=r,this._name=t.name,this._password="",this._stage="name"}catch(t){if(this._settled)return;this._error=t?.message??String(t)}finally{this._busy=!1}}};_onAttach=()=>{if(!this._decoded)return;let t=xt(this._name);if(!t)return;let r=W().find(n=>n.id===this._decoded.id)??null;if(r){this._existingById=r;return}this._nameCollision(t)||this._finish({id:this._decoded.id,name:t,privateKeyBase64:this._decoded.privateKeyBase64})};_nameCollision(t){if(!t||!this._decoded)return null;for(let r of W())if(r.id!==this._decoded.id&&xt(r.name)===t)return r;return null}_onKeydown=t=>{t.key==="Enter"&&(t.preventDefault(),this._stage==="password"?this._onUnlock():this._stage==="name"&&this._onAttach())};_passwordStage(){return c`<p class="nwd-note">Someone shared a workspace with you. Enter the password they sent separately to attach it to this browser.</p><label class="wsl-field"><span>Password</span> <input type="password" class="nwd-input" autocomplete="off" data-1p-ignore="true" data-lpignore="true" data-bwignore="true" data-form-type="other" name="dv-share-link-unlock" maxlength="1024" .value="${this._password}" @input="${this._onPasswordInput}" @keydown="${this._onKeydown}"></label> ${this._error?c`<p class="wsl-error" role="alert">${this._error}</p>`:g}<footer class="nwd-actions"><span class="nwd-spacer"></span> <button type="button" @click="${this._onCancel}">Cancel</button> <button type="button" class="primary" ?disabled="${!this._password||this._busy}" @click="${this._onUnlock}">${this._busy?"Unlocking\u2026":"Unlock"}</button></footer>`}_alreadyAttachedStage(){let t=this._existingById;return c`<p class="nwd-note">This workspace is already attached as <strong>"${t?.name??""}"</strong>. Open it from the sidebar.</p><footer class="nwd-actions"><span class="nwd-spacer"></span> <button type="button" class="primary" @click="${this._onCancel}">Close</button></footer>`}_nameStage(){if(this._existingById)return this._alreadyAttachedStage();let t=xt(this._name),r=this._nameCollision(t),n=!!t&&!r;return c`<p class="nwd-note">Pick a name for the workspace on this device. The shared identity is preserved either way — only the visible label changes.</p><label class="wsl-field"><span>Workspace name</span> <input type="text" class="nwd-input" data-role="name" placeholder="Workspace name" maxlength="200" .value="${this._name}" @input="${this._onNameInput}" @keydown="${this._onKeydown}"></label> ${r?c`<p class="wsl-error" role="alert">A workspace named "${t}" already exists on this device. Pick a different name.</p>`:g}<footer class="nwd-actions"><span class="nwd-spacer"></span> <button type="button" @click="${this._onCancel}">Cancel</button> <button type="button" class="primary" ?disabled="${!n}" @click="${this._onAttach}">Attach</button></footer>`}render(){let t=this._stage==="password"?"Attach shared workspace":this._existingById?"Workspace already attached":"Name the workspace";return c`<dialog @close="${this._onClose}"><header><h3>${t}</h3></header>${this._stage==="password"?this._passwordStage():this._nameStage()}</dialog>`}};customElements.define("workspace-unlock-link-dialog",Ic);function Vh({encoded:e}={}){return new Promise((t,r)=>{let n=document.createElement("workspace-unlock-link-dialog");n.encoded=e??"",n.addEventListener("resolve",o=>{n.remove(),t(o.detail)}),n.addEventListener("modal-conflict",o=>{n.encoded="",n.remove(),r(bt(o.detail?.cause))}),document.body.append(n)})}var De=null,vi=!1,Io=null;function A0(e){if(!e)return"Could not unlock. Try again.";switch(e.name??""){case"NotAllowedError":case"AbortError":return"";case"SecurityError":return"The site identity does not match the one this passkey was registered for. If you opened DeepView through a different URL (different subdomain, different port), reload via the original URL.";case"InvalidStateError":return"The passkey state on this device is inconsistent. Try reloading the page or removing and re-creating the passkey.";case"NotSupportedError":return"This browser does not support the WebAuthn PRF extension this site needs. Try a recent Chrome, Safari, or Edge with a platform authenticator.";case"NetworkError":return"A network error prevented the passkey from completing. Check your connection and try again.";case"UnknownError":return"The authenticator returned an unknown error. Try again, or use a different passkey.";default:{let r=e.message??String(e);return r.length>200?r.slice(0,197)+"\u2026":r}}}function T0(){if(De)return De;De=document.createElement("div"),De.id="lock-overlay",De.setAttribute("role","dialog"),De.setAttribute("aria-modal","true"),De.setAttribute("aria-label","Unlock DeepView"),De.innerHTML=`
47
+ You can change this anytime from the lock icon in the sidebar header.`)){nh();return}await ti(),ne()&&nh()}var sh=ac;var ih=["type","model","think","effort","exportsMode"],or="deepview.lastFile",Bo=new Set(["overview","graph","treemap","compare","advisories","issues","code","search","terminal"]);function sr(e,t="overview"){let r=t&&t!=="overview"&&Bo.has(t)?` ${t}`:"";Ee(or,`b:${e}${r}`).catch(()=>{})}var Br=0,Re=e=>e!==Br;function lc(e){let t=lh(e.toLowerCase());return t.endsWith(".map")?"sourcemap":t==="stasis.code.br"||t.endsWith(".stasis.code.br")?"stasis":null}function lh(e){return e.replace(/ \(\d+\)(?=\.[^.]*$)/u,"")}async function ah({name:e,content:t,existingNames:r}){if(!r.has(e))return await ht(e,t),r.add(e),{name:e,content:t};let n;try{n=await De(e)}catch(l){if(!(l instanceof DOMException&&l.name==="NotFoundError"||typeof l?.message=="string"&&l.message.startsWith("File not found:")))throw l;return await ht(e,t),r.add(e),{name:e,content:t}}if(n===t)return{name:e,content:t};let s=V().filter(l=>Array.isArray(l.reports)&&l.reports.includes(e)).filter(l=>$o(l.id,e)),i=await Vf({name:e,workspaceNames:s.map(l=>l.name),existingNames:r});if(i.action==="cancel")return null;if(i.action==="rename"){let l=i.newName;return await ht(l,t),r.add(l),{name:l,content:t}}return await ht(e,t),s.length>0&&await sv(e,s),{name:e,content:t}}async function sv(e,t){let r;try{r=await vr(e)}catch(n){console.warn(`Import: failed to read freshly-saved "${e}" for cloud sync:`,n);return}for(let n of t)try{await ei(n.id);let o=await Xs(n.id,e,r);o&&o.ok===!1&&console.warn(`Import: failed to upload "${e}" to workspace "${n.name}" (${n.id}): ${o.reason??"unknown"}`)}catch(o){console.warn(`Import: failed to upload "${e}" to workspace "${n.name}" (${n.id}):`,o)}}async function cc(e){await sh();let t=null,r=null,n=new Set,o=new Set(await fe());for(let s of e)try{let i=lh(s.name.toLowerCase());if(i.endsWith(".gz")||i.endsWith(".deepview-workspace.enc")){await rh(s);try{let u=await fe();o.clear();for(let p of u)o.add(p)}catch(u){console.warn("Import: failed to refresh existingNames after workspace import:",u)}continue}if(lc(s.name)){let u=new Uint8Array(await s.arrayBuffer()),{integrity:p}=await kr(s.name,u);r=p,n.add(p);continue}let d=await s.text();if(i.endsWith(".csv")){let u=Jf(d);for(let{displayName:p,data:f}of u){let h=p.replaceAll("/","__")+".codex",b=JSON.stringify(f),{count:m,source:y}=Ke(b),v=await ah({name:h,content:b,existingNames:o});v&&(Je(v.name,m,y),t={name:v.name,content:v.content})}}else{let u=Ke(d);if(!u.recognized)throw new Error("not a recognized DeepView, DeepSec, Claude Security, or Codex report");let p=await ah({name:s.name,content:d,existingNames:o});if(!p)continue;Je(p.name,u.count,u.source),t={name:p.name,content:p.content}}}catch(i){alert(`Failed to load ${s.name}: ${i.message}`)}await K();for(let s of n)nc(s).catch(()=>{});t?await At(t.name,t.content):r&&(a.currentView="bundles",a.selectedBundle=r,a.bundleDetails=null,a.bundleDetailsTab="overview",a.bundleSourceFile=null,a.bundleSourceFindingIdx=null,a.bundleCodeSearchQuery="",a.bundleCodeSearchMode="files",a.bundleSearchQuery="",a.bundleSearchRegex=!1,a.bundleSearchCase=!1,a.bundleSearchContext=!0,a.shownTriage=null,C.showAll=!0,sr(r),$(),await K(),Ot(r))}async function At(e,t){let r=++Br,n=new Set(V().filter(o=>Array.isArray(o.reports)&&o.reports.includes(e)).map(o=>o.id));for(let o of D.openSessions)o&&!n.has(o.workspaceId)&&(D.closeSession(o.workspaceId),xo(o.workspaceId));if(a.reports=[],a.workspaceMerges=[],a.currentFile=e,a.currentWorkspace=null,(a.currentView==="bundles"||a.currentView==="packages"||a.currentView==="repositories")&&(a.currentView="findings"),a.repoUrl=qe(e),a.repoEditing=!1,C.selected=null,C.focusedPkg=null,C.layoutCache=null,C.solo=null,C.hidden.clear(),C.pathFilter="",Pe(),Ee(or,e).catch(()=>{}),t===void 0){try{t=await De(e)}catch(o){if(Re(r))return;if(o&&o.message?.includes("vault locked")){if(await ri()&&!Re(r)){await At(e);return}Re(r)||(a.currentFile=null,await K());return}alert(`Failed to read ${e}: ${o.message}`),a.currentFile=null,await K();return}if(Re(r))return}if(await uc(e,t,r),!Re(r)){for(let o of n)D.openSession(o),D.refreshSession(o),ei(o);await K()}}async function ir(e){let t=V().find(o=>o.id===e);if(!t)return;let r=++Br;for(let o of D.openSessions)o&&o.workspaceId!==e&&(D.closeSession(o.workspaceId),xo(o.workspaceId));(a.currentView==="bundles"||a.currentView==="packages"||a.currentView==="repositories")&&(a.currentView="findings"),a.reports=[],a.workspaceMerges=[],a.currentFile=null,a.currentWorkspace=e,a.repoUrl="",a.repoEditing=!1,C.selected=null,C.focusedPkg=null,C.layoutCache=null,C.solo=null,C.hidden.clear(),C.pathFilter="",Pe(),Ee(or,`ws:${e}`).catch(()=>{}),t.reports.length===0&&(I.classList.remove("active"),q(g,I),Be.classList.remove("hidden"));let n=t.reports.map(o=>De(o).catch(()=>null));for(let o=0;o<t.reports.length;o++){let s=await n[o];if(Re(r))return;if(s!==null&&(await uc(t.reports[o],s,r),Re(r)))return}D.openSession(e),D.refreshSession(e),ei(e),await K()}async function ch({triage:e="keep",deleteFromRemoteWorkspaceIds:t=[]}={}){if(!a.currentFile)return;let r=++Br,n=a.currentFile;sn(n),Ye(n,"");for(let o of t)try{let s=await Qs(o,n);if(Re(r))return;s&&s.ok===!1&&s.reason!=="not-found"&&console.warn(`Failed to delete '${n}' from workspace ${o} remote: ${s.reason}`)}catch(s){console.warn(`Failed to delete '${n}' from workspace ${o} remote:`,s)}if(await Xr(n),!Re(r)&&(await ho(n,null),!Re(r))){if(e==="wipe"){try{await js()}catch(o){console.warn("Skipped orphan-triage GC:",o)}if(Re(r))return}Re(r)||(dc(),await K())}}function dc(){a.currentFile=null,a.currentWorkspace=null,a.selectedBundle=null,a.bundleDetails=null,a.bundleSourceFile=null,a.bundleSourceFindingIdx=null,a.reports=[],a.workspaceMerges=[],a.repoUrl="",a.repoEditing=!1,a.shownTriage=null,a.currentView="findings",C.selected=null,C.focusedPkg=null,C.layoutCache=null,C.solo=null,C.hidden.clear(),C.pathFilter="",Pe(),Gr(or),I.classList.remove("active"),q(g,I),Be.classList.remove("hidden"),document.title="DeepView"}async function dh(){++Br;for(let e of D.openSessions)e&&(D.closeSession(e.workspaceId),xo(e.workspaceId));dc(),await K()}async function uh({deleteFromRemoteWorkspaceIds:e=[]}={}){if(!a.selectedBundle)return;let t=++Br,r=a.selectedBundle;for(let o of e)try{let s=await Zs(o,r);if(Re(t))return;s&&s.ok===!1&&s.reason!=="not-found"&&console.warn(`Failed to delete bundle from workspace ${o} remote: ${s.reason}`)}catch(s){console.warn(`Failed to delete bundle from workspace ${o} remote:`,s)}if(await Ia(r),Re(t)||(await hl(r,null),Re(t)))return;a.selectedBundle=null,a.bundleDetails=null,a.bundleSourceFile=null,a.bundleSourceFindingIdx=null;let n=we(or);typeof n=="string"&&(n===`b:${r}`||n.startsWith(`b:${r} `))&&Gr(or),Ka(r),a.bundles=await gt(),!Re(t)&&($(),await K())}async function ph(e,t="detach",{triage:r="keep"}={}){let n=V().find(l=>l.id===e);if(!n)return;++Br;let o=Array.isArray(n.reports)?[...n.reports]:[];if(D.closeSession(e),xo(e),t==="delete"){for(let l of o){try{await Xr(l)}catch{}sn(l),Ye(l,"")}if(r==="wipe")try{await js()}catch(l){console.warn("Skipped orphan-triage GC:",l)}}let s=a.currentWorkspace===e,i=t==="delete"&&a.currentFile!=null&&o.includes(a.currentFile);(s||i)&&dc(),await cl(e),await K()}async function uc(e,t,r=null){let n=()=>r!==null&&Re(r);try{if(await bo,n())return;let o;try{o=JSON.parse(t)}catch(b){if(o=Qr(t)??Zr(t),!o)throw new Error(`Not JSON, and not a recognized markdown format. (JSON error: ${b.message})`,{cause:b})}let s=a.reports.length===0,i=new Set,l=new Map;for(let b=0;b<a.reports.length;b++){let m=a.reports[b];for(let y=0;y<m.groups.length;y++){let v=m.groups[y],w=`${b}:${y}`;for(let k of v)k.id&&(i.add(k.id),l.set(k.id,w))}}let d=o.findings||[],u=d.flatMap(jl).filter(b=>!b.id);if(u.length>0){let b=await Promise.all(u.map(Ls));if(n())return;u.forEach((m,y)=>{b[y]&&(m.id=b[y])})}let p=qe(e),f=[],h=0;for(let b of d){let m=jl(b);if(m.length===0)continue;let y=m.filter(x=>x.id&&i.has(x.id)),v=m.filter(x=>!x.id||!i.has(x.id)),w=new Set;for(let x of y){let T=l.get(x.id);T!==void 0&&w.add(T)}let k=m.filter(x=>x.id).map(x=>x.id);if(v.length===0){w.size>1&&a.workspaceMerges.push(new Set(k)),h+=y.length;continue}let E=[];for(let x of v){x.id&&i.add(x.id);let T={...x,_id:a.nextFindingId++,_repoFallback:p,_reportName:e,_bundleHashes:o.bundleHashes??[]};if(!o.source&&!ih.some(Z=>T[Z]!==void 0))for(let Z of ih)o[Z]!==void 0&&(T[Z]=o[Z]);T._analyzer=o.source??T.type??null,E.push(T)}y.length>0&&(h+=y.length,a.workspaceMerges.push(new Set(k)));let S=`${a.reports.length}:${f.length}`;for(let x of v)x.id&&l.set(x.id,S);f.push(E)}if(h>0&&console.log(`${e}: skipped ${h} duplicate finding${h===1?"":"s"}`),a.reports.push({type:o.type||"analysis",source:o.source??null,fileName:e,groups:f,tree:o.tree??null,bundleHashes:o.bundleHashes??[]}),Array.isArray(o.bundleHashes)&&o.bundleHashes.length>0){let b=new Set((a.bundles??[]).map(m=>m.integrity));for(let m of o.bundleHashes)b.has(m)&&nc(m).catch(()=>{})}if(s)if(ii(),f.some(m=>m.some(y=>y.confidence!==void 0))){let m=v=>f.reduce((w,k)=>w+(k.some(E=>E.confidence!==void 0&&E.confidence>=v)?1:0),0),y;for(m(6)<=25?y=6:m(7)<=25?y=7:y=8;y>0&&m(y-1)===m(y);)y--;a.filterConfMin=y}else a.filterConfMin=0;$()}catch(o){alert(`Failed to parse ${e}: ${o.message}`)}}window.__loadFile=(e,t)=>uc(e,t);window.__setFilters=({severities:e,confMin:t}={})=>{e!=null&&(a.filterSeverities=new Set(e)),t!==void 0&&(a.filterConfMin=t),$()};document.addEventListener("keydown",e=>{e.key==="Escape"&&document.body.classList.contains("report-fullscreen")&&document.body.classList.remove("report-fullscreen")});document.addEventListener("dragover",e=>e.preventDefault());document.addEventListener("drop",e=>{e.preventDefault(),!e.target.closest("#drop-zone")&&cc(e.dataTransfer.files)});Be.addEventListener("dragover",e=>{e.preventDefault(),Be.classList.add("hover")});Be.addEventListener("dragleave",()=>Be.classList.remove("hover"));Be.addEventListener("drop",e=>{e.preventDefault(),Be.classList.remove("hover"),cc(e.dataTransfer.files)});var Et=null;function iv(){Et||(Et=document.createElement("input"),Et.type="file",Et.multiple=!0,Et.hidden=!0,Et.addEventListener("change",()=>{let e=Et.files;e&&e.length>0&&cc(e),Et.value=""}),document.body.append(Et)),Et.click()}Be.addEventListener("click",e=>{e.target.closest(".drop-prompt-action")&&iv()});var Nt=new Map,fh="deepview.advisories.proxyConsent";function hh(){try{return localStorage.getItem(fh)==="1"}catch{return!1}}function gh(){try{localStorage.setItem(fh,"1")}catch{}}function av(e){let t=new Map;if(!e||e.kind!=="stasis"||!e.bundle)return t;for(let[r,n]of e.bundle.modules){if(!r.includes("node_modules")||!n?.name||typeof n.version!="string"||!n.version)continue;let o=t.get(n.name);o||(o=new Set,t.set(n.name,o)),o.add(n.version)}return t}function lv(e){if(!e||e.kind!=="stasis"||!e.bundle)return!1;for(let[t,r]of e.bundle.modules)if(t.includes("node_modules")&&r?.name&&typeof r.version=="string"&&r.version)return!0;return!1}function mh(e,t){return!e||lc(e.name)!=="stasis"?!1:!t||t.integrity!==e.integrity?!0:lv(t)}function cv(e){let t=Object.create(null);for(let[r,n]of e)t[r]=[...n].toSorted();return t}async function pc(e,t){if(!e?.integrity||Nt.has(e.integrity)||!hh())return;let r=av(e);if(r.size===0){Nt.set(e.integrity,{state:"ok",byPackage:new Map,query:r});return}Nt.set(e.integrity,{state:"loading",query:r});let n=e.integrity;try{let o=await fetch("/api/npm-advisories",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(cv(r))});if(!o.ok){let l=`HTTP ${o.status}`;try{let d=await o.json();d&&typeof d.error=="string"&&d.error&&(l=`${d.error} (HTTP ${o.status})`)}catch{}Nt.set(n,{state:"error",reason:l,query:r}),t();return}let s=await o.json(),i=new Map;if(s&&typeof s=="object")for(let[l,d]of Object.entries(s)){if(!Array.isArray(d))continue;let u=d.filter(p=>p&&typeof p=="object"&&typeof p.title=="string"&&typeof p.severity=="string");u.length>0&&i.set(l,u)}Nt.set(n,{state:"ok",byPackage:i,query:r})}catch(o){Nt.set(n,{state:"error",reason:o?.message??"fetch-failed",query:r})}t()}async function bh(e,t){e?.integrity&&Nt.get(e.integrity)?.state==="error"&&(Nt.delete(e.integrity),await pc(e,t))}var dv={critical:0,high:1,moderate:2,low:3,info:4};function xi(e){return dv[e]??999}function uv(e){return e.charAt(0).toUpperCase()+e.slice(1)}function pv(){let e=typeof window>"u"?"":window.location.host;return c`<div class="bundle-advisories-consent"><div class="bundle-advisories-consent-card"><p class="bundle-advisories-consent-text">This bundle's dependency names and versions will be sent to the npm registry through a same-origin proxy (<span class="mono">${e}</span> → <span class="mono">registry.npmjs.org</span>) to look up published security advisories.</p><button type="button" class="bundle-advisories-consent-btn" data-advisories-consent>Confirm</button><p class="bundle-advisories-consent-note">This preference will be saved and reused for other bundles.</p></div></div>`}function yh(e){if(!e)return c`<div class="bundle-advisories-empty">Bundle not loaded yet.</div>`;if(e.kind!=="stasis"||!e.bundle)return c`<div class="bundle-advisories-empty">Advisories are only available for stasis bundles.</div>`;if(!hh())return pv();let t=Nt.get(e.integrity);if(!t||t.state==="loading")return c`<div class="bundle-advisories-empty">Loading advisories from npm registry…</div>`;if(t.state==="error")return c`<div class="bundle-advisories-empty is-error"><span>Failed to fetch advisories: ${t.reason}</span> <button type="button" class="bundle-advisories-retry" data-advisories-retry>Retry</button></div>`;let r=t.query.size,n=t.byPackage.size;if(n===0)return c`<div class="bundle-advisories"><div class="bundle-advisories-summary">No advisories for the ${r} ${r===1?"package":"packages"} in this bundle.</div></div>`;let o=[...t.byPackage.entries()].toSorted(([i,l],[d,u])=>{let p=Math.min(...l.map(h=>xi(h.severity))),f=Math.min(...u.map(h=>xi(h.severity)));return p!==f?p-f:i.localeCompare(d)}),s=[...t.byPackage.values()].reduce((i,l)=>i+l.length,0);return c`<div class="bundle-advisories"><div class="bundle-advisories-summary">${s} ${s===1?"advisory":"advisories"} across ${n} of ${r} ${r===1?"package":"packages"}</div><ul class="bundle-advisories-list">${o.map(([i,l])=>fv(i,l,t.query.get(i)))}</ul></div>`}function fv(e,t,r){let n=[...t].toSorted((s,i)=>{let l=xi(s.severity)-xi(i.severity);return l!==0?l:(s.title??"").localeCompare(i.title??"")}),o=r?[...r].toSorted():[];return c`<li class="bundle-advisories-section"><div class="bundle-advisories-section-header"><span class="bundle-advisories-section-name">${e}</span> ${o.length>0?c`<span class="bundle-advisories-section-versions">${o.map(s=>c`<span class="bundle-advisories-version-chip">${s}</span>`)}</span>`:g} <span class="bundle-advisories-section-count">${n.length} ${n.length===1?"advisory":"advisories"}</span></div><ul class="bundle-advisories-rows">${n.map(s=>bv(s))}</ul></li>`}function hv(e){if(typeof e!="string")return null;let t=/\/(GHSA-[a-z0-9-]+)(?:[/?#]|$)/iu.exec(e);return t?t[1]:null}var gv=c`<svg class="bundle-advisory-ghsa-icon" viewBox="0 0 16 16" width="11" height="11" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 13L13 3"/><path d="M5 3h8v8"/></svg>`;function mv(e){let t=/^CWE-(\d+)$/u.exec(e);if(!t)return c`<span>${e}</span>`;let r=`https://cwe.mitre.org/data/definitions/${t[1]}.html`;return c`<a class="bundle-advisory-cwe" href="${r}" target="_blank" rel="noopener noreferrer">${e}</a>`}function bv(e){let t=e.severity,r=e.title,n=typeof e?.cvss?.score=="number"?e.cvss.score.toFixed(1):"",o=typeof e?.cvss?.vectorString=="string"&&e.cvss.vectorString?e.cvss.vectorString:"",s=typeof e.vulnerable_versions=="string"?e.vulnerable_versions:null,i=typeof e.url=="string"&&/^https?:\/\//iu.test(e.url)?e.url:null,l=hv(i),d=Array.isArray(e.cwe)?e.cwe.filter(p=>typeof p=="string"):[],u=l&&i?c`<a class="bundle-advisory-ghsa" href="${i}" target="_blank" rel="noopener noreferrer">${l}${gv}</a>`:l?c`<span class="bundle-advisory-ghsa">${l}</span>`:g;return c`<li class="bundle-advisory-row"><div class="bundle-advisory-rail"><span class="${`bundle-advisory-severity sev-${t}`}">${uv(t)}</span> ${n?c`<span class="bundle-advisory-cvss-score">CVSS <span class="mono">${n}</span></span>`:g}</div><div class="bundle-advisory-body"><div class="bundle-advisory-header"><span class="bundle-advisory-title">${r}</span> ${u}</div><div class="bundle-advisory-subrow"><div class="bundle-advisory-meta">${s?c`<span>Affected <span class="mono">${s}</span></span>`:g} ${d.length>0?c`<span class="bundle-advisory-cwes">${d.map((p,f)=>c`${f===0?"":", "}${mv(p)}`)}</span>`:g}</div>${o?c`<div class="bundle-advisory-cvss-vector mono">${o}</div>`:g}</div></div></li>`}var Lo=null;function yv(e){let t=new Map;if(!e||e.kind!=="stasis"||!e.bundle)return t;for(let r of e.bundle.imports.values())for(let[n,o]of r){t.has(n)||t.set(n,new Set);for(let s of o.values())typeof s=="string"&&t.get(n).add(s)}return t}function wv(e){let t=He(e),r=yv(e),n=[...t.keys()],{stripped:o}=Qe(n),s=new Map(n.map((l,d)=>[l,o[d]])),i={};for(let[l,d]of t){let u=s.get(l),p=r.get(l);i[u]={imports:p?[...p].map(f=>s.get(f)).filter(Boolean):[],size:new TextEncoder().encode(d).byteLength}}return{tree:i,origToStripped:s}}async function oc(e){let t=He(e),r=new Map;for(let[n,o]of t)r.set(n,await Qu(o));return r}function xh(e){let t={inprogress:0,fixed:0,invalid:0,deleted:0};if(!e?.fileHashes)return t;let r=new Set;for(let n of e.fileHashes.values())if(!r.has(n)){r.add(n);for(let o of ro(n)){let s=a.triage.get(P(o))?.triage;s&&t[s]!==void 0&&t[s]++}}return t}function _n(e,t="graph"){if(!e||e.size===0)return new Map;let r=new Map;for(let[n,o]of e){let s=ro(o);if(s.length===0)continue;let i=s.filter(d=>{let u=a.triage.get(P(d))?.triage??null;return t==="issues"?u!=="invalid"&&u!=="deleted":u===a.shownTriage});if(i.length===0)continue;r.has(n)||r.set(n,[]);let l=r.get(n);for(let d of i)l.push(d)}return r}function _h(e){let{tree:t,origToStripped:r}=wv(e),n=Object.keys(t);if(n.length===0)return null;let o=null;if(e.fileHashes&&e.fileHashes.size>0){o=new Map;for(let[x,T]of e.fileHashes){let N=r.get(x);N!==void 0&&o.set(N,T)}}let s=_n(o),i=new Map,l=new Map,d=new Map,u=new Map;for(let[x,T]of s){let N={critical:0,high:0,medium:0,low:0,high_bug:0,bug:0,informational:0},Z=new Set,W=new Set,be=[];for(let ie of T){N[ie.severity]=(N[ie.severity]||0)+1,Z.add(ie.severity);let _e=a.triage.get(P(ie))?.color??"none";W.add(_e),be.push({severity:ie.severity,color:_e})}i.set(x,N),l.set(x,Z),d.set(x,W),u.set(x,be)}let p=ui(t,i),f=new Map;for(let[x,T]of r)f.set(T,x);let h=nr(e),b=h?new Map([...r].map(([x,T])=>[T,h.get(x)])):null,m=b?x=>b.get(x):null,y=Wf(n,m),v=C.splitOwnDirs&&y,w=x=>it(x,{splitOwnDirs:v,packageDir:m?.(x)}),k=new Set;for(let x of n)if(k.add(w(x)),k.size>=3)break;let E=k.size>=3,S=n;if(C.focusedPkg){let x=n.filter(T=>w(T)===C.focusedPkg);x.length>0?S=x:C.focusedPkg=null}return C.selected&&!Object.hasOwn(t,C.selected)&&(C.selected=null),{treeData:t,files:S,ownCounts:i,transitiveCounts:p,severitySets:l,colorSets:d,fileFindings:u,options:{pkgOf:w},strippedToOrig:f,canSplitOwnDirs:y,canPackagesView:E}}function Si(){if(!Lo)return;let e=bn();e&&e.refreshSidebar(Lo,{isBundleContext:!0})}function Ci(){if(!Lo)return;let e=bn();e&&e.refreshTopPkgs(Lo)}function Sh(e){Lo=e}function vv(e){let t=new Map,r=0;for(let{path:o,size:s,pkgDir:i}of e){if(typeof s!="number"||s<=0)continue;let l=it(o,{packageDir:i});t.set(l,(t.get(l)??0)+s),r+=s}if(r===0)return g;let n=[...t.entries()].toSorted((o,s)=>s[1]-o[1]);return c`<div class="bundles-dist"><div class="bundles-dist-bar" aria-hidden="true">${X(n,([o])=>o,([o,s])=>c`<span class="bundles-dist-seg" style="${pe({flexGrow:s,background:st(o)})}" data-tooltip="${o==="__own__"?g:`${o}: ${ee(s)}`}"></span>`)}</div><ul class="bundles-dist-list">${X(n,([o])=>o,([o,s])=>{let i=(s/r*100).toFixed(1),l=o==="__own__"?"own source":o,d=st(o);return c`<li><span class="bundles-dist-dot" style="${pe({background:d})}"></span> <span class="bundles-dist-pkg" data-tooltip="${o==="__own__"?g:o}">${l}</span> <span class="bundles-dist-bar-row" aria-hidden="true"><span class="bundles-dist-bar-fill" style="${pe({width:`${i}%`,background:d})}"></span> </span><span class="bundles-dist-size">${ee(s)}</span> <span class="bundles-dist-percent">${i}%</span></li>`})}</ul></div>`}function wh(e,t,r,n,o){let{prefix:s,stripped:i}=Qe(r),l=S=>o?.get(r[S]),d=new Set;for(let S=0;S<i.length;S++)d.add(it(i[S],{packageDir:l(S)}));let u=i.map((S,x)=>x).toSorted((S,x)=>i[S].localeCompare(i[x])),p=i.map((S,x)=>({path:S,size:n[x],pkgDir:l(x)})),f=vv(p),h=f===g?c`<p class="bundles-overview-col-empty">No size information for this bundle's sources.</p>`:f,b={critical:0,high:0,medium:0,low:0,high_bug:0,bug:0,informational:0},m=0,y=new Map;if(a.bundleDetails?.fileHashes){let S=_n(a.bundleDetails.fileHashes,"issues");for(let x of S.values())for(let T of x){b[T.severity]!==void 0&&b[T.severity]++,m++;for(let N of no(T.fileHash,T))y.set(N,(y.get(N)??0)+1)}}let v=[...y.keys()].toSorted(),w=ke.filter(S=>b[S]>0).map(S=>c`<span class="${`tree-count-chip ${S}`}">${b[S]} ${S.replaceAll("_"," ")}</span>`),k=r.length>0?c`<ul class="bundles-sources-list">${u.map(S=>{let x=r[S],T=i[S],N=n[S];return c`<li><button type="button" class="bundles-source-row" data-bundle-view-source="${x}" data-tooltip="${x}"><span class="bundles-source-path">${T}</span> ${N==null?g:c`<span class="bundles-source-size">${ee(N)}</span>`}</button></li>`})}</ul>`:c`<p class="bundles-overview-col-empty">No source files in this bundle.</p>`,E=v.length>0?c`<ul class="bundles-reports-list">${v.map(S=>{let x=re[Xe(S)]??re.default,T=y.get(S)??0;return c`<li><button type="button" class="report-chip bundles-report-chip" data-tooltip="${S}" data-bundle-issue-report="${S}">${me(x)}<span class="report-chip-label">${Me(S)}</span> <span class="bundles-report-count">${T} ${T===1?"issue":"issues"}</span></button></li>`})}</ul>`:c`<p class="bundles-overview-col-empty">No matching reports indexed yet.</p>`;return c`<div class="bundles-overview"><div class="bundles-overview-summary"><div class="bundles-detail-meta-row">${e}<dl class="bundles-detail-meta">${t}<dt>Sources</dt><dd>${r.length}</dd>${s?c`<dt>Prefix</dt><dd class="mono">${s}</dd>`:g}</dl></div>${m>0?c`<div class="bundles-issue-summary tree-count-chips">${w}</div>`:g}</div><div class="bundles-overview-columns"><section class="bundles-overview-col"><header class="bundles-overview-col-head">Packages <span class="bundles-overview-col-count">${d.size}</span></header><div class="bundles-overview-col-body">${h}</div></section><section class="bundles-overview-col"><header class="bundles-overview-col-head">Files <span class="bundles-overview-col-count">${r.length}</span></header><div class="bundles-overview-col-body bundles-overview-col-body--list">${k}</div></section>${v.length>0?c`<section class="bundles-overview-col"><header class="bundles-overview-col-head">Reports <span class="bundles-overview-col-count">${v.length}</span></header><div class="bundles-overview-col-body bundles-overview-col-body--list">${E}</div></section>`:g}</div></div>`}var fc=new Map,hc=new Set,kv=c`<svg viewBox="0 0 16 16" width="11" height="11" aria-hidden="true"><rect x="3" y="2.5" width="8" height="10" rx="1" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linejoin="round"/><rect x="5.5" y="5" width="8" height="9" rx="1" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linejoin="round"/></svg>`,Dt=null;function Po(){queueMicrotask(()=>{document.querySelector(".bundle-code-rail-body .bundle-code-tree-link.current")?.scrollIntoView({block:"nearest"})})}function Mr(e){for(let t of ke)for(let r of e)if(r.severity===t)return t;return e[0]?.severity??null}function mc(e,t,r,n,o=null){let s=e.split(`
48
+ `).length,i=String(s).length,l=hi(t),d=`${r??""}\0${t}`;l&&!fc.has(d)&&!hc.has(d)&&(hc.add(d),(async()=>{let p=await gi(e,l);fc.set(d,p??null),hc.delete(d),a.bundleSourceFile===t&&$()})());let u=fc.get(d);return c`<div class="bundle-source-lines" style="${pe({"--lineno-width":`${i}ch`})}"><aside class="bundle-source-lineno-col" aria-hidden="true">${Array.from({length:s},(p,f)=>{let h=f+1,b=n.get(h),m=b?Mr(b.map(v=>v.f)):null,y=b&&a.bundleSourceFindingIdx!=null&&b.some(v=>v.idx===a.bundleSourceFindingIdx);return c`<div class="${R({"bundle-source-lineno-row":!0,"is-match":o?.has(h)??!1})}" data-line="${h}">${b?c`<button type="button" class="${R({"bundle-source-dot":!0,[`sev-${m}`]:!0,active:y})}" data-bundle-source-finding="${b[0].idx}" title="${`${b.length} ${b.length===1?"issue":"issues"} on line ${h}`}" aria-label="${`${b.length} issues on line ${h}`}"></button>`:c`<span class="bundle-source-dot-placeholder"></span>`} <span class="bundle-source-lineno-num">${h}</span></div>`})}</aside><pre class="bundle-source-code"><code class="${l?`language-${l}`:""}">${typeof u=="string"?me(u):e}</code></pre></div>`}function bc(e){let t=a.bundleSourceFindingIdx;if(t==null)return g;let r=e[t];if(!r)return g;let n=r.fileHash?no(r.fileHash,r):[],o=a.triage.get(P(r))?.triage,s=o==="fixed"?"Fixed":o==="inprogress"?"In progress":null,i=Ar(r),l=Th(r.line);return c`<aside class="bundle-source-panel"><header class="bundle-source-panel-bar"><span class="${`bundle-source-panel-sev sev-${r.severity}`}">${r.severity.replaceAll("_"," ")}</span> ${s?c`<span class="${`bundle-source-panel-triage triage-${o}`}">${s}</span>`:g} <button type="button" class="bundle-source-panel-close" data-action="bundle-source-panel-close" title="Close (Esc)" aria-label="Close finding details">×</button></header><div class="bundle-source-panel-body">${l||i?c`<div class="bundle-source-panel-line-row">${l?c`<span class="bundle-source-panel-line">${l}</span>`:g} ${i?c`<span class="bundle-source-panel-meta" title="${i}">${i}</span>`:g}</div>`:g}<div class="bundle-source-panel-desc">${Fr(r.description??"")}</div>${n.length>0?c`<div class="bundle-source-panel-reports"><div class="bundle-source-panel-reports-label">Reported by</div>${n.map(d=>{let u=re[Xe(d)]??re.default;return c`<button type="button" class="report-chip bundle-source-panel-report" title="${d}" data-bundle-issue-report="${d}">${me(u)}<span class="report-chip-label">${Me(d)}</span></button>`})}</div>`:g}</div></aside>`}function yc(e,t,r){let n=[],o=new Map;if(typeof r=="string"&&e?.fileHashes){let i=_n(e.fileHashes,"issues").get(t)??[];for(let l=0;l<i.length;l++){let d=i[l];n.push(d);let u=parseInt(d.line,10);Number.isFinite(u)&&u>0&&(o.has(u)||o.set(u,[]),o.get(u).push({f:d,idx:l}))}}return{fileFindings:n,lineFindings:o}}function Ch(){let e=a.bundleSourceFile;if(!e)return g;if(a.bundleDetailsTab==="code"||a.bundleDetailsTab==="search")return g;let r=He(a.bundleDetails).get(e),{fileFindings:n,lineFindings:o}=yc(a.bundleDetails,e,r);return c`<div class="bundle-source-overlay"><div class="${R({"bundle-source-modal":!0,"with-panel":a.bundleSourceFindingIdx!=null})}"><header class="bundle-source-bar"><div class="bundle-source-title" title="${e}">${e}</div><button type="button" class="bundle-source-close" data-action="bundle-source-close" title="Close source viewer (Esc)" aria-label="Close source viewer">×</button></header><div class="bundle-source-body"><div class="bundle-source-code-wrap">${typeof r=="string"?mc(r,e,a.bundleDetails?.integrity,o):c`<div class="bundle-source-empty">Source content not bundled.</div>`}</div>${bc(n)}</div></div></div>`}function Eh(e){let t={name:"",files:new Map,dirs:new Map};for(let r of e){let n=r.split("/"),o=t;for(let s=0;s<n.length-1;s++){let i=n[s],l=o.dirs.get(i);l||(l={name:i,files:new Map,dirs:new Map},o.dirs.set(i,l)),o=l}o.files.set(n.at(-1),r)}return t}var _i=new Map,vh=null;function $v(e,t){let r=0,n=null;if(!t||t.size===0)return{count:r,worst:n};let o=s=>{for(let i of s.files.values()){let l=t.get(i);if(!l||l.length===0)continue;r+=l.length;let d=Mr(l);(n===null||(Le[d]??0)>(Le[n]??0))&&(n=d)}for(let i of s.dirs.values())o(i)};return o(e),{count:r,worst:n}}function gc(e,t,r=0,n=null,o="",s=!1){let i=[...e.dirs.entries()].toSorted(([f],[h])=>f.localeCompare(h)),l=[...e.files.entries()].toSorted(([f],[h])=>f.localeCompare(h)),d=f=>{if(!t)return!1;for(let h of f.files.values())if(h===t)return!0;for(let h of f.dirs.values())if(d(h))return!0;return!1},u=(f,h)=>s?!0:_i.has(f)?_i.get(f):r===0||d(h),p=f=>h=>{_i.set(f,!h.currentTarget.parentElement.open)};return c`<ul class="${R({"bundle-code-tree":!0,root:r===0})}">${X(i,([f])=>`${o}/${f}`,([f,h])=>{let b=o?`${o}/${f}`:f,m=$v(h,n);return c`<li class="bundle-code-tree-dir"><details ?open="${u(b,h)}"><summary @click="${p(b)}"><span class="bundle-code-tree-dirname">${f}</span> ${m.count>0?c`<span class="${`bundle-code-tree-count sev-${m.worst}`}" title="${`${m.count} ${m.count===1?"issue":"issues"} inside`}">${m.count}</span>`:g}</summary>${gc(h,t,r+1,n,b,s)}</details></li>`})} ${X(l,([,f])=>f,([f,h])=>{let b=n?.get(h),m=b&&b.length>0?Mr(b):null,y=b?.length??0;return c`<li class="bundle-code-tree-file"><button type="button" class="${R({"bundle-code-tree-link":!0,current:h===t})}" data-bundle-view-source="${h}" title="${h}"><span class="bundle-code-tree-name">${f}</span> ${y>0?c`<span class="${`bundle-code-tree-count sev-${m}`}" title="${`${y} ${y===1?"issue":"issues"}`}">${y}</span>`:g}</button></li>`})}</ul>`}function xv(e,t,r,n,o=""){if(!r)return gc(e,t,0,n);let s=r.toLowerCase(),i=[],l=h=>{for(let[,b]of h.dirs)l(b);for(let[,b]of h.files)(o&&b.startsWith(o)?b.slice(o.length):b).toLowerCase().includes(s)&&i.push(b)};if(l(e),i.length===0)return c`<div class="bundle-code-search-empty">No files match.</div>`;let d=o?i.map(h=>h.startsWith(o)?h.slice(o.length):h):i,u=new Map;for(let h=0;h<i.length;h++)u.set(d[h],i[h]);let p=Eh(d),f=h=>{let b=new Map;for(let[m,y]of h.files)b.set(m,u.get(y)??y);h.files=b;for(let m of h.dirs.values())f(m)};return f(p),gc(p,t,0,n,"",!0)}function _v(e,t,r,n=""){if(!t)return c`<div class="bundle-code-search-hint">Type to search across every source in this bundle.</div>`;let o=t.toLowerCase(),s=20,i=100,l=[],d=0;for(let[u,p]of e){if(typeof p!="string")continue;let f=[],h=p.split(`
49
+ `);for(let b=0;b<h.length;b++){let m=h[b];if(m.toLowerCase().includes(o)&&(f.push({ln:b+1,text:m}),d++,f.length>=s))break}if(f.length>0&&l.push({path:u,hits:f}),l.length>=i)break}return l.length===0?c`<div class="bundle-code-search-empty">No matches.</div>`:c`<div class="bundle-code-search-results"><div class="bundle-code-search-summary">${d} ${d===1?"hit":"hits"} in ${l.length} ${l.length===1?"file":"files"}</div>${l.map(({path:u,hits:p})=>{let f=n&&u.startsWith(n)?u.slice(n.length):u;return c`<div class="${R({"bundle-code-search-file":!0,current:u===r})}"><button type="button" class="bundle-code-search-file-name" data-bundle-view-source="${u}" title="${u}">${f}</button><ul class="bundle-code-search-hits">${p.map(h=>c`<li class="bundle-code-search-hit"><button type="button" class="bundle-code-search-hit-link" data-bundle-view-source="${u}" data-bundle-view-line="${h.ln}" data-bundle-view-scroll-block="start" title="${`${u}:${h.ln}`}"><span class="bundle-code-search-hit-ln">${h.ln}</span> <span class="bundle-code-search-hit-text mono">${h.text.slice(0,200)}</span></button></li>`)}</ul></div>`})}</div>`}function Sv(e,t,r,n=""){if(!e.fileHashes)return c`<div class="bundle-code-search-empty">Computing file hashes…</div>`;let o=_n(e.fileHashes,"issues");if(o.size===0)return c`<div class="bundle-code-search-empty">No issues match this bundle's files.</div>`;let s=t.toLowerCase(),i=[];for(let[l,d]of o)for(let u=0;u<d.length;u++){let p=d[u],f=p.description??"";s&&!l.toLowerCase().includes(s)&&!p.severity.includes(s)&&!p.severity.replaceAll("_"," ").includes(s)&&!f.toLowerCase().includes(s)||i.push({file:l,finding:p,fileIdx:u})}return i.sort((l,d)=>{let u=Le[l.finding.severity]??0,p=Le[d.finding.severity]??0;return p!==u?p-u:l.file.localeCompare(d.file)}),i.length===0?c`<div class="bundle-code-search-empty">No matches.</div>`:c`<div class="bundle-code-search-results"><div class="bundle-code-search-summary">${i.length} ${i.length===1?"issue":"issues"}</div><ul class="bundle-code-search-issues">${i.map(({file:l,finding:d,fileIdx:u})=>{let p=d.severity,f=n&&l.startsWith(n)?l.slice(n.length):l,h=l===r&&a.bundleSourceFindingIdx===u;return c`<li class="${R({"bundle-code-search-issue":!0,current:h})}"><button type="button" class="bundle-code-search-issue-link" data-bundle-view-source="${l}" data-bundle-view-finding-idx="${u}" data-bundle-view-line="${d.line??""}" title="${l}"><div class="bundle-code-search-issue-row"><span class="${`bundle-code-search-issue-sev sev-${p}`}">${p.replaceAll("_"," ")}</span> <span class="bundle-code-search-issue-path mono">${f}${d.line?`:${d.line}`:""}</span></div><div class="bundle-code-search-issue-desc">${Fr(d.description??"")}</div></button></li>`})}</ul></div>`}function kh(e,t,r){let n=null,o=-1,s=0;for(let[d,u]of r){if(typeof t.get(d)!="string")continue;let p=Le[Mr(u)]??0;(p>o||p===o&&u.length>s||p===o&&u.length===s&&(n===null||d.localeCompare(n)<0))&&(n=d,o=p,s=u.length)}if(n)return n;if(e.kind==="stasis"&&e.bundle){for(let d of e.bundle.entries)if(typeof t.get(d)=="string")return d}let i=null,l=-1;for(let[d,u]of t)typeof u=="string"&&u.length>l&&(i=d,l=u.length);return i}function Cv(e){if(!e||!e.json&&!e.bundle)return g;let t=He(e);if(t.size===0)return c`<div class="bundle-code-empty">This bundle doesn't carry any source content.</div>`;vh!==a.selectedBundle&&(_i.clear(),vh=a.selectedBundle);let r=[...t.keys()].toSorted(),{prefix:n,stripped:o}=Qe(r),s=new Map;for(let w=0;w<r.length;w++)s.set(o[w],r[w]);let i=Eh(o),l=w=>{let k=new Map;for(let[E,S]of w.files)k.set(E,s.get(S)??S);w.files=k;for(let E of w.dirs.values())l(E)};l(i);let d=e.fileHashes?_n(e.fileHashes,"issues"):new Map,u=a.bundleSourceFile;if(Dt&&(Dt.bundle!==a.selectedBundle||u&&u!==Dt.path)&&(Dt=null),!u)u=kh(e,t,d),u&&(a.bundleSourceFile=u,Dt={bundle:a.selectedBundle,path:u,hadIssues:d.size>0},Po());else if(Dt&&!Dt.hadIssues&&d.size>0){Dt.hadIssues=!0;let w=kh(e,t,d);w&&w!==u&&(u=w,a.bundleSourceFile=w,a.bundleSourceFindingIdx=null,Dt.path=w,Po())}let p=u?t.get(u):null,{fileFindings:f,lineFindings:h}=yc(e,u,p),m=d.size>0?["files","code","issues"]:["files","code"],y=m.includes(a.bundleCodeSearchMode)?a.bundleCodeSearchMode:"files",v=a.bundleCodeSearchQuery;return c`<div class="bundle-code-view"><aside class="bundle-code-rail"><div class="bundle-code-rail-head"><span class="bundle-code-rail-label">Files</span> <span class="bundle-code-rail-count">${r.length}</span></div>${n?c`<div class="bundle-code-rail-prefix mono" title="${n}">${n}</div>`:g}<bundle-code-search .modes="${m}"></bundle-code-search><div class="bundle-code-rail-body">${Zl(y,[["files",()=>xv(i,u,v,d,n)],["code",()=>_v(t,v,u,n)],["issues",()=>Sv(e,v,u,n)]])}</div></aside><div class="${R({"bundle-code-main":!0,"with-panel":a.bundleSourceFindingIdx!=null})}">${u?Ev(e,u,p,f,h):c`<div class="bundle-code-placeholder">Pick a file from the tree to view its source.</div>`}</div></div>`}function Ev(e,t,r,n,o){let s=typeof r=="string"?r.split(`
50
+ `).length:0,i=typeof r=="string"?new TextEncoder().encode(r).byteLength:0,l=n.map((d,u)=>({idx:u,line:parseInt(d.line,10)||0})).toSorted((d,u)=>d.line-u.line||d.idx-u.idx);return c`<header class="bundle-code-main-bar"><span class="bundle-code-main-path mono" title="${t}">${t}</span> <button type="button" class="bundle-code-copy-path" data-copy-path="${t}" title="Copy file path" aria-label="Copy file path">${kv}</button> <span class="bundle-code-main-spacer"></span> ${typeof r=="string"?c`<span class="bundle-code-main-stats">${s.toLocaleString()} ${s===1?"line":"lines"} · ${ee(i)}</span>`:g} ${n.length>0?c`<span class="bundle-code-main-issues" data-bundle-code-issue-order="${JSON.stringify(l)}"><span class="${`bundle-code-tree-count sev-${Mr(n)}`}" title="${`${n.length} ${n.length===1?"issue":"issues"} in this file`}">${n.length}</span> <button type="button" class="bundle-code-issue-step" data-bundle-code-issue-step="-1" title="Previous issue" aria-label="Previous issue">‹</button> <button type="button" class="bundle-code-issue-step" data-bundle-code-issue-step="1" title="Next issue" aria-label="Next issue">›</button></span>`:g}</header><div class="bundle-code-main-body"><div class="bundle-source-code-wrap">${typeof r=="string"?mc(r,t,e.integrity,o):c`<div class="bundle-source-empty">Source content not bundled.</div>`}</div>${bc(n)}</div>`}var Av=5e3,Tv=500,Iv=400,$h=50;function Rv(e){return e<=5?8:e<=15?6:e<=40?4:e<=120?3:2}function Fv(e,t){let r=t?"gu":"giu",n=t?"g":"gi";try{return{re:new RegExp(e,r)}}catch{try{return{re:new RegExp(e,n)}}catch(o){return{error:o.message}}}}function Ah(e,t,r){if(t){let s=Fv(e,r);if(s.error)return{error:s.error};let{re:i}=s;return{ranges(l){i.lastIndex=0;let d=[],u;for(;(u=i.exec(l))!==null;){if(u[0].length===0){i.lastIndex++;continue}if(d.push([u.index,u.index+u[0].length]),d.length>=$h)break}return d}}}let n=r?e:e.toLowerCase(),o=n.length;return{ranges(s){let i=r?s:s.toLowerCase(),l=[],d=0,u;for(;(u=i.indexOf(n,d))!==-1&&(l.push([u,u+o]),d=u+o,!(l.length>=$h)););return l}}}function Bv(e,t,r){let n=[];for(let o of e){let s=Math.max(1,o.ln-r),i=Math.min(t,o.ln+r),l=n.at(-1);l&&s<=l.end+1?l.end=Math.max(l.end,i):n.push({start:s,end:i})}return n}function Mv(e,t,r){if(e.length<=r)return{text:e,ranges:t,clipped:!1};let n=t.length>0?t[0][0]:0,o=n>r-60?Math.max(0,n-60):0,s=e.slice(o,o+r);if(o===0)return{text:s,ranges:t,clipped:!1};let i=[];for(let[l,d]of t){let u=l-o,p=d-o;p<=0||u>=s.length||i.push([Math.max(0,u),Math.min(s.length,p)])}return{text:s,ranges:i,clipped:!0}}function Lv(e,t){if(t.length===0)return e;let r=[],n=0;for(let[o,s]of t){let i=Math.max(n,Math.min(o,e.length)),l=Math.max(i,Math.min(s,e.length));l<=i||(i>n&&r.push(e.slice(n,i)),r.push(c`<mark class="bundle-search-mark">${e.slice(i,l)}</mark>`),n=l)}return n<e.length&&r.push(e.slice(n)),r}function Pv(e,t,r){let n=Mv(e,r??[],Iv);return c`<div class="${R({"bundle-search-line":!0,"is-match":r!=null})}"><span class="bundle-search-lineno">${t}</span> <span class="bundle-search-code">${n.clipped?c`<span class="bundle-search-clip">…</span>`:g}${Lv(n.text,n.ranges)}</span></div>`}function Ov(e,t,r,n,o){let{start:s,end:i}=r,l=s;for(let p=s;p<=i;p++)if(n.has(p)){l=p;break}let d=String(i).length,u=[];for(let p=s;p<=i;p++)u.push(Pv(t[p-1]??"",p,n.get(p)??null));return c`${o?c`<div class="bundle-search-gap" aria-hidden="true"></div>`:g} <button type="button" class="bundle-search-snippet" style="${pe({"--bundle-search-lineno-w":`${d}ch`})}" data-bundle-view-source="${e}" data-bundle-view-line="${l}" data-bundle-view-scroll-block="center" title="${`${e}:${l}`}">${u}</button>`}function Nv(e,t,r){let{path:n,lines:o,hits:s}=e,i=t&&n.startsWith(t)?n.slice(t.length):n,l=Bv(s,o.length,r),d=new Map(s.map(f=>[f.ln,f.ranges])),u=s[0].ln,p=n===a.bundleSourceFile;return c`<section class="${R({"bundle-search-file":!0,current:p})}"><header class="bundle-search-file-head"><button type="button" class="bundle-search-file-name mono" data-bundle-view-source="${n}" data-bundle-view-line="${u}" data-bundle-view-scroll-block="center" title="${n}">${i}</button> <span class="bundle-search-file-count">${s.length} ${s.length===1?"match":"matches"}</span></header><div class="bundle-search-snippets">${l.map((f,h)=>Ov(n,o,f,d,h>0))}</div></section>`}function Dv(e,t,r,n,o){if(!t)return c`<div class="bundle-search-results"><div class="bundle-search-hint">Search across every source in this bundle. Each match shows the surrounding lines for context — fewer matches get more context. Toggle <span class="bundle-search-hint-kbd">Aa</span> for case-sensitive and <span class="bundle-search-hint-kbd">.*</span> for regular-expression matching.</div></div>`;let s=Ah(t,r,n);if(s.error)return c`<div class="bundle-search-results"><div class="bundle-search-error"><span class="bundle-search-error-label">Invalid regular expression</span> <span class="bundle-search-error-msg mono">${s.error}</span></div></div>`;let i=[...e.keys()].toSorted(),{prefix:l}=Qe(i),d=[],u=0,p=!1;for(let b of i){let m=e.get(b);if(typeof m!="string")continue;let y=m.split(`
51
+ `),v=[];for(let w=0;w<y.length;w++){let k=s.ranges(y[w]);if(k.length!==0&&(v.push({ln:w+1,ranges:k}),u++,u>=Av)){p=!0;break}}if(v.length>0&&d.push({path:b,lines:y,hits:v}),p)break;if(d.length>=Tv){p=!0;break}}if(d.length===0)return c`<div class="bundle-search-results"><div class="bundle-search-empty">No matches.</div></div>`;let f=o?Rv(u):0,h=d.length;return c`<div class="bundle-search-results"><div class="bundle-search-summary"><span>${u}${p?"+":""} ${u===1?"match":"matches"} in ${h}${p?"+":""} ${h===1?"file":"files"}</span> ${l?c`<span class="bundle-search-summary-prefix mono" title="${l}">${l}</span>`:g} ${p?c`<span class="bundle-search-summary-more">results capped — refine to narrow</span>`:g}</div>${X(d,b=>b.path,b=>Nv(b,l,f))}</div>`}function zv(e,t,r,n){if(!t||typeof e!="string")return null;let o=Ah(t,r,n);if(o.error)return null;let s=new Set,i=e.split(`
52
+ `);for(let l=0;l<i.length;l++)o.ranges(i[l]).length>0&&s.add(l+1);return s}function Uv(e,t,r){let n=a.bundleSourceFile;if(!n)return g;let o=t.get(n),{fileFindings:s,lineFindings:i}=yc(e,n,o);return c`<aside class="bundle-search-side"><header class="bundle-source-bar"><div class="bundle-source-title" title="${n}">${n}</div><button type="button" class="bundle-source-close" data-action="bundle-source-close" title="Close source viewer (Esc)" aria-label="Close source viewer">×</button></header><div class="bundle-source-body"><div class="bundle-source-code-wrap">${typeof o=="string"?mc(o,n,e.integrity,i,r):c`<div class="bundle-source-empty">Source content not bundled.</div>`}</div>${bc(s)}</div></aside>`}function Hv(e){if(!e||!e.json&&!e.bundle)return g;let t=He(e);if(t.size===0)return c`<div class="bundle-search-view"><div class="bundle-code-empty">This bundle doesn't carry any source content.</div></div>`;let r=a.bundleSearchQuery,n=a.bundleSearchRegex,o=a.bundleSearchCase,s=null;if(a.bundleSourceFile){let l=zv(t.get(a.bundleSourceFile),r,n,o);l&&l.size===0?(a.bundleSourceFile=null,a.bundleSourceFindingIdx=null):s=l}let i=a.bundleSearchContext;return c`<div class="bundle-search-view"><div class="bundle-search-bar-row"><bundle-search></bundle-search><button type="button" class="${R({"bundle-search-context-toggle":!0,on:i})}" data-bundle-search-context aria-pressed="${String(i)}" aria-label="Toggle context lines"><span>Context</span><span class="bundle-search-switch" aria-hidden="true"></span></button></div><div class="bundle-search-main">${Dv(t,r,n,o,i)} ${Uv(e,t,s)}</div></div>`}function Wv(e){let t=mh(e,a.bundleDetails);a.bundleDetailsTab==="advisories"&&!t&&(a.bundleDetailsTab="overview");let r=(a.bundles?.length??0)>=2;a.bundleDetailsTab==="compare"&&!r&&(a.bundleDetailsTab="overview");let n=a.bundleDetailsTab,o=n==="overview",s=a.bundleDetails,i=!!(s&&s.integrity===e.integrity),l=i&&!s.error&&!!(s.json||s.bundle);return n==="advisories"&&t&&l&&pc(s,$).catch(()=>{}),c`<div class="bundles-view bundles-slide-view"><header class="bundles-slide-bar"><span class="bundles-slide-icon" aria-hidden="true">${me(yn)}</span><div class="bundles-slide-title"><div class="bundles-slide-name">${e.name}</div></div><div class="bundles-slide-tabs" role="tablist">${t?c`<button type="button" class="${R({"bundles-tab":!0,active:n==="advisories"})}" data-bundle-tab="advisories" aria-selected="${String(n==="advisories")}" role="tab">Advisories</button>`:g} <button type="button" class="${R({"bundles-tab":!0,active:n==="issues"})}" data-bundle-tab="issues" aria-selected="${String(n==="issues")}" role="tab">Issues</button> <button type="button" class="${R({"bundles-tab":!0,active:n==="terminal"})}" data-bundle-tab="terminal" aria-selected="${String(n==="terminal")}" role="tab">Terminal</button> <button type="button" class="${R({"bundles-tab":!0,active:n==="treemap"})}" data-bundle-tab="treemap" aria-selected="${String(n==="treemap")}" role="tab">Treemap</button> <button type="button" class="${R({"bundles-tab":!0,active:n==="graph"})}" data-bundle-tab="graph" aria-selected="${String(n==="graph")}" role="tab">Graph</button> <button type="button" class="${R({"bundles-tab":!0,active:n==="code"})}" data-bundle-tab="code" aria-selected="${String(n==="code")}" role="tab">Code</button> <button type="button" class="${R({"bundles-tab":!0,active:n==="search"})}" data-bundle-tab="search" aria-selected="${String(n==="search")}" role="tab">Search</button> ${r?c`<button type="button" class="${R({"bundles-tab":!0,active:n==="compare"})}" data-bundle-tab="compare" aria-selected="${String(n==="compare")}" role="tab">Compare</button>`:g} <button type="button" class="${R({"bundles-tab":!0,active:o})}" data-bundle-tab="overview" aria-selected="${String(o)}" role="tab">Overview</button></div></header><div class="${R({"bundles-slide-body":!0,"bundles-slide-body-overview":o})}">${o?Kv(e,s):l?Zl(n,[["terminal",()=>c`<div id="bundle-terminal-slot" class="bundle-terminal-slot"></div>`],["graph",()=>c`<div id="bundle-graph-slot" class="bundle-graph-slot"></div>`],["treemap",()=>c`<bundle-treemap .details="${s}"></bundle-treemap>`],["code",()=>Cv(s)],["search",()=>Hv(s)],["compare",()=>c`<bundle-compare .details="${s}" .integrity="${e.integrity}"></bundle-compare>`],["issues",()=>jv(s)],["advisories",()=>yh(s)]]):i?c`<div class="${R({"bundles-slide-placeholder":!0,"is-error":!!s.error})}">${s.error?`Failed to parse: ${s.error}`:"Bundle contents not parsed."}</div>`:c`<div class="bundles-slide-placeholder">Loading bundle…</div>`}</div></div>`}function Vv(e,t={}){if(!e)return g;let r=[];if(e.fileHash&&(r=no(e.fileHash,e)),r.length===0&&t.bucketKey&&(t.kind==="package"?r=Ha(t.bucketKey,e):t.kind==="repository"&&(r=Wa(t.bucketKey,e))),r.length===0)return g;let n=r.slice(0,2),o=r.length-n.length;return c`<div class="bundle-issue-reports">${n.map(s=>{let i=re[Xe(s)]??re.default;return c`<button type="button" class="report-chip" title="${s}" data-bundle-issue-report="${s}">${me(i)}<span class="report-chip-label">${Me(s)}</span></button>`})} ${o>0?c`<span class="bundle-issue-reports-more">, and ${o} more…</span>`:g}</div>`}function Th(e){if(e==null||e==="")return"";let t=String(e),r=t.indexOf("-");if(r>0){let o=parseInt(t.slice(0,r),10),s=parseInt(t.slice(r+1),10);return Number.isFinite(o)&&Number.isFinite(s)&&s>o?`Lines ${o}-${s}`:Number.isFinite(o)?`Line ${o}`:""}let n=parseInt(t,10);return Number.isFinite(n)?`Line ${n}`:""}function Mo(e,t){return c`<div class="bundle-issues-empty"><p class="bundle-issues-empty-primary">${e}</p>${t?c`<p class="bundle-issues-empty-hint">${t}</p>`:g}</div>`}function jv(e){if(!e||!e.json&&!e.bundle)return g;if(!e.fileHashes)return Mo("Computing file hashes\u2026","Hashing this bundle's sources so findings from your reports can be matched against them.");if(e.fileHashes.size===0)return Mo("This bundle doesn't carry any source content.","Issues are matched by source-file hash, so a bundle without inline sources has nothing to match findings against.");let t=_n(e.fileHashes,"issues");if(t.size===0){let r=Ua();if(r===0)return Mo("No issues match this bundle's files.","Issues are analyzer findings matched to this bundle by source-file hash. No hash-carrying findings are indexed yet \u2014 hash matching needs the analyzer's native JSON reports; drop one and any matches will appear here automatically.");let n=0;for(let o of e.fileHashes.values())n+=ro(o).length;return n>0?Mo("All matching issues are dismissed.",`${n} ${n===1?"finding matches":"findings match"} this bundle's files, but every one is triaged invalid or deleted.`):Mo("No issues match this bundle's files.",`None of the ${r.toLocaleString()} indexed ${r===1?"finding":"findings"} reference a source file in this bundle \u2014 matching compares exact file hashes, so findings from a different build of the same project won't line up.`)}return Oo(t,{kind:"bundle"})}function Oo(e,{kind:t,bucketKey:r}={}){let n=[...e.keys()],{prefix:o,stripped:s}=Qe(n),i=new Map(n.map((u,p)=>[u,s[p]])),l=[...e.entries()].toSorted(([u,p],[f,h])=>{let b=Le[Mr(p)]??0,m=Le[Mr(h)]??0;return m!==b?m-b:(i.get(u)??u).localeCompare(i.get(f)??f)}),d=[...e.values()].reduce((u,p)=>u+p.length,0);return c`<div class="bundle-issues"><div class="bundle-issues-summary">${d} ${d===1?"issue":"issues"} across ${e.size} ${e.size===1?"file":"files"} ${o?c`<span class="mono">${o}</span>`:g}</div><ul class="bundle-issues-list">${X(l,([u])=>u,([u,p])=>{let f=i.get(u)??u,h=[...p].toSorted((m,y)=>{let v=Le[m.severity]??0,w=Le[y.severity]??0;if(w!==v)return w-v;let k=parseInt(m.line,10)||0,E=parseInt(y.line,10)||0;return k-E}),b=t==="repository"&&r?`${/^https?:/iu.test(r)?r.replace(/\/$/u,""):`https://github.com/${r}`}/blob/HEAD/${u}`:null;return c`<li class="bundle-issues-file-group"><header class="bundle-issues-file-header">${t==="bundle"?c`<button type="button" class="bundle-issues-file-name mono" data-bundle-view-source="${u}" title="${u}">${f}</button>`:b?c`<a class="bundle-issues-file-name bundle-issues-file-name-link mono" href="${b}" target="_blank" rel="noopener" title="${u}">${f}</a>`:c`<span class="bundle-issues-file-name bundle-issues-file-name-static mono" title="${u}">${f}</span>`} <span class="bundle-issues-file-count">${p.length} ${p.length===1?"issue":"issues"}</span></header><ul class="bundle-issues-findings">${X(h,m=>m.id??`${u}\0${m.line??""}\0${m.severity??""}\0${m.description??""}`,m=>{let y=p.indexOf(m),v=m.severity,w=a.triage.get(P(m))?.triage,k=w==="fixed"||w==="invalid"||w==="deleted"?w.toUpperCase():w==="inprogress"?"In progress":null,E=c`<div class="bundle-issues-finding-head"><span class="${`bundle-issue-sev sev-${v}`}">${v.replaceAll("_"," ")}</span> ${(()=>{let S=Th(m.line);return S?c`<span class="bundle-issues-finding-line">${S}</span>`:g})()} ${k?c`<span class="${`bundle-issues-finding-triage triage-${w}`}">${k}</span>`:g} <span class="bundle-issues-finding-spacer"></span> ${Vv(m,{kind:t,bucketKey:r})}</div><div class="bundle-issues-finding-desc">${Fr(m.description??"")}</div>`;return c`<li class="bundle-issues-finding">${t==="bundle"?c`<button type="button" class="bundle-issues-finding-link" data-bundle-view-source="${u}" data-bundle-view-finding-idx="${y}" data-bundle-view-line="${m.line??""}" title="${u}">${E}</button>`:c`<div class="bundle-issues-finding-link bundle-issues-finding-static" title="${u}">${E}</div>`}</li>`})}</ul></li>`})}</ul></div>`}function Ih(e){let t=a.selectedBundle,r=t?e.find(n=>n.integrity===t):null;return r?Wv(r):c`<div class="bundles-view bundles-view-empty"><p class="bundles-empty-hint">${e.length===0?c`No bundles yet. Drop a <code>.map</code> sourcemap or a <code>.stasis.code.br</code> bundle to start.`:"Pick a bundle from the sidebar to open it."}</p></div>`}function Kv(e,t){let r=c`<dl class="bundles-detail-meta"><dt>Name</dt><dd>${e.name}</dd><dt>Integrity</dt><dd class="mono">${e.integrity}</dd>${t&&t.integrity===e.integrity?c`<dt>Size</dt><dd>${ee(t.size)}</dd>`:g}</dl>`;if(!t||t.integrity!==e.integrity)return c`<div class="bundles-overview"><div class="bundles-overview-summary">${r}</div></div>`;if(t.error)return c`<div class="bundles-overview"><div class="bundles-overview-summary">${r}</div><div class="bundles-overview-placeholder is-error">Failed to parse: ${t.error}</div></div>`;if(t.kind==="sourcemap"&&t.json){let n=t.json,o=n.sources??[],s=n.sourcesContent??[],i=o.map((d,u)=>typeof s[u]=="string"?new TextEncoder().encode(s[u]).byteLength:null),l=c`<dt>Version</dt><dd>${String(n.version??"?")}</dd>${n.file?c`<dt>Output</dt><dd class="mono">${n.file}</dd>`:g} ${n.sourceRoot?c`<dt>Source root</dt><dd class="mono">${n.sourceRoot}</dd>`:g} ${n.names?c`<dt>Names</dt><dd>${n.names.length}</dd>`:g}`;return wh(r,l,o,i,null)}if(t.kind==="stasis"&&t.bundle){let n=t.bundle,o=n.sources,s=[...o.keys()],i=new Set;for(let p of n.imports.keys()){let f=p.replace(/\s*\(with: .*\)\s*$/u,"");for(let h of f.split(", "))i.add(h)}let l=[...i].toSorted(),d=s.map(p=>{let f=o.get(p);return typeof f=="string"?new TextEncoder().encode(f).byteLength:null}),u=c`<dt>Version</dt><dd>${String(n.version)}</dd>${l.length>0?c`<dt>Resolution kinds</dt><dd>${l.join(", ")}</dd>`:g}`;return wh(r,u,s,d,nr(t))}return c`<div class="bundles-overview"><div class="bundles-overview-summary">${r}</div><div class="bundles-overview-placeholder">Bundle contents not parsed.</div></div>`}function Rh(){xt().catch(()=>{});let e=$t(),t={inprogress:0,fixed:0,invalid:0,deleted:0},r=[];for(let[h,b]of e){let m=[],y=[],v=new Map,w=new Set;for(let[k,E]of b.byVersion){let S=[],x=new Map;for(let T of E.findings){let N=a.triage.get(P(T))?.triage??null;N==="inprogress"?t.inprogress++:N==="fixed"?t.fixed++:N==="invalid"?t.invalid++:N==="deleted"&&t.deleted++,N===a.shownTriage&&(S.push(T),x.has(T.file)||x.set(T.file,[]),x.get(T.file).push(T))}if(S.length!==0){m.push([k,{findings:S,files:x,reports:E.reports}]);for(let T of S)y.push(T),v.has(T.file)||v.set(T.file,[]),v.get(T.file).push(T);for(let T of E.reports)w.add(T)}}m.length!==0&&(m.sort(([k],[E])=>ia(k,E)),r.push([h,{findings:y,files:v,reports:w,versions:m}]))}let n=a.selectedPackage,o=n?r.find(([h])=>h===n)??null:null,s=null;if(o){let h=o[1].versions,b=a.selectedPackageVersion;s=h.find(([m])=>m===b)??null,!s&&h.length===1&&(s=h[0])}let i=s?s[1]:o?o[1]:null;if(o&&a.packageDetailsTab==="issues")return Zv(o[0],i,s?s[0]:void 0);let l=a.packagesSearchQuery.trim().toLowerCase(),d=l?r.filter(([h])=>h.toLowerCase().includes(l)):r.slice();Xv(d,a.packagesSortBy);let u=r.reduce((h,[,b])=>h+b.findings.length,0),p=new Set;for(let[,h]of r)for(let b of h.reports)p.add(b);let f=o?"packages-layout open":"packages-layout";return c`<div class="${R({"packages-view":!0,"with-details":!!o})}"><header class="page-head"><div class="page-title"><h1>Packages</h1><div class="meta-row"><span>${d.length===r.length?c`${r.length} ${r.length===1?"package":"packages"}`:c`${d.length} of ${r.length} ${r.length===1?"package":"packages"}`}</span> ${u>0?c`<span>${u} ${u===1?"finding":"findings"} across ${p.size} ${p.size===1?"report":"reports"}</span>`:g}</div></div>${Yv(t)}</header>${r.length===0?c`<p style="color:var(--muted)">${e.size===0?"Indexing reports\u2026 this view populates as the OPFS scan finishes.":a.shownTriage?`No ${a.shownTriage} findings in any package.`:"No untriaged findings in any package."}</p>`:d.length===0?c`<p style="color:var(--muted)">No packages match "${a.packagesSearchQuery}".</p>`:c`<div class="${f}"><ul class="packages-list">${X(Gv(d),qv,h=>e0(h,n,a.selectedPackageVersion))}</ul>${o?c`<aside class="packages-details" id="packages-details"><header class="packages-details-bar"><span class="packages-details-label">Details</span> <button type="button" class="packages-details-close" data-deselect-package title="Close details" aria-label="Close details">×</button></header><div class="packages-details-body">${n0(o[0],i,s?s[0]:void 0)}</div></aside>`:g}</div>`}</div>`}function Gv(e){let t=[];for(let[r,n]of e){let o=n.versions;if(o.length<=1){let[d,u]=o[0];t.push({kind:"single",pkg:r,version:d,bucket:u,totalVersions:1});continue}let[s,i]=o[0],l=a.expandedPackages.has(r);if(t.push({kind:"latest",pkg:r,version:s,bucket:i,totalVersions:o.length,expanded:l}),l)for(let d=1;d<o.length;d++){let[u,p]=o[d];t.push({kind:"other",pkg:r,version:u,bucket:p,totalVersions:o.length})}}return t}function qv(e){return e.version===null?`${e.kind}:${e.pkg}`:`${e.kind}:${e.pkg}@${e.version}`}function Yv(e){return c`<div class="packages-toolbar"><entity-search kind="packages"></entity-search><entity-sort kind="packages"></entity-sort><triage-selector variant="packages" .counts="${e}" .states="${Jv}"></triage-selector></div>`}var Jv=["inprogress","fixed","invalid","deleted"];function Xv(e,t){let r=t==="name-asc"?(n,o)=>n[0].localeCompare(o[0]):t==="files-desc"?(n,o)=>o[1].files.size-n[1].files.size||n[0].localeCompare(o[0]):t==="reports-desc"?(n,o)=>o[1].reports.size-n[1].reports.size||n[0].localeCompare(o[0]):(n,o)=>o[1].findings.length-n[1].findings.length||n[0].localeCompare(o[0]);e.sort(r)}function Qv(e,t){let r={live:0,invalid:0,deleted:0};if(!e)return r;let n=t===void 0?e.files.values():e.byVersion.get(t)?.files.values()??[].values();for(let o of n)for(let s of o){let i=a.triage.get(P(s))?.triage??null;i==="invalid"?r.invalid++:i==="deleted"?r.deleted++:r.live++}return r}function Zv(e,t,r){let n=$t().get(e),o=Qv(n,r),s=a.packageSlideTriage??"live",i=n?Fh(n,e,s,r):new Map,l=[...i.values()].reduce((f,h)=>f+h.length,0),d=s==="live"?l===1?"issue":"issues":l===1?`${s} issue`:`${s} issues`,u=s==="live"?"No live issues for this package.":`No ${s} issues for this package.`,p=typeof r=="string"?` @ ${r}`:"";return c`<div class="packages-view packages-slide-view"><header class="bundles-slide-bar"><button type="button" class="bundles-slide-back" data-action="package-slide-back" title="Back to packages" aria-label="Back to packages">← Back</button><div class="bundles-slide-title"><div class="bundles-slide-name">${e}${p}</div><div class="bundles-slide-integrity">${l} ${d} · ${t.files.size} ${t.files.size===1?"file":"files"} · ${t.reports.size} ${t.reports.size===1?"report":"reports"}</div></div><slide-triage-tabs kind="package" .counts="${o}"></slide-triage-tabs></header><div class="bundles-slide-body">${i.size===0?c`<div class="bundle-issues-empty">${u}</div>`:Oo(i,{kind:"package",bucketKey:e})}</div></div>`}function e0(e,t,r){let{kind:n,pkg:o,version:s,bucket:i}=e,l={critical:0,high:0,medium:0,low:0,high_bug:0,bug:0,informational:0};for(let m of i.findings)l[m.severity]!==void 0&&l[m.severity]++;let d=ke.filter(m=>l[m]>0),u=st(o),f={selected:o===t&&t0(e,r),"packages-row-latest":n==="latest","packages-row-other":n==="other"},h=s===null?"":s,b=s===null?`Open issues for ${o}`:`Open issues for ${o}@${s}`;return c`<li class="${R(f)}" data-select-package="${o}" data-select-package-version="${h}"><span class="packages-dot" style="${pe({background:u})}"></span><div class="packages-row-text"><div class="packages-name-line"><span class="packages-name">${o}${s===null?g:c`<span class="packages-version">@${s}</span>`} </span>${n==="latest"?r0(o,e.expanded,e.totalVersions-1):g}</div><span class="packages-row-meta">${i.findings.length} ${i.findings.length===1?"finding":"findings"} · ${i.files.size} ${i.files.size===1?"file":"files"} · ${i.reports.size} ${i.reports.size===1?"report":"reports"}</span></div>${d.length>0?c`<div class="packages-row-chips">${d.map(m=>c`<span class="${`tree-count-chip ${m}`}" title="${m.replaceAll("_"," ")}">${l[m]}</span>`)}</div>`:g} <button type="button" class="packages-row-issues" data-package-row-issues="${o}" data-package-row-issues-version="${h}" aria-label="${b}">Issues →</button></li>`}function t0(e,t){return e.kind==="single"?!0:e.version===t}function r0(e,t,r){let n=t?"Hide":`+${r} ${r===1?"version":"versions"}`;return c`<button type="button" class="${R({"packages-row-expand":!0,expanded:t})}" data-package-expand="${e}" aria-expanded="${String(t)}" aria-label="${t?`Hide older versions of ${e}`:`Show older versions of ${e}`}" title="${t?"Hide older versions":`Show older versions (${r})`}"><span class="packages-row-expand-chevron" aria-hidden="true"></span> <span class="packages-row-expand-label">${n}</span></button>`}function n0(e,t,r){let n=$t().get(e),s=[...(n?Fh(n,e,"live",r):new Map).values()].reduce((i,l)=>i+l.length,0);return c`<div class="bundles-tabs" role="tablist"><button type="button" class="bundles-tab active" data-package-tab="overview" aria-selected="true" role="tab">Overview</button> <span class="bundles-tabs-spacer"></span> ${s>0?c`<button type="button" class="bundles-tab bundles-tab-action" data-package-tab="issues">Issues (${s}) →</button>`:g}</div>${o0(e,t,r)}`}function Fh(e,t,r="live",n){let o=new Map,s=n===void 0?e.files:e.byVersion.get(n)?.files??new Map;for(let[i,l]of s){let d=l.filter(f=>{let h=a.triage.get(P(f))?.triage??null;return r==="invalid"?h==="invalid":r==="deleted"?h==="deleted":h!=="invalid"&&h!=="deleted"});if(d.length===0)continue;let u=Bh(t,i);o.has(u)||o.set(u,[]);let p=o.get(u);for(let f of d)p.push(f)}return o}function o0(e,t,r){let n={critical:0,high:0,medium:0,low:0,high_bug:0,bug:0,informational:0};for(let f of t.findings)n[f.severity]!==void 0&&n[f.severity]++;let o=ke.filter(f=>n[f]>0),s=[...t.files.entries()].toSorted(([f,h],[b,m])=>m.length!==h.length?m.length-h.length:f.localeCompare(b)),i=[...t.reports].toSorted((f,h)=>f.localeCompare(h)),d=$t().get(e)?.repos,u=d&&d.size===1?[...d][0]:null,p=u?/^https?:/iu.test(u)?u:`https://github.com/${u}`:null;return c`<dl class="packages-detail-meta"><dt>Package</dt><dd class="mono">${e}</dd>${r?c`<dt>Version</dt><dd class="mono">${r}</dd>`:g} ${p?c`<dt>Repository</dt><dd class="mono"><a href="${p}" target="_blank" rel="noopener">${u}</a></dd>`:g}<dt>Findings</dt><dd>${t.findings.length}</dd><dt>Files</dt><dd>${t.files.size}</dd><dt>Reports</dt><dd>${t.reports.size}</dd></dl>${o.length>0?c`<div class="packages-detail-chips">${o.map(f=>c`<span class="${`tree-count-chip ${f}`}">${n[f]} ${f.replaceAll("_"," ")}</span>`)}</div>`:g}<h3 class="packages-detail-section">Reports</h3><ul class="packages-detail-reports">${i.map(f=>{let h=re[Xe(f)]??re.default;return c`<li><button type="button" class="packages-detail-report" title="${f}" data-package-report="${f}">${me(h)}<span class="packages-detail-report-label">${Me(f)}</span></button></li>`})}</ul><h3 class="packages-detail-section">Files</h3><ul class="packages-detail-files">${s.map(([f,h])=>{let b=Bh(e,f);return c`<li class="packages-detail-file"><span class="packages-detail-file-path mono" title="${f}">${b}</span> <span class="packages-detail-file-count">${h.length}</span></li>`})}</ul>`}function Bh(e,t){for(let r of["node_modules","dependencies"]){let n=`${r}/${e}/`,o=t.indexOf(n);if(o>=0)return t.slice(o+n.length)}return t.startsWith(`${e}/`)?t.slice(e.length+1):t}function at(e){if(!e)return"";let t=e.match(/github\.com\/([^/?#]+\/[^/?#]+?)(?:\.git)?(?:[/?#]|$)/iu);return t?t[1]:e}function Mh(){xt().catch(()=>{});let e=_r(),t={inprogress:0,fixed:0,invalid:0,deleted:0},r=[];for(let[p,f]of e){let h=[],b=new Map;for(let m of f.findings){let y=a.triage.get(P(m))?.triage??null;y==="inprogress"?t.inprogress++:y==="fixed"?t.fixed++:y==="invalid"?t.invalid++:y==="deleted"&&t.deleted++,y===a.shownTriage&&(h.push(m),b.has(m.file)||b.set(m.file,[]),b.get(m.file).push(m))}h.length>0&&r.push([p,{findings:h,files:b,reports:f.reports}])}let n=a.selectedRepository,o=n?r.find(([p])=>p===n)??null:null;if(o&&a.repositoryDetailsTab==="issues")return c0(o[0],o[1]);let s=a.repositoriesSearchQuery.trim().toLowerCase(),i=s?r.filter(([p])=>p.toLowerCase().includes(s)||at(p).toLowerCase().includes(s)):r.slice();a0(i,a.repositoriesSortBy);let l=r.reduce((p,[,f])=>p+f.findings.length,0),d=new Set;for(let[,p]of r)for(let f of p.reports)d.add(f);let u=o?"packages-layout open":"packages-layout";return c`<div class="${R({"packages-view":!0,"with-details":!!o})}"><header class="page-head"><div class="page-title"><h1>Repositories</h1><div class="meta-row"><span>${i.length===r.length?c`${r.length} ${r.length===1?"repository":"repositories"}`:c`${i.length} of ${r.length} ${r.length===1?"repository":"repositories"}`}</span> ${l>0?c`<span>${l} ${l===1?"finding":"findings"} across ${d.size} ${d.size===1?"report":"reports"}</span>`:g}</div></div>${s0(t)}</header>${r.length===0?c`<p style="color:var(--muted)">${e.size===0?"Indexing reports\u2026 this view populates as the OPFS scan finishes.":a.shownTriage?`No ${a.shownTriage} findings in any repository.`:"No untriaged findings in any repository."}</p>`:i.length===0?c`<p style="color:var(--muted)">No repositories match "${a.repositoriesSearchQuery}".</p>`:c`<div class="${u}"><ul class="packages-list">${X(i,([p])=>p,([p,f])=>d0(p,f,p===n))}</ul>${o?c`<aside class="packages-details" id="repositories-details"><header class="packages-details-bar"><span class="packages-details-label">Details</span> <button type="button" class="packages-details-close" data-deselect-repository title="Close details" aria-label="Close details">×</button></header><div class="packages-details-body">${u0(o[0],o[1])}</div></aside>`:g}</div>`}</div>`}function s0(e){return c`<div class="packages-toolbar"><entity-search kind="repositories"></entity-search><entity-sort kind="repositories"></entity-sort><triage-selector variant="packages" .counts="${e}" .states="${i0}"></triage-selector></div>`}var i0=["inprogress","fixed","invalid","deleted"];function a0(e,t){let r=t==="name-asc"?(n,o)=>at(n[0]).localeCompare(at(o[0])):t==="files-desc"?(n,o)=>o[1].files.size-n[1].files.size||at(n[0]).localeCompare(at(o[0])):t==="reports-desc"?(n,o)=>o[1].reports.size-n[1].reports.size||at(n[0]).localeCompare(at(o[0])):(n,o)=>o[1].findings.length-n[1].findings.length||at(n[0]).localeCompare(at(o[0]));e.sort(r)}function l0(e){let t={live:0,invalid:0,deleted:0};if(!e)return t;for(let r of e.files.values())for(let n of r){let o=a.triage.get(P(n))?.triage??null;o==="invalid"?t.invalid++:o==="deleted"?t.deleted++:t.live++}return t}function c0(e,t){let r=_r().get(e),n=l0(r),o=a.repositorySlideTriage??"live",s=r?Lh(r,o):new Map,i=[...s.values()].reduce((u,p)=>u+p.length,0),l=o==="live"?i===1?"issue":"issues":i===1?`${o} issue`:`${o} issues`,d=o==="live"?"No live issues for this repository.":`No ${o} issues for this repository.`;return c`<div class="packages-view packages-slide-view"><header class="bundles-slide-bar"><button type="button" class="bundles-slide-back" data-action="repository-slide-back" title="Back to repositories" aria-label="Back to repositories">← Back</button><div class="bundles-slide-title"><div class="bundles-slide-name">${at(e)}</div><div class="bundles-slide-integrity">${i} ${l} · ${t.files.size} ${t.files.size===1?"file":"files"} · ${t.reports.size} ${t.reports.size===1?"report":"reports"}</div></div><slide-triage-tabs kind="repository" .counts="${n}"></slide-triage-tabs></header><div class="bundles-slide-body">${s.size===0?c`<div class="bundle-issues-empty">${d}</div>`:Oo(s,{kind:"repository",bucketKey:e})}</div></div>`}function d0(e,t,r){let n={critical:0,high:0,medium:0,low:0,high_bug:0,bug:0,informational:0};for(let l of t.findings)n[l.severity]!==void 0&&n[l.severity]++;let o=ke.filter(l=>n[l]>0),s=st(e),i=at(e);return c`<li class="${r?"selected":""}" data-select-repository="${e}"><span class="packages-dot" style="${pe({background:s})}"></span><div class="packages-row-text"><span class="packages-name">${i}</span> <span class="packages-row-meta">${t.findings.length} ${t.findings.length===1?"finding":"findings"} · ${t.files.size} ${t.files.size===1?"file":"files"} · ${t.reports.size} ${t.reports.size===1?"report":"reports"}</span></div>${o.length>0?c`<div class="packages-row-chips">${o.map(l=>c`<span class="${`tree-count-chip ${l}`}" title="${l.replaceAll("_"," ")}">${n[l]}</span>`)}</div>`:g} <button type="button" class="packages-row-issues" data-repository-row-issues="${e}" aria-label="${`Open issues for ${i}`}">Issues →</button></li>`}function u0(e,t){let r=_r().get(e),o=[...(r?Lh(r):new Map).values()].reduce((s,i)=>s+i.length,0);return c`<div class="bundles-tabs" role="tablist"><button type="button" class="bundles-tab active" data-repository-tab="overview" aria-selected="true" role="tab">Overview</button> <span class="bundles-tabs-spacer"></span> ${o>0?c`<button type="button" class="bundles-tab bundles-tab-action" data-repository-tab="issues">Issues (${o}) →</button>`:g}</div>${p0(e,t)}`}function Lh(e,t="live"){let r=new Map;for(let[n,o]of e.files){let s=o.filter(i=>{let l=a.triage.get(P(i))?.triage??null;return t==="invalid"?l==="invalid":t==="deleted"?l==="deleted":l!=="invalid"&&l!=="deleted"});s.length>0&&r.set(n,s)}return r}function p0(e,t){let r={critical:0,high:0,medium:0,low:0,high_bug:0,bug:0,informational:0};for(let l of t.findings)r[l.severity]!==void 0&&r[l.severity]++;let n=ke.filter(l=>r[l]>0),o=[...t.files.entries()].toSorted(([l,d],[u,p])=>p.length!==d.length?p.length-d.length:l.localeCompare(u)),s=[...t.reports].toSorted((l,d)=>l.localeCompare(d)),i=/^https?:/iu.test(e)?e:`https://github.com/${e}`;return c`<dl class="packages-detail-meta"><dt>Repository</dt><dd class="mono"><a href="${i}" target="_blank" rel="noopener">${at(e)}</a></dd><dt>Findings</dt><dd>${t.findings.length}</dd><dt>Files</dt><dd>${t.files.size}</dd><dt>Reports</dt><dd>${t.reports.size}</dd></dl>${n.length>0?c`<div class="packages-detail-chips">${n.map(l=>c`<span class="${`tree-count-chip ${l}`}">${r[l]} ${l.replaceAll("_"," ")}</span>`)}</div>`:g}<h3 class="packages-detail-section">Reports</h3><ul class="packages-detail-reports">${s.map(l=>{let d=re[Xe(l)]??re.default;return c`<li><button type="button" class="packages-detail-report" title="${l}" data-package-report="${l}">${me(d)}<span class="packages-detail-report-label">${Me(l)}</span></button></li>`})}</ul><h3 class="packages-detail-section">Files</h3><ul class="packages-detail-files">${o.map(([l,d])=>c`<li class="packages-detail-file"><span class="packages-detail-file-path mono" title="${l}">${l}</span> <span class="packages-detail-file-count">${d.length}</span></li>`)}</ul>`}var No=new Map,Do=new Map,wc=new Set;function f0(e,t,r){let n=`${e}\0${t}`;if(Do.has(n)||wc.has(n))return;let o=hi(t);if(!o){Do.set(n,null);return}wc.add(n),(async()=>{let s=await gi(r,o);Do.set(n,s??null),wc.delete(n),a.focusCodeTick++,queueMicrotask($)})()}async function h0(e){let t=No.get(e);if(t&&(t.loading||t.sources))return;let r=(a.bundles??[]).find(n=>n.integrity===e);if(r){No.set(e,{sources:null,loading:!0,error:null});try{let n=await kn(e,r),o=He(n);No.set(e,{sources:o,loading:!1,error:n.error??null})}catch(n){No.set(e,{sources:null,loading:!1,error:n.message})}a.focusCodeTick++,queueMicrotask($),queueMicrotask(()=>{let n=I.querySelector(".focus-code-line-active");n&&n.scrollIntoView({block:"center",behavior:"instant"})})}}function Ph(e){if(!e)return null;let t=ze(e);if(!t.fileHash||!Array.isArray(t._bundleHashes)||t._bundleHashes.length===0)return null;let r=new Set(t._bundleHashes),n=Sr(t.fileHash).find(({integrity:u})=>r.has(u));if(!n)return null;let o=No.get(n.integrity);if(!o)return h0(n.integrity),{loading:!0};if(o.loading)return{loading:!0};if(!o.sources)return null;let s=o.sources.get(n.file);if(typeof s!="string")return null;f0(n.integrity,n.file,s);let i=`${n.integrity}\0${n.file}`,l=Do.has(i)?Do.get(i):void 0,d=parseInt(t.line,10);return{content:s,file:n.file,integrity:n.integrity,line:Number.isFinite(d)?d:null,highlighted:l,loading:!1}}var vc=class extends F{static styles=[...F.styles,B($e)];static properties={workspaceId:{type:String},items:{type:Array},_uploading:{state:!0},_errors:{state:!0},_done:{state:!0},_settled:{state:!0}};constructor(){super(),this.workspaceId="",this.items=[],this._uploading=!1,this._errors=[],this._done=!1,this._settled=!1}focusInitial(){this.renderRoot.querySelector('button[data-role="upload"]')?.focus()}_onClose=()=>this._finish({uploaded:[],failed:[]});_onCancel=()=>this._finish({uploaded:[],failed:[]});_onUpload=async()=>{if(this._uploading)return;this._uploading=!0,this._errors=[];let t=[],r=[];for(let n of this.items)try{let o;if(n.kind==="bundle")o=await Yp(this.workspaceId,n.identifier);else{let s=await vr(n.identifier);o=await Xs(this.workspaceId,n.identifier,s)}if(o.ok)t.push({kind:n.kind,identifier:n.identifier});else{let s=o.reason??"unknown";r.push({kind:n.kind,identifier:n.identifier,reason:s}),this._errors=[...this._errors,{label:Ze(n),reason:s}]}}catch(o){let s=o?.message??String(o);r.push({kind:n.kind,identifier:n.identifier,reason:s}),this._errors=[...this._errors,{label:Ze(n),reason:s}]}this._uploading=!1,this._done=!0,r.length===0&&this._finish({uploaded:t,failed:r})};_errorsSection(){return this._errors.length===0?g:c`<ul class="lwd-list" role="alert">${this._errors.map(t=>c`<li><strong>${t.label}</strong> — ${t.reason}</li>`)}</ul>`}render(){let t=this.items.length,r=t===1,n=this.items.filter(u=>u.kind==="report").length,o=t-n,s="items";o===0?s=r?"report":"reports":n===0&&(s=r?"bundle":"bundles");let i=r?c`Upload <strong>"${Ze(this.items[0])}"</strong> to the workspace's remote inventory?`:c`Upload <strong>${t}</strong> local ${s} to the workspace's remote inventory?`,l=r?g:c`<ul class="lwd-list">${this.items.map(u=>c`<li>${Ze(u)}${u.kind==="bundle"?c`<span class="lwd-kind-tag">bundle</span>`:g}</li>`)}</ul>`,d=this._uploading?r?"Uploading\u2026":`Uploading ${t} ${s}\u2026`:r?"Upload":`Upload ${t}`;return c`<dialog @close="${this._onClose}"><header><h3>Upload to remote</h3></header><p class="lwd-body">${i}</p>${l}<p class="nwd-note">End-to-end encrypted with the workspace key — only workspace members can decrypt the uploaded content.</p>${this._errorsSection()}<footer class="nwd-actions"><span class="nwd-spacer"></span> <button type="button" data-role="cancel" @click="${this._onCancel}" ?disabled="${this._uploading}">${this._done&&this._errors.length>0?"Close":"Cancel"}</button> ${this._done&&this._errors.length>0?g:c`<button type="button" data-role="upload" @click="${this._onUpload}" ?disabled="${this._uploading||t===0}">${d}</button>`}</footer></dialog>`}};customElements.define("sync-upload-dialog",vc);function Oh({workspaceId:e,items:t}={}){return Q("sync-upload-dialog",{workspaceId:e??"",items:Array.isArray(t)?[...t]:[]})}var kc=class extends F{static styles=[...F.styles,B($e)];static properties={workspaceId:{type:String},items:{type:Array},_running:{state:!0},_errors:{state:!0},_done:{state:!0},_settled:{state:!0}};constructor(){super(),this.workspaceId="",this.items=[],this._running=!1,this._errors=[],this._done=!1,this._settled=!1}focusInitial(){this.renderRoot.querySelector('button[data-role="download"]')?.focus()}_onClose=()=>this._finish({downloaded:[],failed:[]});_onCancel=()=>this._finish({downloaded:[],failed:[]});_onDownload=async()=>{if(this._running)return;this._running=!0,this._errors=[];let t=[],r=[];for(let n of this.items)try{if(n.kind==="bundle"){let l=await qp(this.workspaceId,n.identifier);if(!l.ok){let d=l.reason??"unknown";r.push({kind:"bundle",identifier:n.identifier,reason:d}),this._errors=[...this._errors,{label:Ze(n),reason:d}];continue}await Cr(n.identifier,this.workspaceId),t.push({kind:"bundle",identifier:n.identifier});continue}let o=await Gp(this.workspaceId,n.identifier);if(!o){r.push({kind:"report",identifier:n.identifier,reason:"not found in remote"}),this._errors=[...this._errors,{label:Ze(n),reason:"not found in remote"}];continue}let s;try{s=he(await wt(o.content))}catch{let l="remote payload is not gzipped UTF-8";r.push({kind:"report",identifier:n.identifier,reason:l}),this._errors=[...this._errors,{label:Ze(n),reason:l}];continue}let i=Ke(s);if(!i.recognized){let l="remote payload is not a recognized report format";r.push({kind:"report",identifier:n.identifier,reason:l}),this._errors=[...this._errors,{label:Ze(n),reason:l}];continue}await Qn(n.identifier,o.content),Je(n.identifier,i.count,i.source),await Bt(n.identifier,this.workspaceId),t.push({kind:"report",identifier:n.identifier})}catch(o){let s=o?.message??String(o);r.push({kind:n.kind,identifier:n.identifier,reason:s}),this._errors=[...this._errors,{label:Ze(n),reason:s}]}if(this._running=!1,this._done=!0,t.some(n=>n.kind==="report"))try{a.currentWorkspace===this.workspaceId&&await ir(this.workspaceId)}catch{}r.length===0&&this._finish({downloaded:t,failed:r})};_errorsSection(){return this._errors.length===0?g:c`<ul class="lwd-list" role="alert">${this._errors.map(t=>c`<li><strong>${t.label}</strong> — ${t.reason}</li>`)}</ul>`}render(){let t=this.items.length,r=t===1,n=this.items.filter(u=>u.kind==="report").length,o=t-n,s="items";o===0?s=r?"report":"reports":n===0&&(s=r?"bundle":"bundles");let i=r?c`Download <strong>"${Ze(this.items[0])}"</strong> from the workspace's remote inventory?`:c`Download <strong>${t}</strong> remote ${s} into this workspace?`,l=r?g:c`<ul class="lwd-list">${this.items.map(u=>c`<li>${Ze(u)}${u.kind==="bundle"?c`<span class="lwd-kind-tag">bundle</span>`:g}</li>`)}</ul>`,d=this._running?r?"Downloading\u2026":`Downloading ${t} ${s}\u2026`:r?"Download":`Download ${t}`;return c`<dialog @close="${this._onClose}"><header><h3>Download from remote</h3></header><p class="lwd-body">${i}</p>${l} ${this._errorsSection()}<footer class="nwd-actions"><span class="nwd-spacer"></span> <button type="button" data-role="cancel" @click="${this._onCancel}" ?disabled="${this._running}">${this._done&&this._errors.length>0?"Close":"Cancel"}</button> ${this._done&&this._errors.length>0?g:c`<button type="button" data-role="download" @click="${this._onDownload}" ?disabled="${this._running||t===0}">${d}</button>`}</footer></dialog>`}};customElements.define("sync-download-dialog",kc);function Nh({workspaceId:e,items:t}={}){return Q("sync-download-dialog",{workspaceId:e??"",items:Array.isArray(t)?[...t]:[]})}var Dh=`.rec-list{margin:.2rem 0 .55rem;padding:0;list-style:none;max-height:320px;overflow-y:auto}.rec-row{display:flex;align-items:center;gap:.5rem;padding:.28rem .15rem;font-size:.8rem;line-height:1.4;border-bottom:1px solid rgb(from var(--text) r g b / .06)}.rec-row:last-child{border-bottom:none}.rec-label{flex:1 1 auto;min-width:0;color:var(--text);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.rec-status{flex:0 0 auto;padding:0 .4rem;border-radius:4px;font-size:.68rem;font-weight:600;text-transform:uppercase;letter-spacing:.04em}.rec-status-checking{color:var(--muted)}.rec-status-good{color:var(--ok, #16a34a)}.rec-status-reuploaded{color:var(--accent, #2563eb)}.rec-status-failed,.rec-status-check-failed{color:var(--warning, #d97706)}.rec-status-missing{color:var(--critical, #dc2626)}.rec-summary{margin:.1rem 0 .2rem;color:var(--muted);font-size:.76rem;line-height:1.45}.rec-error{margin:.3rem 0 .2rem;color:var(--critical, #f87171);font-size:.76rem;line-height:1.4}
53
+ `;var m0={checking:"checking\u2026",good:"available",reuploaded:"re-uploaded",failed:"re-upload failed","check-failed":"check failed",missing:"missing"},$c=class extends F{static styles=[...F.styles,B($e),B(Dh)];static properties={workspaceId:{type:String},cloudCount:{type:Number},localFileNames:{type:Array},localBundles:{type:Array},_rows:{state:!0},_running:{state:!0},_ran:{state:!0},_error:{state:!0},_settled:{state:!0}};constructor(){super(),this.workspaceId="",this.cloudCount=0,this.localFileNames=[],this.localBundles=[],this._rows=[],this._running=!1,this._ran=!1,this._error=null,this._settled=!1}focusInitial(){this.renderRoot.querySelector('button[data-role="recheck"]')?.focus()}_result(){return{items:this._rows,counts:this._counts()}}_onClose=()=>this._finish(this._ran?this._result():null);_onCancel=()=>this._finish(this._ran?this._result():null);_counts(){let t={good:0,reuploaded:0,failed:0,"check-failed":0,missing:0};for(let r of this._rows)r.status in t&&(t[r.status]+=1);return t}_onRecheck=async()=>{if(!this._running){this._running=!0,this._error=null,this._rows=[];try{let{items:t}=await Jp(this.workspaceId,{onList:r=>{this._rows=r},onItem:r=>{this._rows=this._rows.map(n=>n.resourceTag===r.resourceTag?r:n)}});this._rows=t}catch(t){this._error=t?.message??String(t)}finally{this._running=!1,this._ran=!0}}};_downloadableItems(){let t=new Set(this.localFileNames),r=new Set(this.localBundles),n=[];for(let o of this._rows)o.status!=="good"||!o.identifier||(o.kind==="report"&&!t.has(o.identifier)?n.push({kind:"report",identifier:o.identifier}):o.kind==="bundle"&&!r.has(o.identifier)&&n.push({kind:"bundle",identifier:o.identifier,label:o.label}));return n}_onDownload=async()=>{let t=this._downloadableItems();t.length!==0&&await Nh({workspaceId:this.workspaceId,items:t})};_rowsSection(){return this._rows.length===0?this._running?c`<p class="lwd-body">Fetching remote listing…</p>`:g:c`<ul class="rec-list">${this._rows.map(t=>c`<li class="rec-row"><span class="rec-label">${t.label}${t.kind==="bundle"?c`<span class="lwd-kind-tag">bundle</span>`:g}</span> <span class="${`rec-status rec-status-${t.status}`}" title="${t.detail??g}">${m0[t.status]??t.status}</span></li>`)}</ul>`}_summarySection(){if(!this._ran||this._rows.length===0)return g;let t=this._counts(),r=[];return t.good&&r.push(`${t.good} available`),t.reuploaded&&r.push(`${t.reuploaded} re-uploaded`),t.failed&&r.push(`${t.failed} failed`),t["check-failed"]&&r.push(`${t["check-failed"]} check failed`),t.missing&&r.push(`${t.missing} missing`),r.length>0?c`<p class="rec-summary" role="status" aria-live="polite">${r.join(" \xB7 ")}</p>`:g}render(){let t=this.cloudCount===1?"":"s",r=this._ran?g:c`<p class="lwd-body">Re-check ${this.cloudCount>0?c`the <strong>${this.cloudCount}</strong>`:g}remote object${t} for this workspace. Each is re-fetched from the relay; any whose bytes are missing are re-uploaded from a matching local copy.</p>`,n=this._ran&&this._rows.length===0&&!this._error?c`<p class="lwd-empty">No remote objects to check.</p>`:g,o=this._ran?this._downloadableItems().length:0;return c`<dialog @close="${this._onClose}"><header><h3>Re-check cloud storage</h3></header>${r} ${this._rowsSection()} ${n} ${this._summarySection()} ${this._error?c`<p class="rec-error" role="alert">${this._error}</p>`:g}<footer class="nwd-actions"><span class="nwd-spacer"></span> ${o>0?c`<button type="button" data-role="download" @click="${this._onDownload}" ?disabled="${this._running}">Download ${o} not stored locally</button>`:g} <button type="button" data-role="cancel" @click="${this._onCancel}" ?disabled="${this._running}">${this._ran?"Close":"Cancel"}</button> <button type="button" data-role="recheck" @click="${this._onRecheck}" ?disabled="${this._running}">${this._running?"Re-checking\u2026":this._ran?"Re-check again":"Re-check"}</button></footer></dialog>`}};customElements.define("objstore-recovery-dialog",$c);function zh({workspaceId:e,cloudCount:t,localFileNames:r,localBundles:n}={}){return Q("objstore-recovery-dialog",{workspaceId:e??"",cloudCount:typeof t=="number"?t:0,localFileNames:Array.isArray(r)?[...r]:[],localBundles:Array.isArray(n)?[...n]:[]})}function Sc(){let e=Yl(a.reports);if(!e)return null;let t=Object.keys(e),n=Ir().filter(p=>Ue(p).commonTriage===a.shownTriage),o=ql(n),s=ui(e,o),i=new Map,l=new Map,d=new Map;for(let p of n)for(let f of p){i.has(f.file)||i.set(f.file,new Set),i.get(f.file).add(f.severity);let h=a.triage.get(P(f))?.color??"none";l.has(f.file)||l.set(f.file,new Set),l.get(f.file).add(h),d.has(f.file)||d.set(f.file,[]),d.get(f.file).push({severity:f.severity,color:h})}let u;return C.focusedPkg?(u=t.filter(p=>(Hf(p)??"__own__")===C.focusedPkg),C.showAll||(u=u.filter(p=>Jl(p,o,s)))):u=C.showAll?t:t.filter(p=>Jl(p,o,s)),{prep:{treeData:e,files:u,ownCounts:o,transitiveCounts:s,severitySets:i,colorSets:l,fileFindings:d},findingCounts:o}}function Cc(){let e=bn();if(!e)return;let t=Sc();t&&e.refreshSidebar(t.prep,{isBundleContext:a.currentView==="bundles"})}function Ec(){let e=bn();if(!e)return;let t=Sc();t&&e.refreshTopPkgs(t.prep)}var b0={"claude-security":"Claude Security findings","codex-security":"Codex Security findings",deepsec:"DeepSec findings"};function y0(e,t){return a.currentWorkspace?t?c`<repo-chip url="${t}"></repo-chip>`:g:e?c`<repo-chip url="${a.repoUrl}" editable ?editing="${a.repoEditing}" ?empty="${!a.repoUrl}"></repo-chip>`:t?c`<repo-chip url="${t}"></repo-chip>`:g}var _c=["type","model","effort","exportsMode"];function Uh(e,t,{typePrefix:r=!0}={}){return e==="type"?r?`analyzer: ${t??"null"}`:`${t??"null"}`:t??null}function w0(e,t=_c){let r=new Map;for(let f of e){let h={};for(let m of t)h[m]=m==="model"?So(f.model)??null:f[m]??null;let b=t.map(m=>h[m]??"").join("|");r.has(b)||r.set(b,h)}let n=[...r.values()];if(n.length===0)return[];let o={};for(let f of t)o[f]=new Set(n.map(h=>h[f])).size===1;let s=t.filter(f=>!o[f]),i=n.length>2&&s.includes("type")&&s.length>1,l=["model","effort"].filter(f=>t.includes(f)&&o[f]),d=[...l,...t.filter(f=>!l.includes(f))],u=[],p=!1;for(let f of d)if(o[f]){let h=Uh(f,n[0][f]);h!=null&&u.push(h)}else if(!p){for(let h of n){let b=s.map(m=>Uh(m,h[m],{typePrefix:!i})).filter(m=>m!=null);b.length>0&&u.push(b.join(" \xB7 "))}p=!0}return u}function v0(e,t,r,n,o){let s=e.length,i=new Set(a.reports.map(W=>W.source)),l=i.size===1?[...i][0]:null,d=a.currentWorkspace?V().find(W=>W.id===a.currentWorkspace):null,u=d?`Workspace: ${d.name}`:l?b0[l]:"Findings",p=l&&re[l]?l:"default",f=me(re[p]),h=c`<svg class="file-icon" viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M14 3H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"/><path d="M14 3v6h6"/></svg>`,b=g;t.length===1?b=c`<span class="file-chip" data-copy-report="${t[0]}" title="Copy report name">${f}<span>${t[0]}</span></span>`:t.length>1&&(b=c`<span class="file-chip" data-copy-report="${t.join(`
54
+ `)}" title="Copy report names">${h}<span>${t.length} reports</span></span>`);let m=a.reports.flatMap(W=>W.groups.flat()),v=`${s} ${`finding${s===1?"":"s"}`}`,k=l||a.currentWorkspace?_c.filter(W=>W!=="type"):_c,E=w0(m,k),S=g;if(s>0){let W={};for(let ie of e){let _e=Tr(ie).severity;_e&&(W[_e]=(W[_e]||0)+1)}let be=ke.filter(ie=>W[ie]>0);be.length>0&&(S=c`<span class="status-bar" aria-hidden="true">${be.map(ie=>{let _e=`${W[ie]} ${ie.replaceAll("_"," ")}`;return c`<span class="${`status-seg sev-${ie}`}" style="${pe({flexGrow:W[ie]})}" title="${_e}"></span>`})}</span>`)}let x=y0(r,n),T=c`<span class="sep" aria-hidden="true"></span>`,N=a.currentView==="files",Z=(o??0)>1?c`<button type="button" class="${R({"files-toggle-btn":!0,active:N})}" data-action="toggle-files" title="${N?"exit files view":"show files"}" aria-pressed="${String(N)}">${`Files: ${o}`}</button>`:g;return c`<header class="page-head"><div class="page-title"><h1>${u}${b}${x}${Z}${k0()}</h1><div class="meta-row"><span>${v}</span> ${S} ${E.length>0?c`${T}${E.map(W=>c`<span class="tag">${W}</span>`)}`:g}</div></div></header>`}function k0(){if(D.status!=="online")return g;if(a.currentView!=="findings"&&a.currentView!=="files")return g;let e=x0();if(!e)return g;let{workspaceId:t,fileNames:r,mode:n}=e;if(n==="single"){let v=r[0],w=Pl(t,v)?"cloud":"local";return $0({status:w,label:w,title:w==="cloud"?"Synced to remote":"Local only \u2014 click to upload",onClick:w==="local"?()=>Hh({workspaceId:t,items:[{kind:"report",identifier:v}]}):null})}let o=V().find(v=>v.id===t),s=o&&Array.isArray(o.bundles)?o.bundles:[],i=zp(t),l=r.filter(v=>!Pl(t,v)),d=s.filter(v=>!Np(t,v)),u=[...l.map(v=>({kind:"report",identifier:v})),...d.map(v=>({kind:"bundle",identifier:v}))];if(i===0&&u.length===0)return g;let p=i>0,f=u.length>0,h=[i>0?`${i} in cloud`:null,u.length>0?`${u.length} local-only`:null,i>0?'click "cloud" to re-check storage':null,u.length>0?`click "local" to upload ${u.length}`:null].filter(Boolean).join(" \u2014 "),b=i===0?g:c`<button type="button" class="sync-badge-chunk cloud" aria-label="${`re-check ${i} cloud object${i===1?"":"s"}`}" @click="${v=>{v.stopPropagation(),zh({workspaceId:t,cloudCount:i,localFileNames:r,localBundles:s})}}">${Yh()}<span>${i} cloud</span></button>`,m=u.length===0?g:c`<button type="button" class="sync-badge-chunk local" aria-label="${`${u.length} items not yet uploaded \u2014 open upload dialog`}" @click="${v=>{v.stopPropagation(),Hh({workspaceId:t,items:u})}}">${qh()}<span>${u.length} local</span></button>`,y=i>0&&u.length>0?c`<span class="sync-badge-divider" aria-hidden="true"></span>`:g;return c`<div class="${`report-sync-badge${p||f?" report-sync-badge-clickable":""}`}" data-status="mixed" title="${h}">${b}${y}${m}</div>`}function $0({status:e,label:t,title:r,onClick:n}){let o=e==="cloud"?Yh():qh(),s=c`<span class="sync-badge-label">${t}</span>`;return typeof n!="function"?c`<span class="report-sync-badge" data-status="${e}" title="${r}" aria-label="${`report sync status: ${t}`}">${o}${s}</span>`:c`<button type="button" class="report-sync-badge report-sync-badge-clickable" data-status="${e}" title="${r}" aria-label="${`report sync status: ${t}`}" @click="${n}">${o}${s}</button>`}function qh(){return c`<svg class="sync-badge-icon" viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="2" y="14" width="20" height="8" rx="2" ry="2"/><line x1="6" y1="18" x2="6.01" y2="18"/><line x1="10" y1="18" x2="10.01" y2="18"/><path d="M6 14V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v10"/></svg>`}function Yh(){return c`<svg class="sync-badge-icon" viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M17.5 19a4.5 4.5 0 1 0-1-8.9A6 6 0 0 0 5.07 13.5 4 4 0 0 0 6 21h11.5z"/></svg>`}async function Hh({workspaceId:e,items:t}){let r=t.filter(n=>n.kind==="bundle");if(r.length>0){let n=await gt(),o=new Map(n.map(s=>[s.integrity,s.name]));for(let s of r){let i=o.get(s.identifier);i&&(s.label=i)}}await Oh({workspaceId:e,items:t})}function x0(){if(a.currentWorkspace)return{mode:"workspace",workspaceId:a.currentWorkspace,fileNames:a.reports.map(e=>e.fileName).filter(e=>typeof e=="string")};if(a.currentFile){let e=V().find(t=>Array.isArray(t.reports)&&t.reports.includes(a.currentFile));return e?{mode:"single",workspaceId:e.id,fileNames:[a.currentFile]}:null}return null}function _0(e){return Object.values(e).some(r=>r>0)||a.filterSeverities.size>0?c`<severity-chips .counts="${e}"></severity-chips>`:g}function S0(e){return Object.values(e).some(r=>r>0)||a.filterColors.size>0?c`<triage-filter .counts="${e}"></triage-filter>`:g}function C0(e,t,r,n,o,s,i,l){let{showSource:d,showConfidence:u,showPriority:p,showGraphMode:f,showFileSort:h,kanbanMode:b,showRepo:m,hasComment:y,hasFix:v,hasFlagged:w}=s;return c`<div class="toolbar"><div class="toolbar-row"><view-mode-buttons modes="${f?"table,list,grouped,focus,kanban,graph":"table,list,grouped,focus,kanban"}"></view-mode-buttons><findings-sort ?show-file="${h}" ?show-confidence="${u}" ?show-priority="${p}"></findings-sort>${d?c`<div class="sep"></div><source-filter></source-filter>`:g} ${y||v||w||a.filterComment||a.filterFix||a.filterFlagged?c`<div class="sep"></div><annotation-filter .hasComment="${y}" .hasFix="${v}" .hasFlagged="${w}"></annotation-filter>`:g} ${u?c`<div class="sep"></div><conf-filter></conf-filter>`:g} ${b?g:c`<triage-selector .counts="${r}"></triage-selector>`}</div><div class="toolbar-row sev-row">${_0(n)} ${i.analyzers.length>1||i.models.length>1?c`<analyzer-select .analyzers="${i.analyzers}" .models="${i.models}" .groups="${i.groups}"></analyzer-select>`:g} ${m&&l.length>1?c`<repo-filter .options="${l}"></repo-filter>`:g} ${S0(o)}<div class="search-row"><toolbar-search kind="findings"></toolbar-search><span class="result-count">${e} of ${t}</span></div></div></div>`}function xc(e,t){return e.map(r=>({p:Tr(r),g:r})).toSorted((r,n)=>t(r.p,n.p)).map(r=>r.g)}var Wh=(e,t)=>e.file.localeCompare(t.file)||parseInt(e.line,10)-parseInt(t.line,10),Ei=null,Vh=0,Sn=null,Ai=new Map;function zo(e,t=!1,r=null){let n=mn(e);return Ai.set(n,{group:e,inGroup:t}),t?r?c`<finding-card data-gid="${n}" in-group context="${r}"></finding-card>`:c`<finding-card data-gid="${n}" in-group></finding-card>`:r?c`<finding-card data-gid="${n}" context="${r}"></finding-card>`:c`<finding-card data-gid="${n}"></finding-card>`}var E0={critical:"C",high:"H",medium:"M",low:"L",high_bug:"H",bug:"B",informational:"i"};function jh(e,t={}){let{variant:r="kanban",active:n=!1}=t,o=Ue(e),s=ze(e),i=ci(ot(s.description,s))||"(untitled finding)",l=r==="kanban",d={"kanban-card":!0,"has-conflict":o.hasConflict,"focus-side-card":!l,active:n};!o.hasConflict&&o.commonColor&&(d[`mark-${o.commonColor}`]=!0);let u=parseInt(s.line,10),p=Number.isFinite(u)?`:${u}`:"",f=E0[s.severity]??"?",h=a.triage.get(P(s))?.flagged===!0,b=c`<div class="kanban-badge-col"><span class="${`kanban-badge sev-${s.severity}`}" title="${gn(s.severity)}" aria-label="${gn(s.severity)}">${f}</span> ${h?c`<span class="kanban-flag" title="Flagged" aria-label="Flagged">${di}</span>`:g}</div><span class="kanban-title">${i}</span><div class="kanban-meta"><span class="kanban-loc">${s.file}${p}</span> ${s.confidence===void 0||s.confidence===null?g:c`<span class="kanban-conf" title="${`Confidence ${s.confidence}/10`}">${s.confidence}</span>`}</div>`;return l?c`<div class="${R(d)}" data-gid="${Ie(e)}" data-kanban-source draggable="true" role="button" tabindex="0" aria-current="${n?"true":"false"}" aria-label="${`Open details for ${i}`}">${b}</div>`:c`<div class="${R(d)}" data-gid="${Ie(e)}" data-focus-select role="button" tabindex="0" aria-current="${n?"true":"false"}" aria-label="${`Focus on ${i}`}">${b}</div>`}function A0(e){let{content:t,line:r,highlighted:n}=e,o=t.split(`
55
+ `).length,s=String(o).length;return c`<div class="focus-code-lines" style="${pe({"--lineno-width":`${s}ch`})}"><aside class="focus-code-gutter" aria-hidden="true">${Array.from({length:o},(i,l)=>{let d=l+1;return c`<div class="${R({"focus-code-lineno":!0,"focus-code-line-active":d===r})}" data-focus-code-line="${d}">${d}</div>`})}</aside><pre class="focus-code-source"><code>${typeof n=="string"?me(n):t}</code></pre></div>`}function T0(e){if(!e)return g;let t=Ue(e),r={"kanban-detail-modal":!0,"has-conflict":t.hasConflict};return!t.hasConflict&&t.commonColor&&(r[`mark-${t.commonColor}`]=!0),c`<div class="kanban-detail-backdrop"><div class="kanban-detail-dim"></div><div class="${R(r)}" role="dialog" aria-modal="true"><button type="button" class="kanban-detail-close" title="Close details" aria-label="Close details">×</button><div class="kanban-detail-body">${zo(e,!1,"kanban-detail")}</div></div></div>`}function I0(e){if(a.viewMode==="table"){let r=a.sortBy==="file"?xc(e,Wh):e;if(r.length===0)return g;let n=a.tableSelectedGid?r.find(s=>Ie(s)===a.tableSelectedGid):null;return Ei=r,c`<div class="${n?"findings-table-layout open":"findings-table-layout"}"><div class="findings-table-list"><div class="finding-table-slot"></div></div>${n?c`<aside class="findings-table-details" id="findings-table-details"><header class="findings-table-details-bar"><span class="findings-table-details-label">Details</span> <button type="button" class="findings-table-details-close" data-table-deselect title="Close details" aria-label="Close details">×</button></header><div class="findings-table-details-body">${zo(n)}</div></aside>`:g}</div>`}if(a.viewMode==="focus"){if(e.length===0)return g;let r=a.focusGid?e.findIndex(d=>Ie(d)===a.focusGid):-1;r<0&&(r=Math.min(Vh,e.length-1),r<0&&(r=0)),Vh=r;let n=e[r];a.focusCodeTick;let o=Ph(n),s=o?"focus-main with-code":"focus-main",i=r===0,l=r===e.length-1;return c`<div class="focus-view"><div class="${s}"><div class="focus-pane focus-pane-card"><div class="focus-card-wrapper">${zo(n,!1,"focus")}</div></div>${o?c`<div class="focus-pane focus-pane-code">${o.loading?c`<div class="focus-code-empty">Loading source…</div>`:c`<header class="focus-code-bar" title="${o.file}"><span class="focus-code-file">${o.file}</span> ${o.line?c`<span class="focus-code-line">:${o.line}</span>`:g}</header><div class="focus-code-body">${A0(o)}</div>`}</div>`:g}</div><aside class="focus-sidebar" aria-label="Up next"><div class="focus-sidebar-header"><span class="label">Up next</span><div class="focus-nav"><button type="button" class="focus-nav-btn" data-focus-nav="prev" ?disabled="${i}" title="Previous finding (←)" aria-label="Previous finding"><svg viewBox="0 0 16 16" width="12" height="12" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M10 3 5 8l5 5"/></svg></button> <span class="count">${r+1} / ${e.length}</span> <button type="button" class="focus-nav-btn" data-focus-nav="next" ?disabled="${l}" title="Next finding (→)" aria-label="Next finding"><svg viewBox="0 0 16 16" width="12" height="12" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M6 3 11 8l-5 5"/></svg></button></div></div><div class="focus-sidebar-body">${X(e,d=>Ie(d),d=>jh(d,{variant:"focus",active:Ie(d)===Ie(n)}))}</div></aside></div>`}if(a.viewMode==="kanban"){let r=[{key:"untriaged",label:"Untriaged",target:"untriaged"},{key:"inprogress",label:"In progress",target:"inprogress"},{key:"fixed",label:"Fixed",target:"fixed"},{key:"invalid",label:"Invalid",target:"invalid"},{key:"deleted",label:"Deleted",target:"deleted"},{key:"ignored",label:"Ignored",target:"ignored"}],n=new Map(r.map(s=>[s.key,[]]));for(let s of e){let l=Ue(s).commonTriage??"untriaged",d=n.get(l);d&&d.push(s)}let o=a.kanbanPopoverGid?e.find(s=>Ie(s)===a.kanbanPopoverGid):null;return c`<div class="kanban-board">${X(r,s=>s.key,s=>{let i=n.get(s.key);return c`<div class="${`kanban-column kanban-column-${s.key}`}" data-kanban-target="${s.target}"><div class="kanban-column-header"><span class="label">${s.label}</span> <span class="count">${i.length}</span></div><div class="kanban-column-body">${i.length===0?c`<div class="kanban-empty">No ${s.label.toLowerCase()} findings.</div>`:X(i,l=>Ie(l),l=>jh(l,{active:Ie(l)===a.kanbanPopoverGid}))}</div></div>`})}</div>${T0(o)}`}if(a.viewMode==="grouped"){let r=new Map;for(let o of e){let s=Tr(o).file;r.has(s)||r.set(s,[]),r.get(s).push(o)}let n=a.sortBy==="file"?[...r.keys()].toSorted():[...r.keys()];return c`${X(n,o=>o,o=>{let s=a.sortBy==="file"?xc(r.get(o),(l,d)=>parseInt(l.line,10)-parseInt(d.line,10)):r.get(o),i=Tr(s[0]);return c`<div class="file-group"><div class="file-header"><span>${Hl(o,i?.repo?.github,i?._repoFallback??a.repoUrl)}</span> <span class="count">${s.length}</span></div><div class="file-body">${X(s,l=>mn(l),l=>zo(l))}</div></div>`})}`}let t=a.sortBy==="file"?xc(e,Wh):e;return c`${X(t,r=>mn(r),r=>{let n=ze(r),o=ff(n.file,n.line,n.repo?.github,n._repoFallback??a.repoUrl),s=Ar(n),i=Er(n),l=r.length>1;return c`<div class="${R({"flat-group":!0,"multi-case":l})}"><div class="flat-group-loc"><span class="file">${Hl(n.file,n.repo?.github,n._repoFallback??a.repoUrl)}</span> ${o===g?g:c`<span class="line-num">${o}</span>`} ${i?c`<span class="meta">${i}</span>`:g} ${s?c`<span class="run-meta">${s}</span>`:g}</div>${zo(r,!0)}</div>`})}`}function R0(){let e=document.querySelector("#bundle-source-overlay-slot");e&&q(Ch(),e)}var Kh=null;function $(){let e=Kh;if(Kh=a.currentView,e!==null&&e!==a.currentView&&typeof document.startViewTransition=="function"&&!matchMedia("(prefers-reduced-motion: reduce)").matches){document.startViewTransition(()=>Gh());return}Gh()}function Gh(){if(R0(),cf(a.reports),a.currentView==="bundles")if((a.bundles??[]).length===0)a.currentView="findings";else{let A=document.querySelector("#bundles-slot");if((!A||!I.contains(A)||I.firstElementChild!==A)&&(I.innerHTML='<div id="bundles-slot"></div>',A=document.querySelector("#bundles-slot")),A&&q(Ih(a.bundles),A),a.selectedBundle&&a.bundleDetailsTab==="graph"&&a.bundleDetails&&(a.bundleDetails.json||a.bundleDetails.bundle)){let M=document.querySelector("#bundle-graph-slot");if(M){let se=_h(a.bundleDetails);if(se){Sh(se);let Zo={hideAllFiles:!0,triageCounts:xh(a.bundleDetails),triageStates:["inprogress","fixed","invalid","deleted"],showSplitOwnDirs:se.canSplitOwnDirs,showPackagesView:se.canPackagesView};Xl(M,se,Zo,Si,Ci)}}}if(a.selectedBundle&&a.bundleDetailsTab==="terminal"&&a.bundleDetails&&(a.bundleDetails.json||a.bundleDetails.bundle)){let M=document.querySelector("#bundle-terminal-slot");M&&zf(M,a.bundleDetails)}I.classList.add("active"),Be.classList.add("hidden"),document.title="DeepView \u2014 bundles";return}if(a.currentView==="packages"){let A=document.querySelector("#packages-slot");(!A||!I.contains(A)||I.firstElementChild!==A)&&(I.innerHTML='<div id="packages-slot"></div>',A=document.querySelector("#packages-slot")),A&&q(Rh(),A),I.classList.add("active"),Be.classList.add("hidden"),document.title="DeepView \u2014 packages";return}if(a.currentView==="repositories"){let A=document.querySelector("#repositories-slot");(!A||!I.contains(A)||I.firstElementChild!==A)&&(I.innerHTML='<div id="repositories-slot"></div>',A=document.querySelector("#repositories-slot")),A&&q(Mh(),A),I.classList.add("active"),Be.classList.add("hidden"),document.title="DeepView \u2014 repositories";return}if(a.reports.length===0)return;let e=Ir(),t=a.viewMode==="kanban",r={inprogress:0,fixed:0,invalid:0,deleted:0,ignored:0},n=[];for(let A of e){let M=Ue(A).commonTriage;M&&r[M]++,(t||M===a.shownTriage)&&n.push(A)}let o=!1,s=!1,i=!1;for(let A of e)for(let M of A){let se=a.triage.get(P(M));se&&(se.comment&&(o=!0),se.fix&&(s=!0),se.flagged===!0&&(i=!0))}let d=[...new Set(a.reports.map(A=>A.type))].join(", "),u=a.reports.map(A=>A.fileName),p={critical:0,high:0,medium:0,low:0,high_bug:0,bug:0,informational:0},f={red:0,blue:0,green:0,gray:0,none:0};for(let A of n){if(A.length===1){let Ce=A[0];p[Ce.severity]=(p[Ce.severity]||0)+1;let Zo=a.triage.get(P(Ce))?.color??"none";f[Zo]=(f[Zo]||0)+1;continue}let M=new Set(A.map(Ce=>Ce.severity));for(let Ce of M)p[Ce]=(p[Ce]||0)+1;let se=new Set(A.map(Ce=>a.triage.get(P(Ce))?.color??"none"));for(let Ce of se)f[Ce]=(f[Ce]||0)+1}let h=n.length>0&&n.every(A=>A.every(M=>M.confidence!==void 0||M.critical===!0)),b=e.some(A=>A.some(M=>M.priority!==void 0)),m=e.some(A=>A.some(M=>tr(M.file))),y=!1,v=!1,w;e:for(let A of e)for(let M of A)if(!v)v=!0,w=M.file;else if(M.file!==w){y=!0;break e}let k=e.some(A=>A.some(M=>!M.repo?.github&&!tr(M.file))),E=new Set;for(let A of e)for(let M of A)!tr(M.file)&&M.repo?.github&&E.add(M.repo.github);let S=E.size===1?[...E][0]:null,x=new Set,T=new Set;for(let A of e)for(let M of A)x.add(M._analyzer??null),T.add(Eo(M));let N=Object.keys(Gl),Z=[...x].toSorted((A,M)=>{let se=A==null?1/0:N.indexOf(A)===-1?N.length:N.indexOf(A),Ce=M==null?1/0:N.indexOf(M)===-1?N.length:N.indexOf(M);return se!==Ce?se-Ce:String(A??"").localeCompare(String(M??""))}),W=[...T].toSorted((A,M)=>A==null&&M==null?0:A==null?1:M==null?-1:A.localeCompare(M));if(a.filterAnalyzer){let A=a.filterAnalyzer===un?null:a.filterAnalyzer;(!x.has(A)||x.size<2)&&(a.filterAnalyzer="")}if(a.filterModel){let A=a.filterModel===pn?null:a.filterModel;(!T.has(A)||T.size<2)&&(a.filterModel="")}let be=new Set;for(let A of e)for(let M of A)be.add(Vl(M));let ie=[...be].toSorted((A,M)=>A==null&&M==null?0:A==null?1:M==null?-1:A.localeCompare(M));if(a.filterRepo){let A=a.filterRepo===Co?null:a.filterRepo;be.has(A)||(a.filterRepo="")}!m&&a.filterSources.size>0&&a.filterSources.clear(),h||(a.filterConfMin=0,a.filterConfMax=10,(a.sortBy==="confidence-desc"||a.sortBy==="confidence-asc")&&(a.sortBy="severity")),!b&&(a.sortBy==="priority-desc"||a.sortBy==="priority-asc")&&(a.sortBy="severity"),!y&&a.sortBy==="file"&&(a.sortBy="severity");let _e=$f(vf(n)),Rn=Yl(a.reports),Nr=Rn?Object.keys(Rn).length:0,zt=Nr>1;!zt&&a.currentView==="files"&&(a.currentView="findings"),!zt&&a.viewMode==="graph"&&(a.viewMode="table");let cr=v0(e,u,k,S,Nr);if(a.currentView==="files"){let A=ql(e),M=document.querySelector("#header-slot"),se=document.querySelector("#tree-view-slot");(!M||!se||!I.contains(M)||!I.contains(se))&&(I.innerHTML='<div id="header-slot"></div><div id="tree-view-slot"></div>',M=document.querySelector("#header-slot"),se=document.querySelector("#tree-view-slot")),M&&q(cr,M),se&&q(Of(Rn,A),se),I.classList.add("active"),Be.classList.add("hidden"),document.title=`DeepView \u2014 ${d||"no analyzer"}`;return}let Fn=a.viewMode==="table"&&a.tableSelectedGid&&_e.some(A=>Ie(A)===a.tableSelectedGid),Dr=null;a.viewMode==="graph"&&Rn&&(Dr=Sc(),Dr||(a.viewMode="table"));let dr=!!Dr,lt="findings-content";Fn&&(lt+=" with-details"),dr&&(lt+=" with-graph"),t&&(lt+=" with-kanban"),a.viewMode==="focus"&&(lt+=" with-focus");let Bn=g,_=g,z=g;Ei=null,Ai.clear(),dr||(Bn=C0(_e.length,n.length,r,p,f,{showSource:m,showConfidence:h,showPriority:b,showGraphMode:zt,showFileSort:y,kanbanMode:t,showRepo:!!a.currentWorkspace,hasComment:o,hasFix:s,hasFlagged:i},{analyzers:Z,models:W,groups:n},ie),a.shownTriage&&n.length===0?_=c`<p style="color:var(--muted);margin:1rem 0">No ${a.shownTriage} findings.</p>`:_e.length===0&&n.length>0?_=c`<p style="color:var(--muted);margin:1rem 0">No findings match the current filters.</p>`:n.length===0&&(_=e.length>0?c`<p style="color:var(--green)">All ${d} issues triaged.</p>`:c`<p style="color:var(--green)">No ${d} issues found.</p>`),z=I0(_e));let J=document.querySelector("#header-slot"),G=I.querySelector(":scope > .findings-content"),ye=G&&G.querySelector(":scope > #findings-graph-slot"),Se=G&&G.querySelector(":scope > #findings-body-slot"),ur=G&&(ye?"graph":Se?"body":null)===(dr?"graph":"body");if(!J||!G||!I.contains(J)||!I.contains(G)||!ur){let A=dr?'<div id="findings-graph-slot"></div>':'<div id="toolbar-slot"></div><div id="empty-state-slot"></div><div id="findings-body-slot"></div>';I.innerHTML=`<div id="header-slot"></div><div class="${lt}">${A}</div>`,J=document.querySelector("#header-slot"),G=I.querySelector(":scope > .findings-content")}else G.className!==lt&&(G.className=lt);J&&q(cr,J);let zd=document.querySelector("#toolbar-slot");zd&&q(Bn,zd);let Ud=document.querySelector("#empty-state-slot");Ud&&q(_,Ud);let Hd=document.querySelector("#findings-body-slot");if(Hd&&q(z,Hd),Dr){let A=document.querySelector("#findings-graph-slot");if(A){let se={extraTopRow:c`<view-mode-buttons modes="table,list,grouped,focus,kanban,graph"></view-mode-buttons>`,triageCounts:r,triageStates:["inprogress","fixed","invalid","deleted","ignored"]};Xl(A,Dr.prep,se,Cc,Ec)}}if(Ei){let A=I.querySelector(".finding-table-slot");A&&(Sn||(Sn=document.createElement("finding-table")),Sn.items=Ei,Sn.selectedGid=a.tableSelectedGid,Sn.parentNode!==A&&A.append(Sn))}if(Ai.size>0)for(let A of I.querySelectorAll("finding-card")){let M=Ai.get(A.dataset.gid);M&&(A.group=M.group)}I.classList.add("active"),Be.classList.add("hidden"),document.title=`DeepView \u2014 ${d||"no analyzer"}`}var Ac=class extends F{static styles=[...F.styles,B(nt)];static properties={workspace:{attribute:!1},_password:{state:!0},_confirm:{state:!0},_noPassword:{state:!0},_includeBundleBytes:{state:!0},_busy:{state:!0},_error:{state:!0},_settled:{state:!0}};constructor(){super(),this.workspace=null,this._password="",this._confirm="",this._noPassword=!1,this._includeBundleBytes=!1,this._busy=!1,this._error="",this._settled=!1}_finish(t){this._settled||(this._password="",this._confirm="",this.workspace=null,super._finish(t))}_onClose=()=>this._finish(null);_onCancel=()=>this._finish(null);_onPasswordInput=t=>{this._password=t.target.value,this._error=""};_onConfirmInput=t=>{this._confirm=t.target.value,this._error=""};_onNoPasswordToggle=t=>{this._noPassword=t.target.checked,this._error="",this._noPassword&&(this._password="",this._confirm="")};_onIncludeBundleBytesToggle=t=>{this._includeBundleBytes=t.target.checked,this._error=""};_canExport(){return this._busy?!1:this._noPassword?!0:(this._password??"").length>0&&this._password===this._confirm}_onExport=async()=>{if(this._canExport()){if(!this.workspace){this._error="No workspace selected.";return}this._busy=!0,this._error="";try{let{blob:t,filename:r}=await Al(this.workspace,{password:this._noPassword?void 0:this._password,includeBundleBytes:this._includeBundleBytes});if(this._settled)return;Wr(t,r),this._finish({ok:!0})}catch(t){if(this._settled)return;this._error=t?.message??String(t)}finally{this._busy=!1}}};_onKeydown=t=>{t.key==="Enter"&&(t.preventDefault(),this._onExport())};_body(){let t=!this._password||!this._confirm||this._password===this._confirm,r=Array.isArray(this.workspace?.bundles)?this.workspace.bundles.length:0;return c`<p class="nwd-note">The export file carries this workspace's reports, triage state, comments, fixes, references to attached bundles (integrities only by default), and its private key. Encrypting the file with a password ensures only those with the password can attach the workspace after download.</p><label class="wsl-field"><span>Password</span> <input type="password" class="nwd-input" autocomplete="off" data-1p-ignore="true" data-lpignore="true" data-bwignore="true" data-form-type="other" name="dv-export-pw" maxlength="1024" ?disabled="${this._noPassword}" .value="${this._password}" @input="${this._onPasswordInput}" @keydown="${this._onKeydown}"></label> <label class="wsl-field"><span>Confirm password</span> <input type="password" class="nwd-input" autocomplete="off" data-1p-ignore="true" data-lpignore="true" data-bwignore="true" data-form-type="other" name="dv-export-pw-confirm" maxlength="1024" ?disabled="${this._noPassword}" .value="${this._confirm}" @input="${this._onConfirmInput}" @keydown="${this._onKeydown}"></label> <label class="wsl-optout"><input type="checkbox" .checked="${this._noPassword}" @change="${this._onNoPasswordToggle}"> <span>Export without password (not recommended)</span></label> ${r>0?c`<label class="wsl-optout"><input type="checkbox" .checked="${this._includeBundleBytes}" @change="${this._onIncludeBundleBytesToggle}"> <span>Include bundle bytes (${r} bundle${r===1?"":"s"}; significantly larger file)</span></label>`:g} ${this._noPassword?c`<p class="wsl-error wsl-warning">Anyone who obtains this file can attach the workspace and read every report, triage decision, comment, and fix. Only opt out when you control where the file goes.</p>`:g} ${this._error?c`<p class="wsl-error" role="alert">${this._error}</p>`:g} ${!this._noPassword&&!t?c`<p class="wsl-error" role="alert">Passwords don't match.</p>`:g}<footer class="nwd-actions"><span class="nwd-spacer"></span> <button type="button" @click="${this._onCancel}">Cancel</button> <button type="button" class="primary" ?disabled="${!this._canExport()}" @click="${this._onExport}">${this._busy?"Exporting\u2026":this._noPassword?"Export without password":"Export"}</button></footer>`}render(){return c`<dialog @close="${this._onClose}"><header><h3>Export workspace</h3></header>${this._body()}</dialog>`}};customElements.define("workspace-export-dialog",Ac);function Jh({workspace:e}={}){return new Promise((t,r)=>{let n=document.createElement("workspace-export-dialog");n.workspace=e??null,n.addEventListener("resolve",o=>{n.remove(),t(o.detail)}),n.addEventListener("modal-conflict",o=>{n.workspace=null,n.remove(),r(yt(o.detail?.cause))}),document.body.append(n)})}async function Xh(e){await Jh({workspace:e})}var Tc=class extends F{static properties={_value:{state:!0}};constructor(){super(),this._value=""}_onInput=t=>{this._value=t.target.value};_onCreate=()=>{let t=(this._value??"").trim();t&&this._finish(t)};_onCancel=()=>this._finish(null);_onKeydown=t=>{t.key==="Enter"&&(t.preventDefault(),this._onCreate())};render(){let t=(this._value??"").trim().length>0;return c`<dialog @close="${this._onClose}"><header><h3>New workspace</h3></header><input type="text" class="nwd-input" placeholder="Workspace name" maxlength="200" .value="${this._value}" @input="${this._onInput}" @keydown="${this._onKeydown}"><p class="nwd-note">Workspace triage is synchronized by default over an end-to-end encrypted channel. Triage on unattached reports stays local to this browser.</p><footer class="nwd-actions"><span class="nwd-spacer"></span> <button type="button" @click="${this._onCancel}">Cancel</button> <button type="button" class="primary" ?disabled="${!t}" @click="${this._onCreate}">Create</button></footer></dialog>`}};customElements.define("new-workspace-dialog",Tc);function Qh(){return Q("new-workspace-dialog")}var Ic=class extends F{static styles=[...F.styles,B($e)];static properties={workspaceName:{type:String},reportCount:{type:Number},bundleCount:{type:Number},orphanedTriage:{type:Number},sharedTriage:{type:Number},_mode:{state:!0},_triage:{state:!0},_settled:{state:!0}};constructor(){super(),this.workspaceName="",this.reportCount=0,this.bundleCount=0,this.orphanedTriage=0,this.sharedTriage=0,this._mode="detach",this._triage="keep",this._settled=!1}focusInitial(){this.renderRoot.querySelector('button[data-role="cancel"]')?.focus()}_finish(t){if(this._settled)return;let r=this.reportCount>0?this._mode:"detach",n=r==="delete"&&this.orphanedTriage>0?this._triage:"keep";super._finish({confirmed:!!t,mode:r,triage:n})}_onClose=()=>this._finish(!1);_onCancel=()=>this._finish(!1);_onConfirm=()=>this._finish(!0);_onModeChange=t=>{this._mode=t.target.value};_onTriageChange=t=>{this._triage=t.target.value};_triageSection(){if(this._mode!=="delete"||this.reportCount===0)return"";let t=this.orphanedTriage,r=this.sharedTriage;return t===0&&r===0?c`<p class="lwd-note">No local triage is attached to ${this.reportCount===1?"this report":"these reports"}.</p>`:t===0?c`<p class="lwd-note">Local triage on ${this.reportCount===1?"this report":"these reports"} is also attached to ${r===1?"a report":"reports"} you're keeping. Nothing will be orphaned.</p>`:c`<fieldset class="lwd-choice"><legend><strong>${t}</strong> ${t===1?"triage entry won't":"triage entries won't"} be reachable from any remaining report. What should happen ${t===1?"to it":"to them"}?</legend><label class="lwd-option"><input type="radio" name="lwd-triage" value="keep" ?checked="${this._triage==="keep"}" @change="${this._onTriageChange}"> <span class="lwd-option-text"><span class="lwd-option-title">Keep</span> <span class="lwd-option-hint">Reapplied automatically if a matching report is imported later.</span></span></label> <label class="lwd-option"><input type="radio" name="lwd-triage" value="wipe" ?checked="${this._triage==="wipe"}" @change="${this._onTriageChange}"> <span class="lwd-option-text"><span class="lwd-option-title">Wipe</span> <span class="lwd-option-hint">Drop the orphaned triage from this browser.</span></span></label></fieldset>`}render(){let t=this.reportCount,r=this.bundleCount,n=t>0,o=t===1?"report":"reports",s=t===1?"it":"them",i=t===1?"stays":"stay",l=t===1?"is removed":"are removed",d=r>0?c`<p class="lwd-note">${r===1?"One bundle is":`${r} bundles are`} also attached. ${r===1?"It":"They"} will become unfiled — the bundle bytes stay on this device either way (delete bundles manually from the Bundles list if you want them gone).</p>`:"",u=n?c`<fieldset class="lwd-choice"><legend>What should happen to the <strong>${t}</strong> attached ${o}?</legend><label class="lwd-option"><input type="radio" name="lwd-mode" value="detach" ?checked="${this._mode==="detach"}" @change="${this._onModeChange}"> <span class="lwd-option-text"><span class="lwd-option-title">Move ${s} out of the workspace</span> <span class="lwd-option-hint">The ${o} ${i} in this browser as unattached ${o}.</span></span></label> <label class="lwd-option"><input type="radio" name="lwd-mode" value="delete" ?checked="${this._mode==="delete"}" @change="${this._onModeChange}"> <span class="lwd-option-text"><span class="lwd-option-title">Delete ${s} along with the workspace</span> <span class="lwd-option-hint">The ${o} ${l} from this browser.</span></span></label></fieldset>`:r>0?c`<p class="lwd-empty">No reports are attached to this workspace (only bundles, see below).</p>`:c`<p class="lwd-empty">No reports are attached to this workspace.</p>`;return c`<dialog @close="${this._onClose}"><header><h3>Leave workspace</h3></header><p class="lwd-body">Leave workspace <strong>"${this.workspaceName}"</strong> on this device?</p>${u} ${d} ${this._triageSection()}<ul class="lwd-list"><li>Workspace synchronization data stays on the sync server — peers (and your other devices) keep their copy.</li></ul><footer class="nwd-actions"><span class="nwd-spacer"></span> <button type="button" data-role="cancel" @click="${this._onCancel}">Cancel</button> <button type="button" class="danger" @click="${this._onConfirm}">Leave</button></footer></dialog>`}};customElements.define("leave-workspace-dialog",Ic);function Zh({name:e,reportCount:t,bundleCount:r,triageImpact:n}={}){return Q("leave-workspace-dialog",{workspaceName:e??"",reportCount:t??0,bundleCount:r??0,orphanedTriage:n?.orphanedCount??0,sharedTriage:n?.sharedCount??0})}var Rc=class extends F{static styles=[...F.styles,B(nt)];static properties={workspaceId:{type:String},initialName:{type:String},privateKeyBase64:{type:String},_name:{state:!0},_password:{state:!0},_confirm:{state:!0},_url:{state:!0},_busy:{state:!0},_error:{state:!0},_copied:{state:!0},_settled:{state:!0}};constructor(){super(),this.workspaceId="",this.initialName="",this.privateKeyBase64="",this._name="",this._password="",this._confirm="",this._url="",this._busy=!1,this._error="",this._copied=!1,this._settled=!1}beforeOpen(){this._name=this.initialName}focusInitial(){this.renderRoot.querySelector('input[data-role="name"]')?.focus()}_finish(){this._settled||(this._copiedTimer&&(clearTimeout(this._copiedTimer),this._copiedTimer=null),this._password="",this._confirm="",this._url="",this.privateKeyBase64="",super._finish(null))}_onClose=()=>this._finish();_onCancel=()=>this._finish();_onNameInput=t=>{this._name=t.target.value};_onPasswordInput=t=>{this._password=t.target.value,this._error=""};_onConfirmInput=t=>{this._confirm=t.target.value,this._error=""};_canGenerate(){return(this._name??"").trim().length>0&&(this._password??"").length>0&&this._password===this._confirm&&!this._busy}_onGenerate=async()=>{if(this._canGenerate()){this._busy=!0,this._error="";try{let t=await Rl({id:this.workspaceId,name:this._name.trim(),privateKeyBase64:this.privateKeyBase64,password:this._password});if(this._settled)return;this._url=Bl(t),this._password="",this._confirm=""}catch(t){if(this._settled)return;this._error=t?.message??String(t)}finally{this._busy=!1}}};_onCopy=async()=>{if(this._url){this._error="";try{if(await navigator.clipboard.writeText(this._url),this._settled)return;this._copied=!0,this._copiedTimer&&clearTimeout(this._copiedTimer),this._copiedTimer=setTimeout(()=>{this._copied=!1,this._copiedTimer=null},1500)}catch{if(this._settled)return;this._error="Copy failed \u2014 select the link and copy it manually."}}};_onKeydown=t=>{t.key==="Enter"&&!this._url&&(t.preventDefault(),this._onGenerate())};_body(){return this._url?c`<p class="nwd-note">Anyone with the link <strong>and</strong> the password can attach this workspace. Share them through separate channels.</p><label class="wsl-field"><span>Share link</span> <textarea class="wsl-link" readonly="readonly" rows="3" @focus="${t=>t.target.select()}">${this._url}</textarea></label> ${this._error?c`<p class="wsl-error" role="alert">${this._error}</p>`:g}<footer class="nwd-actions"><span class="nwd-spacer"></span> <button type="button" @click="${this._onCancel}">Close</button> <button type="button" class="primary" @click="${this._onCopy}">${this._copied?"Copied":"Copy link"}</button></footer>`:c`<label class="wsl-field"><span>Workspace name</span> <input type="text" class="nwd-input" data-role="name" placeholder="Workspace name" maxlength="200" .value="${this._name}" @input="${this._onNameInput}" @keydown="${this._onKeydown}"></label> <label class="wsl-field"><span>Password</span> <input type="password" class="nwd-input" autocomplete="off" data-1p-ignore="true" data-lpignore="true" data-bwignore="true" data-form-type="other" name="dv-share-link-pw" maxlength="1024" .value="${this._password}" @input="${this._onPasswordInput}" @keydown="${this._onKeydown}"></label> <label class="wsl-field"><span>Confirm password</span> <input type="password" class="nwd-input" autocomplete="off" data-1p-ignore="true" data-lpignore="true" data-bwignore="true" data-form-type="other" name="dv-share-link-pw-confirm" maxlength="1024" .value="${this._confirm}" @input="${this._onConfirmInput}" @keydown="${this._onKeydown}"></label><p class="nwd-note">The link carries the workspace's identity (id, name, and private key) so the recipient joins the same sync chain. Triage, reports, and comments aren't in the link itself — they sync over once the recipient joins. The link decrypts with the password above; without it the link is useless.</p>${this._error?c`<p class="wsl-error" role="alert">${this._error}</p>`:g} ${this._password&&this._confirm&&this._password!==this._confirm?c`<p class="wsl-error" role="alert">Passwords don't match.</p>`:g}<footer class="nwd-actions"><span class="nwd-spacer"></span> <button type="button" @click="${this._onCancel}">Cancel</button> <button type="button" class="primary" ?disabled="${!this._canGenerate()}" @click="${this._onGenerate}">${this._busy?"Generating\u2026":"Generate link"}</button></footer>`}render(){return c`<dialog @close="${this._onClose}"><header><h3>${this._url?"Workspace share link":"Share workspace by link"}</h3></header>${this._body()}</dialog>`}};customElements.define("workspace-share-link-dialog",Rc);function eg({id:e,name:t,privateKeyBase64:r}={}){return new Promise((n,o)=>{let s=document.createElement("workspace-share-link-dialog");s.workspaceId=e??"",s.initialName=t??"",s.privateKeyBase64=r??"",s.addEventListener("resolve",()=>{s.remove(),n()}),s.addEventListener("modal-conflict",i=>{s.privateKeyBase64="",s.remove(),o(yt(i.detail?.cause))}),document.body.append(s)})}var Fc=class extends F{static styles=[...F.styles,B($e)];static properties={reportName:{type:String},orphanedTriage:{type:Number},sharedTriage:{type:Number},inRemote:{type:Boolean},_triage:{state:!0}};constructor(){super(),this.reportName="",this.orphanedTriage=0,this.sharedTriage=0,this.inRemote=!1,this._triage="keep"}focusInitial(){this.renderRoot.querySelector('button[data-role="cancel"]')?.focus()}_finish(t){if(this._settled)return;let r=this.orphanedTriage>0?this._triage:"keep";super._finish({confirmed:!!t,triage:r})}_onClose=()=>this._finish(!1);_onCancel=()=>this._finish(!1);_onConfirm=()=>this._finish(!0);_onTriageChange=t=>{this._triage=t.target.value};_remoteNotice(){return this.inRemote?c`<p class="lwd-note">This report is also stored in the workspace's <strong>remote</strong> inventory and will be removed from there too. Newly synced workspace members won't see it; members who already downloaded it keep their local copy (and could re-upload).</p>`:g}_triageSection(){let t=this.orphanedTriage,r=this.sharedTriage;return t===0&&r===0?c`<p class="lwd-note">No local triage is attached to this report.</p>`:t===0?c`<p class="lwd-note">Local triage on this report is also attached to ${r===1?"a report":"reports"} you're keeping. Nothing will be orphaned.</p>`:c`<fieldset class="lwd-choice"><legend><strong>${t}</strong> ${t===1?"triage entry won't":"triage entries won't"} be reachable from any remaining report. What should happen ${t===1?"to it":"to them"}?</legend><label class="lwd-option"><input type="radio" name="drd-triage" value="keep" ?checked="${this._triage==="keep"}" @change="${this._onTriageChange}"> <span class="lwd-option-text"><span class="lwd-option-title">Keep</span> <span class="lwd-option-hint">Reapplied automatically if a matching report is imported later.</span></span></label> <label class="lwd-option"><input type="radio" name="drd-triage" value="wipe" ?checked="${this._triage==="wipe"}" @change="${this._onTriageChange}"> <span class="lwd-option-text"><span class="lwd-option-title">Wipe</span> <span class="lwd-option-hint">Drop the orphaned triage from this browser.</span></span></label></fieldset>`}render(){return c`<dialog @close="${this._onClose}"><header><h3>Delete report</h3></header><p class="lwd-body">Delete <strong>"${this.reportName}"</strong>?</p>${this._remoteNotice()} ${this._triageSection()}<footer class="nwd-actions"><span class="nwd-spacer"></span> <button type="button" data-role="cancel" @click="${this._onCancel}">Cancel</button> <button type="button" class="danger" @click="${this._onConfirm}">Delete</button></footer></dialog>`}};customElements.define("delete-report-dialog",Fc);function tg({name:e,triageImpact:t,inRemote:r}={}){return Q("delete-report-dialog",{reportName:e??"",orphanedTriage:t?.orphanedCount??0,sharedTriage:t?.sharedCount??0,inRemote:!!r})}var Bc=class extends F{static styles=[...F.styles,B($e)];static properties={bundleName:{type:String},inRemote:{type:Boolean}};constructor(){super(),this.bundleName="",this.inRemote=!1}focusInitial(){this.renderRoot.querySelector('button[data-role="cancel"]')?.focus()}_finish(t){this._settled||super._finish({confirmed:!!t})}_onClose=()=>this._finish(!1);_onCancel=()=>this._finish(!1);_onConfirm=()=>this._finish(!0);_remoteNotice(){return this.inRemote?c`<p class="lwd-note">This bundle is also stored in the workspace's <strong>remote</strong> inventory and will be removed from there too. Newly synced workspace members won't see it; members who already downloaded it keep their local copy (and could re-upload).</p>`:g}render(){return c`<dialog @close="${this._onClose}"><header><h3>Delete bundle</h3></header><p class="lwd-body">Delete <strong>"${this.bundleName}"</strong>?</p>${this._remoteNotice()}<footer class="nwd-actions"><span class="nwd-spacer"></span> <button type="button" data-role="cancel" @click="${this._onCancel}">Cancel</button> <button type="button" class="danger" @click="${this._onConfirm}">Delete</button></footer></dialog>`}};customElements.define("delete-bundle-dialog",Bc);function rg({name:e,inRemote:t}={}){return Q("delete-bundle-dialog",{bundleName:e??"",inRemote:!!t})}var Mc=class extends F{static styles=[...F.styles,B($e)];static properties={bundleName:{type:String},workspaceName:{type:String}};constructor(){super(),this.bundleName="",this.workspaceName=""}focusInitial(){this.renderRoot.querySelector('button[data-role="cancel"]')?.focus()}_finish(t){this._settled||super._finish({confirmed:!!t})}_onClose=()=>this._finish(!1);_onCancel=()=>this._finish(!1);_onConfirm=()=>this._finish(!0);render(){return c`<dialog @close="${this._onClose}"><header><h3>Detach bundle</h3></header><p class="lwd-body">Detach <strong>"${this.bundleName}"</strong> from workspace <strong>"${this.workspaceName}"</strong>?</p><p class="lwd-note">This bundle is also stored in the workspace's <strong>remote</strong> inventory and will be removed from there too. Newly synced workspace members won't see it; members who already downloaded it keep their local copy (and could re-upload). The bundle bytes stay on this device — drop it onto another workspace to attach it there.</p><footer class="nwd-actions"><span class="nwd-spacer"></span> <button type="button" data-role="cancel" @click="${this._onCancel}">Cancel</button> <button type="button" class="danger" @click="${this._onConfirm}">Detach</button></footer></dialog>`}};customElements.define("detach-bundle-dialog",Mc);function ng({name:e,workspaceName:t}={}){return Q("detach-bundle-dialog",{bundleName:e??"",workspaceName:t??""})}var Lc=class extends F{static styles=[...F.styles,B($e)];static properties={reportName:{type:String},workspaceName:{type:String}};constructor(){super(),this.reportName="",this.workspaceName=""}focusInitial(){this.renderRoot.querySelector('button[data-role="cancel"]')?.focus()}_finish(t){this._settled||super._finish({confirmed:!!t})}_onClose=()=>this._finish(!1);_onCancel=()=>this._finish(!1);_onConfirm=()=>this._finish(!0);render(){return c`<dialog @close="${this._onClose}"><header><h3>Detach report</h3></header><p class="lwd-body">Detach <strong>"${this.reportName}"</strong> from workspace <strong>"${this.workspaceName}"</strong>?</p><p class="lwd-note">This report is also stored in the workspace's <strong>remote</strong> inventory and will be removed from there too. Newly synced workspace members won't see it; members who already downloaded it keep their local copy (and could re-upload). The report bytes stay on this device — drop it onto another workspace to attach it there.</p><footer class="nwd-actions"><span class="nwd-spacer"></span> <button type="button" data-role="cancel" @click="${this._onCancel}">Cancel</button> <button type="button" class="danger" @click="${this._onConfirm}">Detach</button></footer></dialog>`}};customElements.define("detach-report-dialog",Lc);function og({name:e,workspaceName:t}={}){return Q("detach-report-dialog",{reportName:e??"",workspaceName:t??""})}var Pc=class extends F{focusInitial(){this.renderRoot.querySelector("button.primary")?.focus()}_onConfirm=()=>this._finish(!0);render(){return c`<dialog @close="${this._onClose}"><header><h3>Changes might not be saved</h3></header><p class="nwd-intro">Triage works in this tab, but this browser <strong>can't save its sync state right now</strong> — so changes that haven't reached the server could be lost if you reload the page.</p><p class="nwd-intro">This usually means the browser's storage is full, or another tab is running a newer version of the app (to avoid overwriting that newer version's data, this tab has paused saving).</p><p class="nwd-note">Free up space if storage is full, and close or reload other tabs of this app to the same version. This notice clears on its own once saving works again.</p><footer class="nwd-actions"><span class="nwd-spacer"></span> <button type="button" class="primary" @click="${this._onConfirm}">Got it</button></footer></dialog>`}};customElements.define("persistence-degraded-dialog",Pc);function sg(){return new Promise(e=>{let t=document.createElement("persistence-degraded-dialog"),r=n=>{t.remove(),e({shown:n})};t.addEventListener("resolve",()=>r(!0)),t.addEventListener("modal-conflict",()=>r(!1)),document.body.append(t)})}var Oc=class extends F{focusInitial(){this.renderRoot.querySelector("button.primary")?.focus()}_onReload=()=>this._finish("reload");render(){return c`<dialog @close="${this._onClose}"><header><h3>Sign in to keep syncing</h3></header><p class="nwd-intro">Triage can't reach the sync server — the connection is being redirected to an <strong>authentication proxy</strong> (for example Cloudflare Access). This usually means your access session has expired.</p><p class="nwd-note">Reload the page to sign in again. Your triage is saved on this device, so reloading won't lose anything — or keep working offline and reload later.</p><footer class="nwd-actions"><span class="nwd-spacer"></span> <button type="button" @click="${this._onClose}">Not now</button> <button type="button" class="primary" @click="${this._onReload}">Reload page</button></footer></dialog>`}};customElements.define("proxy-auth-dialog",Oc);function ig(){return new Promise(e=>{let t=document.createElement("proxy-auth-dialog"),r=(n,o)=>{t.remove(),e({shown:n,reload:o})};t.addEventListener("resolve",n=>r(!0,n.detail==="reload")),t.addEventListener("modal-conflict",()=>r(!1,!1)),document.body.append(t)})}var ar;function F0(){return ar||(ar=document.createElement("div"),ar.id="styled-tooltip",document.body.append(ar),ar)}var Lr=null,Uo=null,dg=0,ug=0,ag=!1;function B0(){ag||(ag=!0,document.addEventListener("mousemove",e=>{dg=e.clientX,ug=e.clientY},{passive:!0}))}B0();var M0=100,L0=14,P0=8,lg=8;function O0(e,{placement:t="cursor"}={}){let r=F0();if(Lr===e)return;let n=e.dataset.tooltip??"";if(n){if(r.textContent=n,t==="right"){let o=e.getBoundingClientRect();r.style.top=`${Math.round(o.top+o.height/2)}px`,r.style.left=`${Math.round(o.right+P0)}px`,r.style.transform="translateY(-50%)"}else{r.style.transform="none",r.style.top=`${ug+L0}px`,r.style.left="0px",r.classList.add("visible");let o=r.offsetWidth,s=window.innerWidth-o-lg,i=Math.max(lg,Math.min(dg,s));r.style.left=`${Math.round(i)}px`}r.classList.add("visible"),Lr=e}}function Ho(){clearTimeout(Uo),Uo=null,ar&&ar.classList.remove("visible"),Lr=null}function Nc(e,{gate:t,placement:r}={}){t&&!t(e)||(clearTimeout(Uo),Uo=setTimeout(()=>{O0(e,{placement:r})},M0))}var cg=!1;function pg(){cg||(cg=!0,document.body.addEventListener("mouseover",e=>{let t=e.target.closest("[data-tooltip]");!t||t===Lr||(Ho(),Nc(t))}),document.body.addEventListener("mouseout",e=>{!Lr&&!Uo||Lr&&Lr.contains(e.relatedTarget)||Ho()}))}var Ii=null,de=null,Ti=null;pg();function N0(){return $t().size}function D0(){return _r().size}var Wo=typeof location>"u"||location.hostname.endsWith(".github.io")?"":`${location.protocol==="https:"?"wss:":"ws:"}//${location.host}/api/sync`,Kc="application/x-deepview-report",Hc="application/x-deepview-source-ws",Vo="application/x-deepview-bundle",Ri=!1,Fi=!1,z0={default:"Reports","claude-security":"Claude Security","codex-security":"Codex Security",deepsec:"DeepSec"},fg=["default","claude-security","codex-security","deepsec"],Pr="";function hg(e,t={}){let n=`file-item${e===a.currentFile&&(a.currentView==="findings"||a.currentView==="files")?" current":""}${t.indented?" indented":""}`,o=Me(e),s=ao(e),i=re[Xe(e)]??re.default;return c`<li class="${n}" data-file="${e}" data-workspace-id="${t.workspaceId??g}" draggable="true"><button type="button" class="file-name" data-tooltip="${o}">${me(i)}<span class="file-label">${o}</span>${s===void 0?g:c`<span class="file-count">${s}</span>`}</button></li>`}function U0(e,t={}){let r=`file-group-header${t.dropTarget?" default-reports":""}`;return c`<li class="${r}" data-default-reports="${t.dropTarget?"true":g}"><span class="group-label">${e}</span></li>`}var H0=c`<svg viewBox="0 0 16 16" width="11" height="11" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" aria-hidden="true"><path d="M8 3.5v9M3.5 8h9"/></svg>`;function W0(){return c`<li class="file-group-header workspace-header"><span class="group-label">Workspaces</span><span class="workspace-header-actions"><button type="button" class="workspace-add" data-action="new-workspace" title="Create a new workspace" aria-label="Create a new workspace">${H0}</button></span></li>`}function V0(){return c`<li class="file-group-header bundles-header" data-default-bundles="true"><span class="group-label">Bundles</span></li>`}var j0=c`${me(yn)}`;function gg(e,t={}){let{integrity:r,name:n}=e,o=a.selectedBundle===r&&a.currentView==="bundles",i=`file-item bundle-item${t.workspaceId!=null?" indented":""}${o?" current":""}`;return c`<li class="${i}" data-bundle-integrity="${r}" data-workspace-id="${t.workspaceId??g}" draggable="true"><button type="button" class="file-name" data-tooltip="${`${n}
56
+ ${r}`}">${j0}<span class="file-label">${n}</span></button></li>`}function K0(e,t){let r=e.slice(0,15);return c`<li class="file-item indented bundle-item bundle-missing" data-bundle-integrity="${e}" data-workspace-id="${t}" data-tooltip="Bundle bytes not on this device — drop the matching bundle to attach."><span class="file-name"><span class="file-icon" aria-hidden="true">?</span><span class="file-label"><em>missing · ${r}…</em></span></span></li>`}function G0(e,t){return c`<li class="file-item indented report-missing" data-workspace-id="${t}" data-tooltip="Report not on this device — it re-downloads automatically if a workspace member has uploaded it."><span class="file-name"><span class="file-icon" aria-hidden="true">?</span><span class="file-label"><em>missing · ${Me(e)}</em></span></span></li>`}var q0=c`${me(pi)}`,Y0=c`<svg viewBox="0 0 16 16" width="11" height="11" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M8 2v8M5 7l3 3 3-3M3 13h10"/></svg>`,J0=c`<svg viewBox="0 0 16 16" width="11" height="11" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M9 3H4v10h5"/><path d="M7 8h7M11 5l3 3-3 3"/></svg>`,X0=c`<svg viewBox="0 0 16 16" width="11" height="11" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M7 9.5L9 7.5"/><path d="M9.5 5.5L10.5 4.5a2.1 2.1 0 1 1 3 3l-1 1"/><path d="M6.5 11.5L5.5 12.5a2.1 2.1 0 1 1-3-3l1-1"/></svg>`;function Q0(e){let r=`file-item workspace-item${a.currentWorkspace===e.id&&(a.currentView==="findings"||a.currentView==="files")?" current":""}`;return c`<li class="${r}" data-workspace-id="${e.id}"><button type="button" class="file-name">${q0}<span class="file-label" .textContent="${e.name}"></span></button><button type="button" class="workspace-share" data-action="share-workspace" title="Share by link" aria-label="Share workspace by link">${X0}</button><button type="button" class="workspace-export" data-action="export-workspace" title="Export workspace" aria-label="Export workspace">${Y0}</button><button type="button" class="workspace-leave" data-action="leave-workspace" title="Leave workspace" aria-label="Leave workspace">${J0}</button></li>`}function Cn(e){return Pr?Me(e).toLowerCase().includes(Pr):!0}var Dc=(e,t)=>Me(e).localeCompare(Me(t));async function K(){await kl(),xt().catch(()=>{});let e=await fe(),t=V(),r=await gt();if(a.bundles=r,!de)return;Ii.classList.remove("empty");let n=new Set(e),o=new Set;for(let h of t)for(let b of h.reports)n.has(b)&&o.add(b);let s=new Map(r.map(h=>[h.integrity,h])),i=new Set;for(let h of t)for(let b of h.bundles)s.has(b)&&i.add(b);let l=new Map;for(let h of fg)l.set(h,[]);for(let h of e){if(o.has(h)||!Cn(h))continue;let b=Xe(h);l.has(b)||l.set(b,[]),l.get(b).push(h)}let d=t.filter(h=>!Pr||h.name.toLowerCase().includes(Pr)||h.reports.some(b=>Cn(b))?!0:h.bundles.some(b=>{let m=s.get(b);return m&&Cn(m.name)})),u=r.filter(h=>!i.has(h.integrity)&&Cn(h.name));q(c`${W0()} ${X(d,h=>h.id,h=>{let b=[],m=[];for(let w of h.reports)Cn(w)&&(n.has(w)?b.push(w):m.push(w));b.sort(Dc),m.sort(Dc);let y=[],v=[];for(let w of h.bundles){let k=s.get(w);k?(!Pr||Cn(k.name))&&y.push(k):Pr||v.push(w)}return c`${Q0(h)} ${b.map(w=>hg(w,{indented:!0,workspaceId:h.id}))} ${m.map(w=>G0(w,h.id))} ${y.map(w=>gg(w,{workspaceId:h.id}))} ${v.map(w=>K0(w,h.id))}`})} ${fg.map(h=>{let b=(l.get(h)??[]).toSorted(Dc),m=h==="default";return b.length===0&&!(m&&Ri)?null:c`${U0(z0[h]??h,{dropTarget:m})} ${b.map(y=>hg(y))}`})} ${u.length>0||Fi?V0():null} ${X(u,h=>h.integrity,h=>gg(h))}`,Ti);let p=de.querySelector('sidebar-view-button[kind="packages"]');p&&(p.count=N0());let f=de.querySelector('sidebar-view-button[kind="repositories"]');f&&(f.count=D0()),jo(),Ya(e,()=>{K()})}ve(()=>{K()});async function Z0(e){if(e.target.closest('[data-action="go-home"]')){await dh();return}let t=e.target.closest(".file-item[data-bundle-integrity]");if(t){if(t.classList.contains("bundle-missing"))return;let d=t.dataset.bundleIntegrity;if(a.selectedBundle===d&&a.currentView==="bundles")return;a.currentView="bundles",a.selectedBundle=d,a.bundleDetails=null,a.bundleSourceFile=null,a.bundleSourceFindingIdx=null,a.bundleCodeSearchQuery="",a.bundleCodeSearchMode="files",a.bundleSearchQuery="",a.bundleSearchRegex=!1,a.bundleSearchCase=!1,a.bundleSearchContext=!0,a.bundleDetailsTab="overview",C.showAll=!0,a.shownTriage=null,sr(d),$(),K(),Ot(d);return}let r=e.target.closest("sidebar-view-button");if(r){let d=r.getAttribute("kind");(d==="packages"||d==="repositories")&&(a.currentView=d,$(),K());return}if(e.target.closest('[data-action="new-workspace"]')){let d=await Qh();d&&(await ac(),await ll(d),K());return}let n=e.target.closest('[data-action="share-workspace"]');if(n){let d=n.closest("[data-workspace-id]"),u=d?V().find(p=>p.id===d.dataset.workspaceId):null;u&&eg({id:u.id,name:u.name,privateKeyBase64:u.privateKey}).catch(p=>alert(`Failed to open share dialog: ${p.message}`));return}let o=e.target.closest('[data-action="export-workspace"]');if(o){let d=o.closest("[data-workspace-id]"),u=d?V().find(p=>p.id===d.dataset.workspaceId):null;u&&Xh(u).catch(p=>alert(`Failed to open export dialog: ${p.message}`));return}let s=e.target.closest('[data-action="leave-workspace"]');if(s){let d=s.closest("[data-workspace-id]"),u=d?V().find(y=>y.id===d.dataset.workspaceId):null;if(!u)return;let p=Array.isArray(u.reports)?u.reports:[],f;try{f=await Vs(p)}catch(y){alert(`Couldn't read reports to analyze triage impact: ${y.message}`);return}let{confirmed:h,mode:b,triage:m}=await Zh({name:u.name,reportCount:p.length,bundleCount:u.bundles.length,triageImpact:f});if(!h)return;if(!V().some(y=>y.id===u.id)){alert(`Workspace "${u.name}" was removed elsewhere; nothing to leave.`);return}try{await ph(u.id,b,{triage:m})}catch(y){alert(`Failed to leave workspace: ${y.message}`)}return}let i=e.target.closest(".file-item.workspace-item[data-workspace-id]");if(i){let d=i.dataset.workspaceId,u=a.currentView==="findings"||a.currentView==="files";d&&(d!==a.currentWorkspace||!u)&&ir(d);return}let l=e.target.closest(".file-item[data-file]");if(l){let d=l.dataset.file;d&&(d!==a.currentFile||a.currentView!=="findings")&&At(d);return}if(e.target.closest("sidebar-delete-current")){if(a.currentView==="bundles"&&a.selectedBundle){let m=a.selectedBundle,y=(a.bundles??[]).find(k=>k.integrity===m)?.name??m,v=V().filter(k=>Array.isArray(k.bundles)&&k.bundles.includes(m)).filter(k=>Ol(k.id,m)).map(k=>k.id),{confirmed:w}=await rg({name:y,inRemote:v.length>0});if(!w)return;if(a.selectedBundle!==m){alert(`Active bundle changed during confirmation; aborting delete of "${y}".`);return}try{await uh({deleteFromRemoteWorkspaceIds:v})}catch(k){alert(`Failed to delete bundle: ${k.message}`)}return}if(!a.currentFile)return;let d=a.currentFile,u;try{u=await Vs([d])}catch(m){alert(`Couldn't read reports to analyze triage impact: ${m.message}`);return}let p=V().filter(m=>Array.isArray(m.reports)&&m.reports.includes(d)).filter(m=>$o(m.id,d)).map(m=>m.id),f=p.length>0,{confirmed:h,triage:b}=await tg({name:d,triageImpact:u,inRemote:f});if(!h)return;if(a.currentFile!==d){alert(`Active report changed during confirmation; aborting delete of "${d}".`);return}try{await ch({triage:b,deleteFromRemoteWorkspaceIds:p})}catch(m){alert(`Failed to delete report: ${m.message}`)}return}if(e.target.closest("#sync-status")){D.status==="error"?D.dismissError():D.status==="off"?(!D.getServerUrl()&&Wo&&D.setServerUrl(Wo),D.setEnabled(!0)):D.setEnabled(!1);return}if(e.target.closest("#sidebar-toggle")){Ii.classList.toggle("collapsed");try{localStorage.setItem("deepview.sidebarCollapsed",Ii.classList.contains("collapsed")?"1":"0")}catch{}}}function ek(e){let t=e.target.closest("[data-tooltip]");if(!t){Ho();return}Nc(t,{placement:"right",gate:r=>{let n=r.querySelector(".file-label");return!n||(r.dataset.tooltip??"")!==n.textContent?!0:n.scrollWidth>n.clientWidth}})}function tk(e){let t=e.target.closest("[data-tooltip]"),r=e.relatedTarget?.closest?.("[data-tooltip]")??null;t&&t===r||Ho()}function rk(e){Pr=e.target.value.trim().toLowerCase(),K()}var nk={off:"Sync off",online:"Online",offline:"Offline",connecting:"Connecting\u2026",error:"Sync error"};function ok(){return D.getServerUrl()||Wo?V().length>0:!1}function jo(e){let t=de?.querySelector("#sync-status");if(!t)return;let r=ok();if(r&&D.isEnabled()&&Pp().catch(l=>{console.warn("sync: load failed",l)}),r&&!D.getServerUrl()&&Wo&&D.isEnabled()&&D.setServerUrl(Wo),D.setForcedOff(!r),!r){t.hidden=!0;return}t.hidden=!1;let n=e??D.status;t.dataset.status=n;let o=D.persistenceDegraded;t.toggleAttribute("data-degraded",o);let s=D.proxyAuthRequired;t.toggleAttribute("data-proxy-auth",s),t.title=o?"Not saving to this browser right now (storage may be full, or another tab is on a newer version). Changes that haven\u2019t synced could be lost on reload.":s?"Can\u2019t reach the sync server \u2014 the connection is being redirected to a sign-in proxy (e.g. Cloudflare Access). Reload the page to sign in again.":"";let i=t.querySelector(".sync-label");i&&(i.textContent=nk[n]??"")}D.onStatusChange(jo);var zc=!1,Wc=!1;async function mg(){if(!D.persistenceDegraded||Wc||zc)return;zc=!0;let{shown:e}=await sg();if(zc=!1,e){Wc=!0;return}D.persistenceDegraded&&setTimeout(mg,1500)}D.onPersistenceDegraded(e=>{jo(),e?mg():Wc=!1});var Uc=!1,Vc=!1;async function bg(){if(!D.proxyAuthRequired||Vc||Uc)return;Uc=!0;let{shown:e,reload:t}=await ig();if(Uc=!1,!e){D.proxyAuthRequired&&setTimeout(bg,1500);return}Vc=!0,t&&location.reload()}D.onProxyAuthRequired(e=>{jo(),e?bg():Vc=!1});function sk(e){let t=e.target.closest(".file-item.workspace-item");if(!t)return;let r=t.querySelector(".file-label");if(!r||r.querySelector("input"))return;let n=t.dataset.workspaceId,o=V().find(d=>d.id===n);if(!o)return;e.preventDefault();let s=document.createElement("input");s.type="text",s.value=o.name,s.className="workspace-rename-input",r.textContent="",r.append(s),s.focus(),s.select();let i=!1,l=async d=>{i||(i=!0,d&&await dl(n,s.value),K())};s.addEventListener("keydown",d=>{d.key==="Enter"?(d.preventDefault(),l(!0)):d.key==="Escape"&&(d.preventDefault(),l(!1))}),s.addEventListener("blur",()=>l(!0)),s.addEventListener("click",d=>d.stopPropagation()),s.addEventListener("dblclick",d=>d.stopPropagation())}function Bi(){for(let e of de.querySelectorAll(".drag-over"))e.classList.remove("drag-over")}function yg(e){return e.dataTransfer.types.includes(Kc)||e.dataTransfer.types.includes(Vo)}function ik(e){let t=e.target.closest(".file-item[data-bundle-integrity]");if(t){if(t.classList.contains("bundle-missing")){e.preventDefault();return}let n=t.dataset.bundleIntegrity;e.dataTransfer.effectAllowed="move",e.dataTransfer.setData(Vo,n),e.dataTransfer.setData(Hc,t.dataset.workspaceId??""),e.dataTransfer.setData("text/plain",n),t.classList.add("dragging"),Fi=!0,K();return}let r=e.target.closest(".file-item[data-file]");r&&(e.dataTransfer.effectAllowed="move",e.dataTransfer.setData(Kc,r.dataset.file),e.dataTransfer.setData(Hc,r.dataset.workspaceId??""),e.dataTransfer.setData("text/plain",r.dataset.file),r.classList.add("dragging"),Ri=!0,K())}function ak(){for(let e of de.querySelectorAll(".dragging"))e.classList.remove("dragging");Bi(),(Ri||Fi)&&(Ri=!1,Fi=!1,K())}function lk(e){if(!yg(e))return;e.preventDefault();let t=e.target.closest("[data-workspace-id]"),r=de.querySelector(".dragging")?.closest("[data-workspace-id]")?.dataset.workspaceId??null,s=t&&r&&t.dataset.workspaceId===r||!t&&!r;if(e.dataTransfer.dropEffect=s?"none":"move",Bi(),!s)if(t){let i=t.dataset.workspaceId;for(let l of de.querySelectorAll(`[data-workspace-id="${CSS.escape(i)}"]`))l.classList.contains("dragging")||l.classList.add("drag-over")}else{let l=e.dataTransfer.types.includes(Vo)?"[data-default-bundles]":"[data-default-reports]",d=de.querySelector(l);d&&d.classList.add("drag-over")}}function ck(e){de.contains(e.relatedTarget)||Bi()}async function dk(e){if(!yg(e))return;e.preventDefault(),e.stopPropagation(),Bi();let t=e.target.closest("[data-workspace-id]"),r=t?t.dataset.workspaceId:null,n=e.dataTransfer.getData(Hc)||null;if(e.dataTransfer.types.includes(Vo)){let s=e.dataTransfer.getData(Vo);if(!s)return;if(n&&n!==r&&Ol(n,s)){let i=(a.bundles??[]).find(u=>u.integrity===s)?.name??s,l=V().find(u=>u.id===n),{confirmed:d}=await ng({name:i,workspaceName:l?.name??""});if(!d)return;try{await Zs(n,s)}catch(u){console.warn(`Failed to remove '${i}' from source workspace ${n} remote:`,u)}}r&&await Cr(s,r),n&&n!==r&&await gl(s,n),K();return}let o=e.dataTransfer.getData(Kc);if(o){if(n&&n!==r&&$o(n,o)){let s=V().find(l=>l.id===n),{confirmed:i}=await og({name:o,workspaceName:s?.name??""});if(!i)return;try{await Qs(n,o)}catch(l){console.warn(`Failed to remove '${o}' from source workspace ${n} remote:`,l)}}r&&await Bt(o,r),n&&n!==r&&await go(o,n),K()}}function uk(e){Ii=e,de=e.renderRoot,Ti=de.querySelector("#file-list"),rf(de.querySelector("#encryption-toggle")),de.addEventListener("click",Z0),de.addEventListener("dblclick",sk),de.addEventListener("dragstart",ik),de.addEventListener("dragend",ak),de.addEventListener("dragover",lk),de.addEventListener("dragleave",ck),de.addEventListener("drop",dk),Ti.addEventListener("mouseover",ek),Ti.addEventListener("mouseout",tk),de.querySelector("#sidebar-search-input")?.addEventListener("input",rk),jo(D.status),K()}var jc=class extends j{static styles=[B(Qp),B(Xp)];render(){return c`<div class="sidebar-header"><h2 class="brand"><button class="brand-button" type="button" data-action="go-home"><span class="brand-name">DeepView</span></button> <span class="brand-tag">dev</span></h2><button id="encryption-toggle" type="button" hidden></button> <button id="sidebar-toggle" type="button" title="toggle sidebar" aria-label="toggle sidebar"><svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor" aria-hidden="true"><path d="M2 4h12v1.5H2zM2 7.25h12v1.5H2zM2 10.5h12V12H2z"/></svg></button></div><div class="sidebar-search"><svg class="sidebar-search-icon" viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.5" aria-hidden="true"><circle cx="6.5" cy="6.5" r="4.5"/><path d="M9.7 9.7L13 13" stroke-linecap="round"/></svg> <input id="sidebar-search-input" type="search" placeholder="Search reports..." autocomplete="off"><sidebar-view-button kind="packages"></sidebar-view-button><sidebar-view-button kind="repositories"></sidebar-view-button></div><ul id="file-list"></ul><div class="sidebar-actions"><sidebar-delete-current></sidebar-delete-current><button id="sync-status" type="button" data-status="off"><span class="sync-dot" aria-hidden="true"></span> <span class="sync-label">Sync off</span></button></div>`}firstUpdated(){uk(this)}};customElements.define("app-sidebar",jc);var wg={attach:{title:"Synced triage on report attach",intro:"have triage from your workspace that disagrees with your local view on",trailingNote:"Other findings in this report whose chain value didn't conflict were applied automatically; this list only covers disagreements. Pick which side to keep.",importedSideLabel:"Apply from chain",applyButton:"Apply"},chain:{title:"Triage conflict from peer update",intro:"were changed by a peer (or by another tab) in a way that disagrees with your local triage on",trailingNote:`Other findings whose remote value didn't conflict were applied automatically; this list only covers disagreements. Pick which side to keep for each \u2014 a "keep current" pick re-publishes your local value to the chain on your next save.`,importedSideLabel:"Apply from chain",applyButton:"Apply"}};function vg(){Kp(async(e,t,r)=>{let n=Xa(e);try{return await $i(e,n,wg[r]??wg.attach)}catch{let o=e.length;return alert(`${r==="attach"?"A report attach":"A workspace sync"} had ${o} triage disagreement${o===1?"":"s"} with your local view. Kept your local values because another dialog is open. ${r==="attach"?"Detach and re-attach the report to pick again.":"Your local values will re-publish to the chain on the next change."}`),null}})}var Gc=class extends F{static properties={retry:{type:Boolean},_value:{state:!0}};constructor(){super(),this.retry=!1,this._value=""}_finish(t){this._value="",super._finish(t)}_onCancel=()=>this._finish(null);_onInput=t=>{this._value=t.target.value};_onSubmit=()=>{let t=this._value??"";t&&this._finish(t)};_onKeydown=t=>{t.key==="Enter"&&(t.preventDefault(),this._onSubmit())};render(){let t=(this._value??"").length>0,r=this.retry?"That password didn't match. Try again, or cancel to leave the workspace unsynced for now.":"This sync server requires a password before it accepts a new workspace. Enter it to create the workspace on the server.";return c`<dialog @close="${this._onClose}"><header><h3>Sync server password</h3></header><p class="nwd-intro">${r}</p><input type="password" class="nwd-input" placeholder="Password" autocomplete="off" data-1p-ignore="true" data-lpignore="true" data-bwignore="true" data-form-type="other" name="dv-sync-auth" maxlength="4096" .value="${this._value}" @input="${this._onInput}" @keydown="${this._onKeydown}"><footer class="nwd-actions"><span class="nwd-spacer"></span> <button type="button" @click="${this._onCancel}">Cancel</button> <button type="button" class="primary" ?disabled="${!t}" @click="${this._onSubmit}">${this.retry?"Retry":"Authenticate"}</button></footer></dialog>`}};customElements.define("sync-auth-dialog",Gc);function kg({retry:e=!1}={}){return Q("sync-auth-dialog",{retry:!!e})}function $g(){jp(async({retry:e})=>{try{return await kg({retry:e})}catch(t){return console.warn("Sync auth dialog failed to open:",t),null}})}var Mi="https://triage.space/",pk=[{hostname:"deepaudit.dev",pathPrefix:"/",supportsSync:!0},{hostname:"chalker.github.io",pathPrefix:"/deepview/",supportsSync:!1}];function fk(){for(let e of pk)if(location.hostname===e.hostname&&location.pathname.startsWith(e.pathPrefix))return e;return null}var hk=["deepview.triage","deepview.triage.pending"],gk="deepview.repoUrls";function mk(){try{for(let e of hk)if(localStorage.getItem(e))return!0}catch{return!0}try{let e=localStorage.getItem(gk);if(e){let t=JSON.parse(e);if(t&&typeof t=="object"&&Object.keys(t).length>0)return!0}}catch{return!0}return!1}async function bk(){if(mk())return!0;let e=[];try{e=await fe()}catch{return!0}if(e.length>0)return!0;try{if(V().length>0)return!0}catch{return!0}try{return await Ta()}catch{return!0}}var qc=class extends j{static properties={supportsSync:{attribute:!1}};createRenderRoot(){return this}constructor(){super(),this.supportsSync=!1}firstUpdated(){let t=this.querySelector("dialog");t&&t.showModal();let r=this.querySelector("button.om-stay");r&&r.focus()}_finish(t){if(this._settled)return;this._settled=!0;let r=this.querySelector("dialog");r&&r.close(),this.dispatchEvent(new CustomEvent("resolve",{detail:t}))}_onClose=()=>this._finish(!1);_onStay=()=>this._finish(!1);_onMigrate=()=>this._finish(!0);render(){let t=()=>c`<a class="om-link" href="${Mi}" target="_blank" rel="noopener noreferrer">${Mi}</a>`;return c`<dialog class="origin-migration-dialog" @close="${this._onClose}"><header class="om-head"><h3>This deepview build has moved</h3><p><code>${location.host}${location.pathname}</code> has moved to ${t()}.</p></header><section class="om-body"><p>Workspaces and reports don't migrate automatically — they live in this origin's browser storage (OPFS where available, localStorage as a fallback) and have to be re-imported on ${t()}.</p>${this.supportsSync?c`<p>For each workspace, use the <strong>Export workspace</strong> button in the sidebar to download a <code>.gz</code> bundle (workspace + its reports + its triage), then drop that file on ${t()}. Workspaces that had sync configured will pick their triage state back up from the sync server once you re-import them with the same key.</p><p>For triage attached to loose reports (or as a top-up after re-importing workspaces), call <code>DeepView.export()</code> in the browser console — that downloads just the triage entries plus saved repo URLs, no reports or workspaces.</p>`:c`<p>This build has no sync layer. For each workspace, use the <strong>Export workspace</strong> button in the sidebar to download a <code>.gz</code> bundle (workspace + its reports + its triage), then drop that file on ${t()}.</p><p>For triage attached to loose reports, call <code>DeepView.export()</code> in the browser console — that downloads just the triage entries plus saved repo URLs, no reports or workspaces. Reports themselves need to be re-dropped from their original JSON on the new origin.</p>`}</section><footer class="om-actions"><button type="button" class="om-stay" @click="${this._onStay}">Keep editing on ${location.host}</button> <button type="button" class="primary om-go" @click="${this._onMigrate}">Switch to triage.space</button></footer></dialog>`}};customElements.define("origin-migration-dialog",qc);function yk(e){return new Promise(t=>{let r=document.createElement("origin-migration-dialog");r.supportsSync=e.supportsSync,r.addEventListener("resolve",n=>{r.remove(),t(!!n.detail)}),document.body.append(r)})}async function xg(){let e=fk();return e?await bk()?await yk(e)?(location.assign(Mi),!0):!1:(location.replace(Mi),!0):!1}var Yc=class extends F{static styles=[...F.styles,B(nt)];static properties={encoded:{type:String},_stage:{state:!0},_password:{state:!0},_name:{state:!0},_decoded:{state:!0},_existingById:{state:!0},_busy:{state:!0},_error:{state:!0},_settled:{state:!0}};constructor(){super(),this.encoded="",this._stage="password",this._password="",this._name="",this._decoded=null,this._existingById=null,this._busy=!1,this._error="",this._settled=!1}focusInitial(){this._focusActiveInput()}updated(t){t.has("_stage")&&this._focusActiveInput()}_focusActiveInput(){if(this._stage==="password")this.renderRoot.querySelector('input[type="password"]')?.focus();else if(this._stage==="name"){let t=this.renderRoot.querySelector('input[data-role="name"]');t&&(t.focus(),t.select())}}_finish(t){this._settled||(this._decoded=null,this._password="",this.encoded="",super._finish(t))}_onClose=()=>this._finish(null);_onCancel=()=>this._finish(null);_onPasswordInput=t=>{this._password=t.target.value,this._error=""};_onNameInput=t=>{this._name=t.target.value};_onUnlock=async()=>{if(!(!this._password||this._busy)){this._busy=!0,this._error="";try{let t=await Fl({encoded:this.encoded,password:this._password});if(this._settled)return;let r=V().find(n=>n.id===t.id)??null;this._decoded=t,this._existingById=r,this._name=t.name,this._password="",this._stage="name"}catch(t){if(this._settled)return;this._error=t?.message??String(t)}finally{this._busy=!1}}};_onAttach=()=>{if(!this._decoded)return;let t=_t(this._name);if(!t)return;let r=V().find(n=>n.id===this._decoded.id)??null;if(r){this._existingById=r;return}this._nameCollision(t)||this._finish({id:this._decoded.id,name:t,privateKeyBase64:this._decoded.privateKeyBase64})};_nameCollision(t){if(!t||!this._decoded)return null;for(let r of V())if(r.id!==this._decoded.id&&_t(r.name)===t)return r;return null}_onKeydown=t=>{t.key==="Enter"&&(t.preventDefault(),this._stage==="password"?this._onUnlock():this._stage==="name"&&this._onAttach())};_passwordStage(){return c`<p class="nwd-note">Someone shared a workspace with you. Enter the password they sent separately to attach it to this browser.</p><label class="wsl-field"><span>Password</span> <input type="password" class="nwd-input" autocomplete="off" data-1p-ignore="true" data-lpignore="true" data-bwignore="true" data-form-type="other" name="dv-share-link-unlock" maxlength="1024" .value="${this._password}" @input="${this._onPasswordInput}" @keydown="${this._onKeydown}"></label> ${this._error?c`<p class="wsl-error" role="alert">${this._error}</p>`:g}<footer class="nwd-actions"><span class="nwd-spacer"></span> <button type="button" @click="${this._onCancel}">Cancel</button> <button type="button" class="primary" ?disabled="${!this._password||this._busy}" @click="${this._onUnlock}">${this._busy?"Unlocking\u2026":"Unlock"}</button></footer>`}_alreadyAttachedStage(){let t=this._existingById;return c`<p class="nwd-note">This workspace is already attached as <strong>"${t?.name??""}"</strong>. Open it from the sidebar.</p><footer class="nwd-actions"><span class="nwd-spacer"></span> <button type="button" class="primary" @click="${this._onCancel}">Close</button></footer>`}_nameStage(){if(this._existingById)return this._alreadyAttachedStage();let t=_t(this._name),r=this._nameCollision(t),n=!!t&&!r;return c`<p class="nwd-note">Pick a name for the workspace on this device. The shared identity is preserved either way — only the visible label changes.</p><label class="wsl-field"><span>Workspace name</span> <input type="text" class="nwd-input" data-role="name" placeholder="Workspace name" maxlength="200" .value="${this._name}" @input="${this._onNameInput}" @keydown="${this._onKeydown}"></label> ${r?c`<p class="wsl-error" role="alert">A workspace named "${t}" already exists on this device. Pick a different name.</p>`:g}<footer class="nwd-actions"><span class="nwd-spacer"></span> <button type="button" @click="${this._onCancel}">Cancel</button> <button type="button" class="primary" ?disabled="${!n}" @click="${this._onAttach}">Attach</button></footer>`}render(){let t=this._stage==="password"?"Attach shared workspace":this._existingById?"Workspace already attached":"Name the workspace";return c`<dialog @close="${this._onClose}"><header><h3>${t}</h3></header>${this._stage==="password"?this._passwordStage():this._nameStage()}</dialog>`}};customElements.define("workspace-unlock-link-dialog",Yc);function _g({encoded:e}={}){return new Promise((t,r)=>{let n=document.createElement("workspace-unlock-link-dialog");n.encoded=e??"",n.addEventListener("resolve",o=>{n.remove(),t(o.detail)}),n.addEventListener("modal-conflict",o=>{n.encoded="",n.remove(),r(yt(o.detail?.cause))}),document.body.append(n)})}var We=null,Li=!1,Ko=null;function wk(e){if(!e)return"Could not unlock. Try again.";switch(e.name??""){case"NotAllowedError":case"AbortError":return"";case"SecurityError":return"The site identity does not match the one this passkey was registered for. If you opened DeepView through a different URL (different subdomain, different port), reload via the original URL.";case"InvalidStateError":return"The passkey state on this device is inconsistent. Try reloading the page or removing and re-creating the passkey.";case"NotSupportedError":return"This browser does not support the WebAuthn PRF extension this site needs. Try a recent Chrome, Safari, or Edge with a platform authenticator.";case"NetworkError":return"A network error prevented the passkey from completing. Check your connection and try again.";case"UnknownError":return"The authenticator returned an unknown error. Try again, or use a different passkey.";default:{let r=e.message??String(e);return r.length>200?r.slice(0,197)+"\u2026":r}}}function vk(){if(We)return We;We=document.createElement("div"),We.id="lock-overlay",We.setAttribute("role","dialog"),We.setAttribute("aria-modal","true"),We.setAttribute("aria-label","Unlock DeepView"),We.innerHTML=`
56
57
  <div class="lock-overlay-card">
57
58
  <div class="lock-overlay-icon" aria-hidden="true">
58
59
  <svg viewBox="0 0 32 32" width="40" height="40" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="7" y="15" width="18" height="12" rx="1.5"/><path d="M11 15v-4a5 5 0 0 1 10 0v4"/></svg>
@@ -69,30 +70,30 @@ ${r}`}">${e0}<span class="file-label">${n}</span></button></li>`}function t0(e,t
69
70
  <a href="#" class="lock-overlay-wipe">Wipe local data and start over</a>
70
71
  </p>
71
72
  </div>
72
- `;let e=De.querySelector("button"),t=De.querySelector(".lock-overlay-error");return e.addEventListener("click",async()=>{if(!vi){vi=!0,t.hidden=!0,t.textContent="",e.disabled=!0,e.textContent="Waiting\u2026",Io=new AbortController;try{let n=await Mn({signal:Io.signal})}catch(n){let o=A0(n);t.textContent=o,t.hidden=!o}finally{vi=!1,Io=null,e.disabled=!1,e.textContent="Unlock with passkey"}}}),De.querySelector(".lock-overlay-wipe").addEventListener("click",async n=>{if(n.preventDefault(),!vi&&confirm(`Wipe ALL local DeepView data and start over?
73
+ `;let e=We.querySelector("button"),t=We.querySelector(".lock-overlay-error");return e.addEventListener("click",async()=>{if(!Li){Li=!0,t.hidden=!0,t.textContent="",e.disabled=!0,e.textContent="Waiting\u2026",Ko=new AbortController;try{let n=await qn({signal:Ko.signal})}catch(n){let o=wk(n);t.textContent=o,t.hidden=!o}finally{Li=!1,Ko=null,e.disabled=!1,e.textContent="Unlock with passkey"}}}),We.querySelector(".lock-overlay-wipe").addEventListener("click",async n=>{if(n.preventDefault(),!Li&&confirm(`Wipe ALL local DeepView data and start over?
73
74
 
74
75
  This deletes your encrypted triage, all reports, and the passkey registration on this device. The data CANNOT be recovered after this \u2014 there is no backup.
75
76
 
76
- Use this only if you have lost access to your passkey and have no other way to unlock.`)&&confirm("Really wipe everything? This cannot be undone.")){try{await Ln()}catch(o){alert(`Wipe failed: ${o?.message??o}. Try again or clear localStorage manually via DevTools.`);return}location.reload()}}),document.body.append(De),De}function I0(){return vt()?Q()&&!ct():!1}function Kh(){if(I0()){let e=T0();e.hidden=!1;let t=e.querySelector("button");t&&t.focus()}else if(De&&(De.hidden=!0,Io))try{Io.abort()}catch{}}ve(Kh);Kh();var Gh=`dialog{max-width:640px;width:min(94vw,640px)}header h3{margin:0 0 .4rem}.finding{display:flex;align-items:center;gap:.5rem;flex-wrap:wrap;margin-bottom:.35rem}.loc{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:.76rem;color:var(--text);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0;flex:1}.desc{font-size:.78rem;color:var(--muted);margin:0 0 .7rem;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}textarea{display:block;width:100%;box-sizing:border-box;min-height:9rem;max-height:50vh;resize:vertical;padding:.55rem .65rem;border:1px solid var(--border);border-radius:6px;background:var(--bg, var(--surface));color:var(--text);font:inherit;font-size:.88rem;line-height:1.4;&:focus{outline:none;border-color:var(--accent);box-shadow:0 0 0 3px rgb(from var(--accent) r g b / .18)}&::placeholder{color:var(--muted)}}
77
- `;var Rc=class extends I{static styles=[...I.styles,T(pn),T(Gh)];static properties={initial:{attribute:!1},finding:{attribute:!1},_value:{state:!0}};constructor(){super(),this.initial="",this.finding=null,this._value=""}beforeOpen(){this._value=this.initial??""}focusInitial(){let t=this.renderRoot.querySelector("textarea");if(!t)return;t.focus();let r=t.value.length;try{t.setSelectionRange(r,r)}catch{}}_onInput=t=>{this._value=t.target.value};_onSave=()=>{let t=(this._value??"").trim(),r=(this.initial??"").trim();if(t===r){this._finish(null);return}this._finish(t)};_onClear=()=>this._finish("");_onCancel=()=>this._finish(null);_onKeydown=t=>{t.key==="Enter"&&(t.ctrlKey||t.metaKey)&&(t.preventDefault(),this._onSave())};render(){let t=this.finding??{},r=t.file?t.line?`${t.file}:${t.line}`:t.file:"",n=(this.initial??"").length>0;return c`<dialog @close="${this._onClose}"><header><h3>${n?"Edit comment":"Add comment"}</h3><div class="finding">${fn(t.severity)} ${r?c`<span class="loc" title="${r}">${r}</span>`:g}</div>${t.description?c`<div class="desc" title="${t.description}">${t.description}</div>`:g}</header><textarea rows="6" placeholder="Write your notes here. Markdown is not rendered. Ctrl/⌘+Enter to save, Esc to cancel." .value="${this._value}" @input="${this._onInput}" @keydown="${this._onKeydown}"></textarea><footer class="nwd-actions">${n?c`<button type="button" class="danger" @click="${this._onClear}">Clear</button>`:g} <span class="nwd-spacer"></span> <button type="button" @click="${this._onCancel}">Cancel</button> <button type="button" class="primary" @click="${this._onSave}">Save</button></footer></dialog>`}};customElements.define("comment-dialog",Rc);function qh({initial:e="",finding:t=null}={}){return q("comment-dialog",{initial:e,finding:t})}var Yh=`dialog{max-width:560px;width:min(94vw,560px)}header h3{margin:0 0 .4rem}.finding{display:flex;align-items:center;gap:.5rem;flex-wrap:wrap;margin-bottom:.35rem}.loc{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:.76rem;color:var(--text);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0;flex:1}.desc{font-size:.78rem;color:var(--muted);margin:0 0 .7rem;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}.input-row{display:flex;align-items:stretch;gap:.4rem}input{flex:1;min-width:0;padding:.5rem .65rem;border:1px solid var(--border);border-radius:6px;background:var(--bg, var(--surface));color:var(--text);font:inherit;font-size:.88rem;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;&:focus{outline:none;border-color:var(--accent);box-shadow:0 0 0 3px rgb(from var(--accent) r g b / .18)}&::placeholder{color:var(--muted);font-family:inherit}}.open{display:inline-flex;align-items:center;padding:0 .7rem;border:1px solid var(--accent);border-radius:6px;color:var(--accent);text-decoration:none;font-size:.8rem;font-weight:600;white-space:nowrap;&:hover{background:rgb(from var(--accent) r g b / .1)}}.hint{margin:.45rem 0 0;color:var(--muted);font-size:.74rem}
78
- `;var Fc=class extends I{static styles=[...I.styles,T(pn),T(Yh)];static properties={initial:{attribute:!1},finding:{attribute:!1},_value:{state:!0}};constructor(){super(),this.initial="",this.finding=null,this._value=""}beforeOpen(){this._value=this.initial??""}focusInitial(){let t=this.renderRoot.querySelector('input[type="url"]');if(t){t.focus();try{t.select()}catch{}}}_onInput=t=>{this._value=t.target.value};_onSave=()=>{let t=(this._value??"").trim(),r=(this.initial??"").trim();if(t===r){this._finish(null);return}this._finish(t)};_onClear=()=>this._finish("");_onCancel=()=>this._finish(null);_onKeydown=t=>{t.key==="Enter"&&(t.preventDefault(),this._onSave())};render(){let t=this.finding??{},r=t.file?t.line?`${t.file}:${t.line}`:t.file:"",n=(this.initial??"").length>0,o=(this._value??"").trim(),s=rn(o);return c`<dialog @close="${this._onClose}"><header><h3>${n?"Edit fix link":"Add fix link"}</h3><div class="finding">${fn(t.severity)} ${r?c`<span class="loc" title="${r}">${r}</span>`:g}</div>${t.description?c`<div class="desc" title="${t.description}">${t.description}</div>`:g}</header><div class="input-row"><input type="url" inputmode="url" autocomplete="off" spellcheck="false" placeholder="https://github.com/owner/repo/pull/123" .value="${this._value}" @input="${this._onInput}" @keydown="${this._onKeydown}"> ${s?c`<a class="open" href="${o}" target="_blank" rel="noopener noreferrer" title="Open in a new tab">Open ↗</a>`:g}</div><p class="hint">PR URL, issue link, commit, or any free-form reference. Enter to save, Esc to cancel.</p><footer class="nwd-actions">${n?c`<button type="button" class="danger" @click="${this._onClear}">Clear</button>`:g} <span class="nwd-spacer"></span> <button type="button" @click="${this._onCancel}">Cancel</button> <button type="button" class="primary" @click="${this._onSave}">Save</button></footer></dialog>`}};customElements.define("fix-link-dialog",Fc);function Jh({initial:e="",finding:t=null}={}){return q("fix-link-dialog",{initial:e,finding:t})}var B0={critical:"Critical",high:"High",medium:"Medium",low:"Low",high_bug:"High Bug",bug:"Bug",informational:"Informational"},M0=["critical","high","medium","low","high_bug","bug","informational"];function L0(e){return B0[e]??e}function Xh(e){let t=M0.indexOf(e);return t===-1?999:t}function Qh(e){let t=parseInt(e.line,10);return Number.isFinite(t)?`${e.file}:${t}`:e.file}function P0(e){let t=O(e),r=a.triage.get(t),n=r?.triage,o=nn(e),s=r?.color,i=r?.comment??"",l=st(e.description??"",e),d=$r(e),p=[d?`### ${Qh(e)} - ${d}`:`### ${Qh(e)}`,""],f=[];return e.confidence!==void 0&&f.push(`**Confidence:** ${e.confidence}/10`),n?f.push(`**Triage:** ${n}`):o&&f.push("**Ignored**"),s&&f.push(`**Mark:** ${s}`),r?.flagged===!0&&f.push("**Flagged**"),f.length>0&&(p.push(f.join(", ")),p.push("")),l&&(p.push(l.trim()),p.push("")),e.recommendation&&(p.push(`**Recommendation:** ${st(e.recommendation,e).trim()}`),p.push("")),e.confidenceReason&&(p.push(`**Confidence reason:** ${st(e.confidenceReason,e).trim()}`),p.push("")),e.fix&&(p.push(`**Fix:** ${st(e.fix,e).trim()}`),p.push("")),i&&(p.push(`**Comment:** ${i.trim()}`),p.push("")),p.join(`
79
- `)}function O0(e){let t=(e.groups??[]).flat(),r=[`# ${e.fileName}`,""];if(e.source&&(r.push(`**Source:** ${e.source}`),r.push("")),r.push(`**Findings:** ${t.length}`),r.push(""),t.length===0)return r.join(`
80
- `);let n=new Map;for(let s of t){let i=s.severity??"informational";n.has(i)||n.set(i,[]),n.get(i).push(s)}let o=[...n.keys()].toSorted((s,i)=>Xh(s)-Xh(i));for(let s of o){let i=n.get(s);r.push(`## ${L0(s)} (${i.length})`),r.push("");for(let l of i)r.push(P0(l))}return r.join(`
77
+ Use this only if you have lost access to your passkey and have no other way to unlock.`)&&confirm("Really wipe everything? This cannot be undone.")){try{await Yn()}catch(o){alert(`Wipe failed: ${o?.message??o}. Try again or clear localStorage manually via DevTools.`);return}location.reload()}}),document.body.append(We),We}function kk(){return kt()?ne()&&!pt():!1}function Sg(){if(kk()){let e=vk();e.hidden=!1;let t=e.querySelector("button");t&&t.focus()}else if(We&&(We.hidden=!0,Ko))try{Ko.abort()}catch{}}ve(Sg);Sg();var Cg=`dialog{max-width:640px;width:min(94vw,640px)}header h3{margin:0 0 .4rem}.finding{display:flex;align-items:center;gap:.5rem;flex-wrap:wrap;margin-bottom:.35rem}.loc{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:.76rem;color:var(--text);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0;flex:1}.desc{font-size:.78rem;color:var(--muted);margin:0 0 .7rem;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}textarea{display:block;width:100%;box-sizing:border-box;min-height:9rem;max-height:50vh;resize:vertical;padding:.55rem .65rem;border:1px solid var(--border);border-radius:6px;background:var(--bg, var(--surface));color:var(--text);font:inherit;font-size:.88rem;line-height:1.4;&:focus{outline:none;border-color:var(--accent);box-shadow:0 0 0 3px rgb(from var(--accent) r g b / .18)}&::placeholder{color:var(--muted)}}
78
+ `;var Jc=class extends F{static styles=[...F.styles,B($n),B(Cg)];static properties={initial:{attribute:!1},finding:{attribute:!1},_value:{state:!0}};constructor(){super(),this.initial="",this.finding=null,this._value=""}beforeOpen(){this._value=this.initial??""}focusInitial(){let t=this.renderRoot.querySelector("textarea");if(!t)return;t.focus();let r=t.value.length;try{t.setSelectionRange(r,r)}catch{}}_onInput=t=>{this._value=t.target.value};_onSave=()=>{let t=(this._value??"").trim(),r=(this.initial??"").trim();if(t===r){this._finish(null);return}this._finish(t)};_onClear=()=>this._finish("");_onCancel=()=>this._finish(null);_onKeydown=t=>{t.key==="Enter"&&(t.ctrlKey||t.metaKey)&&(t.preventDefault(),this._onSave())};render(){let t=this.finding??{},r=t.file?t.line?`${t.file}:${t.line}`:t.file:"",n=(this.initial??"").length>0;return c`<dialog @close="${this._onClose}"><header><h3>${n?"Edit comment":"Add comment"}</h3><div class="finding">${xn(t.severity)} ${r?c`<span class="loc" title="${r}">${r}</span>`:g}</div>${t.description?c`<div class="desc" title="${t.description}">${t.description}</div>`:g}</header><textarea rows="6" placeholder="Write your notes here. Markdown is not rendered. Ctrl/⌘+Enter to save, Esc to cancel." .value="${this._value}" @input="${this._onInput}" @keydown="${this._onKeydown}"></textarea><footer class="nwd-actions">${n?c`<button type="button" class="danger" @click="${this._onClear}">Clear</button>`:g} <span class="nwd-spacer"></span> <button type="button" @click="${this._onCancel}">Cancel</button> <button type="button" class="primary" @click="${this._onSave}">Save</button></footer></dialog>`}};customElements.define("comment-dialog",Jc);function Eg({initial:e="",finding:t=null}={}){return Q("comment-dialog",{initial:e,finding:t})}var Ag=`dialog{max-width:560px;width:min(94vw,560px)}header h3{margin:0 0 .4rem}.finding{display:flex;align-items:center;gap:.5rem;flex-wrap:wrap;margin-bottom:.35rem}.loc{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:.76rem;color:var(--text);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0;flex:1}.desc{font-size:.78rem;color:var(--muted);margin:0 0 .7rem;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}.input-row{display:flex;align-items:stretch;gap:.4rem}input{flex:1;min-width:0;padding:.5rem .65rem;border:1px solid var(--border);border-radius:6px;background:var(--bg, var(--surface));color:var(--text);font:inherit;font-size:.88rem;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;&:focus{outline:none;border-color:var(--accent);box-shadow:0 0 0 3px rgb(from var(--accent) r g b / .18)}&::placeholder{color:var(--muted);font-family:inherit}}.open{display:inline-flex;align-items:center;padding:0 .7rem;border:1px solid var(--accent);border-radius:6px;color:var(--accent);text-decoration:none;font-size:.8rem;font-weight:600;white-space:nowrap;&:hover{background:rgb(from var(--accent) r g b / .1)}}.hint{margin:.45rem 0 0;color:var(--muted);font-size:.74rem}
79
+ `;var Xc=class extends F{static styles=[...F.styles,B($n),B(Ag)];static properties={initial:{attribute:!1},finding:{attribute:!1},_value:{state:!0}};constructor(){super(),this.initial="",this.finding=null,this._value=""}beforeOpen(){this._value=this.initial??""}focusInitial(){let t=this.renderRoot.querySelector('input[type="url"]');if(t){t.focus();try{t.select()}catch{}}}_onInput=t=>{this._value=t.target.value};_onSave=()=>{let t=(this._value??"").trim(),r=(this.initial??"").trim();if(t===r){this._finish(null);return}this._finish(t)};_onClear=()=>this._finish("");_onCancel=()=>this._finish(null);_onKeydown=t=>{t.key==="Enter"&&(t.preventDefault(),this._onSave())};render(){let t=this.finding??{},r=t.file?t.line?`${t.file}:${t.line}`:t.file:"",n=(this.initial??"").length>0,o=(this._value??"").trim(),s=dn(o);return c`<dialog @close="${this._onClose}"><header><h3>${n?"Edit fix link":"Add fix link"}</h3><div class="finding">${xn(t.severity)} ${r?c`<span class="loc" title="${r}">${r}</span>`:g}</div>${t.description?c`<div class="desc" title="${t.description}">${t.description}</div>`:g}</header><div class="input-row"><input type="url" inputmode="url" autocomplete="off" spellcheck="false" placeholder="https://github.com/owner/repo/pull/123" .value="${this._value}" @input="${this._onInput}" @keydown="${this._onKeydown}"> ${s?c`<a class="open" href="${o}" target="_blank" rel="noopener noreferrer" title="Open in a new tab">Open ↗</a>`:g}</div><p class="hint">PR URL, issue link, commit, or any free-form reference. Enter to save, Esc to cancel.</p><footer class="nwd-actions">${n?c`<button type="button" class="danger" @click="${this._onClear}">Clear</button>`:g} <span class="nwd-spacer"></span> <button type="button" @click="${this._onCancel}">Cancel</button> <button type="button" class="primary" @click="${this._onSave}">Save</button></footer></dialog>`}};customElements.define("fix-link-dialog",Xc);function Tg({initial:e="",finding:t=null}={}){return Q("fix-link-dialog",{initial:e,finding:t})}var _k={critical:"Critical",high:"High",medium:"Medium",low:"Low",high_bug:"High Bug",bug:"Bug",informational:"Informational"},Sk=["critical","high","medium","low","high_bug","bug","informational"];function Ck(e){return _k[e]??e}function Ig(e){let t=Sk.indexOf(e);return t===-1?999:t}function Rg(e){let t=parseInt(e.line,10);return Number.isFinite(t)?`${e.file}:${t}`:e.file}function Ek(e){let t=P(e),r=a.triage.get(t),n=r?.triage,o=fn(e),s=r?.color,i=r?.comment??"",l=ot(e.description??"",e),d=Er(e),p=[d?`### ${Rg(e)} - ${d}`:`### ${Rg(e)}`,""],f=[];return e.confidence!==void 0&&f.push(`**Confidence:** ${e.confidence}/10`),n?f.push(`**Triage:** ${n}`):o&&f.push("**Ignored**"),s&&f.push(`**Mark:** ${s}`),r?.flagged===!0&&f.push("**Flagged**"),f.length>0&&(p.push(f.join(", ")),p.push("")),l&&(p.push(l.trim()),p.push("")),e.recommendation&&(p.push(`**Recommendation:** ${ot(e.recommendation,e).trim()}`),p.push("")),e.confidenceReason&&(p.push(`**Confidence reason:** ${ot(e.confidenceReason,e).trim()}`),p.push("")),e.fix&&(p.push(`**Fix:** ${ot(e.fix,e).trim()}`),p.push("")),i&&(p.push(`**Comment:** ${i.trim()}`),p.push("")),p.join(`
80
+ `)}function Ak(e){let t=(e.groups??[]).flat(),r=[`# ${e.fileName}`,""];if(e.source&&(r.push(`**Source:** ${e.source}`),r.push("")),r.push(`**Findings:** ${t.length}`),r.push(""),t.length===0)return r.join(`
81
+ `);let n=new Map;for(let s of t){let i=s.severity??"informational";n.has(i)||n.set(i,[]),n.get(i).push(s)}let o=[...n.keys()].toSorted((s,i)=>Ig(s)-Ig(i));for(let s of o){let i=n.get(s);r.push(`## ${Ck(s)} (${i.length})`),r.push("");for(let l of i)r.push(Ek(l))}return r.join(`
81
82
  `).trimEnd()+`
82
- `}function N0(e){return e.map(O0).join(`
83
+ `}function Tk(e){return e.map(Ak).join(`
83
84
  ---
84
85
 
85
- `)}function D0(e){let t=e.map(n=>n.fileName),r="";return t.length===1?r=t[0]:t.length>1&&(r=js(t)),r=r.replace(/\.json$/u,""),`${r||"deepview-report"}.md`}function Zh(e){if(e.length===0)return;let t=N0(e),r=new Blob([t],{type:"text/markdown;charset=utf-8"});Pr(r,D0(e))}Sa(()=>{a.currentView==="bundles"&&a.selectedBundle?x():a.currentView==="packages"?x():a.currentView==="repositories"?x():(a.currentView==="findings"||a.currentView==="files")&&j().catch(()=>{})});function eg(){a.currentView==="bundles"&&a.bundleDetailsTab==="graph"?di():dc()}function $i(){a.currentView==="bundles"&&a.bundleDetailsTab==="graph"?ui():uc()}function Bo(){let e=document.querySelector(".bundle-source-code-wrap"),t=e?.scrollTop??0,r=e?.scrollLeft??0;x();let n=document.querySelector(".bundle-source-code-wrap");n&&(n.scrollTop=t,n.scrollLeft=r)}function Ro(e){let r=document.querySelector(e)?.scrollTop??0;x();let n=document.querySelector(e);n&&(n.scrollTop=r)}function ar(){a.viewMode==="table"?Ro(".findings-table-list"):x()}var Bc=0;function U0(){Bc||(Bc=requestAnimationFrame(()=>{Bc=0,x()}))}function J(e,t){for(let r of e.composedPath())if(r?.matches?.(t))return r;return null}function tg(e){let r=J(e,"[data-gid]")?.dataset?.gid,n=r?_r(r):null;if(!n)return null;let o=Te(n);return Vp(o,Ks(o))}C.addEventListener("click",e=>{let t=J(e,"[data-finding-code-bundle]");if(t){let _=t.dataset.findingCodeBundle,V=t.dataset.findingCodeFile,Z=t.dataset.findingCodeLine,ce=Z?parseInt(Z,10):null;a.bundleSourceFile=V||null,a.bundleSourceFindingIdx=null,(a.bundleDetailsTab==="code"||a.bundleDetailsTab==="search")&&(a.bundleDetailsTab="overview");let ye=()=>{Number.isFinite(ce)&&queueMicrotask(()=>{let se=document.querySelector(`.bundle-source-lineno-row[data-line="${ce}"]`);se&&se.scrollIntoView({block:"start",behavior:"instant"})})};if(a.selectedBundle===_&&a.bundleDetails?.integrity===_){x(),ye();return}a.selectedBundle=_,a.bundleDetails=null,x(),(async()=>(await Ot(_),ye()))();return}let r=e.target.closest("[data-package-expand]");if(r){let _=r.dataset.packageExpand;a.expandedPackages.has(_)?a.expandedPackages.delete(_):a.expandedPackages.add(_),x();return}let n=e.target.closest("[data-package-row-issues]");if(n){let _=n.dataset.packageRowIssues,V=n.dataset.packageRowIssuesVersion;a.selectedPackage=_,a.selectedPackageVersion=V||null,a.packageDetailsTab="issues",a.packageSlideTriage=null,a.packageSlideTransient=!0,x();return}let o=e.target.closest("[data-repository-row-issues]");if(o){let _=o.dataset.repositoryRowIssues;a.selectedRepository=_,a.repositoryDetailsTab="issues",a.repositorySlideTriage=null,a.repositorySlideTransient=!0,x();return}let s=e.target.closest("[data-select-package]");if(s){let _=s.dataset.selectPackage,V=s.dataset.selectPackageVersion??"",Z=V===""?null:V;if(a.selectedPackage===_&&a.selectedPackageVersion===Z)return;a.selectedPackage=_,a.selectedPackageVersion=Z,a.packageDetailsTab="overview",a.packageSlideTriage=null,a.packageSlideTransient=!1,x();return}if(e.target.closest("[data-deselect-package]")){a.selectedPackage=null,a.selectedPackageVersion=null,x();return}let i=e.target.closest("[data-package-tab]");if(i){let _=i.dataset.packageTab;(_==="overview"||_==="issues")&&a.packageDetailsTab!==_&&(a.packageDetailsTab=_,x());return}if(e.target.closest('[data-action="package-slide-back"]')){a.packageDetailsTab="overview",a.packageSlideTriage=null,a.packageSlideTransient&&(a.selectedPackage=null,a.selectedPackageVersion=null,a.packageSlideTransient=!1),x();return}let l=e.target.closest("[data-package-report]");if(l){let _=l.dataset.packageReport;_&&Et(_);return}let d=e.target.closest("[data-select-repository]");if(d){let _=d.dataset.selectRepository;if(a.selectedRepository===_)return;a.selectedRepository=_,a.repositoryDetailsTab="overview",a.repositorySlideTriage=null,a.repositorySlideTransient=!1,x();return}if(e.target.closest("[data-deselect-repository]")){a.selectedRepository=null,x();return}let u=e.target.closest("[data-repository-tab]");if(u){let _=u.dataset.repositoryTab;(_==="overview"||_==="issues")&&a.repositoryDetailsTab!==_&&(a.repositoryDetailsTab=_,x());return}if(e.target.closest('[data-action="repository-slide-back"]')){a.repositoryDetailsTab="overview",a.repositorySlideTriage=null,a.repositorySlideTransient&&(a.selectedRepository=null,a.repositorySlideTransient=!1),x();return}let p=e.target.closest("[data-bundle-tab]");if(p){let _=p.dataset.bundleTab;wo.has(_)&&(a.bundleDetailsTab==="graph"&&_!=="graph"&&He(),a.bundleDetailsTab=_,a.bundleSourceFile=null,a.bundleSourceFindingIdx=null,a.selectedBundle&&Sr(a.selectedBundle,_),x());return}if(J(e,"[data-bundle-search-context]")){a.bundleSearchContext=!a.bundleSearchContext,Ro(".bundle-search-results");return}if(e.target.closest("[data-advisories-consent]")){Uf(),x();return}let h=e.target.closest("[data-bundle-issue-report]");if(h){let _=h.dataset.bundleIssueReport;_&&Et(_);return}if(e.target.classList?.contains("bundle-source-overlay")||e.target.closest('[data-action="bundle-source-close"]')){a.bundleSourceFile&&(a.bundleSourceFile=null,a.bundleSourceFindingIdx=null,x());return}if(e.target.closest('[data-action="bundle-source-panel-close"]')){a.bundleSourceFindingIdx!=null&&(a.bundleSourceFindingIdx=null,Bo());return}let b=e.target.closest("[data-bundle-source-finding]");if(b){let _=parseInt(b.dataset.bundleSourceFinding,10);Number.isFinite(_)&&(a.bundleSourceFindingIdx=a.bundleSourceFindingIdx===_?null:_,Bo());return}let m=J(e,"[data-bundle-view-source]");if(m){let _=m.dataset.bundleViewSource;if(!_)return;let V=m.dataset.bundleViewFindingIdx,Z=V===void 0?null:parseInt(V,10),ce=m.dataset.bundleViewLine,ye=ce?parseInt(ce,10):null;if(a.bundleSourceFile=_,Number.isFinite(Z)&&(a.bundleSourceFindingIdx=Z),m.closest(".bundle-code-rail")?Ro(".bundle-code-rail-body"):m.closest(".bundle-search-results")?Ro(".bundle-search-results"):m.closest(".bundles-slide-body")?Ro(".bundles-slide-body"):x(),Number.isFinite(ye)){let se=m.dataset.bundleViewScrollBlock||"center";queueMicrotask(()=>{let Ve=document.querySelector(`.bundle-source-lineno-row[data-line="${ye}"]`);Ve&&Ve.scrollIntoView({block:se,behavior:"smooth"})})}return}if(e.target.closest('[data-action="toggle-files"]')){a.currentView==="files"?a.currentView="findings":(a.viewMode==="graph"&&He(),a.currentView="files"),document.body.classList.remove("report-fullscreen"),x();return}let k=J(e,"[data-g2-pkg]");if(k){let _=k.dataset.g2Pkg;E.solo=E.solo===_?null:_,E.solo&&(E.selected=null),eg(),$i(),E.graphState?.requestDraw?.();return}let w=J(e,"[data-g2-select]");if(w){E.selected=w.dataset.g2Select,eg();return}let v=J(e,"[data-g2-top-pkgs]");if(v){E.topPkgsTab=v.dataset.g2TopPkgs,$i();return}let $=J(e,"[data-g2-jump-findings]");if($){if(a.currentView==="bundles"){a.bundleDetailsTab==="graph"&&He(),a.bundleDetailsTab="issues",a.bundleSourceFile=null,a.bundleSourceFindingIdx=null,a.selectedBundle&&Sr(a.selectedBundle,"issues"),x();return}Gs(),a.filterConfMin=0,a.filterInclude=$.dataset.g2JumpFindings,a.currentView="findings",a.viewMode==="graph"&&(a.viewMode="table"),He(),x();return}let R=J(e,"[data-g2-jump-file]");if(R){let _=R.dataset.g2JumpFile;a.currentView="files",He(),x(),requestAnimationFrame(()=>{let V=document.querySelector(`#${go(_)}`);V&&V.scrollIntoView({behavior:"smooth",block:"start"})});return}if(J(e,"#g2-path-filter-clear")){E.pathFilter="";let _=document.querySelector("graph-layout")?.shadowRoot?.querySelector("#g2-path-filter");_&&(_.value=""),E.graphState?.requestDraw?.();return}if(J(e,"#g2-fullscreen")){document.body.classList.toggle("report-fullscreen");return}if(J(e,"[data-g2-show-all]")){E.showAll=!E.showAll,E.layoutCache=null,E.selected=null,He(),x();return}let B=J(e,".graph2-triage-selector [data-triage-show]");if(B){let _=B.dataset.triageShow;a.shownTriage=a.shownTriage===_?null:_,E.layoutCache=null,E.selected=null,He(),x();return}let te=J(e,"[data-g2-focus-pkg]");if(te){E.focusedPkg=te.dataset.g2FocusPkg,E.layoutCache=null,He(),x();return}if(J(e,"#g2-back-to-full")){E.focusedPkg=null,E.layoutCache=null,He(),x();return}let z=J(e,".tab");if(z&&J(e,".tabs")){let V=J(e,"[data-gid]").dataset.gid,Z=z.dataset.tid;a.activeTabByGroup.set(V,Z),ar();return}let be=J(e,"[data-triage-action]");if(be){let _=be.closest(".triage-menu"),V=_?.dataset.gid;if(!V)return;let Z=_r(V);if(!Z)return;let ce=be.dataset.triageAction;if(!["inprogress","fixed","invalid","deleted","ignored","restore"].includes(ce))return;let se=$e(Z).hasConflict?[Te(Z)]:Z;for(let Ve of se){let et=O(Ve),Fr=Vs(Ve);ce==="restore"?(L(a.triage,et,{triage:void 0}),ae(a.triage,et,Fr,!1)):ce==="ignored"?Bt(a.triage,et,Fr)?ae(a.triage,et,Fr,!1):(L(a.triage,et,{triage:void 0}),ae(a.triage,et,Fr,!0)):a.triage.get(et)?.triage===ce?L(a.triage,et,{triage:void 0}):(L(a.triage,et,{triage:ce}),ae(a.triage,et,Fr,!1))}try{_.hidePopover()}catch{}oe(),ar();return}if(J(e,".mark-comment")){let V=J(e,"[data-gid]").dataset.gid,Z=_r(V);if(!Z)return;let ce=Te(Z),ye=O(ce),se=a.triage.get(ye)?.comment??"";qh({initial:se,finding:ce}).then(Ve=>(Ve===null||(L(a.triage,ye,{comment:Ve||void 0}),oe(),ar()),null)).catch(()=>{});return}let Ze=J(e,".mark-copy");if(Ze){let _=tg(e);if(_===null)return;try{navigator.clipboard.writeText(_).then(()=>(Ze.classList.add("copied"),setTimeout(()=>Ze.classList.remove("copied"),1e3),null)).catch(()=>{})}catch{}return}let Nt=J(e,"[data-copy-report]");if(Nt){let _=Nt.dataset.copyReport;try{navigator.clipboard.writeText(_).then(()=>(Nt.classList.add("copied"),setTimeout(()=>Nt.classList.remove("copied"),1e3),null)).catch(()=>{})}catch{}return}let Rr=J(e,".mark-claude");if(Rr){let _=tg(e);if(_===null)return;let V=`claude://code/new?q=${encodeURIComponent(`Confirm and fix:
86
-
87
- ${_}`)}`;try{window.location.href=V,Rr.classList.add("copied"),setTimeout(()=>Rr.classList.remove("copied"),1e3)}catch{}return}if(J(e,".mark-fix")){let V=J(e,"[data-gid]").dataset.gid,Z=_r(V);if(!Z)return;let ce=Te(Z),ye=O(ce),se=a.triage.get(ye)?.fix??"";Jh({initial:se,finding:ce}).then(Ve=>(Ve===null||(L(a.triage,ye,{fix:Ve||void 0}),oe(),ar()),null)).catch(()=>{});return}let Dt=J(e,"[data-flag-toggle]");if(Dt){let _=Dt.dataset.flagToggle,V=a.triage.get(_)?.flagged;L(a.triage,_,{flagged:V!==!0}),oe(),ar();return}let Ut=e.target.closest("[data-triage-show]");if(Ut&&!Ut.closest(".graph2-triage-selector")){let _=Ut.dataset.triageShow;a.shownTriage=a.shownTriage===_?null:_,x();return}if(e.target.closest("[data-table-deselect]")){a.tableSelectedGid=null,ar();return}let gt=e.target.closest("[data-tree-select]");if(gt){let _=gt.dataset.treeSelect;a.filesSelectedFile=a.filesSelectedFile===_?null:_,x();return}e.target.closest("[data-tree-deselect]")&&(a.filesSelectedFile=null,x())});var rg=document.querySelector("#bundle-source-overlay-slot");rg&&rg.addEventListener("click",e=>{if(e.target.classList?.contains("bundle-source-overlay")||e.target.closest('[data-action="bundle-source-close"]')){a.bundleSourceFile&&(a.bundleSourceFile=null,a.bundleSourceFindingIdx=null,x());return}if(e.target.closest('[data-action="bundle-source-panel-close"]')){a.bundleSourceFindingIdx!=null&&(a.bundleSourceFindingIdx=null,Bo());return}let t=e.target.closest("[data-bundle-source-finding]");if(t){let r=parseInt(t.dataset.bundleSourceFinding,10);Number.isFinite(r)&&(a.bundleSourceFindingIdx=a.bundleSourceFindingIdx===r?null:r,Bo())}});C.addEventListener("row-select",e=>{let t=e.detail?.gid;t&&(a.tableSelectedGid=a.tableSelectedGid===t?null:t,ar())});var xi="application/x-deepview-kanban-gid";function z0(e,t){let n=$e(e).hasConflict?[Te(e)]:e;for(let o of n){let s=O(o),i=Vs(o);t==="untriaged"?(L(a.triage,s,{triage:void 0}),ae(a.triage,s,i,!1)):t==="ignored"?(L(a.triage,s,{triage:void 0}),ae(a.triage,s,i,!0)):(L(a.triage,s,{triage:t}),ae(a.triage,s,i,!1))}}function Lc(){for(let e of C.querySelectorAll(".kanban-card.dragging"))e.classList.remove("dragging");for(let e of C.querySelectorAll(".kanban-column.drag-over"))e.classList.remove("drag-over")}C.addEventListener("dragstart",e=>{let t=e.target.closest?.(".kanban-card[data-kanban-source]");if(!t||!e.dataTransfer)return;let r=t.dataset.gid;r&&(e.dataTransfer.setData(xi,r),e.dataTransfer.setData("text/plain",r),e.dataTransfer.effectAllowed="move",t.classList.add("dragging"))});C.addEventListener("dragend",()=>{Lc()});C.addEventListener("dragover",e=>{if(!e.dataTransfer?.types.includes(xi))return;let t=e.target.closest?.(".kanban-column[data-kanban-target]");if(t&&(e.preventDefault(),e.dataTransfer.dropEffect="move",!t.classList.contains("drag-over"))){for(let r of C.querySelectorAll(".kanban-column.drag-over"))r!==t&&r.classList.remove("drag-over");t.classList.add("drag-over")}});C.addEventListener("dragleave",e=>{let t=e.target.closest?.(".kanban-column[data-kanban-target]");t&&(t.contains(e.relatedTarget)||t.classList.remove("drag-over"))});C.addEventListener("drop",e=>{if(!e.dataTransfer?.types.includes(xi))return;let t=e.target.closest?.(".kanban-column[data-kanban-target]");if(!t){Lc();return}e.preventDefault();let r=e.dataTransfer.getData(xi),n=t.dataset.kanbanTarget;if(Lc(),!r||!n)return;let o=_r(r);!o||($e(o).commonTriage??"untriaged")===n||(z0(o,n),x(),queueMicrotask(oe))});var Mc=!1;function mn(e){return e?C.querySelector(`.kanban-card[data-gid="${CSS.escape(e)}"]`):null}function ki(e){let t=e??C.querySelector(".kanban-card");if(!t)return;let r=t.getBoundingClientRect();r.width<=0||r.height<=0||(document.documentElement.style.setProperty("--kanban-clip-card-w",`${Math.floor(r.width)}px`),document.documentElement.style.setProperty("--kanban-clip-card-h",`${Math.floor(r.height)}px`))}function Fo(e){let t=a.kanbanPopoverGid;if(t===e)return;let r=t===null&&e!==null,n=t!==null&&e===null;if(!document.startViewTransition||!r&&!n){a.kanbanPopoverGid=e,x();return}if(Mc)return;Mc=!0;let o=r?"kanban-opening":"kanban-closing";document.documentElement.classList.add(o);let s=u=>{u&&(u.style.viewTransitionName=""),document.documentElement.classList.remove(o),Mc=!1};if(r){let u=mn(e);u?(ki(u),u.style.viewTransitionName="kanban-detail-modal",u.getBoundingClientRect()):ki(),a.kanbanPopoverGid=e;let p=document.startViewTransition(()=>{x(),u&&(u.style.viewTransitionName="")}),f=setTimeout(()=>s(u),600);(async()=>{try{await p.finished}catch{}clearTimeout(f),s(u)})();return}ki(),a.kanbanPopoverGid=e;let i=null,l=document.startViewTransition(()=>{x(),i=mn(t),i&&(ki(i),i.style.viewTransitionName="kanban-detail-modal")}),d=setTimeout(()=>s(i??mn(t)),600);(async()=>{try{await l.finished}catch{}clearTimeout(d),s(i??mn(t))})()}function W0(e){let t=mn(a.kanbanPopoverGid),r=t?.closest(".kanban-column");if(!r)return;let n=[...r.querySelectorAll(".kanban-card[data-kanban-source]")],o=n.indexOf(t);if(o<0)return;let s=Math.min(Math.max(o+e,0),n.length-1);if(s===o)return;let i=n[s].dataset.gid;if(!i)return;Fo(i);let l=mn(i);l&&(l.focus({preventScroll:!0}),l.scrollIntoView({block:"nearest",behavior:"instant"}))}C.addEventListener("click",e=>{if(e.target.closest?.(".kanban-detail-close")){Fo(null);return}let t=e.target.closest?.(".kanban-card[data-kanban-source]");if(t){if(window.getSelection?.()?.toString())return;let r=t.dataset.gid;if(!r)return;Fo(a.kanbanPopoverGid===r?null:r);return}e.target.closest?.(".kanban-detail-modal")||a.kanbanPopoverGid&&Fo(null)});document.addEventListener("keydown",e=>{e.key==="Escape"&&a.kanbanPopoverGid&&Fo(null)});function ng(e){if(!e||a.focusGid===e)return;a.focusGid=e,x();let t=C.querySelector(".focus-side-card.active");t&&t.scrollIntoView({block:"nearest",behavior:"instant"});let r=C.querySelector(".focus-code-line-active");r&&r.scrollIntoView({block:"center",behavior:"instant"})}function og(e){let t=C.querySelectorAll(".focus-side-card[data-focus-select]");if(t.length===0)return;let r=-1;for(let s=0;s<t.length;s++)if(t[s].classList.contains("active")){r=s;break}let n=r<0?e>0?0:t.length-1:Math.min(Math.max(r+e,0),t.length-1);if(n===r)return;let o=t[n].dataset.gid;o&&ng(o)}C.addEventListener("click",e=>{let t=e.target.closest?.("[data-focus-nav]");if(t){og(t.dataset.focusNav==="next"?1:-1);return}let r=e.target.closest?.(".focus-side-card[data-focus-select]");if(!r||window.getSelection?.()?.toString())return;let n=r.dataset.gid;n&&ng(n)});function H0(e){if(document.querySelector("dialog[open]"))return!0;for(let t of e.composedPath()){if(!t||t.nodeType!==1)continue;let r=t.tagName;if(r==="INPUT"||r==="TEXTAREA"||r==="SELECT"||r==="DIALOG"&&t.open||t.isContentEditable)return!0}return!1}document.addEventListener("keydown",e=>{if(a.currentView!=="findings")return;let t=a.viewMode==="focus",r=a.viewMode==="kanban"&&a.kanbanPopoverGid!==null;if(!t&&!r||e.metaKey||e.ctrlKey||e.altKey||e.shiftKey||H0(e))return;let n=0;if(e.key==="ArrowRight")n=1;else if(e.key==="ArrowLeft")n=-1;else return;e.preventDefault(),t?og(n):W0(n)});C.addEventListener("mark-color",e=>{let t=J(e,"[data-gid]");if(!t)return;let r=t.dataset.gid,n=_r(r);if(!n)return;let o=O(Te(n)),s=e.detail?.color;if(!s)return;a.triage.get(o)?.color===s?L(a.triage,o,{color:void 0}):L(a.triage,o,{color:s}),oe(),ar()});var Ir=null,Pc=null;function sg(){if(Ir!==null||a.reports.length===0)return;Ir=a.viewMode,Pc=document.title,a.viewMode==="table"&&(a.viewMode="list",x());let e=a.reports.map(r=>r.fileName),t="";e.length===1?t=e[0]:e.length>1&&(t=js(e)),t=t.replace(/\.json$/u,""),t&&(document.title=t)}function ig(){Ir!==null&&(a.viewMode!==Ir&&(a.viewMode=Ir,x()),document.title=Pc,Ir=null,Pc=null)}window.addEventListener("beforeprint",sg);window.addEventListener("afterprint",ig);document.addEventListener("print-requested",async()=>{if(a.reports.length!==0&&Ir===null){sg();try{await Promise.all([...C.querySelectorAll("finding-card")].map(e=>e.updateComplete)),window.print()}catch(e){throw ig(),e}}});document.addEventListener("download-requested",()=>{a.reports.length!==0&&Zh(a.reports)});C.addEventListener("analyzer-change",e=>{a.filterAnalyzer=e.detail.value,x()});C.addEventListener("repo-change",e=>{a.filterRepo=e.detail.value,x()});C.addEventListener("bundle-search-mode-change",e=>{let t=e.detail?.mode;t!=="files"&&t!=="code"&&t!=="issues"||(a.bundleCodeSearchMode=t,x())});C.addEventListener("bundle-search-regex-toggle",()=>{a.bundleSearchRegex=!a.bundleSearchRegex,x()});C.addEventListener("bundle-search-case-toggle",()=>{a.bundleSearchCase=!a.bundleSearchCase,x()});C.addEventListener("bundle-swap",e=>{let t=e.detail?.integrity;!t||!(a.bundles??[]).some(r=>r.integrity===t)||(a.currentView="bundles",a.selectedBundle=t,a.bundleDetails=null,a.bundleSourceFile=null,a.bundleSourceFindingIdx=null,a.bundleCodeSearchQuery="",a.bundleCodeSearchMode="files",a.bundleDetailsTab="compare",E.showAll=!0,a.shownTriage=null,Sr(t,"compare"),x(),j(),Ot(t))});C.addEventListener("sort-change",e=>{let{kind:t,value:r}=e.detail;if(t==="findings")a.sortBy=r;else if(t==="packages")a.packagesSortBy=r;else if(t==="repositories")a.repositoriesSortBy=r;else return;x()});C.addEventListener("range-change",e=>{e.target.id==="conf-range"&&(a.filterConfMin=e.detail.low,a.filterConfMax=e.detail.high,x())});C.addEventListener("input",e=>{let t=e.composedPath()[0],r=t?.id,n=t?.value;r==="g2-path-filter"&&(E.pathFilter=n,E.graphState?.requestDraw?.())});C.addEventListener("search-input",e=>{if(!e.detail)return;let{kind:t,value:r}=e.detail;if(t==="findings")a.filterInclude=r,r||(a.filterIncludeNegate=!1);else if(t==="files")a.filesSearch=r;else if(t==="packages")a.packagesSearchQuery=r;else if(t==="repositories")a.repositoriesSearchQuery=r;else if(t==="bundle-code")a.bundleCodeSearchQuery=r;else if(t==="bundle-search"){a.bundleSearchQuery=r,U0();return}else return;x()});C.addEventListener("search-negate-toggle",()=>{a.filterIncludeNegate=!a.filterIncludeNegate,x()});C.addEventListener("severity-toggle",e=>{let t=e.detail.severity;if(e.detail.kind==="graph"){E.selectedSeverities.has(t)?E.selectedSeverities.delete(t):E.selectedSeverities.add(t),e.composedPath()[0].selected=[...E.selectedSeverities],E.graphState?.requestDraw?.(),$i();return}a.filterSeverities.has(t)?a.filterSeverities.delete(t):a.filterSeverities.add(t),x()});C.addEventListener("color-toggle",e=>{let t=e.detail.color;if(e.detail.kind==="graph"){E.selectedColors.has(t)?E.selectedColors.delete(t):E.selectedColors.add(t),e.composedPath()[0].selected=[...E.selectedColors],E.graphState?.requestDraw?.(),$i();return}a.filterColors.has(t)?a.filterColors.delete(t):a.filterColors.add(t),x()});C.addEventListener("source-toggle",e=>{let t=e.detail.source,r=a.filterSources.has(t);a.filterSources.clear(),r||a.filterSources.add(t),x()});C.addEventListener("annotation-filter-toggle",e=>{let t=e.detail?.key,r=n=>n===""?"with":n==="with"?"without":"";if(t==="comment")a.filterComment=r(a.filterComment);else if(t==="fix")a.filterFix=r(a.filterFix);else if(t==="flag")a.filterFlagged=r(a.filterFlagged);else return;x()});C.addEventListener("slide-triage-toggle",e=>{let{kind:t,value:r}=e.detail;if(t==="package")a.packageSlideTriage=a.packageSlideTriage===r?null:r;else if(t==="repository")a.repositorySlideTriage=a.repositorySlideTriage===r?null:r;else return;x()});C.addEventListener("view-mode-change",e=>{if(e.detail.kind==="files"){a.filesViewMode=e.detail.mode,x();return}a.viewMode=e.detail.mode;try{localStorage.setItem(bs,a.viewMode)}catch{}a.viewMode!=="kanban"&&(a.kanbanPopoverGid=null),a.viewMode!=="focus"&&(a.focusGid=null),x()});C.addEventListener("repo-edit-start",()=>{a.repoEditing=!0,x()});C.addEventListener("repo-input",e=>{a.repoUrl=e.detail.url,Ge(a.currentFile,a.repoUrl)});C.addEventListener("repo-commit",e=>{a.repoUrl=e.detail.url,Ge(a.currentFile,a.repoUrl),a.repoEditing=!1,x()});C.addEventListener("repo-cancel",e=>{a.repoUrl=e.detail.url,Ge(a.currentFile,a.repoUrl),a.repoEditing=!1,x()});document.addEventListener("keydown",e=>{if(e.key==="Escape"){if(a.bundleSourceFindingIdx!=null){a.bundleSourceFindingIdx=null,Bo();return}a.bundleSourceFile&&(a.bundleSourceFile=null,x())}});var ag=`:host{position:absolute;top:.5rem;right:.5rem;z-index:1000;width:30px;height:30px;background:transparent;color:var(--muted);border:0;border-radius:6px;font-size:1rem;line-height:1;font-family:inherit;display:flex;align-items:center;justify-content:center;transition:color .12s,background .12s;cursor:default;user-select:none}:host(:hover){color:var(--text);background:rgb(from var(--text) r g b / .06)}:host(:focus-visible){outline:2px solid var(--accent);outline-offset:2px}@media print{:host{display:none!important}}
88
- `;var Oc="deepview.theme",bn=Object.freeze(["dark","light","green","pink"]),V0={dark:{base:"#1a1a1b",dim:"#0a0a0a"},light:{base:"#f6f6fa",dim:"#646464"},green:{base:"#0a140a",dim:"#050a05"},pink:{base:"#ffe4ee",dim:"#a3727f"}},K0="\u2600",G0="\u263E",Nc="deepview-theme-changed",_i="dark",Uc=!1;function q0(){try{let e=localStorage.getItem(Oc);return bn.includes(e)?e:"dark"}catch{return"dark"}}function Mo(e){bn.includes(e)||(e="dark"),_i=e;for(let r of bn)r!=="dark"&&document.body.classList.remove(`theme-${r}`);e!=="dark"&&document.body.classList.add(`theme-${e}`);try{e==="dark"?localStorage.removeItem(Oc):localStorage.setItem(Oc,e)}catch{}let t=document.querySelector('meta[name="theme-color"]');if(t){let{base:r,dim:n}=V0[e];t.setAttribute("content",Uc?n:r)}window.dispatchEvent(new CustomEvent(Nc,{detail:{theme:e}}))}Mo(q0());window.addEventListener("beforeprint",()=>{Uc=!0,Mo(_i)});window.addEventListener("afterprint",()=>{Uc=!1,Mo(_i)});function lg(e){if(!bn.includes(e))throw new TypeError(`DeepView.setTheme: unknown theme ${JSON.stringify(e)} (expected one of ${bn.map(t=>JSON.stringify(t)).join(", ")})`);Mo(e)}function cg(){return _i}var dg=bn,Dc=class extends H{static properties={_light:{state:!0}};static styles=T(ag);constructor(){super(),this._light=document.body.classList.contains("theme-light")}connectedCallback(){super.connectedCallback(),this.hasAttribute("role")||this.setAttribute("role","button"),this.hasAttribute("tabindex")||(this.tabIndex=0),this.hasAttribute("aria-label")||this.setAttribute("aria-label","toggle theme"),this.hasAttribute("title")||this.setAttribute("title","toggle light/dark theme"),this.addEventListener("click",this._toggle),this.addEventListener("keydown",this._onKeydown),window.addEventListener(Nc,this._onThemeChanged)}disconnectedCallback(){window.removeEventListener(Nc,this._onThemeChanged),this.removeEventListener("click",this._toggle),this.removeEventListener("keydown",this._onKeydown),super.disconnectedCallback()}_onThemeChanged=()=>{this._light=document.body.classList.contains("theme-light")};_toggle=()=>{let t=document.body.classList.contains("theme-light");Mo(t?"dark":"light")};_onKeydown=t=>{(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this._toggle())};render(){return c`${this._light?G0:K0}`}};customElements.define("theme-toggle",Dc);var ug=`:host{display:block}.row{display:grid;grid-template-columns:5.5rem minmax(0,1fr);gap:.2rem .85rem;padding:.25rem .7rem;font-size:.8rem;border-bottom:1px solid var(--border);transition:background .12s}:host(:last-child) .row{border-bottom:none}:host(:hover) .row{background:rgb(from var(--text) r g b / .04)}:host(.mark-red) .row{background:var(--mark-red-bg)}:host(.mark-blue) .row{background:var(--mark-blue-bg)}:host(.mark-green) .row{background:var(--mark-green-bg)}:host(.mark-gray) .row{background:var(--mark-gray-bg)}:host(.has-conflict) .row{outline:2px dashed var(--accent);outline-offset:-2px}:host(.triage-fixed),:host(.triage-invalid),:host(.triage-deleted),:host(.triage-ignored){opacity:.75}:host(.selected) .row{outline:2px solid var(--accent);outline-offset:-2px}:host(:first-of-type) .row{border-top-left-radius:6px;border-top-right-radius:6px}:host(:last-of-type) .row{border-bottom-left-radius:6px;border-bottom-right-radius:6px}.row-score{grid-column:1;grid-row:1 / 3;align-self:center;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:.2rem;font-variant-numeric:tabular-nums;.badge{min-width:4.4rem;text-align:center}.row-conf{color:var(--muted);font-size:.72rem;user-select:none;& strong{color:var(--text);font-size:.8rem}}}.row-body{display:contents}.title-row{grid-column:2;grid-row:1;min-width:0;display:flex;align-items:baseline;gap:.5rem;.title{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:500;user-select:none}.row-type{color:var(--muted);font-size:.68rem;flex-shrink:0}}.meta-row{grid-column:2;grid-row:2;min-width:0;display:flex;align-items:center;gap:.55rem;.row-loc{color:var(--muted);font-size:.72rem;flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;& a{color:inherit}& a:hover{color:var(--accent)}}.marks{display:flex;gap:.35rem;align-items:center;flex-shrink:0;user-select:none}}.tabs-row{grid-column:2;grid-row:3;min-width:0;.tabs{display:flex;gap:.25rem;flex-wrap:wrap}}.badge,.tabs,.tab,.row-type{cursor:default;user-select:none}.badge{display:inline-block;font-size:.7rem;font-weight:600;text-transform:uppercase;padding:.15rem .45rem;border-radius:3px;letter-spacing:.03em;line-height:1;&.critical{background:var(--critical);color:#fff}&.high{background:var(--high);color:#fff}&.medium{background:var(--medium);color:#000}&.low{background:var(--low);color:var(--badge-low-text)}&.high_bug{background:var(--high-bug);color:#fff}&.bug{background:var(--bug);color:#fff}&.informational{background:var(--info);color:#fff}}.tab{background:transparent;color:var(--text);border:1px solid var(--border);border-radius:4px;padding:.2rem .5rem;font-size:.75rem;line-height:1.3;display:inline-flex;align-items:center;gap:.35rem;font-family:inherit;&:hover{border-color:var(--accent)}&.active{border-color:var(--accent);background:var(--surface-active)}&.tab-mark-red{background:var(--mark-red-bg);border-color:var(--mark-red-tab-border)}&.tab-mark-blue{background:var(--mark-blue-bg);border-color:var(--mark-blue-tab-border)}&.tab-mark-green{background:var(--mark-green-bg);border-color:var(--mark-green-tab-border)}&.tab-mark-gray{background:var(--mark-gray-bg);border-color:var(--mark-gray-tab-border)}&.tab-mark-red.active,&.tab-mark-blue.active,&.tab-mark-green.active,&.tab-mark-gray.active{border-color:var(--text)}&.tab-deleted .tab-label{text-decoration:line-through;opacity:.6}&.tab-inprogress .tab-label:after{content:" \\25d0";opacity:.6}&.tab-fixed .tab-label{opacity:.65}&.tab-fixed .tab-label:after{content:" \\2713";opacity:.6}&.tab-invalid .tab-label{opacity:.65}&.tab-invalid .tab-label:after{content:" \\2298";opacity:.6}&.tab-ignored .tab-label{opacity:.55}&.tab-ignored .tab-label:after{content:" \\1f441";opacity:.6;font-size:.7em}.tab-conf{color:var(--muted);font-size:.7rem}&.tab-mark-red .tab-conf,&.tab-mark-blue .tab-conf,&.tab-mark-green .tab-conf,&.tab-mark-gray .tab-conf{color:var(--text)}}.report-chip{display:inline-flex;align-items:center;gap:.3rem;padding:0 .35rem;height:1.4rem;border:1px solid var(--border);border-radius:3px;color:var(--muted);font-size:.72rem;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;margin-right:.65rem;max-width:12rem;min-width:0;.report-chip-label{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}.file-icon{flex-shrink:0}.brand-deepview{.bg{fill:#2563eb}.fg{fill:#fff}}.brand-claude{.bg{fill:#d97757}.fg{fill:#fff}}.brand-codex{.bg{fill:#fff;stroke:#000;stroke-width:.5}.fg{fill:#000}}.brand-vercel{.bg{fill:#000;stroke:#fff;stroke-width:.5}.fg{fill:#fff}}}.mark-action-group{display:inline-flex;border:1px solid var(--border);border-radius:3px;overflow:hidden;margin-right:.25rem;flex-shrink:0}.mark-comment,.mark-fix,.mark-flag,.mark-copy,.mark-issue,.mark-claude{background:transparent;border:0;color:var(--muted);padding:0 .25rem;height:1.4rem;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;&:not(:last-child){border-right:1px solid var(--border)}&:hover{color:var(--accent);background:var(--surface-active)}}.mark-issue{text-decoration:none}.mark-comment.has-comment,.mark-fix.has-fix,.mark-flag.flagged{color:var(--accent)}.mark-flag svg{display:block}.mark-copy.copied,.mark-claude.copied{color:var(--green, #4ade80);background:color-mix(in srgb,var(--green, #4ade80) 14%,transparent)}.mark-comment.has-comment .bubble,.mark-fix.has-fix .wrench,.mark-flag.flagged .flag-cloth{fill:var(--accent);fill-opacity:.15}.mark-x{background:transparent;border:1px solid var(--border);color:var(--muted);border-radius:3px;padding:0 .35rem;font-size:.85rem;line-height:1.1;margin-left:.25rem;&:hover{color:var(--critical);border-color:var(--critical)}}.triage-menu-wrap{position:relative;display:inline-flex;margin-left:.25rem;flex-shrink:0}.mark-triage-menu{background:transparent;border:1px solid var(--border);color:var(--muted);border-radius:3px;padding:0 .3rem;height:1.5rem;display:inline-flex;align-items:center;justify-content:center;gap:.25rem;font:inherit}.mark-triage-menu:hover{color:var(--text);border-color:var(--accent)}.mark-triage-menu.open{border-color:var(--accent);color:var(--text)}.mark-triage-menu.with-label{padding:0 .35rem 0 .5rem;font-size:.72rem;height:1.5rem}.mark-triage-menu .mark-triage-label{text-transform:uppercase;letter-spacing:.05em;font-weight:600}.mark-triage-menu.triage-state-deleted{border-color:var(--critical);color:var(--critical)}.mark-triage-menu.triage-state-fixed{border-color:var(--green, #4ade80);color:var(--green, #4ade80)}.mark-triage-menu.triage-state-inprogress{border-color:var(--warning, #d97706);color:var(--warning, #d97706)}.mark-triage-menu.triage-state-invalid{border-color:var(--muted);color:var(--text)}.mark-triage-menu.triage-state-ignored{border-color:var(--accent, #2563eb);color:var(--accent, #2563eb)}.triage-menu[popover]{position:fixed;inset:auto;margin:0;min-width:7rem;background:var(--bg);border:1px solid var(--border);border-radius:4px;padding:.25rem;box-shadow:0 4px 12px #00000040;display:flex;flex-direction:column;gap:1px;-webkit-app-region:no-drag;app-region:no-drag}.triage-menu[popover]:not(:popover-open){display:none}.triage-menu[popover]:popover-open{display:flex}.triage-menu-item{background:transparent;border:0;padding:.35rem .5rem;font-size:.78rem;color:var(--text);text-align:left;border-radius:3px;font-family:inherit}.triage-menu-item:hover{background:var(--surface)}.triage-menu-item.active:before{content:"\\2713 ";color:var(--accent)}.triage-menu-inprogress:hover{color:var(--warning, #d97706)}.triage-menu-fixed:hover{color:var(--green, #4ade80)}.triage-menu-invalid:hover{color:var(--muted)}.triage-menu-deleted:hover{color:var(--critical)}.mark-restore{background:transparent;border:1px solid var(--border);color:var(--muted);border-radius:3px;padding:0 .45rem;font-size:.75rem;line-height:1.3;margin-left:.25rem;&:hover{color:var(--green);border-color:var(--green)}}.line-num{color:var(--muted);font-size:.75rem}.line-num a{color:inherit}.line-num a:hover{color:var(--accent)}@media print{:host(:hover) .row,:host(.mark-red) .row,:host(.mark-blue) .row,:host(.mark-green) .row,:host(.mark-gray) .row{background:transparent!important}:host(.triage-fixed),:host(.triage-invalid),:host(.triage-deleted),:host(.triage-ignored){opacity:1}:host(.selected) .row,:host(.has-conflict) .row{outline:none!important}.row{break-inside:avoid}.marks,.mark-x,.mark-restore{display:none!important}.badge{-webkit-print-color-adjust:exact;print-color-adjust:exact;&.critical{background:#a30b0f!important;color:#fff!important}&.high{background:#b8400a!important;color:#fff!important}&.medium{background:#855107!important;color:#fff!important}&.low{background:#374151!important;color:#fff!important}&.high_bug{background:#7a3e0c!important;color:#fff!important}&.bug{background:#4d4538!important;color:#fff!important}&.informational{background:#0550ae!important;color:#fff!important}}a,.line-num,.line-num a{color:inherit}}
89
- `;var J0=["is-critical","mark-red","mark-blue","mark-green","mark-gray","has-conflict","triage-inprogress","triage-fixed","triage-invalid","triage-deleted","triage-ignored","selected"],zc=class extends P{static properties={group:{attribute:!1},selected:{type:Boolean}};static styles=T(ug);constructor(){super(),this.group=null,this.selected=!1}render(){if(!this.group)return c``;this.dataset.gid=ho(this.group);let t=new Set(nf(this.group));this.selected&&t.add("selected");for(let r of J0)this.classList.toggle(r,t.has(r));return c`<div class="row">${of(this.group)}</div>`}connectedCallback(){super.connectedCallback(),this.addEventListener("click",this._onClick),this.hasUpdated&&this.requestUpdate()}disconnectedCallback(){this.removeEventListener("click",this._onClick),super.disconnectedCallback()}_onClick=t=>{t.composedPath().some(n=>n?.matches?.("a, button, label"))||this.dataset.gid&&this.dispatchEvent(new CustomEvent("row-select",{detail:{gid:this.dataset.gid},bubbles:!0,composed:!0}))}};customElements.define("finding-row",zc);var pg=`:host{display:block;background:var(--surface);backdrop-filter:var(--glass-blur);border:1px solid var(--border);border-radius:6px;overflow:hidden;box-shadow:var(--shadow-glass);margin-bottom:1rem;max-width:1200px}
90
- `;var Wc=class extends H{static properties={items:{attribute:!1},selectedGid:{attribute:!1}};static styles=T(pg);constructor(){super(),this.items=[],this.selectedGid=null}render(){return c`${G(this.items??[],t=>ho(t),t=>c`<finding-row .group="${t}" ?selected="${ho(t)===this.selectedGid}"></finding-row>`)}`}};customElements.define("finding-table",Wc);var fg=`:host{display:block}:host(.hidden){display:none}:host(.triage-fixed),:host(.triage-invalid),:host(.triage-deleted),:host(.triage-ignored){opacity:.75}.card{padding:.5rem .75rem;border-bottom:1px solid var(--border);font-size:.875rem}:host(:last-child) .card{border-bottom:none}:host(.mark-red) .card{background:var(--mark-red-bg)}:host(.mark-blue) .card{background:var(--mark-blue-bg)}:host(.mark-green) .card{background:var(--mark-green-bg)}:host(.mark-gray) .card{background:var(--mark-gray-bg)}:host(.has-conflict) .card{outline:2px dashed var(--accent);outline-offset:-2px}:host([in-group]) .line-row{display:none}.tabs{display:flex;gap:.25rem;flex-wrap:wrap}.marks-left{display:flex;align-items:center;gap:.5rem;margin-right:auto;flex-wrap:wrap}.commit-ref{color:var(--muted);font-size:.8rem;& a{color:var(--accent);font-family:ui-monospace,SFMono-Regular,Menlo,monospace}& a:hover{text-decoration:underline}& span{font-family:ui-monospace,SFMono-Regular,Menlo,monospace}}.marks-commit-row{margin-top:.4rem;padding-left:4.75rem}.tab-body{display:none;grid-template-columns:auto 1fr;gap:.25rem .75rem;&.active{display:grid}}.desc-title{grid-column:2;font-size:1.08em;font-weight:600;letter-spacing:-.005em;line-height:1.35;color:var(--text)}.desc{grid-column:2;white-space:pre-line;font-size:.96em;line-height:1.6;color:rgb(from var(--text) r g b / .82);margin-top:.4rem}.recommendation{grid-column:2;white-space:pre-line;font-size:.92em;line-height:1.55;color:var(--green);margin-top:.4rem}.conf-reason{grid-column:2;white-space:pre-line;font-size:.92em;font-style:italic;color:var(--muted);margin-top:.6rem;padding-top:.55rem;border-top:1px dashed var(--border)}.inline-quote{background:rgb(from var(--accent) r g b / .1);padding:1px;border-radius:3px;color:var(--text)}.inline-code{background:var(--surface-active);border-radius:3px;border:1px solid var(--border);font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:.9em;color:var(--text)}.line-row{display:flex;justify-content:space-between;align-items:baseline;gap:.5rem;flex-wrap:wrap}.run-meta{color:var(--muted);font-size:.65rem}.finding-code-btn{display:inline-block;margin-top:.35rem;padding:.1rem .45rem;background:transparent;border:1px solid var(--border);border-radius:999px;color:var(--muted);font:inherit;font-size:.65rem;font-weight:500;white-space:nowrap}.finding-code-btn:hover{border-color:var(--accent);color:var(--accent)}.marks{display:flex;gap:.35rem;justify-content:flex-end;margin-top:.4rem;align-items:center;padding-left:4.75rem;user-select:none}.finding-left{align-self:start;text-align:center;min-width:4rem;.value-label:last-child{margin-bottom:0}}.conf-score{font-size:.75rem;color:var(--muted);margin-top:.3rem;& strong{color:var(--text);font-size:.85rem}}.conf-ring{--col: var(--muted);position:relative;width:3rem;height:3rem;margin:.7rem auto .15rem;display:flex;align-items:center;justify-content:center;& svg{position:absolute;inset:0;width:100%;height:100%;transform:rotate(-90deg)}& circle{fill:none;stroke-width:4}.conf-ring-track{stroke:var(--border)}.conf-ring-arc{stroke:var(--col);stroke-linecap:round}& span{position:relative;z-index:1;font-size:.8rem;font-weight:700;color:var(--text);font-variant-numeric:tabular-nums}& small{font-size:.55rem;color:var(--muted);font-weight:500}&.critical{--col: var(--critical)}&.high{--col: var(--high)}&.medium{--col: var(--medium)}&.low{--col: var(--low)}&.high_bug{--col: var(--high-bug)}&.bug{--col: var(--bug)}&.informational{--col: var(--info)}}.value-label{display:block;font-size:.45rem;color:var(--muted);text-transform:uppercase;letter-spacing:.04em;margin-top:.1rem;margin-bottom:.3rem;font-weight:500}.print-case-label{display:none}.badge,.tabs,.tab,.value-label,.run-meta,.conf-ring{cursor:default;user-select:none}.badge{display:inline-block;font-size:.7rem;font-weight:600;text-transform:uppercase;padding:.15rem .45rem;border-radius:3px;letter-spacing:.03em;line-height:1;&.critical{background:var(--critical);color:#fff}&.high{background:var(--high);color:#fff}&.medium{background:var(--medium);color:#000}&.low{background:var(--low);color:var(--badge-low-text)}&.high_bug{background:var(--high-bug);color:#fff}&.bug{background:var(--bug);color:#fff}&.informational{background:var(--info);color:#fff}}.tab{background:transparent;color:var(--text);border:1px solid var(--border);border-radius:4px;padding:.2rem .5rem;font-size:.75rem;line-height:1.3;display:inline-flex;align-items:center;gap:.35rem;font-family:inherit;&:hover{border-color:var(--accent)}&.active{border-color:var(--accent);background:var(--surface-active)}&.tab-mark-red{background:var(--mark-red-bg);border-color:var(--mark-red-tab-border)}&.tab-mark-blue{background:var(--mark-blue-bg);border-color:var(--mark-blue-tab-border)}&.tab-mark-green{background:var(--mark-green-bg);border-color:var(--mark-green-tab-border)}&.tab-mark-gray{background:var(--mark-gray-bg);border-color:var(--mark-gray-tab-border)}&.tab-mark-red.active,&.tab-mark-blue.active,&.tab-mark-green.active,&.tab-mark-gray.active{border-color:var(--text)}&.tab-deleted .tab-label{text-decoration:line-through;opacity:.6}&.tab-inprogress .tab-label:after{content:" \\25d0";opacity:.6}&.tab-fixed .tab-label{opacity:.65}&.tab-fixed .tab-label:after{content:" \\2713";opacity:.6}&.tab-invalid .tab-label{opacity:.65}&.tab-invalid .tab-label:after{content:" \\2298";opacity:.6}&.tab-ignored .tab-label{opacity:.55}&.tab-ignored .tab-label:after{content:" \\1f441";opacity:.6;font-size:.7em}.tab-conf{color:var(--muted);font-size:.7rem}&.tab-mark-red .tab-conf,&.tab-mark-blue .tab-conf,&.tab-mark-green .tab-conf,&.tab-mark-gray .tab-conf{color:var(--text)}}.report-chip{display:inline-flex;align-items:center;gap:.3rem;padding:0 .35rem;height:1.4rem;border:1px solid var(--border);border-radius:3px;color:var(--muted);font-size:.72rem;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;margin-right:.65rem;max-width:16rem;min-width:0;.report-chip-label{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}.file-icon{flex-shrink:0}.brand-deepview{.bg{fill:#2563eb}.fg{fill:#fff}}.brand-claude{.bg{fill:#d97757}.fg{fill:#fff}}.brand-codex{.bg{fill:#fff;stroke:#000;stroke-width:.5}.fg{fill:#000}}.brand-vercel{.bg{fill:#000;stroke:#fff;stroke-width:.5}.fg{fill:#fff}}}.mark-action-group{display:inline-flex;border:1px solid var(--border);border-radius:3px;overflow:hidden;margin-right:.25rem;flex-shrink:0}.mark-comment,.mark-fix,.mark-flag,.mark-copy,.mark-issue,.mark-claude{background:transparent;border:0;color:var(--muted);padding:0 .25rem;height:1.4rem;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;&:not(:last-child){border-right:1px solid var(--border)}&:hover{color:var(--accent);background:var(--surface-active)}}.mark-issue{text-decoration:none}.mark-comment.has-comment,.mark-fix.has-fix,.mark-flag.flagged{color:var(--accent)}.mark-flag svg{display:block}.mark-copy.copied,.mark-claude.copied{color:var(--green, #4ade80);background:color-mix(in srgb,var(--green, #4ade80) 14%,transparent)}.mark-comment.has-comment .bubble,.mark-fix.has-fix .wrench,.mark-flag.flagged .flag-cloth{fill:var(--accent);fill-opacity:.15}.mark-x{background:transparent;border:1px solid var(--border);color:var(--muted);border-radius:3px;padding:0 .35rem;font-size:.85rem;line-height:1.1;margin-left:.25rem;&:hover{color:var(--critical);border-color:var(--critical)}}.triage-menu-wrap{position:relative;display:inline-flex;margin-left:.25rem;flex-shrink:0}.mark-triage-menu{background:transparent;border:1px solid var(--border);color:var(--muted);border-radius:3px;padding:0 .3rem;height:1.5rem;display:inline-flex;align-items:center;justify-content:center;gap:.25rem;font:inherit}.mark-triage-menu:hover{color:var(--text);border-color:var(--accent)}.mark-triage-menu.open{border-color:var(--accent);color:var(--text)}.mark-triage-menu.with-label{padding:0 .35rem 0 .5rem;font-size:.72rem;height:1.5rem}.mark-triage-menu .mark-triage-label{text-transform:uppercase;letter-spacing:.05em;font-weight:600}.mark-triage-menu.triage-state-deleted{border-color:var(--critical);color:var(--critical)}.mark-triage-menu.triage-state-fixed{border-color:var(--green, #4ade80);color:var(--green, #4ade80)}.mark-triage-menu.triage-state-inprogress{border-color:var(--warning, #d97706);color:var(--warning, #d97706)}.mark-triage-menu.triage-state-invalid{border-color:var(--muted);color:var(--text)}.mark-triage-menu.triage-state-ignored{border-color:var(--accent, #2563eb);color:var(--accent, #2563eb)}.triage-menu[popover]{position:fixed;inset:auto;margin:0;min-width:7rem;background:var(--bg);border:1px solid var(--border);border-radius:4px;padding:.25rem;box-shadow:0 4px 12px #00000040;display:flex;flex-direction:column;gap:1px;-webkit-app-region:no-drag;app-region:no-drag}.triage-menu[popover]:not(:popover-open){display:none}.triage-menu[popover]:popover-open{display:flex}.triage-menu-item{background:transparent;border:0;padding:.35rem .5rem;font-size:.78rem;color:var(--text);text-align:left;border-radius:3px;font-family:inherit}.triage-menu-item:hover{background:var(--surface)}.triage-menu-item.active:before{content:"\\2713 ";color:var(--accent)}.triage-menu-inprogress:hover{color:var(--warning, #d97706)}.triage-menu-fixed:hover{color:var(--green, #4ade80)}.triage-menu-invalid:hover{color:var(--muted)}.triage-menu-deleted:hover{color:var(--critical)}:host([context="focus"]) .triage-menu-wrap>.mark-triage-menu{display:none}:host([context="focus"]) .triage-menu-wrap{display:inline-flex}:host([context="focus"]) .triage-menu[popover]{position:static;inset:auto;display:inline-flex!important;flex-flow:row wrap;margin:0;padding:0;background:transparent;border:0;border-radius:0;box-shadow:none;min-width:0;gap:.25rem}:host([context="focus"]) .triage-menu-item{background:transparent;border:1px solid var(--border);padding:.2rem .5rem;border-radius:3px;font-size:.72rem;font-weight:500;text-transform:uppercase;letter-spacing:.04em}:host([context="focus"]) .triage-menu-item.active{background:rgb(from var(--accent) r g b / .12);border-color:var(--accent);color:var(--accent)}:host([context="focus"]) .triage-menu-item:hover{background:var(--surface-active)}:host([context="focus"]) .triage-menu-inprogress.active{background:rgb(from var(--warning, #d97706) r g b / .12);border-color:var(--warning, #d97706);color:var(--warning, #d97706)}:host([context="focus"]) .triage-menu-fixed.active{background:rgb(from var(--green, #4ade80) r g b / .12);border-color:var(--green, #4ade80);color:var(--green, #4ade80)}:host([context="focus"]) .triage-menu-deleted.active{background:rgb(from var(--critical) r g b / .12);border-color:var(--critical);color:var(--critical)}:host([context="focus"]) .triage-menu-item.active:before{content:"";margin:0}:host([context="focus"]) .marks{gap:.5rem;margin-top:.65rem;padding-left:0;padding-top:.55rem;border-top:1px solid var(--border);flex-wrap:wrap}:host([context="focus"]) .marks-commit-row{padding-left:0}:host([context="focus"]) .mark-comment,:host([context="focus"]) .mark-fix,:host([context="focus"]) .mark-flag,:host([context="focus"]) .mark-copy,:host([context="focus"]) .mark-issue,:host([context="focus"]) .mark-claude{height:1.75rem;padding:0 .55rem;gap:.35rem;display:inline-flex;align-items:center;font-size:.72rem}:host([context="focus"]) .mark-btn-label{color:inherit;font-weight:500;letter-spacing:.02em}:host([context="focus"].mark-red) .card{background:color-mix(in srgb,var(--mark-red-bg) 15%,var(--bg))}:host([context="focus"].mark-blue) .card{background:color-mix(in srgb,var(--mark-blue-bg) 15%,var(--bg))}:host([context="focus"].mark-green) .card{background:color-mix(in srgb,var(--mark-green-bg) 15%,var(--bg))}:host([context="focus"].mark-gray) .card{background:color-mix(in srgb,var(--mark-gray-bg) 15%,var(--bg))}.comment-block,.fix-block{margin-top:.5rem;padding:.35rem .55rem;border-left:3px solid var(--accent);background:rgb(from var(--accent) r g b / .08);border-radius:0 4px 4px 0;font-size:.82rem;color:var(--text)}.comment-block{white-space:pre-wrap}.fix-block{word-break:break-all;& a{color:var(--accent);text-decoration:none}& a:hover{text-decoration:underline}}.comment-label,.fix-label{color:var(--muted);font-weight:600;margin-right:.35rem}.mark-restore{background:transparent;border:1px solid var(--border);color:var(--muted);border-radius:3px;padding:0 .45rem;font-size:.75rem;line-height:1.3;margin-left:.25rem;&:hover{color:var(--green);border-color:var(--green)}}.line-num{color:var(--muted);font-size:.8rem}.line-num a{color:inherit}.line-num a:hover{color:var(--accent)}.npm-link{display:inline-block;padding:0 .4rem;border:1px solid var(--border);border-radius:3px;font-size:.72rem;font-weight:500;color:var(--muted);text-decoration:none}.npm-link:hover{border-color:var(--accent);color:var(--accent)}@media print{.card{break-inside:avoid;padding:.45rem .25rem}.finding-code-btn,.mark-copy,.mark-issue,.mark-claude{display:none!important}.npm-link{border:0;padding:0}:host(.triage-fixed),:host(.triage-invalid),:host(.triage-deleted),:host(.triage-ignored){opacity:1}:host(.multi-case) .card:before{content:"Multiple reports of one finding";display:block;font-size:.7rem;font-weight:700;color:#555;text-transform:uppercase;letter-spacing:.06em;border-bottom:1px solid #bbb;padding-bottom:.2rem;margin-bottom:.35rem;-webkit-print-color-adjust:exact;print-color-adjust:exact}.marks,.tabs{display:none!important}.tab-body{display:grid!important}.tab-body+.tab-body{margin-top:.5rem;padding-top:.5rem;border-top:1px dashed #999}:host([in-group].multi-case) .tab-body .line-row{display:flex}.line-row .discovered-in{flex-basis:100%;order:99}.print-case-label{display:block;grid-column:1 / -1;font-size:.65rem;font-weight:600;color:#555;background:#eee;padding:.1rem .35rem;border-radius:3px;margin-bottom:.25rem;letter-spacing:.04em;-webkit-print-color-adjust:exact;print-color-adjust:exact}.value-label{color:#777}.badge{-webkit-print-color-adjust:exact;print-color-adjust:exact;&.critical{background:#a30b0f!important;color:#fff!important}&.high{background:#b8400a!important;color:#fff!important}&.medium{background:#855107!important;color:#fff!important}&.low{background:#374151!important;color:#fff!important}&.high_bug{background:#7a3e0c!important;color:#fff!important}&.bug{background:#4d4538!important;color:#fff!important}&.informational{background:#0550ae!important;color:#fff!important}}a,.line-num,.line-num a{color:inherit}.inline-code{border:0;background:transparent;padding:0}}
91
- `;var Z0=["finding","is-critical","mark-red","mark-blue","mark-green","mark-gray","has-conflict","triage-inprogress","triage-fixed","triage-invalid","triage-deleted","triage-ignored","multi-case"],Hc=class extends P{static properties={group:{attribute:!1},inGroup:{type:Boolean,attribute:"in-group",reflect:!0},context:{type:String,reflect:!0}};static styles=T(fg);constructor(){super(),this.group=null,this.inGroup=!1,this.context=null}render(){if(!this.group)return c``;this.dataset.gid=sn(this.group);let t=new Set(tf(this.group));for(let r of Z0)this.classList.toggle(r,t.has(r));return c`<div class="card">${rf(this.group,{context:this.context})}</div>`}connectedCallback(){super.connectedCallback(),this.hasUpdated&&this.requestUpdate()}};customElements.define("finding-card",Hc);var hg=`:host{display:inline-flex;gap:4px;align-items:center;flex-shrink:0}button{width:14px;height:14px;user-select:none;padding:0;background:transparent;border:1.5px solid currentcolor;border-radius:50%;opacity:.55;transition:opacity .12s,transform .12s}button:hover{opacity:1;transform:scale(1.12)}button.active{background:currentcolor;opacity:1;box-shadow:0 0 0 2px var(--surface),0 0 0 3px currentcolor}.color-red{color:var(--marker-red)}.color-blue{color:var(--marker-blue)}.color-green{color:var(--marker-green)}.color-gray{color:var(--marker-gray)}
92
- `;var tk=["red","blue","green","gray"],jc=class extends H{static properties={selected:{type:String}};static styles=T(hg);constructor(){super(),this.selected=null}render(){return c`${tk.map(t=>c`<button type="button" class="${`color-${t}${this.selected===t?" active":""}`}" data-color="${t}" title="${`mark ${t}`}" @click="${this._onClick}"></button>`)}`}_onClick=t=>{let r=t.currentTarget.dataset.color;this.dispatchEvent(new CustomEvent("mark-color",{detail:{color:r},bubbles:!0,composed:!0}))}};customElements.define("color-marker",jc);var Vc=class extends P{createRenderRoot(){return this}render(){let t=a.filterConfMin,r=a.filterConfMax;return c`<span class="conf-range-label">Confidence</span><range-slider id="conf-range" min="0" max="10" step="1" low="${t}" high="${r}" aria-label="Confidence range"></range-slider><conf-range-mirror id="conf-range-vals" class="conf-vals" for="conf-range" .low="${t}" .high="${r}"></conf-range-mirror>`}};customElements.define("conf-filter",Vc);var gg={files:"Filter files\u2026",code:"Search code\u2026",issues:"Search issues\u2026"},mg={files:"Filter files",code:"Search code",issues:"Search issues"},rk=c`<svg class="bundle-code-search-icon" viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.5" aria-hidden="true"><circle cx="6.5" cy="6.5" r="4.5"/><path d="M9.7 9.7L13 13" stroke-linecap="round"/></svg>`,nk={files:c`<svg viewBox="0 0 16 16" width="13" height="13" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M2 4.5a1 1 0 0 1 1-1h3.2l1.3 1.5H13a1 1 0 0 1 1 1V12a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V4.5Z"/></svg>`,code:c`<svg viewBox="0 0 16 16" width="13" height="13" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5.5 4.5L2 8l3.5 3.5"/><path d="M10.5 4.5L14 8l-3.5 3.5"/></svg>`,issues:c`<svg viewBox="0 0 16 16" width="13" height="13" fill="none" stroke="currentColor" stroke-width="1.3" aria-hidden="true"><circle cx="8" cy="8" r="6"/><path d="M8 4.8v3.6" stroke-linecap="round"/><circle cx="8" cy="11" r=".7" fill="currentColor" stroke="none"/></svg>`},Kc=class extends P{static properties={modes:{attribute:!1}};createRenderRoot(){return this}constructor(){super(),this.modes=[]}render(){let t=a.bundleCodeSearchQuery,r=a.bundleCodeSearchMode,n=this.modes.includes(r)?r:"files",o=gg[n]??gg.files;return c`${rk} <input type="text" class="bundle-code-search-input" placeholder="${o}" aria-label="${o}" .value="${fe(t)}" @input="${this._onInput}"> ${t?c`<button type="button" class="bundle-code-search-clear" title="Clear search" aria-label="Clear search" @click="${this._onClear}">×</button>`:g} ${this.modes.length>0?c`<span class="bundle-code-search-modes" role="tablist">${this.modes.map(s=>c`<button type="button" class="${A({"bundle-code-search-mode":!0,active:n===s})}" role="tab" aria-selected="${String(n===s)}" title="${mg[s]??s}" aria-label="${mg[s]??s}" @click="${()=>this._selectMode(s)}">${nk[s]??g}</button>`)}</span>`:g}`}_onInput=t=>{this._dispatchInput(t.target.value)};_onClear=()=>{this._dispatchInput("")};_dispatchInput(t){this.dispatchEvent(new CustomEvent("search-input",{detail:{kind:"bundle-code",value:t},bubbles:!0,composed:!0}))}_selectMode(t){this.dispatchEvent(new CustomEvent("bundle-search-mode-change",{detail:{mode:t},bubbles:!0,composed:!0}))}};customElements.define("bundle-code-search",Kc);var ok=c`<svg class="bundle-search-icon" viewBox="0 0 16 16" width="15" height="15" fill="none" stroke="currentColor" stroke-width="1.5" aria-hidden="true"><circle cx="6.5" cy="6.5" r="4.5"/><path d="M9.7 9.7L13 13" stroke-linecap="round"/></svg>`,Gc=class extends P{createRenderRoot(){return this}render(){let t=a.bundleSearchQuery,r=a.bundleSearchRegex,n=a.bundleSearchCase,o=r?"Search by regular expression\u2026":"Search all source\u2026";return c`${ok} <input type="text" class="bundle-search-input" placeholder="${o}" aria-label="${o}" spellcheck="false" autocapitalize="off" autocomplete="off" .value="${fe(t)}" @input="${this._onInput}"> ${t?c`<button type="button" class="bundle-search-clear" title="Clear search" aria-label="Clear search" @click="${this._onClear}">×</button>`:g} <span class="bundle-search-mods"><button type="button" class="${A({"bundle-search-mod":!0,active:n})}" title="${n?"Case-sensitive on \u2014 click to ignore case":"Match case"}" aria-label="Match case" aria-pressed="${String(n)}" @click="${this._onToggleCase}">Aa</button> <button type="button" class="${A({"bundle-search-mod":!0,active:r})}" title="${r?"Regular expression on \u2014 click for plain text":"Match by regular expression"}" aria-label="Match by regular expression" aria-pressed="${String(r)}" @click="${this._onToggleRegex}">.*</button></span>`}_onInput=t=>{this._dispatchInput(t.target.value)};_onClear=()=>{this._dispatchInput("")};_dispatchInput(t){this.dispatchEvent(new CustomEvent("search-input",{detail:{kind:"bundle-search",value:t},bubbles:!0,composed:!0}))}_onToggleRegex=()=>{this.dispatchEvent(new CustomEvent("bundle-search-regex-toggle",{bubbles:!0,composed:!0}))};_onToggleCase=()=>{this.dispatchEvent(new CustomEvent("bundle-search-case-toggle",{bubbles:!0,composed:!0}))}};customElements.define("bundle-search",Gc);var bg={packages:{stateKey:"packagesSearchQuery",label:"Filter packages"},repositories:{stateKey:"repositoriesSearchQuery",label:"Filter repositories"}},qc=class extends P{static properties={kind:{type:String}};createRenderRoot(){return this}constructor(){super(),this.kind=""}render(){let t=bg[this.kind];return t?c`<input type="search" class="packages-search" placeholder="${`${t.label}\u2026`}" aria-label="${t.label}" .value="${fe(a[t.stateKey])}" @input="${this._onInput}">`:(console.warn(`<entity-search>: unknown kind ${JSON.stringify(this.kind)}; expected one of ${Object.keys(bg).map(r=>JSON.stringify(r)).join(", ")}.`),g)}_onInput=t=>{this.dispatchEvent(new CustomEvent("search-input",{detail:{kind:this.kind,value:t.target.value},bubbles:!0,composed:!0}))}};customElements.define("entity-search",qc);var sk=[["findings-desc","Findings \u2193"],["files-desc","Files \u2193"],["reports-desc","Reports \u2193"],["name-asc","Name A\u2192Z"]],yg={packages:{stateKey:"packagesSortBy",aria:"Sort packages"},repositories:{stateKey:"repositoriesSortBy",aria:"Sort repositories"}},Yc=class extends P{static properties={kind:{type:String}};createRenderRoot(){return this}constructor(){super(),this.kind=""}render(){let t=yg[this.kind];return t?c`<select class="packages-sort" aria-label="${t.aria}" .value="${fe(a[t.stateKey])}" @change="${this._onChange}">${sk.map(([r,n])=>c`<option value="${r}">${n}</option>`)}</select>`:(console.warn(`<entity-sort>: unknown kind ${JSON.stringify(this.kind)}; expected one of ${Object.keys(yg).map(r=>JSON.stringify(r)).join(", ")}.`),g)}_onChange=t=>{this.dispatchEvent(new CustomEvent("sort-change",{detail:{kind:this.kind,value:t.target.value},bubbles:!0,composed:!0}))}};customElements.define("entity-sort",Yc);var Jc=class extends P{static properties={showFile:{type:Boolean,attribute:"show-file"},showConfidence:{type:Boolean,attribute:"show-confidence"},showPriority:{type:Boolean,attribute:"show-priority"}};createRenderRoot(){return this}constructor(){super(),this.showFile=!1,this.showConfidence=!1,this.showPriority=!1}render(){let t=(r,n)=>c`<option value="${r}">${n}</option>`;return c`<select class="sort-select" aria-label="Sort findings" .value="${fe(a.sortBy)}" @change="${this._onChange}">${t("severity","Severity \u2193")} ${this.showFile?t("file","File \u2191"):g} ${this.showConfidence?c`${t("confidence-desc","Confidence \u2193")}${t("confidence-asc","Confidence \u2191")}`:g} ${this.showPriority?c`${t("priority-desc","Priority \u2193")}${t("priority-asc","Priority \u2191")}`:g}</select>`}_onChange=t=>{this.dispatchEvent(new CustomEvent("sort-change",{detail:{kind:"findings",value:t.target.value},bubbles:!0,composed:!0}))}};customElements.define("findings-sort",Jc);var wg=`:host{display:inline-flex;align-items:center;width:8.5rem;height:16px;--rs-thumb-size: 14px;--rs-track-height: 3px;--rs-rail: rgb(from currentcolor r g b / .25);--rs-fill: var(--accent, currentColor)}.track-wrap{position:relative;flex:1;height:var(--rs-thumb-size)}.track{position:absolute;left:0;right:0;top:50%;height:var(--rs-track-height);transform:translateY(-50%);border-radius:99px;background:linear-gradient(to right,var(--rs-rail) 0,var(--rs-rail) var(--low, 0%),var(--rs-fill) var(--low, 0%),var(--rs-fill) var(--high, 100%),var(--rs-rail) var(--high, 100%))}input[type=range]{appearance:none;-webkit-appearance:none;position:absolute;left:0;right:0;top:0;width:100%;height:var(--rs-thumb-size);background:transparent;pointer-events:none;margin:0;padding:0;outline:none}input[type=range]::-webkit-slider-thumb{-webkit-appearance:none;appearance:none;pointer-events:auto;width:var(--rs-thumb-size);height:var(--rs-thumb-size);border-radius:50%;background:var(--rs-fill);border:0;box-shadow:0 1px 3px #00000080}input[type=range]::-moz-range-thumb{pointer-events:auto;width:var(--rs-thumb-size);height:var(--rs-thumb-size);border-radius:50%;background:var(--rs-fill);border:0;box-shadow:0 1px 3px #00000080}input[type=range]::-webkit-slider-runnable-track{background:transparent;height:var(--rs-thumb-size)}
93
- `;var Xc=class extends H{static properties={min:{type:Number},max:{type:Number},step:{type:Number},low:{type:Number},high:{type:Number}};static styles=T(wg);constructor(){super(),this.min=0,this.max=100,this.step=1,this.low=0,this.high=100}willUpdate(){this.low<this.min&&(this.low=this.min),this.high>this.max&&(this.high=this.max),this.low>this.high&&(this.low=this.high)}render(){let t=this.max-this.min||1,r=(this.low-this.min)/t*100,n=(this.high-this.min)/t*100;return c`<div class="track-wrap" style="${`--low:${r}%;--high:${n}%`}"><div class="track"></div><input type="range" min="${this.min}" max="${this.max}" step="${this.step}" @input="${this._onInput}" @change="${this._onChange}"> <input type="range" min="${this.min}" max="${this.max}" step="${this.step}" @input="${this._onInput}" @change="${this._onChange}"></div>`}firstUpdated(){this._inputs=[...this.renderRoot.querySelectorAll('input[type="range"]')],this._inputs[0].value=this.low,this._inputs[1].value=this.high}updated(t){if(!this._inputs||!(t.has("low")||t.has("high")))return;let r=this._inputs.map(i=>Number(i.value)),n=r[0]>r[1],o=n?1:0,s=n?0:1;this.low!==r[o]&&(this._inputs[o].value=this.low),this.high!==r[s]&&(this._inputs[s].value=this.high)}_onInput=()=>{let t=Number(this._inputs[0].value),r=Number(this._inputs[1].value);this.low=Math.min(t,r),this.high=Math.max(t,r),this._emit("range-input")};_onChange=()=>{this._emit("range-change")};_emit(t){this.dispatchEvent(new CustomEvent(t,{detail:{low:this.low,high:this.high},bubbles:!0,composed:!0}))}};customElements.define("range-slider",Xc);var Qc=class extends H{static properties={low:{type:Number},high:{type:Number},for:{type:String}};createRenderRoot(){return this}constructor(){super(),this.low=0,this.high=10,this.for="conf-range",this._dragging=!1,this._liveLow=0,this._liveHigh=10}connectedCallback(){super.connectedCallback(),document.addEventListener("range-input",this._onRangeInput),document.addEventListener("range-change",this._onRangeChange)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("range-input",this._onRangeInput),document.removeEventListener("range-change",this._onRangeChange)}willUpdate(t){this._dragging&&(t.has("low")&&this.low!==this._liveLow&&(this.low=this._liveLow),t.has("high")&&this.high!==this._liveHigh&&(this.high=this._liveHigh))}_onRangeInput=t=>{t.target?.id===this.for&&(this._dragging=!0,this._liveLow=t.detail.low,this._liveHigh=t.detail.high,this.low=t.detail.low,this.high=t.detail.high)};_onRangeChange=t=>{t.target?.id===this.for&&(this._dragging=!1)};render(){return c`<span>${this.low}</span><span class="dash">–</span><span>${this.high}</span>`}};customElements.define("conf-range-mirror",Qc);var vg=`dialog{max-width:560px;width:min(94vw,560px)}header h3{margin:0 0 .25rem}header p{margin:0 0 .9rem;color:var(--muted);font-size:.82rem}hr{border:0;border-top:1px solid var(--border);margin:.9rem 0}.section h4{margin:0 0 .25rem;font-size:.82rem;font-weight:600;text-transform:uppercase;letter-spacing:.08em;color:var(--muted)}.section p{margin:0 0 .55rem;color:var(--muted);font-size:.78rem}.section button{background:transparent;border:1px solid var(--border);color:var(--text);border-radius:5px;padding:.35rem .9rem;font:inherit;font-size:.8rem;&:hover{border-color:var(--accent);color:var(--accent)}&.primary{background:var(--accent);color:var(--surface);border-color:var(--accent)}&.primary:hover{filter:brightness(1.08)}&:disabled{opacity:.5}}input[type=file]{display:block;color:var(--text);font:inherit;font-size:.78rem;margin-bottom:.5rem}.error{margin:.5rem 0;padding:.4rem .6rem;border:1px solid var(--critical, #f87171);border-radius:5px;background:rgb(from var(--critical, #f87171) r g b / .07);color:var(--text);font-size:.78rem}.summary{margin:.5rem 0;font-size:.82rem;& strong{color:var(--text)}.meta{margin-left:.4rem;color:var(--muted);font-size:.74rem}}.mode{border:1px solid var(--border);border-radius:6px;padding:.55rem .7rem;margin:.55rem 0 .7rem;display:flex;flex-direction:column;gap:.35rem}.mode legend{padding:0 .35rem;font-size:.68rem;color:var(--muted);text-transform:uppercase;letter-spacing:.08em}.mode label{display:flex;align-items:flex-start;gap:.5rem;font-size:.82rem;& em{color:var(--muted);font-style:normal;font-size:.74rem}}.status{margin:.8rem 0 0;padding:.4rem .6rem;border-radius:5px;font-size:.78rem;&.status-ok{border:1px solid var(--accent);background:rgb(from var(--accent) r g b / .08);color:var(--text)}&.status-err{border:1px solid var(--critical, #f87171);background:rgb(from var(--critical, #f87171) r g b / .07);color:var(--text)}}.actions{display:flex;justify-content:flex-end;gap:.4rem;margin-top:.8rem;padding-top:.7rem;border-top:1px solid var(--border)}.actions button{background:transparent;border:1px solid var(--border);color:var(--text);border-radius:5px;padding:.3rem .8rem;font:inherit;font-size:.78rem;&:hover{border-color:var(--accent);color:var(--accent)}}
94
- `;var Zc=class extends I{static styles=[...I.styles,T(vg)];static properties={parsed:{state:!0},parseError:{state:!0},mode:{state:!0},busy:{state:!0},status:{state:!0}};constructor(){super(),this.parsed=null,this.parseError=null,this.mode="prefer-current",this.busy=!1,this.status=null}focusInitial(){this.renderRoot.querySelector("button.primary")?.focus()}async _onDownload(){this.busy=!0,this.status=null;try{let{blob:t,filename:r}=await ll();Pr(t,r),this.status={kind:"ok",text:`Downloaded ${r}`}}catch(t){this.status={kind:"err",text:`Export failed: ${t.message}`}}finally{this.busy=!1}}async _onFile(t){let r=t.target.files?.[0];if(this.parsed=null,this.parseError=null,this.status=null,!!r)try{this.parsed=await cl(r)}catch(n){this.parseError=n.message}}_onMode(t){this.mode=t.target.value}async _onApply(){if(!(!this.parsed||this.busy)){this.busy=!0,this.status=null;try{let t=await dl(this.parsed,this.mode);x(),this.status=t.repoUrlError?{kind:"err",text:`Applied ${t.triageEntries} triage entries (${this.mode}), but saving repo URLs failed: ${t.repoUrlError.message}`}:{kind:"ok",text:`Applied ${t.triageEntries} triage entries and ${t.repoUrls} repo URLs (${this.mode}).`},this.parsed=null;let r=this.renderRoot.querySelector('input[type="file"]');r&&(r.value="")}catch(t){this.status={kind:"err",text:`Import failed: ${t.message}`}}finally{this.busy=!1}}}render(){let t=this.parsed;return c`<dialog @close="${this._onClose}"><header><h3>Triage backup</h3><p>Bundles every triage entry (markers, triage states, comments, fixes, per-report ignores) and all saved repo URLs into a single gzipped JSON file.</p></header><section class="section"><h4>Export</h4><p>Download the current triage + repo-URL set as a portable backup.</p><button type="button" class="primary" @click="${this._onDownload}" ?disabled="${this.busy}">${this.busy?"Working\u2026":"Download backup"}</button></section><hr><section class="section"><h4>Import</h4><p>Pick a previously-exported backup. Nothing is applied until you click Apply.</p><input type="file" accept=".gz,application/gzip" @change="${this._onFile}" ?disabled="${this.busy}"> ${this.parseError?c`<div class="error">Failed to parse: ${this.parseError}</div>`:g} ${t?c`<div class="summary">Found <strong>${Object.keys(t.triage).length}</strong> triage entries and <strong>${Object.keys(t.repoUrls).length}</strong> repo URLs. ${t.exportedAt?c`<span class="meta">Exported ${t.exportedAt}.</span>`:g}</div><fieldset class="mode"><legend>Merge mode</legend><label><input type="radio" name="te-mode" value="prefer-current" .checked="${this.mode==="prefer-current"}" @change="${this._onMode}"> <span>Merge — keep current on conflict <em>(safest, only fills gaps)</em></span></label> <label><input type="radio" name="te-mode" value="prefer-imported" .checked="${this.mode==="prefer-imported"}" @change="${this._onMode}"> <span>Merge — prefer imported on conflict <em>(overwrites where both have a value)</em></span></label> <label><input type="radio" name="te-mode" value="replace" .checked="${this.mode==="replace"}" @change="${this._onMode}"> <span>Replace all <em>(drops every current persisted entry first — destructive)</em></span></label></fieldset><button type="button" class="primary" @click="${this._onApply}" ?disabled="${this.busy}">${this.busy?"Applying\u2026":"Apply import"}</button>`:g}</section>${this.status?c`<div class="${`status status-${this.status.kind}`}">${this.status.text}</div>`:g}<footer class="actions"><button type="button" @click="${this._onClose}">Close</button></footer></dialog>`}};customElements.define("triage-export-dialog",Zc);function kg(){return q("triage-export-dialog")}var $g=`:host{display:inline-block;vertical-align:middle;position:relative}.chip{display:inline-flex;align-items:center;gap:.375rem;cursor:default;user-select:none;position:relative;min-height:24px;box-sizing:border-box;padding:.125rem .375rem .125rem .5rem;background:var(--surface);border:1px solid var(--border);border-radius:999px;color:var(--text);font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:.72rem;font-weight:500}.chip svg{color:var(--muted);flex-shrink:0}.chip.empty:hover{border-color:var(--accent)}.chip.empty .label{color:var(--muted);font-style:italic}.chip.readonly{padding-right:.5rem}.chip.copied:after{content:"Copied";position:absolute;inset:0;display:grid;place-items:center;background:var(--surface);backdrop-filter:var(--glass-blur);border-radius:999px;color:var(--text);font-weight:400;white-space:nowrap;pointer-events:none}.edit-btn{width:18px;height:18px;display:grid;place-items:center;padding:0;margin-left:.125rem;background:transparent;border:0;border-radius:4px;color:var(--muted)}.edit-btn:hover{color:var(--text);background:rgb(from var(--text) r g b / .06)}.chip[inert]{visibility:hidden;min-width:19rem}input{position:absolute;inset:0;box-sizing:border-box;padding:0 .55rem;background:var(--surface);border:1px solid var(--accent);border-radius:999px;color:var(--text);font:inherit;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:.72rem;font-weight:400;outline:none}@media print{.chip{color:#000!important;border:0!important}.chip svg{color:#000!important}.edit-btn,input{display:none!important}}
95
- `;function Si(e){if(!e)return"";let t=e.match(/github\.com\/([^/?#]+\/[^/?#]+?)(?:\.git)?(?:[/?#]|$)/iu);return t?t[1]:e}var ed=c`<svg viewBox="0 0 16 16" width="12" height="12" fill="currentColor" aria-hidden="true"><path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8z"/></svg>`,xg=c`<svg viewBox="0 0 16 16" width="11" height="11" fill="currentColor" aria-hidden="true"><path d="M11.013 1.427a1.75 1.75 0 0 1 2.474 0l1.086 1.086a1.75 1.75 0 0 1 0 2.474l-8.61 8.61c-.21.21-.47.364-.756.445l-3.251.93a.75.75 0 0 1-.927-.928l.929-3.25c.082-.286.235-.547.445-.758l8.61-8.61z"/></svg>`,td=class extends H{static properties={url:{type:String},editable:{type:Boolean,reflect:!0},editing:{type:Boolean,reflect:!0},_copied:{state:!0}};static styles=T($g);constructor(){super(),this.url="",this.editable=!1,this.editing=!1,this._copied=!1,this._opener=""}render(){if(this.editable&&this.editing){let t=!!this.url,r=t?Si(this.url):"Set repo";return c`<span class="${t?"chip":"chip empty"}" aria-hidden="true" inert>${ed} <span class="label">${r}</span> <button type="button" class="edit-btn">${xg}</button> </span><input type="text" .value="${fe(this.url)}" placeholder="user/repo or https://github.com/user/repo" @input="${this._onInput}" @focus="${this._onFocus}" @keydown="${this._onKeydown}" @blur="${this._onBlur}">`}if(this.editable){let t=!!this.url,r=t?Si(this.url):"Set repo",n=t?this._copied?"chip copied":"chip":"chip empty";return c`<span class="${n}" @click="${t?null:this._onEdit}">${ed} ${t?this._slugLabel(r):c`<span class="label">${r}</span>`} <button type="button" class="edit-btn" title="Edit repo URL" aria-label="Edit repo URL" @click="${this._onEdit}">${xg}</button></span>`}if(this.url){let t=this._copied?"chip readonly copied":"chip readonly";return c`<span class="${t}" title="Repo from findings (read-only)">${ed} ${this._slugLabel(Si(this.url))}</span>`}return g}_slugLabel(t){return c`<span class="label" title="Copy repo name" @click="${this._onCopyLabel}">${t}</span>`}updated(t){if(t.has("editing")&&this.editing){let r=this.renderRoot.querySelector("input");r&&(r.focus(),r.select())}}_onEdit=t=>{t&&t.stopPropagation(),this._emit("repo-edit-start")};_onCopyLabel=t=>{t&&t.stopPropagation();let r=Si(this.url);if(r)try{navigator.clipboard.writeText(r).then(()=>(this._copied=!0,setTimeout(()=>{this._copied=!1},1e3),null)).catch(()=>{})}catch{}};_onFocus=t=>{this._opener=t.target.value};_onInput=t=>{this.url=t.target.value,this._emit("repo-input",{url:this.url})};_onKeydown=t=>{t.key==="Enter"?(t.preventDefault(),this._emit("repo-commit",{url:this.url})):t.key==="Escape"&&(t.preventDefault(),this.url=this._opener,this._emit("repo-cancel",{url:this._opener}))};_onBlur=()=>{this.editing&&this._emit("repo-commit",{url:this.url})};_emit(t,r){this.dispatchEvent(new CustomEvent(t,{detail:r,bubbles:!0,composed:!0}))}};customElements.define("repo-chip",td);function je(e,t){for(let[r,n]of Object.entries(t))e.hasAttribute(r)||e.setAttribute(r,n)}var ck=c`<svg viewBox="0 0 16 16" width="12" height="12" aria-hidden="true"><path class="bubble" d="M2.5 3h11a.5.5 0 0 1 .5.5v6.5a.5.5 0 0 1-.5.5H8.4l-3 2.6V10.5H2.5a.5.5 0 0 1-.5-.5V3.5a.5.5 0 0 1 .5-.5z" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linejoin="round"/></svg>`,dk=c`<svg viewBox="0 0 16 16" width="12" height="12" aria-hidden="true"><path class="wrench" d="M10.4 2.6a3 3 0 0 0-3.6 4.5L2 12l2 2 4.9-4.8a3 3 0 0 0 4.5-3.6l-1.8 1.8-1.5-.4-.4-1.5z" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linejoin="round"/></svg>`,uk=c`<svg viewBox="0 0 16 16" width="12" height="12" aria-hidden="true"><path class="flag-cloth" d="M5 1.5h6v13l-3-2.7-3 2.7z" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linejoin="round"/></svg>`,pk=[{key:"comment",glyph:ck,label:"commented",stateKey:"filterComment",hasKey:"hasComment"},{key:"fix",glyph:dk,label:"fixed",stateKey:"filterFix",hasKey:"hasFix"},{key:"flag",glyph:uk,label:"flagged",stateKey:"filterFlagged",hasKey:"hasFlagged"}],rd=class extends P{static properties={hasComment:{attribute:!1},hasFix:{attribute:!1},hasFlagged:{attribute:!1}};createRenderRoot(){return this}constructor(){super(),this.hasComment=!1,this.hasFix=!1,this.hasFlagged=!1}connectedCallback(){super.connectedCallback(),je(this,{role:"group","aria-label":"Annotation filter"})}render(){let t=pk.filter(r=>this[r.hasKey]||a[r.stateKey]);return t.length===0?g:c`${t.map(r=>{let n=a[r.stateKey],o=n==="with"?`Showing only ${r.label} findings \u2014 click to exclude them`:n==="without"?`Excluding ${r.label} findings \u2014 click to clear`:`Show only ${r.label} findings`;return c`<button type="button" class="${A({"annotation-chip":!0,"sel-with":n==="with","sel-without":n==="without"})}" title="${o}" aria-label="${o}" aria-pressed="${String(n!=="")}" @click="${()=>this._toggle(r.key)}">${r.glyph}</button>`})}`}_toggle(t){this.dispatchEvent(new CustomEvent("annotation-filter-toggle",{detail:{key:t},bubbles:!0,composed:!0}))}};customElements.define("annotation-filter",rd);var fk=[["critical","Critical"],["high","High"],["medium","Medium"],["low","Low"],["high_bug","High bug"],["bug","Bug"],["informational","Info"]],nd=class extends P{static properties={counts:{attribute:!1},selected:{attribute:!1},kind:{type:String}};createRenderRoot(){return this}constructor(){super(),this.counts={},this.selected=[],this.kind="findings"}connectedCallback(){super.connectedCallback(),je(this,{role:"group","aria-label":"Filter by severity"})}render(){let t=this.kind==="graph"?new Set(this.selected):a.filterSeverities,r=fk.filter(([n])=>(this.counts[n]??0)||t.has(n));return r.length===0?g:c`${r.map(([n,o])=>{let s=this.counts[n]??0,i=t.has(n);return c`<button type="button" class="${A({"sev-chip":!0,[n]:!0,active:i})}" aria-pressed="${String(i)}" @click="${()=>this._toggle(n)}"><span class="sd"></span><span class="name">${o}</span><span class="n">${s}</span></button>`})}`}_toggle(t){this.dispatchEvent(new CustomEvent("severity-toggle",{detail:{severity:t,kind:this.kind},bubbles:!0,composed:!0}))}};customElements.define("severity-chips",nd);var hk=c`<svg class="trash-icon" viewBox="0 0 16 16" width="11" height="11" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 4h10M6.5 4V2.5h3V4M5 4l.7 9h4.6L11 4"/></svg>`,od=class extends P{createRenderRoot(){return this}render(){let t=a.currentView==="bundles"&&a.selectedBundle,r=!a.currentFile&&!t;return c`<button type="button" class="danger" ?disabled="${r}">${hk}<span>Delete current</span></button>`}};customElements.define("sidebar-delete-current",od);var gk=c`<svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M2 6h12v7a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V6Z"/><path d="M2 6l1.6-3.3A1.3 1.3 0 0 1 4.8 2h6.4a1.3 1.3 0 0 1 1.2.7L14 6"/><path d="M8 2v4"/></svg>`,mk=c`<svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><line x1="4" x2="4" y1="2.5" y2="10"/><circle cx="12" cy="4" r="2"/><circle cx="4" cy="12" r="2"/><path d="M12 6a6 6 0 0 1-6 6"/></svg>`,_g={packages:{title:"Show packages",icon:gk,view:"packages"},repositories:{title:"Show repositories",icon:mk,view:"repositories"}},sd=class extends P{static properties={kind:{type:String},count:{type:Number}};createRenderRoot(){return this}constructor(){super(),this.kind="",this.count=0}render(){if(this.count===0)return g;let t=_g[this.kind];if(!t)return console.warn(`<sidebar-view-button>: unknown kind ${JSON.stringify(this.kind)}; expected one of ${Object.keys(_g).map(n=>JSON.stringify(n)).join(", ")}.`),g;let r=a.currentView===t.view;return c`<button type="button" class="${A({"sidebar-view-btn":!0,active:r})}" title="${t.title}" aria-label="${t.title}">${t.icon}<span class="view-btn-count">${this.count}</span></button>`}};customElements.define("sidebar-view-button",sd);var bk=["invalid","deleted"],Sg={package:{stateKey:"packageSlideTriage"},repository:{stateKey:"repositorySlideTriage"}},id=class extends P{static properties={counts:{attribute:!1},kind:{type:String}};createRenderRoot(){return this}constructor(){super(),this.counts={},this.kind=""}connectedCallback(){super.connectedCallback(),je(this,{role:"group","aria-label":"Triage view"})}render(){let t=Sg[this.kind];if(!t)return console.warn(`<slide-triage-tabs>: unknown kind ${JSON.stringify(this.kind)}; expected one of ${Object.keys(Sg).map(o=>JSON.stringify(o)).join(", ")}.`),g;let r=a[t.stateKey],n=bk.filter(o=>(this.counts[o]??0)>0||r===o);return n.length===0?g:c`${n.map(o=>{let s=r===o,i=this.counts[o]??0;return c`<button type="button" class="${A({"triage-state-btn":!0,[`triage-state-${o}`]:!0,active:s})}" title="${s?`Exit ${o} view`:`Show ${o} (${i})`}" aria-pressed="${String(s)}" @click="${()=>this._toggle(o)}">${o.charAt(0).toUpperCase()+o.slice(1)} (${i})</button>`})}`}_toggle(t){this.dispatchEvent(new CustomEvent("slide-triage-toggle",{detail:{kind:this.kind,value:t},bubbles:!0,composed:!0}))}};customElements.define("slide-triage-tabs",id);var yk=[["own","Sources"],["modules","Dependencies"]],ad=class extends P{createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),je(this,{role:"group","aria-label":"Source filter"})}render(){return c`${yk.map(([t,r])=>{let n=a.filterSources.has(t);return c`<button type="button" class="${A({"source-chip":!0,active:n})}" aria-pressed="${String(n)}" @click="${()=>this._toggle(t)}">${r}</button>`})}`}_toggle(t){this.dispatchEvent(new CustomEvent("source-toggle",{detail:{source:t},bubbles:!0,composed:!0}))}};customElements.define("source-filter",ad);var wk=c`<svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/></svg>`,vk=c`<svg viewBox="0 0 16 16" width="13" height="13" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 6h10v4"/></svg>`,Cg={findings:{stateKey:"filterInclude",placeholder:"Search findings\u2026"},files:{stateKey:"filesSearch",placeholder:"Search files\u2026"}},ld=class extends P{static properties={kind:{type:String}};createRenderRoot(){return this}constructor(){super(),this.kind=""}render(){let t=Cg[this.kind];if(!t)return console.warn(`<toolbar-search>: unknown kind ${JSON.stringify(this.kind)}; expected one of ${Object.keys(Cg).map(n=>JSON.stringify(n)).join(", ")}.`),g;let r=a[t.stateKey];return c`${wk} <input type="text" aria-label="${t.placeholder}" placeholder="${t.placeholder}" .value="${fe(r)}" @input="${this._onInput}"> ${this.kind==="findings"&&r?this._negateToggle():g}`}_negateToggle(){let t=a.filterIncludeNegate;return c`<button type="button" class="${A({"search-negate-btn":!0,active:t})}" title="${t?"Negation on \u2014 click to undo":"Negate: show non-matching findings"}" aria-label="Negate search" aria-pressed="${String(t)}" @click="${this._onToggleNegate}">${vk}</button>`}_onInput=t=>{this.dispatchEvent(new CustomEvent("search-input",{detail:{kind:this.kind,value:t.target.value},bubbles:!0,composed:!0}))};_onToggleNegate=()=>{this.dispatchEvent(new CustomEvent("search-negate-toggle",{bubbles:!0,composed:!0}))}};customElements.define("toolbar-search",ld);function kk(e){if(!e)return"";let t=e.match(/github\.com\/([^/?#]+\/[^/?#]+?)(?:\.git)?(?:[/?#]|$)/iu);return t?t[1]:e}var cd=class extends P{static properties={options:{attribute:!1}};createRenderRoot(){return this}constructor(){super(),this.options=[]}render(){return c`<select class="sort-select" aria-label="Filter by repository" .value="${fe(a.filterRepo)}" @change="${this._onChange}"><option value="">All repositories</option>${this.options.map(t=>{let r=t??fo,n=t==null?"(no repo)":kk(t);return c`<option value="${r}">${n}</option>`})}</select>`}_onChange=t=>{this.dispatchEvent(new CustomEvent("repo-change",{detail:{value:t.target.value},bubbles:!0,composed:!0}))}};customElements.define("repo-filter",cd);var Eg=[["none","none","unmarked"],["red","r","red"],["blue","b","blue"],["green","g","green"],["gray","x","gray"]],dd=class extends P{static properties={counts:{attribute:!1},selected:{attribute:!1},kind:{type:String}};createRenderRoot(){return this}constructor(){super(),this.counts={},this.selected=[],this.kind="findings"}connectedCallback(){super.connectedCallback(),je(this,{role:"group","aria-label":"Filter by mark color"})}render(){let t=this.kind==="graph"?new Set(this.selected):a.filterColors;return Eg.some(([n])=>(this.counts[n]??0)||t.has(n))?c`${Eg.map(([n,o,s])=>{let i=this.counts[n]??0,l=t.has(n);return c`<button type="button" class="${l?"active":""}" title="${`${s} (${i})`}" aria-pressed="${String(l)}" @click="${()=>this._toggle(n)}"><span class="${`td ${o}`}"></span><span class="count">${i}</span></button>`})}`:g}_toggle(t){this.dispatchEvent(new CustomEvent("color-toggle",{detail:{color:t,kind:this.kind},bubbles:!0,composed:!0}))}};customElements.define("triage-filter",dd);var $k=["inprogress","fixed","invalid","deleted","ignored"],ud={graph:"graph2-triage-selector",packages:"packages-triage-selector"},xk={inprogress:"In progress"},_k=e=>xk[e]??e.charAt(0).toUpperCase()+e.slice(1),pd=class extends P{static properties={counts:{attribute:!1},states:{attribute:!1},variant:{type:String}};createRenderRoot(){return this}constructor(){super(),this.counts={},this.states=null,this.variant=""}connectedCallback(){super.connectedCallback(),je(this,{role:"group","aria-label":"Triage view"})}render(){let t=this.states??$k,r=t.reduce((s,i)=>s+(this.counts[i]??0),0),n=this.variant?ud[this.variant]:null;this.variant&&n===void 0&&console.warn(`<triage-selector>: unknown variant ${JSON.stringify(this.variant)}; expected one of ${Object.keys(ud).map(s=>JSON.stringify(s)).join(", ")} or "".`);for(let s of Object.values(ud))this.classList.toggle(s,s===n);let o=r===0&&!a.shownTriage;return this.classList.toggle("is-empty",o),o?g:c`${t.map(s=>{let i=this.counts[s]??0,l=a.shownTriage===s;if(i===0&&!l)return g;let d=_k(s);return c`<button type="button" class="${A({"triage-state-btn":!0,[`triage-state-${s}`]:!0,active:l})}" data-triage-show="${s}" title="${l?`Exit ${d.toLowerCase()} view`:`Show ${d.toLowerCase()} (${i})`}" aria-pressed="${String(l)}">${d} (${i})</button>`})}`}};customElements.define("triage-selector",pd);var Sk={table:c`<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><rect x="3" y="3" width="18" height="18" rx="2"/><line x1="3" x2="21" y1="9" y2="9"/><line x1="3" x2="21" y1="15" y2="15"/><line x1="9" x2="9" y1="3" y2="21"/></svg>`,list:c`<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><line x1="3" x2="21" y1="6" y2="6"/><line x1="3" x2="21" y1="12" y2="12"/><line x1="3" x2="21" y1="18" y2="18"/></svg>`,grouped:c`<svg viewBox="0 0 16 16" width="16" height="16" fill="currentColor" aria-hidden="true"><rect x="2" y="1.5" width="12" height="2" rx=".4"/><rect x="5" y="4.4" width="9" height="1.3"/><rect x="5" y="6.2" width="9" height="1.3"/><rect x="2" y="8.5" width="12" height="2" rx=".4"/><rect x="5" y="11.4" width="9" height="1.3"/><rect x="5" y="13.2" width="9" height="1.3"/></svg>`,kanban:c`<svg viewBox="0 0 16 16" width="16" height="16" fill="currentColor" aria-hidden="true"><rect x="1.5" y="2" width="3.8" height="12" rx=".6" fill="none" stroke="currentColor" stroke-width="1"/><rect x="6.1" y="2" width="3.8" height="12" rx=".6" fill="none" stroke="currentColor" stroke-width="1"/><rect x="10.7" y="2" width="3.8" height="12" rx=".6" fill="none" stroke="currentColor" stroke-width="1"/><rect x="2.4" y="3.6" width="2" height="1.4" rx=".2"/><rect x="2.4" y="5.6" width="2" height="1.4" rx=".2"/><rect x="7" y="3.6" width="2" height="1.4" rx=".2"/><rect x="11.6" y="3.6" width="2" height="1.4" rx=".2"/><rect x="11.6" y="5.6" width="2" height="1.4" rx=".2"/><rect x="11.6" y="7.6" width="2" height="1.4" rx=".2"/></svg>`,focus:c`<svg viewBox="0 0 16 16" width="16" height="16" fill="currentColor" aria-hidden="true"><rect x="1.5" y="2.5" width="8.5" height="11" rx=".6" fill="none" stroke="currentColor" stroke-width="1"/><rect x="3" y="4.4" width="5.5" height="1"/><rect x="3" y="6.4" width="5.5" height="1"/><rect x="3" y="8.4" width="3.5" height="1"/><rect x="11.2" y="2.5" width="3.3" height="2.5" rx=".4" fill="currentColor" opacity=".55"/><rect x="11.2" y="5.7" width="3.3" height="2.5" rx=".4" fill="currentColor" opacity=".35"/><rect x="11.2" y="8.9" width="3.3" height="2.5" rx=".4" fill="currentColor" opacity=".22"/></svg>`,graph:c`<svg viewBox="0 0 16 16" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" aria-hidden="true"><line x1="4.5" y1="4.5" x2="11.5" y2="6.5"/><line x1="4.5" y1="4.5" x2="6.5" y2="11.5"/><line x1="11.5" y1="6.5" x2="6.5" y2="11.5"/><circle cx="4.5" cy="4.5" r="2" fill="currentColor"/><circle cx="11.5" cy="6.5" r="2" fill="currentColor"/><circle cx="6.5" cy="11.5" r="2" fill="currentColor"/></svg>`},Ag={table:"Table view (compact rows, click a row to expand)",list:"List view (flat, one card per finding)",grouped:"List view, grouped by file",focus:"Focus view (one finding centered + a queue of next findings)",kanban:"Kanban board, columns grouped by triage status",graph:"Graph view (canvas with imports / exports)"},fd=["table","list","grouped","focus","kanban","graph"],hd=class extends P{static properties={modes:{type:String},kind:{type:String}};createRenderRoot(){return this}constructor(){super(),this.modes=fd.join(","),this.kind="findings"}connectedCallback(){super.connectedCallback(),je(this,{role:"group","aria-label":"View mode"})}render(){let t=this.kind==="files"?a.filesViewMode:a.viewMode,r=this.modes.split(",").map(o=>o.trim()).filter(o=>fd.includes(o)),n=r.length>0?r:fd;return c`${n.map(o=>c`<button type="button" class="${A({"view-mode-btn":!0,active:t===o})}" title="${Ag[o]}" aria-label="${Ag[o]}" aria-pressed="${String(t===o)}" @click="${()=>this._select(o,t)}">${Sk[o]}</button>`)}`}_select(t,r){t!==r&&this.dispatchEvent(new CustomEvent("view-mode-change",{detail:{mode:t,kind:this.kind},bubbles:!0,composed:!0}))}};customElements.define("view-mode-buttons",hd);var Ck=6,Tg=14,Ci=2,Ig=24,Lo=4;function Ek(e){let t=/^#?([0-9a-f]{6})$/iu.exec(e);if(!t)return"#fff";let r=parseInt(t[1],16),n=r>>16&255,o=r>>8&255,s=r&255;return(.2126*n+.7152*o+.0722*s)/255>.6?"#1a1a1a":"#fff"}function Ak(e,t,r,n){let o=r*r,s=n*n;return Math.max(s*e/o,o/(s*t))}function Rg(e,t){let r=[],n=e.filter(f=>f.value>0),{x:o,y:s,w:i,h:l}=t;if(n.length===0||i<=0||l<=0)return r;let d=0;for(let f of n)d+=f.value;let u=i*l/d,p=0;for(;p<n.length&&i>.5&&l>.5;){let f=Math.min(i,l),h=p,b=0,m=0,y=1/0,k=1/0;for(;h<n.length;){let v=n[h].value*u,$=v>m?v:m,R=v<y?v:y,F=Ak($,R,b+v,f);if(h===p||F<=k)k=F,b+=v,m=$,y=R,h++;else break}let w=b/f;if(i>=l){let v=s;for(let $=p;$<h;$++){let R=$===h-1?s+l-v:n[$].value*u/w;r.push({node:n[$],x:o,y:v,w,h:R}),v+=R}o+=w,i-=w}else{let v=o;for(let $=p;$<h;$++){let R=$===h-1?o+i-v:n[$].value*u/w;r.push({node:n[$],x:v,y:s,w:R,h:w}),v+=R}s+=w,l-=w}p=h}return r}function Fg(e){for(;e.children&&e.children.size===1;){let t=e.children.values().next().value;if(t.isFile)break;e.name=`${e.name}/${t.name}`,e.children=t.children}if(e.children)for(let t of e.children.values())Fg(t)}function Bg(e,t,r,n){if(e.path=e.name?t?`${t}/${e.name}`:e.name:t,e.parent=r,e.isFile)return e.count=1,e.value;n.set(e.path,e);let o=0,s=0;for(let i of e.children.values())o+=Bg(i,e.path,e,n),s+=i.count;return e.value=o,e.count=s,o}function Mg(e,t,r,n,o,s,i){if(n<Lo||o<Lo)return;if(e.isFile){i.push({kind:"file",node:e,x:t,y:r,w:n,h:o});return}if(!(s<Ck&&n>=Ig&&o>=Ig&&e.children.size>0)){i.push({kind:"agg",node:e,x:t,y:r,w:n,h:o});return}i.push({kind:"dir",node:e,x:t,y:r,w:n,h:o});let d=o>=Tg+Lo+Ci?Tg:0,u=t+Ci,p=r+d,f=n-Ci*2,h=o-d-Ci;if(f<Lo||h<Lo)return;let b=[...e.children.values()].toSorted((m,y)=>y.value-m.value);for(let m of Rg(b,{x:u,y:p,w:f,h}))Mg(m.node,m.x,m.y,m.w,m.h,s+1,i)}var gd=class extends H{static properties={details:{attribute:!1},_w:{state:!0},_h:{state:!0},_focus:{state:!0}};createRenderRoot(){return this}constructor(){super(),this.details=null,this._w=0,this._h=0,this._root=null,this._focus=[],this._dirByPath=new Map,this._status="loading",this._meta={files:0,total:0,prefix:""},this._ro=null,this._plot=null,this._tooltip=null,this._ttCell=null,this._onPointerMove=this._onPointerMove.bind(this),this._onPointerLeave=this._onPointerLeave.bind(this),this._onPlotClick=this._onPlotClick.bind(this)}willUpdate(t){t.has("details")&&this._rebuild()}firstUpdated(){this._plot=this.querySelector(".bundle-treemap-plot"),this._tooltip=this.querySelector(".bundle-treemap-tooltip"),!(!this._plot||typeof ResizeObserver>"u")&&(this._ro=new ResizeObserver(t=>{let r=t[0]?.contentRect;if(!r)return;let n=Math.floor(r.width),o=Math.floor(r.height);(n!==this._w||o!==this._h)&&(this._w=n,this._h=o)}),this._ro.observe(this._plot))}disconnectedCallback(){super.disconnectedCallback(),this._ro&&(this._ro.disconnect(),this._ro=null)}_onPointerMove(t){let r=t.target.closest(".bundle-treemap-node");if(!r||!this._tooltip){this._hideTooltip();return}if(r!==this._ttCell){this._ttCell=r;let n=r.dataset;K(c`<div class="bundle-treemap-tt-path">${n.ttPath}</div>${n.ttPkg?c`<div class="bundle-treemap-tt-head"><span class="bundle-treemap-tt-dot" style="${`background:${n.ttColor}`}"></span> <span class="bundle-treemap-tt-pkg">${n.ttPkg}</span></div>`:""}<div class="bundle-treemap-tt-meta">${n.ttMeta}</div>`,this._tooltip)}this._positionTooltip(t.clientX,t.clientY)}_onPointerLeave(){this._hideTooltip()}_positionTooltip(t,r){let n=this._tooltip;if(!n||!this._plot)return;n.classList.add("show");let o=this._plot.getBoundingClientRect(),s=t-o.left,i=r-o.top,l=12,d=s+l;d+n.offsetWidth>o.width-4&&(d=s-n.offsetWidth-l),d<4&&(d=4);let u=i+l;u+n.offsetHeight>o.height-4&&(u=i-n.offsetHeight-l),u<4&&(u=4),n.style.left=`${d}px`,n.style.top=`${u}px`}_hideTooltip(){this._ttCell=null,this._tooltip&&this._tooltip.classList.remove("show")}_rebuild(){if(this._root=null,this._focus=[],this._dirByPath=new Map,this._meta={files:0,total:0,prefix:""},!this.details){this._status="loading";return}let t=Ne(this.details);if(!t||t.size===0){this._status="empty";return}let r=[...t.keys()],{prefix:n,stripped:o}=Xe(r),s=new TextEncoder,i={name:"",children:new Map,value:0,isFile:!1},l=0,d=0;for(let p=0;p<r.length;p++){let f=t.get(r[p]),h=typeof f=="string"?s.encode(f).byteLength:0;if(h<=0)continue;let b=o[p].split("/"),m=i,y=!1;for(let v=0;v<b.length-1;v++){let $=m.children.get(b[v]);if($&&$.isFile){y=!0;break}$||($={name:b[v],children:new Map,value:0,isFile:!1},m.children.set(b[v],$)),m=$}if(y)continue;let k=b.at(-1),w=m.children.get(k);w&&!w.isFile||(w||(w={name:k,isFile:!0,value:0,origPath:r[p]},m.children.set(k,w)),w.value+=h,l+=h,d++)}if(l===0){this._status="empty";return}for(let p of i.children.values())Fg(p);let u=new Map;Bg(i,"",null,u),this._root=i,this._dirByPath=u,this._meta={files:d,total:l,prefix:n},this._status="ok"}get _focusNode(){return this._focus.length>0?this._focus.at(-1):this._root}_drillInto(t){if(!t||t.isFile||!t.children||t.children.size===0)return;let r=[];for(let n=t;n&&n!==this._root;n=n.parent)r.push(n);r.reverse(),this._focus=r,this._hideTooltip()}_focusTo(t){let r=t<0?[]:this._focus.slice(0,t+1);r.length!==this._focus.length&&(this._focus=r,this._hideTooltip())}_onPlotClick(t){let r=t.target.closest("[data-treemap-into]");if(!r)return;let n=this._dirByPath.get(r.dataset.treemapInto);n&&this._drillInto(n)}_renderCrumbs(){let t=this._focus,r=t.length===0,n=t.slice(0,-1),o=r?null:t.at(-1);return c`<nav class="bundle-treemap-crumbs" aria-label="Treemap location"><span class="bundle-treemap-crumbs-lead"><button type="button" class="${A({"bundle-treemap-crumb-home":!0,"at-root":r})}" @click="${()=>this._focusTo(-1)}">Source treemap</button> ${n.map((s,i)=>c`<span class="bundle-treemap-crumb-sep" aria-hidden="true">›</span><button type="button" class="bundle-treemap-crumb" @click="${()=>this._focusTo(i)}" title="${s.path}">${s.name}</button>`)} </span>${o?c`<span class="bundle-treemap-crumb-sep" aria-hidden="true">›</span><span class="bundle-treemap-crumb-current" aria-current="location" title="${o.path}">${o.name}</span>`:""}</nav>`}_cell(t){let r=this._meta.total||1,n=t.node.value/r*100,o=n>=10?n.toFixed(0):n.toFixed(n>=1?1:2),s={left:`${t.x}px`,top:`${t.y}px`,width:`${t.w}px`,height:`${t.h}px`},i=`${t.node.count} ${t.node.count===1?"file":"files"}`;if(t.kind==="dir")return c`<div class="bundle-treemap-node bundle-treemap-dir" style="${ue(s)}" data-treemap-into="${t.node.path}" data-tt-path="${`${t.node.path}/`}" data-tt-meta="${`${ne(t.node.value)} \xB7 ${i} \xB7 ${o}%`}"><span class="bundle-treemap-dirname">${t.node.name}</span></div>`;let l=or(t.node.path),d=ht(l),u=ue({...s,background:d,color:Ek(d)}),p=l==="__own__"?"own source":l;return t.kind==="agg"?c`<div class="bundle-treemap-node bundle-treemap-leaf bundle-treemap-agg" style="${u}" data-treemap-into="${t.node.path}" data-tt-path="${`${t.node.path}/`}" data-tt-pkg="${p}" data-tt-color="${d}" data-tt-meta="${`${ne(t.node.value)} \xB7 ${i} \xB7 ${o}%`}"><span class="bundle-treemap-label">${t.node.name}/</span></div>`:c`<div class="bundle-treemap-node bundle-treemap-leaf bundle-treemap-file" style="${u}" data-bundle-view-source="${t.node.origPath}" data-tt-path="${t.node.path}" data-tt-pkg="${p}" data-tt-color="${d}" data-tt-meta="${`${ne(t.node.value)} \xB7 ${o}% of bundle`}"><span class="bundle-treemap-label">${t.node.name}</span></div>`}render(){let t=this._focusNode,r=[];if(this._status==="ok"&&t&&t.children&&this._w>0&&this._h>0){let d=[...t.children.values()].toSorted((u,p)=>p.value-u.value);for(let u of Rg(d,{x:0,y:0,w:this._w,h:this._h}))Mg(u.node,u.x,u.y,u.w,u.h,1,r)}let{files:n,total:o,prefix:s}=this._meta,i=this._status==="ok"&&t?t.count:n,l=this._status==="ok"&&t?t.value:o;return c`<header class="bundle-treemap-head">${this._renderCrumbs()} <span class="bundle-treemap-sub">${i} ${i===1?"file":"files"} · ${ne(l)}${s?c`· <span class="mono">${s}</span>`:""}</span></header><div class="bundle-treemap-plot" @click="${this._onPlotClick}" @pointermove="${this._onPointerMove}" @pointerleave="${this._onPointerLeave}">${this._status==="loading"?c`<div class="bundle-treemap-empty">Loading…</div>`:this._status==="empty"?c`<div class="bundle-treemap-empty">This bundle doesn't carry any source content.</div>`:r.map(d=>this._cell(d))}<div class="bundle-treemap-tooltip"></div></div>`}};customElements.define("bundle-treemap",gd);var Tk=new TextEncoder;function Ei(e){return typeof e=="string"?Tk.encode(e).byteLength:0}function Lg(e){return(t,r)=>Math.abs(r.delta)-Math.abs(t.delta)||t[e].localeCompare(r[e])}function Ai(e){return(t,r)=>r.bytes-t.bytes||t[e].localeCompare(r[e])}function Ik(){return{baseBytes:0,otherBytes:0,onlyBaseFiles:0,onlyOtherFiles:0,changedFiles:0}}function Pg(e,t,r){let n=[],o=[],s=[],i=0,l=0,d=0,u=0,p=0,f=0,h=new Map,b=v=>{let $=r(v),R=h.get($);return R||(R=Ik(),h.set($,R)),R},m=new Set([...e.keys(),...t.keys()]);for(let v of m){let $=e.has(v),R=t.has(v),F=b(v);if($&&R){let B=e.get(v),te=t.get(v),z=Ei(B),be=B===te?z:Ei(te);if(i+=z,l+=be,F.baseBytes+=z,F.otherBytes+=be,B===te)f++;else{let _e=be-z;s.push({path:v,baseBytes:z,otherBytes:be,delta:_e}),p+=_e,F.changedFiles++}}else if($){let B=Ei(e.get(v));i+=B,d+=B,F.baseBytes+=B,F.onlyBaseFiles++,n.push({path:v,bytes:B})}else{let B=Ei(t.get(v));l+=B,u+=B,F.otherBytes+=B,F.onlyOtherFiles++,o.push({path:v,bytes:B})}}let y=[],k=[],w=[];for(let[v,$]of h){let R=$.baseBytes>0||$.onlyBaseFiles>0||$.changedFiles>0,F=$.otherBytes>0||$.onlyOtherFiles>0||$.changedFiles>0,B=$.onlyBaseFiles+$.onlyOtherFiles+$.changedFiles;R&&!F?y.push({pkg:v,bytes:$.baseBytes}):F&&!R?k.push({pkg:v,bytes:$.otherBytes}):(B>0||$.baseBytes!==$.otherBytes)&&w.push({pkg:v,baseBytes:$.baseBytes,otherBytes:$.otherBytes,delta:$.otherBytes-$.baseBytes})}return n.sort(Ai("path")),o.sort(Ai("path")),s.sort(Lg("path")),y.sort(Ai("pkg")),k.sort(Ai("pkg")),w.sort(Lg("pkg")),{totals:{baseFiles:e.size,baseBytes:i,otherFiles:t.size,otherBytes:l,onlyBaseFiles:n.length,onlyBaseBytes:d,onlyOtherFiles:o.length,onlyOtherBytes:u,changedFiles:s.length,changedDelta:p,unchangedFiles:f,fileDelta:t.size-e.size,byteDelta:l-i,identical:n.length===0&&o.length===0&&s.length===0},files:{onlyBase:n,onlyOther:o,changed:s},packages:{onlyBase:y,onlyOther:k,changed:w}}}var Og=400,Po=null;function md(e){return e===0?"\xB10 B":`${e>0?"+":"\u2212"}${Math.abs(e).toLocaleString()} B`}function Rk(e,t){if(!t)return"";let r=e/t*100;return`${r>0?"+":r<0?"\u2212":"\xB1"}${Math.abs(r).toFixed(1)}%`}function Ng(e){return e==="__own__"?"own source":e}var bd=class extends H{static properties={details:{attribute:!1},integrity:{attribute:!1},_targetIntegrity:{state:!0},_otherDetails:{state:!0},_status:{state:!0}};createRenderRoot(){return this}constructor(){super(),this.details=null,this.integrity=null,this._targetIntegrity=null,this._otherDetails=null,this._status="idle",this._diff=null,this._diffKey=null}willUpdate(t){if(t.has("integrity")){if(Po&&this.integrity===Po.base){let r=Po.target;Po=null,this._targetIntegrity=r,this._otherDetails=null,this._status="loading",this._diff=null,this._diffKey=null,this._loadOther(r);return}this._targetIntegrity=null,this._otherDetails=null,this._status="idle",this._diff=null,this._diffKey=null}}_swap(){let t=this._targetIntegrity;!t||t===this.integrity||(a.bundles??[]).some(r=>r.integrity===t)&&(Po={base:t,target:this.integrity},this.dispatchEvent(new CustomEvent("bundle-swap",{bubbles:!0,composed:!0,detail:{integrity:t}})))}_nameFor(t){return(a.bundles??[]).find(n=>n.integrity===t)?.name??`${t.slice(0,15)}\u2026`}_onPick(t){let r=t.target.value||null;if(this._targetIntegrity=r,this._otherDetails=null,this._diff=null,this._diffKey=null,!r){this._status="idle";return}this._status="loading",this._loadOther(r)}async _loadOther(t){let r=(a.bundles??[]).find(o=>o.integrity===t);if(!r){this._status="idle",this._targetIntegrity=null;return}let n=await un(t,r);this._targetIntegrity===t&&(this._otherDetails=n,this._status="ready")}get _baseReady(){return!!(this.details&&this.details.integrity===this.integrity&&(this.details.json||this.details.bundle))}_fileRow(t,r,n,o){let s=c`<span class="bundle-compare-row-path mono">${r}</span>${o}`;return n?c`<li><button type="button" class="bundle-compare-row bundle-compare-row-link" data-bundle-view-source="${t}" title="${t}">${s}</button></li>`:c`<li><div class="bundle-compare-row" title="${t}">${s}</div></li>`}_fileGroup(t,r,n,o,s){if(r.length===0)return g;let i=r.slice(0,Og),l=r.length-i.length;return c`<section class="${`bundle-compare-group bundle-compare-${n}`}"><header class="bundle-compare-group-head"><span class="bundle-compare-dot" aria-hidden="true"></span> <span class="bundle-compare-group-title">${t}</span> <span class="bundle-compare-group-count">${r.length}</span></header><ul class="bundle-compare-rows">${G(i,d=>d.path,d=>{let u=d.delta===void 0?c`<span class="bundle-compare-row-size">${ne(d.bytes)}</span>`:c`<span class="bundle-compare-row-size">${ne(d.baseBytes)} → ${ne(d.otherBytes)}</span> <span class="${`bundle-compare-row-delta ${d.delta>0?"up":d.delta<0?"down":""}`}">${md(d.delta)}</span>`;return this._fileRow(d.path,s(d.path),o,u)})}</ul>${l>0?c`<div class="bundle-compare-more">and ${l.toLocaleString()} more…</div>`:g}</section>`}_pkgGroup(t,r,n){if(r.length===0)return g;let o=r.slice(0,Og),s=r.length-o.length;return c`<section class="${`bundle-compare-group bundle-compare-${n}`}"><header class="bundle-compare-group-head"><span class="bundle-compare-dot" aria-hidden="true"></span> <span class="bundle-compare-group-title">${t}</span> <span class="bundle-compare-group-count">${r.length}</span></header><ul class="bundle-compare-rows">${G(o,i=>i.pkg,i=>{let l=i.delta===void 0?c`<span class="bundle-compare-row-size">${ne(i.bytes)}</span>`:c`<span class="bundle-compare-row-size">${ne(i.baseBytes)} → ${ne(i.otherBytes)}</span> <span class="${`bundle-compare-row-delta ${i.delta>0?"up":i.delta<0?"down":""}`}">${md(i.delta)}</span>`;return c`<li><div class="bundle-compare-row" title="${Ng(i.pkg)}"><span class="bundle-compare-pkg-dot" style="${ue({background:ht(i.pkg)})}"></span> <span class="bundle-compare-row-path">${Ng(i.pkg)}</span> ${l}</div></li>`})}</ul>${s>0?c`<div class="bundle-compare-more">and ${s.toLocaleString()} more…</div>`:g}</section>`}_diffFor(){let t=`${this.integrity}|${this._targetIntegrity}`;if(this._diffKey!==t||!this._diff){let r=Ne(this.details),n=Ne(this._otherDetails),{prefix:o}=Xe([...r.keys(),...n.keys()]),s=o?i=>or(i.startsWith(o)?i.slice(o.length):i):or;this._diff=Pg(r,n,s),this._diffKey=t}return this._diff}_renderSummary(t){return c`<div class="bundle-compare-summary"><div class="bundle-compare-metric"><span class="bundle-compare-metric-label">Files</span> <span class="bundle-compare-metric-value">${t.baseFiles.toLocaleString()} → ${t.otherFiles.toLocaleString()}</span> <span class="${`bundle-compare-metric-delta ${t.fileDelta>0?"up":t.fileDelta<0?"down":""}`}">${t.fileDelta===0?"\xB10":`${t.fileDelta>0?"+":"\u2212"}${Math.abs(t.fileDelta).toLocaleString()}`}</span></div><div class="bundle-compare-metric"><span class="bundle-compare-metric-label">Size</span> <span class="bundle-compare-metric-value">${ne(t.baseBytes)} → ${ne(t.otherBytes)}</span> <span class="${`bundle-compare-metric-delta ${t.byteDelta>0?"up":t.byteDelta<0?"down":""}`}">${md(t.byteDelta)}${(()=>{let r=Rk(t.byteDelta,t.baseBytes);return r?c`${" "}<span class="bundle-compare-pct">(${r})</span>`:g})()}</span></div><div class="bundle-compare-chips"><span class="bundle-compare-chip removed">−${t.onlyBaseFiles.toLocaleString()} removed</span> <span class="bundle-compare-chip added">+${t.onlyOtherFiles.toLocaleString()} added</span> <span class="bundle-compare-chip changed">${t.changedFiles.toLocaleString()} changed</span> <span class="bundle-compare-chip unchanged">${t.unchangedFiles.toLocaleString()} unchanged</span></div></div>`}_renderPicker(t,r){let n=this._nameFor(this.integrity);return c`<div class="bundle-compare-picker"><span class="bundle-compare-base" title="${n}">${n}</span> <span class="bundle-compare-arrow" aria-hidden="true">→</span> <label class="bundle-compare-select-wrap"><span class="bundle-compare-select-hint">Compare with</span> <select class="bundle-compare-select" .value="${fe(this._targetIntegrity??"")}" @change="${o=>this._onPick(o)}" aria-label="Bundle to compare with"><option value="">Choose a bundle…</option>${t.map(o=>c`<option value="${o.integrity}">${o.label}</option>`)}</select></label> ${r?c`<button type="button" class="bundle-compare-swap" @click="${()=>this._swap()}" aria-label="Swap the two bundles"><span class="bundle-compare-swap-icon" aria-hidden="true">↔</span>Swap</button>`:g}</div>`}_otherOptions(){let t=(a.bundles??[]).filter(n=>n.integrity!==this.integrity),r=new Map;for(let n of t)r.set(n.name,(r.get(n.name)??0)+1);return t.map(n=>({integrity:n.integrity,label:r.get(n.name)>1?`${n.name} \xB7 ${n.integrity.slice(7,13)}\u2026`:n.name}))}render(){let t=this._otherOptions(),r=!!this._targetIntegrity&&t.some(i=>i.integrity===this._targetIntegrity),n=t.length>0?this._renderPicker(t,r):g,o=r&&this._status==="ready"&&this._otherDetails&&(this._otherDetails.json||this._otherDetails.bundle)&&!this._otherDetails.error,s;return this._baseReady?t.length===0?s=c`<div class="bundle-compare-empty">No other bundles to compare with. Drop a second <code>.map</code> or <code>.stasis.code.br</code> bundle to diff against this one.</div>`:r?this._status==="loading"||!this._otherDetails?s=c`<div class="bundle-compare-empty">Comparing…</div>`:this._otherDetails.error?s=c`<div class="bundle-compare-empty is-error">Couldn't read the selected bundle: ${this._otherDetails.error}</div>`:!this._otherDetails.json&&!this._otherDetails.bundle?s=c`<div class="bundle-compare-empty is-error">The selected bundle couldn't be parsed.</div>`:s=this._renderDiff():s=c`<div class="bundle-compare-empty">Pick a bundle above to compare against <strong>${this._nameFor(this.integrity)}</strong>.</div>`:s=c`<div class="bundle-compare-empty">Loading bundle…</div>`,c`<div class="bundle-compare"><header class="bundle-compare-head">${n} ${this._baseReady&&o?this._renderSummary(this._diffFor().totals):g}</header><div class="bundle-compare-body">${s}</div></div>`}_renderDiff(){let t=this._diffFor(),r=this._nameFor(this._targetIntegrity),n=this._nameFor(this.integrity),o=[...t.files.onlyBase.map(p=>p.path),...t.files.onlyOther.map(p=>p.path),...t.files.changed.map(p=>p.path)],{prefix:s,stripped:i}=Xe(o),l=new Map;for(let p=0;p<o.length;p++)l.set(o[p],i[p]);let d=p=>l.get(p)??p,u=t.packages.onlyOther.length>0||t.packages.onlyBase.length>0||t.packages.changed.length>0;return c`<div class="bundle-compare-caption">Changes from <strong>${n}</strong> to <strong>${r}</strong> ${s?c`· <span class="mono">${s}</span>`:g}</div>${t.totals.identical?c`<div class="bundle-compare-identical">These two bundles carry identical sources (${t.totals.unchangedFiles.toLocaleString()} ${t.totals.unchangedFiles===1?"file":"files"}).</div>`:c`${u?c`<section class="bundle-compare-section"><h3 class="bundle-compare-section-head">Packages</h3><div class="bundle-compare-cols">${this._pkgGroup(`Removed \xB7 only in ${n}`,t.packages.onlyBase,"removed")} ${this._pkgGroup(`Added \xB7 only in ${r}`,t.packages.onlyOther,"added")} ${this._pkgGroup("Changed size",t.packages.changed,"changed")}</div></section>`:g}<section class="bundle-compare-section"><h3 class="bundle-compare-section-head">Files</h3><div class="bundle-compare-cols bundle-compare-cols--files">${this._fileGroup(`Removed \xB7 only in ${n}`,t.files.onlyBase,"removed",!0,d)} ${this._fileGroup(`Added \xB7 only in ${r}`,t.files.onlyOther,"added",!1,d)} ${this._fileGroup("Changed",t.files.changed,"changed",!0,d)}</div></section>`}`}};customElements.define("bundle-compare",bd);var Fk=c`<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path d="M6 9V2h12v7"/><path d="M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2"/><rect x="6" y="14" width="12" height="8"/></svg>`,yd=class extends P{createRenderRoot(){return this}render(){return a.reports.length>0&&a.currentView==="findings"&&a.viewMode!=="graph"&&a.viewMode!=="kanban"?c`<button type="button" title="print this report" aria-label="print" @click="${this._onClick}">${Fk}</button>`:g}_onClick=()=>{this.dispatchEvent(new CustomEvent("print-requested",{bubbles:!0,composed:!0}))}};customElements.define("print-button",yd);var Bk=c`<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" x2="12" y1="15" y2="3"/></svg>`,wd=class extends P{createRenderRoot(){return this}render(){return a.reports.length>0&&a.currentView==="findings"&&a.viewMode!=="graph"&&a.viewMode!=="kanban"?c`<button type="button" title="download this report" aria-label="download" @click="${this._onClick}">${Bk}</button>`:g}_onClick=()=>{this.dispatchEvent(new CustomEvent("download-requested",{bubbles:!0,composed:!0}))}};customElements.define("download-button",wd);function Oo(e){let t=new Map;for(let[r,n]of a.triage)n[e]&&t.set(r,n[e]);return t}var Mk={get markers(){return Oo("color")},get triageState(){return Oo("triage")},get comments(){return Oo("comment")},get fixes(){return Oo("fix")},get flags(){return Oo("flagged")},get(e){let t=a.triage.get(e),r={};return t?.color&&(r.color=t.color),t?.triage&&(r.triage=t.triage),t?.comment&&(r.comment=t.comment),t?.fix&&(r.fix=t.fix),t?.flagged!==void 0&&(r.flagged=t.flagged),r},async set(e,{color:t,triage:r,comment:n,fix:o,flagged:s}={}){let i=!1;if(t!==void 0&&(t===null||t===""?L(a.triage,e,{color:void 0})&&(i=!0):a.triage.get(e)?.color!==t&&(L(a.triage,e,{color:t}),i=!0)),r!==void 0)if(r===null||r===""||r===!1)L(a.triage,e,{triage:void 0})&&(i=!0);else if(r==="inprogress"||r==="fixed"||r==="invalid"||r==="deleted")a.triage.get(e)?.triage!==r&&(L(a.triage,e,{triage:r}),i=!0);else throw new TypeError(`DeepView.triage.set: unknown triage value ${JSON.stringify(r)} (expected 'inprogress' | 'fixed' | 'invalid' | 'deleted' | null)`);if(n!==void 0){let l=n?String(n):"";l?a.triage.get(e)?.comment!==l&&(L(a.triage,e,{comment:l}),i=!0):L(a.triage,e,{comment:void 0})&&(i=!0)}if(o!==void 0){let l=o?String(o):"";l?a.triage.get(e)?.fix!==l&&(L(a.triage,e,{fix:l}),i=!0):L(a.triage,e,{fix:void 0})&&(i=!0)}if(s!==void 0){let l=s===null||s===""?void 0:!!s;a.triage.get(e)?.flagged!==l&&(L(a.triage,e,{flagged:l}),i=!0)}return i&&(await oe(),x()),i}};window.DeepView={get reports(){return a.reports.slice()},get groups(){return Pt()},get findings(){return Pt().flat()},get currentFile(){return a.currentFile},get currentWorkspace(){return a.currentWorkspace},triage:Mk,themes:dg,setTheme:lg,get theme(){return cg()},triageSync:N,refresh(){x()},export(){return kg()}};var Lk={default:X.default,"claude-security":X["claude-security"],"codex-security":X["codex-security"],deepsec:X.deepsec,bundle:ln,workspace:Js};for(let e of document.querySelectorAll(".drop-supported-icon[data-icon]")){let t=Lk[e.dataset.icon];t&&(e.innerHTML=t)}_p(x);rl(x);xp(x);N.onStatusChange(x);kp(async(e,t)=>{a.currentWorkspace===e?await nr(e):a.currentFile&&a.currentFile===t?await Et(t):await j()});$p(async()=>{await j(),a.currentView==="bundles"&&x()});zh();Hh();async function Wg(){let e=wl();if(!e)return!1;try{history.replaceState(null,"",location.pathname)}catch{}let t;try{t=await Vh({encoded:e})}catch(n){return alert(`Couldn't open the share-link unlock prompt: ${n.message}`),!1}if(!t)return!1;let r=await Ja({id:t.id,name:t.name,privateKey:t.privateKeyBase64});if(r.status==="already-attached")return alert(`This workspace is already attached as "${r.workspace.name}".`),!1;if(r.status==="name-collision"){let n=r.existing?.name;return alert(n?`A workspace named "${n}" already exists. Open the share link again and pick a different name.`:"The shared workspace name is empty or invalid. Ask the sender to re-share with a real name."),!1}return r.workspace?.id?await nr(r.workspace.id):await j(),!0}var yn=!1;async function Hg(){if(yn||(yn=!0,await jt(),Va(),await j(),await Wg()))return;let t=we(rr);if(t)if(t.startsWith("ws:")){let r=t.slice(3);W().some(n=>n.id===r)&&await nr(r)}else if(t.startsWith("b:")){let r=t.slice(2),n=r.indexOf(" "),o=n>=0?r.slice(0,n):r,s=n>=0?r.slice(n+1):"",i=wo.has(s)?s:"overview";(a.bundles??[]).some(l=>l.integrity===o)&&(a.currentView="bundles",a.selectedBundle=o,a.bundleDetails=null,a.bundleSourceFile=null,a.bundleSourceFindingIdx=null,a.bundleCodeSearchQuery="",a.bundleCodeSearchMode="files",a.bundleSearchQuery="",a.bundleSearchRegex=!1,a.bundleSearchCase=!1,a.bundleSearchContext=!0,a.bundleDetailsTab=i,a.shownTriage=null,E.showAll=!0,x(),Ot(o))}else(await pe()).includes(t)&&await Et(t)}var Dg=Q(),Ug=!1;function zg(e){Ug||(Ug=!0,queueMicrotask(()=>{alert(e+" This tab will reload to refresh its state. Any unsaved edits in this tab will be lost."),location.reload()}))}ve(()=>{let e=Dg,t=Q();if(Dg=t,x(),!yn&&ct()){Hg().catch(r=>console.warn("continueBoot:",r));return}if(yn&&t&&!ct()){zg("Encryption was just enabled in another tab.");return}yn&&e&&!t&&!ra()&&zg("Encryption was disabled in another tab.")});window.addEventListener("hashchange",()=>{yn&&Wg().catch(e=>console.warn("share-link hashchange:",e))});(async()=>{if(!await jh()){try{let e=window.matchMedia?.("(display-mode: window-controls-overlay)").matches;if(!e&&localStorage.getItem("deepview.sidebarCollapsed")==="1"&&ou.classList.add("collapsed"),window.matchMedia?.("(display-mode: standalone)").matches||e){let r=document.querySelector('meta[name="viewport"]');r&&r.setAttribute("content","width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"),window.addEventListener("wheel",n=>{(n.ctrlKey||n.metaKey)&&n.preventDefault()},{passive:!1}),window.addEventListener("keydown",n=>{(n.ctrlKey||n.metaKey)&&(n.key==="="||n.key==="+"||n.key==="-"||n.key==="0")&&n.preventDefault()})}}catch{}Q()&&!ct()||await Hg()}})();
86
+ `)}function Ik(e){let t=e.map(n=>n.fileName),r="";return t.length===1?r=t[0]:t.length>1&&(r=si(t)),r=r.replace(/\.json$/u,""),`${r||"deepview-report"}.md`}function Fg(e){if(e.length===0)return;let t=Tk(e),r=new Blob([t],{type:"text/markdown;charset=utf-8"});Wr(r,Ik(e))}Da(()=>{a.currentView==="bundles"&&a.selectedBundle?$():a.currentView==="packages"?$():a.currentView==="repositories"?$():(a.currentView==="findings"||a.currentView==="files")&&K().catch(()=>{})});function Bg(){a.currentView==="bundles"&&a.bundleDetailsTab==="graph"?Si():Cc()}function Oi(){a.currentView==="bundles"&&a.bundleDetailsTab==="graph"?Ci():Ec()}function An(){let e=document.querySelector(".bundle-source-code-wrap"),t=e?.scrollTop??0,r=e?.scrollLeft??0;$();let n=document.querySelector(".bundle-source-code-wrap");n&&(n.scrollTop=t,n.scrollLeft=r)}function Go(e){let r=document.querySelector(e)?.scrollTop??0;$();let n=document.querySelector(e);n&&(n.scrollTop=r)}function lr(){a.viewMode==="table"?Go(".findings-table-list"):$()}var Qc=0;function Rk(){Qc||(Qc=requestAnimationFrame(()=>{Qc=0,$()}))}function Y(e,t){for(let r of e.composedPath())if(r?.matches?.(t))return r;return null}function Mg(e){let r=Y(e,"[data-gid]")?.dataset?.gid,n=r?Rr(r):null;if(!n)return null;let o=ze(n);return gf(o,li(o))}I.addEventListener("click",e=>{let t=Y(e,"[data-finding-code-bundle]");if(t){let _=t.dataset.findingCodeBundle,z=t.dataset.findingCodeFile,J=t.dataset.findingCodeLine,G=J?parseInt(J,10):null;a.bundleSourceFile=z||null,a.bundleSourceFindingIdx=null,(a.bundleDetailsTab==="code"||a.bundleDetailsTab==="search")&&(a.bundleDetailsTab="overview");let ye=()=>{Number.isFinite(G)&&queueMicrotask(()=>{let Se=document.querySelector(`.bundle-source-lineno-row[data-line="${G}"]`);Se&&Se.scrollIntoView({block:"start",behavior:"instant"})})};if(a.selectedBundle===_&&a.bundleDetails?.integrity===_){$(),ye();return}a.selectedBundle=_,a.bundleDetails=null,$(),(async()=>(await Ot(_),ye()))();return}let r=e.target.closest("[data-package-expand]");if(r){let _=r.dataset.packageExpand;a.expandedPackages.has(_)?a.expandedPackages.delete(_):a.expandedPackages.add(_),$();return}let n=e.target.closest("[data-package-row-issues]");if(n){let _=n.dataset.packageRowIssues,z=n.dataset.packageRowIssuesVersion;a.selectedPackage=_,a.selectedPackageVersion=z||null,a.packageDetailsTab="issues",a.packageSlideTriage=null,a.packageSlideTransient=!0,$();return}let o=e.target.closest("[data-repository-row-issues]");if(o){let _=o.dataset.repositoryRowIssues;a.selectedRepository=_,a.repositoryDetailsTab="issues",a.repositorySlideTriage=null,a.repositorySlideTransient=!0,$();return}let s=e.target.closest("[data-select-package]");if(s){let _=s.dataset.selectPackage,z=s.dataset.selectPackageVersion??"",J=z===""?null:z;if(a.selectedPackage===_&&a.selectedPackageVersion===J)return;a.selectedPackage=_,a.selectedPackageVersion=J,a.packageDetailsTab="overview",a.packageSlideTriage=null,a.packageSlideTransient=!1,$();return}if(e.target.closest("[data-deselect-package]")){a.selectedPackage=null,a.selectedPackageVersion=null,$();return}let i=e.target.closest("[data-package-tab]");if(i){let _=i.dataset.packageTab;(_==="overview"||_==="issues")&&a.packageDetailsTab!==_&&(a.packageDetailsTab=_,$());return}if(e.target.closest('[data-action="package-slide-back"]')){a.packageDetailsTab="overview",a.packageSlideTriage=null,a.packageSlideTransient&&(a.selectedPackage=null,a.selectedPackageVersion=null,a.packageSlideTransient=!1),$();return}let l=e.target.closest("[data-package-report]");if(l){let _=l.dataset.packageReport;_&&At(_);return}let d=e.target.closest("[data-select-repository]");if(d){let _=d.dataset.selectRepository;if(a.selectedRepository===_)return;a.selectedRepository=_,a.repositoryDetailsTab="overview",a.repositorySlideTriage=null,a.repositorySlideTransient=!1,$();return}if(e.target.closest("[data-deselect-repository]")){a.selectedRepository=null,$();return}let u=e.target.closest("[data-repository-tab]");if(u){let _=u.dataset.repositoryTab;(_==="overview"||_==="issues")&&a.repositoryDetailsTab!==_&&(a.repositoryDetailsTab=_,$());return}if(e.target.closest('[data-action="repository-slide-back"]')){a.repositoryDetailsTab="overview",a.repositorySlideTriage=null,a.repositorySlideTransient&&(a.selectedRepository=null,a.repositorySlideTransient=!1),$();return}let p=e.target.closest("[data-bundle-tab]");if(p){let _=p.dataset.bundleTab;if(Bo.has(_)){if(_===a.bundleDetailsTab){a.selectedBundle&&sr(a.selectedBundle,_);return}a.bundleDetailsTab==="graph"&&_!=="graph"&&Pe(),a.bundleDetailsTab=_,a.bundleSourceFile=null,a.bundleSourceFindingIdx=null,a.selectedBundle&&sr(a.selectedBundle,_),$(),_==="code"&&Po()}return}if(Y(e,"[data-bundle-search-context]")){a.bundleSearchContext=!a.bundleSearchContext,Go(".bundle-search-results");return}if(e.target.closest("[data-advisories-consent]")){gh(),$();return}if(e.target.closest("[data-advisories-retry]")){bh(a.bundleDetails,$).catch(()=>{}),$();return}let h=e.target.closest("[data-bundle-issue-report]");if(h){let _=h.dataset.bundleIssueReport;_&&At(_);return}if(e.target.classList?.contains("bundle-source-overlay")||e.target.closest('[data-action="bundle-source-close"]')){a.bundleSourceFile&&(a.bundleSourceFile=null,a.bundleSourceFindingIdx=null,$());return}if(e.target.closest('[data-action="bundle-source-panel-close"]')){a.bundleSourceFindingIdx!=null&&(a.bundleSourceFindingIdx=null,An());return}let b=e.target.closest("[data-bundle-source-finding]");if(b){let _=parseInt(b.dataset.bundleSourceFinding,10);Number.isFinite(_)&&(a.bundleSourceFindingIdx=a.bundleSourceFindingIdx===_?null:_,An());return}let m=e.target.closest("[data-bundle-code-issue-step]");if(m){let _=m.closest("[data-bundle-code-issue-order]"),z=null;try{z=JSON.parse(_?.dataset.bundleCodeIssueOrder??"null")}catch{}if(Array.isArray(z)&&z.length>0){let J=m.dataset.bundleCodeIssueStep==="-1"?-1:1,G=z.findIndex(Se=>Se.idx===a.bundleSourceFindingIdx),ye=G===-1?J>0?z[0]:z.at(-1):z[(G+J+z.length)%z.length];a.bundleSourceFindingIdx=ye.idx,An(),ye.line>0&&queueMicrotask(()=>{let Se=document.querySelector(`.bundle-source-lineno-row[data-line="${ye.line}"]`);Se&&Se.scrollIntoView({block:"center",behavior:"smooth"})})}return}let y=Y(e,"[data-bundle-view-source]");if(y){let _=y.dataset.bundleViewSource;if(!_)return;let z=y.dataset.bundleViewFindingIdx,J=z===void 0?null:parseInt(z,10),G=y.dataset.bundleViewLine,ye=G?parseInt(G,10):null,Se=a.bundleSourceFile!==_;if(a.bundleSourceFile=_,Number.isFinite(J)?a.bundleSourceFindingIdx=J:Se&&(a.bundleSourceFindingIdx=null),y.closest(".bundle-code-rail")?Go(".bundle-code-rail-body"):y.closest(".bundle-search-results")?Go(".bundle-search-results"):y.closest(".bundles-slide-body")?Go(".bundles-slide-body"):$(),Number.isFinite(ye)){let ct=y.dataset.bundleViewScrollBlock||"center";queueMicrotask(()=>{let Ve=document.querySelector(`.bundle-source-lineno-row[data-line="${ye}"]`);Ve&&Ve.scrollIntoView({block:ct,behavior:"smooth"})})}return}if(e.target.closest('[data-action="toggle-files"]')){a.currentView==="files"?a.currentView="findings":(a.viewMode==="graph"&&Pe(),a.currentView="files"),document.body.classList.remove("report-fullscreen"),$();return}let w=Y(e,"[data-g2-pkg]");if(w){let _=w.dataset.g2Pkg;C.solo=C.solo===_?null:_,C.solo&&(C.selected=null),Bg(),Oi(),C.graphState?.requestDraw?.();return}let k=Y(e,"[data-g2-select]");if(k){C.selected=k.dataset.g2Select,Bg(),C.graphState?.requestDraw?.();return}let E=Y(e,"[data-g2-top-pkgs]");if(E){C.topPkgsTab=E.dataset.g2TopPkgs,Oi();return}let S=Y(e,"[data-g2-jump-findings]");if(S){if(a.currentView==="bundles"){a.bundleDetailsTab==="graph"&&Pe(),a.bundleDetailsTab="issues",a.bundleSourceFile=null,a.bundleSourceFindingIdx=null,a.selectedBundle&&sr(a.selectedBundle,"issues"),$();return}ii(),a.filterConfMin=0,a.filterInclude=S.dataset.g2JumpFindings,a.currentView="findings",a.viewMode==="graph"&&(a.viewMode="table"),Pe(),$();return}let x=Y(e,"[data-g2-jump-file]");if(x){let _=x.dataset.g2JumpFile;a.currentView="files",Pe(),$(),requestAnimationFrame(()=>{let z=document.querySelector(`#${To(_)}`);z&&z.scrollIntoView({behavior:"smooth",block:"start"})});return}if(Y(e,"#g2-path-filter-clear")){C.pathFilter="";let _=document.querySelector("graph-layout")?.shadowRoot?.querySelector("#g2-path-filter");_&&(_.value=""),C.graphState?.requestDraw?.();return}if(Y(e,"#g2-fullscreen")){document.body.classList.toggle("report-fullscreen");return}if(Y(e,"[data-g2-show-all]")){C.showAll=!C.showAll,C.layoutCache=null,C.selected=null,Pe(),$();return}if(Y(e,"[data-g2-split-own]")){C.splitOwnDirs=!C.splitOwnDirs,C.layoutCache=null,C.solo=null,C.focusedPkg=null,C.packagesView&&(C.selected=null),Pe(),$();return}if(Y(e,"[data-g2-packages-view]")){C.packagesView=!C.packagesView,C.layoutCache=null,C.selected=null,C.focusedPkg=null,Pe(),$();return}let W=Y(e,".graph2-triage-selector [data-triage-show]");if(W){let _=W.dataset.triageShow;a.shownTriage=a.shownTriage===_?null:_,C.layoutCache=null,C.selected=null,Pe(),$();return}let be=Y(e,"[data-g2-focus-pkg]");if(be){C.focusedPkg=be.dataset.g2FocusPkg,C.layoutCache=null,Pe(),$();return}if(Y(e,"#g2-back-to-full")){C.focusedPkg=null,C.layoutCache=null,C.packagesView&&(C.selected=null),Pe(),$();return}let ie=Y(e,".tab");if(ie&&Y(e,".tabs")){let z=Y(e,"[data-gid]").dataset.gid,J=ie.dataset.tid;a.activeTabByGroup.set(z,J),lr();return}let _e=Y(e,"[data-triage-action]");if(_e){let _=_e.closest(".triage-menu"),z=_?.dataset.gid;if(!z)return;let J=Rr(z);if(!J)return;let G=_e.dataset.triageAction;if(!["inprogress","fixed","invalid","deleted","ignored","restore"].includes(G))return;let Se=Ue(J).hasConflict?[ze(J)]:J;for(let ct of Se){let Ve=P(ct),ur=ai(ct);G==="restore"?(L(a.triage,Ve,{triage:void 0}),ce(a.triage,Ve,ur,!1)):G==="ignored"?Mt(a.triage,Ve,ur)?ce(a.triage,Ve,ur,!1):(L(a.triage,Ve,{triage:void 0}),ce(a.triage,Ve,ur,!0)):a.triage.get(Ve)?.triage===G?L(a.triage,Ve,{triage:void 0}):(L(a.triage,Ve,{triage:G}),ce(a.triage,Ve,ur,!1))}try{_.hidePopover()}catch{}ae(),lr();return}if(Y(e,".mark-comment")){let z=Y(e,"[data-gid]").dataset.gid,J=Rr(z);if(!J)return;let G=ze(J),ye=P(G),Se=a.triage.get(ye)?.comment??"";Eg({initial:Se,finding:G}).then(ct=>(ct===null||(L(a.triage,ye,{comment:ct||void 0}),ae(),lr()),null)).catch(()=>{});return}let Nr=Y(e,".mark-copy");if(Nr){let _=Mg(e);if(_===null)return;try{navigator.clipboard.writeText(_).then(()=>(Nr.classList.add("copied"),setTimeout(()=>Nr.classList.remove("copied"),1e3),null)).catch(()=>{})}catch{}return}let zt=Y(e,"[data-copy-report]");if(zt){let _=zt.dataset.copyReport;try{navigator.clipboard.writeText(_).then(()=>(zt.classList.add("copied"),setTimeout(()=>zt.classList.remove("copied"),1e3),null)).catch(()=>{})}catch{}return}let cr=Y(e,"[data-copy-path]");if(cr){let _=cr.dataset.copyPath;try{navigator.clipboard.writeText(_).then(()=>(cr.classList.add("copied"),setTimeout(()=>cr.classList.remove("copied"),1e3),null)).catch(()=>{})}catch{}return}let Fn=Y(e,".mark-claude");if(Fn){let _=Mg(e);if(_===null)return;let z=`claude://code/new?q=${encodeURIComponent(`Confirm and fix:
87
+
88
+ ${_}`)}`;try{window.location.href=z,Fn.classList.add("copied"),setTimeout(()=>Fn.classList.remove("copied"),1e3)}catch{}return}if(Y(e,".mark-fix")){let z=Y(e,"[data-gid]").dataset.gid,J=Rr(z);if(!J)return;let G=ze(J),ye=P(G),Se=a.triage.get(ye)?.fix??"";Tg({initial:Se,finding:G}).then(ct=>(ct===null||(L(a.triage,ye,{fix:ct||void 0}),ae(),lr()),null)).catch(()=>{});return}let dr=Y(e,"[data-flag-toggle]");if(dr){let _=dr.dataset.flagToggle,z=a.triage.get(_)?.flagged;L(a.triage,_,{flagged:z!==!0}),ae(),lr();return}let lt=e.target.closest("[data-triage-show]");if(lt&&!lt.closest(".graph2-triage-selector")){let _=lt.dataset.triageShow;a.shownTriage=a.shownTriage===_?null:_,$();return}if(e.target.closest("[data-table-deselect]")){a.tableSelectedGid=null,lr();return}let Bn=e.target.closest("[data-tree-select]");if(Bn){let _=Bn.dataset.treeSelect;a.filesSelectedFile=a.filesSelectedFile===_?null:_,$();return}e.target.closest("[data-tree-deselect]")&&(a.filesSelectedFile=null,$())});var Lg=document.querySelector("#bundle-source-overlay-slot");Lg&&Lg.addEventListener("click",e=>{if(e.target.classList?.contains("bundle-source-overlay")||e.target.closest('[data-action="bundle-source-close"]')){a.bundleSourceFile&&(a.bundleSourceFile=null,a.bundleSourceFindingIdx=null,$());return}if(e.target.closest('[data-action="bundle-source-panel-close"]')){a.bundleSourceFindingIdx!=null&&(a.bundleSourceFindingIdx=null,An());return}let t=e.target.closest("[data-bundle-source-finding]");if(t){let r=parseInt(t.dataset.bundleSourceFinding,10);Number.isFinite(r)&&(a.bundleSourceFindingIdx=a.bundleSourceFindingIdx===r?null:r,An())}});I.addEventListener("row-select",e=>{let t=e.detail?.gid;t&&(a.tableSelectedGid=a.tableSelectedGid===t?null:t,lr())});var Ni="application/x-deepview-kanban-gid";function Fk(e,t){let n=Ue(e).hasConflict?[ze(e)]:e;for(let o of n){let s=P(o),i=ai(o);t==="untriaged"?(L(a.triage,s,{triage:void 0}),ce(a.triage,s,i,!1)):t==="ignored"?(L(a.triage,s,{triage:void 0}),ce(a.triage,s,i,!0)):(L(a.triage,s,{triage:t}),ce(a.triage,s,i,!1))}}function ed(){for(let e of I.querySelectorAll(".kanban-card.dragging"))e.classList.remove("dragging");for(let e of I.querySelectorAll(".kanban-column.drag-over"))e.classList.remove("drag-over")}I.addEventListener("dragstart",e=>{let t=e.target.closest?.(".kanban-card[data-kanban-source]");if(!t||!e.dataTransfer)return;let r=t.dataset.gid;r&&(e.dataTransfer.setData(Ni,r),e.dataTransfer.setData("text/plain",r),e.dataTransfer.effectAllowed="move",t.classList.add("dragging"))});I.addEventListener("dragend",()=>{ed()});I.addEventListener("dragover",e=>{if(!e.dataTransfer?.types.includes(Ni))return;let t=e.target.closest?.(".kanban-column[data-kanban-target]");if(t&&(e.preventDefault(),e.dataTransfer.dropEffect="move",!t.classList.contains("drag-over"))){for(let r of I.querySelectorAll(".kanban-column.drag-over"))r!==t&&r.classList.remove("drag-over");t.classList.add("drag-over")}});I.addEventListener("dragleave",e=>{let t=e.target.closest?.(".kanban-column[data-kanban-target]");t&&(t.contains(e.relatedTarget)||t.classList.remove("drag-over"))});I.addEventListener("drop",e=>{if(!e.dataTransfer?.types.includes(Ni))return;let t=e.target.closest?.(".kanban-column[data-kanban-target]");if(!t){ed();return}e.preventDefault();let r=e.dataTransfer.getData(Ni),n=t.dataset.kanbanTarget;if(ed(),!r||!n)return;let o=Rr(r);!o||(Ue(o).commonTriage??"untriaged")===n||(Fk(o,n),$(),queueMicrotask(ae))});var Zc=!1;function En(e){return e?I.querySelector(`.kanban-card[data-gid="${CSS.escape(e)}"]`):null}function Pi(e){let t=e??I.querySelector(".kanban-card");if(!t)return;let r=t.getBoundingClientRect();r.width<=0||r.height<=0||(document.documentElement.style.setProperty("--kanban-clip-card-w",`${Math.floor(r.width)}px`),document.documentElement.style.setProperty("--kanban-clip-card-h",`${Math.floor(r.height)}px`))}function qo(e){let t=a.kanbanPopoverGid;if(t===e)return;let r=t===null&&e!==null,n=t!==null&&e===null;if(!document.startViewTransition||!r&&!n){a.kanbanPopoverGid=e,$();return}if(Zc)return;Zc=!0;let o=r?"kanban-opening":"kanban-closing";document.documentElement.classList.add(o);let s=u=>{u&&(u.style.viewTransitionName=""),document.documentElement.classList.remove(o),Zc=!1};if(r){let u=En(e);u?(Pi(u),u.style.viewTransitionName="kanban-detail-modal",u.getBoundingClientRect()):Pi(),a.kanbanPopoverGid=e;let p=document.startViewTransition(()=>{$(),u&&(u.style.viewTransitionName="")}),f=setTimeout(()=>s(u),600);(async()=>{try{await p.finished}catch{}clearTimeout(f),s(u)})();return}Pi(),a.kanbanPopoverGid=e;let i=null,l=document.startViewTransition(()=>{$(),i=En(t),i&&(Pi(i),i.style.viewTransitionName="kanban-detail-modal")}),d=setTimeout(()=>s(i??En(t)),600);(async()=>{try{await l.finished}catch{}clearTimeout(d),s(i??En(t))})()}function Bk(e){let t=En(a.kanbanPopoverGid),r=t?.closest(".kanban-column");if(!r)return;let n=[...r.querySelectorAll(".kanban-card[data-kanban-source]")],o=n.indexOf(t);if(o<0)return;let s=Math.min(Math.max(o+e,0),n.length-1);if(s===o)return;let i=n[s].dataset.gid;if(!i)return;qo(i);let l=En(i);l&&(l.focus({preventScroll:!0}),l.scrollIntoView({block:"nearest",behavior:"instant"}))}I.addEventListener("click",e=>{if(e.target.closest?.(".kanban-detail-close")){qo(null);return}let t=e.target.closest?.(".kanban-card[data-kanban-source]");if(t){if(window.getSelection?.()?.toString())return;let r=t.dataset.gid;if(!r)return;qo(a.kanbanPopoverGid===r?null:r);return}e.target.closest?.(".kanban-detail-modal")||a.kanbanPopoverGid&&qo(null)});document.addEventListener("keydown",e=>{e.key==="Escape"&&a.kanbanPopoverGid&&qo(null)});function Pg(e){if(!e||a.focusGid===e)return;a.focusGid=e,$();let t=I.querySelector(".focus-side-card.active");t&&t.scrollIntoView({block:"nearest",behavior:"instant"});let r=I.querySelector(".focus-code-line-active");r&&r.scrollIntoView({block:"center",behavior:"instant"})}function Og(e){let t=I.querySelectorAll(".focus-side-card[data-focus-select]");if(t.length===0)return;let r=-1;for(let s=0;s<t.length;s++)if(t[s].classList.contains("active")){r=s;break}let n=r<0?e>0?0:t.length-1:Math.min(Math.max(r+e,0),t.length-1);if(n===r)return;let o=t[n].dataset.gid;o&&Pg(o)}I.addEventListener("click",e=>{let t=e.target.closest?.("[data-focus-nav]");if(t){Og(t.dataset.focusNav==="next"?1:-1);return}let r=e.target.closest?.(".focus-side-card[data-focus-select]");if(!r||window.getSelection?.()?.toString())return;let n=r.dataset.gid;n&&Pg(n)});function Mk(e){if(document.querySelector("dialog[open]"))return!0;for(let t of e.composedPath()){if(!t||t.nodeType!==1)continue;let r=t.tagName;if(r==="INPUT"||r==="TEXTAREA"||r==="SELECT"||r==="DIALOG"&&t.open||t.isContentEditable)return!0}return!1}document.addEventListener("keydown",e=>{if(a.currentView!=="findings")return;let t=a.viewMode==="focus",r=a.viewMode==="kanban"&&a.kanbanPopoverGid!==null;if(!t&&!r||e.metaKey||e.ctrlKey||e.altKey||e.shiftKey||Mk(e))return;let n=0;if(e.key==="ArrowRight")n=1;else if(e.key==="ArrowLeft")n=-1;else return;e.preventDefault(),t?Og(n):Bk(n)});I.addEventListener("mark-color",e=>{let t=Y(e,"[data-gid]");if(!t)return;let r=t.dataset.gid,n=Rr(r);if(!n)return;let o=P(ze(n)),s=e.detail?.color;if(!s)return;a.triage.get(o)?.color===s?L(a.triage,o,{color:void 0}):L(a.triage,o,{color:s}),ae(),lr()});var Or=null,td=null;function Ng(){if(Or!==null||a.reports.length===0)return;Or=a.viewMode,td=document.title,a.viewMode==="table"&&(a.viewMode="list",$());let e=a.reports.map(r=>r.fileName),t="";e.length===1?t=e[0]:e.length>1&&(t=si(e)),t=t.replace(/\.json$/u,""),t&&(document.title=t)}function Dg(){Or!==null&&(a.viewMode!==Or&&(a.viewMode=Or,$()),document.title=td,Or=null,td=null)}window.addEventListener("beforeprint",Ng);window.addEventListener("afterprint",Dg);document.addEventListener("print-requested",async()=>{if(a.reports.length!==0&&Or===null){Ng();try{await Promise.all([...I.querySelectorAll("finding-card")].map(e=>e.updateComplete)),window.print()}catch(e){throw Dg(),e}}});document.addEventListener("download-requested",()=>{a.reports.length!==0&&Fg(a.reports)});I.addEventListener("analyzer-change",e=>{a.filterAnalyzer=e.detail.analyzer,a.filterModel=e.detail.model,$()});I.addEventListener("repo-change",e=>{a.filterRepo=e.detail.value,$()});I.addEventListener("bundle-search-mode-change",e=>{let t=e.detail?.mode;t!=="files"&&t!=="code"&&t!=="issues"||(a.bundleCodeSearchMode=t,$(),t==="files"&&Po())});I.addEventListener("bundle-search-regex-toggle",()=>{a.bundleSearchRegex=!a.bundleSearchRegex,$()});I.addEventListener("bundle-search-case-toggle",()=>{a.bundleSearchCase=!a.bundleSearchCase,$()});I.addEventListener("bundle-swap",e=>{let t=e.detail?.integrity;!t||!(a.bundles??[]).some(r=>r.integrity===t)||(a.currentView="bundles",a.selectedBundle=t,a.bundleDetails=null,a.bundleSourceFile=null,a.bundleSourceFindingIdx=null,a.bundleCodeSearchQuery="",a.bundleCodeSearchMode="files",a.bundleSearchQuery="",a.bundleSearchRegex=!1,a.bundleSearchCase=!1,a.bundleSearchContext=!0,a.bundleDetailsTab="compare",C.showAll=!0,a.shownTriage=null,sr(t,"compare"),$(),K(),Ot(t))});I.addEventListener("sort-change",e=>{let{kind:t,value:r}=e.detail;if(t==="findings")a.sortBy=r;else if(t==="packages")a.packagesSortBy=r;else if(t==="repositories")a.repositoriesSortBy=r;else return;$()});I.addEventListener("range-change",e=>{e.target.id==="conf-range"&&(a.filterConfMin=e.detail.low,a.filterConfMax=e.detail.high,$())});I.addEventListener("input",e=>{let t=e.composedPath()[0],r=t?.id,n=t?.value;r==="g2-path-filter"&&(C.pathFilter=n,C.graphState?.requestDraw?.())});I.addEventListener("search-input",e=>{if(!e.detail)return;let{kind:t,value:r}=e.detail;if(t==="findings")a.filterInclude=r,r||(a.filterIncludeNegate=!1);else if(t==="files")a.filesSearch=r;else if(t==="packages")a.packagesSearchQuery=r;else if(t==="repositories")a.repositoriesSearchQuery=r;else if(t==="bundle-code")a.bundleCodeSearchQuery=r;else if(t==="bundle-search"){a.bundleSearchQuery=r,Rk();return}else return;$()});I.addEventListener("search-negate-toggle",()=>{a.filterIncludeNegate=!a.filterIncludeNegate,$()});I.addEventListener("severity-toggle",e=>{let t=e.detail.severity;if(e.detail.kind==="graph"){C.selectedSeverities.has(t)?C.selectedSeverities.delete(t):C.selectedSeverities.add(t),e.composedPath()[0].selected=[...C.selectedSeverities],C.graphState?.requestDraw?.(),Oi();return}a.filterSeverities.has(t)?a.filterSeverities.delete(t):a.filterSeverities.add(t),$()});I.addEventListener("color-toggle",e=>{let t=e.detail.color;if(e.detail.kind==="graph"){C.selectedColors.has(t)?C.selectedColors.delete(t):C.selectedColors.add(t),e.composedPath()[0].selected=[...C.selectedColors],C.graphState?.requestDraw?.(),Oi();return}a.filterColors.has(t)?a.filterColors.delete(t):a.filterColors.add(t),$()});I.addEventListener("source-toggle",e=>{let t=e.detail.source,r=a.filterSources.has(t);a.filterSources.clear(),r||a.filterSources.add(t),$()});I.addEventListener("annotation-filter-toggle",e=>{let t=e.detail?.key,r=n=>n===""?"with":n==="with"?"without":"";if(t==="comment")a.filterComment=r(a.filterComment);else if(t==="fix")a.filterFix=r(a.filterFix);else if(t==="flag")a.filterFlagged=r(a.filterFlagged);else return;$()});I.addEventListener("slide-triage-toggle",e=>{let{kind:t,value:r}=e.detail;if(t==="package")a.packageSlideTriage=a.packageSlideTriage===r?null:r;else if(t==="repository")a.repositorySlideTriage=a.repositorySlideTriage===r?null:r;else return;$()});I.addEventListener("view-mode-change",e=>{if(e.detail.kind==="files"){a.filesViewMode=e.detail.mode,$();return}a.viewMode=e.detail.mode;try{localStorage.setItem(Bs,a.viewMode)}catch{}a.viewMode!=="kanban"&&(a.kanbanPopoverGid=null),a.viewMode!=="focus"&&(a.focusGid=null),$()});I.addEventListener("repo-edit-start",()=>{a.repoEditing=!0,$()});I.addEventListener("repo-input",e=>{a.repoUrl=e.detail.url,Ye(a.currentFile,a.repoUrl)});I.addEventListener("repo-commit",e=>{a.repoUrl=e.detail.url,Ye(a.currentFile,a.repoUrl),a.repoEditing=!1,$()});I.addEventListener("repo-cancel",e=>{a.repoUrl=e.detail.url,Ye(a.currentFile,a.repoUrl),a.repoEditing=!1,$()});document.addEventListener("keydown",e=>{if(e.key==="Escape"){if(a.bundleSourceFindingIdx!=null){a.bundleSourceFindingIdx=null,An();return}if(a.bundleSourceFile){if(a.currentView==="bundles"&&a.bundleDetailsTab==="code")return;a.bundleSourceFile=null,$()}}});var zg=`:host{position:absolute;top:.5rem;right:.5rem;z-index:1000;width:30px;height:30px;background:transparent;color:var(--muted);border:0;border-radius:6px;font-size:1rem;line-height:1;font-family:inherit;display:flex;align-items:center;justify-content:center;transition:color .12s,background .12s;cursor:default;user-select:none}:host(:hover){color:var(--text);background:rgb(from var(--text) r g b / .06)}:host(:focus-visible){outline:2px solid var(--accent);outline-offset:2px}@media print{:host{display:none!important}}
89
+ `;var rd="deepview.theme",Tn=Object.freeze(["dark","light","green","pink"]),Pk={dark:{base:"#1a1a1b",dim:"#0a0a0a"},light:{base:"#f6f6fa",dim:"#646464"},green:{base:"#0a140a",dim:"#050a05"},pink:{base:"#ffe4ee",dim:"#a3727f"}},Ok="\u2600",Nk="\u263E",nd="deepview-theme-changed",Di="dark",sd=!1;function Dk(){try{let e=localStorage.getItem(rd);return Tn.includes(e)?e:"dark"}catch{return"dark"}}function Yo(e){Tn.includes(e)||(e="dark"),Di=e;for(let r of Tn)r!=="dark"&&document.body.classList.remove(`theme-${r}`);e!=="dark"&&document.body.classList.add(`theme-${e}`);try{e==="dark"?localStorage.removeItem(rd):localStorage.setItem(rd,e)}catch{}let t=document.querySelector('meta[name="theme-color"]');if(t){let{base:r,dim:n}=Pk[e];t.setAttribute("content",sd?n:r)}window.dispatchEvent(new CustomEvent(nd,{detail:{theme:e}}))}Yo(Dk());window.addEventListener("beforeprint",()=>{sd=!0,Yo(Di)});window.addEventListener("afterprint",()=>{sd=!1,Yo(Di)});function Ug(e){if(!Tn.includes(e))throw new TypeError(`DeepView.setTheme: unknown theme ${JSON.stringify(e)} (expected one of ${Tn.map(t=>JSON.stringify(t)).join(", ")})`);Yo(e)}function Hg(){return Di}var Wg=Tn,od=class extends j{static properties={_light:{state:!0}};static styles=B(zg);constructor(){super(),this._light=document.body.classList.contains("theme-light")}connectedCallback(){super.connectedCallback(),this.hasAttribute("role")||this.setAttribute("role","button"),this.hasAttribute("tabindex")||(this.tabIndex=0),this.hasAttribute("aria-label")||this.setAttribute("aria-label","toggle theme"),this.hasAttribute("title")||this.setAttribute("title","toggle light/dark theme"),this.addEventListener("click",this._toggle),this.addEventListener("keydown",this._onKeydown),window.addEventListener(nd,this._onThemeChanged)}disconnectedCallback(){window.removeEventListener(nd,this._onThemeChanged),this.removeEventListener("click",this._toggle),this.removeEventListener("keydown",this._onKeydown),super.disconnectedCallback()}_onThemeChanged=()=>{this._light=document.body.classList.contains("theme-light")};_toggle=()=>{let t=document.body.classList.contains("theme-light");Yo(t?"dark":"light")};_onKeydown=t=>{(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this._toggle())};render(){return c`${this._light?Nk:Ok}`}};customElements.define("theme-toggle",od);var Vg=`:host{display:block}.row{display:grid;grid-template-columns:5.5rem minmax(0,1fr);gap:.2rem .85rem;padding:.25rem .7rem;font-size:.8rem;border-bottom:1px solid var(--border);transition:background .12s}:host(:last-child) .row{border-bottom:none}:host(:hover) .row{background:rgb(from var(--text) r g b / .04)}:host(.mark-red) .row{background:var(--mark-red-bg)}:host(.mark-blue) .row{background:var(--mark-blue-bg)}:host(.mark-green) .row{background:var(--mark-green-bg)}:host(.mark-gray) .row{background:var(--mark-gray-bg)}:host(.has-conflict) .row{outline:2px dashed var(--accent);outline-offset:-2px}:host(.triage-fixed),:host(.triage-invalid),:host(.triage-deleted),:host(.triage-ignored){opacity:.75}:host(.selected) .row{outline:2px solid var(--accent);outline-offset:-2px}:host(:first-of-type) .row{border-top-left-radius:6px;border-top-right-radius:6px}:host(:last-of-type) .row{border-bottom-left-radius:6px;border-bottom-right-radius:6px}.row-score{grid-column:1;grid-row:1 / 3;align-self:center;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:.2rem;font-variant-numeric:tabular-nums;.badge{min-width:4.4rem;text-align:center}.row-conf{color:var(--muted);font-size:.72rem;user-select:none;& strong{color:var(--text);font-size:.8rem}}}.row-body{display:contents}.title-row{grid-column:2;grid-row:1;min-width:0;display:flex;align-items:baseline;gap:.5rem;.title{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:500;user-select:none}.row-type{color:var(--muted);font-size:.68rem;flex-shrink:0}}.meta-row{grid-column:2;grid-row:2;min-width:0;display:flex;align-items:center;gap:.55rem;.row-loc{color:var(--muted);font-size:.72rem;flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;& a{color:inherit}& a:hover{color:var(--accent)}}.marks{display:flex;gap:.35rem;align-items:center;flex-shrink:0;user-select:none}}.tabs-row{grid-column:2;grid-row:3;min-width:0;.tabs{display:flex;gap:.25rem;flex-wrap:wrap}}.badge,.tabs,.tab,.row-type{cursor:default;user-select:none}.badge{display:inline-block;font-size:.7rem;font-weight:600;text-transform:uppercase;padding:.15rem .45rem;border-radius:3px;letter-spacing:.03em;line-height:1;&.critical{background:var(--critical);color:#fff}&.high{background:var(--high);color:#fff}&.medium{background:var(--medium);color:#000}&.low{background:var(--low);color:var(--badge-low-text)}&.high_bug{background:var(--high-bug);color:#fff}&.bug{background:var(--bug);color:#fff}&.informational{background:var(--info);color:#fff}}.tab{background:transparent;color:var(--text);border:1px solid var(--border);border-radius:4px;padding:.2rem .5rem;font-size:.75rem;line-height:1.3;display:inline-flex;align-items:center;gap:.35rem;font-family:inherit;&:hover{border-color:var(--accent)}&.active{border-color:var(--accent);background:var(--surface-active)}&.tab-mark-red{background:var(--mark-red-bg);border-color:var(--mark-red-tab-border)}&.tab-mark-blue{background:var(--mark-blue-bg);border-color:var(--mark-blue-tab-border)}&.tab-mark-green{background:var(--mark-green-bg);border-color:var(--mark-green-tab-border)}&.tab-mark-gray{background:var(--mark-gray-bg);border-color:var(--mark-gray-tab-border)}&.tab-mark-red.active,&.tab-mark-blue.active,&.tab-mark-green.active,&.tab-mark-gray.active{border-color:var(--text)}&.tab-deleted .tab-label{text-decoration:line-through;opacity:.6}&.tab-inprogress .tab-label:after{content:" \\25d0";opacity:.6}&.tab-fixed .tab-label{opacity:.65}&.tab-fixed .tab-label:after{content:" \\2713";opacity:.6}&.tab-invalid .tab-label{opacity:.65}&.tab-invalid .tab-label:after{content:" \\2298";opacity:.6}&.tab-ignored .tab-label{opacity:.55}&.tab-ignored .tab-label:after{content:" \\1f441";opacity:.6;font-size:.7em}.tab-conf{color:var(--muted);font-size:.7rem}&.tab-mark-red .tab-conf,&.tab-mark-blue .tab-conf,&.tab-mark-green .tab-conf,&.tab-mark-gray .tab-conf{color:var(--text)}.tab-marks{display:inline-flex;align-items:center;gap:.15rem;margin-left:.25rem;vertical-align:middle;color:var(--accent)}.tab-marks svg{display:block}.tab-marks .has-comment .bubble,.tab-marks .has-fix .wrench,.tab-marks .flagged .flag-cloth{fill:var(--accent);fill-opacity:.15}}.report-chip{display:inline-flex;align-items:center;gap:.3rem;padding:0 .35rem;height:1.4rem;border:1px solid var(--border);border-radius:3px;color:var(--muted);font-size:.72rem;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;margin-right:.65rem;max-width:12rem;min-width:0;.report-chip-label{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}.file-icon{flex-shrink:0}.brand-deepview{.bg{fill:#2563eb}.fg{fill:#fff}}.brand-claude{.bg{fill:#d97757}.fg{fill:#fff}}.brand-codex{.bg{fill:#fff;stroke:#000;stroke-width:.5}.fg{fill:#000}}.brand-vercel{.bg{fill:#000;stroke:#fff;stroke-width:.5}.fg{fill:#fff}}}.mark-action-group{display:inline-flex;border:1px solid var(--border);border-radius:3px;overflow:hidden;margin-right:.25rem;flex-shrink:0}.mark-comment,.mark-fix,.mark-flag,.mark-copy,.mark-issue,.mark-claude{background:transparent;border:0;color:var(--muted);padding:0 .25rem;height:1.4rem;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;&:not(:last-child){border-right:1px solid var(--border)}&:hover{color:var(--accent);background:var(--surface-active)}}.mark-issue{text-decoration:none}.mark-comment.has-comment,.mark-fix.has-fix,.mark-flag.flagged{color:var(--accent)}.mark-flag svg{display:block}.mark-copy.copied,.mark-claude.copied{color:var(--green, #4ade80);background:color-mix(in srgb,var(--green, #4ade80) 14%,transparent)}.mark-comment.has-comment .bubble,.mark-fix.has-fix .wrench,.mark-flag.flagged .flag-cloth{fill:var(--accent);fill-opacity:.15}.mark-x{background:transparent;border:1px solid var(--border);color:var(--muted);border-radius:3px;padding:0 .35rem;font-size:.85rem;line-height:1.1;margin-left:.25rem;&:hover{color:var(--critical);border-color:var(--critical)}}.triage-menu-wrap{position:relative;display:inline-flex;margin-left:.25rem;flex-shrink:0}.mark-triage-menu{background:transparent;border:1px solid var(--border);color:var(--muted);border-radius:3px;padding:0 .3rem;height:1.5rem;display:inline-flex;align-items:center;justify-content:center;gap:.25rem;font:inherit}.mark-triage-menu:hover{color:var(--text);border-color:var(--accent)}.mark-triage-menu.open{border-color:var(--accent);color:var(--text)}.mark-triage-menu.with-label{padding:0 .35rem 0 .5rem;font-size:.72rem;height:1.5rem}.mark-triage-menu .mark-triage-label{text-transform:uppercase;letter-spacing:.05em;font-weight:600}.mark-triage-menu.triage-state-deleted{border-color:var(--critical);color:var(--critical)}.mark-triage-menu.triage-state-fixed{border-color:var(--green, #4ade80);color:var(--green, #4ade80)}.mark-triage-menu.triage-state-inprogress{border-color:var(--warning, #d97706);color:var(--warning, #d97706)}.mark-triage-menu.triage-state-invalid{border-color:var(--muted);color:var(--text)}.mark-triage-menu.triage-state-ignored{border-color:var(--accent, #2563eb);color:var(--accent, #2563eb)}.triage-menu[popover]{position:fixed;inset:auto;margin:0;min-width:7rem;background:var(--bg);border:1px solid var(--border);border-radius:4px;padding:.25rem;box-shadow:0 4px 12px #00000040;display:flex;flex-direction:column;gap:1px;-webkit-app-region:no-drag;app-region:no-drag}.triage-menu[popover]:not(:popover-open){display:none}.triage-menu[popover]:popover-open{display:flex}.triage-menu-item{background:transparent;border:0;padding:.35rem .5rem;font-size:.78rem;color:var(--text);text-align:left;border-radius:3px;font-family:inherit}.triage-menu-item:hover{background:var(--surface)}.triage-menu-item.active:before{content:"\\2713 ";color:var(--accent)}.triage-menu-inprogress:hover{color:var(--warning, #d97706)}.triage-menu-fixed:hover{color:var(--green, #4ade80)}.triage-menu-invalid:hover{color:var(--muted)}.triage-menu-deleted:hover{color:var(--critical)}.mark-restore{background:transparent;border:1px solid var(--border);color:var(--muted);border-radius:3px;padding:0 .45rem;font-size:.75rem;line-height:1.3;margin-left:.25rem;&:hover{color:var(--green);border-color:var(--green)}}.line-num{color:var(--muted);font-size:.75rem}.line-num a{color:inherit}.line-num a:hover{color:var(--accent)}@media print{:host(:hover) .row,:host(.mark-red) .row,:host(.mark-blue) .row,:host(.mark-green) .row,:host(.mark-gray) .row{background:transparent!important}:host(.triage-fixed),:host(.triage-invalid),:host(.triage-deleted),:host(.triage-ignored){opacity:1}:host(.selected) .row,:host(.has-conflict) .row{outline:none!important}.row{break-inside:avoid}.marks,.mark-x,.mark-restore{display:none!important}.badge{-webkit-print-color-adjust:exact;print-color-adjust:exact;&.critical{background:#a30b0f!important;color:#fff!important}&.high{background:#b8400a!important;color:#fff!important}&.medium{background:#855107!important;color:#fff!important}&.low{background:#374151!important;color:#fff!important}&.high_bug{background:#7a3e0c!important;color:#fff!important}&.bug{background:#4d4538!important;color:#fff!important}&.informational{background:#0550ae!important;color:#fff!important}}a,.line-num,.line-num a{color:inherit}}
90
+ `;var Uk=["is-critical","mark-red","mark-blue","mark-green","mark-gray","has-conflict","triage-inprogress","triage-fixed","triage-invalid","triage-deleted","triage-ignored","selected"],id=class extends O{static properties={group:{attribute:!1},selected:{type:Boolean}};static styles=B(Vg);constructor(){super(),this.group=null,this.selected=!1}render(){if(!this.group)return c``;this.dataset.gid=Ao(this.group);let t=new Set(Ff(this.group));this.selected&&t.add("selected");for(let r of Uk)this.classList.toggle(r,t.has(r));return c`<div class="row">${Bf(this.group)}</div>`}connectedCallback(){super.connectedCallback(),this.addEventListener("click",this._onClick),this.hasUpdated&&this.requestUpdate()}disconnectedCallback(){this.removeEventListener("click",this._onClick),super.disconnectedCallback()}_onClick=t=>{t.composedPath().some(n=>n?.matches?.("a, button, label"))||this.dataset.gid&&this.dispatchEvent(new CustomEvent("row-select",{detail:{gid:this.dataset.gid},bubbles:!0,composed:!0}))}};customElements.define("finding-row",id);var jg=`:host{display:block;background:var(--surface);backdrop-filter:var(--glass-blur);border:1px solid var(--border);border-radius:6px;overflow:hidden;box-shadow:var(--shadow-glass);margin-bottom:1rem;max-width:1200px}@media not print{finding-row{content-visibility:auto;contain-intrinsic-size:auto 3.2rem}}
91
+ `;var ad=class extends j{static properties={items:{attribute:!1},selectedGid:{attribute:!1}};static styles=B(jg);constructor(){super(),this.items=[],this.selectedGid=null}render(){return c`${X(this.items??[],t=>Ao(t),t=>c`<finding-row .group="${t}" ?selected="${Ao(t)===this.selectedGid}"></finding-row>`)}`}};customElements.define("finding-table",ad);var Kg=`:host{display:block}:host(.hidden){display:none}:host(.triage-fixed),:host(.triage-invalid),:host(.triage-deleted),:host(.triage-ignored){opacity:.75}.card{padding:.5rem .75rem;border-bottom:1px solid var(--border);font-size:.875rem}:host(:last-child) .card{border-bottom:none}:host(.mark-red) .card{background:var(--mark-red-bg)}:host(.mark-blue) .card{background:var(--mark-blue-bg)}:host(.mark-green) .card{background:var(--mark-green-bg)}:host(.mark-gray) .card{background:var(--mark-gray-bg)}:host(.has-conflict) .card{outline:2px dashed var(--accent);outline-offset:-2px}:host([in-group]) .line-row{display:none}.tabs{display:flex;gap:.25rem;flex-wrap:wrap}.marks-left{display:flex;align-items:center;gap:.5rem;margin-right:auto;flex-wrap:wrap}.commit-ref{color:var(--muted);font-size:.8rem;& a{color:var(--accent);font-family:ui-monospace,SFMono-Regular,Menlo,monospace}& a:hover{text-decoration:underline}& span{font-family:ui-monospace,SFMono-Regular,Menlo,monospace}}.marks-commit-row{margin-top:.4rem;padding-left:4.75rem}.tab-body{display:none;grid-template-columns:auto 1fr;gap:.25rem .75rem;&.active{display:grid}}.desc-title{grid-column:2;font-size:1.08em;font-weight:600;letter-spacing:-.005em;line-height:1.35;color:var(--text)}.desc{grid-column:2;white-space:pre-line;font-size:.96em;line-height:1.6;color:rgb(from var(--text) r g b / .82);margin-top:.4rem}.recommendation{grid-column:2;white-space:pre-line;font-size:.92em;line-height:1.55;color:var(--green);margin-top:.4rem}.conf-reason{grid-column:2;white-space:pre-line;font-size:.92em;font-style:italic;color:var(--muted);margin-top:.6rem;padding-top:.55rem;border-top:1px dashed var(--border)}.inline-quote{background:rgb(from var(--accent) r g b / .1);padding:1px;border-radius:3px;color:var(--text)}.inline-code{background:var(--surface-active);border-radius:3px;border:1px solid var(--border);font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:.9em;color:var(--text)}.line-row{display:flex;justify-content:space-between;align-items:baseline;gap:.5rem;flex-wrap:wrap}.run-meta{color:var(--muted);font-size:.65rem}.finding-code-btn{display:inline-block;margin-top:.35rem;padding:.1rem .45rem;background:transparent;border:1px solid var(--border);border-radius:999px;color:var(--muted);font:inherit;font-size:.65rem;font-weight:500;white-space:nowrap}.finding-code-btn:hover{border-color:var(--accent);color:var(--accent)}.marks{display:flex;gap:.35rem;justify-content:flex-end;margin-top:.4rem;align-items:center;padding-left:4.75rem;user-select:none}.finding-left{align-self:start;text-align:center;min-width:4rem;.value-label:last-child{margin-bottom:0}}.conf-score{font-size:.75rem;color:var(--muted);margin-top:.3rem;& strong{color:var(--text);font-size:.85rem}}.conf-ring{--col: var(--muted);position:relative;width:3rem;height:3rem;margin:.7rem auto .15rem;display:flex;align-items:center;justify-content:center;& svg{position:absolute;inset:0;width:100%;height:100%;transform:rotate(-90deg)}& circle{fill:none;stroke-width:4}.conf-ring-track{stroke:var(--border)}.conf-ring-arc{stroke:var(--col);stroke-linecap:round}& span{position:relative;z-index:1;font-size:.8rem;font-weight:700;color:var(--text);font-variant-numeric:tabular-nums}& small{font-size:.55rem;color:var(--muted);font-weight:500}&.critical{--col: var(--critical)}&.high{--col: var(--high)}&.medium{--col: var(--medium)}&.low{--col: var(--low)}&.high_bug{--col: var(--high-bug)}&.bug{--col: var(--bug)}&.informational{--col: var(--info)}}.value-label{display:block;font-size:.45rem;color:var(--muted);text-transform:uppercase;letter-spacing:.04em;margin-top:.1rem;margin-bottom:.3rem;font-weight:500}.print-case-label{display:none}.badge,.tabs,.tab,.value-label,.run-meta,.conf-ring{cursor:default;user-select:none}.badge{display:inline-block;font-size:.7rem;font-weight:600;text-transform:uppercase;padding:.15rem .45rem;border-radius:3px;letter-spacing:.03em;line-height:1;&.critical{background:var(--critical);color:#fff}&.high{background:var(--high);color:#fff}&.medium{background:var(--medium);color:#000}&.low{background:var(--low);color:var(--badge-low-text)}&.high_bug{background:var(--high-bug);color:#fff}&.bug{background:var(--bug);color:#fff}&.informational{background:var(--info);color:#fff}}.tab{background:transparent;color:var(--text);border:1px solid var(--border);border-radius:4px;padding:.2rem .5rem;font-size:.75rem;line-height:1.3;display:inline-flex;align-items:center;gap:.35rem;font-family:inherit;&:hover{border-color:var(--accent)}&.active{border-color:var(--accent);background:var(--surface-active)}&.tab-mark-red{background:var(--mark-red-bg);border-color:var(--mark-red-tab-border)}&.tab-mark-blue{background:var(--mark-blue-bg);border-color:var(--mark-blue-tab-border)}&.tab-mark-green{background:var(--mark-green-bg);border-color:var(--mark-green-tab-border)}&.tab-mark-gray{background:var(--mark-gray-bg);border-color:var(--mark-gray-tab-border)}&.tab-mark-red.active,&.tab-mark-blue.active,&.tab-mark-green.active,&.tab-mark-gray.active{border-color:var(--text)}&.tab-deleted .tab-label{text-decoration:line-through;opacity:.6}&.tab-inprogress .tab-label:after{content:" \\25d0";opacity:.6}&.tab-fixed .tab-label{opacity:.65}&.tab-fixed .tab-label:after{content:" \\2713";opacity:.6}&.tab-invalid .tab-label{opacity:.65}&.tab-invalid .tab-label:after{content:" \\2298";opacity:.6}&.tab-ignored .tab-label{opacity:.55}&.tab-ignored .tab-label:after{content:" \\1f441";opacity:.6;font-size:.7em}.tab-conf{color:var(--muted);font-size:.7rem}&.tab-mark-red .tab-conf,&.tab-mark-blue .tab-conf,&.tab-mark-green .tab-conf,&.tab-mark-gray .tab-conf{color:var(--text)}.tab-marks{display:inline-flex;align-items:center;gap:.15rem;margin-left:.25rem;vertical-align:middle;color:var(--accent)}.tab-marks svg{display:block}.tab-marks .has-comment .bubble,.tab-marks .has-fix .wrench,.tab-marks .flagged .flag-cloth{fill:var(--accent);fill-opacity:.15}}.report-chip{display:inline-flex;align-items:center;gap:.3rem;padding:0 .35rem;height:1.4rem;border:1px solid var(--border);border-radius:3px;color:var(--muted);font-size:.72rem;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;margin-right:.65rem;max-width:16rem;min-width:0;.report-chip-label{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}.file-icon{flex-shrink:0}.brand-deepview{.bg{fill:#2563eb}.fg{fill:#fff}}.brand-claude{.bg{fill:#d97757}.fg{fill:#fff}}.brand-codex{.bg{fill:#fff;stroke:#000;stroke-width:.5}.fg{fill:#000}}.brand-vercel{.bg{fill:#000;stroke:#fff;stroke-width:.5}.fg{fill:#fff}}}.mark-action-group{display:inline-flex;border:1px solid var(--border);border-radius:3px;overflow:hidden;margin-right:.25rem;flex-shrink:0}.mark-comment,.mark-fix,.mark-flag,.mark-copy,.mark-issue,.mark-claude{background:transparent;border:0;color:var(--muted);padding:0 .25rem;height:1.4rem;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;&:not(:last-child){border-right:1px solid var(--border)}&:hover{color:var(--accent);background:var(--surface-active)}}.mark-issue{text-decoration:none}.mark-comment.has-comment,.mark-fix.has-fix,.mark-flag.flagged{color:var(--accent)}.mark-flag svg{display:block}.mark-copy.copied,.mark-claude.copied{color:var(--green, #4ade80);background:color-mix(in srgb,var(--green, #4ade80) 14%,transparent)}.mark-comment.has-comment .bubble,.mark-fix.has-fix .wrench,.mark-flag.flagged .flag-cloth{fill:var(--accent);fill-opacity:.15}.mark-x{background:transparent;border:1px solid var(--border);color:var(--muted);border-radius:3px;padding:0 .35rem;font-size:.85rem;line-height:1.1;margin-left:.25rem;&:hover{color:var(--critical);border-color:var(--critical)}}.triage-menu-wrap{position:relative;display:inline-flex;margin-left:.25rem;flex-shrink:0}.mark-triage-menu{background:transparent;border:1px solid var(--border);color:var(--muted);border-radius:3px;padding:0 .3rem;height:1.5rem;display:inline-flex;align-items:center;justify-content:center;gap:.25rem;font:inherit}.mark-triage-menu:hover{color:var(--text);border-color:var(--accent)}.mark-triage-menu.open{border-color:var(--accent);color:var(--text)}.mark-triage-menu.with-label{padding:0 .35rem 0 .5rem;font-size:.72rem;height:1.5rem}.mark-triage-menu .mark-triage-label{text-transform:uppercase;letter-spacing:.05em;font-weight:600}.mark-triage-menu.triage-state-deleted{border-color:var(--critical);color:var(--critical)}.mark-triage-menu.triage-state-fixed{border-color:var(--green, #4ade80);color:var(--green, #4ade80)}.mark-triage-menu.triage-state-inprogress{border-color:var(--warning, #d97706);color:var(--warning, #d97706)}.mark-triage-menu.triage-state-invalid{border-color:var(--muted);color:var(--text)}.mark-triage-menu.triage-state-ignored{border-color:var(--accent, #2563eb);color:var(--accent, #2563eb)}.triage-menu[popover]{position:fixed;inset:auto;margin:0;min-width:7rem;background:var(--bg);border:1px solid var(--border);border-radius:4px;padding:.25rem;box-shadow:0 4px 12px #00000040;display:flex;flex-direction:column;gap:1px;-webkit-app-region:no-drag;app-region:no-drag}.triage-menu[popover]:not(:popover-open){display:none}.triage-menu[popover]:popover-open{display:flex}.triage-menu-item{background:transparent;border:0;padding:.35rem .5rem;font-size:.78rem;color:var(--text);text-align:left;border-radius:3px;font-family:inherit}.triage-menu-item:hover{background:var(--surface)}.triage-menu-item.active:before{content:"\\2713 ";color:var(--accent)}.triage-menu-inprogress:hover{color:var(--warning, #d97706)}.triage-menu-fixed:hover{color:var(--green, #4ade80)}.triage-menu-invalid:hover{color:var(--muted)}.triage-menu-deleted:hover{color:var(--critical)}:host([context="focus"]) .triage-menu-wrap>.mark-triage-menu{display:none}:host([context="focus"]) .triage-menu-wrap{display:inline-flex}:host([context="focus"]) .triage-menu[popover]{position:static;inset:auto;display:inline-flex!important;flex-flow:row wrap;margin:0;padding:0;background:transparent;border:0;border-radius:0;box-shadow:none;min-width:0;gap:.25rem}:host([context="focus"]) .triage-menu-item{background:transparent;border:1px solid var(--border);padding:.2rem .5rem;border-radius:3px;font-size:.72rem;font-weight:500;text-transform:uppercase;letter-spacing:.04em}:host([context="focus"]) .triage-menu-item.active{background:rgb(from var(--accent) r g b / .12);border-color:var(--accent);color:var(--accent)}:host([context="focus"]) .triage-menu-item:hover{background:var(--surface-active)}:host([context="focus"]) .triage-menu-inprogress.active{background:rgb(from var(--warning, #d97706) r g b / .12);border-color:var(--warning, #d97706);color:var(--warning, #d97706)}:host([context="focus"]) .triage-menu-fixed.active{background:rgb(from var(--green, #4ade80) r g b / .12);border-color:var(--green, #4ade80);color:var(--green, #4ade80)}:host([context="focus"]) .triage-menu-deleted.active{background:rgb(from var(--critical) r g b / .12);border-color:var(--critical);color:var(--critical)}:host([context="focus"]) .triage-menu-item.active:before{content:"";margin:0}:host([context="focus"]) .marks{gap:.5rem;margin-top:.65rem;padding-left:0;padding-top:.55rem;border-top:1px solid var(--border);flex-wrap:wrap}:host([context="focus"]) .marks-commit-row{padding-left:0}:host([context="focus"]) .mark-comment,:host([context="focus"]) .mark-fix,:host([context="focus"]) .mark-flag,:host([context="focus"]) .mark-copy,:host([context="focus"]) .mark-issue,:host([context="focus"]) .mark-claude{height:1.75rem;padding:0 .55rem;gap:.35rem;display:inline-flex;align-items:center;font-size:.72rem}:host([context="focus"]) .mark-btn-label{color:inherit;font-weight:500;letter-spacing:.02em}:host([context="focus"].mark-red) .card{background:color-mix(in srgb,var(--mark-red-bg) 15%,var(--bg))}:host([context="focus"].mark-blue) .card{background:color-mix(in srgb,var(--mark-blue-bg) 15%,var(--bg))}:host([context="focus"].mark-green) .card{background:color-mix(in srgb,var(--mark-green-bg) 15%,var(--bg))}:host([context="focus"].mark-gray) .card{background:color-mix(in srgb,var(--mark-gray-bg) 15%,var(--bg))}.comment-block,.fix-block{margin-top:.5rem;padding:.35rem .55rem;border-left:3px solid var(--accent);background:rgb(from var(--accent) r g b / .08);border-radius:0 4px 4px 0;font-size:.82rem;color:var(--text)}.comment-block{white-space:pre-wrap;& a{color:var(--accent);text-decoration:none}& a:hover{text-decoration:underline}}.fix-block{word-break:break-all;& a{color:var(--accent);text-decoration:none}& a:hover{text-decoration:underline}}.comment-label,.fix-label{color:var(--muted);font-weight:600;margin-right:.35rem}.mark-restore{background:transparent;border:1px solid var(--border);color:var(--muted);border-radius:3px;padding:0 .45rem;font-size:.75rem;line-height:1.3;margin-left:.25rem;&:hover{color:var(--green);border-color:var(--green)}}.line-num{color:var(--muted);font-size:.8rem}.line-num a{color:inherit}.line-num a:hover{color:var(--accent)}.npm-link{display:inline-block;padding:0 .4rem;border:1px solid var(--border);border-radius:3px;font-size:.72rem;font-weight:500;color:var(--muted);text-decoration:none}.npm-link:hover{border-color:var(--accent);color:var(--accent)}@media print{.card{break-inside:avoid;padding:.45rem .25rem}.finding-code-btn,.mark-copy,.mark-issue,.mark-claude{display:none!important}.npm-link{border:0;padding:0}:host(.triage-fixed),:host(.triage-invalid),:host(.triage-deleted),:host(.triage-ignored){opacity:1}:host(.multi-case) .card:before{content:"Multiple reports of one finding";display:block;font-size:.7rem;font-weight:700;color:#555;text-transform:uppercase;letter-spacing:.06em;border-bottom:1px solid #bbb;padding-bottom:.2rem;margin-bottom:.35rem;-webkit-print-color-adjust:exact;print-color-adjust:exact}.marks,.tabs{display:none!important}.tab-body{display:grid!important}.tab-body+.tab-body{margin-top:.5rem;padding-top:.5rem;border-top:1px dashed #999}:host([in-group].multi-case) .tab-body .line-row{display:flex}.line-row .discovered-in{flex-basis:100%;order:99}.print-case-label{display:block;grid-column:1 / -1;font-size:.65rem;font-weight:600;color:#555;background:#eee;padding:.1rem .35rem;border-radius:3px;margin-bottom:.25rem;letter-spacing:.04em;-webkit-print-color-adjust:exact;print-color-adjust:exact}.value-label{color:#777}.badge{-webkit-print-color-adjust:exact;print-color-adjust:exact;&.critical{background:#a30b0f!important;color:#fff!important}&.high{background:#b8400a!important;color:#fff!important}&.medium{background:#855107!important;color:#fff!important}&.low{background:#374151!important;color:#fff!important}&.high_bug{background:#7a3e0c!important;color:#fff!important}&.bug{background:#4d4538!important;color:#fff!important}&.informational{background:#0550ae!important;color:#fff!important}}a,.line-num,.line-num a{color:inherit}.inline-code{border:0;background:transparent;padding:0}}
92
+ `;var Vk=["finding","is-critical","mark-red","mark-blue","mark-green","mark-gray","has-conflict","triage-inprogress","triage-fixed","triage-invalid","triage-deleted","triage-ignored","multi-case"],ld=class extends O{static properties={group:{attribute:!1},inGroup:{type:Boolean,attribute:"in-group",reflect:!0},context:{type:String,reflect:!0}};static styles=B(Kg);constructor(){super(),this.group=null,this.inGroup=!1,this.context=null}render(){if(!this.group)return c``;this.dataset.gid=mn(this.group);let t=new Set(If(this.group));for(let r of Vk)this.classList.toggle(r,t.has(r));return c`<div class="card">${Rf(this.group,{context:this.context})}</div>`}connectedCallback(){super.connectedCallback(),this.hasUpdated&&this.requestUpdate()}};customElements.define("finding-card",ld);var Gg=`:host{display:inline-flex;gap:4px;align-items:center;flex-shrink:0}button{width:14px;height:14px;user-select:none;padding:0;background:transparent;border:1.5px solid currentcolor;border-radius:50%;opacity:.55;transition:opacity .12s,transform .12s}button:hover{opacity:1;transform:scale(1.12)}button.active{background:currentcolor;opacity:1;box-shadow:0 0 0 2px var(--surface),0 0 0 3px currentcolor}.color-red{color:var(--marker-red)}.color-blue{color:var(--marker-blue)}.color-green{color:var(--marker-green)}.color-gray{color:var(--marker-gray)}
93
+ `;var Kk=["red","blue","green","gray"],cd=class extends j{static properties={selected:{type:String}};static styles=B(Gg);constructor(){super(),this.selected=null}render(){return c`${Kk.map(t=>c`<button type="button" class="${`color-${t}${this.selected===t?" active":""}`}" data-color="${t}" title="${`mark ${t}`}" @click="${this._onClick}"></button>`)}`}_onClick=t=>{let r=t.currentTarget.dataset.color;this.dispatchEvent(new CustomEvent("mark-color",{detail:{color:r},bubbles:!0,composed:!0}))}};customElements.define("color-marker",cd);var dd=class extends O{createRenderRoot(){return this}render(){let t=a.filterConfMin,r=a.filterConfMax;return c`<span class="conf-range-label">Confidence</span><range-slider id="conf-range" min="0" max="10" step="1" low="${t}" high="${r}" aria-label="Confidence range"></range-slider><conf-range-mirror id="conf-range-vals" class="conf-vals" for="conf-range" .low="${t}" .high="${r}"></conf-range-mirror>`}};customElements.define("conf-filter",dd);var xe=bt(class extends et{constructor(e){if(super(e),e.type!==Oe.PROPERTY&&e.type!==Oe.ATTRIBUTE&&e.type!==Oe.BOOLEAN_ATTRIBUTE)throw Error("The `live` directive is not allowed on child or event bindings");if(!cu(e))throw Error("`live` bindings can only contain a single expression")}render(e){return e}update(e,[t]){if(t===ue||t===g)return t;let r=e.element,n=e.name;if(e.type===Oe.PROPERTY){if(t===r[n])return ue}else if(e.type===Oe.BOOLEAN_ATTRIBUTE){if(!!t===r.hasAttribute(n))return ue}else if(e.type===Oe.ATTRIBUTE&&r.getAttribute(n)===t+"")return ue;return ds(e),t}});var qg={files:"Filter files\u2026",code:"Search code\u2026",issues:"Search issues\u2026"},Yg={files:"Filter files",code:"Search code",issues:"Search issues"},Gk=c`<svg class="bundle-code-search-icon" viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.5" aria-hidden="true"><circle cx="6.5" cy="6.5" r="4.5"/><path d="M9.7 9.7L13 13" stroke-linecap="round"/></svg>`,qk={files:c`<svg viewBox="0 0 16 16" width="13" height="13" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M2 4.5a1 1 0 0 1 1-1h3.2l1.3 1.5H13a1 1 0 0 1 1 1V12a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V4.5Z"/></svg>`,code:c`<svg viewBox="0 0 16 16" width="13" height="13" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5.5 4.5L2 8l3.5 3.5"/><path d="M10.5 4.5L14 8l-3.5 3.5"/></svg>`,issues:c`<svg viewBox="0 0 16 16" width="13" height="13" fill="none" stroke="currentColor" stroke-width="1.3" aria-hidden="true"><circle cx="8" cy="8" r="6"/><path d="M8 4.8v3.6" stroke-linecap="round"/><circle cx="8" cy="11" r=".7" fill="currentColor" stroke="none"/></svg>`},ud=class extends O{static properties={modes:{attribute:!1}};createRenderRoot(){return this}constructor(){super(),this.modes=[]}render(){let t=a.bundleCodeSearchQuery,r=a.bundleCodeSearchMode,n=this.modes.includes(r)?r:"files",o=qg[n]??qg.files;return c`${Gk} <input type="text" class="bundle-code-search-input" placeholder="${o}" aria-label="${o}" .value="${xe(t)}" @input="${this._onInput}"> ${t?c`<button type="button" class="bundle-code-search-clear" title="Clear search" aria-label="Clear search" @click="${this._onClear}">×</button>`:g} ${this.modes.length>0?c`<span class="bundle-code-search-modes" role="tablist">${this.modes.map(s=>c`<button type="button" class="${R({"bundle-code-search-mode":!0,active:n===s})}" role="tab" aria-selected="${String(n===s)}" title="${Yg[s]??s}" aria-label="${Yg[s]??s}" @click="${()=>this._selectMode(s)}">${qk[s]??g}</button>`)}</span>`:g}`}_onInput=t=>{this._dispatchInput(t.target.value)};_onClear=()=>{this._dispatchInput("")};_dispatchInput(t){this.dispatchEvent(new CustomEvent("search-input",{detail:{kind:"bundle-code",value:t},bubbles:!0,composed:!0}))}_selectMode(t){this.dispatchEvent(new CustomEvent("bundle-search-mode-change",{detail:{mode:t},bubbles:!0,composed:!0}))}};customElements.define("bundle-code-search",ud);var Yk=c`<svg class="bundle-search-icon" viewBox="0 0 16 16" width="15" height="15" fill="none" stroke="currentColor" stroke-width="1.5" aria-hidden="true"><circle cx="6.5" cy="6.5" r="4.5"/><path d="M9.7 9.7L13 13" stroke-linecap="round"/></svg>`,pd=class extends O{createRenderRoot(){return this}render(){let t=a.bundleSearchQuery,r=a.bundleSearchRegex,n=a.bundleSearchCase,o=r?"Search by regular expression\u2026":"Search all source\u2026";return c`${Yk} <input type="text" class="bundle-search-input" placeholder="${o}" aria-label="${o}" spellcheck="false" autocapitalize="off" autocomplete="off" .value="${xe(t)}" @input="${this._onInput}"> ${t?c`<button type="button" class="bundle-search-clear" title="Clear search" aria-label="Clear search" @click="${this._onClear}">×</button>`:g} <span class="bundle-search-mods"><button type="button" class="${R({"bundle-search-mod":!0,active:n})}" title="${n?"Case-sensitive on \u2014 click to ignore case":"Match case"}" aria-label="Match case" aria-pressed="${String(n)}" @click="${this._onToggleCase}">Aa</button> <button type="button" class="${R({"bundle-search-mod":!0,active:r})}" title="${r?"Regular expression on \u2014 click for plain text":"Match by regular expression"}" aria-label="Match by regular expression" aria-pressed="${String(r)}" @click="${this._onToggleRegex}">.*</button></span>`}_onInput=t=>{this._dispatchInput(t.target.value)};_onClear=()=>{this._dispatchInput("")};_dispatchInput(t){this.dispatchEvent(new CustomEvent("search-input",{detail:{kind:"bundle-search",value:t},bubbles:!0,composed:!0}))}_onToggleRegex=()=>{this.dispatchEvent(new CustomEvent("bundle-search-regex-toggle",{bubbles:!0,composed:!0}))};_onToggleCase=()=>{this.dispatchEvent(new CustomEvent("bundle-search-case-toggle",{bubbles:!0,composed:!0}))}};customElements.define("bundle-search",pd);var Jg={packages:{stateKey:"packagesSearchQuery",label:"Filter packages"},repositories:{stateKey:"repositoriesSearchQuery",label:"Filter repositories"}},fd=class extends O{static properties={kind:{type:String}};createRenderRoot(){return this}constructor(){super(),this.kind=""}render(){let t=Jg[this.kind];return t?c`<input type="search" class="packages-search" placeholder="${`${t.label}\u2026`}" aria-label="${t.label}" .value="${xe(a[t.stateKey])}" @input="${this._onInput}">`:(console.warn(`<entity-search>: unknown kind ${JSON.stringify(this.kind)}; expected one of ${Object.keys(Jg).map(r=>JSON.stringify(r)).join(", ")}.`),g)}_onInput=t=>{this.dispatchEvent(new CustomEvent("search-input",{detail:{kind:this.kind,value:t.target.value},bubbles:!0,composed:!0}))}};customElements.define("entity-search",fd);var Jk=[["findings-desc","Findings \u2193"],["files-desc","Files \u2193"],["reports-desc","Reports \u2193"],["name-asc","Name A\u2192Z"]],Xg={packages:{stateKey:"packagesSortBy",aria:"Sort packages"},repositories:{stateKey:"repositoriesSortBy",aria:"Sort repositories"}},hd=class extends O{static properties={kind:{type:String}};createRenderRoot(){return this}constructor(){super(),this.kind=""}render(){let t=Xg[this.kind];return t?c`<select class="packages-sort" aria-label="${t.aria}" .value="${xe(a[t.stateKey])}" @change="${this._onChange}">${Jk.map(([r,n])=>c`<option value="${r}">${n}</option>`)}</select>`:(console.warn(`<entity-sort>: unknown kind ${JSON.stringify(this.kind)}; expected one of ${Object.keys(Xg).map(r=>JSON.stringify(r)).join(", ")}.`),g)}_onChange=t=>{this.dispatchEvent(new CustomEvent("sort-change",{detail:{kind:this.kind,value:t.target.value},bubbles:!0,composed:!0}))}};customElements.define("entity-sort",hd);var gd=class extends O{static properties={showFile:{type:Boolean,attribute:"show-file"},showConfidence:{type:Boolean,attribute:"show-confidence"},showPriority:{type:Boolean,attribute:"show-priority"}};createRenderRoot(){return this}constructor(){super(),this.showFile=!1,this.showConfidence=!1,this.showPriority=!1}render(){let t=(r,n)=>c`<option value="${r}">${n}</option>`;return c`<select class="sort-select" aria-label="Sort findings" .value="${xe(a.sortBy)}" @change="${this._onChange}">${t("severity","Severity \u2193")} ${this.showFile?t("file","File \u2191"):g} ${this.showConfidence?c`${t("confidence-desc","Confidence \u2193")}${t("confidence-asc","Confidence \u2191")}`:g} ${this.showPriority?c`${t("priority-desc","Priority \u2193")}${t("priority-asc","Priority \u2191")}`:g}</select>`}_onChange=t=>{this.dispatchEvent(new CustomEvent("sort-change",{detail:{kind:"findings",value:t.target.value},bubbles:!0,composed:!0}))}};customElements.define("findings-sort",gd);var Qg=`:host{display:inline-flex;align-items:center;width:8.5rem;height:16px;--rs-thumb-size: 14px;--rs-track-height: 3px;--rs-rail: rgb(from currentcolor r g b / .25);--rs-fill: var(--accent, currentColor)}.track-wrap{position:relative;flex:1;height:var(--rs-thumb-size)}.track{position:absolute;left:0;right:0;top:50%;height:var(--rs-track-height);transform:translateY(-50%);border-radius:99px;background:linear-gradient(to right,var(--rs-rail) 0,var(--rs-rail) var(--low, 0%),var(--rs-fill) var(--low, 0%),var(--rs-fill) var(--high, 100%),var(--rs-rail) var(--high, 100%))}input[type=range]{appearance:none;-webkit-appearance:none;position:absolute;left:0;right:0;top:0;width:100%;height:var(--rs-thumb-size);background:transparent;pointer-events:none;margin:0;padding:0;outline:none}input[type=range]::-webkit-slider-thumb{-webkit-appearance:none;appearance:none;pointer-events:auto;width:var(--rs-thumb-size);height:var(--rs-thumb-size);border-radius:50%;background:var(--rs-fill);border:0;box-shadow:0 1px 3px #00000080}input[type=range]::-moz-range-thumb{pointer-events:auto;width:var(--rs-thumb-size);height:var(--rs-thumb-size);border-radius:50%;background:var(--rs-fill);border:0;box-shadow:0 1px 3px #00000080}input[type=range]::-webkit-slider-runnable-track{background:transparent;height:var(--rs-thumb-size)}
94
+ `;var md=class extends j{static properties={min:{type:Number},max:{type:Number},step:{type:Number},low:{type:Number},high:{type:Number}};static styles=B(Qg);constructor(){super(),this.min=0,this.max=100,this.step=1,this.low=0,this.high=100}willUpdate(){this.low<this.min&&(this.low=this.min),this.high>this.max&&(this.high=this.max),this.low>this.high&&(this.low=this.high)}render(){let t=this.max-this.min||1,r=(this.low-this.min)/t*100,n=(this.high-this.min)/t*100;return c`<div class="track-wrap" style="${`--low:${r}%;--high:${n}%`}"><div class="track"></div><input type="range" min="${this.min}" max="${this.max}" step="${this.step}" @input="${this._onInput}" @change="${this._onChange}"> <input type="range" min="${this.min}" max="${this.max}" step="${this.step}" @input="${this._onInput}" @change="${this._onChange}"></div>`}firstUpdated(){this._inputs=[...this.renderRoot.querySelectorAll('input[type="range"]')],this._inputs[0].value=this.low,this._inputs[1].value=this.high}updated(t){if(!this._inputs||!(t.has("low")||t.has("high")))return;let r=this._inputs.map(i=>Number(i.value)),n=r[0]>r[1],o=n?1:0,s=n?0:1;this.low!==r[o]&&(this._inputs[o].value=this.low),this.high!==r[s]&&(this._inputs[s].value=this.high)}_onInput=()=>{let t=Number(this._inputs[0].value),r=Number(this._inputs[1].value);this.low=Math.min(t,r),this.high=Math.max(t,r),this._emit("range-input")};_onChange=()=>{this._emit("range-change")};_emit(t){this.dispatchEvent(new CustomEvent(t,{detail:{low:this.low,high:this.high},bubbles:!0,composed:!0}))}};customElements.define("range-slider",md);var bd=class extends j{static properties={low:{type:Number},high:{type:Number},for:{type:String}};createRenderRoot(){return this}constructor(){super(),this.low=0,this.high=10,this.for="conf-range",this._dragging=!1,this._liveLow=0,this._liveHigh=10}connectedCallback(){super.connectedCallback(),document.addEventListener("range-input",this._onRangeInput),document.addEventListener("range-change",this._onRangeChange)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("range-input",this._onRangeInput),document.removeEventListener("range-change",this._onRangeChange)}willUpdate(t){this._dragging&&(t.has("low")&&this.low!==this._liveLow&&(this.low=this._liveLow),t.has("high")&&this.high!==this._liveHigh&&(this.high=this._liveHigh))}_onRangeInput=t=>{t.target?.id===this.for&&(this._dragging=!0,this._liveLow=t.detail.low,this._liveHigh=t.detail.high,this.low=t.detail.low,this.high=t.detail.high)};_onRangeChange=t=>{t.target?.id===this.for&&(this._dragging=!1)};render(){return c`<span>${this.low}</span><span class="dash">–</span><span>${this.high}</span>`}};customElements.define("conf-range-mirror",bd);var Zg=`dialog{max-width:560px;width:min(94vw,560px)}header h3{margin:0 0 .25rem}header p{margin:0 0 .9rem;color:var(--muted);font-size:.82rem}hr{border:0;border-top:1px solid var(--border);margin:.9rem 0}.section h4{margin:0 0 .25rem;font-size:.82rem;font-weight:600;text-transform:uppercase;letter-spacing:.08em;color:var(--muted)}.section p{margin:0 0 .55rem;color:var(--muted);font-size:.78rem}.section button{background:transparent;border:1px solid var(--border);color:var(--text);border-radius:5px;padding:.35rem .9rem;font:inherit;font-size:.8rem;&:hover{border-color:var(--accent);color:var(--accent)}&.primary{background:var(--accent);color:var(--surface);border-color:var(--accent)}&.primary:hover{filter:brightness(1.08)}&:disabled{opacity:.5}}input[type=file]{display:block;color:var(--text);font:inherit;font-size:.78rem;margin-bottom:.5rem}.error{margin:.5rem 0;padding:.4rem .6rem;border:1px solid var(--critical, #f87171);border-radius:5px;background:rgb(from var(--critical, #f87171) r g b / .07);color:var(--text);font-size:.78rem}.summary{margin:.5rem 0;font-size:.82rem;& strong{color:var(--text)}.meta{margin-left:.4rem;color:var(--muted);font-size:.74rem}}.mode{border:1px solid var(--border);border-radius:6px;padding:.55rem .7rem;margin:.55rem 0 .7rem;display:flex;flex-direction:column;gap:.35rem}.mode legend{padding:0 .35rem;font-size:.68rem;color:var(--muted);text-transform:uppercase;letter-spacing:.08em}.mode label{display:flex;align-items:flex-start;gap:.5rem;font-size:.82rem;& em{color:var(--muted);font-style:normal;font-size:.74rem}}.status{margin:.8rem 0 0;padding:.4rem .6rem;border-radius:5px;font-size:.78rem;&.status-ok{border:1px solid var(--accent);background:rgb(from var(--accent) r g b / .08);color:var(--text)}&.status-err{border:1px solid var(--critical, #f87171);background:rgb(from var(--critical, #f87171) r g b / .07);color:var(--text)}}.actions{display:flex;justify-content:flex-end;gap:.4rem;margin-top:.8rem;padding-top:.7rem;border-top:1px solid var(--border)}.actions button{background:transparent;border:1px solid var(--border);color:var(--text);border-radius:5px;padding:.3rem .8rem;font:inherit;font-size:.78rem;&:hover{border-color:var(--accent);color:var(--accent)}}
95
+ `;var yd=class extends F{static styles=[...F.styles,B(Zg)];static properties={parsed:{state:!0},parseError:{state:!0},mode:{state:!0},busy:{state:!0},status:{state:!0}};constructor(){super(),this.parsed=null,this.parseError=null,this.mode="prefer-current",this.busy=!1,this.status=null}focusInitial(){this.renderRoot.querySelector("button.primary")?.focus()}async _onDownload(){this.busy=!0,this.status=null;try{let{blob:t,filename:r}=await xl();Wr(t,r),this.status={kind:"ok",text:`Downloaded ${r}`}}catch(t){this.status={kind:"err",text:`Export failed: ${t.message}`}}finally{this.busy=!1}}async _onFile(t){let r=t.target.files?.[0];if(this.parsed=null,this.parseError=null,this.status=null,!!r)try{this.parsed=await _l(r)}catch(n){this.parseError=n.message}}_onMode(t){this.mode=t.target.value}async _onApply(){if(!(!this.parsed||this.busy)){this.busy=!0,this.status=null;try{let t=await Sl(this.parsed,this.mode);$(),this.status=t.repoUrlError?{kind:"err",text:`Applied ${t.triageEntries} triage entries (${this.mode}), but saving repo URLs failed: ${t.repoUrlError.message}`}:{kind:"ok",text:`Applied ${t.triageEntries} triage entries and ${t.repoUrls} repo URLs (${this.mode}).`},this.parsed=null;let r=this.renderRoot.querySelector('input[type="file"]');r&&(r.value="")}catch(t){this.status={kind:"err",text:`Import failed: ${t.message}`}}finally{this.busy=!1}}}render(){let t=this.parsed;return c`<dialog @close="${this._onClose}"><header><h3>Triage backup</h3><p>Bundles every triage entry (markers, triage states, comments, fixes, per-report ignores) and all saved repo URLs into a single gzipped JSON file.</p></header><section class="section"><h4>Export</h4><p>Download the current triage + repo-URL set as a portable backup.</p><button type="button" class="primary" @click="${this._onDownload}" ?disabled="${this.busy}">${this.busy?"Working\u2026":"Download backup"}</button></section><hr><section class="section"><h4>Import</h4><p>Pick a previously-exported backup. Nothing is applied until you click Apply.</p><input type="file" accept=".gz,application/gzip" @change="${this._onFile}" ?disabled="${this.busy}"> ${this.parseError?c`<div class="error">Failed to parse: ${this.parseError}</div>`:g} ${t?c`<div class="summary">Found <strong>${Object.keys(t.triage).length}</strong> triage entries and <strong>${Object.keys(t.repoUrls).length}</strong> repo URLs. ${t.exportedAt?c`<span class="meta">Exported ${t.exportedAt}.</span>`:g}</div><fieldset class="mode"><legend>Merge mode</legend><label><input type="radio" name="te-mode" value="prefer-current" .checked="${this.mode==="prefer-current"}" @change="${this._onMode}"> <span>Merge — keep current on conflict <em>(safest, only fills gaps)</em></span></label> <label><input type="radio" name="te-mode" value="prefer-imported" .checked="${this.mode==="prefer-imported"}" @change="${this._onMode}"> <span>Merge — prefer imported on conflict <em>(overwrites where both have a value)</em></span></label> <label><input type="radio" name="te-mode" value="replace" .checked="${this.mode==="replace"}" @change="${this._onMode}"> <span>Replace all <em>(drops every current persisted entry first — destructive)</em></span></label></fieldset><button type="button" class="primary" @click="${this._onApply}" ?disabled="${this.busy}">${this.busy?"Applying\u2026":"Apply import"}</button>`:g}</section>${this.status?c`<div class="${`status status-${this.status.kind}`}">${this.status.text}</div>`:g}<footer class="actions"><button type="button" @click="${this._onClose}">Close</button></footer></dialog>`}};customElements.define("triage-export-dialog",yd);function em(){return Q("triage-export-dialog")}var tm=`:host{display:inline-block;vertical-align:middle;position:relative}.chip{display:inline-flex;align-items:center;gap:.375rem;cursor:default;user-select:none;position:relative;min-height:24px;box-sizing:border-box;padding:.125rem .375rem .125rem .5rem;background:var(--surface);border:1px solid var(--border);border-radius:999px;color:var(--text);font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:.72rem;font-weight:500}.chip svg{color:var(--muted);flex-shrink:0}.chip.empty:hover{border-color:var(--accent)}.chip.empty .label{color:var(--muted);font-style:italic}.chip.readonly{padding-right:.5rem}.chip.copied:after{content:"Copied";position:absolute;inset:0;display:grid;place-items:center;background:var(--surface);backdrop-filter:var(--glass-blur);border-radius:999px;color:var(--text);font-weight:400;white-space:nowrap;pointer-events:none}.edit-btn{width:18px;height:18px;display:grid;place-items:center;padding:0;margin-left:.125rem;background:transparent;border:0;border-radius:4px;color:var(--muted)}.edit-btn:hover{color:var(--text);background:rgb(from var(--text) r g b / .06)}.chip[inert]{visibility:hidden;min-width:19rem}input{position:absolute;inset:0;box-sizing:border-box;padding:0 .55rem;background:var(--surface);border:1px solid var(--accent);border-radius:999px;color:var(--text);font:inherit;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:.72rem;font-weight:400;outline:none}@media print{.chip{color:#000!important;border:0!important}.chip svg{color:#000!important}.edit-btn,input{display:none!important}}
96
+ `;function zi(e){if(!e)return"";let t=e.match(/github\.com\/([^/?#]+\/[^/?#]+?)(?:\.git)?(?:[/?#]|$)/iu);return t?t[1]:e}var wd=c`<svg viewBox="0 0 16 16" width="12" height="12" fill="currentColor" aria-hidden="true"><path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8z"/></svg>`,rm=c`<svg viewBox="0 0 16 16" width="11" height="11" fill="currentColor" aria-hidden="true"><path d="M11.013 1.427a1.75 1.75 0 0 1 2.474 0l1.086 1.086a1.75 1.75 0 0 1 0 2.474l-8.61 8.61c-.21.21-.47.364-.756.445l-3.251.93a.75.75 0 0 1-.927-.928l.929-3.25c.082-.286.235-.547.445-.758l8.61-8.61z"/></svg>`,vd=class extends j{static properties={url:{type:String},editable:{type:Boolean,reflect:!0},editing:{type:Boolean,reflect:!0},_copied:{state:!0}};static styles=B(tm);constructor(){super(),this.url="",this.editable=!1,this.editing=!1,this._copied=!1,this._opener=""}render(){if(this.editable&&this.editing){let t=!!this.url,r=t?zi(this.url):"Set repo";return c`<span class="${t?"chip":"chip empty"}" aria-hidden="true" inert>${wd} <span class="label">${r}</span> <button type="button" class="edit-btn">${rm}</button> </span><input type="text" .value="${xe(this.url)}" placeholder="user/repo or https://github.com/user/repo" @input="${this._onInput}" @focus="${this._onFocus}" @keydown="${this._onKeydown}" @blur="${this._onBlur}">`}if(this.editable){let t=!!this.url,r=t?zi(this.url):"Set repo",n=t?this._copied?"chip copied":"chip":"chip empty";return c`<span class="${n}" @click="${t?null:this._onEdit}">${wd} ${t?this._slugLabel(r):c`<span class="label">${r}</span>`} <button type="button" class="edit-btn" title="Edit repo URL" aria-label="Edit repo URL" @click="${this._onEdit}">${rm}</button></span>`}if(this.url){let t=this._copied?"chip readonly copied":"chip readonly";return c`<span class="${t}" title="Repo from findings (read-only)">${wd} ${this._slugLabel(zi(this.url))}</span>`}return g}_slugLabel(t){return c`<span class="label" title="Copy repo name" @click="${this._onCopyLabel}">${t}</span>`}updated(t){if(t.has("editing")&&this.editing){let r=this.renderRoot.querySelector("input");r&&(r.focus(),r.select())}}_onEdit=t=>{t&&t.stopPropagation(),this._emit("repo-edit-start")};_onCopyLabel=t=>{t&&t.stopPropagation();let r=zi(this.url);if(r)try{navigator.clipboard.writeText(r).then(()=>(this._copied=!0,setTimeout(()=>{this._copied=!1},1e3),null)).catch(()=>{})}catch{}};_onFocus=t=>{this._opener=t.target.value};_onInput=t=>{this.url=t.target.value,this._emit("repo-input",{url:this.url})};_onKeydown=t=>{t.key==="Enter"?(t.preventDefault(),this._emit("repo-commit",{url:this.url})):t.key==="Escape"&&(t.preventDefault(),this.url=this._opener,this._emit("repo-cancel",{url:this._opener}))};_onBlur=()=>{this.editing&&this._emit("repo-commit",{url:this.url})};_emit(t,r){this.dispatchEvent(new CustomEvent(t,{detail:r,bubbles:!0,composed:!0}))}};customElements.define("repo-chip",vd);function Ge(e,t){for(let[r,n]of Object.entries(t))e.hasAttribute(r)||e.setAttribute(r,n)}var e$=c`<svg viewBox="0 0 16 16" width="12" height="12" aria-hidden="true"><path class="bubble" d="M2.5 3h11a.5.5 0 0 1 .5.5v6.5a.5.5 0 0 1-.5.5H8.4l-3 2.6V10.5H2.5a.5.5 0 0 1-.5-.5V3.5a.5.5 0 0 1 .5-.5z" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linejoin="round"/></svg>`,t$=c`<svg viewBox="0 0 16 16" width="12" height="12" aria-hidden="true"><path class="wrench" d="M10.4 2.6a3 3 0 0 0-3.6 4.5L2 12l2 2 4.9-4.8a3 3 0 0 0 4.5-3.6l-1.8 1.8-1.5-.4-.4-1.5z" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linejoin="round"/></svg>`,r$=c`<svg viewBox="0 0 16 16" width="12" height="12" aria-hidden="true"><path class="flag-cloth" d="M5 1.5h6v13l-3-2.7-3 2.7z" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linejoin="round"/></svg>`,n$=[{key:"comment",glyph:e$,label:"commented",stateKey:"filterComment",hasKey:"hasComment"},{key:"fix",glyph:t$,label:"fixed",stateKey:"filterFix",hasKey:"hasFix"},{key:"flag",glyph:r$,label:"flagged",stateKey:"filterFlagged",hasKey:"hasFlagged"}],kd=class extends O{static properties={hasComment:{attribute:!1},hasFix:{attribute:!1},hasFlagged:{attribute:!1}};createRenderRoot(){return this}constructor(){super(),this.hasComment=!1,this.hasFix=!1,this.hasFlagged=!1}connectedCallback(){super.connectedCallback(),Ge(this,{role:"group","aria-label":"Annotation filter"})}render(){let t=n$.filter(r=>this[r.hasKey]||a[r.stateKey]);return t.length===0?g:c`${t.map(r=>{let n=a[r.stateKey],o=n==="with"?`Showing only ${r.label} findings \u2014 click to exclude them`:n==="without"?`Excluding ${r.label} findings \u2014 click to clear`:`Show only ${r.label} findings`;return c`<button type="button" class="${R({"annotation-chip":!0,"sel-with":n==="with","sel-without":n==="without"})}" title="${o}" aria-label="${o}" aria-pressed="${String(n!=="")}" @click="${()=>this._toggle(r.key)}">${r.glyph}</button>`})}`}_toggle(t){this.dispatchEvent(new CustomEvent("annotation-filter-toggle",{detail:{key:t},bubbles:!0,composed:!0}))}};customElements.define("annotation-filter",kd);var o$=[["critical","Critical"],["high","High"],["medium","Medium"],["low","Low"],["high_bug","High bug"],["bug","Bug"],["informational","Info"]],$d=class extends O{static properties={counts:{attribute:!1},selected:{attribute:!1},kind:{type:String}};createRenderRoot(){return this}constructor(){super(),this.counts={},this.selected=[],this.kind="findings"}connectedCallback(){super.connectedCallback(),Ge(this,{role:"group","aria-label":"Filter by severity"})}render(){let t=this.kind==="graph"?new Set(this.selected):a.filterSeverities,r=o$.filter(([n])=>(this.counts[n]??0)||t.has(n));return r.length===0?g:c`${r.map(([n,o])=>{let s=this.counts[n]??0,i=t.has(n);return c`<button type="button" class="${R({"sev-chip":!0,[n]:!0,active:i})}" aria-pressed="${String(i)}" @click="${()=>this._toggle(n)}"><span class="sd"></span><span class="name">${o}</span><span class="n">${s}</span></button>`})}`}_toggle(t){this.dispatchEvent(new CustomEvent("severity-toggle",{detail:{severity:t,kind:this.kind},bubbles:!0,composed:!0}))}};customElements.define("severity-chips",$d);var s$=c`<svg class="trash-icon" viewBox="0 0 16 16" width="11" height="11" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 4h10M6.5 4V2.5h3V4M5 4l.7 9h4.6L11 4"/></svg>`,xd=class extends O{createRenderRoot(){return this}render(){let t=a.currentView==="bundles"&&a.selectedBundle,r=!a.currentFile&&!t;return c`<button type="button" class="danger" ?disabled="${r}">${s$}<span>Delete current</span></button>`}};customElements.define("sidebar-delete-current",xd);var i$=c`<svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M2 6h12v7a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V6Z"/><path d="M2 6l1.6-3.3A1.3 1.3 0 0 1 4.8 2h6.4a1.3 1.3 0 0 1 1.2.7L14 6"/><path d="M8 2v4"/></svg>`,a$=c`<svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><line x1="4" x2="4" y1="2.5" y2="10"/><circle cx="12" cy="4" r="2"/><circle cx="4" cy="12" r="2"/><path d="M12 6a6 6 0 0 1-6 6"/></svg>`,nm={packages:{title:"Show packages",icon:i$,view:"packages"},repositories:{title:"Show repositories",icon:a$,view:"repositories"}},_d=class extends O{static properties={kind:{type:String},count:{type:Number}};createRenderRoot(){return this}constructor(){super(),this.kind="",this.count=0}render(){if(this.count===0)return g;let t=nm[this.kind];if(!t)return console.warn(`<sidebar-view-button>: unknown kind ${JSON.stringify(this.kind)}; expected one of ${Object.keys(nm).map(n=>JSON.stringify(n)).join(", ")}.`),g;let r=a.currentView===t.view;return c`<button type="button" class="${R({"sidebar-view-btn":!0,active:r})}" title="${t.title}" aria-label="${t.title}">${t.icon}<span class="view-btn-count">${this.count}</span></button>`}};customElements.define("sidebar-view-button",_d);var l$=["invalid","deleted"],om={package:{stateKey:"packageSlideTriage"},repository:{stateKey:"repositorySlideTriage"}},Sd=class extends O{static properties={counts:{attribute:!1},kind:{type:String}};createRenderRoot(){return this}constructor(){super(),this.counts={},this.kind=""}connectedCallback(){super.connectedCallback(),Ge(this,{role:"group","aria-label":"Triage view"})}render(){let t=om[this.kind];if(!t)return console.warn(`<slide-triage-tabs>: unknown kind ${JSON.stringify(this.kind)}; expected one of ${Object.keys(om).map(o=>JSON.stringify(o)).join(", ")}.`),g;let r=a[t.stateKey],n=l$.filter(o=>(this.counts[o]??0)>0||r===o);return n.length===0?g:c`${n.map(o=>{let s=r===o,i=this.counts[o]??0;return c`<button type="button" class="${R({"triage-state-btn":!0,[`triage-state-${o}`]:!0,active:s})}" title="${s?`Exit ${o} view`:`Show ${o} (${i})`}" aria-pressed="${String(s)}" @click="${()=>this._toggle(o)}">${o.charAt(0).toUpperCase()+o.slice(1)} (${i})</button>`})}`}_toggle(t){this.dispatchEvent(new CustomEvent("slide-triage-toggle",{detail:{kind:this.kind,value:t},bubbles:!0,composed:!0}))}};customElements.define("slide-triage-tabs",Sd);var c$=[["own","Sources"],["modules","Dependencies"]],Cd=class extends O{createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),Ge(this,{role:"group","aria-label":"Source filter"})}render(){return c`${c$.map(([t,r])=>{let n=a.filterSources.has(t);return c`<button type="button" class="${R({"source-chip":!0,active:n})}" aria-pressed="${String(n)}" @click="${()=>this._toggle(t)}">${r}</button>`})}`}_toggle(t){this.dispatchEvent(new CustomEvent("source-toggle",{detail:{source:t},bubbles:!0,composed:!0}))}};customElements.define("source-filter",Cd);var d$=c`<svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/></svg>`,u$=c`<svg viewBox="0 0 16 16" width="13" height="13" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 6h10v4"/></svg>`,sm={findings:{stateKey:"filterInclude",placeholder:"Search findings\u2026"},files:{stateKey:"filesSearch",placeholder:"Search files\u2026"}},Ed=class extends O{static properties={kind:{type:String}};createRenderRoot(){return this}constructor(){super(),this.kind=""}render(){let t=sm[this.kind];if(!t)return console.warn(`<toolbar-search>: unknown kind ${JSON.stringify(this.kind)}; expected one of ${Object.keys(sm).map(n=>JSON.stringify(n)).join(", ")}.`),g;let r=a[t.stateKey];return c`${d$} <input type="text" aria-label="${t.placeholder}" placeholder="${t.placeholder}" .value="${xe(r)}" @input="${this._onInput}"> ${this.kind==="findings"&&r?this._negateToggle():g}`}_negateToggle(){let t=a.filterIncludeNegate;return c`<button type="button" class="${R({"search-negate-btn":!0,active:t})}" title="${t?"Negation on \u2014 click to undo":"Negate: show non-matching findings"}" aria-label="Negate search" aria-pressed="${String(t)}" @click="${this._onToggleNegate}">${u$}</button>`}_onInput=t=>{this.dispatchEvent(new CustomEvent("search-input",{detail:{kind:this.kind,value:t.target.value},bubbles:!0,composed:!0}))};_onToggleNegate=()=>{this.dispatchEvent(new CustomEvent("search-negate-toggle",{bubbles:!0,composed:!0}))}};customElements.define("toolbar-search",Ed);function p$(e){if(!e)return"";let t=e.match(/github\.com\/([^/?#]+\/[^/?#]+?)(?:\.git)?(?:[/?#]|$)/iu);return t?t[1]:e}var Ad=class extends O{static properties={options:{attribute:!1}};createRenderRoot(){return this}constructor(){super(),this.options=[]}render(){return c`<select class="sort-select" aria-label="Filter by repository" .value="${xe(a.filterRepo)}" @change="${this._onChange}"><option value="">All repositories</option>${this.options.map(t=>{let r=t??Co,n=t==null?"(no repo)":p$(t);return c`<option value="${r}">${n}</option>`})}</select>`}_onChange=t=>{this.dispatchEvent(new CustomEvent("repo-change",{detail:{value:t.target.value},bubbles:!0,composed:!0}))}};customElements.define("repo-filter",Ad);var im=[["none","none","unmarked"],["red","r","red"],["blue","b","blue"],["green","g","green"],["gray","x","gray"]],Td=class extends O{static properties={counts:{attribute:!1},selected:{attribute:!1},kind:{type:String}};createRenderRoot(){return this}constructor(){super(),this.counts={},this.selected=[],this.kind="findings"}connectedCallback(){super.connectedCallback(),Ge(this,{role:"group","aria-label":"Filter by mark color"})}render(){let t=this.kind==="graph"?new Set(this.selected):a.filterColors;return im.some(([n])=>(this.counts[n]??0)||t.has(n))?c`${im.map(([n,o,s])=>{let i=this.counts[n]??0,l=t.has(n);return c`<button type="button" class="${l?"active":""}" title="${`${s} (${i})`}" aria-pressed="${String(l)}" @click="${()=>this._toggle(n)}"><span class="${`td ${o}`}"></span><span class="count">${i}</span></button>`})}`:g}_toggle(t){this.dispatchEvent(new CustomEvent("color-toggle",{detail:{color:t,kind:this.kind},bubbles:!0,composed:!0}))}};customElements.define("triage-filter",Td);var f$=["inprogress","fixed","invalid","deleted","ignored"],Id={graph:"graph2-triage-selector",packages:"packages-triage-selector"},h$={inprogress:"In progress"},g$=e=>h$[e]??e.charAt(0).toUpperCase()+e.slice(1),Rd=class extends O{static properties={counts:{attribute:!1},states:{attribute:!1},variant:{type:String}};createRenderRoot(){return this}constructor(){super(),this.counts={},this.states=null,this.variant=""}connectedCallback(){super.connectedCallback(),Ge(this,{role:"group","aria-label":"Triage view"})}render(){let t=this.states??f$,r=t.reduce((s,i)=>s+(this.counts[i]??0),0),n=this.variant?Id[this.variant]:null;this.variant&&n===void 0&&console.warn(`<triage-selector>: unknown variant ${JSON.stringify(this.variant)}; expected one of ${Object.keys(Id).map(s=>JSON.stringify(s)).join(", ")} or "".`);for(let s of Object.values(Id))this.classList.toggle(s,s===n);let o=r===0&&!a.shownTriage;return this.classList.toggle("is-empty",o),o?g:c`${t.map(s=>{let i=this.counts[s]??0,l=a.shownTriage===s;if(i===0&&!l)return g;let d=g$(s);return c`<button type="button" class="${R({"triage-state-btn":!0,[`triage-state-${s}`]:!0,active:l})}" data-triage-show="${s}" title="${l?`Exit ${d.toLowerCase()} view`:`Show ${d.toLowerCase()} (${i})`}" aria-pressed="${String(l)}">${d} (${i})</button>`})}`}};customElements.define("triage-selector",Rd);var m$={table:c`<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><rect x="3" y="3" width="18" height="18" rx="2"/><line x1="3" x2="21" y1="9" y2="9"/><line x1="3" x2="21" y1="15" y2="15"/><line x1="9" x2="9" y1="3" y2="21"/></svg>`,list:c`<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><line x1="3" x2="21" y1="6" y2="6"/><line x1="3" x2="21" y1="12" y2="12"/><line x1="3" x2="21" y1="18" y2="18"/></svg>`,grouped:c`<svg viewBox="0 0 16 16" width="16" height="16" fill="currentColor" aria-hidden="true"><rect x="2" y="1.5" width="12" height="2" rx=".4"/><rect x="5" y="4.4" width="9" height="1.3"/><rect x="5" y="6.2" width="9" height="1.3"/><rect x="2" y="8.5" width="12" height="2" rx=".4"/><rect x="5" y="11.4" width="9" height="1.3"/><rect x="5" y="13.2" width="9" height="1.3"/></svg>`,kanban:c`<svg viewBox="0 0 16 16" width="16" height="16" fill="currentColor" aria-hidden="true"><rect x="1.5" y="2" width="3.8" height="12" rx=".6" fill="none" stroke="currentColor" stroke-width="1"/><rect x="6.1" y="2" width="3.8" height="12" rx=".6" fill="none" stroke="currentColor" stroke-width="1"/><rect x="10.7" y="2" width="3.8" height="12" rx=".6" fill="none" stroke="currentColor" stroke-width="1"/><rect x="2.4" y="3.6" width="2" height="1.4" rx=".2"/><rect x="2.4" y="5.6" width="2" height="1.4" rx=".2"/><rect x="7" y="3.6" width="2" height="1.4" rx=".2"/><rect x="11.6" y="3.6" width="2" height="1.4" rx=".2"/><rect x="11.6" y="5.6" width="2" height="1.4" rx=".2"/><rect x="11.6" y="7.6" width="2" height="1.4" rx=".2"/></svg>`,focus:c`<svg viewBox="0 0 16 16" width="16" height="16" fill="currentColor" aria-hidden="true"><rect x="1.5" y="2.5" width="8.5" height="11" rx=".6" fill="none" stroke="currentColor" stroke-width="1"/><rect x="3" y="4.4" width="5.5" height="1"/><rect x="3" y="6.4" width="5.5" height="1"/><rect x="3" y="8.4" width="3.5" height="1"/><rect x="11.2" y="2.5" width="3.3" height="2.5" rx=".4" fill="currentColor" opacity=".55"/><rect x="11.2" y="5.7" width="3.3" height="2.5" rx=".4" fill="currentColor" opacity=".35"/><rect x="11.2" y="8.9" width="3.3" height="2.5" rx=".4" fill="currentColor" opacity=".22"/></svg>`,graph:c`<svg viewBox="0 0 16 16" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" aria-hidden="true"><line x1="4.5" y1="4.5" x2="11.5" y2="6.5"/><line x1="4.5" y1="4.5" x2="6.5" y2="11.5"/><line x1="11.5" y1="6.5" x2="6.5" y2="11.5"/><circle cx="4.5" cy="4.5" r="2" fill="currentColor"/><circle cx="11.5" cy="6.5" r="2" fill="currentColor"/><circle cx="6.5" cy="11.5" r="2" fill="currentColor"/></svg>`},am={table:"Table view (compact rows, click a row to expand)",list:"List view (flat, one card per finding)",grouped:"List view, grouped by file",focus:"Focus view (one finding centered + a queue of next findings)",kanban:"Kanban board, columns grouped by triage status",graph:"Graph view (canvas with imports / exports)"},Fd=["table","list","grouped","focus","kanban","graph"],Bd=class extends O{static properties={modes:{type:String},kind:{type:String}};createRenderRoot(){return this}constructor(){super(),this.modes=Fd.join(","),this.kind="findings"}connectedCallback(){super.connectedCallback(),Ge(this,{role:"group","aria-label":"View mode"})}render(){let t=this.kind==="files"?a.filesViewMode:a.viewMode,r=this.modes.split(",").map(o=>o.trim()).filter(o=>Fd.includes(o)),n=r.length>0?r:Fd;return c`${n.map(o=>c`<button type="button" class="${R({"view-mode-btn":!0,active:t===o})}" title="${am[o]}" aria-label="${am[o]}" aria-pressed="${String(t===o)}" @click="${()=>this._select(o,t)}">${m$[o]}</button>`)}`}_select(t,r){t!==r&&this.dispatchEvent(new CustomEvent("view-mode-change",{detail:{mode:t,kind:this.kind},bubbles:!0,composed:!0}))}};customElements.define("view-mode-buttons",Bd);var um=6,lm=14,Ui=2,cm=24,Jo=4,b$=1.5,Hi=new Map,dm="treemap";function y$(e){let t=/^#?([0-9a-f]{6})$/iu.exec(e);if(!t)return"#fff";let r=parseInt(t[1],16),n=r>>16&255,o=r>>8&255,s=r&255;return(.2126*n+.7152*o+.0722*s)/255>.6?"#1a1a1a":"#fff"}function w$(e,t,r,n){let o=r*r,s=n*n;return Math.max(s*e/o,o/(s*t))}function pm(e,t){let r=[],n=e.filter(f=>f.value>0),{x:o,y:s,w:i,h:l}=t;if(n.length===0||i<=0||l<=0)return r;let d=0;for(let f of n)d+=f.value;let u=i*l/d,p=0;for(;p<n.length&&i>.5&&l>.5;){let f=Math.min(i,l),h=p,b=0,m=0,y=1/0,v=1/0;for(;h<n.length;){let k=n[h].value*u,E=k>m?k:m,S=k<y?k:y,x=w$(E,S,b+k,f);if(h===p||x<=v)v=x,b+=k,m=E,y=S,h++;else break}let w=b/f;if(i>=l){let k=s;for(let E=p;E<h;E++){let S=E===h-1?s+l-k:n[E].value*u/w;r.push({node:n[E],x:o,y:k,w,h:S}),k+=S}o+=w,i-=w}else{let k=o;for(let E=p;E<h;E++){let S=E===h-1?o+i-k:n[E].value*u/w;r.push({node:n[E],x:k,y:s,w:S,h:w}),k+=S}s+=w,l-=w}p=h}return r}function fm(e){for(;e.children&&e.children.size===1;){let t=e.children.values().next().value;if(t.isFile)break;e.name=`${e.name}/${t.name}`,e.children=t.children}if(e.children)for(let t of e.children.values())fm(t)}function hm(e,t,r,n){if(e.path=e.name?t?`${t}/${e.name}`:e.name:t,e.parent=r,e.isFile)return e.count=1,e.value;n.set(e.path,e);let o=0,s=0,i;for(let l of e.children.values())o+=hm(l,e.path,e,n),s+=l.count,i===void 0?i=l.pkg:i!==l.pkg&&(i=null);return e.value=o,e.count=s,e.pkg=i??null,o}function gm(e,t,r,n,o,s,i){if(n<Jo||o<Jo)return;if(e.isFile){i.push({kind:"file",node:e,x:t,y:r,w:n,h:o});return}if(!(s<um&&n>=cm&&o>=cm&&e.children.size>0)){i.push({kind:"agg",node:e,x:t,y:r,w:n,h:o});return}i.push({kind:"dir",node:e,x:t,y:r,w:n,h:o});let d=o>=lm+Jo+Ui?lm:0,u=t+Ui,p=r+d,f=n-Ui*2,h=o-d-Ui;if(f<Jo||h<Jo)return;let b=[...e.children.values()].toSorted((m,y)=>y.value-m.value);for(let m of pm(b,{x:u,y:p,w:f,h}))gm(m.node,m.x,m.y,m.w,m.h,s+1,i)}function Md(e,t){let r=e/(t||1)*100;return r>=10?r.toFixed(0):r.toFixed(r>=1?1:2)}function mm(e,t){if(t<=0||e.isFile||!e.children||e.children.size===0)return 0;let r=1;for(let n of e.children.values()){if(r>=t)break;let o=1+mm(n,t-1);o>r&&(r=o)}return r}function v$(e,t,r,n,o,s){let i=Math.min(s-o,Math.PI*2-1e-4),l=o+i,d=i>Math.PI?1:0,u=Math.cos(o),p=Math.sin(o),f=Math.cos(l),h=Math.sin(l),b=m=>m.toFixed(2);return`M${b(e+n*u)} ${b(t+n*p)}A${b(n)} ${b(n)} 0 ${d} 1 ${b(e+n*f)} ${b(t+n*h)}L${b(e+r*f)} ${b(t+r*h)}A${b(r)} ${b(r)} 0 ${d} 0 ${b(e+r*u)} ${b(t+r*p)}Z`}function k$(e,t){let r=Math.max(4,Math.floor(t/6.4));return e.length>r?`${e.slice(0,r-1)}\u2026`:e}var Ld=class extends j{static properties={details:{attribute:!1},_w:{state:!0},_h:{state:!0},_focus:{state:!0},_mode:{state:!0}};createRenderRoot(){return this}constructor(){super(),this.details=null,this._w=0,this._h=0,this._root=null,this._focus=[],this._mode=dm,this._dirByPath=new Map,this._status="loading",this._meta={files:0,total:0,prefix:""},this._ro=null,this._plot=null,this._tooltip=null,this._ttCell=null,this._onPointerMove=this._onPointerMove.bind(this),this._onPointerLeave=this._onPointerLeave.bind(this),this._onPlotClick=this._onPlotClick.bind(this)}willUpdate(t){t.has("details")&&this._rebuild()}firstUpdated(){this._plot=this.querySelector(".bundle-treemap-plot"),this._tooltip=this.querySelector(".bundle-treemap-tooltip"),!(!this._plot||typeof ResizeObserver>"u")&&(this._ro=new ResizeObserver(t=>{let r=t[0]?.contentRect;if(!r)return;let n=Math.floor(r.width),o=Math.floor(r.height);(n!==this._w||o!==this._h)&&(this._w=n,this._h=o)}),this._ro.observe(this._plot))}disconnectedCallback(){super.disconnectedCallback(),this._ro&&(this._ro.disconnect(),this._ro=null)}_onPointerMove(t){let r=t.target.closest(".bundle-treemap-node");if(!r||!this._tooltip){this._hideTooltip();return}if(r!==this._ttCell){this._ttCell=r;let n=r.dataset;q(c`<div class="bundle-treemap-tt-path">${n.ttPath}</div>${n.ttPkg?c`<div class="bundle-treemap-tt-head"><span class="bundle-treemap-tt-dot" style="${`background:${n.ttColor}`}"></span> <span class="bundle-treemap-tt-pkg">${n.ttPkg}</span></div>`:""}<div class="bundle-treemap-tt-meta">${n.ttMeta}</div>`,this._tooltip)}this._positionTooltip(t.clientX,t.clientY)}_onPointerLeave(){this._hideTooltip()}_positionTooltip(t,r){let n=this._tooltip;if(!n||!this._plot)return;n.classList.add("show");let o=this._plot.getBoundingClientRect(),s=t-o.left,i=r-o.top,l=12,d=s+l;d+n.offsetWidth>o.width-4&&(d=s-n.offsetWidth-l),d<4&&(d=4);let u=i+l;u+n.offsetHeight>o.height-4&&(u=i-n.offsetHeight-l),u<4&&(u=4),n.style.left=`${d}px`,n.style.top=`${u}px`}_hideTooltip(){this._ttCell=null,this._tooltip&&this._tooltip.classList.remove("show")}_rebuild(){if(this._root=null,this._focus=[],this._dirByPath=new Map,this._meta={files:0,total:0,prefix:""},!this.details){this._status="loading";return}let t=He(this.details);if(!t||t.size===0){this._status="empty";return}let r=[...t.keys()],n=nr(this.details),{prefix:o,stripped:s}=Qe(r),i=new TextEncoder,l={name:"",children:new Map,value:0,isFile:!1},d=0,u=0;for(let h=0;h<r.length;h++){let b=t.get(r[h]),m=typeof b=="string"?i.encode(b).byteLength:0;if(m<=0)continue;let y=s[h].split("/"),v=l,w=!1;for(let S=0;S<y.length-1;S++){let x=v.children.get(y[S]);if(x&&x.isFile){w=!0;break}x||(x={name:y[S],children:new Map,value:0,isFile:!1},v.children.set(y[S],x)),v=x}if(w)continue;let k=y.at(-1),E=v.children.get(k);if(!(E&&!E.isFile)){if(!E){let S=it(s[h],{packageDir:n?.get(r[h])});E={name:k,isFile:!0,value:0,origPath:r[h],pkg:S},v.children.set(k,E)}E.value+=m,d+=m,u++}}if(d===0){this._status="empty";return}for(let h of l.children.values())fm(h);let p=new Map;hm(l,"",null,p),this._root=l,this._dirByPath=p,this._meta={files:u,total:d,prefix:o},this._status="ok";let f=this.details?.integrity?Hi.get(this.details.integrity):null;if(f){let h=p.get(f);h?this._focus=this._chainTo(h):Hi.delete(this.details.integrity)}}get _focusNode(){return this._focus.length>0?this._focus.at(-1):this._root}_chainTo(t){let r=[];for(let n=t;n&&n!==this._root;n=n.parent)r.push(n);return r.reverse(),r}_rememberFocus(){let t=this.details?.integrity;if(!t)return;let r=this._focus.at(-1)?.path;r?Hi.set(t,r):Hi.delete(t)}_drillInto(t){!t||t.isFile||!t.children||t.children.size===0||(this._focus=this._chainTo(t),this._rememberFocus(),this._hideTooltip())}_focusTo(t){let r=t<0?[]:this._focus.slice(0,t+1);r.length!==this._focus.length&&(this._focus=r,this._rememberFocus(),this._hideTooltip())}_toggleMode(){this._mode=this._mode==="sunburst"?"treemap":"sunburst",dm=this._mode,this._hideTooltip()}_onPlotClick(t){let r=t.target.closest("[data-treemap-into]");if(!r)return;let n=this._dirByPath.get(r.dataset.treemapInto);n&&this._drillInto(n)}_renderCrumbs(){let t=this._focus,r=t.length===0,n=t.slice(0,-1),o=r?null:t.at(-1);return c`<nav class="bundle-treemap-crumbs" aria-label="Treemap location"><span class="bundle-treemap-crumbs-lead"><button type="button" class="${R({"bundle-treemap-crumb-home":!0,"at-root":r})}" @click="${()=>this._focusTo(-1)}">Source ${this._mode==="sunburst"?"sunburst":"treemap"}</button> ${n.map((s,i)=>c`<span class="bundle-treemap-crumb-sep" aria-hidden="true">›</span><button type="button" class="bundle-treemap-crumb" @click="${()=>this._focusTo(i)}" title="${s.path}">${s.name}</button>`)} </span>${o?c`<span class="bundle-treemap-crumb-sep" aria-hidden="true">›</span><span class="bundle-treemap-crumb-current" aria-current="location" title="${o.path}">${o.name}</span>`:""}</nav>`}_cell(t){let r=Md(t.node.value,this._meta.total),n={left:`${t.x}px`,top:`${t.y}px`,width:`${t.w}px`,height:`${t.h}px`},o=`${t.node.count} ${t.node.count===1?"file":"files"}`;if(t.kind==="dir")return c`<div class="bundle-treemap-node bundle-treemap-dir" style="${pe(n)}" data-treemap-into="${t.node.path}" data-tt-path="${`${t.node.path}/`}" data-tt-meta="${`${ee(t.node.value)} \xB7 ${o} \xB7 ${r}%`}"><span class="bundle-treemap-dirname">${t.node.name}</span></div>`;let s=t.node.pkg??it(t.node.path),i=st(s),l=pe({...n,background:i,color:y$(i)}),d=s==="__own__"?"own source":s;return t.kind==="agg"?c`<div class="bundle-treemap-node bundle-treemap-leaf bundle-treemap-agg" style="${l}" data-treemap-into="${t.node.path}" data-tt-path="${`${t.node.path}/`}" data-tt-pkg="${d}" data-tt-color="${i}" data-tt-meta="${`${ee(t.node.value)} \xB7 ${o} \xB7 ${r}%`}"><span class="bundle-treemap-label">${t.node.name}/</span></div>`:c`<div class="bundle-treemap-node bundle-treemap-leaf bundle-treemap-file" style="${l}" data-bundle-view-source="${t.node.origPath}" data-tt-path="${t.node.path}" data-tt-pkg="${d}" data-tt-color="${i}" data-tt-meta="${`${ee(t.node.value)} \xB7 ${r}% of bundle`}"><span class="bundle-treemap-label">${t.node.name}</span></div>`}_arc(t,r,n){let o=Md(t.value,n),s=t.pkg??it(t.path),i=st(s),l=s==="__own__"?"own source":s;if(t.isFile)return Ut`<path class="bundle-treemap-node bundle-treemap-arc" d="${r}" fill="${i}" data-bundle-view-source="${t.origPath}" data-tt-path="${t.path}" data-tt-pkg="${l}" data-tt-color="${i}" data-tt-meta="${`${ee(t.value)} \xB7 ${o}% of bundle`}"></path>`;let d=`${t.count} ${t.count===1?"file":"files"}`;return Ut`<path class="bundle-treemap-node bundle-treemap-arc" d="${r}" fill="${i}" data-treemap-into="${t.path}" data-tt-path="${`${t.path}/`}" data-tt-pkg="${t.pkg?l:g}" data-tt-color="${t.pkg?i:g}" data-tt-meta="${`${ee(t.value)} \xB7 ${d} \xB7 ${o}%`}"></path>`}_renderSunburst(t){let r=this._w,n=this._h,o=r/2,s=n/2,i=Math.min(r,n)/2-6;if(i<30)return g;let l=mm(t,um),d=Math.min(Math.max(i*.18,26),i*.45),u=(i-d)/l,p=this._meta.total||1,f=[],h=(w,k,E,S)=>{let x=[...w.children.values()].toSorted((Z,W)=>W.value-Z.value),T=E-k,N=k;for(let Z of x){let W=T*(Z.value/w.value),be=d+(S-1)*u,ie=be+u;W*ie>=b$&&(f.push(this._arc(Z,v$(o,s,be,ie,N,N+W),p)),!Z.isFile&&S<l&&Z.children.size>0&&h(Z,N,N+W,S+1)),N+=W}};h(t,-Math.PI/2,Math.PI*1.5,1);let b=this._focus.length>0,m=Math.max(d-4,10),y=b?Ut`<circle class="bundle-treemap-node bundle-treemap-center" cx="${o}" cy="${s}" r="${m}" data-treemap-into="${t.parent.path}" data-tt-path="${`${t.path}/`}" data-tt-meta="${`${ee(t.value)} \xB7 ${t.count} ${t.count===1?"file":"files"} \xB7 ${Md(t.value,p)}%`}"></circle>`:Ut`<circle class="bundle-treemap-center" cx="${o}" cy="${s}" r="${m}"></circle>`,v=Ut`<text class="bundle-treemap-center-label" x="${o}" y="${s}" text-anchor="middle">${b?Ut`<tspan x="${o}" dy="-0.3em">${k$(t.name,m*2-12)}</tspan><tspan class="bundle-treemap-center-sub" x="${o}" dy="1.5em">${ee(t.value)}</tspan>`:Ut`<tspan x="${o}" dy="0.35em">${ee(t.value)}</tspan>`}</text>`;return c`<svg class="bundle-treemap-sunburst" width="${r}" height="${n}" viewBox="${`0 0 ${r} ${n}`}">${f}${y}${v}</svg>`}render(){let t=this._focusNode,r=this._mode==="sunburst",n=this._status==="ok"&&t&&t.children&&this._w>0&&this._h>0,o=[];if(n&&!r){let p=[...t.children.values()].toSorted((f,h)=>h.value-f.value);for(let f of pm(p,{x:0,y:0,w:this._w,h:this._h}))gm(f.node,f.x,f.y,f.w,f.h,1,o)}let{files:s,total:i,prefix:l}=this._meta,d=this._status==="ok"&&t?t.count:s,u=this._status==="ok"&&t?t.value:i;return c`<header class="bundle-treemap-head">${this._renderCrumbs()} <span class="bundle-treemap-head-right"><span class="bundle-treemap-sub">${d} ${d===1?"file":"files"} · ${ee(u)}${l?c`· <span class="mono">${l}</span>`:""}</span> <button type="button" class="${R({"bundle-treemap-mode-toggle":!0,on:r})}" aria-pressed="${String(r)}" aria-label="Toggle sunburst view" @click="${this._toggleMode}"><span>Sunburst</span><span class="bundle-treemap-switch" aria-hidden="true"></span></button></span></header><div class="bundle-treemap-plot" @click="${this._onPlotClick}" @pointermove="${this._onPointerMove}" @pointerleave="${this._onPointerLeave}">${this._status==="loading"?c`<div class="bundle-treemap-empty">Loading…</div>`:this._status==="empty"?c`<div class="bundle-treemap-empty">This bundle doesn't carry any source content.</div>`:r?n?this._renderSunburst(t):g:o.map(p=>this._cell(p))}<div class="bundle-treemap-tooltip"></div></div>`}};customElements.define("bundle-treemap",Ld);var $$=new TextEncoder;function Wi(e){return typeof e=="string"?$$.encode(e).byteLength:0}function bm(e){return(t,r)=>Math.abs(r.delta)-Math.abs(t.delta)||t[e].localeCompare(r[e])}function Vi(e){return(t,r)=>r.bytes-t.bytes||t[e].localeCompare(r[e])}function x$(){return{baseBytes:0,otherBytes:0,onlyBaseFiles:0,onlyOtherFiles:0,changedFiles:0}}function ym(e,t,r){let n=[],o=[],s=[],i=0,l=0,d=0,u=0,p=0,f=0,h=new Map,b=k=>{let E=r(k),S=h.get(E);return S||(S=x$(),h.set(E,S)),S},m=new Set([...e.keys(),...t.keys()]);for(let k of m){let E=e.has(k),S=t.has(k),x=b(k);if(E&&S){let T=e.get(k),N=t.get(k),Z=Wi(T),W=T===N?Z:Wi(N);if(i+=Z,l+=W,x.baseBytes+=Z,x.otherBytes+=W,T===N)f++;else{let be=W-Z;s.push({path:k,baseBytes:Z,otherBytes:W,delta:be}),p+=be,x.changedFiles++}}else if(E){let T=Wi(e.get(k));i+=T,d+=T,x.baseBytes+=T,x.onlyBaseFiles++,n.push({path:k,bytes:T})}else{let T=Wi(t.get(k));l+=T,u+=T,x.otherBytes+=T,x.onlyOtherFiles++,o.push({path:k,bytes:T})}}let y=[],v=[],w=[];for(let[k,E]of h){let S=E.baseBytes>0||E.onlyBaseFiles>0||E.changedFiles>0,x=E.otherBytes>0||E.onlyOtherFiles>0||E.changedFiles>0,T=E.onlyBaseFiles+E.onlyOtherFiles+E.changedFiles;S&&!x?y.push({pkg:k,bytes:E.baseBytes}):x&&!S?v.push({pkg:k,bytes:E.otherBytes}):(T>0||E.baseBytes!==E.otherBytes)&&w.push({pkg:k,baseBytes:E.baseBytes,otherBytes:E.otherBytes,delta:E.otherBytes-E.baseBytes})}return n.sort(Vi("path")),o.sort(Vi("path")),s.sort(bm("path")),y.sort(Vi("pkg")),v.sort(Vi("pkg")),w.sort(bm("pkg")),{totals:{baseFiles:e.size,baseBytes:i,otherFiles:t.size,otherBytes:l,onlyBaseFiles:n.length,onlyBaseBytes:d,onlyOtherFiles:o.length,onlyOtherBytes:u,changedFiles:s.length,changedDelta:p,unchangedFiles:f,fileDelta:t.size-e.size,byteDelta:l-i,identical:n.length===0&&o.length===0&&s.length===0},files:{onlyBase:n,onlyOther:o,changed:s},packages:{onlyBase:y,onlyOther:v,changed:w}}}var wm=400,Xo=null;function Pd(e){return e===0?"\xB10 B":`${e>0?"+":"\u2212"}${Math.abs(e).toLocaleString()} B`}function _$(e,t){if(!t)return"";let r=e/t*100;return`${r>0?"+":r<0?"\u2212":"\xB1"}${Math.abs(r).toFixed(1)}%`}function vm(e){return e==="__own__"?"own source":e}var Od=class extends j{static properties={details:{attribute:!1},integrity:{attribute:!1},_targetIntegrity:{state:!0},_otherDetails:{state:!0},_status:{state:!0}};createRenderRoot(){return this}constructor(){super(),this.details=null,this.integrity=null,this._targetIntegrity=null,this._otherDetails=null,this._status="idle",this._diff=null,this._diffKey=null}willUpdate(t){if(t.has("integrity")){if(Xo&&this.integrity===Xo.base){let r=Xo.target;Xo=null,this._targetIntegrity=r,this._otherDetails=null,this._status="loading",this._diff=null,this._diffKey=null,this._loadOther(r);return}this._targetIntegrity=null,this._otherDetails=null,this._status="idle",this._diff=null,this._diffKey=null}}_swap(){let t=this._targetIntegrity;!t||t===this.integrity||(a.bundles??[]).some(r=>r.integrity===t)&&(Xo={base:t,target:this.integrity},this.dispatchEvent(new CustomEvent("bundle-swap",{bubbles:!0,composed:!0,detail:{integrity:t}})))}_nameFor(t){return(a.bundles??[]).find(n=>n.integrity===t)?.name??`${t.slice(0,15)}\u2026`}_onPick(t){let r=t.target.value||null;if(this._targetIntegrity=r,this._otherDetails=null,this._diff=null,this._diffKey=null,!r){this._status="idle";return}this._status="loading",this._loadOther(r)}async _loadOther(t){let r=(a.bundles??[]).find(o=>o.integrity===t);if(!r){this._status="idle",this._targetIntegrity=null;return}let n=await kn(t,r);this._targetIntegrity===t&&(this._otherDetails=n,this._status="ready")}get _baseReady(){return!!(this.details&&this.details.integrity===this.integrity&&(this.details.json||this.details.bundle))}_fileRow(t,r,n,o){let s=c`<span class="bundle-compare-row-path mono">${r}</span>${o}`;return n?c`<li><button type="button" class="bundle-compare-row bundle-compare-row-link" data-bundle-view-source="${t}" title="${t}">${s}</button></li>`:c`<li><div class="bundle-compare-row" title="${t}">${s}</div></li>`}_fileGroup(t,r,n,o,s){if(r.length===0)return g;let i=r.slice(0,wm),l=r.length-i.length;return c`<section class="${`bundle-compare-group bundle-compare-${n}`}"><header class="bundle-compare-group-head"><span class="bundle-compare-dot" aria-hidden="true"></span> <span class="bundle-compare-group-title">${t}</span> <span class="bundle-compare-group-count">${r.length}</span></header><ul class="bundle-compare-rows">${X(i,d=>d.path,d=>{let u=d.delta===void 0?c`<span class="bundle-compare-row-size">${ee(d.bytes)}</span>`:c`<span class="bundle-compare-row-size">${ee(d.baseBytes)} → ${ee(d.otherBytes)}</span> <span class="${`bundle-compare-row-delta ${d.delta>0?"up":d.delta<0?"down":""}`}">${Pd(d.delta)}</span>`;return this._fileRow(d.path,s(d.path),o,u)})}</ul>${l>0?c`<div class="bundle-compare-more">and ${l.toLocaleString()} more…</div>`:g}</section>`}_pkgGroup(t,r,n){if(r.length===0)return g;let o=r.slice(0,wm),s=r.length-o.length;return c`<section class="${`bundle-compare-group bundle-compare-${n}`}"><header class="bundle-compare-group-head"><span class="bundle-compare-dot" aria-hidden="true"></span> <span class="bundle-compare-group-title">${t}</span> <span class="bundle-compare-group-count">${r.length}</span></header><ul class="bundle-compare-rows">${X(o,i=>i.pkg,i=>{let l=i.delta===void 0?c`<span class="bundle-compare-row-size">${ee(i.bytes)}</span>`:c`<span class="bundle-compare-row-size">${ee(i.baseBytes)} → ${ee(i.otherBytes)}</span> <span class="${`bundle-compare-row-delta ${i.delta>0?"up":i.delta<0?"down":""}`}">${Pd(i.delta)}</span>`;return c`<li><div class="bundle-compare-row" title="${vm(i.pkg)}"><span class="bundle-compare-pkg-dot" style="${pe({background:st(i.pkg)})}"></span> <span class="bundle-compare-row-path">${vm(i.pkg)}</span> ${l}</div></li>`})}</ul>${s>0?c`<div class="bundle-compare-more">and ${s.toLocaleString()} more…</div>`:g}</section>`}_diffFor(){let t=`${this.integrity}|${this._targetIntegrity}`;if(this._diffKey!==t||!this._diff){let r=He(this.details),n=He(this._otherDetails),{prefix:o}=Qe([...r.keys(),...n.keys()]),s=nr(this.details),i=nr(this._otherDetails),l=s||i?new Map([...s??[],...i??[]]):null,d=u=>it(o&&u.startsWith(o)?u.slice(o.length):u,{packageDir:l?.get(u)});this._diff=ym(r,n,d),this._diffKey=t}return this._diff}_renderSummary(t){return c`<div class="bundle-compare-summary"><div class="bundle-compare-metric"><span class="bundle-compare-metric-label">Files</span> <span class="bundle-compare-metric-value">${t.baseFiles.toLocaleString()} → ${t.otherFiles.toLocaleString()}</span> <span class="${`bundle-compare-metric-delta ${t.fileDelta>0?"up":t.fileDelta<0?"down":""}`}">${t.fileDelta===0?"\xB10":`${t.fileDelta>0?"+":"\u2212"}${Math.abs(t.fileDelta).toLocaleString()}`}</span></div><div class="bundle-compare-metric"><span class="bundle-compare-metric-label">Size</span> <span class="bundle-compare-metric-value">${ee(t.baseBytes)} → ${ee(t.otherBytes)}</span> <span class="${`bundle-compare-metric-delta ${t.byteDelta>0?"up":t.byteDelta<0?"down":""}`}">${Pd(t.byteDelta)}${(()=>{let r=_$(t.byteDelta,t.baseBytes);return r?c`${" "}<span class="bundle-compare-pct">(${r})</span>`:g})()}</span></div><div class="bundle-compare-chips"><span class="bundle-compare-chip removed">−${t.onlyBaseFiles.toLocaleString()} removed</span> <span class="bundle-compare-chip added">+${t.onlyOtherFiles.toLocaleString()} added</span> <span class="bundle-compare-chip changed">${t.changedFiles.toLocaleString()} changed</span> <span class="bundle-compare-chip unchanged">${t.unchangedFiles.toLocaleString()} unchanged</span></div></div>`}_renderPicker(t,r){let n=this._nameFor(this.integrity);return c`<div class="bundle-compare-picker"><span class="bundle-compare-base" title="${n}">${n}</span> <span class="bundle-compare-arrow" aria-hidden="true">→</span> <label class="bundle-compare-select-wrap"><span class="bundle-compare-select-hint">Compare with</span> <select class="bundle-compare-select" .value="${xe(this._targetIntegrity??"")}" @change="${o=>this._onPick(o)}" aria-label="Bundle to compare with"><option value="">Choose a bundle…</option>${t.map(o=>c`<option value="${o.integrity}">${o.label}</option>`)}</select></label> ${r?c`<button type="button" class="bundle-compare-swap" @click="${()=>this._swap()}" aria-label="Swap the two bundles"><span class="bundle-compare-swap-icon" aria-hidden="true">↔</span>Swap</button>`:g}</div>`}_otherOptions(){let t=(a.bundles??[]).filter(n=>n.integrity!==this.integrity),r=new Map;for(let n of t)r.set(n.name,(r.get(n.name)??0)+1);return t.map(n=>({integrity:n.integrity,label:r.get(n.name)>1?`${n.name} \xB7 ${n.integrity.slice(7,13)}\u2026`:n.name}))}render(){let t=this._otherOptions(),r=!!this._targetIntegrity&&t.some(i=>i.integrity===this._targetIntegrity),n=t.length>0?this._renderPicker(t,r):g,o=r&&this._status==="ready"&&this._otherDetails&&(this._otherDetails.json||this._otherDetails.bundle)&&!this._otherDetails.error,s;return this._baseReady?t.length===0?s=c`<div class="bundle-compare-empty">No other bundles to compare with. Drop a second <code>.map</code> or <code>.stasis.code.br</code> bundle to diff against this one.</div>`:r?this._status==="loading"||!this._otherDetails?s=c`<div class="bundle-compare-empty">Comparing…</div>`:this._otherDetails.error?s=c`<div class="bundle-compare-empty is-error">Couldn't read the selected bundle: ${this._otherDetails.error}</div>`:!this._otherDetails.json&&!this._otherDetails.bundle?s=c`<div class="bundle-compare-empty is-error">The selected bundle couldn't be parsed.</div>`:s=this._renderDiff():s=c`<div class="bundle-compare-empty">Pick a bundle above to compare against <strong>${this._nameFor(this.integrity)}</strong>.</div>`:s=c`<div class="bundle-compare-empty">Loading bundle…</div>`,c`<div class="bundle-compare"><header class="bundle-compare-head">${n} ${this._baseReady&&o?this._renderSummary(this._diffFor().totals):g}</header><div class="bundle-compare-body">${s}</div></div>`}_renderDiff(){let t=this._diffFor(),r=this._nameFor(this._targetIntegrity),n=this._nameFor(this.integrity),o=[...t.files.onlyBase.map(p=>p.path),...t.files.onlyOther.map(p=>p.path),...t.files.changed.map(p=>p.path)],{prefix:s,stripped:i}=Qe(o),l=new Map;for(let p=0;p<o.length;p++)l.set(o[p],i[p]);let d=p=>l.get(p)??p,u=t.packages.onlyOther.length>0||t.packages.onlyBase.length>0||t.packages.changed.length>0;return c`<div class="bundle-compare-caption">Changes from <strong>${n}</strong> to <strong>${r}</strong> ${s?c`· <span class="mono">${s}</span>`:g}</div>${t.totals.identical?c`<div class="bundle-compare-identical">These two bundles carry identical sources (${t.totals.unchangedFiles.toLocaleString()} ${t.totals.unchangedFiles===1?"file":"files"}).</div>`:c`${u?c`<section class="bundle-compare-section"><h3 class="bundle-compare-section-head">Packages</h3><div class="bundle-compare-cols">${this._pkgGroup(`Removed \xB7 only in ${n}`,t.packages.onlyBase,"removed")} ${this._pkgGroup(`Added \xB7 only in ${r}`,t.packages.onlyOther,"added")} ${this._pkgGroup("Changed size",t.packages.changed,"changed")}</div></section>`:g}<section class="bundle-compare-section"><h3 class="bundle-compare-section-head">Files</h3><div class="bundle-compare-cols bundle-compare-cols--files">${this._fileGroup(`Removed \xB7 only in ${n}`,t.files.onlyBase,"removed",!0,d)} ${this._fileGroup(`Added \xB7 only in ${r}`,t.files.onlyOther,"added",!1,d)} ${this._fileGroup("Changed",t.files.changed,"changed",!0,d)}</div></section>`}`}};customElements.define("bundle-compare",Od);var S$=c`<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path d="M6 9V2h12v7"/><path d="M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2"/><rect x="6" y="14" width="12" height="8"/></svg>`,Nd=class extends O{createRenderRoot(){return this}render(){return a.reports.length>0&&a.currentView==="findings"&&a.viewMode!=="graph"&&a.viewMode!=="kanban"?c`<button type="button" title="print this report" aria-label="print" @click="${this._onClick}">${S$}</button>`:g}_onClick=()=>{this.dispatchEvent(new CustomEvent("print-requested",{bubbles:!0,composed:!0}))}};customElements.define("print-button",Nd);var C$=c`<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" x2="12" y1="15" y2="3"/></svg>`,Dd=class extends O{createRenderRoot(){return this}render(){return a.reports.length>0&&a.currentView==="findings"&&a.viewMode!=="graph"&&a.viewMode!=="kanban"?c`<button type="button" title="download this report" aria-label="download" @click="${this._onClick}">${C$}</button>`:g}_onClick=()=>{this.dispatchEvent(new CustomEvent("download-requested",{bubbles:!0,composed:!0}))}};customElements.define("download-button",Dd);function Qo(e){let t=new Map;for(let[r,n]of a.triage)n[e]&&t.set(r,n[e]);return t}var E$={get markers(){return Qo("color")},get triageState(){return Qo("triage")},get comments(){return Qo("comment")},get fixes(){return Qo("fix")},get flags(){return Qo("flagged")},get(e){let t=a.triage.get(e),r={};return t?.color&&(r.color=t.color),t?.triage&&(r.triage=t.triage),t?.comment&&(r.comment=t.comment),t?.fix&&(r.fix=t.fix),t?.flagged!==void 0&&(r.flagged=t.flagged),r},async set(e,{color:t,triage:r,comment:n,fix:o,flagged:s}={}){let i=!1;if(t!==void 0&&(t===null||t===""?L(a.triage,e,{color:void 0})&&(i=!0):a.triage.get(e)?.color!==t&&(L(a.triage,e,{color:t}),i=!0)),r!==void 0)if(r===null||r===""||r===!1)L(a.triage,e,{triage:void 0})&&(i=!0);else if(r==="inprogress"||r==="fixed"||r==="invalid"||r==="deleted")a.triage.get(e)?.triage!==r&&(L(a.triage,e,{triage:r}),i=!0);else throw new TypeError(`DeepView.triage.set: unknown triage value ${JSON.stringify(r)} (expected 'inprogress' | 'fixed' | 'invalid' | 'deleted' | null)`);if(n!==void 0){let l=n?String(n):"";l?a.triage.get(e)?.comment!==l&&(L(a.triage,e,{comment:l}),i=!0):L(a.triage,e,{comment:void 0})&&(i=!0)}if(o!==void 0){let l=o?String(o):"";l?a.triage.get(e)?.fix!==l&&(L(a.triage,e,{fix:l}),i=!0):L(a.triage,e,{fix:void 0})&&(i=!0)}if(s!==void 0){let l=s===null||s===""?void 0:!!s;a.triage.get(e)?.flagged!==l&&(L(a.triage,e,{flagged:l}),i=!0)}return i&&(await ae(),$()),i}};window.DeepView={get reports(){return a.reports.slice()},get groups(){return Ir()},get findings(){return Ir().flat()},get currentFile(){return a.currentFile},get currentWorkspace(){return a.currentWorkspace},triage:E$,themes:Wg,setTheme:Ug,get theme(){return Hg()},triageSync:D,refresh(){$()},export(){return em()}};var A$={default:re.default,"claude-security":re["claude-security"],"codex-security":re["codex-security"],deepsec:re.deepsec,bundle:yn,workspace:pi};for(let e of document.querySelectorAll(".drop-supported-icon[data-icon]")){let t=A$[e.dataset.icon];t&&(e.innerHTML=t)}Vp($);bl($);Wp($);D.onStatusChange($);Up(async(e,t)=>{a.currentWorkspace===e?await ir(e):a.currentFile&&a.currentFile===t?await At(t):await K()});Hp(async()=>{await K(),a.currentView==="bundles"&&$()});vg();$g();async function _m(){let e=Ml();if(!e)return!1;try{history.replaceState(null,"",location.pathname)}catch{}let t;try{t=await _g({encoded:e})}catch(n){return alert(`Couldn't open the share-link unlock prompt: ${n.message}`),!1}if(!t)return!1;let r=await ul({id:t.id,name:t.name,privateKey:t.privateKeyBase64});if(r.status==="already-attached")return alert(`This workspace is already attached as "${r.workspace.name}".`),!1;if(r.status==="name-collision"){let n=r.existing?.name;return alert(n?`A workspace named "${n}" already exists. Open the share link again and pick a different name.`:"The shared workspace name is empty or invalid. Ask the sender to re-share with a real name."),!1}return r.workspace?.id?await ir(r.workspace.id):await K(),!0}var In=!1;async function Sm(){if(In||(In=!0,await jt(),il(),await K(),await _m()))return;let t=we(or);if(t)if(t.startsWith("ws:")){let r=t.slice(3);V().some(n=>n.id===r)&&await ir(r)}else if(t.startsWith("b:")){let r=t.slice(2),n=r.indexOf(" "),o=n>=0?r.slice(0,n):r,s=n>=0?r.slice(n+1):"",i=Bo.has(s)?s:"overview";(a.bundles??[]).some(l=>l.integrity===o)&&(a.currentView="bundles",a.selectedBundle=o,a.bundleDetails=null,a.bundleSourceFile=null,a.bundleSourceFindingIdx=null,a.bundleCodeSearchQuery="",a.bundleCodeSearchMode="files",a.bundleSearchQuery="",a.bundleSearchRegex=!1,a.bundleSearchCase=!1,a.bundleSearchContext=!0,a.bundleDetailsTab=i,a.shownTriage=null,C.showAll=!0,$(),Ot(o))}else(await fe()).includes(t)&&await At(t)}var km=ne(),$m=!1;function xm(e){$m||($m=!0,queueMicrotask(()=>{alert(e+" This tab will reload to refresh its state. Any unsaved edits in this tab will be lost."),location.reload()}))}ve(()=>{let e=km,t=ne();if(km=t,$(),!In&&pt()){Sm().catch(r=>console.warn("continueBoot:",r));return}if(In&&t&&!pt()){xm("Encryption was just enabled in another tab.");return}In&&e&&!t&&!ma()&&xm("Encryption was disabled in another tab.")});window.addEventListener("hashchange",()=>{In&&_m().catch(e=>console.warn("share-link hashchange:",e))});(async()=>{if(!await xg()){try{let e=window.matchMedia?.("(display-mode: window-controls-overlay)").matches;if(!e&&localStorage.getItem("deepview.sidebarCollapsed")==="1"&&_u.classList.add("collapsed"),window.matchMedia?.("(display-mode: standalone)").matches||e){let r=document.querySelector('meta[name="viewport"]');r&&r.setAttribute("content","width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"),window.addEventListener("wheel",n=>{(n.ctrlKey||n.metaKey)&&n.preventDefault()},{passive:!1}),window.addEventListener("keydown",n=>{(n.ctrlKey||n.metaKey)&&(n.key==="="||n.key==="+"||n.key==="-"||n.key==="0")&&n.preventDefault()})}}catch{}ne()&&!pt()||await Sm()}})();
96
97
  /*! Bundled license information:
97
98
 
98
99
  @lit/reactive-element/css-tag.js: