@preventive/triage 1.0.0-alpha.7 → 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,56 +1,59 @@
1
- var Bo=globalThis,Lo=Bo.ShadowRoot&&(Bo.ShadyCSS===void 0||Bo.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,pd=Symbol(),ud=new WeakMap,Mo=class{constructor(t,r,n){if(this._$cssResult$=!0,n!==pd)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(Lo&&t===void 0){let n=r!==void 0&&r.length===1;n&&(t=ud.get(r)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),n&&ud.set(r,t))}return t}toString(){return this.cssText}},A=e=>new Mo(typeof e=="string"?e:e+"",void 0,pd);var fd=(e,t)=>{if(Lo)e.adoptedStyleSheets=t.map(r=>r instanceof CSSStyleSheet?r:r.styleSheet);else for(let r of t){let n=document.createElement("style"),o=Bo.litNonce;o!==void 0&&n.setAttribute("nonce",o),n.textContent=r.cssText,e.appendChild(n)}},Ci=Lo?e=>e:e=>e instanceof CSSStyleSheet?(t=>{let r="";for(let n of t.cssRules)r+=n.cssText;return A(r)})(e):e;var{is:Ig,defineProperty:Rg,getOwnPropertyDescriptor:Fg,getOwnPropertyNames:Bg,getOwnPropertySymbols:Mg,getPrototypeOf:Lg}=Object,Po=globalThis,hd=Po.trustedTypes,Pg=hd?hd.emptyScript:"",Ng=Po.reactiveElementPolyfillSupport,gn=(e,t)=>e,Ei={toAttribute(e,t){switch(t){case Boolean:e=e?Pg: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}},md=(e,t)=>!Ig(e,t),gd={attribute:!0,type:String,converter:Ei,reflect:!1,useDefault:!1,hasChanged:md};Symbol.metadata??=Symbol("metadata"),Po.litPropertyMetadata??=new WeakMap;var Ct=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&&Rg(this.prototype,t,o)}}static getPropertyDescriptor(t,r,n){let{get:o,set:s}=Fg(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(gn("elementProperties")))return;let t=Lg(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(gn("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(gn("properties"))){let r=this.properties,n=[...Bg(r),...Mg(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(Ci(o))}else t!==void 0&&r.push(Ci(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 fd(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:Ei).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:Ei;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??md)(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){}};Ct.elementStyles=[],Ct.shadowRootOptions={mode:"open"},Ct[gn("elementProperties")]=new Map,Ct[gn("finalized")]=new Map,Ng?.({ReactiveElement:Ct}),(Po.reactiveElementVersions??=[]).push("2.1.2");var Ti=globalThis,bd=e=>e,No=Ti.trustedTypes,yd=No?No.createPolicy("lit-html",{createHTML:e=>e}):void 0,Ii="$lit$",Et=`lit$${Math.random().toFixed(9).slice(2)}$`,Ri="?"+Et,Og=`<${Ri}>`,cr=document,bn=()=>cr.createComment(""),yn=e=>e===null||typeof e!="object"&&typeof e!="function",Fi=Array.isArray,_d=e=>Fi(e)||typeof e?.[Symbol.iterator]=="function",Ai=`[
2
- \f\r]`,mn=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,wd=/-->/g,vd=/>/g,ar=RegExp(`>|${Ai}(?:([^\\s"'>=/]+)(${Ai}*=${Ai}*(?:[^
3
- \f\r"'\`<>=]|("|')|))|$)`,"g"),kd=/'/g,$d=/"/g,Sd=/^(?:script|style|textarea|title)$/i,Bi=e=>(t,...r)=>({_$litType$:e,strings:t,values:r}),c=Bi(1),nk=Bi(2),ok=Bi(3),le=Symbol.for("lit-noChange"),g=Symbol.for("lit-nothing"),xd=new WeakMap,lr=cr.createTreeWalker(cr,129);function Cd(e,t){if(!Fi(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return yd!==void 0?yd.createHTML(t):t}var Ed=(e,t)=>{let r=e.length-1,n=[],o,s=t===2?"<svg>":t===3?"<math>":"",i=mn;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===mn?p[1]==="!--"?i=wd:p[1]!==void 0?i=vd:p[2]!==void 0?(Sd.test(p[2])&&(o=RegExp("</"+p[2],"g")),i=ar):p[3]!==void 0&&(i=ar):i===ar?p[0]===">"?(i=o??mn,f=-1):p[1]===void 0?f=-2:(f=i.lastIndex-p[2].length,u=p[1],i=p[3]===void 0?ar:p[3]==='"'?$d:kd):i===$d||i===kd?i=ar:i===wd||i===vd?i=mn:(i=ar,o=void 0);let b=i===ar&&e[l+1].startsWith("/>")?" ":"";s+=i===mn?d+Og:f>=0?(n.push(u),d.slice(0,f)+Ii+d.slice(f)+Et+b):d+Et+(f===-2?l:b)}return[Cd(e,s+(e[r]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),n]},wn=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]=Ed(t,r);if(this.el=e.createElement(u,n),lr.currentNode=this.el.content,r===2||r===3){let f=this.el.content.firstChild;f.replaceWith(...f.childNodes)}for(;(o=lr.nextNode())!==null&&d.length<l;){if(o.nodeType===1){if(o.hasAttributes())for(let f of o.getAttributeNames())if(f.endsWith(Ii)){let h=p[i++],b=o.getAttribute(f).split(Et),m=/([.?@])?(.*)/.exec(h);d.push({type:1,index:s,name:m[2],strings:b,ctor:m[1]==="."?Do:m[1]==="?"?Uo:m[1]==="@"?zo:ur}),o.removeAttribute(f)}else f.startsWith(Et)&&(d.push({type:6,index:s}),o.removeAttribute(f));if(Sd.test(o.tagName)){let f=o.textContent.split(Et),h=f.length-1;if(h>0){o.textContent=No?No.emptyScript:"";for(let b=0;b<h;b++)o.append(f[b],bn()),lr.nextNode(),d.push({type:2,index:++s});o.append(f[h],bn())}}}else if(o.nodeType===8)if(o.data===Ri)d.push({type:2,index:s});else{let f=-1;for(;(f=o.data.indexOf(Et,f+1))!==-1;)d.push({type:7,index:s}),f+=Et.length-1}s++}}static createElement(t,r){let n=cr.createElement("template");return n.innerHTML=t,n}};function dr(e,t,r=e,n){if(t===le)return t;let o=n!==void 0?r._$Co?.[n]:r._$Cl,s=yn(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=dr(e,o._$AS(e,t.values),o,n)),t}var Oo=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??cr).importNode(r,!0);lr.currentNode=o;let s=lr.nextNode(),i=0,l=0,d=n[0];for(;d!==void 0;){if(i===d.index){let u;d.type===2?u=new Ir(s,s.nextSibling,this,t):d.type===1?u=new d.ctor(s,d.name,d.strings,this,t):d.type===6&&(u=new Wo(s,this,t)),this._$AV.push(u),d=n[++l]}i!==d?.index&&(s=lr.nextNode(),i++)}return lr.currentNode=cr,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++}},Ir=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=dr(this,t,r),yn(t)?t===g||t==null||t===""?(this._$AH!==g&&this._$AR(),this._$AH=g):t!==this._$AH&&t!==le&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):_d(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&&yn(this._$AH)?this._$AA.nextSibling.data=t:this.T(cr.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=wn.createElement(Cd(n.h,n.h[0]),this.options)),n);if(this._$AH?._$AD===o)this._$AH.p(r);else{let s=new Oo(o,this),i=s.u(this.options);s.p(r),this.T(i),this._$AH=s}}_$AC(t){let r=xd.get(t.strings);return r===void 0&&xd.set(t.strings,r=new wn(t)),r}k(t){Fi(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(bn()),this.O(bn()),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=bd(t).nextSibling;bd(t).remove(),t=n}}setConnected(t){this._$AM===void 0&&(this._$Cv=t,this._$AP?.(t))}},ur=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=dr(this,t,r,0),i=!yn(t)||t!==this._$AH&&t!==le,i&&(this._$AH=t);else{let l=t,d,u;for(t=s[0],d=0;d<s.length-1;d++)u=dr(this,l[n+d],r,d),u===le&&(u=this._$AH[d]),i||=!yn(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??"")}},Do=class extends ur{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===g?void 0:t}},Uo=class extends ur{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==g)}},zo=class extends ur{constructor(t,r,n,o,s){super(t,r,n,o,s),this.type=5}_$AI(t,r=this){if((t=dr(this,t,r,0)??g)===le)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)}},Wo=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){dr(this,t)}},Ad={M:Ii,P:Et,A:Ri,C:1,L:Ed,R:Oo,D:_d,V:dr,I:Ir,H:ur,N:Uo,U:zo,B:Do,F:Wo},Dg=Ti.litHtmlPolyfillSupport;Dg?.(wn,Ir),(Ti.litHtmlVersions??=[]).push("3.3.2");var W=(e,t,r)=>{let n=r?.renderBefore??t,o=n._$litPart$;if(o===void 0){let s=r?.renderBefore??null;n._$litPart$=o=new Ir(t.insertBefore(bn(),s),s,void 0,r??{})}return o._$AI(e),o};var Mi=globalThis,H=class extends Ct{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=W(r,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return le}};H._$litElement$=!0,H.finalized=!0,Mi.litElementHydrateSupport?.({LitElement:H});var Ug=Mi.litElementPolyfillSupport;Ug?.({LitElement:H});(Mi.litElementVersions??=[]).push("4.2.2");var Me={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},ft=e=>(...t)=>({_$litDirective$:e,values:t}),Qe=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=ft(class extends Qe{constructor(e){if(super(e),e.type!==Me.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 le}});var{I:zg}=Ad,Td=e=>e;var Rd=e=>e.strings===void 0,Id=()=>document.createComment(""),Rr=(e,t,r)=>{let n=e._$AA.parentNode,o=t===void 0?e._$AB:t._$AA;if(r===void 0){let s=n.insertBefore(Id(),o),i=n.insertBefore(Id(),o);r=new zg(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=Td(d).nextSibling;Td(n).insertBefore(d,o),d=u}}}return r},Nt=(e,t,r=e)=>(e._$AI(t,r),e),Wg={},Ho=(e,t=Wg)=>e._$AH=t,Fd=e=>e._$AH,jo=e=>{e._$AR(),e._$AA.remove()};var Bd=(e,t,r)=>{let n=new Map;for(let o=t;o<=r;o++)n.set(e[o],o);return n},Q=ft(class extends Qe{constructor(e){if(super(e),e.type!==Me.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=Fd(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]=Nt(o[f],s[b]),f++,b++;else if(l[h]===i[m])d[m]=Nt(o[h],s[m]),h--,m--;else if(l[f]===i[m])d[m]=Nt(o[f],s[m]),Rr(e,d[m+1],o[f]),f++,m--;else if(l[h]===i[b])d[b]=Nt(o[h],s[b]),Rr(e,o[f],o[h]),h--,b++;else if(u===void 0&&(u=Bd(i,b,m),p=Bd(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=Rr(e,o[f]);Nt(w,s[b]),d[b]=w}else d[b]=Nt(k,s[b]),Rr(e,o[f],k),o[y]=null;b++}else jo(o[h]),h--;else jo(o[f]),f++;for(;b<=m;){let y=Rr(e,d[m+1]);Nt(y,s[b]),d[b++]=y}for(;f<=h;){let y=o[f++];y!==null&&jo(y)}return this.ut=i,Ho(e,d),le}});var Md="important",Hg=" !"+Md,ve=ft(class extends Qe{constructor(e){if(super(e),e.type!==Me.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(Hg);n.includes("-")||s?r.setProperty(n,s?o.slice(0,-11):o,s?Md:""):r[n]=o}}return le}});var Oi=new WeakMap,Od=Symbol("iteration key");function jg(e){Oi.set(e,new Map)}function Vg(e,{target:t,key:r,type:n}){n==="iterate"&&(r=Od);let o=Oi.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 Kg({target:e,key:t,type:r}){let n=Oi.get(e),o=new Set;if(r==="clear"?n.forEach((s,i)=>{Li(o,n,i)}):Li(o,n,t),r==="add"||r==="delete"||r==="clear"){let s=Array.isArray(e)?"length":Od;Li(o,n,s)}return o}function Li(e,t,r){let n=t.get(r);n&&n.forEach(e.add,e)}function Dd(e){e.cleaners&&e.cleaners.forEach(Gg,e),e.cleaners=[]}function Gg(e){e.delete(this)}var Fr=[],Pi=!1;function qg(e,t,r,n){if(e.unobserved)return Reflect.apply(t,r,n);if(Fr.indexOf(e)===-1){Dd(e);try{return Fr.push(e),Reflect.apply(t,r,n)}finally{Fr.pop()}}}function ot(e){let t=Fr[Fr.length-1];t&&(Ud(t,e),Vg(t,e))}function Ot(e){Kg(e).forEach(Yg,e)}function Yg(e){Ud(e,this),typeof e.scheduler=="function"?e.scheduler(e):typeof e.scheduler=="object"?e.scheduler.add(e):e()}function Ud(e,t){if(e.debugger&&!Pi)try{Pi=!0,e.debugger(t)}finally{Pi=!1}}function zd(){return Fr.length>0}var Ld=Symbol("is reaction");function Wd(e,t={}){let r=e[Ld]?e:function n(){return qg(n,e,this,arguments)};return r.scheduler=t.scheduler,r.debugger=t.debugger,r[Ld]=!0,t.lazy||r(),r}function Di(e){e.unobserved||(e.unobserved=!0,Dd(e)),typeof e.scheduler=="object"&&e.scheduler.delete(e)}var Te=new WeakMap,Go=new WeakMap,Jg=Object.prototype.hasOwnProperty;function Ko(e){let t=Go.get(e);return zd()&&typeof e=="object"&&e!==null?t||qo(e):t||e}function Ni(e,t){let r=e.next;return e.next=()=>{let{done:n,value:o}=r.call(e);return n||(t?o[1]=Ko(o[1]):o=Ko(o)),{done:n,value:o}},e}var Pd={has(e){let t=Te.get(this),r=Reflect.getPrototypeOf(this);return ot({target:t,key:e,type:"has"}),r.has.apply(t,arguments)},get(e){let t=Te.get(this),r=Reflect.getPrototypeOf(this);return ot({target:t,key:e,type:"get"}),Ko(r.get.apply(t,arguments))},add(e){let t=Te.get(this),r=Reflect.getPrototypeOf(this),n=r.has.call(t,e),o=r.add.apply(t,arguments);return n||Ot({target:t,key:e,value:e,type:"add"}),o},set(e,t){let r=Te.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&&Ot({target:r,key:e,value:t,oldValue:s,type:"set"}):Ot({target:r,key:e,value:t,type:"add"}),i},delete(e){let t=Te.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&&Ot({target:t,key:e,oldValue:o,type:"delete"}),s},clear(){let e=Te.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&&Ot({target:e,oldTarget:n,type:"clear"}),o},forEach(e,...t){let r=Te.get(this),n=Reflect.getPrototypeOf(this);ot({target:r,type:"iterate"});let o=(s,...i)=>e(Ko(s),...i);return n.forEach.call(r,o,...t)},keys(){let e=Te.get(this),t=Reflect.getPrototypeOf(this);return ot({target:e,type:"iterate"}),t.keys.apply(e,arguments)},values(){let e=Te.get(this),t=Reflect.getPrototypeOf(this);ot({target:e,type:"iterate"});let r=t.values.apply(e,arguments);return Ni(r,!1)},entries(){let e=Te.get(this),t=Reflect.getPrototypeOf(this);ot({target:e,type:"iterate"});let r=t.entries.apply(e,arguments);return Ni(r,!0)},[Symbol.iterator](){let e=Te.get(this),t=Reflect.getPrototypeOf(this);ot({target:e,type:"iterate"});let r=t[Symbol.iterator].apply(e,arguments);return Ni(r,e instanceof Map)},get size(){let e=Te.get(this),t=Reflect.getPrototypeOf(this);return ot({target:e,type:"iterate"}),Reflect.get(t,"size",e)}},Vo={get(e,t,r){return e=Jg.call(Pd,t)?Pd:e,Reflect.get(e,t,r)}},Nd=typeof window=="object"?window:Function("return this")(),Hd=new Map([[Map,Vo],[Set,Vo],[WeakMap,Vo],[WeakSet,Vo],[Object,!1],[Array,!1],[Int8Array,!1],[Uint8Array,!1],[Uint8ClampedArray,!1],[Int16Array,!1],[Uint16Array,!1],[Int32Array,!1],[Uint32Array,!1],[Float32Array,!1],[Float64Array,!1]]);function Xg({constructor:e}){return!(typeof e=="function"&&e.name in Nd&&Nd[e.name]===e)||Hd.has(e)}function Qg(e){return Hd.get(e.constructor)}var jd=Object.prototype.hasOwnProperty,Zg=new Set(Object.getOwnPropertyNames(Symbol).map(e=>Symbol[e]).filter(e=>typeof e=="symbol"));function em(e,t,r){let n=Reflect.get(e,t,r);if(typeof t=="symbol"&&Zg.has(t))return n;ot({target:e,key:t,receiver:r,type:"get"});let o=Go.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 qo(n)}return o||n}function tm(e,t){let r=Reflect.has(e,t);return ot({target:e,key:t,type:"has"}),r}function rm(e){return ot({target:e,type:"iterate"}),Reflect.ownKeys(e)}function nm(e,t,r,n){typeof r=="object"&&r!==null&&(r=Te.get(r)||r);let o=jd.call(e,t),s=e[t],i=Reflect.set(e,t,r,n);return e!==Te.get(n)||(o?r!==s&&Ot({target:e,key:t,value:r,oldValue:s,receiver:n,type:"set"}):Ot({target:e,key:t,value:r,receiver:n,type:"add"})),i}function om(e,t){let r=jd.call(e,t),n=e[t],o=Reflect.deleteProperty(e,t);return r&&Ot({target:e,key:t,oldValue:n,type:"delete"}),o}var sm={get:em,has:tm,ownKeys:rm,set:nm,deleteProperty:om};function qo(e={}){return Te.has(e)||!Xg(e)?e:Go.get(e)||im(e)}function im(e){let t=Qg(e)||sm,r=new Proxy(e,t);return Go.set(e,r),Te.set(r,e),jg(e),r}var Vd=qo;function Ui(e){let t=!0,r=Wd(()=>{try{e(t)}finally{t=!1}},{lazy:!0});try{r()}catch(n){throw Di(r),n}return()=>Di(r)}var P=class extends H{_disposers=[];observes=null;connectedCallback(){super.connectedCallback(),this.bindState()}bindState(){if(this.observes){this._disposers.push(Ui(t=>{this.observes(),t||this.requestUpdate()}));return}this._render||(this._render=this.render,this.render=()=>{let t,r=Ui(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:W,unsafeCSS:A,StateElement:P,classMap:R,repeat:Q,styleMap:ve};var Ie=document.querySelector("#drop-zone"),C=document.querySelector("#report"),Kd=document.querySelector("app-sidebar");function Br(e,t){let r=URL.createObjectURL(e),n=document.createElement("span");n.style.display="none",W(c`<a href="${r}" download="${t}"></a>`,n),document.body.append(n),n.firstElementChild.click(),n.remove(),URL.revokeObjectURL(r)}function ht(e){return new Error("Another dialog is already open. Close it and try again.",{cause:e})}function qd(e){let t=e?.package?.npm?.version;if(typeof t=="string"&&t)return t;let r=e?.file;if(!r)return null;let n=/(?:^|\/)node_modules\/\.pnpm\/([^/]+)\/node_modules\//u.exec(r);if(!n)return null;let o=n[1],s=o.indexOf("_");s>0&&(o=o.slice(0,s));let i=o.lastIndexOf("@");return i<=0?null:o.slice(i+1)||null}function Yo(){return{keys:new Set,findings:[],files:new Map,reports:new Set,_keyReports:new Map}}function Jo(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 Xo(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 Qo(e){let t=new Set;for(let r of e._keyReports.values())for(let n of r)t.add(n);e.reports=t}function Yd(e,t,r,n,o){let s=e.byVersion.get(t);s||(s=Yo(),e.byVersion.set(t,s)),Jo(s,n,o,r)}function Jd(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&&Xo(i,r,n,s)),i._keyReports.size===0){e.byVersion.delete(t);return}Qo(i)}function zi(e,t){if(e===t)return 0;if(e===null)return 1;if(t===null)return-1;let[r,n=""]=Gd(e,"-"),[o,s=""]=Gd(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 Gd(e,t){let r=e.indexOf(t);return r<0?[e,""]:[e.slice(0,r),e.slice(r+1)]}var am=new TextEncoder,lm=new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});function q(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 am.encode(e)}function ue(e){if(!ArrayBuffer.isView(e)&&!(e instanceof ArrayBuffer))throw new TypeError(`decodeUtf8 expects a BufferSource, got ${e===null?"null":typeof e}`);return lm.decode(e)}async function vn(e){let t=new Blob([e]).stream().pipeThrough(new CompressionStream("gzip"));return new Uint8Array(await new Response(t).arrayBuffer())}async function gt(e){let t=new Blob([e]).stream().pipeThrough(new DecompressionStream("gzip"));return new Uint8Array(await new Response(t).arrayBuffer())}async function Zo(e){return await vn(q(e))}async function kn(e){return ue(await gt(e))}async function Xd(e){let t=await crypto.subtle.digest("SHA-512",e);return`sha512-${new Uint8Array(t).toBase64()}`}var st=new Uint8Array([68,86,69,49]),Mr=12,cm=32,dm="deepview-passkey.v1.content-key";function $n(){return!(typeof window>"u"||typeof PublicKeyCredential>"u"||typeof navigator>"u"||!navigator.credentials)}async function Qd(){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 es(e){let t=new Uint8Array(e);return crypto.getRandomValues(t),t}async function Wi(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:q(dm)},t,cm*8);return new Uint8Array(r)}function Hi(e){return crypto.subtle.importKey("raw",e,{name:"AES-GCM"},!1,["encrypt","decrypt"])}async function Dt(e,t,r){let n=es(Mr),o=new Uint8Array(await crypto.subtle.encrypt({name:"AES-GCM",iv:n,additionalData:r},e,t)),s=new Uint8Array(st.length+Mr+o.length);return s.set(st,0),s.set(n,st.length),s.set(o,st.length+Mr),s}async function pr(e,t,r){if(!Oe(t))throw new Error("passkey: missing envelope magic");if(t.length<st.length+Mr+16)throw new Error("passkey: envelope too short");let n=t.subarray(st.length,st.length+Mr),o=t.subarray(st.length+Mr);return new Uint8Array(await crypto.subtle.decrypt({name:"AES-GCM",iv:n,additionalData:r},e,o))}function Oe(e){if(e.length<st.length)return!1;for(let t=0;t<st.length;t++)if(e[t]!==st[t])return!1;return!0}async function Zd(e){if(!$n())throw new Error("passkey: not supported in this environment");let t=es(32),r=es(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 ji(e){if(!$n())throw new Error("passkey: not supported in this environment");let t=es(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 xn=Object.freeze(["deepview.workspaces","deepview.sync.sessions","deepview.sync.userEnabled","deepview.sync.password","deepview.repoUrls","deepview.fileCounts","deepview.lastFile"]),Le=new Map,rs=!1,At=new Map,Ze=new Map,ts=new Set;function Lr(e){let t=()=>e();return ts.add(t),rs&&queueMicrotask(()=>{if(ts.has(t))try{t()}catch(r){console.warn("secure-storage after-hydrate listener:",r)}}),()=>ts.delete(t)}function um(){for(let e of ts)try{e()}catch(t){console.warn("secure-storage after-hydrate listener:",t)}}function ns(e){let t=nu()??"";return q(`deepview.secure.v1|${t}|${e}`)}function Vi(e){try{let t=Uint8Array.fromBase64(e);if(Oe(t))return t}catch{}return null}function he(e){return Le.get(e)??null}async function ke(e,t){if(typeof t!="string")throw new TypeError("secure-storage: value must be a string");if(Z()&&!$e())throw new Error(`secure-storage: vault locked, cannot save "${e}"`);if(ru())throw new Error(`secure-storage: wipe in progress, cannot save "${e}"`);let r=Le.has(e),n=Le.get(e);Le.set(e,t),Ze.set(e,t);let o=At.get(e)??Promise.resolve(),s=()=>{Ze.get(e)===t&&Ze.delete(e)},i=o.catch(()=>{}).then(()=>pm(e,t)).then(()=>s(),l=>{throw s(),Le.get(e)===t&&(r?Le.set(e,n):Le.delete(e)),l});At.set(e,i.catch(()=>{})),await i}async function Pr(e){let t=Symbol("secure-storage:removed");Le.delete(e),Ze.set(e,t);let r=At.get(e)??Promise.resolve(),n=()=>{try{localStorage.removeItem(e)}catch{}Ze.get(e)===t&&(Ze.delete(e),Le.delete(e))},o=r.catch(()=>{}).then(()=>n());At.set(e,o.catch(()=>{})),await o}async function pm(e,t){let r=$e();if(r){let n=await Dt(r,q(t),ns(e));localStorage.setItem(e,n.toBase64())}else localStorage.setItem(e,t)}async function Ut(){rs||ge(()=>{Ut().catch(r=>console.warn("secure-storage rehydrate:",r))}),rs=!0;for(let r of[...Le.keys()])Ze.has(r)||Le.delete(r);let e=$e(),t=[];for(let r of xn){if(Ze.has(r))continue;let n=localStorage.getItem(r);if(n===null)continue;let o=Vi(n);if(o){if(!e)continue;try{let s=await pr(e,o,ns(r));if(Ze.has(r))continue;Le.set(r,ue(s))}catch(s){console.warn(`secure-storage: decrypt failed for "${r}":`,s)}}else Le.set(r,n),e&&Z()&&t.push([r,n])}um(),t.length>0&&queueMicrotask(()=>{for(let[r,n]of t)Le.get(r)===n&&ke(r,n).catch(o=>{console.warn(`secure-storage: self-heal failed for "${r}":`,o)})})}async function eu(e,t){let r=At.get(e)??Promise.resolve(),n=async()=>{if(Ze.has(e))return;let s=localStorage.getItem(e);if(s===null)return;let i=await t(s);i!==null&&(Ze.has(e)||(localStorage.setItem(e,i.storageValue),Le.set(e,i.cacheValue)))},o=r.catch(()=>{}).then(n);At.set(e,o.catch(()=>{})),await o}async function Ki({seal:e}){for(let t of xn)await eu(t,async r=>{if(Vi(r))return null;let n=$e();return n?{storageValue:(await Dt(n,q(r),ns(t))).toBase64(),cacheValue:r}:null})}async function Gi({open:e}){for(let t of xn)await eu(t,async r=>{let n=Vi(r);if(!n)return null;let o=await e(n,ns(t)),s=ue(o);return{storageValue:s,cacheValue:s}})}var fm="deepview.secure.v1.mutate:";function qi(e,t){return xn.includes(e)?navigator.locks.request(fm+e,async()=>{let r=At.get(e);r&&await r.catch(()=>{}),await Ut();let n=he(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 ke(e,o)}}):Promise.reject(new Error(`secure-storage: mutate() called with non-secure key "${e}"`))}async function tu(){await Promise.allSettled([...At.values()]),Ze.clear(),At.clear()}typeof window<"u"&&window.addEventListener("storage",e=>{!rs||!e.key||!xn.includes(e.key)||Ut().catch(()=>{})});var Cn="deepview.passkey.v1",Nr="deepview.passkey.userId",ss="deepview.passkey.cleanDisable",et="deepview.passkey.v1.write",gm="deepview.triage.v1|",mm="deepview.opfs.v1|",bm="deepview.bundle.v1|",ee=null,mt=null,zt=null,Sn=0;function Xi(){return Sn>0}var Yi=0;function ru(){return Yi>0}function fr(){try{let e=localStorage.getItem(Cn);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 ou(e){localStorage.setItem(Cn,JSON.stringify(e))}function ym(){localStorage.removeItem(Cn)}function wm(){try{let t=localStorage.getItem(Nr);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(Nr,e.toBase64({alphabet:"base64url",omitPadding:!0}))}catch{}return e}function is(){return typeof location>"u"?"":location.hostname}function Z(){return fr()!==null}function it(){return ee!==null}function bt(){return!(!$n()||typeof navigator>"u"||!navigator.locks?.request||!is())}function nu(){return mt}function En(){if(fr()!==null)return!1;try{return localStorage.getItem(ss)==="1"?!1:localStorage.getItem(Nr)!==null}catch{return!1}}function $e(){return ee}function An(){return q(gm+(mt??""))}function as(e){if(typeof e!="string")throw new TypeError("passkey vault: OPFS AAD requires a filename string");return q(mm+(mt??"")+"|"+e)}function ls(e){if(typeof e!="string")throw new TypeError("passkey vault: bundle AAD requires a slot string");return q(bm+(mt??"")+"|"+e)}var Ji=new Set;function ge(e){return Ji.add(e),()=>Ji.delete(e)}function Or(){for(let e of Ji)try{e()}catch(t){console.warn("passkey vault listener:",t)}}async function Tn({signal:e}={}){let t=fr();if(!t)return!1;let r;try{r=await ji({credentialId:t.credentialId,prfSalt:t.prfSalt,rpId:t.rpId??is(),...e?{signal:e}:{}})}catch(o){if(o&&o.name==="NotAllowedError"||o&&o.name==="AbortError")return!1;throw o&&o.message?.includes("PRF")?_n(o):o}if(!r||r.length<32)throw _n();let n=await Wi(r);return r.fill(0),navigator.locks.request(et,async()=>{let o=fr();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 Hi(n),n.fill(0),mt=o.userId,zt=o.credentialId,Or(),!0})}function _n(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 Qi({migrate:e,userName:t,rpName:r,signal:n,acknowledgeOrphan:o}){if(!$n())throw new Error("passkey: WebAuthn unavailable in this environment");if(En()&&!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=is();return navigator.locks.request(et,async()=>{if(Z())throw new Error("passkey: encryption is already enabled");if(await Qd()===!1)throw _n();let l=wm(),d=await Zd({userName:t||"DeepView user",userId:l,rpName:r||"DeepView",rpId:s,...n?{signal:n}:{}}),u=d.prfOutput;if(!u)try{u=await ji({credentialId:d.credentialId,prfSalt:d.prfSalt,rpId:s,...n?{signal:n}:{}})}catch(m){let y=l.toBase64({alphabet:"base64url",omitPadding:!0});await os({credentialId:d.credentialId,rpId:s,userId:y}).catch(()=>{});try{localStorage.removeItem(Nr)}catch{}throw m&&m.message?.includes("PRF")?_n(m):m}if(!u||u.length<32){let m=l.toBase64({alphabet:"base64url",omitPadding:!0});await os({credentialId:d.credentialId,rpId:s,userId:m}).catch(()=>{});try{localStorage.removeItem(Nr)}catch{}throw _n()}let p=await Wi(u);u.fill(0);let f=await Hi(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,mt=h,zt=d.credentialId,ou(b),typeof e=="function"&&await e({seal:(y,k)=>Dt(f,y,k)});try{localStorage.removeItem(ss)}catch{}return Or(),!0})}async function Zi({migrate:e}){if(!Z())return{disabled:!1,signalAttempted:!1};if(!it())throw new Error("passkey: must unlock before disabling encryption");Sn+=1;try{return await navigator.locks.request(et,async()=>{let t=fr();if(!t)return{disabled:!1,signalAttempted:!1};let r=ee;if(!r)return{disabled:!1,signalAttempted:!1};if(ym(),ee=null,zt=null,typeof e=="function"){let o=(s,i)=>pr(r,s,i);try{await e({open:o})}catch(s){throw ou(t),ee=r,zt=t.credentialId,Or(),s}}mt=null;try{localStorage.setItem(ss,"1")}catch{}let n=await os(t).catch(()=>!1);return Or(),{disabled:!0,signalAttempted:n}})}finally{Sn-=1}}async function os({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 vm(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 km(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 vm(r,n);o&&t.push(o)}return t}async function In({refuseIfEnabled:e=!1}={}){Sn+=1,Yi+=1;try{return await navigator.locks.request(et,async()=>{if(e&&Z())throw new Error("passkey: encryption was just enabled in another tab. Reload this page to unlock instead of wiping.");await tu();let t=fr();if(t)try{await os({credentialId:t.credentialId,rpId:t.rpId??is(),userId:t.userId})}catch{}try{localStorage.removeItem(Cn)}catch{}try{localStorage.removeItem(Nr)}catch{}try{localStorage.removeItem(ss)}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,mt=null,zt=null,Or();let r=await km(["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{Sn-=1,Yi-=1}}function su(e){return ee?Dt(ee,e,An()):Promise.reject(new Error("passkey: vault locked, cannot seal triage"))}function iu(e){return ee?pr(ee,e,An()):Promise.reject(new Error("passkey: vault locked, cannot open triage"))}function cs(e,t){return ee?Dt(ee,e,as(t)):Promise.reject(new Error("passkey: vault locked, cannot seal OPFS file"))}function au(e,t){return ee?pr(ee,e,as(t)):Promise.reject(new Error("passkey: vault locked, cannot open OPFS file"))}function ea(e,t){return ee?Dt(ee,e,ls(t)):Promise.reject(new Error("passkey: vault locked, cannot seal bundle"))}function ta(e,t){return ee?pr(ee,e,ls(t)):Promise.reject(new Error("passkey: vault locked, cannot open bundle"))}typeof window<"u"&&window.addEventListener("storage",e=>{if(e.key!==Cn)return;let t=fr();(!t&&ee||t&&ee&&t.credentialId!==zt)&&(ee=null,mt=null,zt=null),Or()});var sa="__meta__",$m="deepview-reports",ia="deepview-bundles",Tt="deepview.report:",lu=!1;async function aa(e,{create:t,warnOnce:r=!1}={}){try{return await(await navigator.storage.getDirectory()).getDirectoryHandle(e,{create:t})}catch(n){return r&&!lu&&(lu=!0,console.warn("OPFS unavailable, falling back to gzipped localStorage (limited quota).",n)),null}}async function ds(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 ra(e,t){if(!Oe(e))return e;if(!$e())throw new Error(`storage: vault locked, cannot decrypt "${t}"`);return await au(e,t)}async function Rn(e,t,r,n,o=()=>{}){if(Z()&&!$e())throw o(),new Error(`storage: vault locked, cannot save ${n}`);let s=$e(),i=s?await t(e,r):e;if($e()!==s)throw o(),new Error(`storage: vault state changed mid-save for ${n}; retry`);return i}function hr(){return aa($m,{create:!0,warnOnce:!0})}var at=new Map,Wt=new Map,na=new Map;function oe(e){na.set(e,(na.get(e)??0)+1)}function cu(e){return na.get(e)??0}var oa=new Set;function du(e){return oa.add(e),()=>oa.delete(e)}function Dr(e,t){for(let r of oa)try{r(e,t)}catch(n){console.warn("storage file-change listener:",n)}}async function ce(){let e=await hr();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(Tt)&&t.push(n.slice(Tt.length))}return t.toSorted()}async function lt(e,t){if(typeof e!="string"||e.includes("\0"))throw new Error("Invalid report name: contains NUL byte or is not a string");return oe(e),navigator.locks.request(et,{mode:"shared"},async()=>{let r=await hr();if(r){let s=await vn(q(t));s=await Rn(s,cs,e,`"${e}"`,()=>oe(e));let l=await(await r.getFileHandle(e,{create:!0})).createWritable();try{await l.write(s),await l.close()}catch(d){at.delete(e),oe(e);try{await l.abort(d)}catch{}throw d}at.set(e,t),oe(e),Dr(e,"save");return}let n=q(t);n=await vn(n),n=await Rn(n,cs,e,`"${e}"`,()=>oe(e));let o=n.toBase64();try{localStorage.setItem(Tt+e,o),at.set(e,t),oe(e),Dr(e,"save")}catch(s){throw oe(e),new Error(`localStorage write failed for ${e}: ${s.message}`,{cause:s})}})}async function Pe(e){if(at.has(e))return at.get(e);if(Wt.has(e))return Wt.get(e);let t=cu(e),r=(async()=>{let n=await hr();if(n){let d=await(await n.getFileHandle(e)).getFile(),u=new Uint8Array(await d.arrayBuffer());if(u=await ra(u,e),u.length>=2&&u[0]===31&&u[1]===139){let f=await gt(u);return ue(f)}let p=ue(u);return lt(e,p).catch(f=>{console.warn(`storage: legacy-uncompressed migration of "${e}" failed:`,f)}),p}let o=localStorage.getItem(Tt+e);if(o===null)throw new Error(`File not found: ${e}`);let s=Uint8Array.fromBase64(o);s=await ra(s,e);let i=await gt(s);return ue(i)})();Wt.set(e,r);try{let n=await r;return cu(e)===t&&at.set(e,n),n}finally{Wt.delete(e)}}async function gr(e){let t=await hr(),r;if(t){let o=await(await t.getFileHandle(e)).getFile();r=new Uint8Array(await o.arrayBuffer())}else{let n=localStorage.getItem(Tt+e);if(n===null)throw new Error(`File not found: ${e}`);r=Uint8Array.fromBase64(n)}return r=await ra(r,e),r}async function Bn(e,t){if(typeof e!="string"||e.includes("\0"))throw new Error("Invalid report name: contains NUL byte or is not a string");return oe(e),at.delete(e),navigator.locks.request(et,{mode:"shared"},async()=>{let r=await Rn(t,cs,e,`"${e}"`,()=>oe(e)),n=await hr();if(n){let s=await(await n.getFileHandle(e,{create:!0})).createWritable();try{await s.write(r),await s.close()}catch(i){oe(e);try{await s.abort(i)}catch{}throw i}oe(e),Dr(e,"save");return}try{localStorage.setItem(Tt+e,r.toBase64()),oe(e),Dr(e,"save")}catch(o){throw oe(e),new Error(`localStorage write failed for ${e}: ${o.message}`,{cause:o})}})}async function Ur(e){return oe(e),at.delete(e),Wt.delete(e),navigator.locks.request(et,{mode:"shared"},async()=>{let t=await hr();if(t){try{await t.removeEntry(e)}catch(r){if(!(r instanceof DOMException)||r.name!=="NotFoundError")throw oe(e),r}oe(e),Dr(e,"delete");return}localStorage.removeItem(Tt+e),oe(e),Dr(e,"delete")})}var Fn="_meta.json";function Mn(){return aa(ia,{create:!0})}function la(e){return e.replaceAll("/","_")}async function ca(e){let t;try{let o=await(await e.getFileHandle(Fn)).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(Oe(t)){if(!$e())return console.warn("readBundleMeta: vault locked, returning empty bundle list"),[];try{r=await ta(t,sa)}catch(o){return console.warn("readBundleMeta: decrypt failed (tampering, key mismatch, or vault identity drift):",o),[]}}try{let n=JSON.parse(ue(r));return Array.isArray(n)?n:[]}catch(n){return console.warn("readBundleMeta: JSON.parse failed:",n),[]}}async function uu(e,t){let r=q(JSON.stringify(t));r=await Rn(r,ea,sa,"bundle metadata");try{await e.removeEntry(Fn)}catch{}let n=await e.getFileHandle(Fn,{create:!0});await ds(n,r)}var xm=`${ia}/${Fn}`;function pu(e){return navigator.locks.request(xm,e)}async function ct(){let e=await Mn();return e?[...await ca(e)].toSorted((r,n)=>r.name.localeCompare(n.name)):[]}async function da(){if(typeof navigator>"u"||!navigator.storage?.getDirectory)return!1;let e=await aa(ia,{create:!1});if(!e)return!1;try{for await(let t of e.entries())return!0}catch{}return!1}async function mr(e,t){let r=await Mn();if(!r)throw new Error(`Cannot save bundle ${e}: OPFS unavailable`);let n=t instanceof Uint8Array?t:q(t),o=await Xd(n),s=la(o),i=e.toLowerCase().endsWith(".map")?await vn(n):n;return navigator.locks.request(et,{mode:"shared"},async()=>{i=await Rn(i,ea,o,`bundle "${e}"`);try{await r.removeEntry(s)}catch{}let l=await r.getFileHandle(s,{create:!0});await ds(l,i);try{await pu(async()=>{let d=await ca(r),u=d.findIndex(p=>p.integrity===o);u>=0?d[u]={integrity:o,name:e}:d.push({integrity:o,name:e}),await uu(r,d)})}catch(d){try{await r.removeEntry(s)}catch{}throw d}return{integrity:o,name:e}})}async function ua(e){let t=await Mn();if(t)return navigator.locks.request(et,{mode:"shared"},async()=>{try{await t.removeEntry(la(e))}catch(r){if(!(r instanceof DOMException)||r.name!=="NotFoundError")throw r}await pu(async()=>{let r=await ca(t),n=r.filter(o=>o.integrity!==e);n.length!==r.length&&await uu(t,n)})})}async function br(e){let t=await Mn();if(!t)throw new Error("OPFS unavailable");let n=await(await t.getFileHandle(la(e))).getFile(),o=new Uint8Array(await n.arrayBuffer());if(Oe(o)){if(!$e())throw new Error(`storage: vault locked, cannot read bundle "${e}"`);o=await ta(o,e)}return o.length>=2&&o[0]===31&&o[1]===139?await gt(o):o}async function _m(e,t){let r=await hr();if(r){let l=await(await r.getFileHandle(e)).getFile(),d=new Uint8Array(await l.arrayBuffer()),u=await t(d);if(u===null)return;at.delete(e),Wt.delete(e),oe(e);let p=await r.getFileHandle(e,{create:!0});await ds(p,u),oe(e);return}let n=localStorage.getItem(Tt+e);if(n===null)return;let o=Uint8Array.fromBase64(n),s=await t(o);s!==null&&(at.delete(e),Wt.delete(e),oe(e),localStorage.setItem(Tt+e,s.toBase64()),oe(e))}function fu(e,t){return e.seal?r=>Oe(r)?null:e.seal(r,t):r=>Oe(r)?e.open(r,t):null}async function hu(e){let t=await ce();for(let r of t)try{await _m(r,fu(e,as(r)))}catch(n){if(n instanceof DOMException&&n.name==="NotFoundError")continue;throw n}}var pa=({seal:e})=>hu({seal:e}),fa=({open:e})=>hu({open:e});async function Sm(){let e=await Mn();if(!e)return{dir:null,keys:[]};let t=[];for await(let[r]of e.entries())t.push(r);return{dir:e,keys:t}}function Cm(e){return e===Fn?sa:e.startsWith("sha512-")?e.replaceAll("_","/"):null}async function Em(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 ds(l,i)}async function gu(e){let{dir:t,keys:r}=await Sm();if(t)for(let n of r){let o=Cm(n);if(o!==null)try{await Em(t,n,fu(e,ls(o)))}catch(s){if(s instanceof DOMException&&s.name==="NotFoundError")continue;throw s}}}var ha=({seal:e})=>gu({seal:e}),ga=({open:e})=>gu({open:e});ge(()=>{at.clear(),Wt.clear()});var ps="deepview.viewMode",us="deepview.repoUrls",Am=new Set(["grouped","list","table","kanban","focus"]);function Tm(){try{let e=localStorage.getItem(ps);return e!==null&&Am.has(e)?e:null}catch{return null}}function ba(e){try{let t=JSON.parse(e||"{}");return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}catch{return{}}}function fs(){return ba(he(us))}function Ve(e){return e?fs()[e]??"":""}var ma=new Set;function mu(e){return ma.add(e),()=>{ma.delete(e)}}function Im(e){for(let t of ma)try{t(e)}catch(r){console.warn("repo-url listener:",r)}}function Ke(e,t){if(!e)return;let r=fs();t?r[e]=t:delete r[e],ke(us,JSON.stringify(r)).catch(n=>console.warn("saveRepoUrlFor:",n)),qi(us,n=>{let o=ba(n);return t?o[e]=t:delete o[e],JSON.stringify(o)}).catch(n=>console.warn("saveRepoUrlFor cross-tab merge:",n)),Im(e)}async function bu(e,t){await qi(us,r=>{let n=ba(r),o=t==="replace"?{...e}:t==="prefer-imported"?{...n,...e}:{...e,...n};return JSON.stringify(o)}),yu()}var a=Vd({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:"",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:Tm()??"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 yu(){a.repoEditing||a.currentFile&&(a.repoUrl=Ve(a.currentFile))}Lr(()=>{yu()});var Rm=/^## ([A-Z][A-Z_]*)\s*\(\d+\)\s*$/mu;function Fm(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 Bm(e){if(e)switch(e.toLowerCase()){case"high":return 8;case"medium":return 5;case"low":return 2;default:return}}function Mm(e){return typeof e=="string"?e.replace(/^`(.*)`$/u,"$1"):e}function zr(e){let t=e.replaceAll(/\r\n?/gu,`
4
- `).trim();if(!Rm.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=Fm(r[o]),l=(r[o+1]||"").split(/^### /mu).slice(1);for(let d of l){let u=Lm(d,s);u&&n.push(u)}}return n.length===0?null:{type:"security",source:"deepsec",findings:n}}function Lm(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=Mm(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=Bm(s.confidence);return m!==void 0&&(b.confidence=m),s.slug&&(b.slug=s.slug),b}var Pm=new Set(["critical","high","medium","low","high_bug","bug","informational"]);function Wr(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=Nm(s);i&&n.push(i)}return n.length===0?null:{type:n.find(s=>s.type)?.type||"analysis",source:"claude-security",findings:n}}function Nm(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}=Om(n),i=Dm(o),l=Um(s),{file:d,line:u,locationLink:p}=zm(i.location||""),f=(l.severity||"").toLowerCase(),h=Pm.has(f)?f:"medium",b=Wm(r,i),m=i["recommended fix"]?wu(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 Om(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 Dm(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 Um(e){let t={};for(let r of e.matchAll(/\*\*([^:]+):\*\*\s*(.+)/gu))t[r[1].trim().toLowerCase()]=r[2].trim();return t}function zm(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 Wm(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"]}`),wu(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 wu(e){return e.replaceAll("**","")}function Hm(e){return Array.from(e,t=>t.toString(16).padStart(2,"0")).join("")}function jm(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCodePoint(e[r]);return btoa(t)}async function vu(e){let t=typeof e=="string"?q(e):e,r=await crypto.subtle.digest("SHA-512",t);return`sha512-${jm(new Uint8Array(r))}`}async function Vm(e){let t=q(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=Hm(n);return`${o.slice(0,8)}-${o.slice(8,12)}-${o.slice(12,16)}-${o.slice(16,20)}-${o.slice(20,32)}`}async function hs(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 Vm(t)}catch{return null}}function Ht(e){try{return JSON.parse(e)}catch{return zr(e)??Wr(e)}}function jt(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 Hr(e){let t=e.filter(n=>n&&!n.id);if(t.length===0)return;let r=await Promise.all(t.map(hs));t.forEach((n,o)=>{r[o]&&(n.id=r[o])})}var jr=new Map,Vr=new Map,Kr=new Map,gs=new Map;function Km(e){if(typeof e?.package?.npm?.name=="string"&&e.package.npm.name)return e.package.npm.name;if(!e?.file)return null;let t=/(?:^|\/)(?:node_modules|dependencies)\/(@[^/]+\/[^/]+|[^/]+)/gu,r;for(;(r=t.exec(e.file))!==null;)if(r[1]!==".pnpm")return r[1];return null}function Gm(e){return typeof e?.file!="string"?!1:/(?:^|\/)(?:node_modules|dependencies)\//u.test(e.file)}function qm(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 Pn=new Set,ya=new Set,Ln=null,wa=!1;function va(e){return ya.add(e),()=>ya.delete(e)}function ka(){for(let e of ya)try{e()}catch{}}function ms(e){return jr.get(e)?.list??[]}function yt(){return Vr}function yr(){return Kr}function Nn(e,t){let r=jr.get(e);if(!r)return[];let n=r.reports.get(Vt(t));return n?[...n]:[]}function $a(e,t){let r=Vr.get(e);if(!r)return[];let n=r._keyReports.get(Vt(t));return n?[...n]:[]}function xa(e,t){let r=Kr.get(e);if(!r)return[];let n=r._keyReports.get(Vt(t));return n?[...n]:[]}var ku=["type","model","think","effort","exportsMode"];function Ym(e,t){if(!ku.some(r=>e[r]!==void 0))for(let r of ku)t[r]!==void 0&&(e[r]=t[r])}function Jm(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 jt(t))r&&Ym(o,e),n.push(o);return n}function Vt(e){return e.id?`id:${e.id}`:`c:${e.severity??""}|${e.description??""}|${e.file??""}|${e.line??""}`}function _a(e,t,r){let n=gs.get(e);n||(n={hash:[],pkg:[],repo:[]},gs.set(e,n)),n[t].push(r)}function Xm(e,t,r){let n=jr.get(e.fileHash);n||(n={keys:new Set,list:[],reports:new Map},jr.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&&_a(r,"hash",{hash:e.fileHash,key:t}),n.keys.has(t)?s:(n.keys.add(t),n.list.push(e),!0)}function Qm(e,t,r){let n=Km(e);if(!n)return!1;let o=qd(e),s=Vr.get(n);if(s||(s={...Yo(),repos:new Set,byVersion:new Map,_repoReports:new Map},Vr.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)}Yd(s,o,e,t,r);let i=Jo(s,t,r,e);return _a(r,"pkg",{pkg:n,key:t,file:e.file,version:o}),i}function Zm(e,t,r,n){if(Gm(e))return!1;let o=qm(e,n);if(!o)return!1;let s=Kr.get(o);s||(s=Yo(),Kr.set(o,s));let i=Jo(s,t,r,e);return i&&_a(r,"repo",{repo:o,key:t,file:e.file}),i}function Sa(e){let t=gs.get(e);if(gs.delete(e),Pn.delete(e),!t)return!1;let r=!1;for(let{hash:o,key:s}of t.hash){let i=jr.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=>Vt(u)===s);d>=0&&i.list.splice(d,1)}i.keys.size===0&&jr.delete(o)}}let n=new Set;for(let{pkg:o,key:s,file:i,version:l}of t.pkg){let d=Vr.get(o);if(!d)continue;let u=d._keyReports.get(s);if(u){if(u.delete(e)&&(r=!0),u.size===0&&Xo(d,s,i,Vt),Jd(d,l,s,i,e,Vt),!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?Vr.delete(o):Qo(d)}}for(let{repo:o,key:s,file:i}of t.repo){let l=Kr.get(o);if(!l)continue;let d=l._keyReports.get(s);d&&(d.delete(e)&&(r=!0),d.size===0&&Xo(l,s,i,Vt),l._keyReports.size===0?Kr.delete(o):Qo(l))}return r}async function eb(e){if(Pn.has(e))return!1;Pn.add(e);try{let t=await Pe(e),r=Ht(t);if(!r)return!1;let n=Jm(r);if(n.length===0)return!1;let o="";try{o=Ve(e)}catch{}let s=!1;for(let i of n){let l=Vt(i);i.fileHash&&Xm(i,l,e)&&(s=!0),i.file&&Qm(i,l,e)&&(s=!0),i.file&&Zm(i,l,e,o)&&(s=!0)}return Pn.has(e)?s:(Sa(e),wa=!0,!1)}catch{return Pn.delete(e),!1}}function wt(){return Ln||(Ln=(async()=>{try{do{wa=!1;let e=await ce();for(let t of e)await eb(t)&&ka()}while(wa)}finally{Ln=null}})(),Ln)}du(e=>{Sa(e)&&ka()});mu(e=>{Sa(e)&&ka(),wt().catch(()=>{})});var On=new Map,Dn=new Map;function bs(e,t){if(!e||!t)return!1;let r=!Dn.has(e);Dn.set(e,t);for(let[n,o]of t){if(!o)continue;let s=On.get(o);s||(s=new Map,On.set(o,s)),s.set(e,n)}return r}function Ca(e){let t=Dn.get(e);if(Dn.delete(e),!!t)for(let r of t.values()){let n=On.get(r);n&&(n.delete(e),n.size===0&&On.delete(r))}}function wr(e){if(!e)return[];let t=On.get(e);if(!t)return[];let r=[];for(let[n,o]of t)r.push({integrity:n,file:o});return r}function Ea(e){return Dn.has(e)}var $u="deepview.fileCounts",qr=null;function ws(){if(qr)return qr;try{qr=JSON.parse(he($u)||"{}")}catch{qr={}}return qr}function Aa(){ke($u,JSON.stringify(qr)).catch(e=>console.warn("counts persist:",e))}function xu(e){let t=ws()[e];if(t!==void 0)return typeof t=="number"?{count:t}:t}function zn(e){return xu(e)?.count}function Wn(e){return xu(e)?.source}function Ge(e,t,r){let n=ws();n[e]=r?{count:t,source:r}:{count:t},Aa()}function Yr(e){let t=ws();delete t[e],Aa()}function De(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=zr(e);if(t)return{count:t.findings.length,source:t.source,recognized:!0};let r=Wr(e);return r?{count:r.findings.length,source:r.source,recognized:!0}:{count:0,recognized:!1}}var Un=null,Gr=null,ys=null;function tb(e,t){for(let{names:r,onUpdate:n}of ys)if(r.has(e))try{n(e,t)}catch(o){console.warn("ensureCounts onUpdate:",o)}}function Ta(e,t){if(Un){t&&ys.push({names:new Set(e),onUpdate:t});for(let r of e)Gr.add(r);return Un}return Gr=new Set(e),ys=t?[{names:new Set(e),onUpdate:t}]:[],Un=(async()=>{await Promise.resolve();try{let r=ws();for(;Gr.size>0;){let n=Gr.values().next().value;if(Gr.delete(n),r[n]===void 0)try{let o=await Pe(n);if(r[n]!==void 0)continue;let{count:s,source:i}=De(o);r[n]=i?{count:s,source:i}:{count:s},Aa(),tb(n,s)}catch{}}}finally{Un=null,Gr=null,ys=null}})(),Un}function Ia(e){if(!e)return"";for(let t of e.split(`
15
- `))if(t.trim())return t.trim();return""}function Ra(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:Ia(s.description)}),r.size===t.size))return r}return r}var rb=`deepview/workspace-id/v1
16
- `;async function Hn(e){let t=Uint8Array.fromBase64(e),r=q(rb),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 jn(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 _u=jn("create"),Su=jn("delete"),Cu=jn("privateKey"),Eu=jn("report-membership"),Au=jn("bundle-membership"),nb=_u.on,Fa=Su.on,Ba=Cu.on,Ma=Eu.on,La=Au.on,vs=_u.fire,Pa=Su.fire,Na=Cu.fire,ks=Eu.fire,$s=Au.fire;var Da="deepview.workspaces",ob=1;function Vn(){try{let e=he(Da);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 sb(e){await ke(Da,JSON.stringify({version:ob,workspaces:e}))}var ib=Da;function Jr(e){return navigator.locks.request(ib,async()=>{await Ut();let t=Vn(),r=await e(t);if(r!==!1)return await sb(t),r})}function Kn(e){return{id:e.id,privateKey:e.privateKey,reports:Array.isArray(e.reports)?[...e.reports]:[],bundles:Array.isArray(e.bundles)?[...e.bundles]:[]}}var dt=Vn().map(Kn);function Ua(){dt=Vn().map(Kn)}function za(e){dt=dt.filter(t=>t.id!==e.id),dt.push(Kn(e))}function ab(e,t){let r=Array.isArray(e[t])?[...e[t]]:[],n=dt.find(o=>o.id===e.id);if(n){n[t]=r;return}dt.push(Kn(e))}function lb(e){dt=dt.filter(t=>t.id!==e)}function z(){let e=Vn();for(let t of e)Array.isArray(t.reports)||(t.reports=[]),Array.isArray(t.bundles)||(t.bundles=[]);return e}var cb=200;function vt(e){let t=(e??"").trim();return t&&t.replaceAll(/[\u0000-\u001F\u007F]/gu,"").slice(0,cb)||null}async function Wa(e){let t=vt(e);if(!t)return null;let r=new Uint8Array(32);crypto.getRandomValues(r);let n=r.toBase64(),o={id:await Hn(n),name:t,privateKey:n,reports:[],bundles:[],createdAt:Date.now()};return await Jr(i=>i.some(l=>l.id===o.id)?!1:(i.push(o),o))?(za(o),o):null}async function Ha(e){await Jr(r=>{let n=r.findIndex(o=>o.id===e);return n<0?!1:(r.splice(n,1),!0)})&&(Pa(e),lb(e))}async function ja(e,t){let r=vt(t);return!(!r||!await Jr(o=>{let s=o.find(i=>i.id===e);return!s||s.name===r?!1:(s.name=r,s)}))}async function Tu(e){let t=await Jr(o=>{let s=o.findIndex(p=>p.id===e.id),i=s>=0?o[s]:null,l=vt(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=dt.find(o=>o.id===r.id)??null;return n==null?vs(r.id):(n.privateKey!==r.privateKey&&Na(r.id),xs(n.reports,r.reports)||ks(r.id),xs(n.bundles,r.bundles)||$s(r.id)),za(r),r}async function Va({id:e,name:t,privateKey:r,createdAt:n}){let o=null;return await Jr(s=>{let i=vt(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=>vt(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"&&(vs(o.workspace.id),za(o.workspace)),o}function xs(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 Oa({identifier:e,workspaceId:t,field:r,fire:n,additive:o=!1,from:s=void 0}){let i=await Jr(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&&ab(p,r)}}function Iu(e,t){return{move:(r,n)=>Oa({identifier:r,workspaceId:n,field:e,fire:t}),add:(r,n)=>Oa({identifier:r,workspaceId:n,field:e,fire:t,additive:!0}),remove:(r,n)=>Oa({identifier:r,field:e,fire:t,from:n})}}var Ka=Iu("reports",ks),Ga=Iu("bundles",$s),Gn=Ka.move,It=Ka.add,qn=Ka.remove,qa=Ga.move,vr=Ga.add,Ya=Ga.remove;function db(){let e=Vn().map(Kn),t=dt,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)||Pa(o);for(let[o,s]of n){let i=r.get(o);if(!i){vs(o);continue}i.privateKey!==s.privateKey&&Na(o),xs(i.reports,s.reports)||ks(o),xs(i.bundles,s.bundles)||$s(o)}dt=e}Lr(()=>{db()});function Ru(e){return e==="inprogress"||e==="fixed"||e==="invalid"||e==="deleted"?e:void 0}function pe(e){if(e)return Ru(e.triage)??(e.deleted?"deleted":void 0)}function ub(e){return e?!e.color&&!pe(e)&&!e.comment&&!e.fix&&!(e.ignoredReports&&e.ignoredReports.length>0)&&e.flagged===void 0:!0}function Rt(e,t,r){let n=e.get(t)?.ignoredReports;return Array.isArray(n)&&n.includes(r)}function Yn(e){if(!e||typeof e!="object")return;let t=e,r={};typeof t.color=="string"&&t.color&&(r.color=t.color);let n=Ru(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 ub(r)?void 0:r}function pb(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 fb(e,t){let r=e??{},n=t??{};return(r.color??"")===(n.color??"")&&(pe(r)??"")===(pe(n)??"")&&(r.comment??"")===(n.comment??"")&&(r.fix??"")===(n.fix??"")&&r.flagged===n.flagged&&pb(r.ignoredReports,n.ignoredReports)}function M(e,t,r){let n=e.get(t),o=Yn({...n,...r});return o===void 0?e.delete(t):fb(n,o)?!1:(e.set(t,o),!0)}function se(e,t,r,n){let o=new Set(e.get(t)?.ignoredReports??[]);return n?o.add(r):o.delete(r),M(e,t,{ignoredReports:o.size>0?[...o]:void 0})}var Ja=()=>{};function Bu(e){Ja=typeof e=="function"?e:()=>{}}var Mu=()=>{};function Xa(e){Mu=typeof e=="function"?e:()=>{}}var Kt="deepview.triage",Ft="deepview.triage.pending",kt=/^\d+$/u;async function hb(e){let t=new Blob([e]).stream().pipeThrough(new CompressionStream("deflate"));return new Uint8Array(await new Response(t).arrayBuffer())}async function gb(e){let t=new Blob([e]).stream().pipeThrough(new DecompressionStream("deflate"));return new Uint8Array(await new Response(t).arrayBuffer())}var mb="deepview.triage.save",Fu=0;function Qa(){let e={};for(let[t,r]of a.triage){if(kt.test(t))continue;let n=Yn(r);n&&(e[t]=n)}return e}function ne(){let e=++Fu,t=Qa(),r=Object.keys(t).length===0,n=r?null:JSON.stringify(t);if(n!=null)try{localStorage.setItem(Ft,n)}catch{}return navigator.locks.request(et,{mode:"shared"},async()=>{let o=null,s=null;if(n!=null)try{let i=q(n),l=await hb(i);s=$e(),o=(s?await su(l):l).toBase64()}catch(i){console.warn("Failed to save triage:",i),Ja();return}await navigator.locks.request(mb,()=>{try{if(e!==Fu)return;if(n!=null&&$e()!==s){queueMicrotask(()=>{ne()});return}if(r)localStorage.removeItem(Kt),localStorage.removeItem(Ft);else{localStorage.setItem(Kt,o);try{localStorage.removeItem(Ft)}catch{}}}catch(i){console.warn("Failed to save triage:",i)}}),Ja()})}async function Lu(){let e=localStorage.getItem(Ft);if(e)try{return JSON.parse(e)}catch{}let t=localStorage.getItem(Kt);if(!t)return null;let r=Uint8Array.fromBase64(t);if(Oe(r)){if(!$e())throw new Error("triage: vault locked, cannot decrypt envelope");r=await iu(r)}let n=await gb(r);return JSON.parse(ue(n))}function Pu(e,{replace:t=!1}={}){let r=a.triage;if(t){let n=null,o=localStorage.getItem(Ft);if(o)try{n=JSON.parse(o)}catch{}let s=i=>n!=null&&i in n;for(let i of[...r.keys()]){if(kt.test(i))continue;let l=e?.[i],d=!e||!(i in e);!(s(i)&&n[i]?.color)&&(d||!l?.color)&&M(r,i,{color:void 0}),!(s(i)&&(n[i]?.triage||n[i]?.deleted))&&!pe(l)&&M(r,i,{triage:void 0}),!(s(i)&&n[i]?.comment)&&(d||typeof l?.comment!="string"||!l.comment)&&M(r,i,{comment:void 0}),!(s(i)&&n[i]?.fix)&&(d||typeof l?.fix!="string"||!l.fix)&&M(r,i,{fix:void 0}),!(s(i)&&n[i]?.flagged!==void 0)&&(d||l?.flagged===void 0)&&M(r,i,{flagged:void 0})}for(let i of[...r.keys()]){if(kt.test(i))continue;let l=r.get(i)?.ignoredReports;if(!l||l.length===0)continue;let d=e?.[i],u=!!pe(d);for(let p of[...l]){if(s(i)&&Array.isArray(n[i]?.ignoredReports)&&n[i].ignoredReports.includes(p))continue;if(u){se(r,i,p,!1);continue}let f=d?.ignoredReports;(!Array.isArray(f)||!f.includes(p))&&se(r,i,p,!1)}}}if(e)for(let[n,o]of Object.entries(e)){let s=pe(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&&M(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&&M(r,n,{ignoredReports:[...l]})}}}async function bb(){try{let e=await Lu();Pu(e)}catch(e){console.warn("Failed to load triage:",e)}}async function Nu(){try{let e=await Lu();Pu(e,{replace:!0}),Mu()}catch(e){console.warn("Failed to reload triage:",e)}}typeof window<"u"&&window.addEventListener("storage",e=>{e.key!==Kt&&e.key!==Ft||Nu()});var Jn=bb();ge(()=>{Nu()});ge(()=>{$e()&&localStorage.getItem(Ft)&&ne()});async function Za({seal:e}){try{localStorage.removeItem(Ft)}catch{}let t=localStorage.getItem(Kt);if(!t)return;let r=Uint8Array.fromBase64(t);if(Oe(r))return;let n=await e(r,An());localStorage.setItem(Kt,n.toBase64())}async function el({open:e}){try{localStorage.removeItem(Ft)}catch{}let t=localStorage.getItem(Kt);if(!t)return;let r=Uint8Array.fromBase64(t);if(!Oe(r))return;let n=await e(r,An());localStorage.setItem(Kt,n.toBase64())}var Ou="deepview.lastFile",Xn=null;function tl(){return Xn||(Xn=yb(),Xn.catch(()=>{Xn=null})),Xn}async function yb(){try{await Jn}catch{}let e=await ce(),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 Pe(o),await lt(s,i),await Ur(o)}catch(p){console.warn(`migrate: failed to rename ${o} -> ${s}`,p);continue}t.delete(o),t.add(s),n.add(o);let l=zn(o);if(Yr(o),l===void 0){let{count:p,source:f}=De(i);Ge(s,p,f)}else{let{source:p}=De(i);Ge(s,l,p)}let d=Ve(o);d&&(Ke(o,""),Ke(s,d));let u=!1;for(let[p,f]of[...a.triage])f.ignoredReports?.includes(o)&&(se(a.triage,p,o,!1),se(a.triage,p,s,!0),u=!0);if(u&&await ne(),he(Ou)===o)try{await ke(Ou,s)}catch{}}for(let o of z())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 qn(s,o.id),await It(i,o.id)}}var rl=1;function wb(){let e=Qa(),t=fs();return{version:rl,exportedAt:new Date().toISOString(),triage:e,repoUrls:t}}function vb(){return`deepview-triage-${new Date().toISOString().replaceAll(/[:.]/gu,"-").slice(0,19)}.json.gz`}async function nl(){let e=wb();return{blob:new Blob([await Zo(JSON.stringify(e))]),filename:vb()}}async function ol(e){let t;try{t=await kn(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!==rl)throw new Error(`Unsupported backup version: ${r.version} (expected ${rl})`);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()])kt.test(l)||n.delete(l);let o=t==="prefer-current";for(let[l,d]of Object.entries(r)){if(kt.test(l)||!d||typeof d!="object")continue;typeof d.color=="string"&&d.color&&(!o||!n.get(l)?.color)&&M(n,l,{color:d.color});let u=pe(d);if(u&&(!o||!pe(n.get(l)))&&M(n,l,{triage:u}),typeof d.comment=="string"&&d.comment&&(!o||!n.get(l)?.comment)&&M(n,l,{comment:d.comment}),typeof d.fix=="string"&&d.fix&&(!o||!n.get(l)?.fix)&&M(n,l,{fix:d.fix}),typeof d.flagged=="boolean"&&(!o||n.get(l)?.flagged===void 0)&&M(n,l,{flagged:d.flagged}),Array.isArray(d.ignoredReports)&&!pe(n.get(l)))for(let p of d.ignoredReports)typeof p=="string"&&(o&&Rt(n,l,p)||se(n,l,p,!0))}await ne();let s=0,i=null;try{await bu(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 kb(e){return e?.name==="NotFoundError"||typeof e?.message=="string"&&e.message.startsWith("File not found:")}async function il(e){let t=new Set;for(let r of e){let n;try{n=await Pe(r)}catch(i){if(kb(i))continue;throw new Error(`Failed to read ${r}: ${i.message}`,{cause:i})}if(n==null)continue;let o=Ht(n);if(!Array.isArray(o?.findings))continue;let s=jt(o.findings);await Hr(s);for(let i of s)i.id&&t.add(i.id)}return t}function $b(){let e=new Set;for(let t of a.triage.keys())kt.test(t)||e.add(t);return e}async function _s(e){let t=$b();if(t.size===0)return{orphanedCount:0,sharedCount:0};let r=await il(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 ce(),s=new Set(e),i=o.filter(p=>!s.has(p)),l=await il(i),d=0,u=0;for(let p of n)l.has(p)?u++:d++;return{orphanedCount:d,sharedCount:u}}async function Ss(){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 ce(),n=new Set(r),o=await il(r),s=!1;for(let i of e){if(kt.test(i)||o.has(i))continue;let l=a.triage.get(i);!l||!(l.color||pe(l)||l.comment||l.fix||l.flagged!==void 0)||M(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)kt.test(i)||o.has(i)&&n.has(l)||Rt(a.triage,i,l)&&se(a.triage,i,l,!1)&&(s=!0);s&&await ne()}var al=1,qt=16,Du=12,Uu=1+qt+Du+16,Gt=1+qt+Du;async function zu(e,t){let r=await crypto.subtle.importKey("raw",q(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 Wu(e){return!(e instanceof Uint8Array)||e.length<Uu?!1:e[0]===al}async function Cs(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(Gt+e.length+16);r[0]=al,crypto.getRandomValues(r.subarray(1,1+qt)),crypto.getRandomValues(r.subarray(1+qt,Gt));let n=r.subarray(1,1+qt),o=r.subarray(1+qt,Gt),s=await zu(t,n),i=new Uint8Array(await crypto.subtle.encrypt({name:"AES-GCM",iv:o,additionalData:r.subarray(0,Gt)},s,e));return r.set(i,Gt),r}async function _b(e,t){if(typeof t!="string"||!t)throw new TypeError("tryDecryptWithPassword: password required");if(!(e instanceof Uint8Array)||e.length<Uu)return{ok:!1,reason:"malformed"};if(e[0]!==al)return{ok:!1,reason:"malformed"};let r=e.subarray(1,1+qt),n=e.subarray(1+qt,Gt),o=e.subarray(Gt),s=await zu(t,r),i;try{i=new Uint8Array(await crypto.subtle.decrypt({name:"AES-GCM",iv:n,additionalData:e.subarray(0,Gt)},s,o))}catch{return{ok:!1,reason:"wrong-password"}}return{ok:!0,plaintext:i}}async function Es(e,t,r){if(!r||typeof r.malformedMsg!="string"||typeof r.wrongPasswordMsg!="string")throw new TypeError("decryptWithPasswordOrThrow: { malformedMsg, wrongPasswordMsg } strings required");let n=await _b(e,t);if(n.ok)return n.plaintext;throw n.reason==="wrong-password"?new Error(r.wrongPasswordMsg):new Error(r.malformedMsg)}var Qn=Wu,Hu=Cs;function ju(e,t){return Es(e,t,{malformedMsg:"malformed encrypted bundle",wrongPasswordMsg:"wrong password or corrupt bundle"})}var Sb=1;async function Cb(e){let t=new Set,r=Ht(e);if(!Array.isArray(r?.findings))return t;let n=jt(r.findings);await Hr(n);for(let o of n)o.id&&t.add(o.id);return t}function Vu(e){return(e??"").replaceAll(/[^a-zA-Z0-9._-]+/gu,"_").replaceAll(/^_+|_+$/gu,"")||"workspace"}async function Eb(e){if(!Array.isArray(e)||e.length===0)return[];let t=await ct(),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 br(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 Ab(e,{includeBundleBytes:t=!1}={}){let r=[],n=new Set;for(let u of e.reports??[]){let p;try{p=await Pe(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 Gn(u,null);continue}r.push({name:u,content:p});for(let f of await Cb(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=Yn({...p,ignoredReports:f});h&&(s[u]=h)}let i={};for(let u of r){let p=Ve(u.name);p&&(i[u.name]=p)}let l=(e.bundles??[]).filter(u=>typeof u=="string"&&u.length>0),d={version:Sb,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 Eb(l);u.length>0&&(d.bundleBlobs=u)}return d}async function Ku(e,{includeBundleBytes:t=!1}={}){let r=await Ab(e,{includeBundleBytes:t});return{blob:new Blob([await Zo(JSON.stringify(r))]),filename:`${Vu(e.name)}.deepview-workspace.json.gz`}}async function Tb(e,t,{includeBundleBytes:r=!1}={}){if(typeof t!="string"||!t)throw new TypeError("buildWorkspaceExportEncrypted: password required");let{blob:n}=await Ku(e,{includeBundleBytes:r}),o=new Uint8Array(await n.arrayBuffer()),s=await Hu(o,t);return{blob:new Blob([s],{type:"application/octet-stream"}),filename:`${Vu(e.name)}.deepview-workspace.enc`}}async function ll(e,{password:t,includeBundleBytes:r=!1}={}){return typeof t=="string"&&t?await Tb(e,t,{includeBundleBytes:r}):await Ku(e,{includeBundleBytes:r})}var Ib=1,Gu=1024,qu=1024,As=200,Qu=100*1024*1024,Rb=Math.ceil(Qu*4/3)+16,Yu=512,Ju=64;function Fb(e){if(!e||typeof e!="object")return"payload is not an object";if(e.version!==Ib)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>qu)return`reports count (${e.reports.length}) exceeds cap (${qu})`;if(e.bundles!==void 0){if(!Array.isArray(e.bundles))return"bundles field must be an array when present";if(e.bundles.length>Gu)return`bundles count (${e.bundles.length}) exceeds cap (${Gu})`;for(let t of e.bundles){if(typeof t!="string")return"bundles entries must be strings";if(t.length>As)return`bundle integrity exceeds per-entry length cap (${As})`}}if(e.bundleBlobs!==void 0){if(!Array.isArray(e.bundleBlobs))return"bundleBlobs field must be an array when present";if(e.bundleBlobs.length>Ju)return`bundleBlobs count (${e.bundleBlobs.length}) exceeds cap (${Ju})`;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>As)return`bundleBlobs.integrity exceeds per-entry length cap (${As})`;if(typeof t.name!="string"||t.name.length===0)return"bundleBlobs.name must be a non-empty string";if(t.name.length>Yu)return`bundleBlobs.name exceeds per-entry length cap (${Yu})`;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>Rb)return`bundleBlobs.data exceeds per-blob size cap (${Qu} bytes raw)`}}return null}async function cl(e){return new Uint8Array(await e.arrayBuffer())}async function Ts(e,t){if(Qn(e)){if(typeof t!="string"||!t)throw new TypeError("parseWorkspaceBundleBytes: password required for encrypted bundle");let n=await ju(e,t);try{return Xu(await kn(n))}catch(o){throw new Error("wrong password or corrupt bundle",{cause:o})}}let r;try{r=await kn(e)}catch(n){throw new Error(`gzip decompression failed: ${n.message}`,{cause:n})}return Xu(r)}function Xu(e){let t;try{t=JSON.parse(e)}catch(o){throw new Error(`payload is not JSON: ${o.message}`,{cause:o})}let r=Fb(t);if(r===null)return t;let n=r.includes("exceeds cap");throw new Error(n?r:`not a deepview workspace export: ${r}`)}function Bb(e){return pe(e)??null}async function Mb(e){let t=new Map;for(let r of e??[]){if(typeof r?.content!="string")continue;let n=Ht(r.content);if(!n?.findings)continue;let o=jt(n.findings);await Hr(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:Ia(s.description)})}return t}async function Lb(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&&M(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&&M(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&&M(n,s,{fix:h});let b=Bb(i),m=pe(n.get(s))??null;b&&m&&m!==b?o.push({id:s,property:"triage",local:m,imported:b}):b&&!m&&M(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&&M(n,s,{flagged:k});let w=Array.isArray(i.ignoredReports)?i.ignoredReports:[];if(!pe(n.get(s)))for(let v of w)typeof v=="string"&&se(n,s,v,!0)}if(o.length>0&&t){let s=await t(o,r??new Map);s&&Pb(o,s)}await ne()}function Pb(e,t){for(let r of e){let n=`${r.id}:${r.property}`;t[n]==="imported"&&Nb(r.id,r.property)===r.local&&(r.property==="color"?M(a.triage,r.id,{color:r.imported}):r.property==="comment"?M(a.triage,r.id,{comment:r.imported}):r.property==="fix"?M(a.triage,r.id,{fix:r.imported}):r.property==="triage"?M(a.triage,r.id,{triage:r.imported,ignoredReports:void 0}):r.property==="flagged"&&M(a.triage,r.id,{flagged:r.imported==="flagged"?!0:r.imported==="not flagged"?!1:void 0}))}}function Nb(e,t){if(t==="color")return a.triage.get(e)?.color;if(t==="triage")return pe(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 Ob(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 mr(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 dl(e,{conflictResolver:t}={}){let r=[];for(let u of e.reports)if(!(typeof u?.name!="string"||typeof u?.content!="string"))try{await lt(u.name,u.content);let{count:p,source:f}=De(u.content);Ge(u.name,p,f??Wn(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 Ob(e.bundleBlobs);let o=e.triage&&Object.keys(e.triage).length>0?await Mb(e.reports):new Map;await Lb(e.triage,t,o);let s=Array.isArray(e.bundles),i=s?e.bundles.filter(u=>typeof u=="string"&&u.length>0):[],l=await Tu({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||Ve(u)||(Ke(u,p),a.currentFile===u&&(a.repoUrl=p));return l}async function ul({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 Hn(r)===e?{v:1,n:t,k:r}:{v:1,i:e,n:t,k:r};return(await Cs(q(JSON.stringify(s)),n)).toBase64({alphabet:"base64url",omitPadding:!0})}async function pl({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 Es(r,t,{malformedMsg:"malformed share link",wrongPasswordMsg:"wrong password or corrupt link"});try{return await Db(n)}catch(o){throw new Error("wrong password or corrupt link",{cause:o})}}async function Db(e){let t=JSON.parse(ue(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 Hn(t.k),name:t.n,privateKeyBase64:t.k}}function fl(e){return typeof location>"u"?`#share=${e}`:`${location.origin}${location.pathname}#share=${e}`}function hl(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 Ub={get state(){return a},listWorkspaces:z,addReportToWorkspace:It,addBundleToWorkspace:vr,onReportMembershipChanged:Ma,onBundleMembershipChanged:La,onWorkspaceDeleted:Fa,onWorkspacePrivateKeyChanged:Ba,analyzeContent:De,setCount:Ge,gunzipBytes:gt,listBundles:ct,listFiles:ce,readBundle:br,readFileBytes:gr,saveBundle:mr,saveFileBytes:Bn,saveTriage:ne,getSecureItem:he,setSecureItem:ke,removeSecureItem:Pr,onSecureStorageHydrated:Lr};function Zu(e){e.installSyncHost(Ub),Bu(()=>e.triageSync.notify())}var U=null,Zn=null;function np(){try{return he("deepview.sync.userEnabled")!=="0"}catch{return!0}}function gl(){return Zn||(Zn=(async()=>{let e="./client-sync.js";try{let t=await import(e);return Zu(t),U=t,zb(),t}catch(t){throw Zn=null,t}})(),Zn)}function op(){return gl()}var sp=[];function to(e){U?e(U):sp.push(e)}function zb(){let e=sp.splice(0);for(let t of e)try{t(U)}catch(r){console.warn("client-sync: deferred apply failed:",r)}}function eo(e,t){let r={cancelled:!1,unsub:null};return to(n=>{r.cancelled||(r.unsub=t(n,e))}),()=>{r.cancelled=!0,r.unsub&&r.unsub()}}function ml(e,t){return U?U.isInRemote(e,t):!1}function ip(e,t){return U?U.isBundleInRemote(e,t):!1}var Wb="deepview.objstore-presence.";function ap(e){try{let t=localStorage.getItem(Wb+e);if(!t)return null;let r=JSON.parse(t);return r&&typeof r=="object"?r:null}catch{return null}}function ro(e,t){if(U&&U.isInRemote(e,t))return!0;let r=ap(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 bl(e,t){if(U&&U.isBundleInRemote(e,t))return!0;let r=ap(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 lp(e){return U?U.remoteCount(e):0}function cp(e){return eo(e,(t,r)=>t.onAutoDownloaded(r))}function dp(e){return eo(e,(t,r)=>t.onBundleAutoDownloaded(r))}function up(e){return eo(e,(t,r)=>t.onChange(r))}var ep=null,tp=null,rp=null,Is=[];function pp(e){if(U){U.setRedraw(e);return}ep=e,to(t=>{ep===e&&t.setRedraw(e)})}function fp(e){if(U){U.setAuthenticationResolver(e);return}tp=e,to(t=>{tp===e&&t.setAuthenticationResolver(e)})}function hp(e){if(U){U.setHydrationConflictResolver(e);return}rp=e,to(t=>{rp===e&&t.setHydrationConflictResolver(e)})}async function Bt(e,t){if(!(!np()&&!U))return(await gl())[e](...t)}function gp(...e){return Bt("fetchFile",e)}function mp(...e){return Bt("fetchBundleFromRemote",e)}function Rs(...e){return Bt("putFile",e)}function bp(...e){return Bt("putBundleToRemote",e)}function Fs(...e){return Bt("deleteFromRemote",e)}function Bs(...e){return Bt("deleteBundleFromRemote",e)}function Ms(...e){return Bt("openWorkspace",e)}function no(...e){return Bt("closeWorkspace",e)}function yp(...e){return Bt("recheckRemoteStorage",e)}function Yt(e,t){if(U)return U.triageSync[e](...t);to(r=>{r.triageSync[e](...t)})}var O={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 gl().then(t=>{t.triageSync.setEnabled(!0);let r=Is;Is=[];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){Is=U.openWorkspaceIds();for(let t of Is)try{U.closeWorkspace(t)}catch(r){console.warn(`client-sync: closeWorkspace(${t}) failed during disable:`,r)}U.triageSync.setEnabled(!1);return}Yt("setEnabled",[e])},isEnabled(){return U?U.triageSync.isEnabled():np()},openSession(e){Yt("openSession",[e])},closeSession(e){Yt("closeSession",[e])},refreshSession(e){Yt("refreshSession",[e])},dismissError(e){Yt("dismissError",[e])},setForcedOff(e){Yt("setForcedOff",[e])},setServerUrl(e){Yt("setServerUrl",[e])},getServerUrl(){return U?U.triageSync.getServerUrl():null},notify(){Yt("notify",[])},onStatusChange(e){return eo(e,(t,r)=>t.triageSync.onStatusChange(r))},onPersistenceDegraded(e){return eo(e,(t,r)=>t.triageSync.onPersistenceDegraded(r))}};var oo=class extends Qe{constructor(t){if(super(t),this.it=g,t.type!==Me.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===le)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:[]}}};oo.directiveName="unsafeHTML",oo.resultType=1;var fe=ft(oo);var wp=`*,*: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 vp=`.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 kp=`*,*: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 T=class extends H{static styles=[A(kp)];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 V(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 tt=`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 yl=class extends T{static styles=[...T.styles,A(tt)];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=En(),this._vaultStateUnsub=ge(()=>{if(this._settled)return;let t=En();this._orphan&&!t&&Z()?(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(Z()){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 In({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(!bt()){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 Qi({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 Ki({seal:r}),this._phase="Encrypting triage data\u2026",await Za({seal:r}),this._phase="Encrypting report files\u2026",await pa({seal:r}),this._phase="Encrypting bundles\u2026",await ha({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=bt();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",yl);function Ls(){return V("passkey-setup-dialog")}var wl=class extends T{static styles=[...T.styles,A(tt)];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 Tn({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",wl);function Ps(){return V("passkey-unlock-dialog")}var $p=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>`,Gb=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>`,xe=null;function xp(){if(!xe)return;if(!bt()){xe.hidden=!0;return}xe.hidden=!1;let e=Z(),t=it();xe.classList.toggle("encrypted",e&&t),xe.classList.toggle("locked-pending",e&&!t),e&&t?(xe.title="Encryption on \u2014 click to disable",xe.setAttribute("aria-label","Disable encryption"),W($p,xe)):e?(xe.title="Encryption on, locked \u2014 click to unlock",xe.setAttribute("aria-label","Unlock encrypted data"),W($p,xe)):(xe.title="Encryption off \u2014 click to enable",xe.setAttribute("aria-label","Enable encryption"),W(Gb,xe))}async function qb(){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 Zi({migrate:async({open:t})=>{await Gi({open:t}),await el({open:t}),await fa({open:t}),await ga({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 Yb(){await Ls()}function _p(e){if(!e||e===xe)return;xe=e;let t=!1;xe.addEventListener("click",async()=>{if(!t){t=!0;try{if(!Z()){await Yb();return}if(!it()){await Ps();return}await qb()}finally{t=!1}}}),ge(xp),xp()}var Ns='<path class="bg" d="M3 2h6l4 4v8H3z"/><path fill="rgba(0,0,0,.18)" d="M9 2v4h4Z"/>',Y={default:`<svg class="file-icon brand-deepview" viewBox="0 0 16 16" width="14" height="14" aria-hidden="true">${Ns}<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">${Ns}<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">${Ns}<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">${Ns}<path class="fg" d="m8 5.97 3.5 6.062h-7Z"/></svg>`};function qe(e){let t=Wn(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 Re(e){return e.toLowerCase().endsWith(".codex")?e.slice(0,-6).replaceAll("__","/"):e}var Sp=globalThis[Symbol.for("@rray/frontend")];if(!Sp)throw new Error("@rray/frontend global not installed; view.js must run before lazy bundles import this wrapper");var{LitElement:s_,html:vl,nothing:Cp,unsafeCSS:i_,render:a_,StateElement:l_,classMap:c_,repeat:d_,styleMap:u_}=Sp;var Ye={critical:6,high:5,medium:4,low:3,high_bug:2,bug:1,informational:0},me=["critical","high","medium","low","high_bug","bug","informational"],Os="node_modules";function Ep(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}}}Os=r?"node_modules":"dependencies"}function Ap(){return Os}function Jt(e){return Os==="node_modules"?/(^|\/)node_modules\//u.test(e):/(^|\/)dependencies\//u.test(e)}function Ue(e){return typeof e!="number"||!Number.isFinite(e)?null:`${e.toLocaleString()} B`}function Mt(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 Jb(e){let t=Os==="node_modules"?/^(?:.*\/)?node_modules\/(?:@[^/]+\/[^/]+|[^/]+)\/(.*)$/u:/^(?:.*\/)?dependencies\/(?:@[^/]+\/[^/]+|[^/]+)\/(.*)$/u;return e.match(t)?.[1]??e}function rt(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 kr(e){let t=e?.exportName,r=e?.methodName;return t&&r&&t!==r?`${t}.${r}`:t||r||""}function Tp(e){return[e.file,e.description,e.recommendation,e.confidenceReason,e.discoveredIn,e.repo?.github].filter(Boolean).join(`
31
- `).toLowerCase()}function kl(e){return e&&e.replace(/^[^/]+\//u,"").replace(/^claude-/u,"").replaceAll("-"," ")}function $r(e){return[e.type,kl(e.model),e.effort,e.exportsMode].filter(Boolean).join(" \xB7 ")}function Ds(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 Ip(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 Xr(e,t,r){if(t)return`https://github.com/${t}/blob/HEAD/${Jb(e)}`;if(Jt(e))return null;let n=Ip(r);return n?`${n}/blob/HEAD/${e}`:null}function $l(e,t,r){let n=Xr(e,t,r);return n?vl`<a href="${n}" target="_blank" rel="noopener">${e}</a>`:e}function Qr(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 Rp(e,t,r,n){let o=parseInt(t,10);if(!Number.isFinite(o))return Cp;let s=Xr(e,r,n),i=`line ${o}`;return s?vl`<a href="${`${s}#L${o}`}" target="_blank" rel="noopener">${i}</a>`:i}function Fp(e,t){return!e||!t?null:`${/^https?:/iu.test(e)?e.replace(/\/$/u,""):`https://github.com/${e}`}/commit/${t}`}function Bp(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 Mp(e,{title:t,body:r}={}){let n=Ip(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 L(e){return e.id??String(e._id)}function _e(e){return L(e[0])}function xl(e){return Array.isArray(e)?e:[e]}function Us(e){return e?._reportName??""}function Zr(e){return Rt(a.triage,L(e),Us(e))}function so(e){return[...e].toSorted((t,r)=>{let n=a.triage.get(L(t))?.color?1:0,o=a.triage.get(L(r))?.color?1:0;if(n!==o)return o-n;let s=Ye[t.severity]||0,i=Ye[r.severity]||0;if(s!==i)return i-s;let l=t.confidence??-1;return(r.confidence??-1)-l})}function ze(e){return so(e)[0]}function Se(e){let t=a.activeTabByGroup.get(_e(e));if(t){let r=e.find(n=>L(n)===t);if(r)return r}return ze(e)}function zs(e){for(let t of yt().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 be(e){let t=e.map(f=>{let h=L(f),b=a.triage.get(h),m=b?.triage??(Zr(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 Lt(){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 xr(e){for(let t of Lt())if(_e(t)===e)return t;return null}var io="\0",ao="";function _l(e){return typeof e.repo?.github=="string"&&e.repo.github?e.repo.github:typeof e._repoFallback=="string"&&e._repoFallback?e._repoFallback:null}function Ws(){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 Xb(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(L(e))?.color??"none";if(!a.filterColors.has(r))return!1}if(a.filterSources.size===1){let r=a.filterSources.has("own");if(r&&Jt(e.file)||!r&&!Jt(e.file))return!1}if(a.filterComment||a.filterFix||a.filterFlagged){let r=a.triage.get(L(e)),n=!!r?.comment,o=!!r?.fix,s=r?.flagged===!0;if(a.filterComment==="with"&&!n||a.filterComment==="without"&&n||a.filterFix==="with"&&!o||a.filterFix==="without"&&o||a.filterFlagged==="with"&&!s||a.filterFlagged==="without"&&s)return!1}if(a.filterAnalyzer){let r=e._analyzer??null,n=a.filterAnalyzer===io?null:a.filterAnalyzer;if(r!==n)return!1}if(a.filterRepo){let r=_l(e),n=a.filterRepo===ao?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(L(e)),n=Tp(e).includes(t)||(r?.comment??"").toLowerCase().includes(t)||(r?.fix??"").toLowerCase().includes(t);return a.filterIncludeNegate?!n:n}return!0}function Np(e){return e.filter(t=>t.some(Xb))}function Lp(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 Op(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 Pp=Op("desc"),Qb={severity:(e,t)=>(Ye[t.severity]||0)-(Ye[e.severity]||0)||Pp(e,t)||parseInt(e.line,10)-parseInt(t.line,10),"confidence-desc":Pp,"confidence-asc":Op("asc"),"priority-desc":Lp("priority","desc",-1),"priority-asc":Lp("priority","asc",11)};function Dp(e){let t=Qb[a.sortBy];return t?[...e].toSorted((r,n)=>t(ze(r),ze(n))):[...e]}var Fe=ft(class extends Qe{constructor(e){if(super(e),e.type!==Me.PROPERTY&&e.type!==Me.ATTRIBUTE&&e.type!==Me.BOOLEAN_ATTRIBUTE)throw Error("The `live` directive is not allowed on child or event bindings");if(!Rd(e))throw Error("`live` bindings can only contain a single expression")}render(e){return e}update(e,[t]){if(t===le||t===g)return t;let r=e.element,n=e.name;if(e.type===Me.PROPERTY){if(t===r[n])return le}else if(e.type===Me.BOOLEAN_ATTRIBUTE){if(!!t===r.hasAttribute(n))return le}else if(e.type===Me.ATTRIBUTE&&r.getAttribute(n)===t+"")return le;return Ho(e),t}});var Cl={"claude-security":"Claude Security","codex-security":"Codex Security",deepsec:"DeepSec"};function Zb(e){return e==null?"(none)":Cl[e]??e}var Sl=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??io}">${Zb(t)}</option>`)}</select>`}_onChange=t=>{this.dispatchEvent(new CustomEvent("analyzer-change",{detail:{value:t.target.value},bubbles:!0,composed:!0}))}};customElements.define("analyzer-select",Sl);function en(e){return e==="informational"?"info":e.replaceAll("_"," ")}function Hs(e){if(!e)return"";for(let t of e.split(`
33
- `))if(t.trim())return t.trim();return""}function ey(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 Up=/"[^"\n]+"|`[^`\n]+`/gu;function El(e){if(!e)return e;Up.lastIndex=0;let t=[],r=0,n;for(;(n=Up.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 ty(e){let t=Xr(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 ry(e,t){if(!t)return g;let r=t.slice(0,7),n=Fp(e,t);return n?c`<a href="${n}" target="_blank" rel="noopener" title="${t}">${r}</a>`:c`<span title="${t}">${r}</span>`}var ny=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>`,oy=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>`,sy=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>`,iy=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>`,ay=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>`,Al=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 ly(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)}">${Al}${t?c`<span class="mark-btn-label">${r?"Flagged":"Flag"}</span>`:g}</button>`}function cy(e){let t=Hs(e.description)||e.file||"Security finding";return t.length>120?`${t.slice(0,119)}\u2026`:t}function dy(e){let t=Xr(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 uy(e){if(!a.currentWorkspace)return g;let t=e[0]?._reportName;if(!t)return g;let r=Y[qe(t)]??Y.default;return c`<span class="report-chip" title="${t}">${fe(r)}<span class="report-chip-label">${Re(t)}</span></span>`}function zp(e,t,r,n,o=null){let s=uy(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="${R({"mark-comment":!0,"has-comment":d})}" title="${p}" aria-label="${p}">${ny}${h?c`<span class="mark-btn-label">${b}</span>`:g}</button>`,k=c`<button type="button" class="${R({"mark-fix":!0,"has-fix":u})}" title="${f}" aria-label="${f}">${oy}${h?c`<span class="mark-btn-label">${m}</span>`:g}</button>`,w=ly(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">${sy}${h?c`<span class="mark-btn-label">Copy</span>`:g}</button>`,S=Se(e),F=zs(S),I=Mp(F,{title:cy(S),body:dy(S)}),N=I?c`<a class="mark-issue" href="${I}" target="_blank" rel="noopener" title="Create a pre-filled GitHub issue for this finding" aria-label="Create a GitHub issue for this finding">${ay}${h?c`<span class="mark-btn-label">Issue</span>`:g}</a>`:g,de=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">${iy}${h?c`<span class="mark-btn-label">Claude</span>`:g}</button>`,K=c`<color-marker .selected="${l}"></color-marker>`,pt=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}${N}${de}</span>${K}${fy(e,pt,o)}`}function py(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=L(e[0]),o=be(e),s=Se(e),i=L(s),l=o.hasConflict?a.triage.get(i)?.triage??(Zr(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="${py}">${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 Wp(e,t){let r=L(e),n=a.triage.get(r),o=n?.color,s=n?.triage,i=Zr(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}`}">${en(e.severity)}</span> ${e.confidence===void 0?g:c`<span class="tab-conf">${e.confidence}/10</span>`}</span></button>`}function hy(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 gy=/^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/iu;function my(e){let t=e?.name;if(typeof t!="string"||!gy.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 by(e,t,r=0,n=1,o=null){let s=L(e),i=a.triage.get(s),l=i?.comment??"",d=i?.fix??"",u=Xr(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=kr(e),y=m?c`<span class="line-num">${b}, ${m}</span>`:c`<span class="line-num">${b}</span>`,k=$r(e),w=o==="focus"?my(e.package?.npm):g,v=g;if(o!=="focus"&&e.fileHash&&Array.isArray(e._bundleHashes)&&e._bundleHashes.length>0){let I=new Set(e._bundleHashes),N=wr(e.fileHash).find(({integrity:de})=>I.has(de));N&&(v=c`<button type="button" class="finding-code-btn" data-finding-code-bundle="${N.integrity}" data-finding-code-file="${N.file}" data-finding-code-line="${e.line??""}" title="${`Open ${N.file} in bundle source viewer`}">Code</button>`)}let{title:S,body:F}=ey(rt(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}`}">${en(e.severity)}</span><div class="value-label">Severity</div>${e.confidence===void 0?g:hy(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>${S?c`<div class="desc-title">${S}</div>`:g} ${F?c`<div class="desc">${El(F)}</div>`:g} ${e.recommendation?c`<div class="recommendation">Recommendation: ${El(rt(e.recommendation,e))}</div>`:g} ${e.confidenceReason?c`<div class="conf-reason">${El(rt(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> ${Qr(d)?c`<a href="${d}" target="_blank" rel="noopener noreferrer">${d}</a>`:d}</div>`:g}</div></div>`}function tn(e){return _e(e)}function Hp(e){let t=be(e),r=so(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 jp(e,t={}){let{context:r=null}=t,n=be(e),o=so(e),s=Se(e),i=L(s),l=s.commitHash?c`<div class="commit-ref">introduced in ${ry(s.repo?.github,s.commitHash)}</div>`:g,d=a.currentWorkspace&&l!==g;return c`${o.map((u,p)=>by(u,L(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=>Wp(u,L(u)===i))}</div>`:g}</div>${zp(e,o,n,i,r)}</div>`}function lo(e){return _e(e)}function Vp(e){let t=be(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 Kp(e){let t=be(e),r=so(e),n=Se(e),o=L(n),s=n,i=Hs(rt(s.description,s)),l=$r(s),d=kr(s),u=d?`, ${d}`:"";return c`<div class="row-score"><span class="${`badge ${s.severity}`}">${en(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">${ty(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=>Wp(p,L(p)===o))}</div></div>`:g}</div>`}function co(e){return"tree-"+e.replaceAll(/[^\w-]+/gu,"_")}var qp=()=>Object.fromEntries(me.map(e=>[e,0]));function Tl(e){let t=new Map;for(let r of e)for(let n of r){t.has(n.file)||t.set(n.file,qp());let o=t.get(n.file);o[n.severity]!==void 0&&o[n.severity]++}return t}function Il(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 js(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=qp();for(let l of o){let d=t.get(l);if(d)for(let u of me)i[u]+=d[u]??0}r.set(n,i)}return r}function Rl(e,t,r){let n=t.get(e),o=r.get(e);return Gp(n)>0||Gp(o)>0}function Gp(e){if(!e)return 0;let t=0;for(let r of me)t+=e[r]??0;return t}function Yp(e){if(!e)return g;let t=wr(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 Jp(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="${`#${co(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=me.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?me.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=Ue(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">${yy(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=Ue(f?.size);return c`<section class="tree-file" id="${co(p)}"><div class="tree-file-header"><span class="name">${p}</span> ${l(p)} ${b?c`<span class="tree-file-size">${b}</span>`:g} ${Yp(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 yy(e,t,r,n){let o=Ue(e?.size);return c`<div class="tree-detail-name"><span class="name">${t}</span> ${o?c`<span class="tree-detail-size">${o}</span>`:g} ${Yp(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 wy(){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 Xt=wy(),E=new Proxy(Xt,{get(e,t){return Xt[t]},set(e,t,r){return Xt[t]=r,!0},has(e,t){return t in Xt},deleteProperty(e,t){return delete Xt[t]},ownKeys(){return Reflect.ownKeys(Xt)},getOwnPropertyDescriptor(e,t){return Object.getOwnPropertyDescriptor(Xt,t)}});function We(){E.graphState?._cleanup&&E.graphState._cleanup(),E.graphState=null}function Xp(){return Xt}var uo=null,Qp=null;function rn(){return Qp}function vy(){return uo||(uo=(async()=>{let e="./graph.js";try{let t=await import(e);return t._swapGraph2Impl(Xp()),Qp=t,t}catch(t){throw uo=null,t}})(),uo)}async function Fl(e,t,r,n,o){try{let s=await vy(),i=s.buildGraphFromPrep(t);W(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 ut(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 po=null,fo=null;function ky(){return po||(po=(async()=>{let e="./terminal.js";try{return await import(e)}catch(t){throw po=null,t}})(),po)}function $y(e){let t=ut(e);if(t.size===0)return t;let r=[...t.keys()],{stripped:n}=Mt(r),o=new Map;for(let s=0;s<r.length;s++)o.set(n[s],t.get(r[s]));return o}async function Zp(e,t){let r=t?.integrity??"";(!fo||fo.integrity!==r)&&(fo={integrity:r,promise:xy(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 xy(e,t){return(await ky()).createTerminalElement($y(e),t)}function tf(e){if(!e)return null;let t=Ap()==="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 _y=["#4e9af1","#f28e2b","#59a14f","#e15759","#76b7b2","#edc948","#b07aa1","#ff9da7","#9c755f","#5cd1e5","#f1ce63","#d37295","#a0cbe8","#86bcb6","#8cd17d","#b6992d","#499894","#e15759","#e879c7","#d4a6c8"],ef=["#2f8aef","#d2691e","#2ea043","#e63946","#2e9a92","#b88817","#9560e8","#d24a9c","#8a5d40","#0891b2","#a07a14","#c14e8e","#1f7ad0","#549b94","#3fb95f","#a07a14","#2a8278","#cb2c40","#c026d3","#965f93"];function Sy(){if(typeof document>"u")return!1;let e=document.body?.classList;return!!e&&(e.contains("theme-light")||e.contains("theme-pink"))}var Bl=new Map;function Pt(e){let t=Sy()?ef:_y,n=`${t===ef?"l":"d"}:${e??"__own__"}`;if(Bl.has(n))return Bl.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 Bl.set(n,d),d}var Ml=(e,t,r)=>{for(let n of t)if(n[0]===e)return(0,n[1])();return r?.()};var nn='<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>',Vs='<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 Ks=null;function Cy(){return Ks||(Ks=(async()=>await import("./prism.js"))(),Ks)}var Ey={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 Gs(e){if(typeof e!="string")return null;let t=e.lastIndexOf(".");return t<0?null:Ey[e.slice(t+1).toLowerCase()]??null}async function qs(e,t){if(!t)return null;try{return(await Cy()).highlight(e,t)}catch{return null}}var ye=`.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 Ll=class extends T{static styles=[...T.styles,A(ye)];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",Ll);function rf({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:Ty(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 Ty(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 on(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 Iy=e=>e&&[null,Object.prototype].includes(Object.getPrototypeOf(e)),sn=e=>Object.setPrototypeOf(Object.fromEntries(e),null),nf=e=>[...e].toSorted((t,r)=>on(t,r)),Ys=e=>sn([...e].toSorted((t,r)=>on(t[0],r[0])).map(([t,r])=>[t,r instanceof Map?Ys(r):r])),Pl=e=>new Map(Object.entries(e).map(([t,r])=>[t,Iy(r)?Pl(r):r]));function of(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 $t=1,Nl=0,Js=({name:e,version:t,files:r})=>({name:e,version:t,files:sn(Object.entries(r))}),sf=e=>of(e)??{dir:".",rel:e,name:null},Xs=class e{static VERSION=$t;version=$t;config;entries;modules;formats;imports;constructor({config:t={scope:"full"},entries:r,modules:n,formats:o,imports:s,version:i=$t}={}){D([Nl,$t].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===$t||r.version===Nl),D(["node_modules","full"].includes(r.config?.scope)),D(r.formats),D(r.imports);let n=new Map,o=new Set;if(r.version===$t){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,Js(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,Js(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}=sf(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:Pl(r.imports)})}static parseResources(t){let r=JSON.parse(t);D(r.version===$t||r.version===Nl);let n=new Map,o={scope:"full"};if(r.version===$t){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,Js(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,Js(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}=sf(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=sn(Object.entries(i).toSorted((p,f)=>on(p[0],f[0])));(l?t:r).push([n,{name:o,version:s,files:d}])}return t.sort((n,o)=>on(n[0],o[0])),r.sort((n,o)=>on(n[0],o[0])),{modules:sn(t),sources:sn(r)}}serializeCode(){let t=nf(this.entries),{modules:r,sources:n}=this.#e(),o=Ys(this.formats),s=Ys(this.imports),i={version:$t,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:$t,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 Qs=null,Zs=null,ei=null;function Ry(){for(let e of["br","brotli"])try{return new DecompressionStream(e),e}catch{}return null}async function Fy(e,t){let r=new Blob([t]).stream().pipeThrough(new DecompressionStream(e));return new Uint8Array(await new Response(r).arrayBuffer())}async function By(){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 My(){return ei||(ei=(async()=>await import("./brotli-fallback.js"))(),ei)}async function Ly(){await By();let e=Ry();return e?(Qs={kind:"native",format:e},Qs):(Qs={kind:"fallback"},Qs)}function af(){return Zs||(Zs=Ly(),Zs)}async function lf(e){let t=await af();return t.kind==="native"?Fy(t.format,e):(await My()).brotliDecompress(e)}af().catch(()=>{});async function ti(e,t){try{let r=await br(e),n=t.name.toLowerCase().endsWith(".map"),o=n?"sourcemap":"stasis";try{if(n){let l=JSON.parse(ue(r));return{integrity:e,kind:o,size:r.byteLength,json:l}}let s=ue(await lf(r)),i=Xs.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 Py(e){!e?.json&&!e?.bundle||(async()=>{try{let t=await Dl(e);if(bs(e.integrity,t),a.selectedBundle!==e.integrity)return;e.fileHashes=t,$()}catch{}})()}async function Ol(e){if(Ea(e))return;let t=(a.bundles??[]).find(n=>n.integrity===e);if(!t)return;let r=await ti(e,t);if(!(!r?.json&&!r?.bundle))try{let n=await Dl(r);bs(e,n)}catch{}}async function Qt(e){let t=(a.bundles??[]).find(n=>n.integrity===e);if(!t)return;let r=await ti(e,t);a.selectedBundle===e&&(a.bundleDetails=r,$(),Py(r),wt().catch(()=>{}))}var Ny=["finding_url","repository","title","description","severity","configured_scan_id","relevant_paths"];function Oy(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 cf(e){let t=Oy(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 Ny)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=>Dy(m,o));i.push({displayName:h,data:{type:"security",source:"codex-security",findings:b}})}return i}function Dy(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 an=`.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 df=`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 ln(e){if(!e)return g;let t=e.replaceAll("_"," ");return c`<span class="${`conflict-sev sev-${e}`}">${t}</span>`}function Wy(e){return`bundle-${e.slice(7,19)}\u2026`}function Je(e){return e.kind==="bundle"?e.label??Wy(e.identifier):e.identifier}function Hy(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 jy(e){return c`<span class="comment-text">${e||c`<em>empty</em>`}</span>`}function Vy(e){return e?Qr(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 Ky(e){return e?c`<span class="${`triage triage-${e}`}">${e}</span>`:c`<em>none</em>`}function Gy(e){return e?c`<span class="${`flag-badge${e==="flagged"?" on":""}`}">${e}</span>`:c`<em>none</em>`}function uf(e,t){return e==="color"?Hy(t):e==="comment"?jy(t):e==="fix"?Vy(t):e==="triage"?Ky(t):e==="flagged"?Gy(t):c`${String(t)}`}function qy(e,t){let r=e?.file?e.line?`${e.file}:${e.line}`:e.file:"";return c`<div class="card-head">${ln(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 ff={title:"Triage conflicts",intro:"disagree with your local triage on",trailingNote:"",applyButton:"Apply",importedSideLabel:"Apply imported"},pf={color:0,comment:1,fix:2,triage:3,flagged:4},Yy={color:"Color",comment:"Comment",fix:"Fix",triage:"Triage state",flagged:"Flag"},Ul=class extends T{static styles=[...T.styles,A(an),A(df)];static properties={conflicts:{attribute:!1},findingLookup:{attribute:!1},labels:{attribute:!1},_settled:{state:!0}};constructor(){super(),this.conflicts=[],this.findingLookup=new Map,this.labels={...ff},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)=>(pf[f.property]??99)-(pf[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}">${qy(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">${Yy[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">${uf(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">${uf(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",Ul);function ri(e,t,r={}){return new Promise((n,o)=>{let s=document.createElement("triage-conflict-dialog");s.conflicts=e,s.findingLookup=t,s.labels={...ff,...r},s.addEventListener("resolve",i=>{s.remove(),n(i.detail)}),s.addEventListener("modal-conflict",i=>{s.remove(),o(ht(i.detail?.cause))}),document.body.append(s)})}var zl=class extends T{static styles=[...T.styles,A(tt)];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",zl);function hf({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(ht(o.detail?.cause))}),document.body.append(n)})}async function gf(e){let t=await cl(e),r;if(Qn(t)){if(r=await hf({tryPassword:o=>Ts(t,o)}),!r)return null}else r=await Ts(t);let n=await dl(r,{conflictResolver:async(o,s)=>{try{return await ri(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 bf="deepview.passkey.firstImportPrompted";function Jy(){try{return localStorage.getItem(bf)==="1"}catch{return!1}}function mf(){try{localStorage.setItem(bf,"1")}catch{}}async function Wl(){if(Z()||!bt()||Jy())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.`)){mf();return}await Ls(),Z()&&mf()}var yf=Wl;var wf=["type","model","think","effort","exportsMode"],Zt="deepview.lastFile",ho=new Set(["overview","graph","treemap","advisories","issues","code","terminal"]);function cn(e,t="overview"){let r=t&&t!=="overview"&&ho.has(t)?` ${t}`:"";ke(Zt,`b:${e}${r}`).catch(()=>{})}var _r=0,Ce=e=>e!==_r;function Hl(e){let t=kf(e.toLowerCase());return t.endsWith(".map")?"sourcemap":t==="stasis.code.br"||t.endsWith(".stasis.code.br")?"stasis":null}function kf(e){return e.replace(/ \(\d+\)(?=\.[^.]*$)/u,"")}async function vf({name:e,content:t,existingNames:r}){if(!r.has(e))return await lt(e,t),r.add(e),{name:e,content:t};let n;try{n=await Pe(e)}catch(l){if(!(l instanceof DOMException&&l.name==="NotFoundError"||typeof l?.message=="string"&&l.message.startsWith("File not found:")))throw l;return await lt(e,t),r.add(e),{name:e,content:t}}if(n===t)return{name:e,content:t};let s=z().filter(l=>Array.isArray(l.reports)&&l.reports.includes(e)).filter(l=>ro(l.id,e)),i=await rf({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 lt(l,t),r.add(l),{name:l,content:t}}return await lt(e,t),s.length>0&&await Xy(e,s),{name:e,content:t}}async function Xy(e,t){let r;try{r=await gr(e)}catch(n){console.warn(`Import: failed to read freshly-saved "${e}" for cloud sync:`,n);return}for(let n of t)try{await Ms(n.id);let o=await Rs(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 jl(e){await yf();let t=null,r=null,n=new Set,o=new Set(await ce());for(let s of e)try{let i=kf(s.name.toLowerCase());if(i.endsWith(".gz")||i.endsWith(".deepview-workspace.enc")){await gf(s);try{let u=await ce();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(Hl(s.name)){let u=new Uint8Array(await s.arrayBuffer()),{integrity:p}=await mr(s.name,u);r=p,n.add(p);continue}let d=await s.text();if(i.endsWith(".csv")){let u=cf(d);for(let{displayName:p,data:f}of u){let h=p.replaceAll("/","__")+".codex",b=JSON.stringify(f),{count:m,source:y}=De(b),k=await vf({name:h,content:b,existingNames:o});k&&(Ge(k.name,m,y),t={name:k.name,content:k.content})}}else{let u=De(d);if(!u.recognized)throw new Error("not a recognized DeepView, DeepSec, Claude Security, or Codex report");let p=await vf({name:s.name,content:d,existingNames:o});if(!p)continue;Ge(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)Ol(s).catch(()=>{});t?await _t(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.shownTriage=null,E.showAll=!0,cn(r),$(),await j(),Qt(r))}async function _t(e,t){let r=++_r,n=new Set(z().filter(o=>Array.isArray(o.reports)&&o.reports.includes(e)).map(o=>o.id));for(let o of O.openSessions)o&&!n.has(o.workspaceId)&&(O.closeSession(o.workspaceId),no(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=Ve(e),a.repoEditing=!1,E.selected=null,E.focusedPkg=null,E.layoutCache=null,E.solo=null,E.hidden.clear(),E.pathFilter="",We(),ke(Zt,e).catch(()=>{}),t===void 0){try{t=await Pe(e)}catch(o){if(Ce(r))return;if(o&&o.message?.includes("vault locked")){if(await Ps()&&!Ce(r)){await _t(e);return}Ce(r)||(a.currentFile=null,await j());return}alert(`Failed to read ${e}: ${o.message}`),a.currentFile=null,await j();return}if(Ce(r))return}if(await Kl(e,t,r),!Ce(r)){for(let o of n)O.openSession(o),O.refreshSession(o),Ms(o);await j()}}async function er(e){let t=z().find(o=>o.id===e);if(!t)return;let r=++_r;for(let o of O.openSessions)o&&o.workspaceId!==e&&(O.closeSession(o.workspaceId),no(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="",We(),ke(Zt,`ws:${e}`).catch(()=>{}),t.reports.length===0&&(C.classList.remove("active"),W(g,C),Ie.classList.remove("hidden"));let n=t.reports.map(o=>Pe(o).catch(()=>null));for(let o=0;o<t.reports.length;o++){let s=await n[o];if(Ce(r))return;if(s!==null&&(await Kl(t.reports[o],s,r),Ce(r)))return}O.openSession(e),O.refreshSession(e),Ms(e),await j()}async function $f({triage:e="keep",deleteFromRemoteWorkspaceIds:t=[]}={}){if(!a.currentFile)return;let r=++_r,n=a.currentFile;Yr(n),Ke(n,"");for(let o of t)try{let s=await Fs(o,n);if(Ce(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 Ur(n),!Ce(r)&&(await Gn(n,null),!Ce(r))){if(e==="wipe"){try{await Ss()}catch(o){console.warn("Skipped orphan-triage GC:",o)}if(Ce(r))return}Ce(r)||(Vl(),await j())}}function Vl(){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="",We(),Pr(Zt),C.classList.remove("active"),W(g,C),Ie.classList.remove("hidden"),document.title="DeepView"}async function xf(){++_r;for(let e of O.openSessions)e&&(O.closeSession(e.workspaceId),no(e.workspaceId));Vl(),await j()}async function _f({deleteFromRemoteWorkspaceIds:e=[]}={}){if(!a.selectedBundle)return;let t=++_r,r=a.selectedBundle;for(let o of e)try{let s=await Bs(o,r);if(Ce(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 ua(r),Ce(t)||(await qa(r,null),Ce(t)))return;a.selectedBundle=null,a.bundleDetails=null,a.bundleSourceFile=null,a.bundleSourceFindingIdx=null;let n=he(Zt);typeof n=="string"&&(n===`b:${r}`||n.startsWith(`b:${r} `))&&Pr(Zt),Ca(r),a.bundles=await ct(),!Ce(t)&&($(),await j())}async function Sf(e,t="detach",{triage:r="keep"}={}){let n=z().find(l=>l.id===e);if(!n)return;++_r;let o=Array.isArray(n.reports)?[...n.reports]:[];if(O.closeSession(e),no(e),t==="delete"){for(let l of o){try{await Ur(l)}catch{}Yr(l),Ke(l,"")}if(r==="wipe")try{await Ss()}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)&&Vl(),await Ha(e),await j()}async function Kl(e,t,r=null){let n=()=>r!==null&&Ce(r);try{if(await Jn,n())return;let o;try{o=JSON.parse(t)}catch(b){if(o=zr(t)??Wr(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(xl).filter(b=>!b.id);if(u.length>0){let b=await Promise.all(u.map(hs));if(n())return;u.forEach((m,y)=>{b[y]&&(m.id=b[y])})}let p=Ve(e),f=[],h=0;for(let b of d){let m=xl(b);if(m.length===0)continue;let y=m.filter(I=>I.id&&i.has(I.id)),k=m.filter(I=>!I.id||!i.has(I.id)),w=new Set;for(let I of y){let N=l.get(I.id);N!==void 0&&w.add(N)}let v=m.filter(I=>I.id).map(I=>I.id);if(k.length===0){w.size>1&&a.workspaceMerges.push(new Set(v)),h+=y.length;continue}let S=[];for(let I of k){I.id&&i.add(I.id);let N={...I,_id:a.nextFindingId++,_repoFallback:p,_reportName:e,_bundleHashes:o.bundleHashes??[]};if(!o.source&&!wf.some(K=>N[K]!==void 0))for(let K of wf)o[K]!==void 0&&(N[K]=o[K]);N._analyzer=o.source??N.type??null,S.push(N)}y.length>0&&(h+=y.length,a.workspaceMerges.push(new Set(v)));let F=`${a.reports.length}:${f.length}`;for(let I of k)I.id&&l.set(I.id,F);f.push(S)}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)&&Ol(m).catch(()=>{})}if(s)if(Ws(),f.some(m=>m.some(y=>y.confidence!==void 0))){let m=k=>f.reduce((w,v)=>w+(v.some(S=>S.confidence!==void 0&&S.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;$()}catch(o){alert(`Failed to parse ${e}: ${o.message}`)}}window.__loadFile=(e,t)=>Kl(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")&&jl(e.dataTransfer.files)});Ie.addEventListener("dragover",e=>{e.preventDefault(),Ie.classList.add("hover")});Ie.addEventListener("dragleave",()=>Ie.classList.remove("hover"));Ie.addEventListener("drop",e=>{e.preventDefault(),Ie.classList.remove("hover"),jl(e.dataTransfer.files)});var xt=null;function Qy(){xt||(xt=document.createElement("input"),xt.type="file",xt.multiple=!0,xt.hidden=!0,xt.addEventListener("change",()=>{let e=xt.files;e&&e.length>0&&jl(e),xt.value=""}),document.body.append(xt)),xt.click()}Ie.addEventListener("click",e=>{e.target.closest(".drop-prompt-action")&&Qy()});var Sr=new Map,Cf="deepview.advisories.proxyConsent";function Ef(){try{return localStorage.getItem(Cf)==="1"}catch{return!1}}function Af(){try{localStorage.setItem(Cf,"1")}catch{}}function Zy(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 ew(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 Tf(e,t){return!e||Hl(e.name)!=="stasis"?!1:!t||t.integrity!==e.integrity?!0:ew(t)}function tw(e){let t=Object.create(null);for(let[r,n]of e)t[r]=[...n].toSorted();return t}async function If(e,t){if(!e?.integrity||Sr.has(e.integrity)||!Ef())return;let r=Zy(e);if(r.size===0){Sr.set(e.integrity,{state:"ok",byPackage:new Map,query:r});return}Sr.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(tw(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{}Sr.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)}Sr.set(n,{state:"ok",byPackage:i,query:r})}catch(o){Sr.set(n,{state:"error",reason:o?.message??"fetch-failed",query:r})}t()}var rw={critical:0,high:1,moderate:2,low:3,info:4};function ni(e){return rw[e]??999}function nw(e){return e.charAt(0).toUpperCase()+e.slice(1)}function ow(){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 Rf(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(!Ef())return ow();let t=Sr.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=>ni(h.severity))),f=Math.min(...u.map(h=>ni(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])=>sw(i,l,t.query.get(i)))}</ul></div>`}function sw(e,t,r){let n=[...t].toSorted((s,i)=>{let l=ni(s.severity)-ni(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=>cw(s))}</ul></li>`}function iw(e){if(typeof e!="string")return null;let t=/\/(GHSA-[a-z0-9-]+)(?:[/?#]|$)/iu.exec(e);return t?t[1]:null}var aw=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 lw(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 cw(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=iw(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}${aw}</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}`}">${nw(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?"":", "}${lw(p)}`)}</span>`:g}</div>${o?c`<div class="bundle-advisory-cvss-vector mono">${o}</div>`:g}</div></div></li>`}var go=null;function dw(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 uw(e){let t=ut(e),r=dw(e),n=[...t.keys()],{stripped:o}=Mt(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 Dl(e){let t=ut(e),r=new Map;for(let[n,o]of t)r.set(n,await vu(o));return r}function Mf(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 ms(n)){let s=a.triage.get(L(o))?.triage;s&&t[s]!==void 0&&t[s]++}}return t}function Cr(e,t="graph"){if(!e||e.size===0)return new Map;let r=new Map;for(let[n,o]of e){let s=ms(o);if(s.length===0)continue;let i=s.filter(d=>{let u=a.triage.get(L(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 pw(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 Lf(e){let{tree:t,origToStripped:r}=uw(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=Cr(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,S=[];for(let F of y){k[F.severity]=(k[F.severity]||0)+1,w.add(F.severity);let I=a.triage.get(L(F))?.color??"none";v.add(I),S.push({severity:F.severity,color:I})}i.set(m,k),l.set(m,w),d.set(m,v),u.set(m,S)}let p=js(t,i),f=E.showAll?n:[...pw(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:mo},strippedToOrig:h,hasEdges:b}}function ii(){if(!go)return;let e=rn();e&&e.refreshSidebar(go,{isBundleContext:!0})}function ai(){if(!go)return;let e=rn();e&&e.refreshTopPkgs(go)}function Pf(e){go=e}function mo(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=mo(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">${Q(n,([o])=>o,([o,s])=>c`<span class="bundles-dist-seg" style="${ve({flexGrow:s,background:Pt(o)})}" data-tooltip="${o==="__own__"?g:`${o}: ${Ue(s)}`}"></span>`)}</div><ul class="bundles-dist-list">${Q(n,([o])=>o,([o,s])=>{let i=(s/r*100).toFixed(1),l=o==="__own__"?"own source":o,d=Pt(o);return c`<li><span class="bundles-dist-dot" style="${ve({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="${ve({width:`${i}%`,background:d})}"></span> </span><span class="bundles-dist-size">${Ue(s)}</span> <span class="bundles-dist-percent">${i}%</span></li>`})}</ul></div>`}function Ff(e,t,r,n){let{prefix:o,stripped:s}=Mt(r),i=new Set;for(let v of s)i.add(mo(v));let l=s.map((v,S)=>S).toSorted((v,S)=>s[v].localeCompare(s[S])),d=s.map((v,S)=>({path:v,size:n[S]})),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=Cr(a.bundleDetails.fileHashes,"issues");for(let S of v.values())for(let F of S){f[F.severity]!==void 0&&f[F.severity]++,h++;for(let I of Nn(F.fileHash,F))b.set(I,(b.get(I)??0)+1)}}let m=[...b.keys()].toSorted(),y=me.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 S=r[v],F=s[v],I=n[v];return c`<li><button type="button" class="bundles-source-row" data-bundle-view-source="${S}" data-tooltip="${S}"><span class="bundles-source-path">${F}</span> ${I==null?g:c`<span class="bundles-source-size">${Ue(I)}</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 S=Y[qe(v)]??Y.default,F=b.get(v)??0;return c`<li><button type="button" class="report-chip bundles-report-chip" data-tooltip="${v}" data-bundle-issue-report="${v}">${fe(S)}<span class="report-chip-label">${Re(v)}</span> <span class="bundles-report-count">${F} ${F===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 Gl=new Map,ql=new Set;function si(e){for(let t of me)for(let r of e)if(r.severity===t)return t;return e[0]?.severity??null}function Nf(e,t,r,n){let o=e.split(`
48
- `).length,s=String(o).length,i=Gs(t),l=`${r??""}\0${t}`;i&&!Gl.has(l)&&!ql.has(l)&&(ql.add(l),(async()=>{let u=await qs(e,i);Gl.set(l,u??null),ql.delete(l),a.bundleSourceFile===t&&$()})());let d=Gl.get(l);return c`<div class="bundle-source-lines" style="${ve({"--lineno-width":`${s}ch`})}"><aside class="bundle-source-lineno-col" aria-hidden="true">${Array.from({length:o},(u,p)=>{let f=p+1,h=n.get(f),b=h?si(h.map(y=>y.f)):null,m=h&&a.bundleSourceFindingIdx!=null&&h.some(y=>y.idx===a.bundleSourceFindingIdx);return c`<div class="bundle-source-lineno-row" data-line="${f}">${h?c`<button type="button" class="${R({"bundle-source-dot":!0,[`sev-${b}`]:!0,active:m})}" data-bundle-source-finding="${h[0].idx}" title="${`${h.length} ${h.length===1?"issue":"issues"} on line ${f}`}" aria-label="${`${h.length} issues on line ${f}`}"></button>`:c`<span class="bundle-source-dot-placeholder"></span>`} <span class="bundle-source-lineno-num">${f}</span></div>`})}</aside><pre class="bundle-source-code"><code class="${i?`language-${i}`:""}">${typeof d=="string"?fe(d):e}</code></pre></div>`}function Of(e){let t=a.bundleSourceFindingIdx;if(t==null)return g;let r=e[t];if(!r)return g;let n=r.fileHash?Nn(r.fileHash,r):[],o=a.triage.get(L(r))?.triage,s=o==="fixed"?"Fixed":o==="inprogress"?"In progress":null,i=$r(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=Y[qe(d)]??Y.default;return c`<button type="button" class="report-chip bundle-source-panel-report" title="${d}" data-bundle-issue-report="${d}">${fe(u)}<span class="report-chip-label">${Re(d)}</span></button>`})}</div>`:g}</div></aside>`}function Df(){let e=a.bundleSourceFile;if(!e)return g;if(a.bundleDetailsTab==="code")return g;let r=ut(a.bundleDetails).get(e),n=[],o=new Map;if(typeof r=="string"&&a.bundleDetails?.fileHashes){let i=Cr(a.bundleDetails.fileHashes,"issues").get(e)??[];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 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"?Nf(r,e,a.bundleDetails?.integrity,o):c`<div class="bundle-source-empty">Source content not bundled.</div>`}</div>${Of(n)}</div></div></div>`}function Uf(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 oi=new Map,Bf=null;function Yl(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:oi.has(f)?oi.get(f):r===0||d(h),p=f=>h=>{oi.set(f,!h.currentTarget.parentElement.open)};return c`<ul class="${R({"bundle-code-tree":!0,root:r===0})}">${Q(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>${Yl(h,t,r+1,n,b,s)}</details></li>`})} ${Q(l,([,f])=>f,([f,h])=>{let b=n?.get(h),m=b&&b.length>0?si(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 hw(e,t,r,n,o=""){if(!r)return Yl(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=Uf(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),Yl(p,t,0,n,"",!0)}function gw(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 mw(e,t,r,n=""){if(!e.fileHashes)return c`<div class="bundle-code-search-empty">Computing file hashes…</div>`;let o=Cr(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=Ye[l.finding.severity]??0,p=Ye[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">${d.description??""}</div></button></li>`})}</ul></div>`}function bw(e){if(!e||!e.json&&!e.bundle)return g;let t=ut(e);if(t.size===0)return c`<div class="bundle-code-empty">This bundle doesn't carry any source content.</div>`;Bf!==a.selectedBundle&&(oi.clear(),Bf=a.selectedBundle);let r=[...t.keys()].toSorted(),{prefix:n,stripped:o}=Mt(r),s=new Map;for(let w=0;w<r.length;w++)s.set(o[w],r[w]);let i=Uf(o),l=w=>{let v=new Map;for(let[S,F]of w.files)v.set(S,s.get(F)??F);w.files=v;for(let S of w.dirs.values())l(S)};l(i);let d=a.bundleSourceFile,u=d?t.get(d):null,p=[],f=new Map;if(typeof u=="string"&&e.fileHashes){let v=Cr(e.fileHashes,"issues").get(d)??[];for(let S=0;S<v.length;S++){let F=v[S];p.push(F);let I=parseInt(F.line,10);Number.isFinite(I)&&I>0&&(f.has(I)||f.set(I,[]),f.get(I).push({f:F,idx:S}))}}let h=e.fileHashes?Cr(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">${Ml(y,[["files",()=>hw(i,d,k,h,n)],["code",()=>gw(t,k,d,n)],["issues",()=>mw(e,k,d,n)]])}</div></aside><div class="${R({"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"?Nf(u,d,e.integrity,f):c`<div class="bundle-source-empty">Source content not bundled.</div>`}</div>${Of(p)}</div>`:c`<div class="bundle-code-placeholder">Pick a file from the tree to view its source.</div>`}</div></div>`}function yw(e){let t=Tf(e,a.bundleDetails);a.bundleDetailsTab==="advisories"&&!t&&(a.bundleDetailsTab="overview");let r=a.bundleDetailsTab,n=r==="overview";return r==="advisories"&&t&&If(a.bundleDetails,$).catch(()=>{}),c`<div class="bundles-view bundles-slide-view"><header class="bundles-slide-bar"><span class="bundles-slide-icon" aria-hidden="true">${fe(nn)}</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:r==="advisories"})}" data-bundle-tab="advisories" aria-selected="${String(r==="advisories")}" role="tab">Advisories</button>`:g} <button type="button" class="${R({"bundles-tab":!0,active:r==="issues"})}" data-bundle-tab="issues" aria-selected="${String(r==="issues")}" role="tab">Issues</button> <button type="button" class="${R({"bundles-tab":!0,active:r==="terminal"})}" data-bundle-tab="terminal" aria-selected="${String(r==="terminal")}" role="tab">Terminal</button> <button type="button" class="${R({"bundles-tab":!0,active:r==="treemap"})}" data-bundle-tab="treemap" aria-selected="${String(r==="treemap")}" role="tab">Treemap</button> <button type="button" class="${R({"bundles-tab":!0,active:r==="graph"})}" data-bundle-tab="graph" aria-selected="${String(r==="graph")}" role="tab">Graph</button> <button type="button" class="${R({"bundles-tab":!0,active:r==="code"})}" data-bundle-tab="code" aria-selected="${String(r==="code")}" role="tab">Code</button> <button type="button" class="${R({"bundles-tab":!0,active:n})}" data-bundle-tab="overview" aria-selected="${String(n)}" role="tab">Overview</button></div></header><div class="${R({"bundles-slide-body":!0,"bundles-slide-body-overview":n})}">${n?kw(e,a.bundleDetails):Ml(r,[["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",()=>bw(a.bundleDetails)],["issues",()=>vw(a.bundleDetails)],["advisories",()=>Rf(a.bundleDetails)]])}</div></div>`}function ww(e,t={}){if(!e)return g;let r=[];if(e.fileHash&&(r=Nn(e.fileHash,e)),r.length===0&&t.bucketKey&&(t.kind==="package"?r=$a(t.bucketKey,e):t.kind==="repository"&&(r=xa(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=Y[qe(s)]??Y.default;return c`<button type="button" class="report-chip" title="${s}" data-bundle-issue-report="${s}">${fe(i)}<span class="report-chip-label">${Re(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 vw(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=Cr(e.fileHashes,"issues");return t.size===0?c`<div class="bundle-issues-empty">No issues match this bundle's files.</div>`:bo(t,{kind:"bundle"})}function bo(e,{kind:t,bucketKey:r}={}){let n=[...e.keys()],{prefix:o,stripped:s}=Mt(n),i=new Map(n.map((u,p)=>[u,s[p]])),l=[...e.entries()].toSorted(([u,p],[f,h])=>{let b=Ye[si(p)]??0,m=Ye[si(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">${Q(l,([u])=>u,([u,p])=>{let f=i.get(u)??u,h=[...p].toSorted((m,y)=>{let k=Ye[m.severity]??0,w=Ye[y.severity]??0;if(w!==k)return w-k;let v=parseInt(m.line,10)||0,S=parseInt(y.line,10)||0;return v-S}),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">${Q(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(L(m))?.triage,v=w==="fixed"||w==="invalid"||w==="deleted"?w.toUpperCase():w==="inprogress"?"In progress":null,S=c`<div class="bundle-issues-finding-head"><span class="${`bundle-issue-sev sev-${k}`}">${k.replaceAll("_"," ")}</span> ${(()=>{let F=zf(m.line);return F?c`<span class="bundle-issues-finding-line">${F}</span>`:g})()} ${v?c`<span class="${`bundle-issues-finding-triage triage-${w}`}">${v}</span>`:g} <span class="bundle-issues-finding-spacer"></span> ${ww(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}">${S}</button>`:c`<div class="bundle-issues-finding-link bundle-issues-finding-static" title="${u}">${S}</div>`}</li>`})}</ul></li>`})}</ul></div>`}function Wf(e){let t=a.selectedBundle,r=t?e.find(n=>n.integrity===t):null;return r?yw(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 kw(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>${Ue(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 Ff(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 Ff(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 Hf(){wt().catch(()=>{});let e=yt(),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,S]of b.byVersion){let F=[],I=new Map;for(let N of S.findings){let de=a.triage.get(L(N))?.triage??null;de==="inprogress"?t.inprogress++:de==="fixed"?t.fixed++:de==="invalid"?t.invalid++:de==="deleted"&&t.deleted++,de===a.shownTriage&&(F.push(N),I.has(N.file)||I.set(N.file,[]),I.get(N.file).push(N))}if(F.length!==0){m.push([v,{findings:F,files:I,reports:S.reports}]);for(let N of F)y.push(N),k.has(N.file)||k.set(N.file,[]),k.get(N.file).push(N);for(let N of S.reports)w.add(N)}}m.length!==0&&(m.sort(([v],[S])=>zi(v,S)),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 Aw(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();Cw(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>${_w(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">${Q($w(d),xw,h=>Tw(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">${Fw(o[0],i,s?s[0]:void 0)}</div></aside>`:g}</div>`}</div>`}function $w(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 xw(e){return e.version===null?`${e.kind}:${e.pkg}`:`${e.kind}:${e.pkg}@${e.version}`}function _w(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="${Sw}"></triage-selector></div>`}var Sw=["inprogress","fixed","invalid","deleted"];function Cw(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 Ew(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(L(s))?.triage??null;i==="invalid"?r.invalid++:i==="deleted"?r.deleted++:r.live++}return r}function Aw(e,t,r){let n=yt().get(e),o=Ew(n,r),s=a.packageSlideTriage??"live",i=n?jf(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>`:bo(i,{kind:"package",bucketKey:e})}</div></div>`}function Tw(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=me.filter(m=>l[m]>0),u=Pt(o),f={selected:o===t&&Iw(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="${ve({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"?Rw(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 Iw(e,t){return e.kind==="single"?!0:e.version===t}function Rw(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 Fw(e,t,r){let n=yt().get(e),s=[...(n?jf(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>${Bw(e,t,r)}`}function jf(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(L(f))?.triage??null;return r==="invalid"?h==="invalid":r==="deleted"?h==="deleted":h!=="invalid"&&h!=="deleted"});if(d.length===0)continue;let u=Vf(t,i);o.has(u)||o.set(u,[]);let p=o.get(u);for(let f of d)p.push(f)}return o}function Bw(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=me.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=yt().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=Y[qe(f)]??Y.default;return c`<li><button type="button" class="packages-detail-report" title="${f}" data-package-report="${f}">${fe(h)}<span class="packages-detail-report-label">${Re(f)}</span></button></li>`})}</ul><h3 class="packages-detail-section">Files</h3><ul class="packages-detail-files">${s.map(([f,h])=>{let b=Vf(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 Vf(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 nt(e){if(!e)return"";let t=e.match(/github\.com\/([^/?#]+\/[^/?#]+?)(?:\.git)?(?:[/?#]|$)/iu);return t?t[1]:e}function Kf(){wt().catch(()=>{});let e=yr(),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(L(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 Ow(o[0],o[1]);let s=a.repositoriesSearchQuery.trim().toLowerCase(),i=s?r.filter(([p])=>p.toLowerCase().includes(s)||nt(p).toLowerCase().includes(s)):r.slice();Pw(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>${Mw(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">${Q(i,([p])=>p,([p,f])=>Dw(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">${Uw(o[0],o[1])}</div></aside>`:g}</div>`}</div>`}function Mw(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="${Lw}"></triage-selector></div>`}var Lw=["inprogress","fixed","invalid","deleted"];function Pw(e,t){let r=t==="name-asc"?(n,o)=>nt(n[0]).localeCompare(nt(o[0])):t==="files-desc"?(n,o)=>o[1].files.size-n[1].files.size||nt(n[0]).localeCompare(nt(o[0])):t==="reports-desc"?(n,o)=>o[1].reports.size-n[1].reports.size||nt(n[0]).localeCompare(nt(o[0])):(n,o)=>o[1].findings.length-n[1].findings.length||nt(n[0]).localeCompare(nt(o[0]));e.sort(r)}function Nw(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(L(n))?.triage??null;o==="invalid"?t.invalid++:o==="deleted"?t.deleted++:t.live++}return t}function Ow(e,t){let r=yr().get(e),n=Nw(r),o=a.repositorySlideTriage??"live",s=r?Gf(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">${nt(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>`:bo(s,{kind:"repository",bucketKey:e})}</div></div>`}function Dw(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=me.filter(l=>n[l]>0),s=Pt(e),i=nt(e);return c`<li class="${r?"selected":""}" data-select-repository="${e}"><span class="packages-dot" style="${ve({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 Uw(e,t){let r=yr().get(e),o=[...(r?Gf(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>${zw(e,t)}`}function Gf(e,t="live"){let r=new Map;for(let[n,o]of e.files){let s=o.filter(i=>{let l=a.triage.get(L(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 zw(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=me.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">${nt(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=Y[qe(l)]??Y.default;return c`<li><button type="button" class="packages-detail-report" title="${l}" data-package-report="${l}">${fe(d)}<span class="packages-detail-report-label">${Re(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 yo=new Map,wo=new Map,Jl=new Set;function Ww(e,t,r){let n=`${e}\0${t}`;if(wo.has(n)||Jl.has(n))return;let o=Gs(t);if(!o){wo.set(n,null);return}Jl.add(n),(async()=>{let s=await qs(r,o);wo.set(n,s??null),Jl.delete(n),a.focusCodeTick++,queueMicrotask($)})()}async function Hw(e){let t=yo.get(e);if(t&&(t.loading||t.sources))return;let r=(a.bundles??[]).find(n=>n.integrity===e);if(r){yo.set(e,{sources:null,loading:!0,error:null});try{let n=await ti(e,r),o=ut(n);yo.set(e,{sources:o,loading:!1,error:n.error??null})}catch(n){yo.set(e,{sources:null,loading:!1,error:n.message})}a.focusCodeTick++,queueMicrotask($),queueMicrotask(()=>{let n=C.querySelector(".focus-code-line-active");n&&n.scrollIntoView({block:"center",behavior:"instant"})})}}function qf(e){if(!e)return null;let t=Se(e);if(!t.fileHash||!Array.isArray(t._bundleHashes)||t._bundleHashes.length===0)return null;let r=new Set(t._bundleHashes),n=wr(t.fileHash).find(({integrity:u})=>r.has(u));if(!n)return null;let o=yo.get(n.integrity);if(!o)return Hw(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;Ww(n.integrity,n.file,s);let i=`${n.integrity}\0${n.file}`,l=wo.has(i)?wo.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 Xl=class extends T{static styles=[...T.styles,A(ye)];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 bp(this.workspaceId,n.identifier);else{let s=await gr(n.identifier);o=await Rs(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:Je(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:Je(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>"${Je(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>${Je(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",Xl);function Yf({workspaceId:e,items:t}={}){return V("sync-upload-dialog",{workspaceId:e??"",items:Array.isArray(t)?[...t]:[]})}var Ql=class extends T{static styles=[...T.styles,A(ye)];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 mp(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:Je(n),reason:d}];continue}await vr(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:Je(n),reason:"not found in remote"}];continue}let s;try{s=ue(await gt(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:Je(n),reason:l}];continue}let i=De(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:Je(n),reason:l}];continue}await Bn(n.identifier,o.content),Ge(n.identifier,i.count,i.source),await It(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:Je(n),reason:s}]}if(this._running=!1,this._done=!0,t.some(n=>n.kind==="report"))try{a.currentWorkspace===this.workspaceId&&await er(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>"${Je(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>${Je(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",Ql);function Jf({workspaceId:e,items:t}={}){return V("sync-download-dialog",{workspaceId:e??"",items:Array.isArray(t)?[...t]:[]})}var Xf=`.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}
50
- `;var Vw={checking:"checking\u2026",good:"available",reuploaded:"re-uploaded",failed:"re-upload failed","check-failed":"check failed",missing:"missing"},Zl=class extends T{static styles=[...T.styles,A(ye),A(Xf)];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 yp(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 Jf({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}">${Vw[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",Zl);function Qf({workspaceId:e,cloudCount:t,localFileNames:r,localBundles:n}={}){return V("objstore-recovery-dialog",{workspaceId:e??"",cloudCount:typeof t=="number"?t:0,localFileNames:Array.isArray(r)?[...r]:[],localBundles:Array.isArray(n)?[...n]:[]})}function tc(){let e=Il(a.reports);if(!e)return null;let t=Object.keys(e),n=Lt().filter(p=>be(p).commonTriage===a.shownTriage),o=Tl(n),s=js(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(L(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=>(tf(p)??"__own__")===E.focusedPkg),E.showAll||(u=u.filter(p=>Rl(p,o,s)))):u=E.showAll?t:t.filter(p=>Rl(p,o,s)),{prep:{treeData:e,files:u,ownCounts:o,transitiveCounts:s,severitySets:i,colorSets:l,fileFindings:d},findingCounts:o}}function rc(){let e=rn();if(!e)return;let t=tc();t&&e.refreshSidebar(t.prep,{isBundleContext:a.currentView==="bundles"})}function nc(){let e=rn();if(!e)return;let t=tc();t&&e.refreshTopPkgs(t.prep)}var Kw={"claude-security":"Claude Security findings","codex-security":"Codex Security findings",deepsec:"DeepSec findings"};function Gw(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 ec=["type","model","effort","exportsMode"];function Zf(e,t,{typePrefix:r=!0}={}){return e==="type"?r?`analyzer: ${t??"null"}`:`${t??"null"}`:t??null}function qw(e,t=ec){let r=new Map;for(let f of e){let h={};for(let m of t)h[m]=m==="model"?kl(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=Zf(f,n[0][f]);h!=null&&u.push(h)}else if(!p){for(let h of n){let b=s.map(m=>Zf(m,h[m],{typePrefix:!i})).filter(m=>m!=null);b.length>0&&u.push(b.join(" \xB7 "))}p=!0}return u}function Yw(e,t,r,n,o){let s=new Set(a.reports.map(K=>K.source)),i=s.size===1?[...s][0]:null,l=a.currentWorkspace?z().find(K=>K.id===a.currentWorkspace):null,d=l?`Workspace: ${l.name}`:i?Kw[i]:"Findings",u=i&&Y[i]?i:"default",p=fe(Y[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(`
51
- `)}" title="Copy report names">${f}<span>${t.length} reports</span></span>`);let b=a.reports.flatMap(K=>K.groups.flat()),y=`${e} ${`finding${e===1?"":"s"}`}`,w=i||a.currentWorkspace?ec.filter(K=>K!=="type"):ec,v=qw(b,w),S=g;if(e>0){let K={};for(let we of Lt()){let je=ze(we).severity;je&&(K[je]=(K[je]||0)+1)}let pt=me.filter(we=>K[we]>0);pt.length>0&&(S=c`<span class="status-bar" aria-hidden="true">${pt.map(we=>{let je=`${K[we]} ${we.replaceAll("_"," ")}`;return c`<span class="${`status-seg sev-${we}`}" style="${ve({flexGrow:K[we]})}" title="${je}"></span>`})}</span>`)}let F=Gw(r,n),I=c`<span class="sep" aria-hidden="true"></span>`,N=a.currentView==="files",de=(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>${d}${h}${F}${de}${Jw()}</h1><div class="meta-row"><span>${y}</span> ${S} ${v.length>0?c`${I}${v.map(K=>c`<span class="tag">${K}</span>`)}`:g}</div></div></header>`}function Jw(){if(O.status!=="online")return g;if(a.currentView!=="findings"&&a.currentView!=="files")return g;let e=Qw();if(!e)return g;let{workspaceId:t,fileNames:r,mode:n}=e;if(n==="single"){let k=r[0],w=ml(t,k)?"cloud":"local";return Xw({status:w,label:w,title:w==="cloud"?"Synced to remote":"Local only \u2014 click to upload",onClick:w==="local"?()=>eh({workspaceId:t,items:[{kind:"report",identifier:k}]}):null})}let o=z().find(k=>k.id===t),s=o&&Array.isArray(o.bundles)?o.bundles:[],i=lp(t),l=r.filter(k=>!ml(t,k)),d=s.filter(k=>!ip(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(),Qf({workspaceId:t,cloudCount:i,localFileNames:r,localBundles:s})}}">${ih()}<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(),eh({workspaceId:t,items:u})}}">${sh()}<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 Xw({status:e,label:t,title:r,onClick:n}){let o=e==="cloud"?ih():sh(),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 sh(){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 ih(){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 eh({workspaceId:e,items:t}){let r=t.filter(n=>n.kind==="bundle");if(r.length>0){let n=await ct(),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 Yf({workspaceId:e,items:t})}function Qw(){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=z().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 Zw(e){return Object.values(e).some(r=>r>0)||a.filterSeverities.size>0?c`<severity-chips .counts="${e}"></severity-chips>`:g}function ev(e){return Object.values(e).some(r=>r>0)||a.filterColors.size>0?c`<triage-filter .counts="${e}"></triage-filter>`:g}function tv(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">${Zw(n)} ${i.length>1?c`<analyzer-select .options="${i}"></analyzer-select>`:g} ${m&&l.length>1?c`<repo-filter .options="${l}"></repo-filter>`:g} ${ev(o)}<div class="search-row"><toolbar-search kind="findings"></toolbar-search><span class="result-count">${e} of ${t}</span></div></div></div>`}var vo=null,th=0,tr=null,li=new Map;function ko(e,t=!1,r=null){let n=tn(e);return li.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 rv={critical:"C",high:"H",medium:"M",low:"L",high_bug:"H",bug:"B",informational:"i"};function rh(e,t={}){let{variant:r="kanban",active:n=!1}=t,o=be(e),s=Se(e),i=Hs(rt(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=rv[s.severity]??"?",h=a.triage.get(L(s))?.flagged===!0,b=c`<div class="kanban-badge-col"><span class="${`kanban-badge sev-${s.severity}`}" title="${en(s.severity)}" aria-label="${en(s.severity)}">${f}</span> ${h?c`<span class="kanban-flag" title="Flagged" aria-label="Flagged">${Al}</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="${_e(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="${_e(e)}" data-focus-select role="button" tabindex="0" aria-current="${n?"true":"false"}" aria-label="${`Focus on ${i}`}">${b}</div>`}function nv(e){let{content:t,line:r,highlighted:n}=e,o=t.split(`
52
- `).length,s=String(o).length;return c`<div class="focus-code-lines" style="${ve({"--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"?fe(n):t}</code></pre></div>`}function ov(e){if(!e)return g;let t=be(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">${ko(e,!1,"kanban-detail")}</div></div></div>`}function sv(e){if(a.viewMode==="table"){let r=a.sortBy==="file"?[...e].toSorted((s,i)=>{let l=ze(s),d=ze(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=>_e(s)===a.tableSelectedGid):null;return vo=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">${ko(n)}</div></aside>`:g}</div>`}if(a.viewMode==="focus"){if(e.length===0)return g;let r=a.focusGid?e.findIndex(d=>_e(d)===a.focusGid):-1;r<0&&(r=Math.min(th,e.length-1),r<0&&(r=0)),th=r;let n=e[r];a.focusCodeTick;let o=qf(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">${ko(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">${nv(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">${Q(e,d=>_e(d),d=>rh(d,{variant:"focus",active:_e(d)===_e(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=be(s).commonTriage??"untriaged",d=n.get(l);d&&d.push(s)}let o=a.kanbanPopoverGid?e.find(s=>_e(s)===a.kanbanPopoverGid):null;return c`<div class="kanban-board">${Q(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>`:Q(i,l=>_e(l),l=>rh(l,{active:_e(l)===a.kanbanPopoverGid}))}</div></div>`})}</div>${ov(o)}`}if(a.viewMode==="grouped"){let r=new Map;for(let o of e){let s=ze(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`${Q(n,o=>o,o=>{let s=a.sortBy==="file"?r.get(o).toSorted((l,d)=>parseInt(ze(l).line,10)-parseInt(ze(d).line,10)):r.get(o),i=ze(s[0]);return c`<div class="file-group"><div class="file-header"><span>${$l(o,i?.repo?.github,i?._repoFallback??a.repoUrl)}</span> <span class="count">${s.length}</span></div><div class="file-body">${Q(s,l=>tn(l),l=>ko(l))}</div></div>`})}`}let t=a.sortBy==="file"?[...e].toSorted((r,n)=>{let o=ze(r),s=ze(n);return o.file.localeCompare(s.file)||parseInt(o.line,10)-parseInt(s.line,10)}):e;return c`${Q(t,r=>tn(r),r=>{let n=Se(r),o=Rp(n.file,n.line,n.repo?.github,n._repoFallback??a.repoUrl),s=$r(n),i=kr(n),l=r.length>1;return c`<div class="${R({"flat-group":!0,"multi-case":l})}"><div class="flat-group-loc"><span class="file">${$l(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>${ko(r,!0)}</div>`})}`}function iv(){let e=document.querySelector("#bundle-source-overlay-slot");e&&W(Df(),e)}var nh=null;function $(){let e=nh;if(nh=a.currentView,e!==null&&e!==a.currentView&&typeof document.startViewTransition=="function"&&!matchMedia("(prefers-reduced-motion: reduce)").matches){document.startViewTransition(()=>oh());return}oh()}function oh(){if(iv(),Ep(a.reports),a.currentView==="bundles")if((a.bundles??[]).length===0)a.currentView="findings";else{let _=document.querySelector("#bundles-slot");if((!_||!C.contains(_)||C.firstElementChild!==_)&&(C.innerHTML='<div id="bundles-slot"></div>',_=document.querySelector("#bundles-slot")),_&&W(Wf(a.bundles),_),a.selectedBundle&&a.bundleDetailsTab==="graph"&&a.bundleDetails&&(a.bundleDetails.json||a.bundleDetails.bundle)){let B=document.querySelector("#bundle-graph-slot");if(B){let te=Lf(a.bundleDetails);if(te){Pf(te);let Ae=!te.hasEdges,_i=Mf(a.bundleDetails);Fl(B,te,{hideAllFiles:Ae,triageCounts:_i,triageStates:["inprogress","fixed","invalid","deleted"]},ii,ai)}}}if(a.selectedBundle&&a.bundleDetailsTab==="terminal"&&a.bundleDetails&&(a.bundleDetails.json||a.bundleDetails.bundle)){let B=document.querySelector("#bundle-terminal-slot");B&&Zp(B,a.bundleDetails)}C.classList.add("active"),Ie.classList.add("hidden"),document.title="DeepView \u2014 bundles";return}if(a.currentView==="packages"){let _=document.querySelector("#packages-slot");(!_||!C.contains(_)||C.firstElementChild!==_)&&(C.innerHTML='<div id="packages-slot"></div>',_=document.querySelector("#packages-slot")),_&&W(Hf(),_),C.classList.add("active"),Ie.classList.add("hidden"),document.title="DeepView \u2014 packages";return}if(a.currentView==="repositories"){let _=document.querySelector("#repositories-slot");(!_||!C.contains(_)||C.firstElementChild!==_)&&(C.innerHTML='<div id="repositories-slot"></div>',_=document.querySelector("#repositories-slot")),_&&W(Kf(),_),C.classList.add("active"),Ie.classList.add("hidden"),document.title="DeepView \u2014 repositories";return}if(a.reports.length===0)return;let e=Lt(),t={inprogress:0,fixed:0,invalid:0,deleted:0,ignored:0};for(let _ of e){let B=be(_).commonTriage;B&&t[B]++}let r=!1,n=!1,o=!1;for(let _ of e)for(let B of _){let te=a.triage.get(L(B));te&&(te.comment&&(r=!0),te.fix&&(n=!0),te.flagged===!0&&(o=!0))}let s=a.viewMode==="kanban",i=s?e:e.filter(_=>be(_).commonTriage===a.shownTriage),d=[...new Set(a.reports.map(_=>_.type))].join(", "),u=a.reports.map(_=>_.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 _ of i){let B=new Set(_.map(Ae=>Ae.severity));for(let Ae of B)p[Ae]=(p[Ae]||0)+1;let te=new Set(_.map(Ae=>a.triage.get(L(Ae))?.color??"none"));for(let Ae of te)f[Ae]=(f[Ae]||0)+1}let h=i.length>0&&i.every(_=>_.every(B=>B.confidence!==void 0||B.critical===!0)),b=e.some(_=>_.some(B=>B.priority!==void 0)),m=e.some(_=>_.some(B=>Jt(B.file))),y=new Set;for(let _ of e)for(let B of _)y.add(B.file);let k=y.size>1,w=e.some(_=>_.some(B=>!B.repo?.github&&!Jt(B.file))),v=new Set;for(let _ of e)for(let B of _)!Jt(B.file)&&B.repo?.github&&v.add(B.repo.github);let S=v.size===1?[...v][0]:null,F=new Set;for(let _ of e)for(let B of _)F.add(B._analyzer??null);let I=Object.keys(Cl),N=[...F].toSorted((_,B)=>{let te=_==null?1/0:I.indexOf(_)===-1?I.length:I.indexOf(_),Ae=B==null?1/0:I.indexOf(B)===-1?I.length:I.indexOf(B);return te!==Ae?te-Ae:String(_??"").localeCompare(String(B??""))});if(a.filterAnalyzer){let _=a.filterAnalyzer===io?null:a.filterAnalyzer;F.has(_)||(a.filterAnalyzer="")}let de=new Set;for(let _ of e)for(let B of _)de.add(_l(B));let K=[...de].toSorted((_,B)=>_==null&&B==null?0:_==null?1:B==null?-1:_.localeCompare(B));if(a.filterRepo){let _=a.filterRepo===ao?null:a.filterRepo;de.has(_)||(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 pt=Dp(Np(i)),we=Il(a.reports),je=we?Object.keys(we).length:0,or=je>1;!or&&a.currentView==="files"&&(a.currentView="findings"),!or&&a.viewMode==="graph"&&(a.viewMode="table");let xi=Yw(e.length,u,w,S,je);if(a.currentView==="files"){let _=Tl(e),B=document.querySelector("#header-slot"),te=document.querySelector("#tree-view-slot");(!B||!te||!C.contains(B)||!C.contains(te))&&(C.innerHTML='<div id="header-slot"></div><div id="tree-view-slot"></div>',B=document.querySelector("#header-slot"),te=document.querySelector("#tree-view-slot")),B&&W(xi,B),te&&W(Jp(we,_),te),C.classList.add("active"),Ie.classList.add("hidden"),document.title=`DeepView \u2014 ${d||"no analyzer"}`;return}let Fo=a.viewMode==="table"&&a.tableSelectedGid&&pt.some(_=>_e(_)===a.tableSelectedGid),St=null;a.viewMode==="graph"&&we&&(St=tc(),St||(a.viewMode="table"));let sr=!!St,x="findings-content";Fo&&(x+=" with-details"),sr&&(x+=" with-graph"),s&&(x+=" with-kanban"),a.viewMode==="focus"&&(x+=" with-focus");let G=g,X=g,ae=g;sr||(G=tv(pt.length,i.length,t,p,f,{showSource:m,showConfidence:h,showPriority:b,showGraphMode:or,showFileSort:k,kanbanMode:s,showRepo:!!a.currentWorkspace,hasComment:r,hasFix:n,hasFlagged:o},N,K),a.shownTriage&&i.length===0?X=c`<p style="color:var(--muted);margin:1rem 0">No ${a.shownTriage} findings.</p>`:pt.length===0&&i.length>0?X=c`<p style="color:var(--muted);margin:1rem 0">No findings match the current filters.</p>`:i.length===0&&(X=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>`),vo=null,li.clear(),ae=sv(pt));let Be=!!(tr&&tr.isConnected);Be&&tr.remove();let Ee=document.querySelector("#header-slot"),re=C.querySelector(":scope > .findings-content"),Xe=re&&re.querySelector(":scope > #findings-graph-slot"),ir=re&&re.querySelector(":scope > #findings-body-slot"),Ag=re&&(Xe?"graph":ir?"body":null)===(sr?"graph":"body");if(!Ee||!re||!C.contains(Ee)||!C.contains(re)||!Ag){let _=sr?'<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="${x}">${_}</div>`,Ee=document.querySelector("#header-slot"),re=C.querySelector(":scope > .findings-content")}else re.className!==x&&(re.className=x);Ee&&W(xi,Ee);let cd=document.querySelector("#toolbar-slot");cd&&W(G,cd);let dd=document.querySelector("#empty-state-slot");dd&&W(X,dd);let hn=document.querySelector("#findings-body-slot");if(hn&&(vo||Be)){let _=document.createElement("div");_.id="findings-body-slot",hn.replaceWith(_),hn=_}if(hn&&W(ae,hn),St){let _=document.querySelector("#findings-graph-slot");if(_){let B=c`<view-mode-buttons modes="table,list,grouped,focus,kanban,graph"></view-mode-buttons>`,te={inprogress:0,fixed:0,invalid:0,deleted:0,ignored:0};for(let _i of Lt()){let Si=be(_i).commonTriage;Si&&te[Si]++}let Ae={extraTopRow:B,triageCounts:te,triageStates:["inprogress","fixed","invalid","deleted","ignored"]};Fl(_,St.prep,Ae,rc,nc)}}if(vo){let _=C.querySelector(".finding-table-slot");_&&(tr||(tr=document.createElement("finding-table")),tr.items=vo,tr.selectedGid=a.tableSelectedGid,_.replaceWith(tr))}if(li.size>0)for(let _ of C.querySelectorAll("finding-card")){let B=li.get(_.dataset.gid);B&&(_.group=B.group)}C.classList.add("active"),Ie.classList.add("hidden"),document.title=`DeepView \u2014 ${d||"no analyzer"}`}var oc=class extends T{static styles=[...T.styles,A(tt)];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 ll(this.workspace,{password:this._noPassword?void 0:this._password,includeBundleBytes:this._includeBundleBytes});if(this._settled)return;Br(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",oc);function ah({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(ht(o.detail?.cause))}),document.body.append(n)})}async function lh(e){await ah({workspace:e})}var sc=class extends T{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",sc);function ch(){return V("new-workspace-dialog")}var ic=class extends T{static styles=[...T.styles,A(ye)];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 dh({name:e,reportCount:t,bundleCount:r,triageImpact:n}={}){return V("leave-workspace-dialog",{workspaceName:e??"",reportCount:t??0,bundleCount:r??0,orphanedTriage:n?.orphanedCount??0,sharedTriage:n?.sharedCount??0})}var ac=class extends T{static styles=[...T.styles,A(tt)];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 ul({id:this.workspaceId,name:this._name.trim(),privateKeyBase64:this.privateKeyBase64,password:this._password});if(this._settled)return;this._url=fl(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 are not included. 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",ac);function uh({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(ht(i.detail?.cause))}),document.body.append(s)})}var lc=class extends T{static styles=[...T.styles,A(ye)];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",lc);function ph({name:e,triageImpact:t,inRemote:r}={}){return V("delete-report-dialog",{reportName:e??"",orphanedTriage:t?.orphanedCount??0,sharedTriage:t?.sharedCount??0,inRemote:!!r})}var cc=class extends T{static styles=[...T.styles,A(ye)];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",cc);function fh({name:e,inRemote:t}={}){return V("delete-bundle-dialog",{bundleName:e??"",inRemote:!!t})}var dc=class extends T{static styles=[...T.styles,A(ye)];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",dc);function hh({name:e,workspaceName:t}={}){return V("detach-bundle-dialog",{bundleName:e??"",workspaceName:t??""})}var uc=class extends T{static styles=[...T.styles,A(ye)];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",uc);function gh({name:e,workspaceName:t}={}){return V("detach-report-dialog",{reportName:e??"",workspaceName:t??""})}var pc=class extends T{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 mh(){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 rr;function av(){return rr||(rr=document.createElement("div"),rr.id="styled-tooltip",document.body.append(rr),rr)}var Er=null,$o=null,vh=0,kh=0,bh=!1;function lv(){bh||(bh=!0,document.addEventListener("mousemove",e=>{vh=e.clientX,kh=e.clientY},{passive:!0}))}lv();var cv=100,dv=14,uv=8,yh=8;function pv(e,{placement:t="cursor"}={}){let r=av();if(Er===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+uv)}px`,r.style.transform="translateY(-50%)"}else{r.style.transform="none",r.style.top=`${kh+dv}px`,r.style.left="0px",r.classList.add("visible");let o=r.offsetWidth,s=window.innerWidth-o-yh,i=Math.max(yh,Math.min(vh,s));r.style.left=`${Math.round(i)}px`}r.classList.add("visible"),Er=e}}function xo(){clearTimeout($o),$o=null,rr&&rr.classList.remove("visible"),Er=null}function fc(e,{gate:t,placement:r}={}){t&&!t(e)||(clearTimeout($o),$o=setTimeout(()=>{pv(e,{placement:r})},cv))}var wh=!1;function $h(){wh||(wh=!0,document.body.addEventListener("mouseover",e=>{let t=e.target.closest("[data-tooltip]");!t||t===Er||(xo(),fc(t))}),document.body.addEventListener("mouseout",e=>{!Er&&!$o||Er&&Er.contains(e.relatedTarget)||xo()}))}var di=null,ie=null,ci=null;$h();function fv(){return yt().size}function hv(){return yr().size}var _o=typeof location>"u"||location.hostname.endsWith(".github.io")?"":`${location.protocol==="https:"?"wss:":"ws:"}//${location.host}/api/sync`,wc="application/x-deepview-report",mc="application/x-deepview-source-ws",So="application/x-deepview-bundle",ui=!1,pi=!1,gv={default:"Reports","claude-security":"Claude Security","codex-security":"Codex Security",deepsec:"DeepSec"},xh=["default","claude-security","codex-security","deepsec"],Ar="";function _h(e,t={}){let n=`file-item${e===a.currentFile&&(a.currentView==="findings"||a.currentView==="files")?" current":""}${t.indented?" indented":""}`,o=Re(e),s=zn(e),i=Y[qe(e)]??Y.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}">${fe(i)}<span class="file-label">${o}</span>${s===void 0?g:c`<span class="file-count">${s}</span>`}</button></li>`}function mv(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 bv=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 yv(){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">${bv}</button></span></li>`}function wv(){return c`<li class="file-group-header bundles-header" data-default-bundles="true"><span class="group-label">Bundles</span></li>`}var vv=c`${fe(nn)}`;function Sh(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}
53
- ${r}`}">${vv}<span class="file-label">${n}</span></button></li>`}function kv(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 $v(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 · ${Re(e)}</em></span></span></li>`}var xv=c`${fe(Vs)}`,_v=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>`,Sv=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>`,Cv=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 Ev(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">${xv}<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">${Cv}</button><button type="button" class="workspace-export" data-action="export-workspace" title="Export workspace" aria-label="Export workspace">${_v}</button><button type="button" class="workspace-leave" data-action="leave-workspace" title="Leave workspace" aria-label="Leave workspace">${Sv}</button></li>`}function dn(e){return Ar?Re(e).toLowerCase().includes(Ar):!0}var hc=(e,t)=>Re(e).localeCompare(Re(t));async function j(){await tl(),wt().catch(()=>{});let e=await ce(),t=z(),r=await ct();if(a.bundles=r,!ie)return;di.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 xh)l.set(h,[]);for(let h of e){if(o.has(h)||!dn(h))continue;let b=qe(h);l.has(b)||l.set(b,[]),l.get(b).push(h)}let d=t.filter(h=>!Ar||h.name.toLowerCase().includes(Ar)||h.reports.some(b=>dn(b))?!0:h.bundles.some(b=>{let m=s.get(b);return m&&dn(m.name)})),u=r.filter(h=>!i.has(h.integrity)&&dn(h.name));W(c`${yv()} ${Q(d,h=>h.id,h=>{let b=[],m=[];for(let w of h.reports)dn(w)&&(n.has(w)?b.push(w):m.push(w));b.sort(hc),m.sort(hc);let y=[],k=[];for(let w of h.bundles){let v=s.get(w);v?(!Ar||dn(v.name))&&y.push(v):Ar||k.push(w)}return c`${Ev(h)} ${b.map(w=>_h(w,{indented:!0,workspaceId:h.id}))} ${m.map(w=>$v(w,h.id))} ${y.map(w=>Sh(w,{workspaceId:h.id}))} ${k.map(w=>kv(w,h.id))}`})} ${xh.map(h=>{let b=(l.get(h)??[]).toSorted(hc),m=h==="default";return b.length===0&&!(m&&ui)?null:c`${mv(gv[h]??h,{dropTarget:m})} ${b.map(y=>_h(y))}`})} ${u.length>0||pi?wv():null} ${Q(u,h=>h.integrity,h=>Sh(h))}`,ci);let p=ie.querySelector('sidebar-view-button[kind="packages"]');p&&(p.count=fv());let f=ie.querySelector('sidebar-view-button[kind="repositories"]');f&&(f.count=hv()),fi(),Ta(e,()=>{j()})}ge(()=>{j()});async function Av(e){if(e.target.closest('[data-action="go-home"]')){await xf();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.bundleDetailsTab="overview",E.showAll=!0,a.shownTriage=null,cn(d),$(),j(),Qt(d);return}let r=e.target.closest("sidebar-view-button");if(r){let d=r.getAttribute("kind");(d==="packages"||d==="repositories")&&(a.currentView=d,$(),j());return}if(e.target.closest('[data-action="new-workspace"]')){let d=await ch();d&&(await Wl(),await Wa(d),j());return}let n=e.target.closest('[data-action="share-workspace"]');if(n){let d=n.closest("[data-workspace-id]"),u=d?z().find(p=>p.id===d.dataset.workspaceId):null;u&&uh({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?z().find(p=>p.id===d.dataset.workspaceId):null;u&&lh(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?z().find(y=>y.id===d.dataset.workspaceId):null;if(!u)return;let p=Array.isArray(u.reports)?u.reports:[],f;try{f=await _s(p)}catch(y){alert(`Couldn't read reports to analyze triage impact: ${y.message}`);return}let{confirmed:h,mode:b,triage:m}=await dh({name:u.name,reportCount:p.length,bundleCount:u.bundles.length,triageImpact:f});if(!h)return;if(!z().some(y=>y.id===u.id)){alert(`Workspace "${u.name}" was removed elsewhere; nothing to leave.`);return}try{await Sf(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)&&er(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")&&_t(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=z().filter(v=>Array.isArray(v.bundles)&&v.bundles.includes(m)).filter(v=>bl(v.id,m)).map(v=>v.id),{confirmed:w}=await fh({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 _f({deleteFromRemoteWorkspaceIds:k})}catch(v){alert(`Failed to delete bundle: ${v.message}`)}return}if(!a.currentFile)return;let d=a.currentFile,u;try{u=await _s([d])}catch(m){alert(`Couldn't read reports to analyze triage impact: ${m.message}`);return}let p=z().filter(m=>Array.isArray(m.reports)&&m.reports.includes(d)).filter(m=>ro(m.id,d)).map(m=>m.id),f=p.length>0,{confirmed:h,triage:b}=await ph({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 $f({triage:b,deleteFromRemoteWorkspaceIds:p})}catch(m){alert(`Failed to delete report: ${m.message}`)}return}if(e.target.closest("#sync-status")){O.status==="error"?O.dismissError():O.status==="off"?(!O.getServerUrl()&&_o&&O.setServerUrl(_o),O.setEnabled(!0)):O.setEnabled(!1);return}if(e.target.closest("#sidebar-toggle")){di.classList.toggle("collapsed");try{localStorage.setItem("deepview.sidebarCollapsed",di.classList.contains("collapsed")?"1":"0")}catch{}}}function Tv(e){let t=e.target.closest("[data-tooltip]");if(!t){xo();return}fc(t,{placement:"right",gate:r=>{let n=r.querySelector(".file-label");return!n||(r.dataset.tooltip??"")!==n.textContent?!0:n.scrollWidth>n.clientWidth}})}function Iv(e){let t=e.target.closest("[data-tooltip]"),r=e.relatedTarget?.closest?.("[data-tooltip]")??null;t&&t===r||xo()}function Rv(e){Ar=e.target.value.trim().toLowerCase(),j()}var Fv={off:"Sync off",online:"Online",offline:"Offline",connecting:"Connecting\u2026",error:"Sync error"};function Bv(){return O.getServerUrl()||_o?z().length>0:!1}function fi(e){let t=ie?.querySelector("#sync-status");if(!t)return;let r=Bv();if(r&&O.isEnabled()&&op().catch(i=>{console.warn("sync: load failed",i)}),r&&!O.getServerUrl()&&_o&&O.isEnabled()&&O.setServerUrl(_o),O.setForcedOff(!r),!r){t.hidden=!0;return}t.hidden=!1;let n=e??O.status;t.dataset.status=n;let o=O.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=Fv[n]??"")}O.onStatusChange(fi);var gc=!1,bc=!1;async function Ch(){if(!O.persistenceDegraded||bc||gc)return;gc=!0;let{shown:e}=await mh();if(gc=!1,e){bc=!0;return}O.persistenceDegraded&&setTimeout(Ch,1500)}O.onPersistenceDegraded(e=>{fi(),e?Ch():bc=!1});function Mv(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=z().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 ja(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 hi(){for(let e of ie.querySelectorAll(".drag-over"))e.classList.remove("drag-over")}function Eh(e){return e.dataTransfer.types.includes(wc)||e.dataTransfer.types.includes(So)}function Lv(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(So,n),e.dataTransfer.setData(mc,t.dataset.workspaceId??""),e.dataTransfer.setData("text/plain",n),t.classList.add("dragging"),pi=!0,j();return}let r=e.target.closest(".file-item[data-file]");r&&(e.dataTransfer.effectAllowed="move",e.dataTransfer.setData(wc,r.dataset.file),e.dataTransfer.setData(mc,r.dataset.workspaceId??""),e.dataTransfer.setData("text/plain",r.dataset.file),r.classList.add("dragging"),ui=!0,j())}function Pv(){for(let e of ie.querySelectorAll(".dragging"))e.classList.remove("dragging");hi(),(ui||pi)&&(ui=!1,pi=!1,j())}function Nv(e){if(!Eh(e))return;e.preventDefault();let t=e.target.closest("[data-workspace-id]"),r=ie.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",hi(),!s)if(t){let i=t.dataset.workspaceId;for(let l of ie.querySelectorAll(`[data-workspace-id="${CSS.escape(i)}"]`))l.classList.contains("dragging")||l.classList.add("drag-over")}else{let l=e.dataTransfer.types.includes(So)?"[data-default-bundles]":"[data-default-reports]",d=ie.querySelector(l);d&&d.classList.add("drag-over")}}function Ov(e){ie.contains(e.relatedTarget)||hi()}async function Dv(e){if(!Eh(e))return;e.preventDefault(),e.stopPropagation(),hi();let t=e.target.closest("[data-workspace-id]"),r=t?t.dataset.workspaceId:null,n=e.dataTransfer.getData(mc)||null;if(e.dataTransfer.types.includes(So)){let s=e.dataTransfer.getData(So);if(!s)return;if(n&&n!==r&&bl(n,s)){let i=(a.bundles??[]).find(u=>u.integrity===s)?.name??s,l=z().find(u=>u.id===n),{confirmed:d}=await hh({name:i,workspaceName:l?.name??""});if(!d)return;try{await Bs(n,s)}catch(u){console.warn(`Failed to remove '${i}' from source workspace ${n} remote:`,u)}}r&&await vr(s,r),n&&n!==r&&await Ya(s,n),j();return}let o=e.dataTransfer.getData(wc);if(o){if(n&&n!==r&&ro(n,o)){let s=z().find(l=>l.id===n),{confirmed:i}=await gh({name:o,workspaceName:s?.name??""});if(!i)return;try{await Fs(n,o)}catch(l){console.warn(`Failed to remove '${o}' from source workspace ${n} remote:`,l)}}r&&await It(o,r),n&&n!==r&&await qn(o,n),j()}}function Uv(e){di=e,ie=e.renderRoot,ci=ie.querySelector("#file-list"),_p(ie.querySelector("#encryption-toggle")),ie.addEventListener("click",Av),ie.addEventListener("dblclick",Mv),ie.addEventListener("dragstart",Lv),ie.addEventListener("dragend",Pv),ie.addEventListener("dragover",Nv),ie.addEventListener("dragleave",Ov),ie.addEventListener("drop",Dv),ci.addEventListener("mouseover",Tv),ci.addEventListener("mouseout",Iv),ie.querySelector("#sidebar-search-input")?.addEventListener("input",Rv),fi(O.status),j()}var yc=class extends H{static styles=[A(vp),A(wp)];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(){Uv(this)}};customElements.define("app-sidebar",yc);var Ah={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 Th(){hp(async(e,t,r)=>{let n=Ra(e);try{return await ri(e,n,Ah[r]??Ah.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 vc=class extends T{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",vc);function Ih({retry:e=!1}={}){return V("sync-auth-dialog",{retry:!!e})}function Rh(){fp(async({retry:e})=>{try{return await Ih({retry:e})}catch(t){return console.warn("Sync auth dialog failed to open:",t),null}})}var gi="https://triage.space/",zv=[{hostname:"deepaudit.dev",pathPrefix:"/",supportsSync:!0},{hostname:"chalker.github.io",pathPrefix:"/deepview/",supportsSync:!1}];function Wv(){for(let e of zv)if(location.hostname===e.hostname&&location.pathname.startsWith(e.pathPrefix))return e;return null}var Hv=["deepview.triage","deepview.triage.pending"],jv="deepview.repoUrls";function Vv(){try{for(let e of Hv)if(localStorage.getItem(e))return!0}catch{return!0}try{let e=localStorage.getItem(jv);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 Kv(){if(Vv())return!0;let e=[];try{e=await ce()}catch{return!0}if(e.length>0)return!0;try{if(z().length>0)return!0}catch{return!0}try{return await da()}catch{return!0}}var kc=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="${gi}" target="_blank" rel="noopener noreferrer">${gi}</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",kc);function Gv(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 Fh(){let e=Wv();return e?await Kv()?await Gv(e)?(location.assign(gi),!0):!1:(location.replace(gi),!0):!1}var $c=class extends T{static styles=[...T.styles,A(tt)];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 pl({encoded:this.encoded,password:this._password});if(this._settled)return;let r=z().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=vt(this._name);if(!t)return;let r=z().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 z())if(r.id!==this._decoded.id&&vt(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=vt(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",$c);function Bh({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(ht(o.detail?.cause))}),document.body.append(n)})}var Ne=null,mi=!1,Co=null;function qv(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 Yv(){if(Ne)return Ne;Ne=document.createElement("div"),Ne.id="lock-overlay",Ne.setAttribute("role","dialog"),Ne.setAttribute("aria-modal","true"),Ne.setAttribute("aria-label","Unlock DeepView"),Ne.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=`
54
57
  <div class="lock-overlay-card">
55
58
  <div class="lock-overlay-icon" aria-hidden="true">
56
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>
@@ -67,30 +70,30 @@ ${r}`}">${vv}<span class="file-label">${n}</span></button></li>`}function kv(e,t
67
70
  <a href="#" class="lock-overlay-wipe">Wipe local data and start over</a>
68
71
  </p>
69
72
  </div>
70
- `;let e=Ne.querySelector("button"),t=Ne.querySelector(".lock-overlay-error");return e.addEventListener("click",async()=>{if(!mi){mi=!0,t.hidden=!0,t.textContent="",e.disabled=!0,e.textContent="Waiting\u2026",Co=new AbortController;try{let n=await Tn({signal:Co.signal})}catch(n){let o=qv(n);t.textContent=o,t.hidden=!o}finally{mi=!1,Co=null,e.disabled=!1,e.textContent="Unlock with passkey"}}}),Ne.querySelector(".lock-overlay-wipe").addEventListener("click",async n=>{if(n.preventDefault(),!mi&&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?
71
74
 
72
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.
73
76
 
74
- 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 In()}catch(o){alert(`Wipe failed: ${o?.message??o}. Try again or clear localStorage manually via DevTools.`);return}location.reload()}}),document.body.append(Ne),Ne}function Jv(){return bt()?Z()&&!it():!1}function Mh(){if(Jv()){let e=Yv();e.hidden=!1;let t=e.querySelector("button");t&&t.focus()}else if(Ne&&(Ne.hidden=!0,Co))try{Co.abort()}catch{}}ge(Mh);Mh();var Lh=`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)}}
75
- `;var xc=class extends T{static styles=[...T.styles,A(an),A(Lh)];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">${ln(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",xc);function Ph({initial:e="",finding:t=null}={}){return V("comment-dialog",{initial:e,finding:t})}var Nh=`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}
76
- `;var _c=class extends T{static styles=[...T.styles,A(an),A(Nh)];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=Qr(o);return c`<dialog @close="${this._onClose}"><header><h3>${n?"Edit fix link":"Add fix link"}</h3><div class="finding">${ln(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",_c);function Oh({initial:e="",finding:t=null}={}){return V("fix-link-dialog",{initial:e,finding:t})}var Zv={critical:"Critical",high:"High",medium:"Medium",low:"Low",high_bug:"High Bug",bug:"Bug",informational:"Informational"},e0=["critical","high","medium","low","high_bug","bug","informational"];function t0(e){return Zv[e]??e}function Dh(e){let t=e0.indexOf(e);return t===-1?999:t}function Uh(e){let t=parseInt(e.line,10);return Number.isFinite(t)?`${e.file}:${t}`:e.file}function r0(e){let t=L(e),r=a.triage.get(t),n=r?.triage,o=Zr(e),s=r?.color,i=r?.comment??"",l=rt(e.description??"",e),d=kr(e),p=[d?`### ${Uh(e)} - ${d}`:`### ${Uh(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:** ${rt(e.recommendation,e).trim()}`),p.push("")),e.confidenceReason&&(p.push(`**Confidence reason:** ${rt(e.confidenceReason,e).trim()}`),p.push("")),e.fix&&(p.push(`**Fix:** ${rt(e.fix,e).trim()}`),p.push("")),i&&(p.push(`**Comment:** ${i.trim()}`),p.push("")),p.join(`
77
- `)}function n0(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(`
78
- `);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)=>Dh(s)-Dh(i));for(let s of o){let i=n.get(s);r.push(`## ${t0(s)} (${i.length})`),r.push("");for(let l of i)r.push(r0(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(`
79
82
  `).trimEnd()+`
80
- `}function o0(e){return e.map(n0).join(`
83
+ `}function Tk(e){return e.map(Ak).join(`
81
84
  ---
82
85
 
83
- `)}function s0(e){let t=e.map(n=>n.fileName),r="";return t.length===1?r=t[0]:t.length>1&&(r=Ds(t)),r=r.replace(/\.json$/u,""),`${r||"deepview-report"}.md`}function zh(e){if(e.length===0)return;let t=o0(e),r=new Blob([t],{type:"text/markdown;charset=utf-8"});Br(r,s0(e))}va(()=>{a.currentView==="bundles"&&a.selectedBundle?$():a.currentView==="packages"?$():a.currentView==="repositories"?$():(a.currentView==="findings"||a.currentView==="files")&&j().catch(()=>{})});function Wh(){a.currentView==="bundles"&&a.bundleDetailsTab==="graph"?ii():rc()}function yi(){a.currentView==="bundles"&&a.bundleDetailsTab==="graph"?ai():nc()}function Ao(){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 Cc(e){let r=document.querySelector(e)?.scrollTop??0;$();let n=document.querySelector(e);n&&(n.scrollTop=r)}function nr(){a.viewMode==="table"?Cc(".findings-table-list"):$()}function J(e,t){for(let r of e.composedPath())if(r?.matches?.(t))return r;return null}function Hh(e){let r=J(e,"[data-gid]")?.dataset?.gid,n=r?xr(r):null;if(!n)return null;let o=Se(n);return Bp(o,zs(o))}C.addEventListener("click",e=>{let t=J(e,"[data-finding-code-bundle]");if(t){let x=t.dataset.findingCodeBundle,G=t.dataset.findingCodeFile,X=t.dataset.findingCodeLine,ae=X?parseInt(X,10):null;a.bundleSourceFile=G||null,a.bundleSourceFindingIdx=null,a.bundleDetailsTab==="code"&&(a.bundleDetailsTab="overview");let Be=()=>{Number.isFinite(ae)&&queueMicrotask(()=>{let Ee=document.querySelector(`.bundle-source-lineno-row[data-line="${ae}"]`);Ee&&Ee.scrollIntoView({block:"start",behavior:"instant"})})};if(a.selectedBundle===x&&a.bundleDetails?.integrity===x){$(),Be();return}a.selectedBundle=x,a.bundleDetails=null,$(),(async()=>(await Qt(x),Be()))();return}let r=e.target.closest("[data-package-expand]");if(r){let x=r.dataset.packageExpand;a.expandedPackages.has(x)?a.expandedPackages.delete(x):a.expandedPackages.add(x),$();return}let n=e.target.closest("[data-package-row-issues]");if(n){let x=n.dataset.packageRowIssues,G=n.dataset.packageRowIssuesVersion;a.selectedPackage=x,a.selectedPackageVersion=G||null,a.packageDetailsTab="issues",a.packageSlideTriage=null,a.packageSlideTransient=!0,$();return}let o=e.target.closest("[data-repository-row-issues]");if(o){let x=o.dataset.repositoryRowIssues;a.selectedRepository=x,a.repositoryDetailsTab="issues",a.repositorySlideTriage=null,a.repositorySlideTransient=!0,$();return}let s=e.target.closest("[data-select-package]");if(s){let x=s.dataset.selectPackage,G=s.dataset.selectPackageVersion??"",X=G===""?null:G;if(a.selectedPackage===x&&a.selectedPackageVersion===X)return;a.selectedPackage=x,a.selectedPackageVersion=X,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 x=i.dataset.packageTab;(x==="overview"||x==="issues")&&a.packageDetailsTab!==x&&(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),$();return}let l=e.target.closest("[data-package-report]");if(l){let x=l.dataset.packageReport;x&&_t(x);return}let d=e.target.closest("[data-select-repository]");if(d){let x=d.dataset.selectRepository;if(a.selectedRepository===x)return;a.selectedRepository=x,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 x=u.dataset.repositoryTab;(x==="overview"||x==="issues")&&a.repositoryDetailsTab!==x&&(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),$();return}let p=e.target.closest("[data-bundle-tab]");if(p){let x=p.dataset.bundleTab;ho.has(x)&&(a.bundleDetailsTab==="graph"&&x!=="graph"&&We(),a.bundleDetailsTab=x,a.bundleSourceFile=null,a.bundleSourceFindingIdx=null,a.selectedBundle&&cn(a.selectedBundle,x),$());return}if(e.target.closest("[data-advisories-consent]")){Af(),$();return}let f=e.target.closest("[data-bundle-issue-report]");if(f){let x=f.dataset.bundleIssueReport;x&&_t(x);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,Ao());return}let h=e.target.closest("[data-bundle-source-finding]");if(h){let x=parseInt(h.dataset.bundleSourceFinding,10);Number.isFinite(x)&&(a.bundleSourceFindingIdx=a.bundleSourceFindingIdx===x?null:x,Ao());return}let b=J(e,"[data-bundle-view-source]");if(b){let x=b.dataset.bundleViewSource;if(!x)return;let G=b.dataset.bundleViewFindingIdx,X=G===void 0?null:parseInt(G,10),ae=b.dataset.bundleViewLine,Be=ae?parseInt(ae,10):null;if(a.bundleSourceFile=x,Number.isFinite(X)&&(a.bundleSourceFindingIdx=X),b.closest(".bundle-code-rail")?Cc(".bundle-code-rail-body"):b.closest(".bundles-slide-body")?Cc(".bundles-slide-body"):$(),Number.isFinite(Be)){let Ee=b.dataset.bundleViewScrollBlock||"center";queueMicrotask(()=>{let re=document.querySelector(`.bundle-source-lineno-row[data-line="${Be}"]`);re&&re.scrollIntoView({block:Ee,behavior:"smooth"})})}return}if(e.target.closest('[data-action="toggle-files"]')){a.currentView==="files"?a.currentView="findings":(a.viewMode==="graph"&&We(),a.currentView="files"),document.body.classList.remove("report-fullscreen"),$();return}let y=J(e,"[data-g2-pkg]");if(y){let x=y.dataset.g2Pkg;E.solo=E.solo===x?null:x,E.solo&&(E.selected=null),Wh(),yi(),E.graphState?.requestDraw?.();return}let k=J(e,"[data-g2-select]");if(k){E.selected=k.dataset.g2Select,Wh();return}let w=J(e,"[data-g2-top-pkgs]");if(w){E.topPkgsTab=w.dataset.g2TopPkgs,yi();return}let v=J(e,"[data-g2-jump-findings]");if(v){if(a.currentView==="bundles"){a.bundleDetailsTab==="graph"&&We(),a.bundleDetailsTab="issues",a.bundleSourceFile=null,a.bundleSourceFindingIdx=null,a.selectedBundle&&cn(a.selectedBundle,"issues"),$();return}Ws(),a.filterConfMin=0,a.filterInclude=v.dataset.g2JumpFindings,a.currentView="findings",a.viewMode==="graph"&&(a.viewMode="table"),We(),$();return}let S=J(e,"[data-g2-jump-file]");if(S){let x=S.dataset.g2JumpFile;a.currentView="files",We(),$(),requestAnimationFrame(()=>{let G=document.querySelector(`#${co(x)}`);G&&G.scrollIntoView({behavior:"smooth",block:"start"})});return}if(J(e,"#g2-path-filter-clear")){E.pathFilter="";let x=document.querySelector("graph-layout")?.shadowRoot?.querySelector("#g2-path-filter");x&&(x.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,We(),$();return}let I=J(e,".graph2-triage-selector [data-triage-show]");if(I){let x=I.dataset.triageShow;a.shownTriage=a.shownTriage===x?null:x,E.layoutCache=null,E.selected=null,We(),$();return}let N=J(e,"[data-g2-focus-pkg]");if(N){E.focusedPkg=N.dataset.g2FocusPkg,E.layoutCache=null,We(),$();return}if(J(e,"#g2-back-to-full")){E.focusedPkg=null,E.layoutCache=null,We(),$();return}let de=J(e,".tab");if(de&&J(e,".tabs")){let G=J(e,"[data-gid]").dataset.gid,X=de.dataset.tid;a.activeTabByGroup.set(G,X),nr();return}let K=J(e,"[data-triage-action]");if(K){let x=K.closest(".triage-menu"),G=x?.dataset.gid;if(!G)return;let X=xr(G);if(!X)return;let ae=K.dataset.triageAction;if(!["inprogress","fixed","invalid","deleted","ignored","restore"].includes(ae))return;let Ee=be(X).hasConflict?[Se(X)]:X;for(let re of Ee){let Xe=L(re),ir=Us(re);ae==="restore"?(M(a.triage,Xe,{triage:void 0}),se(a.triage,Xe,ir,!1)):ae==="ignored"?Rt(a.triage,Xe,ir)?se(a.triage,Xe,ir,!1):(M(a.triage,Xe,{triage:void 0}),se(a.triage,Xe,ir,!0)):a.triage.get(Xe)?.triage===ae?M(a.triage,Xe,{triage:void 0}):(M(a.triage,Xe,{triage:ae}),se(a.triage,Xe,ir,!1))}try{x.hidePopover()}catch{}ne(),nr();return}if(J(e,".mark-comment")){let G=J(e,"[data-gid]").dataset.gid,X=xr(G);if(!X)return;let ae=Se(X),Be=L(ae),Ee=a.triage.get(Be)?.comment??"";Ph({initial:Ee,finding:ae}).then(re=>(re===null||(M(a.triage,Be,{comment:re||void 0}),ne(),nr()),null)).catch(()=>{});return}let we=J(e,".mark-copy");if(we){let x=Hh(e);if(x===null)return;try{navigator.clipboard.writeText(x).then(()=>(we.classList.add("copied"),setTimeout(()=>we.classList.remove("copied"),1e3),null)).catch(()=>{})}catch{}return}let je=J(e,"[data-copy-report]");if(je){let x=je.dataset.copyReport;try{navigator.clipboard.writeText(x).then(()=>(je.classList.add("copied"),setTimeout(()=>je.classList.remove("copied"),1e3),null)).catch(()=>{})}catch{}return}let or=J(e,".mark-claude");if(or){let x=Hh(e);if(x===null)return;let G=`claude://code/new?q=${encodeURIComponent(`Confirm and fix:
84
-
85
- ${x}`)}`;try{window.location.href=G,or.classList.add("copied"),setTimeout(()=>or.classList.remove("copied"),1e3)}catch{}return}if(J(e,".mark-fix")){let G=J(e,"[data-gid]").dataset.gid,X=xr(G);if(!X)return;let ae=Se(X),Be=L(ae),Ee=a.triage.get(Be)?.fix??"";Oh({initial:Ee,finding:ae}).then(re=>(re===null||(M(a.triage,Be,{fix:re||void 0}),ne(),nr()),null)).catch(()=>{});return}let Fo=J(e,"[data-flag-toggle]");if(Fo){let x=Fo.dataset.flagToggle,G=a.triage.get(x)?.flagged;M(a.triage,x,{flagged:G!==!0}),ne(),nr();return}let St=e.target.closest("[data-triage-show]");if(St&&!St.closest(".graph2-triage-selector")){let x=St.dataset.triageShow;a.shownTriage=a.shownTriage===x?null:x,$();return}if(e.target.closest("[data-table-deselect]")){a.tableSelectedGid=null,nr();return}let sr=e.target.closest("[data-tree-select]");if(sr){let x=sr.dataset.treeSelect;a.filesSelectedFile=a.filesSelectedFile===x?null:x,$();return}e.target.closest("[data-tree-deselect]")&&(a.filesSelectedFile=null,$())});var jh=document.querySelector("#bundle-source-overlay-slot");jh&&jh.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,Ao());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,Ao())}});C.addEventListener("row-select",e=>{let t=e.detail?.gid;t&&(a.tableSelectedGid=a.tableSelectedGid===t?null:t,nr())});var wi="application/x-deepview-kanban-gid";function i0(e,t){let n=be(e).hasConflict?[Se(e)]:e;for(let o of n){let s=L(o),i=Us(o);t==="untriaged"?(M(a.triage,s,{triage:void 0}),se(a.triage,s,i,!1)):t==="ignored"?(M(a.triage,s,{triage:void 0}),se(a.triage,s,i,!0)):(M(a.triage,s,{triage:t}),se(a.triage,s,i,!1))}}function Ec(){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(wi,r),e.dataTransfer.setData("text/plain",r),e.dataTransfer.effectAllowed="move",t.classList.add("dragging"))});C.addEventListener("dragend",()=>{Ec()});C.addEventListener("dragover",e=>{if(!e.dataTransfer?.types.includes(wi))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(wi))return;let t=e.target.closest?.(".kanban-column[data-kanban-target]");if(!t){Ec();return}e.preventDefault();let r=e.dataTransfer.getData(wi),n=t.dataset.kanbanTarget;if(Ec(),!r||!n)return;let o=xr(r);!o||(be(o).commonTriage??"untriaged")===n||(i0(o,n),$(),queueMicrotask(ne))});var Sc=!1;function un(e){return e?C.querySelector(`.kanban-card[data-gid="${CSS.escape(e)}"]`):null}function bi(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 Eo(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(Sc)return;Sc=!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),Sc=!1};if(r){let u=un(e);u?(bi(u),u.style.viewTransitionName="kanban-detail-modal",u.getBoundingClientRect()):bi(),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}bi(),a.kanbanPopoverGid=e;let i=null,l=document.startViewTransition(()=>{$(),i=un(t),i&&(bi(i),i.style.viewTransitionName="kanban-detail-modal")}),d=setTimeout(()=>s(i??un(t)),600);(async()=>{try{await l.finished}catch{}clearTimeout(d),s(i??un(t))})()}function a0(e){let t=un(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;Eo(i);let l=un(i);l&&(l.focus({preventScroll:!0}),l.scrollIntoView({block:"nearest",behavior:"instant"}))}C.addEventListener("click",e=>{if(e.target.closest?.(".kanban-detail-close")){Eo(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;Eo(a.kanbanPopoverGid===r?null:r);return}e.target.closest?.(".kanban-detail-modal")||a.kanbanPopoverGid&&Eo(null)});document.addEventListener("keydown",e=>{e.key==="Escape"&&a.kanbanPopoverGid&&Eo(null)});function Vh(e){if(!e||a.focusGid===e)return;a.focusGid=e,$();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 Kh(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&&Vh(o)}C.addEventListener("click",e=>{let t=e.target.closest?.("[data-focus-nav]");if(t){Kh(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&&Vh(n)});function l0(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||l0(e))return;let n=0;if(e.key==="ArrowRight")n=1;else if(e.key==="ArrowLeft")n=-1;else return;e.preventDefault(),t?Kh(n):a0(n)});C.addEventListener("mark-color",e=>{let t=J(e,"[data-gid]");if(!t)return;let r=t.dataset.gid,n=xr(r);if(!n)return;let o=L(Se(n)),s=e.detail?.color;if(!s)return;a.triage.get(o)?.color===s?M(a.triage,o,{color:void 0}):M(a.triage,o,{color:s}),ne(),nr()});var Tr=null,Ac=null;function Gh(){if(Tr!==null||a.reports.length===0)return;Tr=a.viewMode,Ac=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=Ds(e)),t=t.replace(/\.json$/u,""),t&&(document.title=t)}function qh(){Tr!==null&&(a.viewMode!==Tr&&(a.viewMode=Tr,$()),document.title=Ac,Tr=null,Ac=null)}window.addEventListener("beforeprint",Gh);window.addEventListener("afterprint",qh);document.addEventListener("print-requested",async()=>{if(a.reports.length!==0&&Tr===null){Gh();try{await Promise.all([...C.querySelectorAll("finding-card")].map(e=>e.updateComplete)),window.print()}catch(e){throw qh(),e}}});document.addEventListener("download-requested",()=>{a.reports.length!==0&&zh(a.reports)});C.addEventListener("analyzer-change",e=>{a.filterAnalyzer=e.detail.value,$()});C.addEventListener("repo-change",e=>{a.filterRepo=e.detail.value,$()});C.addEventListener("bundle-search-mode-change",e=>{let t=e.detail?.mode;t!=="files"&&t!=="code"&&t!=="issues"||(a.bundleCodeSearchMode=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;$()});C.addEventListener("range-change",e=>{e.target.id==="conf-range"&&(a.filterConfMin=e.detail.low,a.filterConfMax=e.detail.high,$())});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 return;$()});C.addEventListener("search-negate-toggle",()=>{a.filterIncludeNegate=!a.filterIncludeNegate,$()});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?.(),yi();return}a.filterSeverities.has(t)?a.filterSeverities.delete(t):a.filterSeverities.add(t),$()});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?.(),yi();return}a.filterColors.has(t)?a.filterColors.delete(t):a.filterColors.add(t),$()});C.addEventListener("source-toggle",e=>{let t=e.detail.source,r=a.filterSources.has(t);a.filterSources.clear(),r||a.filterSources.add(t),$()});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;$()});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;$()});C.addEventListener("view-mode-change",e=>{if(e.detail.kind==="files"){a.filesViewMode=e.detail.mode,$();return}a.viewMode=e.detail.mode;try{localStorage.setItem(ps,a.viewMode)}catch{}a.viewMode!=="kanban"&&(a.kanbanPopoverGid=null),a.viewMode!=="focus"&&(a.focusGid=null),$()});C.addEventListener("repo-edit-start",()=>{a.repoEditing=!0,$()});C.addEventListener("repo-input",e=>{a.repoUrl=e.detail.url,Ke(a.currentFile,a.repoUrl)});C.addEventListener("repo-commit",e=>{a.repoUrl=e.detail.url,Ke(a.currentFile,a.repoUrl),a.repoEditing=!1,$()});C.addEventListener("repo-cancel",e=>{a.repoUrl=e.detail.url,Ke(a.currentFile,a.repoUrl),a.repoEditing=!1,$()});document.addEventListener("keydown",e=>{if(e.key==="Escape"){if(a.bundleSourceFindingIdx!=null){a.bundleSourceFindingIdx=null,Ao();return}a.bundleSourceFile&&(a.bundleSourceFile=null,$())}});var Yh=`: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}}
86
- `;var Tc="deepview.theme",pn=Object.freeze(["dark","light","green","pink"]),d0={dark:{base:"#1a1a1b",dim:"#0a0a0a"},light:{base:"#f6f6fa",dim:"#646464"},green:{base:"#0a140a",dim:"#050a05"},pink:{base:"#ffe4ee",dim:"#a3727f"}},u0="\u2600",p0="\u263E",Ic="deepview-theme-changed",vi="dark",Fc=!1;function f0(){try{let e=localStorage.getItem(Tc);return pn.includes(e)?e:"dark"}catch{return"dark"}}function To(e){pn.includes(e)||(e="dark"),vi=e;for(let r of pn)r!=="dark"&&document.body.classList.remove(`theme-${r}`);e!=="dark"&&document.body.classList.add(`theme-${e}`);try{e==="dark"?localStorage.removeItem(Tc):localStorage.setItem(Tc,e)}catch{}let t=document.querySelector('meta[name="theme-color"]');if(t){let{base:r,dim:n}=d0[e];t.setAttribute("content",Fc?n:r)}window.dispatchEvent(new CustomEvent(Ic,{detail:{theme:e}}))}To(f0());window.addEventListener("beforeprint",()=>{Fc=!0,To(vi)});window.addEventListener("afterprint",()=>{Fc=!1,To(vi)});function Jh(e){if(!pn.includes(e))throw new TypeError(`DeepView.setTheme: unknown theme ${JSON.stringify(e)} (expected one of ${pn.map(t=>JSON.stringify(t)).join(", ")})`);To(e)}function Xh(){return vi}var Qh=pn,Rc=class extends H{static properties={_light:{state:!0}};static styles=A(Yh);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(Ic,this._onThemeChanged)}disconnectedCallback(){window.removeEventListener(Ic,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");To(t?"dark":"light")};_onKeydown=t=>{(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this._toggle())};render(){return c`${this._light?p0:u0}`}};customElements.define("theme-toggle",Rc);var Zh=`: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}}
87
- `;var g0=["is-critical","mark-red","mark-blue","mark-green","mark-gray","has-conflict","triage-inprogress","triage-fixed","triage-invalid","triage-deleted","triage-ignored","selected"],Bc=class extends P{static properties={group:{attribute:!1},selected:{type:Boolean}};static styles=A(Zh);constructor(){super(),this.group=null,this.selected=!1}render(){if(!this.group)return c``;this.dataset.gid=lo(this.group);let t=new Set(Vp(this.group));this.selected&&t.add("selected");for(let r of g0)this.classList.toggle(r,t.has(r));return c`<div class="row">${Kp(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",Bc);var eg=`: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}
88
- `;var Mc=class extends H{static properties={items:{attribute:!1},selectedGid:{attribute:!1}};static styles=A(eg);constructor(){super(),this.items=[],this.selectedGid=null}render(){return c`${Q(this.items??[],t=>lo(t),t=>c`<finding-row .group="${t}" ?selected="${lo(t)===this.selectedGid}"></finding-row>`)}`}};customElements.define("finding-table",Mc);var tg=`: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}}
89
- `;var y0=["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"],Lc=class extends P{static properties={group:{attribute:!1},inGroup:{type:Boolean,attribute:"in-group",reflect:!0},context:{type:String,reflect:!0}};static styles=A(tg);constructor(){super(),this.group=null,this.inGroup=!1,this.context=null}render(){if(!this.group)return c``;this.dataset.gid=tn(this.group);let t=new Set(Hp(this.group));for(let r of y0)this.classList.toggle(r,t.has(r));return c`<div class="card">${jp(this.group,{context:this.context})}</div>`}connectedCallback(){super.connectedCallback(),this.hasUpdated&&this.requestUpdate()}};customElements.define("finding-card",Lc);var rg=`: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)}
90
- `;var v0=["red","blue","green","gray"],Pc=class extends H{static properties={selected:{type:String}};static styles=A(rg);constructor(){super(),this.selected=null}render(){return c`${v0.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",Pc);var Nc=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",Nc);var ng={files:"Filter files\u2026",code:"Search code\u2026",issues:"Search issues\u2026"},og={files:"Filter files",code:"Search code",issues:"Search issues"},k0=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>`,$0={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>`},Oc=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=ng[n]??ng.files;return c`${k0} <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="${R({"bundle-code-search-mode":!0,active:n===s})}" role="tab" aria-selected="${String(n===s)}" title="${og[s]??s}" aria-label="${og[s]??s}" @click="${()=>this._selectMode(s)}">${$0[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",Oc);var sg={packages:{stateKey:"packagesSearchQuery",label:"Filter packages"},repositories:{stateKey:"repositoriesSearchQuery",label:"Filter repositories"}},Dc=class extends P{static properties={kind:{type:String}};createRenderRoot(){return this}constructor(){super(),this.kind=""}render(){let t=sg[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(sg).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",Dc);var x0=[["findings-desc","Findings \u2193"],["files-desc","Files \u2193"],["reports-desc","Reports \u2193"],["name-asc","Name A\u2192Z"]],ig={packages:{stateKey:"packagesSortBy",aria:"Sort packages"},repositories:{stateKey:"repositoriesSortBy",aria:"Sort repositories"}},Uc=class extends P{static properties={kind:{type:String}};createRenderRoot(){return this}constructor(){super(),this.kind=""}render(){let t=ig[this.kind];return t?c`<select class="packages-sort" aria-label="${t.aria}" .value="${Fe(a[t.stateKey])}" @change="${this._onChange}">${x0.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(ig).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",Uc);var zc=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",zc);var ag=`: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)}
91
- `;var Wc=class extends H{static properties={min:{type:Number},max:{type:Number},step:{type:Number},low:{type:Number},high:{type:Number}};static styles=A(ag);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",Wc);var Hc=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",Hc);var lg=`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)}}
92
- `;var jc=class extends T{static styles=[...T.styles,A(lg)];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 nl();Br(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 ol(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",jc);function cg(){return V("triage-export-dialog")}var dg=`: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}}
93
- `;function ki(e){if(!e)return"";let t=e.match(/github\.com\/([^/?#]+\/[^/?#]+?)(?:\.git)?(?:[/?#]|$)/iu);return t?t[1]:e}var Vc=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>`,ug=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>`,Kc=class extends H{static properties={url:{type:String},editable:{type:Boolean,reflect:!0},editing:{type:Boolean,reflect:!0},_copied:{state:!0}};static styles=A(dg);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?ki(this.url):"Set repo";return c`<span class="${t?"chip":"chip empty"}" aria-hidden="true" inert>${Vc} <span class="label">${r}</span> <button type="button" class="edit-btn">${ug}</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?ki(this.url):"Set repo",n=t?this._copied?"chip copied":"chip":"chip empty";return c`<span class="${n}" @click="${t?null:this._onEdit}">${Vc} ${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}">${ug}</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)">${Vc} ${this._slugLabel(ki(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=ki(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",Kc);function He(e,t){for(let[r,n]of Object.entries(t))e.hasAttribute(r)||e.setAttribute(r,n)}var E0=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>`,A0=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>`,T0=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>`,I0=[{key:"comment",glyph:E0,label:"commented",stateKey:"filterComment",hasKey:"hasComment"},{key:"fix",glyph:A0,label:"fixed",stateKey:"filterFix",hasKey:"hasFix"},{key:"flag",glyph:T0,label:"flagged",stateKey:"filterFlagged",hasKey:"hasFlagged"}],Gc=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(),He(this,{role:"group","aria-label":"Annotation filter"})}render(){let t=I0.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",Gc);var R0=[["critical","Critical"],["high","High"],["medium","Medium"],["low","Low"],["high_bug","High bug"],["bug","Bug"],["informational","Info"]],qc=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(),He(this,{role:"group","aria-label":"Filter by severity"})}render(){let t=this.kind==="graph"?new Set(this.selected):a.filterSeverities,r=R0.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",qc);var F0=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>`,Yc=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}">${F0}<span>Delete current</span></button>`}};customElements.define("sidebar-delete-current",Yc);var B0=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>`,M0=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>`,pg={packages:{title:"Show packages",icon:B0,view:"packages"},repositories:{title:"Show repositories",icon:M0,view:"repositories"}},Jc=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=pg[this.kind];if(!t)return console.warn(`<sidebar-view-button>: unknown kind ${JSON.stringify(this.kind)}; expected one of ${Object.keys(pg).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",Jc);var L0=["invalid","deleted"],fg={package:{stateKey:"packageSlideTriage"},repository:{stateKey:"repositorySlideTriage"}},Xc=class extends P{static properties={counts:{attribute:!1},kind:{type:String}};createRenderRoot(){return this}constructor(){super(),this.counts={},this.kind=""}connectedCallback(){super.connectedCallback(),He(this,{role:"group","aria-label":"Triage view"})}render(){let t=fg[this.kind];if(!t)return console.warn(`<slide-triage-tabs>: unknown kind ${JSON.stringify(this.kind)}; expected one of ${Object.keys(fg).map(o=>JSON.stringify(o)).join(", ")}.`),g;let r=a[t.stateKey],n=L0.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",Xc);var P0=[["own","Sources"],["modules","Dependencies"]],Qc=class extends P{createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),He(this,{role:"group","aria-label":"Source filter"})}render(){return c`${P0.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",Qc);var N0=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>`,O0=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>`,hg={findings:{stateKey:"filterInclude",placeholder:"Search findings\u2026"},files:{stateKey:"filesSearch",placeholder:"Search files\u2026"}},Zc=class extends P{static properties={kind:{type:String}};createRenderRoot(){return this}constructor(){super(),this.kind=""}render(){let t=hg[this.kind];if(!t)return console.warn(`<toolbar-search>: unknown kind ${JSON.stringify(this.kind)}; expected one of ${Object.keys(hg).map(n=>JSON.stringify(n)).join(", ")}.`),g;let r=a[t.stateKey];return c`${N0} <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="${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}">${O0}</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",Zc);function D0(e){if(!e)return"";let t=e.match(/github\.com\/([^/?#]+\/[^/?#]+?)(?:\.git)?(?:[/?#]|$)/iu);return t?t[1]:e}var ed=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??ao,n=t==null?"(no repo)":D0(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",ed);var gg=[["none","none","unmarked"],["red","r","red"],["blue","b","blue"],["green","g","green"],["gray","x","gray"]],td=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(),He(this,{role:"group","aria-label":"Filter by mark color"})}render(){let t=this.kind==="graph"?new Set(this.selected):a.filterColors;return gg.some(([n])=>(this.counts[n]??0)||t.has(n))?c`${gg.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 U0=["inprogress","fixed","invalid","deleted","ignored"],rd={graph:"graph2-triage-selector",packages:"packages-triage-selector"},z0={inprogress:"In progress"},W0=e=>z0[e]??e.charAt(0).toUpperCase()+e.slice(1),nd=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(),He(this,{role:"group","aria-label":"Triage view"})}render(){let t=this.states??U0,r=t.reduce((s,i)=>s+(this.counts[i]??0),0),n=this.variant?rd[this.variant]:null;this.variant&&n===void 0&&console.warn(`<triage-selector>: unknown variant ${JSON.stringify(this.variant)}; expected one of ${Object.keys(rd).map(s=>JSON.stringify(s)).join(", ")} or "".`);for(let s of Object.values(rd))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=W0(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",nd);var H0={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>`},mg={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)"},od=["table","list","grouped","focus","kanban","graph"],sd=class extends P{static properties={modes:{type:String},kind:{type:String}};createRenderRoot(){return this}constructor(){super(),this.modes=od.join(","),this.kind="findings"}connectedCallback(){super.connectedCallback(),He(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=>od.includes(o)),n=r.length>0?r:od;return c`${n.map(o=>c`<button type="button" class="${R({"view-mode-btn":!0,active:t===o})}" title="${mg[o]}" aria-label="${mg[o]}" aria-pressed="${String(t===o)}" @click="${()=>this._select(o,t)}">${H0[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",sd);var j0=6,bg=14,$i=2,yg=24,Io=4;function V0(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 K0(e,t,r,n){let o=r*r,s=n*n;return Math.max(s*e/o,o/(s*t))}function wg(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,S=v>m?v:m,F=v<y?v:y,I=K0(S,F,b+v,f);if(h===p||I<=k)k=I,b+=v,m=S,y=F,h++;else break}let w=b/f;if(i>=l){let v=s;for(let S=p;S<h;S++){let F=S===h-1?s+l-v:n[S].value*u/w;r.push({node:n[S],x:o,y:v,w,h:F}),v+=F}o+=w,i-=w}else{let v=o;for(let S=p;S<h;S++){let F=S===h-1?o+i-v:n[S].value*u/w;r.push({node:n[S],x:v,y:s,w:F,h:w}),v+=F}s+=w,l-=w}p=h}return r}function vg(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())vg(t)}function kg(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+=kg(i,e.path,e,n),s+=i.count;return e.value=o,e.count=s,o}function $g(e,t,r,n,o,s,i){if(n<Io||o<Io)return;if(e.isFile){i.push({kind:"file",node:e,x:t,y:r,w:n,h:o});return}if(!(s<j0&&n>=yg&&o>=yg&&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>=bg+Io+$i?bg:0,u=t+$i,p=r+d,f=n-$i*2,h=o-d-$i;if(f<Io||h<Io)return;let b=[...e.children.values()].toSorted((m,y)=>y.value-m.value);for(let m of wg(b,{x:u,y:p,w:f,h}))$g(m.node,m.x,m.y,m.w,m.h,s+1,i)}var id=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;W(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=ut(this.details);if(!t||t.size===0){this._status="empty";return}let r=[...t.keys()],{prefix:n,stripped:o}=Mt(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 S=m.children.get(b[v]);if(S&&S.isFile){y=!0;break}S||(S={name:b[v],children:new Map,value:0,isFile:!1},m.children.set(b[v],S)),m=S}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())vg(p);let u=new Map;kg(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="${R({"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`<button type="button" class="bundle-treemap-node bundle-treemap-dir" style="${ve(s)}" data-treemap-into="${t.node.path}" data-tt-path="${`${t.node.path}/`}" data-tt-meta="${`${Ue(t.node.value)} \xB7 ${i} \xB7 ${o}%`}" aria-label="${`Zoom into ${t.node.path}`}"><span class="bundle-treemap-dirname">${t.node.name}</span></button>`;let l=mo(t.node.path),d=Pt(l),u=ve({...s,background:d,color:V0(d)}),p=l==="__own__"?"own source":l;return t.kind==="agg"?c`<button type="button" 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="${`${Ue(t.node.value)} \xB7 ${i} \xB7 ${o}%`}" aria-label="${`Zoom into ${t.node.path}`}"><span class="bundle-treemap-label">${t.node.name}/</span></button>`:c`<button type="button" 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="${`${Ue(t.node.value)} \xB7 ${o}% of bundle`}"><span class="bundle-treemap-label">${t.node.name}</span></button>`}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 wg(d,{x:0,y:0,w:this._w,h:this._h}))$g(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"} · ${Ue(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",id);var G0=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>`,ad=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}">${G0}</button>`:g}_onClick=()=>{this.dispatchEvent(new CustomEvent("print-requested",{bubbles:!0,composed:!0}))}};customElements.define("print-button",ad);var q0=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>`,ld=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}">${q0}</button>`:g}_onClick=()=>{this.dispatchEvent(new CustomEvent("download-requested",{bubbles:!0,composed:!0}))}};customElements.define("download-button",ld);function Ro(e){let t=new Map;for(let[r,n]of a.triage)n[e]&&t.set(r,n[e]);return t}var Y0={get markers(){return Ro("color")},get triageState(){return Ro("triage")},get comments(){return Ro("comment")},get fixes(){return Ro("fix")},get flags(){return Ro("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===""?M(a.triage,e,{color:void 0})&&(i=!0):a.triage.get(e)?.color!==t&&(M(a.triage,e,{color:t}),i=!0)),r!==void 0)if(r===null||r===""||r===!1)M(a.triage,e,{triage:void 0})&&(i=!0);else if(r==="inprogress"||r==="fixed"||r==="invalid"||r==="deleted")a.triage.get(e)?.triage!==r&&(M(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&&(M(a.triage,e,{comment:l}),i=!0):M(a.triage,e,{comment:void 0})&&(i=!0)}if(o!==void 0){let l=o?String(o):"";l?a.triage.get(e)?.fix!==l&&(M(a.triage,e,{fix:l}),i=!0):M(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&&(M(a.triage,e,{flagged:l}),i=!0)}return i&&(await ne(),$()),i}};window.DeepView={get reports(){return a.reports.slice()},get groups(){return Lt()},get findings(){return Lt().flat()},get currentFile(){return a.currentFile},get currentWorkspace(){return a.currentWorkspace},triage:Y0,themes:Qh,setTheme:Jh,get theme(){return Xh()},triageSync:O,refresh(){$()},export(){return cg()}};var J0={default:Y.default,"claude-security":Y["claude-security"],"codex-security":Y["codex-security"],deepsec:Y.deepsec,bundle:nn,workspace:Vs};for(let e of document.querySelectorAll(".drop-supported-icon[data-icon]")){let t=J0[e.dataset.icon];t&&(e.innerHTML=t)}pp($);Xa($);up($);O.onStatusChange($);cp(async(e,t)=>{a.currentWorkspace===e?await er(e):a.currentFile&&a.currentFile===t?await _t(t):await j()});dp(async()=>{await j(),a.currentView==="bundles"&&$()});Th();Rh();async function Cg(){let e=hl();if(!e)return!1;try{history.replaceState(null,"",location.pathname)}catch{}let t;try{t=await Bh({encoded:e})}catch(n){return alert(`Couldn't open the share-link unlock prompt: ${n.message}`),!1}if(!t)return!1;let r=await Va({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 er(r.workspace.id):await j(),!0}var fn=!1;async function Eg(){if(fn||(fn=!0,await Ut(),Ua(),await j(),await Cg()))return;let t=he(Zt);if(t)if(t.startsWith("ws:")){let r=t.slice(3);z().some(n=>n.id===r)&&await er(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=ho.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.bundleDetailsTab=i,a.shownTriage=null,E.showAll=!0,$(),Qt(o))}else(await ce()).includes(t)&&await _t(t)}var xg=Z(),_g=!1;function Sg(e){_g||(_g=!0,queueMicrotask(()=>{alert(e+" This tab will reload to refresh its state. Any unsaved edits in this tab will be lost."),location.reload()}))}ge(()=>{let e=xg,t=Z();if(xg=t,$(),!fn&&it()){Eg().catch(r=>console.warn("continueBoot:",r));return}if(fn&&t&&!it()){Sg("Encryption was just enabled in another tab.");return}fn&&e&&!t&&!Xi()&&Sg("Encryption was disabled in another tab.")});window.addEventListener("hashchange",()=>{fn&&Cg().catch(e=>console.warn("share-link hashchange:",e))});(async()=>{if(!await Fh()){try{let e=window.matchMedia?.("(display-mode: window-controls-overlay)").matches;if(!e&&localStorage.getItem("deepview.sidebarCollapsed")==="1"&&Kd.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{}Z()&&!it()||await Eg()}})();
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()}})();
94
97
  /*! Bundled license information:
95
98
 
96
99
  @lit/reactive-element/css-tag.js: