@preventive/triage 1.0.0-alpha.31 → 1.0.0-alpha.33

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.
@@ -1,24 +1,24 @@
1
- var ue=globalThis,pe=ue.ShadowRoot&&(ue.ShadyCSS===void 0||ue.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,$t=Symbol(),xt=new WeakMap,de=class{constructor(e,n,i){if(this._$cssResult$=!0,i!==$t)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=n}get styleSheet(){let e=this.o,n=this.t;if(pe&&e===void 0){let i=n!==void 0&&n.length===1;i&&(e=xt.get(n)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),i&&xt.set(n,e))}return e}toString(){return this.cssText}},W=t=>new de(typeof t=="string"?t:t+"",void 0,$t);var Et=(t,e)=>{if(pe)t.adoptedStyleSheets=e.map(n=>n instanceof CSSStyleSheet?n:n.styleSheet);else for(let n of e){let i=document.createElement("style"),r=ue.litNonce;r!==void 0&&i.setAttribute("nonce",r),i.textContent=n.cssText,t.appendChild(i)}},Fe=pe?t=>t:t=>t instanceof CSSStyleSheet?(e=>{let n="";for(let i of e.cssRules)n+=i.cssText;return W(n)})(t):t;var{is:fr,defineProperty:mr,getOwnPropertyDescriptor:hr,getOwnPropertyNames:gr,getOwnPropertySymbols:yr,getPrototypeOf:br}=Object,fe=globalThis,St=fe.trustedTypes,wr=St?St.emptyScript:"",vr=fe.reactiveElementPolyfillSupport,K=(t,e)=>t,He={toAttribute(t,e){switch(e){case Boolean:t=t?wr:null;break;case Object:case Array:t=t==null?t:JSON.stringify(t)}return t},fromAttribute(t,e){let n=t;switch(e){case Boolean:n=t!==null;break;case Number:n=t===null?null:Number(t);break;case Object:case Array:try{n=JSON.parse(t)}catch{n=null}}return n}},kt=(t,e)=>!fr(t,e),At={attribute:!0,type:String,converter:He,reflect:!1,useDefault:!1,hasChanged:kt};Symbol.metadata??=Symbol("metadata"),fe.litPropertyMetadata??=new WeakMap;var E=class extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??=[]).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,n=At){if(n.state&&(n.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((n=Object.create(n)).wrapped=!0),this.elementProperties.set(e,n),!n.noAccessor){let i=Symbol(),r=this.getPropertyDescriptor(e,i,n);r!==void 0&&mr(this.prototype,e,r)}}static getPropertyDescriptor(e,n,i){let{get:r,set:o}=hr(this.prototype,e)??{get(){return this[n]},set(s){this[n]=s}};return{get:r,set(s){let a=r?.call(this);o?.call(this,s),this.requestUpdate(e,a,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??At}static _$Ei(){if(this.hasOwnProperty(K("elementProperties")))return;let e=br(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(K("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(K("properties"))){let n=this.properties,i=[...gr(n),...yr(n)];for(let r of i)this.createProperty(r,n[r])}let e=this[Symbol.metadata];if(e!==null){let n=litPropertyMetadata.get(e);if(n!==void 0)for(let[i,r]of n)this.elementProperties.set(i,r)}this._$Eh=new Map;for(let[n,i]of this.elementProperties){let r=this._$Eu(n,i);r!==void 0&&this._$Eh.set(r,n)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){let n=[];if(Array.isArray(e)){let i=new Set(e.flat(1/0).reverse());for(let r of i)n.unshift(Fe(r))}else e!==void 0&&n.push(Fe(e));return n}static _$Eu(e,n){let i=n.attribute;return i===!1?void 0:typeof i=="string"?i:typeof e=="string"?e.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(e=>this.enableUpdating=e),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(e=>e(this))}addController(e){(this._$EO??=new Set).add(e),this.renderRoot!==void 0&&this.isConnected&&e.hostConnected?.()}removeController(e){this._$EO?.delete(e)}_$E_(){let e=new Map,n=this.constructor.elementProperties;for(let i of n.keys())this.hasOwnProperty(i)&&(e.set(i,this[i]),delete this[i]);e.size>0&&(this._$Ep=e)}createRenderRoot(){let e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return Et(e,this.constructor.elementStyles),e}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(e=>e.hostConnected?.())}enableUpdating(e){}disconnectedCallback(){this._$EO?.forEach(e=>e.hostDisconnected?.())}attributeChangedCallback(e,n,i){this._$AK(e,i)}_$ET(e,n){let i=this.constructor.elementProperties.get(e),r=this.constructor._$Eu(e,i);if(r!==void 0&&i.reflect===!0){let o=(i.converter?.toAttribute!==void 0?i.converter:He).toAttribute(n,i.type);this._$Em=e,o==null?this.removeAttribute(r):this.setAttribute(r,o),this._$Em=null}}_$AK(e,n){let i=this.constructor,r=i._$Eh.get(e);if(r!==void 0&&this._$Em!==r){let o=i.getPropertyOptions(r),s=typeof o.converter=="function"?{fromAttribute:o.converter}:o.converter?.fromAttribute!==void 0?o.converter:He;this._$Em=r;let a=s.fromAttribute(n,o.type);this[r]=a??this._$Ej?.get(r)??a,this._$Em=null}}requestUpdate(e,n,i,r=!1,o){if(e!==void 0){let s=this.constructor;if(r===!1&&(o=this[e]),i??=s.getPropertyOptions(e),!((i.hasChanged??kt)(o,n)||i.useDefault&&i.reflect&&o===this._$Ej?.get(e)&&!this.hasAttribute(s._$Eu(e,i))))return;this.C(e,n,i)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(e,n,{useDefault:i,reflect:r,wrapped:o},s){i&&!(this._$Ej??=new Map).has(e)&&(this._$Ej.set(e,s??n??this[e]),o!==!0||s!==void 0)||(this._$AL.has(e)||(this.hasUpdated||i||(n=void 0),this._$AL.set(e,n)),r===!0&&this._$Em!==e&&(this._$Eq??=new Set).add(e))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(n){Promise.reject(n)}let e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(let[r,o]of this._$Ep)this[r]=o;this._$Ep=void 0}let i=this.constructor.elementProperties;if(i.size>0)for(let[r,o]of i){let{wrapped:s}=o,a=this[r];s!==!0||this._$AL.has(r)||a===void 0||this.C(r,void 0,o,a)}}let e=!1,n=this._$AL;try{e=this.shouldUpdate(n),e?(this.willUpdate(n),this._$EO?.forEach(i=>i.hostUpdate?.()),this.update(n)):this._$EM()}catch(i){throw e=!1,this._$EM(),i}e&&this._$AE(n)}willUpdate(e){}_$AE(e){this._$EO?.forEach(n=>n.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Eq&&=this._$Eq.forEach(n=>this._$ET(n,this[n])),this._$EM()}updated(e){}firstUpdated(e){}};E.elementStyles=[],E.shadowRootOptions={mode:"open"},E[K("elementProperties")]=new Map,E[K("finalized")]=new Map,vr?.({ReactiveElement:E}),(fe.reactiveElementVersions??=[]).push("2.1.2");var Ke=globalThis,It=t=>t,me=Ke.trustedTypes,Ct=me?me.createPolicy("lit-html",{createHTML:t=>t}):void 0,Nt="$lit$",I=`lit$${Math.random().toFixed(9).slice(2)}$`,Bt="?"+I,_r=`<${Bt}>`,N=document,Z=()=>N.createComment(""),q=t=>t===null||typeof t!="object"&&typeof t!="function",Xe=Array.isArray,xr=t=>Xe(t)||typeof t?.[Symbol.iterator]=="function",ze=`[
1
+ var ue=globalThis,pe=ue.ShadowRoot&&(ue.ShadyCSS===void 0||ue.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,$t=Symbol(),xt=new WeakMap,de=class{constructor(e,n,i){if(this._$cssResult$=!0,i!==$t)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=n}get styleSheet(){let e=this.o,n=this.t;if(pe&&e===void 0){let i=n!==void 0&&n.length===1;i&&(e=xt.get(n)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),i&&xt.set(n,e))}return e}toString(){return this.cssText}},W=t=>new de(typeof t=="string"?t:t+"",void 0,$t);var Et=(t,e)=>{if(pe)t.adoptedStyleSheets=e.map(n=>n instanceof CSSStyleSheet?n:n.styleSheet);else for(let n of e){let i=document.createElement("style"),r=ue.litNonce;r!==void 0&&i.setAttribute("nonce",r),i.textContent=n.cssText,t.appendChild(i)}},Fe=pe?t=>t:t=>t instanceof CSSStyleSheet?(e=>{let n="";for(let i of e.cssRules)n+=i.cssText;return W(n)})(t):t;var{is:fr,defineProperty:hr,getOwnPropertyDescriptor:mr,getOwnPropertyNames:gr,getOwnPropertySymbols:yr,getPrototypeOf:br}=Object,fe=globalThis,St=fe.trustedTypes,wr=St?St.emptyScript:"",vr=fe.reactiveElementPolyfillSupport,K=(t,e)=>t,He={toAttribute(t,e){switch(e){case Boolean:t=t?wr:null;break;case Object:case Array:t=t==null?t:JSON.stringify(t)}return t},fromAttribute(t,e){let n=t;switch(e){case Boolean:n=t!==null;break;case Number:n=t===null?null:Number(t);break;case Object:case Array:try{n=JSON.parse(t)}catch{n=null}}return n}},kt=(t,e)=>!fr(t,e),At={attribute:!0,type:String,converter:He,reflect:!1,useDefault:!1,hasChanged:kt};Symbol.metadata??=Symbol("metadata"),fe.litPropertyMetadata??=new WeakMap;var E=class extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??=[]).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,n=At){if(n.state&&(n.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((n=Object.create(n)).wrapped=!0),this.elementProperties.set(e,n),!n.noAccessor){let i=Symbol(),r=this.getPropertyDescriptor(e,i,n);r!==void 0&&hr(this.prototype,e,r)}}static getPropertyDescriptor(e,n,i){let{get:r,set:o}=mr(this.prototype,e)??{get(){return this[n]},set(s){this[n]=s}};return{get:r,set(s){let a=r?.call(this);o?.call(this,s),this.requestUpdate(e,a,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??At}static _$Ei(){if(this.hasOwnProperty(K("elementProperties")))return;let e=br(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(K("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(K("properties"))){let n=this.properties,i=[...gr(n),...yr(n)];for(let r of i)this.createProperty(r,n[r])}let e=this[Symbol.metadata];if(e!==null){let n=litPropertyMetadata.get(e);if(n!==void 0)for(let[i,r]of n)this.elementProperties.set(i,r)}this._$Eh=new Map;for(let[n,i]of this.elementProperties){let r=this._$Eu(n,i);r!==void 0&&this._$Eh.set(r,n)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){let n=[];if(Array.isArray(e)){let i=new Set(e.flat(1/0).reverse());for(let r of i)n.unshift(Fe(r))}else e!==void 0&&n.push(Fe(e));return n}static _$Eu(e,n){let i=n.attribute;return i===!1?void 0:typeof i=="string"?i:typeof e=="string"?e.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(e=>this.enableUpdating=e),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(e=>e(this))}addController(e){(this._$EO??=new Set).add(e),this.renderRoot!==void 0&&this.isConnected&&e.hostConnected?.()}removeController(e){this._$EO?.delete(e)}_$E_(){let e=new Map,n=this.constructor.elementProperties;for(let i of n.keys())this.hasOwnProperty(i)&&(e.set(i,this[i]),delete this[i]);e.size>0&&(this._$Ep=e)}createRenderRoot(){let e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return Et(e,this.constructor.elementStyles),e}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(e=>e.hostConnected?.())}enableUpdating(e){}disconnectedCallback(){this._$EO?.forEach(e=>e.hostDisconnected?.())}attributeChangedCallback(e,n,i){this._$AK(e,i)}_$ET(e,n){let i=this.constructor.elementProperties.get(e),r=this.constructor._$Eu(e,i);if(r!==void 0&&i.reflect===!0){let o=(i.converter?.toAttribute!==void 0?i.converter:He).toAttribute(n,i.type);this._$Em=e,o==null?this.removeAttribute(r):this.setAttribute(r,o),this._$Em=null}}_$AK(e,n){let i=this.constructor,r=i._$Eh.get(e);if(r!==void 0&&this._$Em!==r){let o=i.getPropertyOptions(r),s=typeof o.converter=="function"?{fromAttribute:o.converter}:o.converter?.fromAttribute!==void 0?o.converter:He;this._$Em=r;let a=s.fromAttribute(n,o.type);this[r]=a??this._$Ej?.get(r)??a,this._$Em=null}}requestUpdate(e,n,i,r=!1,o){if(e!==void 0){let s=this.constructor;if(r===!1&&(o=this[e]),i??=s.getPropertyOptions(e),!((i.hasChanged??kt)(o,n)||i.useDefault&&i.reflect&&o===this._$Ej?.get(e)&&!this.hasAttribute(s._$Eu(e,i))))return;this.C(e,n,i)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(e,n,{useDefault:i,reflect:r,wrapped:o},s){i&&!(this._$Ej??=new Map).has(e)&&(this._$Ej.set(e,s??n??this[e]),o!==!0||s!==void 0)||(this._$AL.has(e)||(this.hasUpdated||i||(n=void 0),this._$AL.set(e,n)),r===!0&&this._$Em!==e&&(this._$Eq??=new Set).add(e))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(n){Promise.reject(n)}let e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(let[r,o]of this._$Ep)this[r]=o;this._$Ep=void 0}let i=this.constructor.elementProperties;if(i.size>0)for(let[r,o]of i){let{wrapped:s}=o,a=this[r];s!==!0||this._$AL.has(r)||a===void 0||this.C(r,void 0,o,a)}}let e=!1,n=this._$AL;try{e=this.shouldUpdate(n),e?(this.willUpdate(n),this._$EO?.forEach(i=>i.hostUpdate?.()),this.update(n)):this._$EM()}catch(i){throw e=!1,this._$EM(),i}e&&this._$AE(n)}willUpdate(e){}_$AE(e){this._$EO?.forEach(n=>n.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Eq&&=this._$Eq.forEach(n=>this._$ET(n,this[n])),this._$EM()}updated(e){}firstUpdated(e){}};E.elementStyles=[],E.shadowRootOptions={mode:"open"},E[K("elementProperties")]=new Map,E[K("finalized")]=new Map,vr?.({ReactiveElement:E}),(fe.reactiveElementVersions??=[]).push("2.1.2");var Ke=globalThis,It=t=>t,he=Ke.trustedTypes,Ct=he?he.createPolicy("lit-html",{createHTML:t=>t}):void 0,Nt="$lit$",I=`lit$${Math.random().toFixed(9).slice(2)}$`,Bt="?"+I,_r=`<${Bt}>`,N=document,Z=()=>N.createComment(""),q=t=>t===null||typeof t!="object"&&typeof t!="function",Xe=Array.isArray,xr=t=>Xe(t)||typeof t?.[Symbol.iterator]=="function",ze=`[
2
2
  \f\r]`,X=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Rt=/-->/g,Tt=/>/g,M=RegExp(`>|${ze}(?:([^\\s"'>=/]+)(${ze}*=${ze}*(?:[^
3
- \f\r"'\`<>=]|("|')|))|$)`,"g"),Lt=/'/g,Mt=/"/g,Ut=/^(?:script|style|textarea|title)$/i,Ze=t=>(e,...n)=>({_$litType$:t,strings:e,values:n}),v=Ze(1),Lo=Ze(2),Mo=Ze(3),S=Symbol.for("lit-noChange"),y=Symbol.for("lit-nothing"),Ot=new WeakMap,O=N.createTreeWalker(N,129);function Dt(t,e){if(!Xe(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return Ct!==void 0?Ct.createHTML(e):e}var $r=(t,e)=>{let n=t.length-1,i=[],r,o=e===2?"<svg>":e===3?"<math>":"",s=X;for(let a=0;a<n;a++){let c=t[a],l,d,p=-1,u=0;for(;u<c.length&&(s.lastIndex=u,d=s.exec(c),d!==null);)u=s.lastIndex,s===X?d[1]==="!--"?s=Rt:d[1]!==void 0?s=Tt:d[2]!==void 0?(Ut.test(d[2])&&(r=RegExp("</"+d[2],"g")),s=M):d[3]!==void 0&&(s=M):s===M?d[0]===">"?(s=r??X,p=-1):d[1]===void 0?p=-2:(p=s.lastIndex-d[2].length,l=d[1],s=d[3]===void 0?M:d[3]==='"'?Mt:Lt):s===Mt||s===Lt?s=M:s===Rt||s===Tt?s=X:(s=M,r=void 0);let m=s===M&&t[a+1].startsWith("/>")?" ":"";o+=s===X?c+_r:p>=0?(i.push(l),c.slice(0,p)+Nt+c.slice(p)+I+m):c+I+(p===-2?a:m)}return[Dt(t,o+(t[n]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),i]},Y=class t{constructor({strings:e,_$litType$:n},i){let r;this.parts=[];let o=0,s=0,a=e.length-1,c=this.parts,[l,d]=$r(e,n);if(this.el=t.createElement(l,i),O.currentNode=this.el.content,n===2||n===3){let p=this.el.content.firstChild;p.replaceWith(...p.childNodes)}for(;(r=O.nextNode())!==null&&c.length<a;){if(r.nodeType===1){if(r.hasAttributes())for(let p of r.getAttributeNames())if(p.endsWith(Nt)){let u=d[s++],m=r.getAttribute(p).split(I),f=/([.?@])?(.*)/.exec(u);c.push({type:1,index:o,name:f[2],strings:m,ctor:f[1]==="."?je:f[1]==="?"?Ve:f[1]==="@"?Ge:j}),r.removeAttribute(p)}else p.startsWith(I)&&(c.push({type:6,index:o}),r.removeAttribute(p));if(Ut.test(r.tagName)){let p=r.textContent.split(I),u=p.length-1;if(u>0){r.textContent=me?me.emptyScript:"";for(let m=0;m<u;m++)r.append(p[m],Z()),O.nextNode(),c.push({type:2,index:++o});r.append(p[u],Z())}}}else if(r.nodeType===8)if(r.data===Bt)c.push({type:2,index:o});else{let p=-1;for(;(p=r.data.indexOf(I,p+1))!==-1;)c.push({type:7,index:o}),p+=I.length-1}o++}}static createElement(e,n){let i=N.createElement("template");return i.innerHTML=e,i}};function P(t,e,n=t,i){if(e===S)return e;let r=i!==void 0?n._$Co?.[i]:n._$Cl,o=q(e)?void 0:e._$litDirective$;return r?.constructor!==o&&(r?._$AO?.(!1),o===void 0?r=void 0:(r=new o(t),r._$AT(t,n,i)),i!==void 0?(n._$Co??=[])[i]=r:n._$Cl=r),r!==void 0&&(e=P(t,r._$AS(t,e.values),r,i)),e}var Pe=class{constructor(e,n){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=n}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){let{el:{content:n},parts:i}=this._$AD,r=(e?.creationScope??N).importNode(n,!0);O.currentNode=r;let o=O.nextNode(),s=0,a=0,c=i[0];for(;c!==void 0;){if(s===c.index){let l;c.type===2?l=new J(o,o.nextSibling,this,e):c.type===1?l=new c.ctor(o,c.name,c.strings,this,e):c.type===6&&(l=new We(o,this,e)),this._$AV.push(l),c=i[++a]}s!==c?.index&&(o=O.nextNode(),s++)}return O.currentNode=N,r}p(e){let n=0;for(let i of this._$AV)i!==void 0&&(i.strings!==void 0?(i._$AI(e,i,n),n+=i.strings.length-2):i._$AI(e[n])),n++}},J=class t{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(e,n,i,r){this.type=2,this._$AH=y,this._$AN=void 0,this._$AA=e,this._$AB=n,this._$AM=i,this.options=r,this._$Cv=r?.isConnected??!0}get parentNode(){let e=this._$AA.parentNode,n=this._$AM;return n!==void 0&&e?.nodeType===11&&(e=n.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,n=this){e=P(this,e,n),q(e)?e===y||e==null||e===""?(this._$AH!==y&&this._$AR(),this._$AH=y):e!==this._$AH&&e!==S&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):xr(e)?this.k(e):this._(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==y&&q(this._$AH)?this._$AA.nextSibling.data=e:this.T(N.createTextNode(e)),this._$AH=e}$(e){let{values:n,_$litType$:i}=e,r=typeof i=="number"?this._$AC(e):(i.el===void 0&&(i.el=Y.createElement(Dt(i.h,i.h[0]),this.options)),i);if(this._$AH?._$AD===r)this._$AH.p(n);else{let o=new Pe(r,this),s=o.u(this.options);o.p(n),this.T(s),this._$AH=o}}_$AC(e){let n=Ot.get(e.strings);return n===void 0&&Ot.set(e.strings,n=new Y(e)),n}k(e){Xe(this._$AH)||(this._$AH=[],this._$AR());let n=this._$AH,i,r=0;for(let o of e)r===n.length?n.push(i=new t(this.O(Z()),this.O(Z()),this,this.options)):i=n[r],i._$AI(o),r++;r<n.length&&(this._$AR(i&&i._$AB.nextSibling,r),n.length=r)}_$AR(e=this._$AA.nextSibling,n){for(this._$AP?.(!1,!0,n);e!==this._$AB;){let i=It(e).nextSibling;It(e).remove(),e=i}}setConnected(e){this._$AM===void 0&&(this._$Cv=e,this._$AP?.(e))}},j=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,n,i,r,o){this.type=1,this._$AH=y,this._$AN=void 0,this.element=e,this.name=n,this._$AM=r,this.options=o,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=y}_$AI(e,n=this,i,r){let o=this.strings,s=!1;if(o===void 0)e=P(this,e,n,0),s=!q(e)||e!==this._$AH&&e!==S,s&&(this._$AH=e);else{let a=e,c,l;for(e=o[0],c=0;c<o.length-1;c++)l=P(this,a[i+c],n,c),l===S&&(l=this._$AH[c]),s||=!q(l)||l!==this._$AH[c],l===y?e=y:e!==y&&(e+=(l??"")+o[c+1]),this._$AH[c]=l}s&&!r&&this.j(e)}j(e){e===y?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}},je=class extends j{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===y?void 0:e}},Ve=class extends j{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==y)}},Ge=class extends j{constructor(e,n,i,r,o){super(e,n,i,r,o),this.type=5}_$AI(e,n=this){if((e=P(this,e,n,0)??y)===S)return;let i=this._$AH,r=e===y&&i!==y||e.capture!==i.capture||e.once!==i.once||e.passive!==i.passive,o=e!==y&&(i===y||r);r&&this.element.removeEventListener(this.name,this,i),o&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){typeof this._$AH=="function"?this._$AH.call(this.options?.host??this.element,e):this._$AH.handleEvent(e)}},We=class{constructor(e,n,i){this.element=e,this.type=6,this._$AN=void 0,this._$AM=n,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(e){P(this,e)}};var Er=Ke.litHtmlPolyfillSupport;Er?.(Y,J),(Ke.litHtmlVersions??=[]).push("3.3.3");var Ft=(t,e,n)=>{let i=n?.renderBefore??e,r=i._$litPart$;if(r===void 0){let o=n?.renderBefore??null;i._$litPart$=r=new J(e.insertBefore(Z(),o),o,void 0,n??{})}return r._$AI(t),r};var qe=globalThis,V=class extends E{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){let e=super.createRenderRoot();return this.renderOptions.renderBefore??=e.firstChild,e}update(e){let n=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=Ft(n,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return S}};V._$litElement$=!0,V.finalized=!0,qe.litElementHydrateSupport?.({LitElement:V});var Sr=qe.litElementPolyfillSupport;Sr?.({LitElement:V});(qe.litElementVersions??=[]).push("4.2.2");var Ht={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},zt=t=>(...e)=>({_$litDirective$:t,values:e}),he=class{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,n,i){this._$Ct=e,this._$AM=n,this._$Ci=i}_$AS(e,n){return this.update(e,n)}update(e,n){return this.render(...n)}};var Q=class extends he{constructor(e){if(super(e),this.it=y,e.type!==Ht.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(e){if(e===y||e==null)return this._t=void 0,this.it=e;if(e===S)return e;if(typeof e!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(e===this.it)return this._t;this.it=e;let n=[e];return n.raw=n,this._t={_$litType$:this.constructor.resultType,strings:n,values:[]}}};Q.directiveName="unsafeHTML",Q.resultType=1;var Ar=zt(Q);var kr=[["manage","Overview"],["manage-bundles","Bundles"],["manage-scans","Scans"],["manage-reports","Reports"],["manage-repos","Repositories","admin"],["admin-users","Users","admin"],["manage-teams","Teams","admin"],["manage-import","Import","admin"],["manage-links","Links"],["manage-history","History"]];function Pt(t,e,n=!1){return v`<nav class="manage-nav" aria-label="Management pages">${kr.filter(([i,,r])=>(r==null||r===e)&&(i!=="manage-links"||n)).map(([i,r])=>v`<button type="button" aria-current="${t===i?"page":y}" @click="${()=>{document.dispatchEvent(new CustomEvent("managed-admin-navigate",{detail:{view:i},bubbles:!0,composed:!0}))}}">${r}</button>`)}</nav>`}var jt=`:host{display:block;position:relative;padding:0 clamp(1rem,3vw,3rem) 3rem;color:var(--text);container-type:inline-size;font-family:var(--sans, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif);font-size:.875rem;line-height:1.5;--panel:color-mix(in srgb, var(--bg) 50%, var(--surface));--panel-hover:color-mix(in srgb, var(--text) 3%, var(--panel))}*,*:before,*:after{box-sizing:border-box}button,summary,select,label,legend,h1,h2,h3,.section-heading,.ui-hint,.page-intro>.intro,.count,.result-count,.repository-count,.breadcrumb-separator,.list-head,.report-list-head,.history-head,.drop-copy,.local-import-copy,.location-field>span,.empty:not(.error,[role=alert]),.msg:not(.error,[role=alert]),.local-import-message:not(.error,[role=status]),.data-empty,.revision-empty{cursor:default;user-select:none;-webkit-user-select:none}input:not([type=checkbox],[type=radio]),textarea,[contenteditable],pre,code,.mono{cursor:text;user-select:text;-webkit-user-select:text}.wrap{width:100%;max-width:76rem;margin:0 auto}.manage-nav button{flex:0 0 auto;position:relative;min-height:3.7rem;padding:.9rem 0;border:0;border-radius:0;color:var(--muted);background:none;font-size:.8rem;font-weight:500;white-space:nowrap}.manage-nav button:hover,.manage-nav button[aria-current=page]{color:var(--text)}.manage-nav button[aria-current=page]:after{content:"";position:absolute;bottom:0;inset-inline:0;height:2px;background:var(--accent);border-radius:var(--ui-radius, 2px)}.manage-nav button:focus-visible{outline-offset:-3px}.head{display:flex;align-items:center;flex-wrap:wrap;gap:.7rem;margin:0 0 .5rem}h1,.head h1{margin:0;font-size:1.9rem;font-weight:600;letter-spacing:-.045em;line-height:1.2}.count{display:inline-flex;align-items:center;justify-content:center;min-width:1.6rem;padding:.12rem .5rem;border:1px solid var(--border);border-radius:6px;color:var(--muted);background:var(--surface);font-size:.73rem;font-weight:500;font-variant-numeric:tabular-nums}button,input,select{font:inherit}button,select,input[type=checkbox]{cursor:default}button,a,input,select{-webkit-app-region:no-drag}button,a{transition:background .15s,color .15s,border-color .15s}button:focus-visible,a:focus-visible,input:focus-visible,select:focus-visible{outline:2px solid var(--accent);outline-offset:3px}button:disabled,select:disabled{opacity:.45}input:not([type=checkbox]),select{min-width:0;min-height:2.25rem;padding:.45rem .65rem;border:1px solid var(--border);border-radius:var(--ui-radius, 7px);background:var(--bg);color:var(--text);font-size:.8rem}input::placeholder{color:var(--muted)}input[type=checkbox]{accent-color:var(--accent)}.btn,.drop-browse{display:inline-flex;align-items:center;justify-content:center;gap:.45rem;min-height:2.25rem;height:auto;padding:.45rem .8rem;border:1px solid var(--border);border-radius:var(--ui-radius, 7px);background:var(--surface);color:var(--text);font-size:.8rem;font-weight:500;text-decoration:none;white-space:nowrap}.btn:hover:not(:disabled),.drop-browse:hover:not(:disabled){background:var(--surface-active);border-color:var(--muted)}.btn.primary,.drop-browse{color:var(--bg);background:var(--accent);border-color:var(--accent)}.btn.primary:hover:not(:disabled),.drop-browse:hover:not(:disabled){background:var(--accent);filter:brightness(1.08)}.btn svg,.icon-btn svg{width:1rem;height:1rem}.icon-btn{width:2rem;height:2rem}.avatar{color:var(--accent);background:color-mix(in srgb,var(--accent) 12%,var(--bg));border:1px solid color-mix(in srgb,var(--accent) 16%,var(--border))}.breadcrumb{display:flex;align-items:center;flex-basis:100%;gap:.4rem;margin-bottom:.8rem}.breadcrumb-manage{padding:.1rem 0;border:0;background:transparent;color:var(--muted);font-size:.78rem}.breadcrumb-manage:hover{color:var(--text)}.breadcrumb-separator{color:var(--muted)}.msg{margin:1rem 0;padding:1.1rem 1.25rem;border:1px solid var(--border);border-radius:var(--ui-radius, 9px);color:var(--muted);font-size:.85rem}.msg.error{color:var(--critical);border-color:color-mix(in srgb,var(--critical) 35%,var(--border))}.empty{padding:3.5rem 1.5rem;border:1px dashed var(--border);border-radius:var(--ui-radius, 10px);color:var(--muted);text-align:center}.empty strong{display:block;margin-bottom:.4rem;color:var(--text);font-size:.95rem;font-weight:500}.empty p{margin:0;font-size:.85rem}.sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}@container (max-width: 35rem){.drop-copy>span{display:none}.manage-nav{gap:1.2rem;margin-bottom:1.75rem}.manage-nav button{min-height:3.25rem}h1,.head h1{font-size:1.65rem}.intro{margin-bottom:1.5rem}}@media(prefers-reduced-motion:reduce){button,a{transition:none}}.collection-toolbar input{flex:1;max-width:26rem;min-width:10rem}.collection-toolbar select{min-width:10rem}.result-count{text-align:right;white-space:nowrap;margin-left:auto;color:var(--muted);font-size:.75rem;font-variant-numeric:tabular-nums}@container (max-width: 35rem){.collection-toolbar input{flex-basis:100%;max-width:none}}.manage-nav{display:flex;gap:1.35rem;align-items:stretch;overflow-x:auto;scrollbar-width:thin;border-bottom:1px solid var(--border);margin-bottom:1.5rem;padding:0 .1rem}.intro{margin:0 0 1.25rem;max-width:46rem;color:var(--muted);font-size:.875rem;line-height:1.65}.collection-toolbar{display:flex;align-items:center;flex-wrap:wrap;gap:.75rem;margin-bottom:.85rem}.page-intro{display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:.5rem 1rem;margin-bottom:1.25rem}.page-intro .intro{margin:0}a{cursor:default}.loading-rows{border:1px solid var(--border);border-radius:var(--ui-radius, 10px);overflow:hidden}.loading-row{display:grid;align-content:center;gap:.6rem;min-height:4.25rem;padding:.85rem 1rem}.loading-row+.loading-row{border-top:1px solid var(--border)}.loading-row span{width:40%;height:.65rem;border-radius:3px;background:color-mix(in srgb,var(--muted) 15%,transparent)}.loading-row span+span{width:65%;height:.5rem}.drop-card{display:flex;align-items:center;gap:.75rem;margin-bottom:1rem;padding:.7rem .85rem;border:1px dashed color-mix(in srgb,var(--muted) 35%,var(--border));border-radius:var(--ui-radius, 8px);background:var(--panel)}.drop-icon{display:grid;place-items:center;flex-shrink:0;width:1.8rem;height:1.8rem;color:var(--muted)}.drop-icon svg{width:1.1rem;height:1.1rem}.drop-copy{min-width:0;display:flex;align-items:baseline;flex-wrap:wrap;gap:.2rem .6rem}.drop-copy strong{font-size:.8rem;font-weight:500}.drop-copy>span{color:var(--muted);font-size:.75rem}.drop-browse{min-width:7rem;margin-left:auto;flex-shrink:0}
3
+ \f\r"'\`<>=]|("|')|))|$)`,"g"),Lt=/'/g,Mt=/"/g,Ut=/^(?:script|style|textarea|title)$/i,Ze=t=>(e,...n)=>({_$litType$:t,strings:e,values:n}),v=Ze(1),Lo=Ze(2),Mo=Ze(3),S=Symbol.for("lit-noChange"),y=Symbol.for("lit-nothing"),Ot=new WeakMap,O=N.createTreeWalker(N,129);function Dt(t,e){if(!Xe(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return Ct!==void 0?Ct.createHTML(e):e}var $r=(t,e)=>{let n=t.length-1,i=[],r,o=e===2?"<svg>":e===3?"<math>":"",s=X;for(let a=0;a<n;a++){let c=t[a],l,d,p=-1,u=0;for(;u<c.length&&(s.lastIndex=u,d=s.exec(c),d!==null);)u=s.lastIndex,s===X?d[1]==="!--"?s=Rt:d[1]!==void 0?s=Tt:d[2]!==void 0?(Ut.test(d[2])&&(r=RegExp("</"+d[2],"g")),s=M):d[3]!==void 0&&(s=M):s===M?d[0]===">"?(s=r??X,p=-1):d[1]===void 0?p=-2:(p=s.lastIndex-d[2].length,l=d[1],s=d[3]===void 0?M:d[3]==='"'?Mt:Lt):s===Mt||s===Lt?s=M:s===Rt||s===Tt?s=X:(s=M,r=void 0);let h=s===M&&t[a+1].startsWith("/>")?" ":"";o+=s===X?c+_r:p>=0?(i.push(l),c.slice(0,p)+Nt+c.slice(p)+I+h):c+I+(p===-2?a:h)}return[Dt(t,o+(t[n]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),i]},Y=class t{constructor({strings:e,_$litType$:n},i){let r;this.parts=[];let o=0,s=0,a=e.length-1,c=this.parts,[l,d]=$r(e,n);if(this.el=t.createElement(l,i),O.currentNode=this.el.content,n===2||n===3){let p=this.el.content.firstChild;p.replaceWith(...p.childNodes)}for(;(r=O.nextNode())!==null&&c.length<a;){if(r.nodeType===1){if(r.hasAttributes())for(let p of r.getAttributeNames())if(p.endsWith(Nt)){let u=d[s++],h=r.getAttribute(p).split(I),f=/([.?@])?(.*)/.exec(u);c.push({type:1,index:o,name:f[2],strings:h,ctor:f[1]==="."?je:f[1]==="?"?Ve:f[1]==="@"?Ge:j}),r.removeAttribute(p)}else p.startsWith(I)&&(c.push({type:6,index:o}),r.removeAttribute(p));if(Ut.test(r.tagName)){let p=r.textContent.split(I),u=p.length-1;if(u>0){r.textContent=he?he.emptyScript:"";for(let h=0;h<u;h++)r.append(p[h],Z()),O.nextNode(),c.push({type:2,index:++o});r.append(p[u],Z())}}}else if(r.nodeType===8)if(r.data===Bt)c.push({type:2,index:o});else{let p=-1;for(;(p=r.data.indexOf(I,p+1))!==-1;)c.push({type:7,index:o}),p+=I.length-1}o++}}static createElement(e,n){let i=N.createElement("template");return i.innerHTML=e,i}};function P(t,e,n=t,i){if(e===S)return e;let r=i!==void 0?n._$Co?.[i]:n._$Cl,o=q(e)?void 0:e._$litDirective$;return r?.constructor!==o&&(r?._$AO?.(!1),o===void 0?r=void 0:(r=new o(t),r._$AT(t,n,i)),i!==void 0?(n._$Co??=[])[i]=r:n._$Cl=r),r!==void 0&&(e=P(t,r._$AS(t,e.values),r,i)),e}var Pe=class{constructor(e,n){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=n}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){let{el:{content:n},parts:i}=this._$AD,r=(e?.creationScope??N).importNode(n,!0);O.currentNode=r;let o=O.nextNode(),s=0,a=0,c=i[0];for(;c!==void 0;){if(s===c.index){let l;c.type===2?l=new J(o,o.nextSibling,this,e):c.type===1?l=new c.ctor(o,c.name,c.strings,this,e):c.type===6&&(l=new We(o,this,e)),this._$AV.push(l),c=i[++a]}s!==c?.index&&(o=O.nextNode(),s++)}return O.currentNode=N,r}p(e){let n=0;for(let i of this._$AV)i!==void 0&&(i.strings!==void 0?(i._$AI(e,i,n),n+=i.strings.length-2):i._$AI(e[n])),n++}},J=class t{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(e,n,i,r){this.type=2,this._$AH=y,this._$AN=void 0,this._$AA=e,this._$AB=n,this._$AM=i,this.options=r,this._$Cv=r?.isConnected??!0}get parentNode(){let e=this._$AA.parentNode,n=this._$AM;return n!==void 0&&e?.nodeType===11&&(e=n.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,n=this){e=P(this,e,n),q(e)?e===y||e==null||e===""?(this._$AH!==y&&this._$AR(),this._$AH=y):e!==this._$AH&&e!==S&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):xr(e)?this.k(e):this._(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==y&&q(this._$AH)?this._$AA.nextSibling.data=e:this.T(N.createTextNode(e)),this._$AH=e}$(e){let{values:n,_$litType$:i}=e,r=typeof i=="number"?this._$AC(e):(i.el===void 0&&(i.el=Y.createElement(Dt(i.h,i.h[0]),this.options)),i);if(this._$AH?._$AD===r)this._$AH.p(n);else{let o=new Pe(r,this),s=o.u(this.options);o.p(n),this.T(s),this._$AH=o}}_$AC(e){let n=Ot.get(e.strings);return n===void 0&&Ot.set(e.strings,n=new Y(e)),n}k(e){Xe(this._$AH)||(this._$AH=[],this._$AR());let n=this._$AH,i,r=0;for(let o of e)r===n.length?n.push(i=new t(this.O(Z()),this.O(Z()),this,this.options)):i=n[r],i._$AI(o),r++;r<n.length&&(this._$AR(i&&i._$AB.nextSibling,r),n.length=r)}_$AR(e=this._$AA.nextSibling,n){for(this._$AP?.(!1,!0,n);e!==this._$AB;){let i=It(e).nextSibling;It(e).remove(),e=i}}setConnected(e){this._$AM===void 0&&(this._$Cv=e,this._$AP?.(e))}},j=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,n,i,r,o){this.type=1,this._$AH=y,this._$AN=void 0,this.element=e,this.name=n,this._$AM=r,this.options=o,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=y}_$AI(e,n=this,i,r){let o=this.strings,s=!1;if(o===void 0)e=P(this,e,n,0),s=!q(e)||e!==this._$AH&&e!==S,s&&(this._$AH=e);else{let a=e,c,l;for(e=o[0],c=0;c<o.length-1;c++)l=P(this,a[i+c],n,c),l===S&&(l=this._$AH[c]),s||=!q(l)||l!==this._$AH[c],l===y?e=y:e!==y&&(e+=(l??"")+o[c+1]),this._$AH[c]=l}s&&!r&&this.j(e)}j(e){e===y?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}},je=class extends j{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===y?void 0:e}},Ve=class extends j{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==y)}},Ge=class extends j{constructor(e,n,i,r,o){super(e,n,i,r,o),this.type=5}_$AI(e,n=this){if((e=P(this,e,n,0)??y)===S)return;let i=this._$AH,r=e===y&&i!==y||e.capture!==i.capture||e.once!==i.once||e.passive!==i.passive,o=e!==y&&(i===y||r);r&&this.element.removeEventListener(this.name,this,i),o&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){typeof this._$AH=="function"?this._$AH.call(this.options?.host??this.element,e):this._$AH.handleEvent(e)}},We=class{constructor(e,n,i){this.element=e,this.type=6,this._$AN=void 0,this._$AM=n,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(e){P(this,e)}};var Er=Ke.litHtmlPolyfillSupport;Er?.(Y,J),(Ke.litHtmlVersions??=[]).push("3.3.3");var Ft=(t,e,n)=>{let i=n?.renderBefore??e,r=i._$litPart$;if(r===void 0){let o=n?.renderBefore??null;i._$litPart$=r=new J(e.insertBefore(Z(),o),o,void 0,n??{})}return r._$AI(t),r};var qe=globalThis,V=class extends E{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){let e=super.createRenderRoot();return this.renderOptions.renderBefore??=e.firstChild,e}update(e){let n=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=Ft(n,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return S}};V._$litElement$=!0,V.finalized=!0,qe.litElementHydrateSupport?.({LitElement:V});var Sr=qe.litElementPolyfillSupport;Sr?.({LitElement:V});(qe.litElementVersions??=[]).push("4.2.2");var Ht={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},zt=t=>(...e)=>({_$litDirective$:t,values:e}),me=class{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,n,i){this._$Ct=e,this._$AM=n,this._$Ci=i}_$AS(e,n){return this.update(e,n)}update(e,n){return this.render(...n)}};var Q=class extends me{constructor(e){if(super(e),this.it=y,e.type!==Ht.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(e){if(e===y||e==null)return this._t=void 0,this.it=e;if(e===S)return e;if(typeof e!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(e===this.it)return this._t;this.it=e;let n=[e];return n.raw=n,this._t={_$litType$:this.constructor.resultType,strings:n,values:[]}}};Q.directiveName="unsafeHTML",Q.resultType=1;var Ar=zt(Q);var kr=[["manage","Overview"],["manage-bundles","Bundles"],["manage-scans","Scans"],["manage-reports","Reports"],["manage-repos","Repositories","admin"],["admin-users","Users","admin"],["manage-teams","Teams","admin"],["manage-import","Import","admin"],["manage-links","Links"],["manage-history","History"]];function Pt(t,e,n=!1){return v`<header class="manage-header"><nav class="manage-nav" aria-label="Management pages">${kr.filter(([i,,r])=>(r==null||r===e)&&(i!=="manage-links"||n)).map(([i,r])=>v`<button type="button" aria-current="${t===i?"page":y}" @click="${()=>{document.dispatchEvent(new CustomEvent("managed-admin-navigate",{detail:{view:i},bubbles:!0,composed:!0}))}}">${r}</button>`)}</nav></header>`}var jt=`:host{display:flex;flex-direction:column;position:relative;padding:0 clamp(1rem,3vw,3rem) 3rem;color:var(--text);container-type:inline-size;font-family:var(--sans, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif);font-size:.875rem;line-height:1.5;--panel:color-mix(in srgb, var(--bg) 50%, var(--surface));--panel-hover:color-mix(in srgb, var(--text) 3%, var(--panel))}*,*:before,*:after{box-sizing:border-box}button,summary,select,label,legend,h1,h2,h3,.section-heading,.ui-hint,.page-intro>.intro,.count,.result-count,.repository-count,.breadcrumb-separator,.list-head,.report-list-head,.history-head,.drop-copy,.local-import-copy,.location-field>span,.empty:not(.error,[role=alert]),.msg:not(.error,[role=alert]),.local-import-message:not(.error,[role=status]),.data-empty,.revision-empty{cursor:default;user-select:none;-webkit-user-select:none}input:not([type=checkbox],[type=radio]),textarea,[contenteditable],pre,code,.mono{cursor:text;user-select:text;-webkit-user-select:text}.wrap{width:100%;max-width:76rem;margin:0 auto;flex:1;min-height:0;overflow-y:auto;overscroll-behavior:contain;scrollbar-gutter:stable}.manage-header{position:sticky;top:0;z-index:2}.wrap:has(>.manage-list){display:flex;flex-direction:column;overflow:hidden;scrollbar-gutter:auto}.wrap:has(>.manage-list)>:not(.manage-list){flex-shrink:0}.manage-list{position:relative;flex:1;min-height:0;overflow:auto;overscroll-behavior:contain;scrollbar-gutter:stable}.manage-nav button{flex:0 0 auto;position:relative;min-height:3.7rem;padding:.9rem 0;border:0;border-radius:0;color:var(--muted);background:none;font-size:.8rem;font-weight:500;white-space:nowrap}.manage-nav button:hover,.manage-nav button[aria-current=page]{color:var(--text)}.manage-nav button[aria-current=page]:after{content:"";position:absolute;bottom:.6rem;inset-inline:0;height:2px;background:var(--accent);border-radius:var(--ui-radius, 2px)}.manage-nav button:focus-visible{outline-offset:-3px}.head{display:flex;align-items:center;flex-wrap:wrap;gap:.7rem;margin:0 0 .5rem}h1,.head h1{margin:0;font-size:1.9rem;font-weight:600;letter-spacing:-.045em;line-height:1.2}.count{display:inline-flex;align-items:center;justify-content:center;min-width:1.6rem;padding:.12rem .5rem;border:1px solid var(--border);border-radius:6px;color:var(--muted);background:var(--surface);font-size:.73rem;font-weight:500;font-variant-numeric:tabular-nums}button,input,select{font:inherit}button,select,input[type=checkbox]{cursor:default}button,a,input,select{-webkit-app-region:no-drag}button,a{transition:background .15s,color .15s,border-color .15s}button:focus-visible,a:focus-visible,input:focus-visible,select:focus-visible{outline:2px solid var(--accent);outline-offset:3px}button:disabled,select:disabled{opacity:.45}input:not([type=checkbox]),select{min-width:0;min-height:2.25rem;padding:.45rem .65rem;border:1px solid var(--border);border-radius:var(--ui-radius, 7px);background:var(--bg);color:var(--text);font-size:.8rem}input::placeholder{color:var(--muted)}input[type=checkbox]{accent-color:var(--accent)}.btn,.drop-browse{display:inline-flex;align-items:center;justify-content:center;gap:.45rem;min-height:2.25rem;height:auto;padding:.45rem .8rem;border:1px solid var(--border);border-radius:var(--ui-radius, 7px);background:var(--surface);color:var(--text);font-size:.8rem;font-weight:500;text-decoration:none;white-space:nowrap}.btn:hover:not(:disabled),.drop-browse:hover:not(:disabled){background:var(--surface-active);border-color:var(--muted)}.btn.primary,.drop-browse{color:var(--bg);background:var(--accent);border-color:var(--accent)}.btn.primary:hover:not(:disabled),.drop-browse:hover:not(:disabled){background:var(--accent);filter:brightness(1.08)}.btn svg,.icon-btn svg{width:1rem;height:1rem}.icon-btn{width:2rem;height:2rem}.avatar{color:var(--accent);background:color-mix(in srgb,var(--accent) 12%,var(--bg));border:1px solid color-mix(in srgb,var(--accent) 16%,var(--border))}.breadcrumb{display:flex;align-items:center;flex-basis:100%;gap:.4rem;margin-bottom:.8rem}.breadcrumb-manage{padding:.1rem 0;border:0;background:transparent;color:var(--muted);font-size:.78rem}.breadcrumb-manage:hover{color:var(--text)}.breadcrumb-separator{color:var(--muted)}.msg{margin:1rem 0;padding:1.1rem 1.25rem;border:1px solid var(--border);border-radius:var(--ui-radius, 9px);color:var(--muted);font-size:.85rem}.msg.error{color:var(--critical);border-color:color-mix(in srgb,var(--critical) 35%,var(--border))}.empty{padding:3.5rem 1.5rem;border:1px dashed var(--border);border-radius:var(--ui-radius, 10px);color:var(--muted);text-align:center}.empty strong{display:block;margin-bottom:.4rem;color:var(--text);font-size:.95rem;font-weight:500}.empty p{margin:0;font-size:.85rem}.sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}@container (max-width: 35rem){.drop-copy>span{display:none}.manage-nav{gap:1.2rem;margin-bottom:1.75rem}.manage-nav button{min-height:3.25rem}h1,.head h1{font-size:1.65rem}.intro{margin-bottom:1.5rem}}@media(prefers-reduced-motion:reduce){button,a{transition:none}}.collection-toolbar input{flex:1;max-width:26rem;min-width:10rem}.collection-toolbar select{min-width:10rem}.result-count{text-align:right;white-space:nowrap;margin-left:auto;color:var(--muted);font-size:.75rem;font-variant-numeric:tabular-nums}@container (max-width: 35rem){.collection-toolbar input{flex-basis:100%;max-width:none}}.manage-nav{display:flex;gap:1.35rem;align-items:stretch;overflow-x:auto;scrollbar-width:thin;border-bottom:1px solid var(--border);margin-bottom:1.5rem;padding:0 .1rem}.wrap>:not(.manage-header),.manage-nav{-webkit-app-region:no-drag;app-region:no-drag}@media(display-mode:window-controls-overlay){.manage-header{display:flow-root}.manage-header:before{content:"";float:right;width:var(--wco-right-toolbar, 0px);height:var(--wco-titlebar-height)}.manage-nav{width:max-content;max-width:100%;border-bottom:0}.manage-nav button{min-height:var(--wco-titlebar-height);padding-block:.35rem}.manage-nav button[aria-current=page]:after{bottom:0}}.intro{margin:0 0 1.25rem;max-width:46rem;color:var(--muted);font-size:.875rem;line-height:1.65}.collection-toolbar{display:flex;align-items:center;flex-wrap:wrap;gap:.75rem;margin-bottom:.85rem}.page-intro{display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:.5rem 1rem;margin-bottom:1.25rem}.page-intro .intro{margin:0}a{cursor:default}.loading-rows{border:1px solid var(--border);border-radius:var(--ui-radius, 10px);overflow:hidden}.loading-row{display:grid;align-content:center;gap:.6rem;min-height:4.25rem;padding:.85rem 1rem}.loading-row+.loading-row{border-top:1px solid var(--border)}.loading-row span{width:40%;height:.65rem;border-radius:3px;background:color-mix(in srgb,var(--muted) 15%,transparent)}.loading-row span+span{width:65%;height:.5rem}.drop-card{display:flex;align-items:center;gap:.75rem;margin-bottom:1rem;padding:.7rem .85rem;border:1px dashed color-mix(in srgb,var(--muted) 35%,var(--border));border-radius:var(--ui-radius, 8px);background:var(--panel)}.drop-icon{display:grid;place-items:center;flex-shrink:0;width:1.8rem;height:1.8rem;color:var(--muted)}.drop-icon svg{width:1.1rem;height:1.1rem}.drop-copy{min-width:0;display:flex;align-items:baseline;flex-wrap:wrap;gap:.2rem .6rem}.drop-copy strong{font-size:.8rem;font-weight:500}.drop-copy>span{color:var(--muted);font-size:.75rem}.drop-browse{min-width:7rem;margin-left:auto;flex-shrink:0}
4
4
  `;var Vt=`h1{font-size:1.35rem;margin-bottom:.5rem}h2{font-size:1.1rem;margin-bottom:.5rem}.triage-import{display:flex;gap:1rem;align-items:center;margin:1.5rem 0 2rem}.triage-import .btn{flex-shrink:0}.triage-import p{margin:0}.workspace-drop{display:grid;gap:.8rem;padding:2rem;margin:1.5rem 0;border:1px dashed var(--border);border-radius:var(--ui-radius, 8px)}.workspace-drop.dragging{border-color:var(--accent);background:rgb(from var(--accent) r g b / .08)}.workspace-drop span,p,li span{color:var(--muted);line-height:1.5}.actions,.local-choice{display:flex;gap:.8rem;flex-wrap:wrap;align-items:center}.local-choice{margin-bottom:1.5rem}.import-preview{display:grid;gap:.8rem}input:not([type=radio]),select{padding:.55rem;border:1px solid var(--border);border-radius:var(--ui-radius, 5px);color:var(--text);background:var(--bg);font:inherit}.import-preview input:not([type=radio]),.import-preview select{width:100%;box-sizing:border-box}fieldset{display:grid;gap:.8rem;padding:1rem;border:1px solid var(--border);border-radius:var(--ui-radius, 5px)}fieldset label{display:flex;gap:.5rem;align-items:center}li{padding:.4rem 0;overflow-wrap:anywhere}li span{display:block;font-size:.8rem}ul{padding-left:1.2rem}.primary{justify-self:start;color:var(--accent)}.error{color:var(--critical)}button:disabled{opacity:.5}input:focus-visible,select:focus-visible,button:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
5
5
  `;var Rr=new TextEncoder,Tr=new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});function ge(t){if(typeof t!="string")throw new TypeError(`encodeUtf8 expects a string, got ${typeof t}`);if(!t.isWellFormed())throw new TypeError("encodeUtf8: input contains lone surrogates");return Rr.encode(t)}function Gt(t){if(!ArrayBuffer.isView(t)&&!(t instanceof ArrayBuffer))throw new TypeError(`decodeUtf8 expects a BufferSource, got ${t===null?"null":typeof t}`);return Tr.decode(t)}async function Lr(t,{maxBytes:e}={}){let n=new Blob([t]).stream().pipeThrough(new DecompressionStream("gzip"));if(e==null)return new Uint8Array(await new Response(n).arrayBuffer());let i=n.getReader(),r=[],o=0;for(;;){let{value:c,done:l}=await i.read();if(l)break;if(o+=c.length,o>e){try{await i.cancel()}catch{}throw new Error(`gunzipBytes: decompressed size exceeds ${e}-byte cap`)}r.push(c)}let s=new Uint8Array(o),a=0;for(let c of r)s.set(c,a),a+=c.length;return s}async function Ye(t){return Gt(await Lr(t))}var Wt=1,ye=16,Kt=12,Xt=1+ye+Kt+16,Je=1+ye+Kt;async function Or(t,e){let n=await crypto.subtle.importKey("raw",ge(t),"PBKDF2",!1,["deriveKey"]);return crypto.subtle.deriveKey({name:"PBKDF2",hash:"SHA-256",salt:e,iterations:3e6},n,{name:"AES-GCM",length:256},!1,["encrypt","decrypt"])}function Zt(t){return!(t instanceof Uint8Array)||t.length<Xt?!1:t[0]===Wt}async function Nr(t,e){if(typeof e!="string"||!e)throw new TypeError("tryDecryptWithPassword: password required");if(!(t instanceof Uint8Array)||t.length<Xt)return{ok:!1,reason:"malformed"};if(t[0]!==Wt)return{ok:!1,reason:"malformed"};let n=t.subarray(1,1+ye),i=t.subarray(1+ye,Je),r=t.subarray(Je),o=await Or(e,n),s;try{s=new Uint8Array(await crypto.subtle.decrypt({name:"AES-GCM",iv:i,additionalData:t.subarray(0,Je)},o,r))}catch{return{ok:!1,reason:"wrong-password"}}return{ok:!0,plaintext:s}}async function qt(t,e,n){if(!n||typeof n.malformedMsg!="string"||typeof n.wrongPasswordMsg!="string")throw new TypeError("decryptWithPasswordOrThrow: { malformedMsg, wrongPasswordMsg } strings required");let i=await Nr(t,e);if(i.ok)return i.plaintext;throw i.reason==="wrong-password"?new Error(n.wrongPasswordMsg):new Error(n.malformedMsg)}var be=Zt;function Yt(t,e){return qt(t,e,{malformedMsg:"malformed encrypted bundle",wrongPasswordMsg:"wrong password or corrupt bundle"})}var Br=1,Jt=1024,Qt=1024,we=200,nn=100*1024*1024,Ur=Math.ceil(nn*4/3)+16,en=512,tn=64;function Dr(t){if(!t||typeof t!="object")return"payload is not an object";if(t.version!==Br)return`unsupported export version: ${t.version}`;if(!t.workspace||typeof t.workspace!="object")return"workspace metadata missing";if(typeof t.workspace.id!="string")return"workspace.id must be a string";if(typeof t.workspace.name!="string")return"workspace.name must be a string";if(typeof t.workspace.privateKey!="string")return"workspace.privateKey must be a string";if(t.workspace.createdAt!==void 0&&!Number.isFinite(t.workspace.createdAt))return"workspace.createdAt must be a finite number or omitted";if(!Array.isArray(t.reports))return"reports field must be an array";if(t.reports.length>Qt)return`reports count (${t.reports.length}) exceeds cap (${Qt})`;if(t.bundles!==void 0){if(!Array.isArray(t.bundles))return"bundles field must be an array when present";if(t.bundles.length>Jt)return`bundles count (${t.bundles.length}) exceeds cap (${Jt})`;for(let e of t.bundles){if(typeof e!="string")return"bundles entries must be strings";if(e.length>we)return`bundle integrity exceeds per-entry length cap (${we})`}}if(t.bundleBlobs!==void 0){if(!Array.isArray(t.bundleBlobs))return"bundleBlobs field must be an array when present";if(t.bundleBlobs.length>tn)return`bundleBlobs count (${t.bundleBlobs.length}) exceeds cap (${tn})`;for(let e of t.bundleBlobs){if(!e||typeof e!="object"||Array.isArray(e))return"bundleBlobs entries must be objects";if(typeof e.integrity!="string"||e.integrity.length===0)return"bundleBlobs.integrity must be a non-empty string";if(e.integrity.length>we)return`bundleBlobs.integrity exceeds per-entry length cap (${we})`;if(typeof e.name!="string"||e.name.length===0)return"bundleBlobs.name must be a non-empty string";if(e.name.length>en)return`bundleBlobs.name exceeds per-entry length cap (${en})`;if(e.name.includes("\0"))return"bundleBlobs.name cannot contain NUL";if(typeof e.data!="string")return"bundleBlobs.data must be a base64 string";if(e.data.length>Ur)return`bundleBlobs.data exceeds per-blob size cap (${nn} bytes raw)`}}return null}async function Qe(t,e){if(be(t)){if(typeof e!="string"||!e)throw new TypeError("parseWorkspaceBundleBytes: password required for encrypted bundle");let i=await Yt(t,e);try{return ve(await Ye(i))}catch(r){throw new Error("wrong password or corrupt bundle",{cause:r})}}let n;try{n=await Ye(t)}catch(i){throw new Error(`gzip decompression failed: ${i.message}`,{cause:i})}return ve(n)}function ve(t){let e;try{e=JSON.parse(t)}catch(r){throw new Error(`payload is not JSON: ${r.message}`,{cause:r})}let n=Dr(e);if(n===null)return e;let i=n.includes("exceeds cap");throw new Error(i?n:`not a deepview workspace export: ${n}`)}var Fr=/^\d+$/u;function Hr(t){for(let e=0;e<t.length;e++){let n=t.codePointAt(e);if(n<32||n===127)return!0}return!1}var et=512;function zr(t){return typeof t=="string"&&t.length>0&&t.length<=et&&!Hr(t)}function ee(t){return zr(t)&&!Fr.test(t)}var As=Object.freeze({manage:"/manage","manage-bundles":"/manage/bundle","manage-scans":"/manage/scans","manage-reports":"/manage/report","manage-repos":"/manage/repositories","admin-users":"/manage/users","manage-teams":"/manage/team","manage-import":"/manage/import","manage-links":"/manage/links","manage-history":"/manage/history"});function Pr(t){if(!t||typeof t!="object"||Array.isArray(t))return null;let{id:e}=t;return typeof e=="string"&&e.length>0?e:null}function rn(t){let e;try{e=JSON.parse(t)}catch{return null}if(!Array.isArray(e)||e.length===0)return null;let n=[],i=0;for(let r of e){if(!Array.isArray(r))return null;let o=new Set;for(let s of r){let a=Pr(s);if(a===null)return null;ee(a)?o.add(a):i++}o.size>1&&n.push([...o])}return{groups:n,skipped:i}}var jr=new TextEncoder;function on(t){if(typeof t!="string")throw new TypeError(`encodeUtf8 expects a string, got ${typeof t}`);if(!t.isWellFormed())throw new TypeError("encodeUtf8: input contains lone surrogates");return jr.encode(t)}async function Vr(t){let e=on(JSON.stringify(t)),n=await crypto.subtle.digest("SHA-256",e),i=new Uint8Array(n,0,16);i[6]=i[6]&15|64,i[8]=i[8]&63|128;let r=Array.from(i,o=>o.toString(16).padStart(2,"0")).join("");return`${r.slice(0,8)}-${r.slice(8,12)}-${r.slice(12,16)}-${r.slice(16,20)}-${r.slice(20,32)}`}async function sn(t){if(typeof crypto?.subtle?.digest!="function")return null;let e=te(t);try{return await Vr(e)}catch{return null}}function te(t){if(t._idBasis)return t._idBasis;let{severity:e,description:n}=t;return t.fileHash?{severity:e,description:n,fileHash:t.fileHash}:t.location?{severity:e,description:n,location:t.location}:{severity:e,description:n,file:t.file,line:t.line}}var cn=/^( *)(`{3,}|~{3,})(.*)$/u,Gr=/^ {0,3}(?:#{1,6}(?:[ \t]|$)|>|([-*_])(?:[ \t]*\1){2,}[ \t]*$)/u,an=/^ {0,3}([-*_])(?:[ \t]*\1){2,}[ \t]*$/u,Wr=/^ {0,3}(?:=+|-+)[ \t]*$/u,B=/^( *)(?:[-*+]|\d{1,9}[.)]) +(?=\S)/u,Kr=/^ *(?:[-*+]|\d{1,9}[.)])[ \t]*$/u,ln=/^\s*$/u,Xr=[[/^<(script|pre|textarea|style)(?:\s|>|$)/iu,/<\/(?:script|pre|textarea|style)>/iu,t=>`</${t[1].toLowerCase()}>`],[/^<!--/u,/-->/u,"-->"],[/^<\?/u,/\?>/u,"?>"],[/^<![A-Za-z]/u,/>/u,"<!-- -->"],[/^<!\[CDATA\[/u,/\]\]>/u,"]]>"],[/^<\/?(?:address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|nav|noframes|ol|optgroup|option|p|param|section|search|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)(?:\s|\/?>|$)/iu,ln,null]],Zr=/^(?:<[A-Za-z][\dA-Za-z-]*(?:\s+[:A-Z_a-z][\w.:-]*(?:\s*=\s*(?:[^\s"'<=>`]+|'[^']*'|"[^"]*"))?)*\s*\/?>|<\/[A-Za-z][\dA-Za-z-]*\s*>)\s*$/u;function _e(t,e,n=e){let i=/^ */u.exec(t)[0].length;if(i>3)return null;if(e&&n&&Wr.test(t))return!0;let r=cn.exec(t);if(r&&!(r[2][0]==="`"&&r[3].includes("`")))return{fence:r[2]};let o=t.slice(i);for(let[c,l,d]of Xr){let p=c.exec(o);if(p)return{html:l,close:typeof d=="function"?d(p):d}}if(!e&&Zr.test(o))return{html:ln,close:null};let s=an.test(t)?null:B.exec(t);if(s&&!(e&&n&&/^ *(?:\d*[02-9]|\d+\d)[.)]/u.test(s[0]))){let c=/ +$/u.exec(s[0])[0].length;return{item:c>4?s[0].length-c+1:s[0].length}}let a=an.test(t)||e&&n?null:Kr.exec(t);return a?{item:a[0].trimEnd().length+1}:Gr.test(t)||null}function U(t){return tt(t).ranges}function qr(t,e){let n=t.replace(/^(?: {0,3}> ?)+/u,""),i=_e(n,e);for(;i?.item;)n=n.slice(i.item),i=_e(n,!1);return n.trim()!==""&&!i&&/^ */u.exec(n)[0].length<4}function tt(t){let e=[],n=-1,i="",r=null,o=0,s=[],a=!1,c=!1,l=!1,d=0;for(let u of t.split(`
6
- `)){let m=d;d+=u.length+1;let f=/^ */u.exec(u)[0].length;if(n!==-1||r){let $=o>0&&u.trim()!==""&&f<o,k=!$&&(r?r.ends.test(u):f<=o+3&&un(i,u));if(($||k)&&(n!==-1&&e.push([n,$?m-1:m+u.length]),n=-1,r=null),!$)continue}if(!u.trim()){l&&s.pop(),l=!1,a=!1;continue}let h=s.length;for(;h>0&&f<s[h-1];)h--;let g=h>0?s[h-1]:0,b=u.slice(g),_=_e(b,a,h===s.length&&!c);if(a&&!_)continue;for(s.length=h;_?.item;)g+=_.item,b=b.slice(_.item),s.push(g),_=_e(b,!1);l=b.trim()==="",_?.fence?[n,i,o]=[m,_.fence,g]:_?.html&&([r,o]=[_.html.test(b)?null:{ends:_.html,close:_.close},g]);let w=a&&c;c=/^ {0,3}>/u.test(b),a=c?qr(b,w):!_&&!l&&/^ */u.exec(b)[0].length<4}n!==-1&&e.push([n,t.length]);let p=n===-1?r?.close:i;return{ranges:e,closer:p?" ".repeat(o)+p:null}}function un(t,e){let n=cn.exec(e);return n!==null&&n[2][0]===t[0]&&n[2].length>=t.length&&!n[3].trim()}function D(t,e){let n=0,i=t.length;for(;n<i;){let r=n+i>>>1;t[r][1]<=e?n=r+1:i=r}return n<t.length&&e>=t[n][0]}function A(t){return String(t??"").replaceAll(/\r\n?/gu,`
6
+ `)){let h=d;d+=u.length+1;let f=/^ */u.exec(u)[0].length;if(n!==-1||r){let $=o>0&&u.trim()!==""&&f<o,k=!$&&(r?r.ends.test(u):f<=o+3&&un(i,u));if(($||k)&&(n!==-1&&e.push([n,$?h-1:h+u.length]),n=-1,r=null),!$)continue}if(!u.trim()){l&&s.pop(),l=!1,a=!1;continue}let m=s.length;for(;m>0&&f<s[m-1];)m--;let g=m>0?s[m-1]:0,b=u.slice(g),_=_e(b,a,m===s.length&&!c);if(a&&!_)continue;for(s.length=m;_?.item;)g+=_.item,b=b.slice(_.item),s.push(g),_=_e(b,!1);l=b.trim()==="",_?.fence?[n,i,o]=[h,_.fence,g]:_?.html&&([r,o]=[_.html.test(b)?null:{ends:_.html,close:_.close},g]);let w=a&&c;c=/^ {0,3}>/u.test(b),a=c?qr(b,w):!_&&!l&&/^ */u.exec(b)[0].length<4}n!==-1&&e.push([n,t.length]);let p=n===-1?r?.close:i;return{ranges:e,closer:p?" ".repeat(o)+p:null}}function un(t,e){let n=cn.exec(e);return n!==null&&n[2][0]===t[0]&&n[2].length>=t.length&&!n[3].trim()}function D(t,e){let n=0,i=t.length;for(;n<i;){let r=n+i>>>1;t[r][1]<=e?n=r+1:i=r}return n<t.length&&e>=t[n][0]}function A(t){return String(t??"").replaceAll(/\r\n?/gu,`
7
7
  `)}var xe=/^## +(.*)$/gmu,ne=/^### +(.*)$/gmu,C=/^#### +(.*)$/gmu,dn=/^##### +(.*)$/gmu,nt=/^(.+):(\d+(?:-\d+)?)$/u;function $e(t){return/^[0-9a-f]{7,64}$/iu.test(t)}function pn(t,e){let n=U(t);return[...t.matchAll(e)].filter(i=>!D(n,i.index))}function Ee(t,e){let n=pn(t,e);return[t.slice(0,n[0]?.index),...n.map((i,r)=>t.slice(i.index+i[0].length,n[r+1]?.index))]}function R(t,e){let n=pn(t,e);return{head:t.slice(0,n[0]?.index),subs:n.map((i,r)=>({heading:i[1],body:t.slice(i.index+i[0].length+1,n[r+1]?.index)}))}}function T(t,e){return R(t,e).subs}function re(t){let e=t.indexOf(`
8
8
  `);return e===-1?{title:t.trim(),body:""}:{title:t.slice(0,e).trim(),body:t.slice(e+1)}}function ie(t){let e=t.split(`
9
- `).map(i=>i.trim()).filter(i=>i.startsWith("|")&&!(/^[\s:|-]+$/u.test(i)&&i.includes("-"))).map(i=>i.replace(/^\|/u,"").replace(/\|$/u,"").split("|").map(r=>r.trim()));if(e.length<2)return[];let n=e[0].map(i=>i.toLowerCase());return e.slice(1).filter(i=>i.length!==n.length||i.some((r,o)=>r.toLowerCase()!==n[o])).map(i=>Object.fromEntries(n.flatMap((r,o)=>r?[[r,i[o]??""]]:[])))}function fn(t){let e=Object.create(null),n=Object.create(null),i=[],r=null,o="",s=[],a="",c=(p,u,m)=>{!p||p in e||(e[p]=m.trim(),n[p]=u)},l=()=>{r&&c(r,o,s.join(`
9
+ `).map(i=>i.trim()).filter(i=>i.startsWith("|")&&!(/^[\s:|-]+$/u.test(i)&&i.includes("-"))).map(i=>i.replace(/^\|/u,"").replace(/\|$/u,"").split("|").map(r=>r.trim()));if(e.length<2)return[];let n=e[0].map(i=>i.toLowerCase());return e.slice(1).filter(i=>i.length!==n.length||i.some((r,o)=>r.toLowerCase()!==n[o])).map(i=>Object.fromEntries(n.flatMap((r,o)=>r?[[r,i[o]??""]]:[])))}function fn(t){let e=Object.create(null),n=Object.create(null),i=[],r=null,o="",s=[],a="",c=(p,u,h)=>{!p||p in e||(e[p]=h.trim(),n[p]=u)},l=()=>{r&&c(r,o,s.join(`
10
10
  `)),r=null,o="",s=[]},d=p=>{(r?s:i).push(p)};for(let p of t.split(`
11
- `)){let u=/^ {0,3}(```|~~~)/u.exec(p),m=u!==null&&(!a||u[1]===a);if(m&&(a=a?"":u[1]),m||a){d(p);continue}if(!p.trim()){r?l():i.push(p);continue}let f=/^\s*(?:[-*] +)?\*\*([^:*]+):\*\*\s*(.*)$/u.exec(p);if(f){l();let h=f[1].trim(),g=f[2],b;for(;(b=/\s+[·•]\s+\*\*([^:*]+):\*\*\s*/u.exec(g))!==null;)c(h.toLowerCase(),h,g.slice(0,b.index)),h=b[1].trim(),g=g.slice(b.index+b[0].length);r=h.toLowerCase(),o=h,s=[g];continue}if(/^\s*(?:#{1,6} |\||[-=*_]{3,}\s*$)/u.test(p)){l();continue}d(p)}return l(),{fields:e,labels:n,prose:i.join(`
12
- `).trim()}}function mn(t){let e=(t||"").trim(),n="",i=G(e);i&&(e=i.label.trim(),n=i.url.trim());let r=/#L(\d+)/u.exec(n)?.[1]??"",a=[...e.matchAll(/`([^`]+)`/gu)].map(d=>d[1].trim()).find(d=>!d.includes("(")&&(d.includes("/")||/\.\w/u.test(d)))??(e.replaceAll("`","").trim().split(/[\s,]+/u).find(Boolean)||""),c=/^(.*?)#L(\d+)(?:-L?\d+)?$/u.exec(a);c&&(a=c[1],r||(r=c[2]));let l=nt.exec(a);return l?(r||(r=l[2]),{file:l[1],line:r,locationLink:n}):{file:a,line:r||"?",locationLink:n}}function rt(t){return t.replaceAll("**","")}function G(t){let e=String(t??""),n=Yr(e,Jr(e)),i=Qr(e),r=e.indexOf("]");for(let o=e.indexOf("[");o!==-1;o=e.indexOf("[",o+1)){for(;r!==-1&&r<=o;)r=e.indexOf("]",r+1);for(let s of[r,n.get(o)??-1]){if(s===-1||s===o+1||e[s+1]!=="(")continue;let a=ei(e,s+1,i);if(a!==null)return{label:e.slice(o+1,s),url:a,index:o}}}return null}function Yr(t,e){let n=new Map,i=[];for(let r=0;r<t.length;r++){let o=t[r];hn(t,r)?r++:o==="`"?r=e.get(r)??r:o==="["?i.push(r):o==="]"&&i.length>0&&n.set(i.pop(),r)}return n}function Jr(t){let e=[];for(let r=t.indexOf("`");r!==-1;r=t.indexOf("`",r)){let o=1;for(;t[r+o]==="`";)o++;e.push([r,o]),r+=o}let n=new Map,i=new Map;for(let r=e.length-1;r>=0;r--){let[o,s]=e[r],a=i.get(s);a!==void 0&&n.set(o,a+s-1),i.set(s,o)}return n}function Qr(t){let e=t.length,n=new Int32Array(e+1).fill(-1),i=new Int32Array(e+1).fill(-1),r=new Int32Array(e+1).fill(-1),o=new Int32Array(e+1).fill(-1);for(let c=e-1;c>=0;c--)n[c]=t[c]===")"?c:n[c+1],i[c]=/\s/u.test(t[c])?c:i[c+1],r[c]=t[c]===">"?c:r[c+1],o[c]=t[c]===`
13
- `?c:o[c+1];let s=new Map,a=[];for(let c=0;c<e;c++){let l=t[c];hn(t,c)?c++:i[c]===c?a.length=0:l==="("?a.push(c):l===")"&&a.length>0&&s.set(a.pop(),c)}return{balanced:s,nextClose:n,nextSpace:i,nextAngle:r,nextLine:o}}function ei(t,e,n){let i=ti(t,e,n);if(i)return i;let r=n.balanced.get(e);if(r!==void 0)return r>e+1?t.slice(e+1,r):null;let o=n.nextClose[e+1],s=n.nextSpace[e+1];return o===-1||o===e+1||s!==-1&&s<o?null:t.slice(e+1,o)}function ti(t,e,n){if(t[e+1]!=="<")return"";let i=n.nextAngle[e+2],r=n.nextLine[e+2];return i===-1||r!==-1&&r<i||t[i+1]!==")"?"":t.slice(e+2,i)}var ni=/\\([!-/:-@[-`{-~])/gu,ri=/[!-/:-@[-`{-~]/u;function hn(t,e){return t[e]==="\\"&&ri.test(t[e+1]??"")}function gn(t){return typeof t=="string"?t.replace(ni,"$1"):t}function yn(t){let e=/^\[(.+)\]$/u.exec(t.trim());return e?e[1].trim():t.trim()}function F(t){let e=(t||"").trim();return/^[-–—]+$/u.test(e)?"":e}var Se=new Map([["CRITICAL","critical"],["HIGH","high"],["MEDIUM","medium"],["LOW","low"],["INFO","informational"],["INFORMATIONAL","informational"],["INFORMATIVE","informative"]]);function bn(t){return typeof t=="string"&&t.trim().toLowerCase()==="informative"?"informational":t}function x(t,e=t.severity){let n=bn(t.severity);return n!==t.severity&&(!t.id&&!t._idBasis&&(t._idBasis=te({...t,severity:e})),t.severity=n),t.correctedSeverity!==void 0&&(t.correctedSeverity=bn(t.correctedSeverity)),t}var ii=/^## ([A-Z][A-Z_]*)\s*\(\d+\)\s*\n/mu,oi=new Map([...Se,["HIGH_BUG","high_bug"],["BUG","bug"]]),_n=t=>String(t??"").toLowerCase().replaceAll(/[^a-z]+/gu,""),wn=new Map([["high",8],["medium",6],["low",4]]);function si(t){if(t!==void 0)return wn.get(_n(t))??wn.get("medium")}var ai=new Map([["confirmed","confirmed"],["falsepositive","refuted"],["uncertain","unknown"]]);function xn(t){let n=A(t).trim().split(ii);if(n.length===1)return null;let i=[];for(let r=1;r<n.length;r+=2){let o=oi.get(n[r].toUpperCase())??"medium";for(let s of Ee(n[r+1],/^### /gmu).slice(1)){let a=vn(s,o);if(!a)continue;let c=s.indexOf(`
11
+ `)){let u=/^ {0,3}(```|~~~)/u.exec(p),h=u!==null&&(!a||u[1]===a);if(h&&(a=a?"":u[1]),h||a){d(p);continue}if(!p.trim()){r?l():i.push(p);continue}let f=/^\s*(?:[-*] +)?\*\*([^:*]+):\*\*\s*(.*)$/u.exec(p);if(f){l();let m=f[1].trim(),g=f[2],b;for(;(b=/\s+[·•]\s+\*\*([^:*]+):\*\*\s*/u.exec(g))!==null;)c(m.toLowerCase(),m,g.slice(0,b.index)),m=b[1].trim(),g=g.slice(b.index+b[0].length);r=m.toLowerCase(),o=m,s=[g];continue}if(/^\s*(?:#{1,6} |\||[-=*_]{3,}\s*$)/u.test(p)){l();continue}d(p)}return l(),{fields:e,labels:n,prose:i.join(`
12
+ `).trim()}}function hn(t){let e=(t||"").trim(),n="",i=G(e);i&&(e=i.label.trim(),n=i.url.trim());let r=/#L(\d+)/u.exec(n)?.[1]??"",a=[...e.matchAll(/`([^`]+)`/gu)].map(d=>d[1].trim()).find(d=>!d.includes("(")&&(d.includes("/")||/\.\w/u.test(d)))??(e.replaceAll("`","").trim().split(/[\s,]+/u).find(Boolean)||""),c=/^(.*?)#L(\d+)(?:-L?\d+)?$/u.exec(a);c&&(a=c[1],r||(r=c[2]));let l=nt.exec(a);return l?(r||(r=l[2]),{file:l[1],line:r,locationLink:n}):{file:a,line:r||"?",locationLink:n}}function rt(t){return t.replaceAll("**","")}function G(t){let e=String(t??""),n=Yr(e,Jr(e)),i=Qr(e),r=e.indexOf("]");for(let o=e.indexOf("[");o!==-1;o=e.indexOf("[",o+1)){for(;r!==-1&&r<=o;)r=e.indexOf("]",r+1);for(let s of[r,n.get(o)??-1]){if(s===-1||s===o+1||e[s+1]!=="(")continue;let a=ei(e,s+1,i);if(a!==null)return{label:e.slice(o+1,s),url:a,index:o}}}return null}function Yr(t,e){let n=new Map,i=[];for(let r=0;r<t.length;r++){let o=t[r];mn(t,r)?r++:o==="`"?r=e.get(r)??r:o==="["?i.push(r):o==="]"&&i.length>0&&n.set(i.pop(),r)}return n}function Jr(t){let e=[];for(let r=t.indexOf("`");r!==-1;r=t.indexOf("`",r)){let o=1;for(;t[r+o]==="`";)o++;e.push([r,o]),r+=o}let n=new Map,i=new Map;for(let r=e.length-1;r>=0;r--){let[o,s]=e[r],a=i.get(s);a!==void 0&&n.set(o,a+s-1),i.set(s,o)}return n}function Qr(t){let e=t.length,n=new Int32Array(e+1).fill(-1),i=new Int32Array(e+1).fill(-1),r=new Int32Array(e+1).fill(-1),o=new Int32Array(e+1).fill(-1);for(let c=e-1;c>=0;c--)n[c]=t[c]===")"?c:n[c+1],i[c]=/\s/u.test(t[c])?c:i[c+1],r[c]=t[c]===">"?c:r[c+1],o[c]=t[c]===`
13
+ `?c:o[c+1];let s=new Map,a=[];for(let c=0;c<e;c++){let l=t[c];mn(t,c)?c++:i[c]===c?a.length=0:l==="("?a.push(c):l===")"&&a.length>0&&s.set(a.pop(),c)}return{balanced:s,nextClose:n,nextSpace:i,nextAngle:r,nextLine:o}}function ei(t,e,n){let i=ti(t,e,n);if(i)return i;let r=n.balanced.get(e);if(r!==void 0)return r>e+1?t.slice(e+1,r):null;let o=n.nextClose[e+1],s=n.nextSpace[e+1];return o===-1||o===e+1||s!==-1&&s<o?null:t.slice(e+1,o)}function ti(t,e,n){if(t[e+1]!=="<")return"";let i=n.nextAngle[e+2],r=n.nextLine[e+2];return i===-1||r!==-1&&r<i||t[i+1]!==")"?"":t.slice(e+2,i)}var ni=/\\([!-/:-@[-`{-~])/gu,ri=/[!-/:-@[-`{-~]/u;function mn(t,e){return t[e]==="\\"&&ri.test(t[e+1]??"")}function gn(t){return typeof t=="string"?t.replace(ni,"$1"):t}function yn(t){let e=/^\[(.+)\]$/u.exec(t.trim());return e?e[1].trim():t.trim()}function F(t){let e=(t||"").trim();return/^[-–—]+$/u.test(e)?"":e}var Se=new Map([["CRITICAL","critical"],["HIGH","high"],["MEDIUM","medium"],["LOW","low"],["INFO","informational"],["INFORMATIONAL","informational"],["INFORMATIVE","informative"]]);function bn(t){return typeof t=="string"&&t.trim().toLowerCase()==="informative"?"informational":t}function x(t,e=t.severity){let n=bn(t.severity);return n!==t.severity&&(!t.id&&!t._idBasis&&(t._idBasis=te({...t,severity:e})),t.severity=n),t.correctedSeverity!==void 0&&(t.correctedSeverity=bn(t.correctedSeverity)),t}var ii=/^## ([A-Z][A-Z_]*)\s*\(\d+\)\s*\n/mu,oi=new Map([...Se,["HIGH_BUG","high_bug"],["BUG","bug"]]),_n=t=>String(t??"").toLowerCase().replaceAll(/[^a-z]+/gu,""),wn=new Map([["high",8],["medium",6],["low",4]]);function si(t){if(t!==void 0)return wn.get(_n(t))??wn.get("medium")}var ai=new Map([["confirmed","confirmed"],["falsepositive","refuted"],["uncertain","unknown"]]);function xn(t){let n=A(t).trim().split(ii);if(n.length===1)return null;let i=[];for(let r=1;r<n.length;r+=2){let o=oi.get(n[r].toUpperCase())??"medium";for(let s of Ee(n[r+1],/^### /gmu).slice(1)){let a=vn(s,o);if(!a)continue;let c=s.indexOf(`
14
14
  ### `);c!==-1&&(a._idBasis=te(vn(s.slice(0,c+1),o))),i.push(a)}}return i.length===0?null:{type:"security",source:"deepsec",findings:i}}function vn(t,e){let{title:n,body:i}=re(t);if(!n)return null;let r=i.replace(/\n---\s*$/u,"").trim(),o=Object.fromEntries([...r.matchAll(/^- \*\*([^:*]+):\*\*\s*(.+)$/gmu)].map(g=>[g[1].trim().toLowerCase(),g[2].trim()])),s=/^\*\*Recommendation:\*\*\s*/mu.exec(r),a=s?r.slice(0,s.index):r,c=s?r.slice(s.index+s[0].length).trim():"",l=a.split(`
15
15
  `).filter(g=>!/^\s*- \*\*/u.test(g)).join(`
16
16
  `).replaceAll("**","").trim(),d=[n,l].filter(Boolean).join(`
17
17
 
18
- `),p=(o.file||"unknown").replace(/^`(.*)`$/u,"$1"),u=(o.lines||"").split(",").map(g=>g.trim()).find(Boolean)||"?",m={file:p,line:u,severity:e,description:d};c&&(m.recommendation=c.replaceAll("**",""));let f=si(o.confidence);f!==void 0&&(m.confidence=f);let h=ai.get(_n(o.revalidation));return h&&(m.revalidate=h,m.revalidateSource="deepsec",o.reasoning&&(m.revalidateVerdict=o.reasoning.replaceAll("**",""))),o.slug&&(m.slug=o.slug),x(m,e==="informative"?"medium":e)}var $n={critical:"Critical",high:"High",medium:"Medium",low:"Low",high_bug:"High bug",bug:"Bug",informational:"Informational"};var En={"claude-security":"Claude Security","codex-security":"Codex Security",deepsec:"DeepSec",piolium:"Piolium"};var Sn=["critical","high","medium","low","high_bug","bug","informational"];var it=["revalidation","refuted","unreachable","confirmed","partial","unknown"],Ys=new Set(it);function An(t){return t?t.split(`
18
+ `),p=(o.file||"unknown").replace(/^`(.*)`$/u,"$1"),u=(o.lines||"").split(",").map(g=>g.trim()).find(Boolean)||"?",h={file:p,line:u,severity:e,description:d};c&&(h.recommendation=c.replaceAll("**",""));let f=si(o.confidence);f!==void 0&&(h.confidence=f);let m=ai.get(_n(o.revalidation));return m&&(h.revalidate=m,h.revalidateSource="deepsec",o.reasoning&&(h.revalidateVerdict=o.reasoning.replaceAll("**",""))),o.slug&&(h.slug=o.slug),x(h,e==="informative"?"medium":e)}var $n={critical:"Critical",high:"High",medium:"Medium",low:"Low",high_bug:"High bug",bug:"Bug",informational:"Informational"};var En={"claude-security":"Claude Security","codex-security":"Codex Security",deepsec:"DeepSec",piolium:"Piolium"};var Sn=["critical","high","medium","low","high_bug","bug","informational"];var it=["revalidation","refuted","unreachable","confirmed","partial","unknown"],Ys=new Set(it);function An(t){return t?t.split(`
19
19
  `).find(e=>e.trim())?.trim()??"":""}function kn(t){return Number.isFinite(parseInt(t?.line,10))?`${t.file}:${t.line}`:t?.file??""}function ot(t){if(typeof t!="string"||t.length===0)return!1;try{let e=new URL(t);return e.protocol==="http:"||e.protocol==="https:"}catch{return!1}}function ci(t,e){let n=U(t),i=0;return t.split(`
20
20
  `).map(r=>{let o=i;return i+=r.length+1,D(n,o)?r:e(r)}).join(`
21
- `)}function H(t){return ci(String(t??""),e=>e.replace(/^( {0,3})\\(\\*#)/u,"$1$2"))}var li=/^(?:https?:\/\/)?(?:www\.)?github\.com\/([^/?#]+)\/([^/?#]+?)(?:\.git)?(?:[/?#].*)?$/iu,ui=/^[\w.-]+\/[\w.-]+$/u;function st(t){return ui.test(t)}function oe(t){let e=t?.repo?.github;if(typeof e!="string")return null;let n=e.trim().replace(/\/+$/u,"");if(!n)return null;let i=li.exec(n),r=(i?`${i[1]}/${i[2]}`:n).replace(/\.git$/u,"");return st(r)?r:null}var In=[["Impact","impact",!1],["Reproduction","reproduction",!1],["Recommendation","recommendation",!1],["Confidence reasoning","confidenceReason",!1],["Revalidation verdict","revalidateVerdict",!0],["Revalidation recommendation","revalidateRecommendation",!0]],Cn=[["Status","status"],["Branch","branch"],["Date created","dateCreated"],["Detected at","detectedAt"],["Committed at","committedAt"],["PoC status","pocStatus"],["Variant of","parent"],["Slug","slug"],["Priority","priority"]],Rn=[["Detailed report","reportPath"],["Commit audited","auditedCommit"],["ID","id"]];var di=new Map(Object.entries($n).map(([t,e])=>[e.toLowerCase(),t])),Ln=new Map(Object.entries(En).map(([t,e])=>[e.toLowerCase(),t]));function z(t){let e=/(`+)(.+?)\1(?!`)/u.exec(String(t??""));if(!e)return null;let n=e[2];if(n.length>2&&n.startsWith(" ")&&n.endsWith(" ")){let i=n.slice(1,-1);if(i.startsWith("`")||i.endsWith("`"))return i}return n}function ke(t){let e=G(String(t??""));return e?.index===0?{label:e.label,url:e.url}:null}function Mn(t){let e=/^<(https?:[^>\s]*)>$/u.exec(t.trim());return e?e[1]:null}function On(t){let e=nt.exec(t);return e?{file:e[1],line:e[2]}:{file:t,line:"?"}}function pi(t){let e=t.indexOf(".");return e>0?{exportName:t.slice(0,e),methodName:t.slice(e+1)}:{exportName:t}}function Ae(t){let e=String(t??"").trim();return di.get(e.toLowerCase())??e}function fi(t){let e={},n=t.trim(),i=/ · (`+)(.+?)\1$/u.exec(n);i&&(Object.assign(e,pi(z(i[0]))),n=n.slice(0,i.index));let r=ke(n),o=z(r?r.label:n);return o!==null&&Object.assign(e,On(o)),r&&ot(r.url)&&(e.location=r.url),e}var Tn=" \xB7 flagged critical by the analyzer",mi=" (varies across reports \u2014 ";function hi(t){let e={},n=t.trim();n.endsWith(Tn)&&(e.critical=!0,n=n.slice(0,-Tn.length));let i=n.indexOf(mi);i!==-1&&(n=n.slice(0,i));let r=/^(.*?) — corrected (from|to) (.*)$/u.exec(n);return r?[e.severity,e.correctedSeverity]=(r[2]==="from"?[r[3],r[1]]:[r[1],r[3]]).map(Ae):e.severity=Ae(n),e}var gi=new Set(["max","xhigh","high","medium","low","minimal"]),yi=new Set(["list","isolate"]);function bi(t){return/\d/u.test(t)||/^(?:opus|sonnet|haiku|gpt|gemini|fable|mythos|llama|mistral)\b/iu.test(t)}function Ie(t){let e=t.trim(),n=Ln.get(e.toLowerCase());if(n)return{source:n};let i={},r=[];for(let o of e.split(" \xB7 ").map(s=>s.trim()).filter(Boolean))o==="revalidate"&&!i.revalidate?i.revalidate="revalidation":yi.has(o)&&!i.exportsMode?i.exportsMode=o:gi.has(o)&&!i.effort?i.effort=o:r.push(o);return r.length>1?[i.type,i.model]=r:r.length===1&&(i[bi(r[0])?"model":"type"]=r[0]),{run:i}}function at(t){let e=t.trim(),n=ke(e);return n?n.label.trim():Mn(e)??e}function wi(t){let e=ke(t.trim());if(e){let n=e.url.split("/").at(-1)??"";return $e(n)?n:z(e.label)??n}return z(t)??t.trim()}function vi(t){let e=z(t)??t.trim(),n=e.lastIndexOf("@");return{npm:n>0?{name:e.slice(0,n),version:e.slice(n+1)}:{name:e}}}function _i(t){let e=t.trim().toLowerCase();return e==="the revalidation pass itself"?"revalidation":it.includes(e)?e:void 0}var xi=new Map([...[["Category","category"],...Cn].map(([t,e])=>[t.toLowerCase(),(n,i)=>{n[e]=i}]),...[...Rn,["Found while analyzing","discoveredIn"]].map(([t,e])=>[t.toLowerCase(),(n,i)=>{n[e]=z(i)??i}]),["location",(t,e)=>Object.assign(t,fi(e))],["severity",(t,e)=>Object.assign(t,hi(e))],["confidence",(t,e)=>{let n=/^(\d+(?:\.\d+)?)\/10$/u.exec(e);n&&(t.confidence=Number(n[1]))}],["revalidation",(t,e)=>{let n=_i(e);n&&(t.revalidate=n)}],["revalidated by",(t,e)=>{let n=e.trim();n&&(t.revalidateSource=Ln.get(n.toLowerCase())??n)}],["repository",(t,e)=>{t.repo={github:at(e)}}],["introduced in",(t,e)=>{t.commitHash=wi(e)}],["package",(t,e)=>{t.package=vi(e)}],["priority",(t,e)=>{t.priority=/^-?\d+(?:\.\d+)?$/u.test(e)?Number(e):e}]]);function Nn(t,e,n){let i=xi.get(e.trim().toLowerCase());i&&i(t,n.trim())}var $i=/^- \*\*([^*\n]+?):\*\* ?(.*)$/u;function Bn(t){let e=t.split(`
21
+ `)}function H(t){return ci(String(t??""),e=>e.replace(/^( {0,3})\\(\\*#)/u,"$1$2"))}var li=/^(?:https?:\/\/)?(?:www\.)?github\.com\/([^/?#]+)\/([^/?#]+?)(?:\.git)?(?:[/?#].*)?$/iu,ui=/^[\w.-]+\/[\w.-]+$/u;function st(t){return ui.test(t)}function oe(t){let e=t?.repo?.github;if(typeof e!="string")return null;let n=e.trim().replace(/\/+$/u,"");if(!n)return null;let i=li.exec(n),r=(i?`${i[1]}/${i[2]}`:n).replace(/\.git$/u,"");return st(r)?r:null}var In=[["Impact","impact",!1],["Reproduction","reproduction",!1],["Recommendation","recommendation",!1],["Confidence reasoning","confidenceReason",!1],["Revalidation verdict","revalidateVerdict",!0],["Revalidation recommendation","revalidateRecommendation",!0]],Cn=[["Status","status"],["Branch","branch"],["Date created","dateCreated"],["Detected at","detectedAt"],["Committed at","committedAt"],["PoC status","pocStatus"],["Variant of","parent"],["Slug","slug"],["Priority","priority"]],Rn=[["Detailed report","reportPath"],["Commit audited","auditedCommit"],["ID","id"]];var di=new Map(Object.entries($n).map(([t,e])=>[e.toLowerCase(),t])),Ln=new Map(Object.entries(En).map(([t,e])=>[e.toLowerCase(),t]));function z(t){let e=/(`+)(.+?)\1(?!`)/u.exec(String(t??""));if(!e)return null;let n=e[2];if(n.length>2&&n.startsWith(" ")&&n.endsWith(" ")){let i=n.slice(1,-1);if(i.startsWith("`")||i.endsWith("`"))return i}return n}function ke(t){let e=G(String(t??""));return e?.index===0?{label:e.label,url:e.url}:null}function Mn(t){let e=/^<(https?:[^>\s]*)>$/u.exec(t.trim());return e?e[1]:null}function On(t){let e=nt.exec(t);return e?{file:e[1],line:e[2]}:{file:t,line:"?"}}function pi(t){let e=t.indexOf(".");return e>0?{exportName:t.slice(0,e),methodName:t.slice(e+1)}:{exportName:t}}function Ae(t){let e=String(t??"").trim();return di.get(e.toLowerCase())??e}function fi(t){let e={},n=t.trim(),i=/ · (`+)(.+?)\1$/u.exec(n);i&&(Object.assign(e,pi(z(i[0]))),n=n.slice(0,i.index));let r=ke(n),o=z(r?r.label:n);return o!==null&&Object.assign(e,On(o)),r&&ot(r.url)&&(e.location=r.url),e}var Tn=" \xB7 flagged critical by the analyzer",hi=" (varies across reports \u2014 ";function mi(t){let e={},n=t.trim();n.endsWith(Tn)&&(e.critical=!0,n=n.slice(0,-Tn.length));let i=n.indexOf(hi);i!==-1&&(n=n.slice(0,i));let r=/^(.*?) — corrected (from|to) (.*)$/u.exec(n);return r?[e.severity,e.correctedSeverity]=(r[2]==="from"?[r[3],r[1]]:[r[1],r[3]]).map(Ae):e.severity=Ae(n),e}var gi=new Set(["max","xhigh","high","medium","low","minimal"]),yi=new Set(["list","isolate"]);function bi(t){return/\d/u.test(t)||/^(?:opus|sonnet|haiku|gpt|gemini|fable|mythos|llama|mistral)\b/iu.test(t)}function Ie(t){let e=t.trim(),n=Ln.get(e.toLowerCase());if(n)return{source:n};let i={},r=[];for(let o of e.split(" \xB7 ").map(s=>s.trim()).filter(Boolean))o==="revalidate"&&!i.revalidate?i.revalidate="revalidation":yi.has(o)&&!i.exportsMode?i.exportsMode=o:gi.has(o)&&!i.effort?i.effort=o:r.push(o);return r.length>1?[i.type,i.model]=r:r.length===1&&(i[bi(r[0])?"model":"type"]=r[0]),{run:i}}function at(t){let e=t.trim(),n=ke(e);return n?n.label.trim():Mn(e)??e}function wi(t){let e=ke(t.trim());if(e){let n=e.url.split("/").at(-1)??"";return $e(n)?n:z(e.label)??n}return z(t)??t.trim()}function vi(t){let e=z(t)??t.trim(),n=e.lastIndexOf("@");return{npm:n>0?{name:e.slice(0,n),version:e.slice(n+1)}:{name:e}}}function _i(t){let e=t.trim().toLowerCase();return e==="the revalidation pass itself"?"revalidation":it.includes(e)?e:void 0}var xi=new Map([...[["Category","category"],...Cn].map(([t,e])=>[t.toLowerCase(),(n,i)=>{n[e]=i}]),...[...Rn,["Found while analyzing","discoveredIn"]].map(([t,e])=>[t.toLowerCase(),(n,i)=>{n[e]=z(i)??i}]),["location",(t,e)=>Object.assign(t,fi(e))],["severity",(t,e)=>Object.assign(t,mi(e))],["confidence",(t,e)=>{let n=/^(\d+(?:\.\d+)?)\/10$/u.exec(e);n&&(t.confidence=Number(n[1]))}],["revalidation",(t,e)=>{let n=_i(e);n&&(t.revalidate=n)}],["revalidated by",(t,e)=>{let n=e.trim();n&&(t.revalidateSource=Ln.get(n.toLowerCase())??n)}],["repository",(t,e)=>{t.repo={github:at(e)}}],["introduced in",(t,e)=>{t.commitHash=wi(e)}],["package",(t,e)=>{t.package=vi(e)}],["priority",(t,e)=>{t.priority=/^-?\d+(?:\.\d+)?$/u.test(e)?Number(e):e}]]);function Nn(t,e,n){let i=xi.get(e.trim().toLowerCase());i&&i(t,n.trim())}var $i=/^- \*\*([^*\n]+?):\*\* ?(.*)$/u;function Bn(t){let e=t.split(`
22
22
  `),n=0,i=()=>{for(;n<e.length&&!e[n].trim();)n++},r=()=>{let a=[];for(let c;(c=$i.exec(e[n]??""))!==null;n++)a.push([c[1].trim(),c[2].trim()]);return a};i();let o=r();if(o.length>0)return{title:"",facts:o,rest:e.slice(n).join(`
23
23
  `)};let s=[];for(;n<e.length&&e[n].trim();)s.push(e[n++]);return i(),o=r(),o.length===0?{title:"",facts:o,rest:t}:{title:H(s.join(`
24
24
  `).trim()),facts:o,rest:e.slice(n).join(`
@@ -26,12 +26,12 @@ var ue=globalThis,pe=ue.ShadowRoot&&(ue.ShadyCSS===void 0||ue.ShadyCSS.nativeSha
26
26
  `)){let o=D(n,i)?null:Ei.exec(r);i+=r.length+1,o?e.push({ref:o[2].trim(),indent:o[1].length+2,note:[]}):e.length>0&&e.at(-1).note.push(r)}return e.map(r=>Si(r))}function Si({ref:t,indent:e,note:n}){let i={},r=ke(t),o=Mn(t),s=o===null?z(r?r.label:t):null;s!==null&&Object.assign(i,On(s));let a=r?r.url:o;ot(a)&&(i.url=a);let c=H(n.map(l=>l.slice(Math.min(e,/^ */u.exec(l)[0].length))).join(`
27
27
  `).trim());return c&&(i.text=c),i}var Dn=new Map(In.map(([t,e])=>[t.toLowerCase(),e])),Ai=[...Dn.keys()];function Fn(t){let e=t.length,n=1/0;for(let i=t.length-1;i>=0;i--){let r=Ai.indexOf(t[i].label.toLowerCase());if(r===-1||r>=n)break;n=r,e=i}return{paragraphs:t.slice(0,e),fields:t.slice(e).map(i=>[Dn.get(i.label.toLowerCase()),i.body])}}function Hn(t,e,n){let i=[],r=An(e),o=t.endsWith("\u2026")?t.slice(0,-1).trimEnd():"";!t||r===t||o&&r.startsWith(o)?i.push(e):i.push(t,e);for(let{label:s,body:a}of n)i.push(a?`**${s}:** ${a}`:`**${s}:**`);return i.filter(Boolean).join(`
28
28
 
29
- `)}var ki=/^<!--\s*DeepView findings export\b[^>]*-->/u,Ii=/^Case \d+ of \d+(?:\s|$)/u,Ci=/^- \*\*([^*\n]+?):\*\* ?(.*)$/gmu,Ri=new Set(["evidence","severity correction","comment"]);function Pn(t){let e=A(t).trim();if(!ki.test(e))return null;let{head:n,subs:i}=R(e,xe),r=[];for(let{heading:o,body:s}of i){if(o.trim().toLowerCase()==="summary")continue;let a=Ti(o);for(let c of T(s,ne))r.push(Mi(c,a))}return Ni(Li(n),r)}function Ti(t){let e=/^(.*?)\s*\(\d+\)\s*$/u.exec(t.trim());return Ae(e?e[1]:t)}function Li(t){let e=new Map;for(let n of t.matchAll(Ci)){let i=n[1].trim().toLowerCase();e.has(i)||e.set(i,n[2].trim())}return{sources:(e.get("source")??"").split(",").map(n=>Ie(n).source).filter(Boolean),analyzers:(e.get("analyzer")??e.get("analyzers")??"").split(";").map(n=>n.trim()).filter(Boolean),repo:e.has("repository")?at(e.get("repository")):""}}function Mi({heading:t,body:e},n){let i=t.trim().replace(/^\d+\.\s+/u,""),r=T(e,C).filter(o=>Ii.test(o.heading.trim()));return r.length===0?[zn(e,C,i,n)]:r.map(o=>zn(o.body,dn,i,n))}function zn(t,e,n,i){let{title:r,facts:o,rest:s}=Bn(t),{head:a,subs:c}=R(s,e),l=c.map(w=>({label:w.heading.trim(),body:w.body.trim()})),d={file:"unknown",line:"?"},p=null;for(let[w,$]of o)w.trim().toLowerCase()==="analyzer"?p=Ie($):Nn(d,w,$);d.severity||(d.severity=i||"medium");let u=r||n,m=u!=="Untitled finding"&&u!==kn(d),f=l.filter(w=>!Ri.has(w.label.toLowerCase())).map(w=>({label:w.label,body:H(w.body)})),{paragraphs:h,fields:g}=Fn(f);d.description=Hn(m?u:"",H(a.trim()),h);let b=l.filter(w=>w.label.toLowerCase()==="evidence").flatMap(w=>Un(w.body));b.length>0&&(d.evidence=b);for(let[w,$]of g)d[w]=$;let _=l.find(w=>w.label.toLowerCase()==="severity correction");return _?.body&&(d.correctedSeverityReason=H(_.body)),{finding:x(d),analyzer:p}}function Oi(t,e){let n={source:null,run:{}};if(e.some(r=>r.analyzer!==null)){let r=new Set(e.map(o=>o.analyzer?.source??null));r.size===1&&!r.has(null)&&([n.source]=r);for(let o of e)o.analyzer?.run?Object.assign(o.finding,o.analyzer.run):o.analyzer?.source&&!n.source&&(o.finding.source=o.analyzer.source);return n}let i=t.analyzers.length===1?Ie(t.analyzers[0]):null;return i?.source?n.source=i.source:i?.run?n.run=i.run:t.analyzers.length===0&&t.sources.length===1&&([n.source]=t.sources),n}function Ni(t,e){let n=e.flat(),{source:i,run:r}=Oi(t,n),o={},s=new Set(n.map(l=>l.finding.type).filter(Boolean)),a=r.type??(s.size===1?[...s][0]:null)??(i?"security":null);a&&(o.type=a),i&&(o.source=i);for(let l of["model","effort","exportsMode"])r[l]&&(o[l]=r[l]);t.repo&&(o.repo={github:t.repo});let c=e.map(l=>l.map(d=>d.finding));return c.every(l=>l.length===1)?o.findings=c.flat():o.groups=c,o}var Bi=new Set(["critical","high","medium","low","high_bug","bug","informational"]);function jn(t){let e=Ui(t);if(!e)return null;let{severity:n,description:i,location:r,file:o,line:s}=e;return r?{severity:n,description:i,location:r}:{severity:n,description:i,file:o,line:s}}function Ui(t){let e=t.indexOf(`
29
+ `)}var ki=/^<!--\s*DeepView findings export\b[^>]*-->/u,Ii=/^Case \d+ of \d+(?:\s|$)/u,Ci=/^- \*\*([^*\n]+?):\*\* ?(.*)$/gmu,Ri=new Set(["evidence","severity correction","comment"]);function Pn(t){let e=A(t).trim();if(!ki.test(e))return null;let{head:n,subs:i}=R(e,xe),r=[];for(let{heading:o,body:s}of i){if(o.trim().toLowerCase()==="summary")continue;let a=Ti(o);for(let c of T(s,ne))r.push(Mi(c,a))}return Ni(Li(n),r)}function Ti(t){let e=/^(.*?)\s*\(\d+\)\s*$/u.exec(t.trim());return Ae(e?e[1]:t)}function Li(t){let e=new Map;for(let n of t.matchAll(Ci)){let i=n[1].trim().toLowerCase();e.has(i)||e.set(i,n[2].trim())}return{sources:(e.get("source")??"").split(",").map(n=>Ie(n).source).filter(Boolean),analyzers:(e.get("analyzer")??e.get("analyzers")??"").split(";").map(n=>n.trim()).filter(Boolean),repo:e.has("repository")?at(e.get("repository")):""}}function Mi({heading:t,body:e},n){let i=t.trim().replace(/^\d+\.\s+/u,""),r=T(e,C).filter(o=>Ii.test(o.heading.trim()));return r.length===0?[zn(e,C,i,n)]:r.map(o=>zn(o.body,dn,i,n))}function zn(t,e,n,i){let{title:r,facts:o,rest:s}=Bn(t),{head:a,subs:c}=R(s,e),l=c.map(w=>({label:w.heading.trim(),body:w.body.trim()})),d={file:"unknown",line:"?"},p=null;for(let[w,$]of o)w.trim().toLowerCase()==="analyzer"?p=Ie($):Nn(d,w,$);d.severity||(d.severity=i||"medium");let u=r||n,h=u!=="Untitled finding"&&u!==kn(d),f=l.filter(w=>!Ri.has(w.label.toLowerCase())).map(w=>({label:w.label,body:H(w.body)})),{paragraphs:m,fields:g}=Fn(f);d.description=Hn(h?u:"",H(a.trim()),m);let b=l.filter(w=>w.label.toLowerCase()==="evidence").flatMap(w=>Un(w.body));b.length>0&&(d.evidence=b);for(let[w,$]of g)d[w]=$;let _=l.find(w=>w.label.toLowerCase()==="severity correction");return _?.body&&(d.correctedSeverityReason=H(_.body)),{finding:x(d),analyzer:p}}function Oi(t,e){let n={source:null,run:{}};if(e.some(r=>r.analyzer!==null)){let r=new Set(e.map(o=>o.analyzer?.source??null));r.size===1&&!r.has(null)&&([n.source]=r);for(let o of e)o.analyzer?.run?Object.assign(o.finding,o.analyzer.run):o.analyzer?.source&&!n.source&&(o.finding.source=o.analyzer.source);return n}let i=t.analyzers.length===1?Ie(t.analyzers[0]):null;return i?.source?n.source=i.source:i?.run?n.run=i.run:t.analyzers.length===0&&t.sources.length===1&&([n.source]=t.sources),n}function Ni(t,e){let n=e.flat(),{source:i,run:r}=Oi(t,n),o={},s=new Set(n.map(l=>l.finding.type).filter(Boolean)),a=r.type??(s.size===1?[...s][0]:null)??(i?"security":null);a&&(o.type=a),i&&(o.source=i);for(let l of["model","effort","exportsMode"])r[l]&&(o[l]=r[l]);t.repo&&(o.repo={github:t.repo});let c=e.map(l=>l.map(d=>d.finding));return c.every(l=>l.length===1)?o.findings=c.flat():o.groups=c,o}var Bi=new Set(["critical","high","medium","low","high_bug","bug","informational"]);function jn(t){let e=Ui(t);if(!e)return null;let{severity:n,description:i,location:r,file:o,line:s}=e;return r?{severity:n,description:i,location:r}:{severity:n,description:i,file:o,line:s}}function Ui(t){let e=t.indexOf(`
30
30
  `),n=(e===-1?t:t.slice(0,e)).trim();if(!n)return null;let i=e===-1?"":t.slice(e+1),{sectionsText:r,metaText:o}=Di(i),s=Fi(r),a=Hi(o),{file:c,line:l,locationLink:d}=zi(s.location||""),p=(a.severity||"").toLowerCase();return{severity:Bi.has(p)?p:"medium",description:Pi(n,s),location:d,file:c||"unknown",line:l}}function Di(t){let e=/^---\s*$/mu,n=e.exec(t);if(!n)return{sectionsText:t,metaText:""};let i=t.slice(0,n.index).trim(),r=t.slice(n.index+n[0].length).replace(/^\n/u,""),o=e.exec(r),s=o?r.slice(0,o.index):r;return{sectionsText:i,metaText:s}}function Fi(t){let e={},n=t.split(/^## /mu);for(let i=1;i<n.length;i++){let r=n[i],o=r.indexOf(`
31
31
  `),s=(o===-1?r:r.slice(0,o)).trim().toLowerCase(),a=(o===-1?"":r.slice(o+1)).trim();s&&(e[s]=a)}return e}function Hi(t){let e={};for(let n of t.matchAll(/\*\*([^:]+):\*\*\s*(.+)/gu))e[n[1].trim().toLowerCase()]=n[2].trim();return e}function zi(t){let e="",n="?",i="",r=t.match(/\[([^\]]+)\]\(([^)]+)\)/u);if(r){e=r[1].trim(),i=r[2];let s=r[2].match(/#L(\d+)/u);s&&(n=s[1])}else e=t.trim(),i=t.trim();let o=e.match(/^(.+):(\d+)$/u);return o&&(e=o[1],n==="?"&&(n=o[2])),{file:e,line:n,locationLink:i}}function Pi(t,e){let n=[t];return e.details&&n.push(e.details),e.impact&&n.push(`Impact: ${e.impact}`),e["reproduction steps"]&&n.push(`Reproduction: ${e["reproduction steps"]}`),ji(n.join(`
32
32
 
33
- `))}function ji(t){return t.replaceAll("**","")}var Vi=new Set([...Sn,"informative"]);function Wn(t){let e=A(t).trim();if(!e.startsWith("# "))return null;let i=Ee(e,/^# /gmu).slice(1).filter(r=>r.trim().length>0).map(r=>Gi(r)).filter(Boolean);return i.length===0?null:{type:"security",source:"claude-security",findings:i}}function Gi(t){let{title:e,body:n}=re(t);if(!e)return null;let{sectionsText:i,metaText:r}=Wi(n),o=Ki(i),s=Object.fromEntries([...r.matchAll(/\*\*([^:]+):\*\*\s*(.+)/gu)].map(b=>[b[1].trim().toLowerCase(),b[2].trim()])),a=Yi(o.evidence||""),{file:c,line:l,locationLink:d}=Kn(o.location||a[0]?.ref||""),p=(s.severity||"").toLowerCase(),u=Vi.has(p)?p:"medium",m=Qi(e,o,a.length>0),f={file:c||"unknown",line:l,severity:u,description:m};d&&(f.location=d),a.length>0&&(f.evidence=a.map(Ji)),o["reproduction steps"]&&(f.reproduction=Xi(o["reproduction steps"])),o["recommended fix"]&&(f.recommendation=o["recommended fix"]),s.repository&&(f.repo={github:s.repository}),s.branch&&(f.branch=s.branch),s["date created"]&&(f.dateCreated=s["date created"]),s.status&&(f.status=s.status),s.category&&(f.category=s.category);let h=t.indexOf(`
34
- # `),g=jn(h===-1?t:t.slice(0,h+1));return g&&(f._idBasis=g),x(f)}function Wi(t){let e=/^---\s*$/mu,n=e.exec(t);if(!n)return{sectionsText:t,metaText:""};let i=t.slice(0,n.index).trim(),r=t.slice(n.index+n[0].length).replace(/^\n/u,""),o=e.exec(r),s=o?r.slice(0,o.index):r;return{sectionsText:i,metaText:s}}function Ki(t){let e=t.split(/^## /mu).slice(1).map(n=>re(n));return Object.fromEntries(e.filter(n=>n.title).map(n=>[n.title.toLowerCase(),n.body.trim()]))}function Kn(t){let e="",n="?",i="",r=G(t);if(r){e=r.label.trim(),i=r.url.trim();let s=i.match(/#L(\d+)(?:-L?(\d+))?/u);s&&(n=s[2]?`${s[1]}-${s[2]}`:s[1])}else e=t.trim(),i=t.trim();e=gn(e.replaceAll("`","")).trim();let o=e.match(/^(.+):(\d+)(?:\s*[-–—]\s*L?(\d+))?$/u);return o&&(e=o[1],n==="?"&&(n=o[3]?`${o[2]}-${o[3]}`:o[2])),{file:e,line:n,locationLink:i,linked:r!==null}}function Xi(t){let e=t.split(`
33
+ `))}function ji(t){return t.replaceAll("**","")}var Vi=new Set([...Sn,"informative"]);function Wn(t){let e=A(t).trim();if(!e.startsWith("# "))return null;let i=Ee(e,/^# /gmu).slice(1).filter(r=>r.trim().length>0).map(r=>Gi(r)).filter(Boolean);return i.length===0?null:{type:"security",source:"claude-security",findings:i}}function Gi(t){let{title:e,body:n}=re(t);if(!e)return null;let{sectionsText:i,metaText:r}=Wi(n),o=Ki(i),s=Object.fromEntries([...r.matchAll(/\*\*([^:]+):\*\*\s*(.+)/gu)].map(b=>[b[1].trim().toLowerCase(),b[2].trim()])),a=Yi(o.evidence||""),{file:c,line:l,locationLink:d}=Kn(o.location||a[0]?.ref||""),p=(s.severity||"").toLowerCase(),u=Vi.has(p)?p:"medium",h=Qi(e,o,a.length>0),f={file:c||"unknown",line:l,severity:u,description:h};d&&(f.location=d),a.length>0&&(f.evidence=a.map(Ji)),o["reproduction steps"]&&(f.reproduction=Xi(o["reproduction steps"])),o["recommended fix"]&&(f.recommendation=o["recommended fix"]),s.repository&&(f.repo={github:s.repository}),s.branch&&(f.branch=s.branch),s["date created"]&&(f.dateCreated=s["date created"]),s.status&&(f.status=s.status),s.category&&(f.category=s.category);let m=t.indexOf(`
34
+ # `),g=jn(m===-1?t:t.slice(0,m+1));return g&&(f._idBasis=g),x(f)}function Wi(t){let e=/^---\s*$/mu,n=e.exec(t);if(!n)return{sectionsText:t,metaText:""};let i=t.slice(0,n.index).trim(),r=t.slice(n.index+n[0].length).replace(/^\n/u,""),o=e.exec(r),s=o?r.slice(0,o.index):r;return{sectionsText:i,metaText:s}}function Ki(t){let e=t.split(/^## /mu).slice(1).map(n=>re(n));return Object.fromEntries(e.filter(n=>n.title).map(n=>[n.title.toLowerCase(),n.body.trim()]))}function Kn(t){let e="",n="?",i="",r=G(t);if(r){e=r.label.trim(),i=r.url.trim();let s=i.match(/#L(\d+)(?:-L?(\d+))?/u);s&&(n=s[2]?`${s[1]}-${s[2]}`:s[1])}else e=t.trim(),i=t.trim();e=gn(e.replaceAll("`","")).trim();let o=e.match(/^(.+):(\d+)(?:\s*[-–—]\s*L?(\d+))?$/u);return o&&(e=o[1],n==="?"&&(n=o[3]?`${o[2]}-${o[3]}`:o[2])),{file:e,line:n,locationLink:i,linked:r!==null}}function Xi(t){let e=t.split(`
35
35
  `),n=e.findIndex(a=>a.trim());if(n===-1||!B.test(e[n])||e.some((a,c)=>c!==n&&B.test(a)))return t;let i=e[n].replace(/^ */u,""),r=i.replace(B,"");if(!r.trim())return t;let o=Vn(r)??Vn(i);if(o===null&&(B.test(r)||qi.test(i)))return t;let s=o===null?[r]:o.length===1?[o[0].step]:o.map(({number:a,step:c})=>`${a}. ${c}`);return e.splice(n,1,...s),e.join(`
36
36
  `)}var Zi=/(?:^|[ \t])(\d{1,9})\)(?=[ \t]|$)/gu,qi=/^\d{1,9}\)(?=[ \t]|$)/u;function Vn(t){let e=[...t.matchAll(Zi)];if(e.length===0||e[0].index!==0)return null;let n=[];for(let[i,r]of e.entries()){let o=Number(r[1]);if(i>0&&o<=n[i-1].number)return null;let s=t.slice(r.index+r[0].length,e[i+1]?.index).trim();if(!s)return null;n.push({number:o,step:s})}return n}var Gn=/^[ \t]*(?:\d+[.)]|[-*+])\s+/u;function Yi(t){let e=[];for(let n of t.split(`
37
37
  `))Gn.test(n)?e.push({ref:n.replace(Gn,"").trim(),note:[]}):e.length>0&&n.trim()&&e.at(-1).note.push(n.trim());if(e.length===0){let n=t.split(`
@@ -39,21 +39,21 @@ var ue=globalThis,pe=ue.ShadowRoot&&(ue.ShadyCSS===void 0||ue.ShadyCSS.nativeSha
39
39
  `);return a&&(s.text=a),s}function Qi(t,e,n){let i=[t];return e.details&&i.push(e.details),e.evidence&&!n&&i.push(`**Evidence:**
40
40
  ${e.evidence}`),e.impact&&i.push(`**Impact:** ${e.impact}`),i.join(`
41
41
 
42
- `)}function eo(t){let e=(t||"").trim(),n="",i=/\[([^\]]+)\]\(([^)]+)\)/u.exec(e);i&&(e=i[1].trim(),n=i[2].trim());let r="",o=/#L(\d+)/u.exec(n);o&&(r=o[1]);let c=[...e.matchAll(/`([^`]+)`/gu)].map(p=>p[1].trim()).find(p=>!p.includes("(")&&(p.includes("/")||/\.\w/u.test(p)))??(e.replaceAll("`","").trim().split(/[\s,]+/u).find(Boolean)||""),l=/^(.*?)#L(\d+)(?:-L?\d+)?$/u.exec(c);l&&(c=l[1],r||(r=l[2]));let d=/^(.+):(\d+(?:-\d+)?)$/u.exec(c);return d?(r||(r=d[2]),{file:d[1],line:r,locationLink:n}):{file:c,line:r||"?",locationLink:n}}function Xn({severity:t,description:e,ref:n,lineBullet:i="",id:r=""}){let o=eo(n),s=o.file||"unknown",a=o.line==="?"&&i?i:o.line,c=o.locationLink||(s==="unknown"&&r?`piolium:${r}`:"");return c?{severity:t,description:e,location:c}:{severity:t,description:e,file:s,line:a}}function L(t){let e=((t||"").trim().split(/\s+/u)[0]||"").replaceAll(/[`*]+/gu,"");return Se.get(e.toUpperCase())??""}function se(...t){return{severity:t.find(Boolean)||"medium",identitySeverity:t.find(e=>e&&e!=="informative")||"medium"}}function ae(t){let e=/^([CHML])-?\d+$/iu.exec((t||"").trim());return e?{C:"critical",H:"high",M:"medium",L:"low"}[e[1].toUpperCase()]:""}function ct(t){return L(/^(critical|high|medium|low|informational|informative|info)(?:[ -](?:severity|risk))?(?:[ -]findings?)?(?:\s*\(\d+\))?$/iu.exec((t||"").trim())?.[1])}function Zn(t){return L(/^(critical|high|medium|low|informational|informative|info)\b/iu.exec((t||"").trim())?.[1])}function Re(t){return/^variants?\s*(?:\(\d+\))?\s*:?$/iu.test((t||"").trim())}function Te(t){let e=/^([CHML]-?\d{1,4}|(?:p|q|b|r|m|l|x|diff)\d{0,4}-\d{2,4})(?:-([A-Za-z0-9][\w-]*))?$/iu.exec(t||"");return e?{id:e[1].toUpperCase(),slug:e[2]||""}:null}function Ce(t){return(t||"").replaceAll("-"," ")}function ce(t){let e=(t||"").trim(),n=/^\[([^\]]+)\]\([^)]*\)$/u.exec(e);return yn(n?n[1]:e).toUpperCase()}function lt(t){let e=/^\[([^\]]+)\]\(([^)]+)\)\s*[:—–-]*\s*(.*)$/u.exec(t);return e?{text:e[3]?`${e[1].trim()} ${e[3].trim()}`:e[1].trim(),link:e[2].trim()}:null}function ut(t){let e=t.search(/\s/u),n=(e===-1?t:t.slice(0,e)).replace(/[:.,—–-]+$/u,""),i=Te(n);if(!i)return null;let r=(e===-1?"":t.slice(e+1)).replace(/^[:—–-]+\s*/u,"").trim();return{id:i.id,slug:i.slug,rest:r}}function dt(t){let{text:e,link:n}=lt(t)??{text:t,link:""},i=/^\[([^\]]+)\] *(.*)$/u.exec(e);if(i){let o=Te(i[1].trim());return o?{id:o.id,title:i[2].trim()||Ce(o.slug)||o.id,link:n}:{id:i[1].trim().toUpperCase(),title:i[2].trim(),link:n}}let r=ut(e);return r?{id:r.id,title:r.rest||Ce(r.slug)||r.id,link:n}:{id:"",title:e.trim(),link:n}}function qn(t){let e={},n=o=>{let s=o.exec(t||"")?.[1];return s===void 0?"":(/`([^`]+)`/u.exec(s)?.[1]??s.split(/\s+/u)[0]??"").trim()},i=n(/^\s*(?:[-*] +)?\*\*Target:?\*\*\s*(.*)$/imu);st(i)&&(e.repo=i);let r=n(/^\s*(?:[-*] +)?\*\*Commit[^:*]*:?\*\*\s*(.*)$/imu);return $e(r)&&(e.commitHash=r),e}var pt=["key code reference","key code","code reference","location","affected file","file","path"];function Le(t){return{id:ce(t.id||""),title:F(t.title),severity:F(t.severity),pocStatus:F(t["poc status"]||t.poc),status:F(t.status),parent:ce(F(t.parent||"")),location:F(t.location)}}function Me(t,e=""){let{severity:n,identitySeverity:i}=se(L(t.severity),e,ae(t.id)),r=ft({ref:t.location||"",id:t.id,severity:n,identitySeverity:i,description:rt(t.title||t.id)});for(let o of["pocStatus","status","parent"])t[o]&&(r[o]=t[o]);return x(r)}function ft({ref:t,lineBullet:e="",id:n,severity:i,identitySeverity:r,description:o}){let{file:s,line:a,locationLink:c}=mn(t),l={file:s||"unknown",line:a==="?"&&e?e:a,severity:i,description:o};return c?l.location=c:l.file==="unknown"&&n&&(l.location=`piolium:${n}`),l._idBasis=Xn({severity:r,description:o,ref:t,lineBullet:e,id:n}),l}function mt(t,e,n){let i=[];for(let r of t.split(`
42
+ `)}function eo(t){let e=(t||"").trim(),n="",i=/\[([^\]]+)\]\(([^)]+)\)/u.exec(e);i&&(e=i[1].trim(),n=i[2].trim());let r="",o=/#L(\d+)/u.exec(n);o&&(r=o[1]);let c=[...e.matchAll(/`([^`]+)`/gu)].map(p=>p[1].trim()).find(p=>!p.includes("(")&&(p.includes("/")||/\.\w/u.test(p)))??(e.replaceAll("`","").trim().split(/[\s,]+/u).find(Boolean)||""),l=/^(.*?)#L(\d+)(?:-L?\d+)?$/u.exec(c);l&&(c=l[1],r||(r=l[2]));let d=/^(.+):(\d+(?:-\d+)?)$/u.exec(c);return d?(r||(r=d[2]),{file:d[1],line:r,locationLink:n}):{file:c,line:r||"?",locationLink:n}}function Xn({severity:t,description:e,ref:n,lineBullet:i="",id:r=""}){let o=eo(n),s=o.file||"unknown",a=o.line==="?"&&i?i:o.line,c=o.locationLink||(s==="unknown"&&r?`piolium:${r}`:"");return c?{severity:t,description:e,location:c}:{severity:t,description:e,file:s,line:a}}function L(t){let e=((t||"").trim().split(/\s+/u)[0]||"").replaceAll(/[`*]+/gu,"");return Se.get(e.toUpperCase())??""}function se(...t){return{severity:t.find(Boolean)||"medium",identitySeverity:t.find(e=>e&&e!=="informative")||"medium"}}function ae(t){let e=/^([CHML])-?\d+$/iu.exec((t||"").trim());return e?{C:"critical",H:"high",M:"medium",L:"low"}[e[1].toUpperCase()]:""}function ct(t){return L(/^(critical|high|medium|low|informational|informative|info)(?:[ -](?:severity|risk))?(?:[ -]findings?)?(?:\s*\(\d+\))?$/iu.exec((t||"").trim())?.[1])}function Zn(t){return L(/^(critical|high|medium|low|informational|informative|info)\b/iu.exec((t||"").trim())?.[1])}function Re(t){return/^variants?\s*(?:\(\d+\))?\s*:?$/iu.test((t||"").trim())}function Te(t){let e=/^([CHML]-?\d{1,4}|(?:p|q|b|r|m|l|x|diff)\d{0,4}-\d{2,4})(?:-([A-Za-z0-9][\w-]*))?$/iu.exec(t||"");return e?{id:e[1].toUpperCase(),slug:e[2]||""}:null}function Ce(t){return(t||"").replaceAll("-"," ")}function ce(t){let e=(t||"").trim(),n=/^\[([^\]]+)\]\([^)]*\)$/u.exec(e);return yn(n?n[1]:e).toUpperCase()}function lt(t){let e=/^\[([^\]]+)\]\(([^)]+)\)\s*[:—–-]*\s*(.*)$/u.exec(t);return e?{text:e[3]?`${e[1].trim()} ${e[3].trim()}`:e[1].trim(),link:e[2].trim()}:null}function ut(t){let e=t.search(/\s/u),n=(e===-1?t:t.slice(0,e)).replace(/[:.,—–-]+$/u,""),i=Te(n);if(!i)return null;let r=(e===-1?"":t.slice(e+1)).replace(/^[:—–-]+\s*/u,"").trim();return{id:i.id,slug:i.slug,rest:r}}function dt(t){let{text:e,link:n}=lt(t)??{text:t,link:""},i=/^\[([^\]]+)\] *(.*)$/u.exec(e);if(i){let o=Te(i[1].trim());return o?{id:o.id,title:i[2].trim()||Ce(o.slug)||o.id,link:n}:{id:i[1].trim().toUpperCase(),title:i[2].trim(),link:n}}let r=ut(e);return r?{id:r.id,title:r.rest||Ce(r.slug)||r.id,link:n}:{id:"",title:e.trim(),link:n}}function qn(t){let e={},n=o=>{let s=o.exec(t||"")?.[1];return s===void 0?"":(/`([^`]+)`/u.exec(s)?.[1]??s.split(/\s+/u)[0]??"").trim()},i=n(/^\s*(?:[-*] +)?\*\*Target:?\*\*\s*(.*)$/imu);st(i)&&(e.repo=i);let r=n(/^\s*(?:[-*] +)?\*\*Commit[^:*]*:?\*\*\s*(.*)$/imu);return $e(r)&&(e.commitHash=r),e}var pt=["key code reference","key code","code reference","location","affected file","file","path"];function Le(t){return{id:ce(t.id||""),title:F(t.title),severity:F(t.severity),pocStatus:F(t["poc status"]||t.poc),status:F(t.status),parent:ce(F(t.parent||"")),location:F(t.location)}}function Me(t,e=""){let{severity:n,identitySeverity:i}=se(L(t.severity),e,ae(t.id)),r=ft({ref:t.location||"",id:t.id,severity:n,identitySeverity:i,description:rt(t.title||t.id)});for(let o of["pocStatus","status","parent"])t[o]&&(r[o]=t[o]);return x(r)}function ft({ref:t,lineBullet:e="",id:n,severity:i,identitySeverity:r,description:o}){let{file:s,line:a,locationLink:c}=hn(t),l={file:s||"unknown",line:a==="?"&&e?e:a,severity:i,description:o};return c?l.location=c:l.file==="unknown"&&n&&(l.location=`piolium:${n}`),l._idBasis=Xn({severity:r,description:o,ref:t,lineBullet:e,id:n}),l}function ht(t,e,n){let i=[];for(let r of t.split(`
43
43
  `)){let o=/^\s{0,3}(?:[-*+]|\d{1,3}[.)])\s+(.+)$/u.exec(r);if(!o)continue;let s=o[1].trim();if(/^\*\*[^:*]+:\*\*/u.test(s))continue;let a=lt(s),c=a?.link??"";if(a)s=a.text;else{let g=/^\*\*([^*]+)\*\*\s*[:—–-]*\s*(.*)$/u.exec(s);g&&(s=g[2]?`${g[1].trim()} ${g[2].trim()}`:g[1].trim())}if(/^(?:none\b|no |n\/a\b)/iu.test(s))continue;let l=ut(s),d=l?.id??"",p=s;if(l){let g=Ce(l.slug);p=g&&l.rest?`${g}
44
44
 
45
- ${l.rest}`:l.rest||g||l.id}let u=n.get(d),{severity:m,identitySeverity:f}=se(L(u?.severity),e,ae(d)),h={file:"unknown",line:"?",severity:m,description:rt(p)};d?h.location=`piolium:${d}`:c&&(h.location=c),c.endsWith("report.md")&&(h.reportPath=c);for(let g of["pocStatus","status","parent"])u?.[g]&&(h[g]=u[g]);i.push({id:d,finding:x(h,f)})}return i}function ht(t,e,n,i=""){let r=[];for(let s of ie(t)){let a=Le(s);!a.id&&!a.title||(!a.parent&&n&&(a.parent=n),a.id&&!e.has(a.id)&&e.set(a.id,a),r.push({id:a.id,finding:Me(a,i)}))}if(r.length>0)return r;let o=mt(t,i,e);for(let s of o)n&&!s.finding.parent&&(s.finding.parent=n);return o}var to=new Set(["technical findings detail","technical findings","detailed findings","findings detail","findings"]),no=/^(?:summary of findings\b|deferred|methodolog|executive|conclusion|attack surface|coverage|discoveries|scope\b|table of contents|contents\b|appendix|recommendation|remediation)/u;function Yn(t){let{id:e}=dt(t);return!!(e&&Te(e))}function ro(t){let e=T(t,ne);return(e.length>0?e:T(t,C)).some(({heading:i})=>Yn(i))}function Jn(t){let e=A(t).trim();if(!/^# +Security Audit Report\b/mu.test(e)&&!/^## +Technical Findings Detail\s*$/imu.test(e)&&!/^## +Findings by Severity\b/imu.test(e))return null;let{head:n,subs:i}=R(e,xe),r=ao(i),o=new Map(ie(r["summary of findings"]||"").map(Le).filter(u=>u.id).map(u=>[u.id,u])),s=qn(n),a=[],c=new Set,l=[],d=({id:u,finding:m})=>{a.push(m),u&&c.add(u)},p=u=>{for(let m of u)d(m)};for(let[u,m]of Object.entries(r)){let f=ct(u);f||to.has(u)||u.startsWith("findings by severity")?p(gt(m,f,o,l)):!no.test(u)&&ro(m)&&p(gt(m,Zn(u),o,l))}for(let u of l)(!u.id||!c.has(u.id))&&d(u);for(let u of o.values())c.has(u.id)||d({id:u.id,finding:Me(u)});if(a.length===0)return null;for(let u of a)s.repo&&(u.repo={github:s.repo}),s.commitHash&&!u.auditedCommit&&(u.auditedCommit=s.commitHash);return{type:"security",source:"piolium",findings:a}}function io(t,e,n,i){let r=[],o="";for(let{heading:s,body:a}of t){let c=ct(s);if(c)r.push(...gt(a,c,e,n)),o="";else if(Re(s))r.push(...so(a,e,o,n,i));else{let l=oo(s,a,e,n,i);r.push(...l),o=l[0]?.id||o}}return r}function oo(t,e,n,i,r){let{head:o,subs:s}=R(e,C),a=Qn(t,o,n,r),c=a!==null&&!a.id&&s.some(d=>!Re(d.heading)&&Yn(d.heading)),l=a&&!c?[a]:[];return l.push(...yt(s,n,i,r,a?.id||"")),l}function so(t,e,n,i,r){let{head:o,subs:s}=R(t,C);return i.push(...ht(o,e,n,r)),yt(s,e,i,r,"")}function yt(t,e,n,i,r){let o=[],s="";for(let{heading:a,body:c}of t){if(Re(a)){n.push(...ht(c,e,r??s,i));continue}let l=Qn(a,c,e,i);l&&(o.push(l),s=l.id||s)}return o}function gt(t,e,n,i){let r=T(t,ne);if(r.length>0)return io(r,n,i,e);let o=yt(T(t,C),n,i,e,null);if(o.length>0)return o;let s=ie(t).map(Le).filter(a=>a.id||a.title);for(let a of s)!a.severity&&e&&(a.severity=e),a.id&&!n.has(a.id)?n.set(a.id,a):a.id||i.push({id:"",finding:Me(a,e)});return s.length===0&&i.push(...mt(t,e,n)),[]}function Qn(t,e,n,i=""){let r=t.trim();if(!r)return null;let{id:o,title:s,link:a}=dt(r),c=n.get(o);if(!o&&s){let k=s.toLowerCase();c=[...n.values()].find(pr=>pr.title.toLowerCase()===k),o=c?.id??""}let{fields:l,labels:d,prose:p}=fn(e),{severity:u,identitySeverity:m}=se(L(l.severity),L(c?.severity),i,ae(o)),f=/\d+/u.exec(l.line||l.lines||"")?.[0]??"",h=/\*\*Variant of:?\*\*\s*\[?([^\]\s)]+)/iu.exec(e),g=p.split(`
45
+ ${l.rest}`:l.rest||g||l.id}let u=n.get(d),{severity:h,identitySeverity:f}=se(L(u?.severity),e,ae(d)),m={file:"unknown",line:"?",severity:h,description:rt(p)};d?m.location=`piolium:${d}`:c&&(m.location=c),c.endsWith("report.md")&&(m.reportPath=c);for(let g of["pocStatus","status","parent"])u?.[g]&&(m[g]=u[g]);i.push({id:d,finding:x(m,f)})}return i}function mt(t,e,n,i=""){let r=[];for(let s of ie(t)){let a=Le(s);!a.id&&!a.title||(!a.parent&&n&&(a.parent=n),a.id&&!e.has(a.id)&&e.set(a.id,a),r.push({id:a.id,finding:Me(a,i)}))}if(r.length>0)return r;let o=ht(t,i,e);for(let s of o)n&&!s.finding.parent&&(s.finding.parent=n);return o}var to=new Set(["technical findings detail","technical findings","detailed findings","findings detail","findings"]),no=/^(?:summary of findings\b|deferred|methodolog|executive|conclusion|attack surface|coverage|discoveries|scope\b|table of contents|contents\b|appendix|recommendation|remediation)/u;function Yn(t){let{id:e}=dt(t);return!!(e&&Te(e))}function ro(t){let e=T(t,ne);return(e.length>0?e:T(t,C)).some(({heading:i})=>Yn(i))}function Jn(t){let e=A(t).trim();if(!/^# +Security Audit Report\b/mu.test(e)&&!/^## +Technical Findings Detail\s*$/imu.test(e)&&!/^## +Findings by Severity\b/imu.test(e))return null;let{head:n,subs:i}=R(e,xe),r=ao(i),o=new Map(ie(r["summary of findings"]||"").map(Le).filter(u=>u.id).map(u=>[u.id,u])),s=qn(n),a=[],c=new Set,l=[],d=({id:u,finding:h})=>{a.push(h),u&&c.add(u)},p=u=>{for(let h of u)d(h)};for(let[u,h]of Object.entries(r)){let f=ct(u);f||to.has(u)||u.startsWith("findings by severity")?p(gt(h,f,o,l)):!no.test(u)&&ro(h)&&p(gt(h,Zn(u),o,l))}for(let u of l)(!u.id||!c.has(u.id))&&d(u);for(let u of o.values())c.has(u.id)||d({id:u.id,finding:Me(u)});if(a.length===0)return null;for(let u of a)s.repo&&(u.repo={github:s.repo}),s.commitHash&&!u.auditedCommit&&(u.auditedCommit=s.commitHash);return{type:"security",source:"piolium",findings:a}}function io(t,e,n,i){let r=[],o="";for(let{heading:s,body:a}of t){let c=ct(s);if(c)r.push(...gt(a,c,e,n)),o="";else if(Re(s))r.push(...so(a,e,o,n,i));else{let l=oo(s,a,e,n,i);r.push(...l),o=l[0]?.id||o}}return r}function oo(t,e,n,i,r){let{head:o,subs:s}=R(e,C),a=Qn(t,o,n,r),c=a!==null&&!a.id&&s.some(d=>!Re(d.heading)&&Yn(d.heading)),l=a&&!c?[a]:[];return l.push(...yt(s,n,i,r,a?.id||"")),l}function so(t,e,n,i,r){let{head:o,subs:s}=R(t,C);return i.push(...mt(o,e,n,r)),yt(s,e,i,r,"")}function yt(t,e,n,i,r){let o=[],s="";for(let{heading:a,body:c}of t){if(Re(a)){n.push(...mt(c,e,r??s,i));continue}let l=Qn(a,c,e,i);l&&(o.push(l),s=l.id||s)}return o}function gt(t,e,n,i){let r=T(t,ne);if(r.length>0)return io(r,n,i,e);let o=yt(T(t,C),n,i,e,null);if(o.length>0)return o;let s=ie(t).map(Le).filter(a=>a.id||a.title);for(let a of s)!a.severity&&e&&(a.severity=e),a.id&&!n.has(a.id)?n.set(a.id,a):a.id||i.push({id:"",finding:Me(a,e)});return s.length===0&&i.push(...ht(t,e,n)),[]}function Qn(t,e,n,i=""){let r=t.trim();if(!r)return null;let{id:o,title:s,link:a}=dt(r),c=n.get(o);if(!o&&s){let k=s.toLowerCase();c=[...n.values()].find(pr=>pr.title.toLowerCase()===k),o=c?.id??""}let{fields:l,labels:d,prose:p}=fn(e),{severity:u,identitySeverity:h}=se(L(l.severity),L(c?.severity),i,ae(o)),f=/\d+/u.exec(l.line||l.lines||"")?.[0]??"",m=/\*\*Variant of:?\*\*\s*\[?([^\]\s)]+)/iu.exec(e),g=p.split(`
46
46
  `).filter(k=>!/^\s*<a\s[^>]*>\s*<\/a>\s*$/iu.test(k)&&!/\*\*Variant of:?\*\*/iu.test(k)).join(`
47
- `).trim(),b=ft({ref:pt.map(k=>l[k]).find(Boolean)??"",lineBullet:f,id:o,severity:u,identitySeverity:m,description:lo(s||o,l,d,g)}),_=l["poc status"]||l.poc||c?.pocStatus;_&&(b.pocStatus=_);let w=l["detailed report"]||(a.endsWith("report.md")?a:"");w&&(b.reportPath=w),c?.status&&(b.status=c.status);let $=c?.parent||(h?ce(h[1]):"");return $&&(b.parent=$),{id:o,finding:x(b)}}function ao(t){let e=Object.create(null);for(let{heading:n,body:i}of t){let r=n.trim().toLowerCase();r&&(e[r]=r in e?`${e[r]}
47
+ `).trim(),b=ft({ref:pt.map(k=>l[k]).find(Boolean)??"",lineBullet:f,id:o,severity:u,identitySeverity:h,description:lo(s||o,l,d,g)}),_=l["poc status"]||l.poc||c?.pocStatus;_&&(b.pocStatus=_);let w=l["detailed report"]||(a.endsWith("report.md")?a:"");w&&(b.reportPath=w),c?.status&&(b.status=c.status);let $=c?.parent||(m?ce(m[1]):"");return $&&(b.parent=$),{id:o,finding:x(b)}}function ao(t){let e=Object.create(null);for(let{heading:n,body:i}of t){let r=n.trim().toLowerCase();r&&(e[r]=r in e?`${e[r]}
48
48
  ${i}`:i)}return e}var co=new Set([...pt,"severity","summary","files","poc","poc status","line","lines","detailed report","proof of concept","evidence","variant of","pattern","status","id","title"]);function lo(t,e,n,i){let r=[t];e.summary&&r.push(e.summary),i&&r.push(i);for(let[o,s]of Object.entries(e))!s||co.has(o)||r.push(`**${n[o]||o}:** ${s}`);return r.filter(Boolean).join(`
49
49
 
50
50
  `)}var uo=["finding_url","repository","title","description","severity","configured_scan_id","relevant_paths"];function po(t){let e=[],n=[],i="",r=!1;for(let o=0;o<t.length;o++){let s=t[o];r?s==='"'?t[o+1]==='"'?(i+='"',o++):r=!1:i+=s:s==='"'?r=!0:s===","?(n.push(i),i=""):s===`
51
51
  `||s==="\r"?(n.push(i),e.push(n),n=[],i="",s==="\r"&&t[o+1]===`
52
- `&&o++):i+=s}for((i!==""||n.length>0)&&(n.push(i),e.push(n));e.length>0&&e.at(-1).length===1&&e.at(-1)[0]==="";)e.pop();return e}function fo(t,e){return e.map(n=>{let i=Object.create(null);return t.forEach((r,o)=>{i[r]=n[o]??""}),i})}function bt(t){let e=po(t);if(e.length<2)throw new Error("Codex CSV: empty or missing header row");let[n,...i]=e;for(let s of uo)if(!n.includes(s))throw new Error(`Codex CSV: missing required column "${s}"`);let r=Map.groupBy(fo(n,i).filter(s=>s.configured_scan_id),s=>s.configured_scan_id);if(r.size===0)throw new Error("Codex CSV: no rows with a configured_scan_id");let o=[];for(let[s,a]of r){let c=new Set(a.map(p=>p.repository).filter(Boolean));if(c.size>1)throw new Error(`Codex CSV: scan ${s} contains multiple repositories: ${[...c].join(", ")}`);let d=`${[...c][0]||"unknown-repo"}:${s.replace(/^[^:]+:/u,"")}`;o.push({displayName:d,data:{type:"security",source:"codex-security",findings:a.map(mo)}})}return o}function mo(t){let e=t.relevant_paths.split(" | ").map(r=>r.trim()).find(Boolean)||"unknown",n=[t.title,t.description].filter(Boolean).join(`
52
+ `&&o++):i+=s}for((i!==""||n.length>0)&&(n.push(i),e.push(n));e.length>0&&e.at(-1).length===1&&e.at(-1)[0]==="";)e.pop();return e}function fo(t,e){return e.map(n=>{let i=Object.create(null);return t.forEach((r,o)=>{i[r]=n[o]??""}),i})}function bt(t){let e=po(t);if(e.length<2)throw new Error("Codex CSV: empty or missing header row");let[n,...i]=e;for(let s of uo)if(!n.includes(s))throw new Error(`Codex CSV: missing required column "${s}"`);let r=Map.groupBy(fo(n,i).filter(s=>s.configured_scan_id),s=>s.configured_scan_id);if(r.size===0)throw new Error("Codex CSV: no rows with a configured_scan_id");let o=[];for(let[s,a]of r){let c=new Set(a.map(p=>p.repository).filter(Boolean));if(c.size>1)throw new Error(`Codex CSV: scan ${s} contains multiple repositories: ${[...c].join(", ")}`);let d=`${[...c][0]||"unknown-repo"}:${s.replace(/^[^:]+:/u,"")}`;o.push({displayName:d,data:{type:"security",source:"codex-security",findings:a.map(ho)}})}return o}function ho(t){let e=t.relevant_paths.split(" | ").map(r=>r.trim()).find(Boolean)||"unknown",n=[t.title,t.description].filter(Boolean).join(`
53
53
 
54
- `),i={id:t.finding_url,file:e,line:"?",severity:(t.severity||"medium").toLowerCase(),description:n,repo:{github:t.repository}};return t.commit_hash&&(i.commitHash=t.commit_hash),t.detected_at&&(i.detectedAt=t.detected_at),t.committed_at&&(i.committedAt=t.committed_at),x(i)}var ho=[["deepview-md",Pn],["deepsec",xn],["piolium",Jn],["claude-security",Wn]];function wt(t){return Array.isArray(t?.findings)?t.findings:Array.isArray(t?.groups)?t.groups:null}function er(t,e){return typeof e=="string"&&/\.csv$/iu.test(e)?"codex":Oe(t).format}function Oe(t){let e;try{let n=JSON.parse(t);if(wt(n)){for(let i of tr(wt(n)))x(i);return{data:n,format:"json",reason:null}}return{data:null,format:null,reason:"JSON, but not a report: no findings array"}}catch(n){e=n}for(let[n,i]of ho){let r=i(t);if(r)return{data:r,format:n,reason:null}}return{data:null,format:null,reason:`Not JSON, and not a recognized markdown format. (JSON error: ${e.message})`}}function tr(t){return t.flat().filter(e=>e&&typeof e=="object")}async function go(t){for(let i of t)x(i);let e=t.filter(i=>!i.id);if(e.length===0)return;let n=await Promise.all(e.map(sn));e.forEach((i,r)=>{n[r]&&(i.id=n[r])})}async function nr(t){let{data:e,format:n}=Oe(t);if(!e)return null;let i=tr(wt(e));return await go(i),{format:n,data:e,findings:i}}function vt(t,e){let n=t.trimStart().startsWith("[")?rn(t):null;if(n)return{data:{source:"links",findings:[],links:n.groups},format:"links",reason:null};let i=Oe(t);if(i.data!=null||er(t,e)!=="codex")return i;try{return{data:{type:"security",source:"codex-security",findings:bt(t).flatMap(o=>o.data.findings)},format:"codex",reason:null}}catch(r){return{data:null,format:null,reason:r instanceof Error?r.message:"Invalid Codex CSV"}}}function rr(t,e){let n=vt(t,e);return n.data==null?Promise.resolve(null):nr(JSON.stringify(n.data))}function ir(t){return t==="inprogress"||t==="fixed"||t==="invalid"||t==="deleted"?t:void 0}function yo(t){if(t)return ir(t.triage)??(t.deleted?"deleted":void 0)}function bo(t){return t?!t.color&&!yo(t)&&!t.comment&&!t.fix&&!(t.ignoredReports&&t.ignoredReports.length>0)&&t.flagged===void 0:!0}function Ne(t){if(!t||typeof t!="object")return;let e=t,n={};typeof e.color=="string"&&e.color&&(n.color=e.color);let i=ir(e.triage)??(e.deleted?"deleted":void 0);if(i&&(n.triage=i),typeof e.comment=="string"&&e.comment&&(n.comment=e.comment),typeof e.fix=="string"&&e.fix&&(n.fix=e.fix),typeof e.flagged=="boolean"&&(n.flagged=e.flagged),Array.isArray(e.ignoredReports)){let r=e.ignoredReports.filter(o=>typeof o=="string"&&o.length>0);r.length>0&&(n.ignoredReports=r)}return bo(n)?void 0:n}var wo=["inprogress","fixed","invalid","deleted"];function vo(t){return typeof t=="string"&&wo.includes(t)}function Be(t){if(t===null)return null;if(typeof t!="object"||Array.isArray(t))return"invalid";let e=t,n={},i=e.color;if(i!=null){if(typeof i!="string"||i.length>50)return"invalid";i!==""&&(n.color=i)}let r=e.triage;if(r!=null){if(!vo(r))return"invalid";n.triage=r}for(let s of["comment","fix"]){let a=e[s];if(a!=null){if(typeof a!="string"||a.length>1e4)return"invalid";a!==""&&(n[s]=a)}}let o=e.flagged;if(o!=null){if(typeof o!="boolean")return"invalid";n.flagged=o}return n}async function sr(t,{session:e,confirmImport:n,...i}){if(e?.role!=="admin"||!e.csrfToken)throw new Error("An administrator session is required.");if(t!=null&&(typeof t!="object"||Array.isArray(t)))throw new Error("Invalid local triage.");let r=Object.create(null);for(let[d,p]of Object.entries(t??{})){let{ignoredReports:u,...m}=Ne(p)??{};Object.keys(m).length!==0&&(r[d]=m)}let o=Object.keys(r).length,s=new Set,a=[],c;if(o>0)do{i.signal?.throwIfAborted();let d="/api/admin/reports/finding-ids"+(c?`?after=${encodeURIComponent(c)}`:""),{reports:p,nextCursor:u}=await i.api.send(d);i.signal?.throwIfAborted();for(let m of p){let f=m.findingIds.filter(h=>Object.hasOwn(r,h)&&!s.has(h));f.length>0&&a.push({id:m.id,ids:f});for(let h of f)s.add(h)}c=u}while(c);for(let d of s){if(!d||d.length>100)throw new Error(`Triage finding IDs must be between 1 and ${100} characters.`);if(Be(r[d])==="invalid")throw new Error(`Triage for ${d} exceeds the managed server limits.`)}if(i.signal?.throwIfAborted(),n){let d=await n({matched:s.size,available:o});if(i.signal?.throwIfAborted(),!d)return null}let l=i.importedIds??new Set;for(let d of a)await _t(r,{...i,importedIds:l,ids:d.ids,path:`/api/admin/reports/${encodeURIComponent(d.id)}/import-triage`});return s.size}function xo(t,e){let n=[],i=Object.create(null);for(let[r,o]of Object.entries(t)){let s=e[r];if(!s)throw new Error("The server did not return the requested triage snapshot.");let a=s.entry??{},c=i[r]={...a};delete c.comment;for(let[l,d]of Object.entries(o))if(l==="comment"){if(s.comments.some(p=>p.body===d))continue;s.comments.length>0?n.push({id:r,property:l,local:s.comments.map(p=>p.body).join(`
54
+ `),i={id:t.finding_url,file:e,line:"?",severity:(t.severity||"medium").toLowerCase(),description:n,repo:{github:t.repository}};return t.commit_hash&&(i.commitHash=t.commit_hash),t.detected_at&&(i.detectedAt=t.detected_at),t.committed_at&&(i.committedAt=t.committed_at),x(i)}var mo=[["deepview-md",Pn],["deepsec",xn],["piolium",Jn],["claude-security",Wn]];function wt(t){return Array.isArray(t?.findings)?t.findings:Array.isArray(t?.groups)?t.groups:null}function er(t,e){return typeof e=="string"&&/\.csv$/iu.test(e)?"codex":Oe(t).format}function Oe(t){let e;try{let n=JSON.parse(t);if(wt(n)){for(let i of tr(wt(n)))x(i);return{data:n,format:"json",reason:null}}return{data:null,format:null,reason:"JSON, but not a report: no findings array"}}catch(n){e=n}for(let[n,i]of mo){let r=i(t);if(r)return{data:r,format:n,reason:null}}return{data:null,format:null,reason:`Not JSON, and not a recognized markdown format. (JSON error: ${e.message})`}}function tr(t){return t.flat().filter(e=>e&&typeof e=="object")}async function go(t){for(let i of t)x(i);let e=t.filter(i=>!i.id);if(e.length===0)return;let n=await Promise.all(e.map(sn));e.forEach((i,r)=>{n[r]&&(i.id=n[r])})}async function nr(t){let{data:e,format:n}=Oe(t);if(!e)return null;let i=tr(wt(e));return await go(i),{format:n,data:e,findings:i}}function vt(t,e){let n=t.trimStart().startsWith("[")?rn(t):null;if(n)return{data:{source:"links",findings:[],links:n.groups},format:"links",reason:null};let i=Oe(t);if(i.data!=null||er(t,e)!=="codex")return i;try{return{data:{type:"security",source:"codex-security",findings:bt(t).flatMap(o=>o.data.findings)},format:"codex",reason:null}}catch(r){return{data:null,format:null,reason:r instanceof Error?r.message:"Invalid Codex CSV"}}}function rr(t,e){let n=vt(t,e);return n.data==null?Promise.resolve(null):nr(JSON.stringify(n.data))}function ir(t){return t==="inprogress"||t==="fixed"||t==="invalid"||t==="deleted"?t:void 0}function yo(t){if(t)return ir(t.triage)??(t.deleted?"deleted":void 0)}function bo(t){return t?!t.color&&!yo(t)&&!t.comment&&!t.fix&&!(t.ignoredReports&&t.ignoredReports.length>0)&&t.flagged===void 0:!0}function Ne(t){if(!t||typeof t!="object")return;let e=t,n={};typeof e.color=="string"&&e.color&&(n.color=e.color);let i=ir(e.triage)??(e.deleted?"deleted":void 0);if(i&&(n.triage=i),typeof e.comment=="string"&&e.comment&&(n.comment=e.comment),typeof e.fix=="string"&&e.fix&&(n.fix=e.fix),typeof e.flagged=="boolean"&&(n.flagged=e.flagged),Array.isArray(e.ignoredReports)){let r=e.ignoredReports.filter(o=>typeof o=="string"&&o.length>0);r.length>0&&(n.ignoredReports=r)}return bo(n)?void 0:n}var wo=["inprogress","fixed","invalid","deleted"];function vo(t){return typeof t=="string"&&wo.includes(t)}function Be(t){if(t===null)return null;if(typeof t!="object"||Array.isArray(t))return"invalid";let e=t,n={},i=e.color;if(i!=null){if(typeof i!="string"||i.length>50)return"invalid";i!==""&&(n.color=i)}let r=e.triage;if(r!=null){if(!vo(r))return"invalid";n.triage=r}for(let s of["comment","fix"]){let a=e[s];if(a!=null){if(typeof a!="string"||a.length>1e4)return"invalid";a!==""&&(n[s]=a)}}let o=e.flagged;if(o!=null){if(typeof o!="boolean")return"invalid";n.flagged=o}return n}async function sr(t,{session:e,confirmImport:n,...i}){if(e?.role!=="admin"||!e.csrfToken)throw new Error("An administrator session is required.");if(t!=null&&(typeof t!="object"||Array.isArray(t)))throw new Error("Invalid local triage.");let r=Object.create(null);for(let[d,p]of Object.entries(t??{})){let{ignoredReports:u,...h}=Ne(p)??{};Object.keys(h).length!==0&&(r[d]=h)}let o=Object.keys(r).length,s=new Set,a=[],c;if(o>0)do{i.signal?.throwIfAborted();let d="/api/admin/reports/finding-ids"+(c?`?after=${encodeURIComponent(c)}`:""),{reports:p,nextCursor:u}=await i.api.send(d);i.signal?.throwIfAborted();for(let h of p){let f=h.findingIds.filter(m=>Object.hasOwn(r,m)&&!s.has(m));f.length>0&&a.push({id:h.id,ids:f});for(let m of f)s.add(m)}c=u}while(c);for(let d of s){if(!d||d.length>100)throw new Error(`Triage finding IDs must be between 1 and ${100} characters.`);if(Be(r[d])==="invalid")throw new Error(`Triage for ${d} exceeds the managed server limits.`)}if(i.signal?.throwIfAborted(),n){let d=await n({matched:s.size,available:o});if(i.signal?.throwIfAborted(),!d)return null}let l=i.importedIds??new Set;for(let d of a)await _t(r,{...i,importedIds:l,ids:d.ids,path:`/api/admin/reports/${encodeURIComponent(d.id)}/import-triage`});return s.size}function xo(t,e){let n=[],i=Object.create(null);for(let[r,o]of Object.entries(t)){let s=e[r];if(!s)throw new Error("The server did not return the requested triage snapshot.");let a=s.entry??{},c=i[r]={...a};delete c.comment;for(let[l,d]of Object.entries(o))if(l==="comment"){if(s.comments.some(p=>p.body===d))continue;s.comments.length>0?n.push({id:r,property:l,local:s.comments.map(p=>p.body).join(`
55
55
 
56
- `),imported:d}):c.comment=d}else if(a[l]!==void 0&&a[l]!==d){let p=u=>l==="flagged"?u?"flagged":"not flagged":u;n.push({id:r,property:l,local:p(a[l]),imported:p(d)})}else c[l]=d}return{entries:i,conflicts:n}}async function $o(t,e,n,i,r){r?.throwIfAborted();let{entries:o,conflicts:s}=xo(t,e);if(s.length===0)return o;let a=await i(s,n,{title:"Triage conflicts on import",intro:"disagree with stored triage on",trailingNote:"Imported comments are added alongside existing comments. Other choices apply to these finding IDs across all teams.",importedSideLabel:"Apply imported"});if(r?.throwIfAborted(),!a)throw new Error("Triage conflict resolution was cancelled.");for(let c of s){let l=a[`${c.id}:${c.property}`];if(!["local","imported"].includes(l))throw new Error("Resolve every triage conflict before importing.");l==="imported"&&(o[c.id][c.property]=t[c.id][c.property])}return o}function Eo(t,e){let n=[],i={entries:{},expected:{}};for(let[r,o]of Object.entries(t)){let s={entries:{...i.entries,[r]:o},expected:{...i.expected,[r]:e[r].version}};if(new TextEncoder().encode(JSON.stringify(s)).length<=262144){i=s;continue}if(Object.keys(i.entries).length===0)throw new Error("This triage entry is too large to import.");n.push(i),i={entries:{[r]:o},expected:{[r]:e[r].version}}}return Object.keys(i.entries).length>0&&n.push(i),n}async function _t(t,{api:e,path:n,ids:i=Object.keys(t),importedIds:r=new Set,lookup:o=new Map,resolveConflicts:s,signal:a}){i=i.filter(c=>Object.hasOwn(t,c)&&!r.has(c));for(let c=0;c<i.length;c+=200){let l=i.slice(c,c+200);for(let d=0;d<5&&l.length>0;d++){a?.throwIfAborted();let{snapshots:p}=await e.send(n,{findingIds:l}),u=Object.fromEntries(l.map(f=>[f,t[f]])),m=await $o(u,p,o,s,a);for(let f of Eo(m,p)){if(a?.throwIfAborted(),(await e.send(n,f)).conflict)break;Object.keys(f.entries).forEach(h=>r.add(h))}l=l.filter(f=>!r.has(f))}if(l.length>0)throw new Error("Stored triage keeps changing. Retry to resolve it against the latest values.")}}function ar(t){if(typeof t!="string")return{ok:!0,path:null};if(/\p{Cc}/u.test(t)||t.includes("\\")||t!==t.trim())return{ok:!1};let e=[];for(let i of t.split("/"))if(!(i===""||i===".")){if(i===".."||i!==i.trim())return{ok:!1};e.push(i)}let n=e.join("/");return n.length>500?{ok:!1}:{ok:!0,path:n===""?null:n}}async function cr(t,e){let n=new Uint8Array(await t.arrayBuffer());return be(n)?e({tryPassword:i=>Qe(n,i)}):n[0]===31&&n[1]===139?Qe(n):ve(new TextDecoder("utf-8",{fatal:!0}).decode(n))}async function lr(t,e){let n=new Map,i=[];for(let s of t.reports){if(typeof s?.name!="string"||!s.name||typeof s.content!="string")throw new Error("Every report must have a name and content.");let a=vt(s.content,s.name);if(!a.data)throw new Error(`${s.name}: ${a.reason??"Unsupported report"}`);let c=oe(a.data),l=c??oe(s)??oe({repo:{github:t.repoUrls?.[s.name]}}),d=e.find(m=>m.fullName.toLowerCase()===l?.toLowerCase())?.repoId??null,p=ar(a.data.repo?.directory);if(!p.ok)throw new Error(`${s.name}: invalid repository directory`);let u=a.format==="links"?[]:(await rr(s.content,s.name))?.findings??[];for(let m of u)m.id&&n.set(m.id,m);i.push({...s,repoId:d,directory:p.path??"",github:l,embedded:c,ids:[...new Set(u.map(m=>m.id).filter(Boolean))],uploaded:null})}let r=Object.create(null);if(t.triage!=null&&(typeof t.triage!="object"||Array.isArray(t.triage)))throw new Error("Invalid workspace triage.");for(let[s,a]of Object.entries(t.triage??{})){if(!n.has(s))continue;let c=Ne(a);if(!c)continue;let{ignoredReports:l,...d}=c;Object.keys(d).length!==0&&(r[s]=d)}let o=[];for(let s of t.bundleBlobs??[]){let a=Uint8Array.fromBase64(s.data),c=`sha512-${new Uint8Array(await crypto.subtle.digest("SHA-512",a)).toBase64()}`;if(c!==s.integrity)throw new Error(`${s.name}: bundle integrity mismatch`);o.push({name:s.name,integrity:c,bytes:a,uploaded:null})}return{name:t.workspace.name.slice(0,100),reports:i,bundles:o,triage:r,lookup:n,references:t.bundles??[],team:null,completed:new Set,importedIds:new Set}}function Ue(t,e,n){async function i(r,o,s={}){n?.throwIfAborted();let a=await t(r,{credentials:"same-origin",signal:n,...o===void 0?{}:{method:"POST",body:o instanceof File?o:JSON.stringify(o)},headers:{...o instanceof File?{}:{"content-type":"application/json"},"x-csrf-token":e.csrfToken,...s}});if(n?.throwIfAborted(),a.status===409)return{conflict:!0};if(!a.ok)throw new Error(`Import request failed (HTTP ${a.status}). You can retry the remaining steps.`);let c=await a.json();return n?.throwIfAborted(),c}return{send:i}}async function So(t,e,n,i,r,o){if(t.bundles.length===0&&t.references.length===0)return;let s=r??(await n.send("/api/admin/bundles")).bundles,a=new Set(t.bundles.map(l=>l.uploaded.id));if([...a].some(l=>!s.some(d=>d.id===l)))throw new Error("Could not verify the uploaded source bundles. Retry the import.");let c=new Set(t.references);for(let l of s){if(!a.has(l.id)&&!c.has(l.integrity))continue;let d=!o.has(l.repoId),p=d?e:l.repoId;d&&await i(`bundle-repo:${l.id}:${p}`,()=>n.send("/api/admin/bundles/set-repo",{bundleId:l.id,repoId:p}));let u=d?"":l.repoDirectory??"";await i(`repo:${p}:${u}`,()=>n.send("/api/admin/teams/set-repo",{teamId:t.team.id,repoId:p,path:u}))}}async function ur(t,{api:e,session:n,defaultRepo:i,includeTriage:r,resolveConflicts:o,signal:s,progress:a=()=>{}}){if(n?.role!=="admin"||!n.csrfToken)throw new Error("An administrator session is required.");if(!t.name.trim()||t.name.trim().length>100)throw new Error("Enter a team name of up to 100 characters.");if(r)for(let[u,m]of Object.entries(t.triage)){if(!u||u.length>100)throw new Error(`Triage finding IDs must be between 1 and ${100} characters. Choose Skip triage to import the files without it.`);if(Be(m)==="invalid")throw new Error(`Triage for ${u} exceeds the managed server limits. Choose Skip triage to import the files without it.`)}s?.throwIfAborted();let c=null;if(t.bundles.length===0){let u=new Set(t.references);c=u.size>0?(await e.send("/api/admin/bundles")).bundles.filter(m=>u.has(m.integrity)):[]}if(t.reports.length===0&&t.bundles.length===0&&c.length===0)throw new Error(t.references.length>0?"None of the referenced source bundles are available on the server. Export with bundle bytes included and try again.":"This workspace contains no report or bundle files.");let l=new Set((await e.send("/api/admin/repositories/browsable")).repos.map(u=>u.repoId));for(let u of t.reports){if(u.embedded&&!l.has(u.repoId))throw new Error(`Connect ${u.embedded} in Repositories before importing ${u.name}.`);if(!l.has(u.repoId)&&!l.has(i))throw new Error(`Choose an active repository for ${u.name}.`)}if((t.bundles.length>0||c.some(u=>!l.has(u.repoId)))&&!l.has(i))throw new Error("Choose an active repository for the source bundles.");let d=()=>s?.throwIfAborted(),p=async(u,m)=>{d(),t.completed.has(u)||(await m(),t.completed.add(u))};if(d(),!t.team){let u=await e.send("/api/admin/teams",{name:t.name.trim()});if(u.conflict)throw new Error("A team already has this name. Choose another name.");t.team=u}await p("member",()=>e.send("/api/admin/teams/set-member",{teamId:t.team.id,userId:n.id,security:!0,dependencies:!0}));for(let u of t.bundles)d(),a(`Importing ${u.name}\u2026`),u.uploaded||(u.uploaded=await e.send("/api/admin/bundles",new File([u.bytes],u.name),{"x-bundle-filename":encodeURIComponent(u.name),"x-repo-id":String(i)}));await So(t,i,e,p,c,l);for(let u of t.reports){d(),a(`Importing ${u.name}\u2026`);let m=l.has(u.repoId)?u.repoId:i;if(!u.uploaded){let g=await e.send("/api/admin/reports",new File([u.content],u.name),{"x-report-filename":encodeURIComponent(u.name),"x-repo-id":String(m),"x-repo-directory":encodeURIComponent(u.directory)});if(g.conflict)throw new Error(`Could not reuse the stored report ${u.name}. Retry the import.`);u.uploaded=g}let f=u.uploaded;l.has(f.repoId)||await p(`report-repo:${f.id}:${m}:${u.directory}`,async()=>{if((await e.send("/api/admin/reports/set-repo",{reportId:f.id,repoId:m,directory:u.directory})).conflict)throw new Error(`Could not assign the stored report ${u.name} to its repository.`);f.repoId=m,f.repoDirectory=u.directory});let h=f.repoDirectory??"";await p(`repo:${f.repoId}:${h}`,()=>e.send("/api/admin/teams/set-repo",{teamId:t.team.id,repoId:f.repoId,path:h})),r&&await _t(t.triage,{api:e,resolveConflicts:o,signal:s,ids:u.ids,importedIds:t.importedIds,lookup:t.lookup,path:`/api/admin/reports/${encodeURIComponent(u.uploaded.id)}/import-triage`}),await p(`publish:${u.uploaded.id}`,()=>e.send("/api/admin/reports/set-visible",{reportId:u.uploaded.id,visible:!0}))}return t.team}function dr(t){let e=()=>t.isEncryptionEnabled()&&!t.isUnlocked();return{get locked(){return e()},unlock:n=>t.unlockEncryption(n),async read({signal:n}={}){let i=!1,r=t.onVaultStateChange(()=>{i=!0}),o=()=>{if(n?.throwIfAborted(),e()||i)throw new Error("Local data was locked or changed. Unlock it and import triage again.")};try{o();let s=await t.readTriageBlob();return o(),s}finally{r()}}}}function De(t){let e=()=>t.isEncryptionEnabled()&&!t.isUnlocked();async function n(){let r=JSON.parse(await t.hydrateKey("deepview.workspaces")||"[]");return(Array.isArray(r)?r:r.workspaces??[]).filter(o=>typeof o.id=="string"&&typeof o.name=="string")}async function i(r,o){let s=!1,a=[t.onVaultStateChange,t.onFileMutated,t.onBundleMutated].map(l=>l(()=>{s=!0})),c=()=>{if(o?.throwIfAborted(),e()||s)throw new Error("Local data was locked or changed. Unlock it and select the workspace again.")};try{c();let l=await r(c);return c(),l}finally{a.forEach(l=>l())}}return{get locked(){return e()},unlock:r=>t.unlockEncryption(r),list:({signal:r}={})=>i(async()=>(await n()).map(o=>({id:o.id,name:o.name})),r),read:(r,{signal:o}={})=>i(async s=>{let a=(await n()).find(f=>f.id===r);if(!a)throw new Error("This local workspace no longer exists.");let c=JSON.stringify(a),l=JSON.parse(await t.hydrateKey("deepview.repoUrls")||"{}"),d=[];for(let f of a.reports??[]){s();let h=await t.withStoredItem("report",f,()=>t.readFile(f));s(),d.push({name:f,content:h,...l[f]?{repo:{github:l[f]}}:{}})}let p=await t.listBundles(),u=[];for(let f of a.bundles??[]){s();let h=p.find(b=>b.integrity===f);if(!h)continue;let g=await t.withStoredItem("bundle",f,()=>t.readBundle(f));s(),u.push({integrity:f,name:h.name,data:g.toBase64()})}let m=await t.readTriageBlob()??{};if(JSON.stringify((await n()).find(f=>f.id===r))!==c)throw new Error("The local workspace changed. Select it again.");return{version:1,workspace:{id:r,name:a.name,privateKey:""},reports:d,bundles:a.bundles??[],bundleBlobs:u,triage:m,repoUrls:l}},o)}}function Ao(t,e){if(customElements.get("managed-admin-import"))return;class n extends t{static styles=[W(jt),W(Vt)];static properties={localDeps:{attribute:!1},_busy:{state:!0},_error:{state:!0},_message:{state:!0},_plan:{state:!0},_catalog:{state:!0},_localOpen:{state:!0},_workspaces:{state:!0},_localId:{state:!0},_triage:{state:!0},_repo:{state:!0},_drag:{state:!0}};constructor(){super(),this._busy=!1,this._error="",this._message="",this._plan=null,this._catalog=null,this._workspaces=[],this._localOpen=!1,this._localId="",this._triage="",this._repo=null,this._files=[],this._drag=!1,this._local=!1,this._over=r=>{r.dataTransfer?.types?.includes("Files")&&(r.preventDefault(),this._drag=!0)},this._drop=r=>{r.dataTransfer?.types?.includes("Files")&&(r.preventDefault(),r.stopPropagation(),this._drag=!1,this._busy||(this._files.push(...r.dataTransfer.files),this._nextFile()))},this._localChanged=()=>{this._workspaces=[],this._localId="",!this._unlocking&&(this._local&&(this._plan=null),(this._local||this._importingTriage)&&(this._operation?.abort(),this._message="",this._error=this._importingTriage?"Local data changed or was locked. Import triage again to continue.":"Local data changed or was locked. Choose the workspace again."))},this._blur=()=>{this._readingLocal&&this._localChanged()}}connectedCallback(){super.connectedCallback(),this.addEventListener("dragover",this._over),this.addEventListener("drop",this._drop),globalThis.addEventListener("blur",this._blur),globalThis.addEventListener("storage",this._localChanged),this._offVault=this.localDeps?.onVaultStateChange(this._localChanged),this._loadCatalog()}disconnectedCallback(){this._operation?.abort(),this._offVault?.(),this._plan=null,this._files=[],this.removeEventListener("dragover",this._over),this.removeEventListener("drop",this._drop),globalThis.removeEventListener("blur",this._blur),globalThis.removeEventListener("storage",this._localChanged),super.disconnectedCallback()}updated(r){r.has("session")&&(this._role!=="admin"||r.get("session")?.id!==this.session?.id)&&(this._operation?.abort(),this._plan=null,this._files=[])}async _action(r){if(this._busy||this._role!=="admin")return;let o=this._operation=new AbortController,s=AbortSignal.any([o.signal,this.appState.sessionController.signal]);this._busy=!0,this._error="";try{await r(s),s.throwIfAborted()}catch(a){s.aborted||(this._error=String(a?.message??a))}finally{this._operation===o&&(this._busy=!1)}}async _loadCatalog(){if(this._role==="admin")try{await this._loadCollection("workspace-import:catalog","import options",async r=>{let o=Ue(e,this.session,r),[s,a,c]=await Promise.all([o.send("/api/admin/reports"),o.send("/api/admin/teams"),o.send("/api/admin/bundles")]);return{repos:s.repos,teams:a.teams,bundles:c.bundles}},r=>{this._catalog=r})}catch(r){this._error=String(r?.message??r)}}_browse(){let r=document.createElement("input");r.type="file",r.multiple=!0,r.accept=".enc,.gz,.json",r.addEventListener("change",()=>{this._files.push(...r.files),this._nextFile()},{once:!0}),r.click()}async _prepare(r,o){if(!r)return;if(this._catalog||await this._loadCatalog(),o.throwIfAborted(),!this._catalog)throw new Error("Could not load repositories. Try again.");let s=await lr(r,this._catalog.repos);o.throwIfAborted();let a=new Set(this._catalog.teams.map(p=>p.name)),c=s.name||"Imported workspace",l=2;for(;a.has(s.name);){let p=` (${l++})`;s.name=c.slice(0,100-p.length)+p}let d=new Set(s.reports.map(p=>p.repoId).filter(p=>p!=null));this._repo=d.size===1?[...d][0]:null,this._triage=Object.keys(s.triage).length>0?"":"skip",this._plan=s,this._message=""}async _nextFile(){if(this._files.length===0||this._busy)return;let r=this._files.shift();this._local=!1,this._plan=null,await this._action(async o=>{let s=await cr(r,this.promptPassword);o.throwIfAborted(),await this._prepare(s,o)})}async _unlock(r,o){this._unlocking=!0;try{return!r.locked||await r.unlock({signal:o})}finally{this._unlocking=!1}}async _chooseLocal(){this._localOpen=!0,await this._action(async r=>{let o=De(this.localDeps);await this._unlock(o,r)&&(r.throwIfAborted(),this._workspaces=await o.list({signal:r}))})}async _readLocal(){if(!this._localId)return;let r=this._localId;this._local=!0,this._plan=null,await this._action(async o=>{let s=De(this.localDeps);if(await this._unlock(s,o)){this._readingLocal=!0;try{await this._prepare(await s.read(r,{signal:o}),o)}finally{this._readingLocal=!1}}})}async _import(){!this._plan||!this._triage||!this._csrf||(await this._action(async r=>{if(this._local&&De(this.localDeps).locked)throw new Error("Unlock local data and choose the workspace again.");let o=this._plan,s=["teams","reports","bundles","history","workspace-import","scan-sources","repo-impact"];try{let a=await this.appState.mutate(()=>ur(o,{api:Ue(e,this.session,r),session:this.session,defaultRepo:this._repo,includeTriage:this._triage==="include",resolveConflicts:this.resolveConflicts,signal:r,progress:c=>{this._message=c}}),s);this._catalog.teams.push(a),this._message=`Imported into ${a.name}.`,this._plan=null}finally{this.appState.invalidate(s),o.team&&this.dispatchEvent(new CustomEvent("managed-import-complete",{bubbles:!0,composed:!0}))}}),!this._plan&&!this._error&&await this._nextFile())}async _importLocalTriage(){this._csrf&&await this._action(async r=>{this._importingTriage=!0,this._message="";let o=new Set,s=["reports","history"];try{let a=dr(this.localDeps);if(!await this._unlock(a,r))return;this._readingLocal=!0;let c;try{c=await a.read({signal:r})}finally{this._readingLocal=!1}let l=await sr(c,{api:Ue(e,this.session,r),session:this.session,resolveConflicts:this.resolveConflicts,signal:r,importedIds:o,confirmImport:async d=>(await this.confirmTriageImport({...d,signal:r}))?.confirmed===!0});if(r.throwIfAborted(),l===null)return;this._message=l?`Imported triage for ${l} finding${l===1?"":"s"}.`:"No local triage matches findings in managed reports."}finally{this._importingTriage=!1,this.appState.invalidate(s),o.size>0&&this.dispatchEvent(new CustomEvent("managed-import-complete",{bubbles:!0,composed:!0}))}})}render(){if(this._role!=="admin")return y;let r=this._plan,o=r?Object.keys(r.triage).length:0,s=new Set([...r?.references??[],...r?.bundles.map(l=>l.integrity)??[]]),a=(this._catalog?.bundles??[]).filter(l=>s.has(l.integrity)),c=r?.references.filter(l=>!r.bundles.some(d=>d.integrity===l)).length??0;return v`<div class="wrap" @dragleave="${()=>{this._drag=!1}}">${Pt("manage-import",this._role,this.allowShare)}<h1>Import</h1><section class="triage-import" aria-label="Local triage"><button type="button" class="btn" ?disabled="${this._busy||!this._csrf}" @click="${()=>this._importLocalTriage()}">Import triage</button><p>Import saved triage and comments for findings already in managed reports.<br>Unmatched data stays in this browser.<br>Conflicting values prompt for resolution; per-report ignores are skipped.</p></section><h2>Import workspace</h2><p class="intro ui-hint">Create a new team from a workspace export or a workspace stored in this browser.</p><section class="${`workspace-drop ${this._drag?"dragging":""}`}" aria-label="Workspace files"><strong>Drop workspace files here</strong><span>Encrypted exports, JSON, or compressed JSON. Encrypted files prompt for a password.</span><div class="actions"><button type="button" class="btn" ?disabled="${this._busy||!this._catalog}" @click="${()=>this._browse()}">Choose files</button> <button type="button" class="btn" ?disabled="${this._busy}" @click="${()=>this._chooseLocal()}">Choose local workspace</button></div></section>${this._localOpen?v`<section class="local-choice"><label for="local-workspace">Local workspace</label> <select id="local-workspace" .value="${this._localId}" ?disabled="${this._busy}" @change="${l=>{this._localId=l.target.value}}"><option value="">Choose a workspace…</option>${this._workspaces.map(l=>v`<option value="${l.id}">${l.name}</option>`)}</select> <button type="button" class="btn" ?disabled="${this._busy||!this._localId}" @click="${()=>this._readLocal()}">Select workspace</button> ${!this._busy&&this._workspaces.length===0?v`<p class="ui-hint">No unlocked local workspaces. Choose local workspace to unlock or refresh.</p>`:y}</section>`:y} ${r?v`<section class="import-preview" aria-label="Import options">${r.team?v`<p>Team ${r.team.name} has been created. Retry continues its remaining import steps.</p>`:y} <label for="import-team">New team name</label><input id="import-team" maxlength="100" .value="${r.name}" ?disabled="${this._busy||!!r.team}" @input="${l=>{r.name=l.target.value,this.requestUpdate()}}"><p>${r.reports.length} reports / links · ${s.size} source bundles · ${o} triaged findings</p><label for="import-repo">Repository for files and source bundles without an active repository</label> <select id="import-repo" .value="${String(this._repo??"")}" ?disabled="${this._busy||!!r.team}" @change="${l=>{this._repo=l.target.value?Number(l.target.value):null}}"><option value="" ?selected="${this._repo==null}">Choose a repository…</option>${(this._catalog?.repos??[]).map(l=>v`<option value="${String(l.repoId)}" ?selected="${this._repo===l.repoId}">${l.fullName}</option>`)}</select><p>Declared report repositories and directories are preserved. Stored reports without an active repository use the selected repository. The new team receives those repository paths; other published reports in the same paths are also visible to that team.</p><ul>${r.reports.map(l=>v`<li>${l.name}<span>${l.github??"Uses selected repository"}${l.embedded&&l.repoId==null?" \u2014 connect this repository first":""}</span></li>`)}</ul>${a.length>0?v`<p>Existing source bundles in active repositories keep their locations. The new team also receives access to those directories. Unassigned bundles and bundles in inactive repositories use the selected repository.</p><ul>${a.map(l=>v`<li>${l.filename}<span>${l.repoFullName?`${l.repoFullName}${l.repoDirectory?`/${l.repoDirectory}`:""}`:"Uses selected repository"}</span></li>`)}</ul>`:y} ${c?v`<p>${c} referenced source bundles have no bytes in this export. Reports can use matching bundles already on the server.</p>`:y} ${o?v`<fieldset ?disabled="${this._busy||!!r.team}"><legend>Import triage?</legend><label><input type="radio" name="import-triage" value="include" ?checked="${this._triage==="include"}" @change="${()=>{this._triage="include"}}"> Include triage and comments</label> <label><input type="radio" name="import-triage" value="skip" ?checked="${this._triage==="skip"}" @change="${()=>{this._triage="skip"}}"> Skip triage</label><p>Conflicting values prompt for resolution. Triage stays shared by finding ID across teams. Per-report local ignores are not imported.</p></fieldset>`:y} <button type="button" class="btn primary" ?disabled="${this._busy||!this._triage||!this._csrf}" @click="${()=>this._import()}">${this._busy?"Importing\u2026":r.team?"Retry remaining import":"Import workspace"}</button></section>`:y} ${this._message?v`<p role="status">${this._message}</p>`:y} ${this._error?v`<p class="error" role="alert">${this._error}${this._catalog?y:v`<button class="btn" @click="${()=>this._loadCatalog()}">Retry</button>`}</p>`:y} ${this._files.length>0&&!this._busy?v`<button class="btn" @click="${()=>this._nextFile()}">Next workspace file (${this._files.length} waiting)</button>`:y}</div>`}}customElements.define("managed-admin-import",n)}export{Ao as registerWorkspaceImport};
56
+ `),imported:d}):c.comment=d}else if(a[l]!==void 0&&a[l]!==d){let p=u=>l==="flagged"?u?"flagged":"not flagged":u;n.push({id:r,property:l,local:p(a[l]),imported:p(d)})}else c[l]=d}return{entries:i,conflicts:n}}async function $o(t,e,n,i,r){r?.throwIfAborted();let{entries:o,conflicts:s}=xo(t,e);if(s.length===0)return o;let a=await i(s,n,{title:"Triage conflicts on import",intro:"disagree with stored triage on",trailingNote:"Imported comments are added alongside existing comments. Other choices apply to these finding IDs across all teams.",importedSideLabel:"Apply imported"});if(r?.throwIfAborted(),!a)throw new Error("Triage conflict resolution was cancelled.");for(let c of s){let l=a[`${c.id}:${c.property}`];if(!["local","imported"].includes(l))throw new Error("Resolve every triage conflict before importing.");l==="imported"&&(o[c.id][c.property]=t[c.id][c.property])}return o}function Eo(t,e){let n=[],i={entries:{},expected:{}};for(let[r,o]of Object.entries(t)){let s={entries:{...i.entries,[r]:o},expected:{...i.expected,[r]:e[r].version}};if(new TextEncoder().encode(JSON.stringify(s)).length<=262144){i=s;continue}if(Object.keys(i.entries).length===0)throw new Error("This triage entry is too large to import.");n.push(i),i={entries:{[r]:o},expected:{[r]:e[r].version}}}return Object.keys(i.entries).length>0&&n.push(i),n}async function _t(t,{api:e,path:n,ids:i=Object.keys(t),importedIds:r=new Set,lookup:o=new Map,resolveConflicts:s,signal:a}){i=i.filter(c=>Object.hasOwn(t,c)&&!r.has(c));for(let c=0;c<i.length;c+=200){let l=i.slice(c,c+200);for(let d=0;d<5&&l.length>0;d++){a?.throwIfAborted();let{snapshots:p}=await e.send(n,{findingIds:l}),u=Object.fromEntries(l.map(f=>[f,t[f]])),h=await $o(u,p,o,s,a);for(let f of Eo(h,p)){if(a?.throwIfAborted(),(await e.send(n,f)).conflict)break;Object.keys(f.entries).forEach(m=>r.add(m))}l=l.filter(f=>!r.has(f))}if(l.length>0)throw new Error("Stored triage keeps changing. Retry to resolve it against the latest values.")}}function ar(t){if(typeof t!="string")return{ok:!0,path:null};if(/\p{Cc}/u.test(t)||t.includes("\\")||t!==t.trim())return{ok:!1};let e=[];for(let i of t.split("/"))if(!(i===""||i===".")){if(i===".."||i!==i.trim())return{ok:!1};e.push(i)}let n=e.join("/");return n.length>500?{ok:!1}:{ok:!0,path:n===""?null:n}}async function cr(t,e){let n=new Uint8Array(await t.arrayBuffer());return be(n)?e({tryPassword:i=>Qe(n,i)}):n[0]===31&&n[1]===139?Qe(n):ve(new TextDecoder("utf-8",{fatal:!0}).decode(n))}async function lr(t,e){let n=new Map,i=[];for(let s of t.reports){if(typeof s?.name!="string"||!s.name||typeof s.content!="string")throw new Error("Every report must have a name and content.");let a=vt(s.content,s.name);if(!a.data)throw new Error(`${s.name}: ${a.reason??"Unsupported report"}`);let c=oe(a.data),l=c??oe(s)??oe({repo:{github:t.repoUrls?.[s.name]}}),d=e.find(h=>h.fullName.toLowerCase()===l?.toLowerCase())?.repoId??null,p=ar(a.data.repo?.directory);if(!p.ok)throw new Error(`${s.name}: invalid repository directory`);let u=a.format==="links"?[]:(await rr(s.content,s.name))?.findings??[];for(let h of u)h.id&&n.set(h.id,h);i.push({...s,repoId:d,directory:p.path??"",github:l,embedded:c,ids:[...new Set(u.map(h=>h.id).filter(Boolean))],uploaded:null})}let r=Object.create(null);if(t.triage!=null&&(typeof t.triage!="object"||Array.isArray(t.triage)))throw new Error("Invalid workspace triage.");for(let[s,a]of Object.entries(t.triage??{})){if(!n.has(s))continue;let c=Ne(a);if(!c)continue;let{ignoredReports:l,...d}=c;Object.keys(d).length!==0&&(r[s]=d)}let o=[];for(let s of t.bundleBlobs??[]){let a=Uint8Array.fromBase64(s.data),c=`sha512-${new Uint8Array(await crypto.subtle.digest("SHA-512",a)).toBase64()}`;if(c!==s.integrity)throw new Error(`${s.name}: bundle integrity mismatch`);o.push({name:s.name,integrity:c,bytes:a,uploaded:null})}return{name:t.workspace.name.slice(0,100),reports:i,bundles:o,triage:r,lookup:n,references:t.bundles??[],team:null,completed:new Set,importedIds:new Set}}function Ue(t,e,n){async function i(r,o,s={}){n?.throwIfAborted();let a=await t(r,{credentials:"same-origin",signal:n,...o===void 0?{}:{method:"POST",body:o instanceof File?o:JSON.stringify(o)},headers:{...o instanceof File?{}:{"content-type":"application/json"},"x-csrf-token":e.csrfToken,...s}});if(n?.throwIfAborted(),a.status===409)return{conflict:!0};if(!a.ok)throw new Error(`Import request failed (HTTP ${a.status}). You can retry the remaining steps.`);let c=await a.json();return n?.throwIfAborted(),c}return{send:i}}async function So(t,e,n,i,r,o){if(t.bundles.length===0&&t.references.length===0)return;let s=r??(await n.send("/api/admin/bundles")).bundles,a=new Set(t.bundles.map(l=>l.uploaded.id));if([...a].some(l=>!s.some(d=>d.id===l)))throw new Error("Could not verify the uploaded source bundles. Retry the import.");let c=new Set(t.references);for(let l of s){if(!a.has(l.id)&&!c.has(l.integrity))continue;let d=!o.has(l.repoId),p=d?e:l.repoId;d&&await i(`bundle-repo:${l.id}:${p}`,()=>n.send("/api/admin/bundles/set-repo",{bundleId:l.id,repoId:p}));let u=d?"":l.repoDirectory??"";await i(`repo:${p}:${u}`,()=>n.send("/api/admin/teams/set-repo",{teamId:t.team.id,repoId:p,path:u}))}}async function ur(t,{api:e,session:n,defaultRepo:i,includeTriage:r,resolveConflicts:o,signal:s,progress:a=()=>{}}){if(n?.role!=="admin"||!n.csrfToken)throw new Error("An administrator session is required.");if(!t.name.trim()||t.name.trim().length>100)throw new Error("Enter a team name of up to 100 characters.");if(r)for(let[u,h]of Object.entries(t.triage)){if(!u||u.length>100)throw new Error(`Triage finding IDs must be between 1 and ${100} characters. Choose Skip triage to import the files without it.`);if(Be(h)==="invalid")throw new Error(`Triage for ${u} exceeds the managed server limits. Choose Skip triage to import the files without it.`)}s?.throwIfAborted();let c=null;if(t.bundles.length===0){let u=new Set(t.references);c=u.size>0?(await e.send("/api/admin/bundles")).bundles.filter(h=>u.has(h.integrity)):[]}if(t.reports.length===0&&t.bundles.length===0&&c.length===0)throw new Error(t.references.length>0?"None of the referenced source bundles are available on the server. Export with bundle bytes included and try again.":"This workspace contains no report or bundle files.");let l=new Set((await e.send("/api/admin/repositories/browsable")).repos.map(u=>u.repoId));for(let u of t.reports){if(u.embedded&&!l.has(u.repoId))throw new Error(`Connect ${u.embedded} in Repositories before importing ${u.name}.`);if(!l.has(u.repoId)&&!l.has(i))throw new Error(`Choose an active repository for ${u.name}.`)}if((t.bundles.length>0||c.some(u=>!l.has(u.repoId)))&&!l.has(i))throw new Error("Choose an active repository for the source bundles.");let d=()=>s?.throwIfAborted(),p=async(u,h)=>{d(),t.completed.has(u)||(await h(),t.completed.add(u))};if(d(),!t.team){let u=await e.send("/api/admin/teams",{name:t.name.trim()});if(u.conflict)throw new Error("A team already has this name. Choose another name.");t.team=u}await p("member",()=>e.send("/api/admin/teams/set-member",{teamId:t.team.id,userId:n.id,security:!0,dependencies:!0}));for(let u of t.bundles)d(),a(`Importing ${u.name}\u2026`),u.uploaded||(u.uploaded=await e.send("/api/admin/bundles",new File([u.bytes],u.name),{"x-bundle-filename":encodeURIComponent(u.name),"x-repo-id":String(i)}));await So(t,i,e,p,c,l);for(let u of t.reports){d(),a(`Importing ${u.name}\u2026`);let h=l.has(u.repoId)?u.repoId:i;if(!u.uploaded){let g=await e.send("/api/admin/reports",new File([u.content],u.name),{"x-report-filename":encodeURIComponent(u.name),"x-repo-id":String(h),"x-repo-directory":encodeURIComponent(u.directory)});if(g.conflict)throw new Error(`Could not reuse the stored report ${u.name}. Retry the import.`);u.uploaded=g}let f=u.uploaded;l.has(f.repoId)||await p(`report-repo:${f.id}:${h}:${u.directory}`,async()=>{if((await e.send("/api/admin/reports/set-repo",{reportId:f.id,repoId:h,directory:u.directory})).conflict)throw new Error(`Could not assign the stored report ${u.name} to its repository.`);f.repoId=h,f.repoDirectory=u.directory});let m=f.repoDirectory??"";await p(`repo:${f.repoId}:${m}`,()=>e.send("/api/admin/teams/set-repo",{teamId:t.team.id,repoId:f.repoId,path:m})),r&&await _t(t.triage,{api:e,resolveConflicts:o,signal:s,ids:u.ids,importedIds:t.importedIds,lookup:t.lookup,path:`/api/admin/reports/${encodeURIComponent(u.uploaded.id)}/import-triage`}),await p(`publish:${u.uploaded.id}`,()=>e.send("/api/admin/reports/set-visible",{reportId:u.uploaded.id,visible:!0}))}return t.team}function dr(t){let e=()=>t.isEncryptionEnabled()&&!t.isUnlocked();return{get locked(){return e()},unlock:n=>t.unlockEncryption(n),async read({signal:n}={}){let i=!1,r=t.onVaultStateChange(()=>{i=!0}),o=()=>{if(n?.throwIfAborted(),e()||i)throw new Error("Local data was locked or changed. Unlock it and import triage again.")};try{o();let s=await t.readTriageBlob();return o(),s}finally{r()}}}}function De(t){let e=()=>t.isEncryptionEnabled()&&!t.isUnlocked();async function n(){let r=JSON.parse(await t.hydrateKey("deepview.workspaces")||"[]");return(Array.isArray(r)?r:r.workspaces??[]).filter(o=>typeof o.id=="string"&&typeof o.name=="string")}async function i(r,o){let s=!1,a=[t.onVaultStateChange,t.onFileMutated,t.onBundleMutated].map(l=>l(()=>{s=!0})),c=()=>{if(o?.throwIfAborted(),e()||s)throw new Error("Local data was locked or changed. Unlock it and select the workspace again.")};try{c();let l=await r(c);return c(),l}finally{a.forEach(l=>l())}}return{get locked(){return e()},unlock:r=>t.unlockEncryption(r),list:({signal:r}={})=>i(async()=>(await n()).map(o=>({id:o.id,name:o.name})),r),read:(r,{signal:o}={})=>i(async s=>{let a=(await n()).find(f=>f.id===r);if(!a)throw new Error("This local workspace no longer exists.");let c=JSON.stringify(a),l=JSON.parse(await t.hydrateKey("deepview.repoUrls")||"{}"),d=[];for(let f of a.reports??[]){s();let m=await t.withStoredItem("report",f,()=>t.readFile(f));s(),d.push({name:f,content:m,...l[f]?{repo:{github:l[f]}}:{}})}let p=await t.listBundles(),u=[];for(let f of a.bundles??[]){s();let m=p.find(b=>b.integrity===f);if(!m)continue;let g=await t.withStoredItem("bundle",f,()=>t.readBundle(f));s(),u.push({integrity:f,name:m.name,data:g.toBase64()})}let h=await t.readTriageBlob()??{};if(JSON.stringify((await n()).find(f=>f.id===r))!==c)throw new Error("The local workspace changed. Select it again.");return{version:1,workspace:{id:r,name:a.name,privateKey:""},reports:d,bundles:a.bundles??[],bundleBlobs:u,triage:h,repoUrls:l}},o)}}function Ao(t,e){if(customElements.get("managed-admin-import"))return;class n extends t{static styles=[W(jt),W(Vt)];static properties={localDeps:{attribute:!1},_busy:{state:!0},_error:{state:!0},_message:{state:!0},_plan:{state:!0},_catalog:{state:!0},_localOpen:{state:!0},_workspaces:{state:!0},_localId:{state:!0},_triage:{state:!0},_repo:{state:!0},_drag:{state:!0}};constructor(){super(),this._busy=!1,this._error="",this._message="",this._plan=null,this._catalog=null,this._workspaces=[],this._localOpen=!1,this._localId="",this._triage="",this._repo=null,this._files=[],this._drag=!1,this._local=!1,this._over=r=>{r.dataTransfer?.types?.includes("Files")&&(r.preventDefault(),this._drag=!0)},this._drop=r=>{r.dataTransfer?.types?.includes("Files")&&(r.preventDefault(),r.stopPropagation(),this._drag=!1,this._busy||(this._files.push(...r.dataTransfer.files),this._nextFile()))},this._localChanged=()=>{this._workspaces=[],this._localId="",!this._unlocking&&(this._local&&(this._plan=null),(this._local||this._importingTriage)&&(this._operation?.abort(),this._message="",this._error=this._importingTriage?"Local data changed or was locked. Import triage again to continue.":"Local data changed or was locked. Choose the workspace again."))},this._blur=()=>{this._readingLocal&&this._localChanged()}}connectedCallback(){super.connectedCallback(),this.addEventListener("dragover",this._over),this.addEventListener("drop",this._drop),globalThis.addEventListener("blur",this._blur),globalThis.addEventListener("storage",this._localChanged),this._offVault=this.localDeps?.onVaultStateChange(this._localChanged),this._loadCatalog()}disconnectedCallback(){this._operation?.abort(),this._offVault?.(),this._plan=null,this._files=[],this.removeEventListener("dragover",this._over),this.removeEventListener("drop",this._drop),globalThis.removeEventListener("blur",this._blur),globalThis.removeEventListener("storage",this._localChanged),super.disconnectedCallback()}updated(r){r.has("session")&&(this._role!=="admin"||r.get("session")?.id!==this.session?.id)&&(this._operation?.abort(),this._plan=null,this._files=[])}async _action(r){if(this._busy||this._role!=="admin")return;let o=this._operation=new AbortController,s=AbortSignal.any([o.signal,this.appState.sessionController.signal]);this._busy=!0,this._error="";try{await r(s),s.throwIfAborted()}catch(a){s.aborted||(this._error=String(a?.message??a))}finally{this._operation===o&&(this._busy=!1)}}async _loadCatalog(){if(this._role==="admin")try{await this._loadCollection("workspace-import:catalog","import options",async r=>{let o=Ue(e,this.session,r),[s,a,c]=await Promise.all([o.send("/api/admin/reports"),o.send("/api/admin/teams"),o.send("/api/admin/bundles")]);return{repos:s.repos,teams:a.teams,bundles:c.bundles}},r=>{this._catalog=r})}catch(r){this._error=String(r?.message??r)}}_browse(){let r=document.createElement("input");r.type="file",r.multiple=!0,r.accept=".enc,.gz,.json",r.addEventListener("change",()=>{this._files.push(...r.files),this._nextFile()},{once:!0}),r.click()}async _prepare(r,o){if(!r)return;if(this._catalog||await this._loadCatalog(),o.throwIfAborted(),!this._catalog)throw new Error("Could not load repositories. Try again.");let s=await lr(r,this._catalog.repos);o.throwIfAborted();let a=new Set(this._catalog.teams.map(p=>p.name)),c=s.name||"Imported workspace",l=2;for(;a.has(s.name);){let p=` (${l++})`;s.name=c.slice(0,100-p.length)+p}let d=new Set(s.reports.map(p=>p.repoId).filter(p=>p!=null));this._repo=d.size===1?[...d][0]:null,this._triage=Object.keys(s.triage).length>0?"":"skip",this._plan=s,this._message=""}async _nextFile(){if(this._files.length===0||this._busy)return;let r=this._files.shift();this._local=!1,this._plan=null,await this._action(async o=>{let s=await cr(r,this.promptPassword);o.throwIfAborted(),await this._prepare(s,o)})}async _unlock(r,o){this._unlocking=!0;try{return!r.locked||await r.unlock({signal:o})}finally{this._unlocking=!1}}async _chooseLocal(){this._localOpen=!0,await this._action(async r=>{let o=De(this.localDeps);await this._unlock(o,r)&&(r.throwIfAborted(),this._workspaces=await o.list({signal:r}))})}async _readLocal(){if(!this._localId)return;let r=this._localId;this._local=!0,this._plan=null,await this._action(async o=>{let s=De(this.localDeps);if(await this._unlock(s,o)){this._readingLocal=!0;try{await this._prepare(await s.read(r,{signal:o}),o)}finally{this._readingLocal=!1}}})}async _import(){!this._plan||!this._triage||!this._csrf||(await this._action(async r=>{if(this._local&&De(this.localDeps).locked)throw new Error("Unlock local data and choose the workspace again.");let o=this._plan,s=["teams","reports","bundles","history","workspace-import","scan-sources","repo-impact"];try{let a=await this.appState.mutate(()=>ur(o,{api:Ue(e,this.session,r),session:this.session,defaultRepo:this._repo,includeTriage:this._triage==="include",resolveConflicts:this.resolveConflicts,signal:r,progress:c=>{this._message=c}}),s);this._catalog.teams.push(a),this._message=`Imported into ${a.name}.`,this._plan=null}finally{this.appState.invalidate(s),o.team&&this.dispatchEvent(new CustomEvent("managed-import-complete",{bubbles:!0,composed:!0}))}}),!this._plan&&!this._error&&await this._nextFile())}async _importLocalTriage(){this._csrf&&await this._action(async r=>{this._importingTriage=!0,this._message="";let o=new Set,s=["reports","history"];try{let a=dr(this.localDeps);if(!await this._unlock(a,r))return;this._readingLocal=!0;let c;try{c=await a.read({signal:r})}finally{this._readingLocal=!1}let l=await sr(c,{api:Ue(e,this.session,r),session:this.session,resolveConflicts:this.resolveConflicts,signal:r,importedIds:o,confirmImport:async d=>(await this.confirmTriageImport({...d,signal:r}))?.confirmed===!0});if(r.throwIfAborted(),l===null)return;this._message=l?`Imported triage for ${l} finding${l===1?"":"s"}.`:"No local triage matches findings in managed reports."}finally{this._importingTriage=!1,this.appState.invalidate(s),o.size>0&&this.dispatchEvent(new CustomEvent("managed-import-complete",{bubbles:!0,composed:!0}))}})}render(){if(this._role!=="admin")return y;let r=this._plan,o=r?Object.keys(r.triage).length:0,s=new Set([...r?.references??[],...r?.bundles.map(l=>l.integrity)??[]]),a=(this._catalog?.bundles??[]).filter(l=>s.has(l.integrity)),c=r?.references.filter(l=>!r.bundles.some(d=>d.integrity===l)).length??0;return v`<div class="wrap" @dragleave="${()=>{this._drag=!1}}">${Pt("manage-import",this._role,this.allowShare)}<h1>Import</h1><section class="triage-import" aria-label="Local triage"><button type="button" class="btn" ?disabled="${this._busy||!this._csrf}" @click="${()=>this._importLocalTriage()}">Import triage</button><p>Import saved triage and comments for findings already in managed reports.<br>Unmatched data stays in this browser.<br>Conflicting values prompt for resolution; per-report ignores are skipped.</p></section><h2>Import workspace</h2><p class="intro ui-hint">Create a new team from a workspace export or a workspace stored in this browser.</p><section class="${`workspace-drop ${this._drag?"dragging":""}`}" aria-label="Workspace files"><strong>Drop workspace files here</strong><span>Encrypted exports, JSON, or compressed JSON. Encrypted files prompt for a password.</span><div class="actions"><button type="button" class="btn" ?disabled="${this._busy||!this._catalog}" @click="${()=>this._browse()}">Choose files</button> <button type="button" class="btn" ?disabled="${this._busy}" @click="${()=>this._chooseLocal()}">Choose local workspace</button></div></section>${this._localOpen?v`<section class="local-choice"><label for="local-workspace">Local workspace</label> <select id="local-workspace" .value="${this._localId}" ?disabled="${this._busy}" @change="${l=>{this._localId=l.target.value}}"><option value="">Choose a workspace…</option>${this._workspaces.map(l=>v`<option value="${l.id}">${l.name}</option>`)}</select> <button type="button" class="btn" ?disabled="${this._busy||!this._localId}" @click="${()=>this._readLocal()}">Select workspace</button> ${!this._busy&&this._workspaces.length===0?v`<p class="ui-hint">No unlocked local workspaces. Choose local workspace to unlock or refresh.</p>`:y}</section>`:y} ${r?v`<section class="import-preview" aria-label="Import options">${r.team?v`<p>Team ${r.team.name} has been created. Retry continues its remaining import steps.</p>`:y} <label for="import-team">New team name</label><input id="import-team" maxlength="100" .value="${r.name}" ?disabled="${this._busy||!!r.team}" @input="${l=>{r.name=l.target.value,this.requestUpdate()}}"><p>${r.reports.length} reports / links · ${s.size} source bundles · ${o} triaged findings</p><label for="import-repo">Repository for files and source bundles without an active repository</label> <select id="import-repo" .value="${String(this._repo??"")}" ?disabled="${this._busy||!!r.team}" @change="${l=>{this._repo=l.target.value?Number(l.target.value):null}}"><option value="" ?selected="${this._repo==null}">Choose a repository…</option>${(this._catalog?.repos??[]).map(l=>v`<option value="${String(l.repoId)}" ?selected="${this._repo===l.repoId}">${l.fullName}</option>`)}</select><p>Declared report repositories and directories are preserved. Stored reports without an active repository use the selected repository. The new team receives those repository paths; other published reports in the same paths are also visible to that team.</p><ul>${r.reports.map(l=>v`<li>${l.name}<span>${l.github??"Uses selected repository"}${l.embedded&&l.repoId==null?" \u2014 connect this repository first":""}</span></li>`)}</ul>${a.length>0?v`<p>Existing source bundles in active repositories keep their locations. The new team also receives access to those directories. Unassigned bundles and bundles in inactive repositories use the selected repository.</p><ul>${a.map(l=>v`<li>${l.filename}<span>${l.repoFullName?`${l.repoFullName}${l.repoDirectory?`/${l.repoDirectory}`:""}`:"Uses selected repository"}</span></li>`)}</ul>`:y} ${c?v`<p>${c} referenced source bundles have no bytes in this export. Reports can use matching bundles already on the server.</p>`:y} ${o?v`<fieldset ?disabled="${this._busy||!!r.team}"><legend>Import triage?</legend><label><input type="radio" name="import-triage" value="include" ?checked="${this._triage==="include"}" @change="${()=>{this._triage="include"}}"> Include triage and comments</label> <label><input type="radio" name="import-triage" value="skip" ?checked="${this._triage==="skip"}" @change="${()=>{this._triage="skip"}}"> Skip triage</label><p>Conflicting values prompt for resolution. Triage stays shared by finding ID across teams. Per-report local ignores are not imported.</p></fieldset>`:y} <button type="button" class="btn primary" ?disabled="${this._busy||!this._triage||!this._csrf}" @click="${()=>this._import()}">${this._busy?"Importing\u2026":r.team?"Retry remaining import":"Import workspace"}</button></section>`:y} ${this._message?v`<p role="status">${this._message}</p>`:y} ${this._error?v`<p class="error" role="alert">${this._error}${this._catalog?y:v`<button class="btn" @click="${()=>this._loadCatalog()}">Retry</button>`}</p>`:y} ${this._files.length>0&&!this._busy?v`<button class="btn" @click="${()=>this._nextFile()}">Next workspace file (${this._files.length} waiting)</button>`:y}</div>`}}customElements.define("managed-admin-import",n)}export{Ao as registerWorkspaceImport};
57
57
  /*! Bundled license information:
58
58
 
59
59
  @lit/reactive-element/css-tag.js: